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 <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2023-07-05 09:55:47 +00:00
committed by Steffen Eiden
parent 552772d2a9
commit 5dcac6d2e3

View File

@@ -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")