Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] selftests/nolibc: explicitly disable position independent executables
@ 2026-10-17 22:02 Thomas Weißschuh
  2026-10-18  4:37 ` Willy Tarreau
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Weißschuh @ 2026-10-17 22:02 UTC (permalink / raw)
  To: Willy Tarreau, Shuah Khan, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt
  Cc: linux-kselftest, linux-kernel, llvm, Thomas Weißschuh

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 <linux@weissschuh.net>
---
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 <linux@weissschuh.net>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftests/nolibc: explicitly disable position independent executables
  2026-10-17 22:02 [PATCH] selftests/nolibc: explicitly disable position independent executables Thomas Weißschuh
@ 2026-10-18  4:37 ` Willy Tarreau
  0 siblings, 0 replies; 2+ messages in thread
From: Willy Tarreau @ 2026-10-18  4:37 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, linux-kselftest, linux-kernel, llvm

Hi Thomas,

On Sun, Oct 18, 2026 at 12:02:18AM +0200, Thomas Weißschuh wrote:
> 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.

Interesting, I didn't know about these options.

> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> 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.

Sounds good.

Reviewed-by: Willy Tarreau <w@1wt.eu>

Willy

> ---
>  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 <linux@weissschuh.net>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-18  4:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-17 22:02 [PATCH] selftests/nolibc: explicitly disable position independent executables Thomas Weißschuh
2026-10-18  4:37 ` Willy Tarreau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox