arch/lkl: use a common helper to determine OUTPUT_FORMAT

The existing scripts work for GCC but restrict LLVM builds to
elf64-x86-64 only. The new cc-objdump-file-format.sh helper script works
with both gcc/clang and objdump/llvm-objdump for CC and OBJDUMP
respectively.

Signed-off-by: David Disseldorp <ddiss@suse.de>
This commit is contained in:
David Disseldorp
2025-06-03 23:47:00 +10:00
parent 83549bf8e6
commit 464dd4bd08
2 changed files with 11 additions and 4 deletions

View File

@@ -38,8 +38,7 @@ config LKL_LINE_COV
config OUTPUT_FORMAT
string "Output format"
default $(shell,$(LD) -r -print-output-format) if LD_IS_BFD
default $(shell,test "$(CROSS_COMPILE)" = "x86_64-linux-gnu" && echo "elf64-x86-64" || echo "unsupported-llvm") if LD_IS_LLD
default $(shell,$(srctree)/arch/lkl/scripts/cc-objdump-file-format.sh)
config ARCH_DMA_ADDR_T_64BIT
def_bool 64BIT
@@ -49,8 +48,8 @@ config PHYS_ADDR_T_64BIT
config 64BIT
bool "64bit kernel"
default y if OUTPUT_FORMAT = "pe-x86-64" || OUTPUT_FORMAT = "elf64-x86-64"
default $(success,$(LD) -r -print-output-format|grep -q '^elf64-') if LD_IS_BFD && OUTPUT_FORMAT != "pe-x86-64" && OUTPUT_FORMAT != "elf64-x86-64"
default y if OUTPUT_FORMAT = "pe-x86-64"
default $(success,$(srctree)/arch/lkl/scripts/cc-objdump-file-format.sh|grep -q '^elf64-') if OUTPUT_FORMAT != "pe-x86-64"
config MMU
bool "LKL MMU implementation"

View File

@@ -0,0 +1,8 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# Print the C compiler output file format, as determined by objdump.
t=`mktemp` || exit 1
echo 'void foo(void) {}' | $CC -x c - -c -o "$t" \
&& $OBJDUMP -p "$t" | awk '/file format/ {print $4}'
rm "$t"