[PATCH 2/8] selftests: x86: check_initial_reg_state: remove -no-pie while using -static

From: Muhammad Usama Anjum
Date: Wed May 01 2024 - 08:29:55 EST


The -static clang flag ignores -no-pie flag. Hence following warning is
generated. Fix the warning by removing the -no-pie flag before
specifying -static flag.

clang: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]

Signed-off-by: Muhammad Usama Anjum <usama.anjum@xxxxxxxxxxxxx>
---
tools/testing/selftests/x86/Makefile | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index 671b1819694ff..b0f5b5ff79b8d 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -108,8 +108,9 @@ $(OUTPUT)/test_syscall_vdso_32: thunks_32.S
# check_initial_reg_state is special: it needs a custom entry, and it
# needs to be static so that its interpreter doesn't destroy its initial
# state.
-$(OUTPUT)/check_initial_reg_state_32: CFLAGS += -Wl,-ereal_start -static
-$(OUTPUT)/check_initial_reg_state_64: CFLAGS += -Wl,-ereal_start -static
+CFLAGS2:=$(filter-out -no-pie,$(CFLAGS))
+$(OUTPUT)/check_initial_reg_state_32: CFLAGS2 += -Wl,-ereal_start -static
+$(OUTPUT)/check_initial_reg_state_64: CFLAGS2 += -Wl,-ereal_start -static

$(OUTPUT)/nx_stack_32: CFLAGS += -Wl,-z,noexecstack
$(OUTPUT)/nx_stack_64: CFLAGS += -Wl,-z,noexecstack
--
2.39.2