Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1255712lqj; Mon, 3 Jun 2024 15:42:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUCzcY40EihEhZtAB/eXS3Y/Vlib7XYZ+mMveH/BKKXzHBkLhjkvyduC5LVcqJ+MIOMkTOKA++4nuoqbXJ5gB5fP2tWOyfQ/Ln9La3SOQ== X-Google-Smtp-Source: AGHT+IFJ9NIWXsCMVRNP97UYXw5/R0wW/cUyIBwLDlYM+np2cAjD52hrgjeT76KmD+AE4XQeG2Tc X-Received: by 2002:a50:ab5b:0:b0:57a:31c6:69d1 with SMTP id 4fb4d7f45d1cf-57a363a138dmr6762530a12.12.1717454550009; Mon, 03 Jun 2024 15:42:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717454549; cv=pass; d=google.com; s=arc-20160816; b=Po/vmNz7RiyB0hKSkG/ILS3+0LxkN/5iFIMsHT1UOrUsLk/tKxfA+LZmcvV59gP599 mP8UdIgnFJ+XTX4bhf50CFagIyJgQ3LDo+f67qy2ZXa3c7DJjmj63Xx0Fi0K9G6kVDQR s99h91qXYB6VdJDnzAfDGiUZEgLDQgQiwd7k5iH3lRbvx8P1mdxNRMaUgZudt692/eIc 7aaVgYQlKBgrgj5t/OBsXHRcht5tXd8VIsIYXzVoCPuC84Zc6tWMX6K2FVGsBCZrhWYs b8QCHdTHRQT6Rz0So9GNO7RU1ZTxK3S1B/cyh74Xz2wUvXvS7gI3RCyRJ8Rolbj8w54O daSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sRbYJguplUjb2+TBLC7FsNBlaUmMKPgr8GA/e+v90bQ=; fh=n3d9c0DAe079qv40NmUfVNZ6k80Is2VpzgjHO/i/jzs=; b=ZdGqBrFo4YMTa2tZp/GPG+anR8TXDxchSDKUvVIdDi0W6Uw8FXDb2nSakflednU024 ipdOng8xLt8CZ4LqAe96oIPr65CpTsUefivZFsv+SMMkBf3qUjyExEdnOCWgYAO3mruZ DRAaUPkkPG+HDThUFXXLPuCzl8XzO/YhG9PNeEQ27EE/7QHgFo/M14M2c6safVclR4Db UsxzeBb0kJoapsjJyNVMvQ7qeXrR6M5c2yze4peItDQ5OSmyu/QB8GeqErSQew6yE9UC K33rOGdSXWTIaKUdBno8AgNk3GP11jHa5JDLV+Wt0IyWTv7edLQO7XaiAOfxd68hfHiR WWCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uVXHcW9P; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199782-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c76a06si4263285a12.440.2024.06.03.15.42.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 15:42:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uVXHcW9P; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199782-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B94301F24030 for ; Mon, 3 Jun 2024 22:42:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED12313D51D; Mon, 3 Jun 2024 22:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uVXHcW9P" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D23513D2B7; Mon, 3 Jun 2024 22:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717454353; cv=none; b=rvrU9weeZUtrtFa8euDLrvbl6JHcFWwkPmVQ8JhZLdjPpc9nZ1Yjujye66AItcMBsPP0I20FKKS/z8ixgMwMBiFmAdGP1rgxC+vIBDKa3pjsXDscOHWuIG4konnLvfjQYu9pFXbk2Y8hhyRnQPs5WcSJOW/igoR+2IeODKJT9/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717454353; c=relaxed/simple; bh=Z+G2URdAE+kmdHSr/8skjh3bJVro0KDIDCAh486xYiM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DHAM+Xor2dg9jzn75KY8KU+8hSP/vZrDnQ1ZnUP/0Rzwt/YHayT/+7T9rhPiDco+Pt+W1yXf2TcsEV0lCZzwKiXH4DQ6mVwagHXFt2eRl9a3Ugtyi6iCDu5HGDdLrDE13NavrjE9qBSh8gEuSI7s7GeHHswQP7W/SaO9aF5TvC8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uVXHcW9P; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA255C2BD10; Mon, 3 Jun 2024 22:39:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717454352; bh=Z+G2URdAE+kmdHSr/8skjh3bJVro0KDIDCAh486xYiM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uVXHcW9PiJf7iVxSRzDLRDlGTQwU4kajjnu8dPUyQZpyTJBLzIW9ezi2O3FbRbk+4 hw8NIo8kMpfXPObWG1hHq+9lK9a4kGFVN2tIpOStiunijT4tHmvRu8ctyLxVSZi+ou oDwOCyx4v/r+/dhPWAUBq6ngKoO6tIU/zQRyv5ZIyqQoO8/7Z/tTMWfzlmjD6ghoBH JKftMwiW3iUFNRs/cidHwashUXC1f5szjZ5Eq+20nSsPrku86AzQhpgSwV/I4lpT1y Cni7ogH8KozMS8+xL3jMJne3JWcf4qBiCtAqhbqsqiiiYWeO2bz61+ThuawOCS9jUt x8ioO7qqHMxUg== Date: Mon, 3 Jun 2024 15:39:10 -0700 From: Nathan Chancellor To: John Hubbard Cc: Shuah Khan , Andrew Morton , Ilpo =?iso-8859-1?Q?J=E4rvinen?= , Maciej Wieczor-Retman , Ryan Roberts , Christian Brauner , Muhammad Usama Anjum , Alexey Gladkov , Valentin Obst , linux-kselftest@vger.kernel.org, LKML , llvm@lists.linux.dev Subject: Re: [PATCH v2 1/2] selftests/openat2: fix clang build failures: -static-libasan, LOCAL_HDRS Message-ID: <20240603223910.GE1802995@thelio-3990X> References: <20240601014534.268360-1-jhubbard@nvidia.com> <20240601014534.268360-2-jhubbard@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240601014534.268360-2-jhubbard@nvidia.com> On Fri, May 31, 2024 at 06:45:33PM -0700, John Hubbard wrote: > When building with clang via: > > make LLVM=1 -C tools/testing/selftests > > two distinct failures occur: > > 1) gcc requires -static-libasan in order to ensure that Address > Sanitizer's library is the first one loaded. However, this leads to > build failures on clang, when building via: > > make LLVM=1 -C tools/testing/selftests > > However, clang already does the right thing by default: it statically > links the Address Sanitizer if -fsanitize is specified. Therefore, fix > this by simply omitting -static-libasan for clang builds. And leave > behind a comment, because the whole reason for static linking might not > be obvious. > > 2) clang won't accept invocations of this form, but gcc will: > > $(CC) file1.c header2.h > > Fix this by using selftests/lib.mk facilities for tracking local header > file dependencies: add them to LOCAL_HDRS, leaving only the .c files to > be passed to the compiler. > > Reviewed-by: Ryan Roberts > Signed-off-by: John Hubbard Assuming that $(LLVM) is the correct conditional to test for: Reviewed-by: Nathan Chancellor > --- > tools/testing/selftests/openat2/Makefile | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/openat2/Makefile b/tools/testing/selftests/openat2/Makefile > index 254d676a2689..185dc76ebb5f 100644 > --- a/tools/testing/selftests/openat2/Makefile > +++ b/tools/testing/selftests/openat2/Makefile > @@ -1,8 +1,18 @@ > # SPDX-License-Identifier: GPL-2.0-or-later > > -CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan > +CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined > TEST_GEN_PROGS := openat2_test resolve_test rename_attack_test > > +# gcc requires -static-libasan in order to ensure that Address Sanitizer's > +# library is the first one loaded. However, clang already statically links the > +# Address Sanitizer if -fsanitize is specified. Therefore, simply omit > +# -static-libasan for clang builds. > +ifeq ($(LLVM),) > + CFLAGS += -static-libasan > +endif > + > +LOCAL_HDRS += helpers.h > + > include ../lib.mk > > -$(TEST_GEN_PROGS): helpers.c helpers.h > +$(TEST_GEN_PROGS): helpers.c > -- > 2.45.1 > >