nolibc does not support position independent executables (PIE).
However a toolchain might generate these by default depending on various
circumstances. Recently clang started to do so for hexagon. See LLVM
commit ab43cb8520c0 ("[Hexagon] Pass -pie to linker when PIE is the
toolchain default (#189723)").

As clang can also be configured to create PIE for other architectures by
default disable it globally. While we are at it also pass the argument
for GCC to be on the safe side.

If PIE is disabled already, clang will generate
-Wunused-command-line-argument warnings. Inhibit those.

Signed-off-by: Thomas Weißschuh <[email protected]>
---
I ran into this when testing the upcoming PR to Linus.
The referenced LLVM commit was released between when I wrote the hexagon
support and today. My plan is to fold this patch into the PR.
---
 tools/testing/selftests/nolibc/Makefile.include | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/nolibc/Makefile.include 
b/tools/testing/selftests/nolibc/Makefile.include
index ea520eac64a6..14e51c821d8a 100644
--- a/tools/testing/selftests/nolibc/Makefile.include
+++ b/tools/testing/selftests/nolibc/Makefile.include
@@ -8,6 +8,7 @@ _CFLAGS_SANITIZER ?= $(call cc-option,-fsanitize=undefined 
-fsanitize-trap=all)
 CFLAGS_NOLIBC_TEST  ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 
-ggdb \
                -W -Wall -Wextra -Wundef -Wwrite-strings \
                $(call cc-option,-fno-stack-protector) $(call 
cc-option,-Wmissing-prototypes) \
+               $(call cc-option,--start-no-unused-arguments) -no-pie $(call 
cc-option,--end-no-unused-arguments) \
                $(_CFLAGS_STACKPROTECTOR) $(_CFLAGS_SANITIZER)
 
 NOLIBC_TEST_SOURCES := nolibc-test.c nolibc-test-linkage.c 
nolibc-test-ignore-errno.c

---
base-commit: f9532b372e415e8198287ce010efa22f337857b5
change-id: 20261017-nolibc-unused-arguments-b504fc061c46

Best regards,
--  
Thomas Weißschuh <[email protected]>


Reply via email to