[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240509200022.253089-2-edliaw@google.com>
Date: Thu, 9 May 2024 19:57:53 +0000
From: Edward Liaw <edliaw@...gle.com>
To: shuah@...nel.org, "Mickaël Salaün" <mic@...ikod.net>,
"Günther Noack" <gnoack@...gle.com>, Christian Brauner <brauner@...nel.org>,
Richard Cochran <richardcochran@...il.com>, Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
"David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>, John Fastabend <john.fastabend@...il.com>,
Kees Cook <keescook@...omium.org>, Andy Lutomirski <luto@...capital.net>,
Will Drewry <wad@...omium.org>, Muhammad Usama Anjum <usama.anjum@...labora.com>,
Edward Liaw <edliaw@...gle.com>, Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
kernel-team@...roid.com, linux-security-module@...r.kernel.org,
netdev@...r.kernel.org, linux-riscv@...ts.infradead.org, bpf@...r.kernel.org,
kernel test robot <oliver.sang@...el.com>, Mark Brown <broonie@...nel.org>,
John Hubbard <jhubbard@...dia.com>
Subject: [PATCH v3 01/68] selftests: Compile kselftest headers with -D_GNU_SOURCE
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@...el.com>
Closes: https://lore.kernel.org/oe-lkp/202404301040.3bea5782-oliver.sang@intel.com
Reviewed-by: Muhammad Usama Anjum <usama.anjum@...labora.com>
Reviewed-by: Mark Brown <broonie@...nel.org>
Reviewed-by: John Hubbard <jhubbard@...dia.com>
Signed-off-by: Edward Liaw <edliaw@...gle.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
Powered by blists - more mailing lists