From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6178812D20F for ; Thu, 9 May 2024 22:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715295548; cv=none; b=BRqMEG2auHnqezPwSYdXmtc6v+KFD3x0R3lbxJvR2SHN/3K8bea1NIH9IU1C7yzBCyIuJK14MoA3cIBsi+CgE8fRs/w3EcoME6nofJXEerQQOUX35fLTtRJBMoGHBrJ9LY38fA/RRCDdtKuaA0CvORZ2QL7N2+i0vBgZIeHtMPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715295548; c=relaxed/simple; bh=6jtL8Tq51/6D1tJuPGm0Kl2FshQGs9RlrJmrJmmfe3k=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=QSbr13v8X/M+R8ijPOyzN2FOxPntZVsCrSnubjMBs4lolm1Q5bw5rfYHp7FV3KbkU3fYsNxtYPOs2TfWWvuXiQPMbGCtjpHhGDcKbohtiv9iUTw8NiG0YkJeALqVHLvr30nc0UzOXF7JecprlwH+HdoDCaPFIzwCrGQbr9Tx2Io= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=j08TbA+4; arc=none smtp.client-ip=209.85.208.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="j08TbA+4" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5724736770cso2398a12.1 for ; Thu, 09 May 2024 15:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715295545; x=1715900345; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=y1vau91hxBMnWZHVkH054+8jTk5Pa/DNJnVVz4HmL40=; b=j08TbA+4eLGw+ulUEWaupL0wgEo+IcJIKC1IAT1G1uR8jtJt0JcQbwjZbbrzP4KEQV 7n8/5WNKUeRGYLv3KXIp9UcqwVkFMFG4PEy+Ce+2sze3V1TFPLoj9RvbNI3sBXqDQEGw 9CzqWC0zpYfLZ2ty04pD4e+BwaVgrsCi1Ratin88wWMIKZkfMklkCGRj8BWjsDKfHCni G7JjZVoHCGKe2Nb4j6V9c06UW0gtVq1fILG7PVYqwzkPOixySzJgNhM/FrPm+r9uZzdF GKnIlFcgWg0c9Pc1Mcod5SGWbbDXEFWjlciZiw0e0Rzgb2kAEqds7a95UdWbDh86Jr2l PhSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715295545; x=1715900345; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y1vau91hxBMnWZHVkH054+8jTk5Pa/DNJnVVz4HmL40=; b=hbxti0XXBpnoFw/2Zvl2wfEzMi/Ufkxfn6ssAEvu4NidULoZwBrqmjrhhCwx3ORgyz TKpqUJmd/eDjtQtI5q9lXWd3+8/G68nOjTs7+dISStRr1XKlyEF9KMiTU62ZEef9hjl7 JWrQT+XxCiDzcm5sP36hJVx7p/y3wxhvVIcBxOves1uvZN9i8HGeLnX/MpmJFTNlizXW DYuO4kjqUnT5+Mgfuf2WJCUwf5rE9EiEf2JIqdXzLvRIkI8k+3V2Cr3UI4pU3N4QiYhd FKGotdXEIWTqC2dzjgBqzKeh9Xe49oieZgq2nkxkOmqWRF4T5TwGAmNp871uHAfZ1fca Hfkg== X-Forwarded-Encrypted: i=1; AJvYcCXG/7RduROH5ZJBh1sg61ZzFEZETmb4HMegTZf3O9KHslr8NXTIHsV1k2eGWWKl2KlP9f1hTUm5L4yB/JD8FFWaVhKax61T X-Gm-Message-State: AOJu0YyvXGdX5tXg7qVf0x3j6pS0Sf+bgtGLL68jGknU5i764GwH801j aVgM3xJOicQ1u43hVO2pGxPFnkawB3zotj2jzV+n6WBMpTm95DO+NkilWdeWfZ/YBaqcBCWbqJ+ QJHxm155MjovL2Xfi1ZozaK4Wnz4fTO/wz0bz X-Google-Smtp-Source: AGHT+IHuVFTFisfvrt55ub+8UO4+Id1LOVWeasU97gGretbq/QA6WW4CiikvBa7AfpTXmMMad1SbRPJ/2IdczDaT84s= X-Received: by 2002:a50:8d84:0:b0:572:e6fb:ab07 with SMTP id 4fb4d7f45d1cf-5735203906fmr30811a12.7.1715295542981; Thu, 09 May 2024 15:59:02 -0700 (PDT) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240509200022.253089-1-edliaw@google.com> <20240509200022.253089-4-edliaw@google.com> <0e196143-c0bf-4d70-9735-7e6d9a69ea8f@nvidia.com> In-Reply-To: <0e196143-c0bf-4d70-9735-7e6d9a69ea8f@nvidia.com> From: Edward Liaw Date: Thu, 9 May 2024 15:58:35 -0700 Message-ID: Subject: Re: [PATCH v3 03/68] selftests: Compile with -D_GNU_SOURCE when including lib.mk To: John Hubbard Cc: shuah@kernel.org, =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= , =?UTF-8?Q?G=C3=BCnther_Noack?= , Christian Brauner , Richard Cochran , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Andrew Morton , Muhammad Usama Anjum , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@android.com, linux-security-module@vger.kernel.org, netdev@vger.kernel.org, linux-riscv@lists.infradead.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 9, 2024 at 2:25=E2=80=AFPM John Hubbard w= rote: > > On 5/9/24 12:57 PM, Edward Liaw wrote: > > lib.mk will add -D_GNU_SOURCE to CFLAGS by default. This will make it > > unnecessary to add #define _GNU_SOURCE in the source code. > > > > Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX") > > Suggested-by: John Hubbard > > Signed-off-by: Edward Liaw > > --- > > tools/testing/selftests/Makefile | 4 ++-- > > tools/testing/selftests/lib.mk | 5 ++++- > > 2 files changed, 6 insertions(+), 3 deletions(-) > > > > Hi Edward, > > This looks good, with one small refactoring opportunity remaining, though= : > > > diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests= /Makefile > > index f0431e6cb67e..9039f3709aff 100644 > > --- a/tools/testing/selftests/Makefile > > +++ b/tools/testing/selftests/Makefile > > @@ -170,11 +170,11 @@ ifneq ($(KBUILD_OUTPUT),) > > # $(realpath ...) resolves symlinks > > abs_objtree :=3D $(realpath $(abs_objtree)) > > BUILD :=3D $(abs_objtree)/kselftest > > - KHDR_INCLUDES :=3D -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include > > + KHDR_INCLUDES :=3D -isystem ${abs_objtree}/usr/include > > else > > BUILD :=3D $(CURDIR) > > abs_srctree :=3D $(shell cd $(top_srcdir) && pwd) > > - KHDR_INCLUDES :=3D -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include > > + KHDR_INCLUDES :=3D -isystem ${abs_srctree}/usr/include > > As mentioned in [1] (but there are a lot of patches to manage here, and > I think it got overlooked), you could factor out the duplicated > -D_GNU_SOURCE items into a single place: Hi John, Here I'm reverting the change I made to the Makefile in patch 1/68, since -D_GNU_SOURCE is being added directly to CFLAGS now, I didn't think it was necessary to add it to KHDR_INCLUDES anymore. I would have merged the two patches together, but since the first and second patches from v2 were already merged, I thought I should leave them in the series. Thanks, Edward > > [1] > https://lore.kernel.org/all/ac8c217e-4109-4ca7-a7dd-fc4fc8b0a4de@nvidia.c= om/ > > thanks, > -- > John Hubbard > NVIDIA > > > DEFAULT_INSTALL_HDR_PATH :=3D 1 > > endif > > > > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/l= ib.mk > > index 3023e0e2f58f..e782f4c96aee 100644 > > --- a/tools/testing/selftests/lib.mk > > +++ b/tools/testing/selftests/lib.mk > > @@ -67,7 +67,7 @@ MAKEFLAGS +=3D --no-print-directory > > endif > > > > ifeq ($(KHDR_INCLUDES),) > > -KHDR_INCLUDES :=3D -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include > > +KHDR_INCLUDES :=3D -isystem $(top_srcdir)/usr/include > > endif > > > > # In order to use newer items that haven't yet been added to the user= 's system > > @@ -188,6 +188,9 @@ endef > > clean: $(if $(TEST_GEN_MODS_DIR),clean_mods_dir) > > $(CLEAN) > > > > +# Build with _GNU_SOURCE by default > > +CFLAGS +=3D -D_GNU_SOURCE > > + > > # Enables to extend CFLAGS and LDFLAGS from command line, e.g. > > # make USERCFLAGS=3D-Werror USERLDFLAGS=3D-static > > CFLAGS +=3D $(USERCFLAGS) > >