Skip to content

Commit

Permalink
selftests: Compile kselftest headers with -D_GNU_SOURCE
Browse files Browse the repository at this point in the history
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 <[email protected]>

Fixes: 8092162 ("selftests/harness: remove use of LINE_MAX")
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-lkp/[email protected]
Signed-off-by: Edward Liaw <[email protected]>
Reviewed-by: Muhammad Usama Anjum <[email protected]>
Reviewed-by: Mark Brown <[email protected]>
Reviewed-by: John Hubbard <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
edliaw authored and shuahkh committed May 8, 2024
1 parent 14d28ec commit daef47b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,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

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/kselftest_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/lib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
top_srcdir = $(selfdir)/../../..

ifeq ($(KHDR_INCLUDES),)
KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
KHDR_INCLUDES := -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include
endif

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

0 comments on commit daef47b

Please sign in to comment.