[PATCH v3] x86/Kconfig: Implement ARCH_HAS_CC_CAN_LINK

From: Thomas Weißschuh

Date: Mon Mar 16 2026 - 11:58:16 EST


The generic CC_CAN_LINK detection using -m32/-m64 does not work for all
architectures and is going to be removed in favor of
architecture-specific logic.

Implement such an architecture specific detection for x86 which mirrors
the existing generic implementation, as the generic implementation
was tailored after x86 originally.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
---
Changes in v3:
- Rephrase commit message.
- Link to v2: https://lore.kernel.org/r/20260227-cc-can-link-x86-v2-1-dae7dfcb1a19@xxxxxxxxxxxxx

Changes in v2:
- Rebase on v7.0-rc1
- Link to v1: https://lore.kernel.org/r/20251222-cc-can-link-x86-v1-1-b7c11d77a8d1@xxxxxxxxxxxxx
---
arch/x86/Kconfig | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e2df1b147184..192b592b647c 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -73,6 +73,7 @@ config X86
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if (PGTABLE_LEVELS > 2) && (X86_64 || X86_PAE)
select ARCH_ENABLE_THP_MIGRATION if X86_64 && TRANSPARENT_HUGEPAGE
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
+ select ARCH_HAS_CC_CAN_LINK
select ARCH_HAS_CPU_ATTACK_VECTORS if CPU_MITIGATIONS
select ARCH_HAS_CACHE_LINE_SIZE
select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
@@ -3185,6 +3186,16 @@ config HAVE_ATOMIC_IOMAP
def_bool y
depends on X86_32

+config ARCH_CC_CAN_LINK
+ bool
+ default $(cc_can_link_user,-m64) if 64BIT
+ default $(cc_can_link_user,-m32)
+
+config ARCH_USERFLAGS
+ string
+ default "-m64" if 64BIT
+ default "-m32"
+
source "arch/x86/kvm/Kconfig"

source "arch/x86/Kconfig.cpufeatures"

---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-cc-can-link-x86-fa7a15eec4db

Best regards,
--
Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>