mirror of https://github.com/torvalds/linux.git
kbuild: allow architectures to override CC_CAN_LINK
The generic test for CC_CAN_LINK assumes that all architectures use -m32 and -m64 to switch between 32-bit and 64-bit compilation. This is overly simplistic. Architectures may use other flags (-mabi, -m31, etc.) or may also require byte order handling (-mlittle-endian, -EL). Expressing all of the different possibilities will be very complicated and brittle. Instead allow architectures to supply their own logic which will be easy to understand and evolve. Both the boolean ARCH_HAS_CC_CAN_LINK and the string ARCH_USERFLAGS need to be implemented as kconfig does not allow the reuse of string options. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Reviewed-by: Nicolas Schier <nsc@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Link: https://patch.msgid.link/20251114-kbuild-userprogs-bits-v3-3-4dee0d74d439@linutronix.de Signed-off-by: Nicolas Schier <nsc@kernel.org>
This commit is contained in:
parent
80623f2c83
commit
deab487e0f
13
Makefile
13
Makefile
|
|
@ -1137,8 +1137,17 @@ ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),)
|
||||||
LDFLAGS_vmlinux += --emit-relocs --discard-none
|
LDFLAGS_vmlinux += --emit-relocs --discard-none
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Align the bit size of userspace programs with the kernel
|
# Align the architecture of userspace programs with the kernel
|
||||||
USERFLAGS_FROM_KERNEL := -m32 -m64 --target=%
|
USERFLAGS_FROM_KERNEL := --target=%
|
||||||
|
|
||||||
|
ifdef CONFIG_ARCH_USERFLAGS
|
||||||
|
KBUILD_USERCFLAGS += $(CONFIG_ARCH_USERFLAGS)
|
||||||
|
KBUILD_USERLDFLAGS += $(CONFIG_ARCH_USERFLAGS)
|
||||||
|
else
|
||||||
|
# If not overridden also inherit the bit size
|
||||||
|
USERFLAGS_FROM_KERNEL += -m32 -m64
|
||||||
|
endif
|
||||||
|
|
||||||
KBUILD_USERCFLAGS += $(filter $(USERFLAGS_FROM_KERNEL), $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
|
KBUILD_USERCFLAGS += $(filter $(USERFLAGS_FROM_KERNEL), $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
|
||||||
KBUILD_USERLDFLAGS += $(filter $(USERFLAGS_FROM_KERNEL), $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
|
KBUILD_USERLDFLAGS += $(filter $(USERFLAGS_FROM_KERNEL), $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,12 @@ config RUSTC_LLVM_VERSION
|
||||||
int
|
int
|
||||||
default $(rustc-llvm-version)
|
default $(rustc-llvm-version)
|
||||||
|
|
||||||
|
config ARCH_HAS_CC_CAN_LINK
|
||||||
|
bool
|
||||||
|
|
||||||
config CC_CAN_LINK
|
config CC_CAN_LINK
|
||||||
bool
|
bool
|
||||||
|
default ARCH_CC_CAN_LINK if ARCH_HAS_CC_CAN_LINK
|
||||||
default $(cc_can_link_user,$(m64-flag)) if 64BIT
|
default $(cc_can_link_user,$(m64-flag)) if 64BIT
|
||||||
default $(cc_can_link_user,$(m32-flag))
|
default $(cc_can_link_user,$(m32-flag))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue