LKML Archive mirror
 help / color / mirror / Atom feed
From: Edward Liaw <edliaw@google.com>
To: shuah@kernel.org, "Mickaël Salaün" <mic@digikod.net>,
	"Günther Noack" <gnoack@google.com>,
	"Christian Brauner" <brauner@kernel.org>,
	"Richard Cochran" <richardcochran@gmail.com>,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Jesper Dangaard Brouer" <hawk@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Andy Lutomirski" <luto@amacapital.net>,
	"Will Drewry" <wad@chromium.org>,
	"Muhammad Usama Anjum" <usama.anjum@collabora.com>,
	"Edward Liaw" <edliaw@google.com>,
	"Andrew Morton" <akpm@linux-foundation.org>
Cc: 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,  kernel test robot <oliver.sang@intel.com>,
	Mark Brown <broonie@kernel.org>,
	 John Hubbard <jhubbard@nvidia.com>
Subject: [PATCH v3 01/68] selftests: Compile kselftest headers with -D_GNU_SOURCE
Date: Thu,  9 May 2024 19:57:53 +0000	[thread overview]
Message-ID: <20240509200022.253089-2-edliaw@google.com> (raw)
In-Reply-To: <20240509200022.253089-1-edliaw@google.com>

Add the -D_GNU_SOURCE flag to KHDR_INCLUDES so that it is defined in a
central location.

809216233555 ("selftests/harness: remove use of LINE_MAX") introduced
asprintf into kselftest_harness.h, which is a GNU extension and needs
_GNU_SOURCE to either be defined prior to including headers or with the
-D_GNU_SOURCE flag passed to the compiler.

Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202404301040.3bea5782-oliver.sang@intel.com
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Edward Liaw <edliaw@google.com>
---
 tools/testing/selftests/Makefile            | 4 ++--
 tools/testing/selftests/kselftest_harness.h | 2 +-
 tools/testing/selftests/lib.mk              | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 9039f3709aff..f0431e6cb67e 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -170,11 +170,11 @@ ifneq ($(KBUILD_OUTPUT),)
   # $(realpath ...) resolves symlinks
   abs_objtree := $(realpath $(abs_objtree))
   BUILD := $(abs_objtree)/kselftest
-  KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
+  KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include
 else
   BUILD := $(CURDIR)
   abs_srctree := $(shell cd $(top_srcdir) && pwd)
-  KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
+  KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include
   DEFAULT_INSTALL_HDR_PATH := 1
 endif
 
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 7612bf09c5f8..31b2c70a2be2 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -51,7 +51,7 @@
 #define __KSELFTEST_HARNESS_H
 
 #ifndef _GNU_SOURCE
-#define _GNU_SOURCE
+static_assert(0, "kselftest harness requires _GNU_SOURCE to be defined");
 #endif
 #include <asm/types.h>
 #include <ctype.h>
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 429535816dbd..3023e0e2f58f 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -67,7 +67,7 @@ MAKEFLAGS += --no-print-directory
 endif
 
 ifeq ($(KHDR_INCLUDES),)
-KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
+KHDR_INCLUDES := -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include
 endif
 
 # In order to use newer items that haven't yet been added to the user's system
