Skip to content

Commit daef47b

Browse files
edliawshuahkh
authored andcommitted
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. Commit 8092162 ("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. Fixed up commit log: Shuah Khan <skhan@linuxfoundation.org> Fixes: 8092162 ("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 Signed-off-by: Edward Liaw <edliaw@google.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: Shuah Khan <skhan@linuxfoundation.org>
1 parent 14d28ec commit daef47b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

tools/testing/selftests/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ ifneq ($(KBUILD_OUTPUT),)
161161
# $(realpath ...) resolves symlinks
162162
abs_objtree := $(realpath $(abs_objtree))
163163
BUILD := $(abs_objtree)/kselftest
164-
KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
164+
KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include
165165
else
166166
BUILD := $(CURDIR)
167167
abs_srctree := $(shell cd $(top_srcdir) && pwd)
168-
KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
168+
KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include
169169
DEFAULT_INSTALL_HDR_PATH := 1
170170
endif
171171

tools/testing/selftests/kselftest_harness.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#define __KSELFTEST_HARNESS_H
5252

5353
#ifndef _GNU_SOURCE
54-
#define _GNU_SOURCE
54+
static_assert(0, "kselftest harness requires _GNU_SOURCE to be defined");
5555
#endif
5656
#include <asm/types.h>
5757
#include <ctype.h>

tools/testing/selftests/lib.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
5353
top_srcdir = $(selfdir)/../../..
5454

5555
ifeq ($(KHDR_INCLUDES),)
56-
KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
56+
KHDR_INCLUDES := -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include
5757
endif
5858

5959
# The following are built by lib.mk common compile rules.

0 commit comments

Comments
 (0)