Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

efi/libstub: Add $(CLANG_FLAGS) to x86 flags

When cross compiling x86 on an ARM machine with clang, there are several
errors along the lines of:

arch/x86/include/asm/page_64.h:52:7: error: invalid output constraint '=D' in asm

This happens because the x86 flags in the EFI stub are not derived from
KBUILD_CFLAGS like the other architectures are and the clang flags that
set the target architecture ('--target=') and the path to the GNU cross
tools ('--prefix=') are not present, meaning that the host architecture
is targeted.

These flags are available as $(CLANG_FLAGS) from the main Makefile so
add them to the cflags for x86 so that cross compiling works as expected.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lkml.kernel.org/r/20210326000435.4785-4-nathan@kernel.org

authored by

Nathan Chancellor and committed by
Borislav Petkov
58d746c1 d5cbd80e

+2 -1
+2 -1
drivers/firmware/efi/libstub/Makefile
··· 13 13 -Wno-pointer-sign \ 14 14 $(call cc-disable-warning, address-of-packed-member) \ 15 15 $(call cc-disable-warning, gnu) \ 16 - -fno-asynchronous-unwind-tables 16 + -fno-asynchronous-unwind-tables \ 17 + $(CLANG_FLAGS) 17 18 18 19 # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly 19 20 # disable the stackleak plugin