From 5dcac6d2e32d92c23d2bbd792a631f7938686b85 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 5 Jul 2023 09:55:47 +0000 Subject: [PATCH] common.mak: use a minimal assembly snippet to check for linker flags Use a minimal assembly snippet to check for linker flags. This has the advantage that it will work even if only the cross-toolchain is installed, but not, for example, stdlib. Using the C snippet, the check runs in a similar error like this: /usr/bin/s390x-linux-gnu-ld: cannot find crt1.o: No such file or directory /usr/bin/s390x-linux-gnu-ld: cannot find crti.o: No such file or directory /usr/bin/s390x-linux-gnu-ld: cannot find -lc: No such file or directory /usr/bin/s390x-linux-gnu-ld: cannot find crtn.o: No such file or directory Reviewed-by: Steffen Eiden Signed-off-by: Marc Hartmayer Signed-off-by: Steffen Eiden --- common.mak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.mak b/common.mak index f84628e8..71461acb 100644 --- a/common.mak +++ b/common.mak @@ -211,8 +211,8 @@ fi # Returns the linker option if available and nothing otherwise # define test_linker_flag -$(shell printf "int main(void) {return 0;}\n" | \ - ( $(CC) "-Wl,$1" -o /dev/null -x c - ) >/dev/null 2>&1 && printf -- '-Wl,%s' "$1") +$(shell printf ".globl _start\n_start:\nnop\n" | \ + ( $(CC) "-Wl,$1" -o /dev/null -nostdlib -x assembler -) >/dev/null 2>&1 && printf -- '-Wl,%s' "$1") endef NO_WARN_RWX_SEGMENTS_LDFLAGS := $(call test_linker_flag,"--no-warn-rwx-segments")