Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1255878lqj; Mon, 3 Jun 2024 15:42:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWdgGbPcQpeQCalFJct/FQoH4QLsxfT0tevNNw/CReAqDJHqSOJ36ESoEuKg+NHPnZ2kReAK+GcRXcl7g6DmsFw7PhqfDwE3xafUW6O8w== X-Google-Smtp-Source: AGHT+IFylyxsqo3L/mQAlTdHtHCO4w0/IAvXnm0PV3+F8C4tA8pmAH7S0m8dc6I+rdeKUGhKUv7p X-Received: by 2002:a17:903:1105:b0:1f6:803a:83fe with SMTP id d9443c01a7336-1f6803a85c6mr34912135ad.46.1717454576690; Mon, 03 Jun 2024 15:42:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717454576; cv=pass; d=google.com; s=arc-20160816; b=LXCKyjJp7Pvzt2uAyVk76u+x0B6S4Nb2IsWVOmVOo/b/ucILOUGi90c7kGKJrSAb3i EO9seSV5nsqrXDVUx2myUavDWLfkhnjYKNM82v7nqdlPhRM3XoEo80kvfg37rAi4oLYT cbOGCCWpHrWw5mUriujMGF05lku8veQIxBlKic6RJuX6tQ36maOkLefNDi0xm2DDhPB0 /MDHLnFBcqlGGUSgr/aEHTQJgD462UkCntCfiIeAxva2gXazYeYuKJty76Pq71idHWc4 HPktAuGFX3GkZcrl10qbQpknrnAp+RAjezTcCYl3P+Jf3jnmX9Lnwqjd+vD6Py6RbBCa PBRQ== 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=K3F+XYSrGqJRWeTKwOmnRj0qXcs3EWDk4E8Twm6tPIWDGSg9UmZFZHuKSTVQwNKlVr 4S0qm3znSNcf2DCDfq0jlU6N8EOmd1WOrdQezQwXNaUviZEYoR58LG3iQmgsx4O4MKOf 2C8G8wyANMVOFzhCsWGwK2qbh5lO9WoW34eua6b7J0bpgk8kdkx3TRRqIEY2fZ/a2nIt ih69xsGYSN+HYxSLAUm1LI6CGMLEKvtzwuImUtM1zaqhu84eZIyRofwOudIFVBX9UsKB 5ofH66rUzZ8qPGaVB6aYCBUCPYYC+OWflVtzWM7wDFR1GFsrYeRrR1O01p5p088fGKrf k/Ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rKdXUaQR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f63233d1c7si4397925ad.85.2024.06.03.15.42.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 15:42:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rKdXUaQR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199780-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B79FB28AE17 for ; Mon, 3 Jun 2024 22:42:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CD0013D27F; Mon, 3 Jun 2024 22:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rKdXUaQR" 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 6233913CF8C; Mon, 3 Jun 2024 22:38:45 +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=1717454325; cv=none; b=kh05UyleZED1bcakYbpTGI09zn/F3EXipnJqFnd2a9kw8Lls2fr89mPOMmyG08vMBeDuSwdCFr5qaRiqSFDZtAvhvJLdpTmHlzPSua64Jy60usIcJA2frL1bvTZ/qBWEZ3ykjZ3DXlyB1rvSFJn7rGvjWxZtg2lCVL+5nEcWSgM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717454325; 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=YIcDdytHajxim/hwb7g4Zr6ptQgLw1y+ZwC5hzBWnkibiQeMr5+fLRw3YxIzP750cBN8Mrd9OjacTRKW1b7Sz4PgQxEts9sMhzvtT6fndlCOMQ34jCAW3xDjBrk/bR4wdlFB2o/32EXY0loYeT0yU1aR4kqW3r3QYqAZbCAlSF4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rKdXUaQR; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FA92C32782; Mon, 3 Jun 2024 22:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717454325; bh=Z+G2URdAE+kmdHSr/8skjh3bJVro0KDIDCAh486xYiM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rKdXUaQRJ3opA5KUc8AATNQzmSia68LZJ5y/27WyX08yfghsqDAfTq7x/bMjBviF/ 3l/pCxxqTgoIRtFBkoNR7aXnhy2/v4xllFaIiuwlpQX70EI2JfAwXcbr9iAq1VeTRg Yu/z6Rb5hopIbWWBX1/+DK1cb0dQOpHoeOX7IUzQmS0VRwyyeQW+DzCVmTP64DTfy2 fJ5MjC5QIyqk0fea1D80PttExxpEahpl5e102vbfi2oPZT2XNgA7qfUh/DxlCBAvrb Se8S/NHlnnkB1s4kESGDJn6PE6NPdYRNfTtinGMCC4KDws5eTjGct0yHwodGNBcXi7 +oEEqUxEMgCMw== Date: Mon, 3 Jun 2024 15:38:43 -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: <20240603223843.GD1802995@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 > >