-- 
2.45.0.118.g7fe29c98d7-goog


  reply	other threads:[~2024-05-09 20:00 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09 19:57 [PATCH v3 00/68] Define _GNU_SOURCE for sources using Edward Liaw
2024-05-09 19:57 ` Edward Liaw [this message]
2024-05-09 19:57 ` [PATCH v3 02/68] selftests/sgx: Include KHDR_INCLUDES in Makefile Edward Liaw
2024-05-09 19:57 ` [PATCH v3 03/68] selftests: Compile with -D_GNU_SOURCE when including lib.mk Edward Liaw
2024-05-09 21:25   ` John Hubbard
2024-05-09 22:58     ` Edward Liaw
2024-05-09 19:57 ` [PATCH v3 04/68] selftests/arm64: Drop define _GNU_SOURCE Edward Liaw
2024-05-09 19:57 ` [PATCH v3 05/68] selftests/arm64: Drop duplicate -D_GNU_SOURCE Edward Liaw
2024-05-09 19:57 ` [PATCH v3 06/68] selftests/bpf: Drop define _GNU_SOURCE Edward Liaw
2024-05-09 19:57 ` [PATCH v3 07/68] selftests/breakpoints: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 08/68] selftests/cachestat: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 09/68] selftests/capabilities: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 10/68] selftests/cgroup: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 11/68] selftests/clone3: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 12/68] selftests/core: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 13/68] selftests/damon: " Edward Liaw
2024-05-09 20:31   ` SeongJae Park
2024-05-09 21:19     ` Edward Liaw
2024-05-09 19:58 ` [PATCH v3 14/68] selftests/drivers: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 15/68] selftests/exec: Drop duplicate -D_GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 16/68] selftests/fchmodat2: Drop define _GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 17/68] selftests/filelock: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 18/68] selftests/filesystems: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 19/68] selftests/firmware: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 20/68] selftests/fpu: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 21/68] selftests/futex: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 22/68] selftests/futex: Drop duplicate -D_GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 23/68] selftests/intel_pstate: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 24/68] selftests/iommu: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 25/68] selftests/ipc: Drop define _GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 26/68] selftests/kcmp: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 27/68] selftests/landlock: " Edward Liaw
2024-05-13  5:11   ` Mickaël Salaün
2024-05-09 19:58 ` [PATCH v3 28/68] selftests/lsm: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 29/68] selftests/membarrier: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 30/68] selftests/memfd: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 31/68] selftests/mincore: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 32/68] selftests/mm: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 33/68] selftests/mount: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 34/68] selftests/mount_setattr: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 35/68] selftests/move_mount_set_group: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 36/68] selftests/mqueue: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 37/68] selftests/net: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 38/68] selftests/net: Drop duplicate -D_GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 39/68] selftests/nolibc: Drop define _GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 40/68] selftests/nsfs: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 41/68] selftests/openat2: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 42/68] selftests/perf_events: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 43/68] selftests/pid_namespace: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 44/68] selftests/pidfd: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 45/68] selftests/ptrace: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 46/68] selftests/powerpc: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 47/68] selftests/proc: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 48/68] selftests/proc: Drop duplicate -D_GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 49/68] selftests/ptp: Drop define _GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 50/68] selftests/resctrl: Drop duplicate -D_GNU_SOURCE Edward Liaw
2024-05-09 22:22   ` Reinette Chatre
2024-05-09 19:58 ` [PATCH v3 51/68] selftests/riscv: Drop define _GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 52/68] selftests/riscv: Drop duplicate -D_GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 53/68] selftests/rlimits: Drop define _GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 54/68] selftests/rseq: " Edward Liaw
2024-05-09 20:16   ` Mathieu Desnoyers
2024-05-09 21:19     ` Edward Liaw
2024-05-09 19:58 ` [PATCH v3 55/68] selftests/safesetid: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 56/68] selftests/sched: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 57/68] selftests/seccomp: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 58/68] selftests/sigaltstack: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 59/68] selftests/splice: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 60/68] selftests/syscall_user_dispatch: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 61/68] selftests/thermal: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 62/68] selftests/timens: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 63/68] selftests/tmpfs: Drop duplicate -D_GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 64/68] selftests/uevent: Drop define _GNU_SOURCE Edward Liaw
2024-05-09 19:58 ` [PATCH v3 65/68] selftests/user_events: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 66/68] selftests/vDSO: " Edward Liaw
2024-05-09 19:58 ` [PATCH v3 67/68] selftests/wireguard: " Edward Liaw
2024-05-09 19:59 ` [PATCH v3 68/68] selftests/x86: " Edward Liaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240509200022.253089-2-edliaw@google.com \
    --to=edliaw@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=broonie@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=gnoack@google.com \
    --cc=hawk@kernel.org \
    --cc=jhubbard@nvidia.com \
    --cc=john.fastabend@gmail.com \
    --cc=keescook@chromium.org \
    --cc=kernel-team@android.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mic@digikod.net \
    --cc=netdev@vger.kernel.org \
    --cc=oliver.sang@intel.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=richardcochran@gmail.com \
    --cc=shuah@kernel.org \
    --cc=usama.anjum@collabora.com \
    --cc=wad@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).