From df5ea255b1ebb95968de57d4ea966e9e4ac71fcf Mon Sep 17 00:00:00 2001 From: LeeYoungJoon Date: Mon, 21 Jul 2025 15:58:16 +0900 Subject: [PATCH 1/4] [FMV][AArch64] Fix missing FMV defines for AArch64 in LNT Makefile Add conditional CFLAGS definitions for AArch64 targets to support FMV-related behavior on Darwin and Linux platforms. - Adds -DHAS_DARWIN_FMV when ARCH=AArch64 and TARGET_OS=Darwin - Adds -DHAS_LINUX_FMV when ARCH=AArch64 and TARGET_OS=Linux This change fixes build errors when running LNT tests on AArch64 systems with platform-specific FMV handling. --- SingleSource/Benchmarks/Misc/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/SingleSource/Benchmarks/Misc/Makefile b/SingleSource/Benchmarks/Misc/Makefile index 5256ac43bf..43b21fc238 100644 --- a/SingleSource/Benchmarks/Misc/Makefile +++ b/SingleSource/Benchmarks/Misc/Makefile @@ -12,6 +12,15 @@ PROGRAMS_TO_SKIP := dt endif endif +ifeq ($(ARCH),AArch64) +ifeq ($(TARGET_OS),Darwin) +CFLAGS += -DHAS_DARWIN_FMV +endif +ifeq ($(TARGET_OS),Linux) +CFLAGS += -DHAS_LINUX_FMV +endif +endif + ifeq ($(ARCH),Mips) RUNTIMELIMIT := 2000 endif From ac0c956dc4bfd7be9c76e3406668fa247a98b772 Mon Sep 17 00:00:00 2001 From: LeeYoungJoon Date: Wed, 23 Jul 2025 14:40:43 +0900 Subject: [PATCH 2/4] [FMV][AArch64] Fix Undefined Symbol error in LNT Makefile build - Adds a pre-build check in the Makefile for the __init_cpu_features_resolver, __init_cpu_features symbol. - The result is used to define CHECK_FMV (HAS_DARWIN_FMV, HAS_LINUX_FMV), which conditionally compiles the platform-specific code in aarch64-init-cpu-features.c --- SingleSource/Benchmarks/Misc/Makefile | 24 ++++++++++++++----- .../Misc/aarch64-init-cpu-features.c | 6 +++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/SingleSource/Benchmarks/Misc/Makefile b/SingleSource/Benchmarks/Misc/Makefile index 43b21fc238..d683f65011 100644 --- a/SingleSource/Benchmarks/Misc/Makefile +++ b/SingleSource/Benchmarks/Misc/Makefile @@ -13,12 +13,24 @@ endif endif ifeq ($(ARCH),AArch64) -ifeq ($(TARGET_OS),Darwin) -CFLAGS += -DHAS_DARWIN_FMV -endif -ifeq ($(TARGET_OS),Linux) -CFLAGS += -DHAS_LINUX_FMV -endif + ifeq ($(TARGET_OS),Darwin) + CHECK_FMV := $(shell echo "void __init_cpu_features_resolver(void);" > CheckHasAArch64FMV.h && \ + $(CC) -c -x c CheckHasAArch64FMV.h -o CheckHasAArch64FMV.o 2>/dev/null && \ + echo yes || echo no; \ + rm -f CheckHasAArch64FMV.h CheckHasAArch64FMV.o) + ifeq ($(CHECK_FMV),yes) + CFLAGS += -DHAS_DARWIN_FMV + endif + endif + ifeq ($(TARGET_OS),Linux) + CHECK_FMV := $(shell echo "void __init_cpu_features(void);" > CheckHasAArch64FMV.h && \ + $(CC) -c -x c CheckHasAArch64FMV.h -o CheckHasAArch64FMV.o 2>/dev/null && \ + echo yes || echo no; \ + rm -f CheckHasAArch64FMV.h CheckHasAArch64FMV.o) + ifeq ($(CHECK_FMV),yes) + CFLAGS += -DHAS_LINUX_FMV + endif + endif endif ifeq ($(ARCH),Mips) diff --git a/SingleSource/Benchmarks/Misc/aarch64-init-cpu-features.c b/SingleSource/Benchmarks/Misc/aarch64-init-cpu-features.c index 39c3f66831..70383b8d8e 100644 --- a/SingleSource/Benchmarks/Misc/aarch64-init-cpu-features.c +++ b/SingleSource/Benchmarks/Misc/aarch64-init-cpu-features.c @@ -1,3 +1,5 @@ +#if defined(HAS_DARWIN_FMV) || defined(HAS_LINUX_FMV) + #include extern struct { @@ -12,7 +14,10 @@ extern struct { void RUNTIME_INIT(void); +#endif /* defined(HAS_DARWIN_FMV) || defined(HAS_LINUX_FMV) */ + int main() { +#if defined(HAS_DARWIN_FMV) || defined(HAS_LINUX_FMV) RUNTIME_INIT(); const unsigned long long first = __aarch64_cpu_features.features; @@ -32,4 +37,5 @@ int main() { __aarch64_cpu_features.features = 0; RUNTIME_INIT(); } +#endif /* defined(HAS_DARWIN_FMV) || defined(HAS_LINUX_FMV) */ } From 65b1785c6be973029b7808b4b8cfca7ad1c0741d Mon Sep 17 00:00:00 2001 From: LeeYoungJoon Date: Fri, 25 Jul 2025 22:25:34 +0900 Subject: [PATCH 3/4] Revert "[FMV][AArch64] Fix Undefined Symbol error in LNT Makefile build" This reverts commit ac0c956dc4bfd7be9c76e3406668fa247a98b772. --- SingleSource/Benchmarks/Misc/Makefile | 24 +++++-------------- .../Misc/aarch64-init-cpu-features.c | 6 ----- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/SingleSource/Benchmarks/Misc/Makefile b/SingleSource/Benchmarks/Misc/Makefile index d683f65011..43b21fc238 100644 --- a/SingleSource/Benchmarks/Misc/Makefile +++ b/SingleSource/Benchmarks/Misc/Makefile @@ -13,24 +13,12 @@ endif endif ifeq ($(ARCH),AArch64) - ifeq ($(TARGET_OS),Darwin) - CHECK_FMV := $(shell echo "void __init_cpu_features_resolver(void);" > CheckHasAArch64FMV.h && \ - $(CC) -c -x c CheckHasAArch64FMV.h -o CheckHasAArch64FMV.o 2>/dev/null && \ - echo yes || echo no; \ - rm -f CheckHasAArch64FMV.h CheckHasAArch64FMV.o) - ifeq ($(CHECK_FMV),yes) - CFLAGS += -DHAS_DARWIN_FMV - endif - endif - ifeq ($(TARGET_OS),Linux) - CHECK_FMV := $(shell echo "void __init_cpu_features(void);" > CheckHasAArch64FMV.h && \ - $(CC) -c -x c CheckHasAArch64FMV.h -o CheckHasAArch64FMV.o 2>/dev/null && \ - echo yes || echo no; \ - rm -f CheckHasAArch64FMV.h CheckHasAArch64FMV.o) - ifeq ($(CHECK_FMV),yes) - CFLAGS += -DHAS_LINUX_FMV - endif - endif +ifeq ($(TARGET_OS),Darwin) +CFLAGS += -DHAS_DARWIN_FMV +endif +ifeq ($(TARGET_OS),Linux) +CFLAGS += -DHAS_LINUX_FMV +endif endif ifeq ($(ARCH),Mips) diff --git a/SingleSource/Benchmarks/Misc/aarch64-init-cpu-features.c b/SingleSource/Benchmarks/Misc/aarch64-init-cpu-features.c index 70383b8d8e..39c3f66831 100644 --- a/SingleSource/Benchmarks/Misc/aarch64-init-cpu-features.c +++ b/SingleSource/Benchmarks/Misc/aarch64-init-cpu-features.c @@ -1,5 +1,3 @@ -#if defined(HAS_DARWIN_FMV) || defined(HAS_LINUX_FMV) - #include extern struct { @@ -14,10 +12,7 @@ extern struct { void RUNTIME_INIT(void); -#endif /* defined(HAS_DARWIN_FMV) || defined(HAS_LINUX_FMV) */ - int main() { -#if defined(HAS_DARWIN_FMV) || defined(HAS_LINUX_FMV) RUNTIME_INIT(); const unsigned long long first = __aarch64_cpu_features.features; @@ -37,5 +32,4 @@ int main() { __aarch64_cpu_features.features = 0; RUNTIME_INIT(); } -#endif /* defined(HAS_DARWIN_FMV) || defined(HAS_LINUX_FMV) */ } From 462f7f3875fd34f3f03c60e3c5767aaba52525f1 Mon Sep 17 00:00:00 2001 From: LeeYoungJoon Date: Fri, 25 Jul 2025 22:51:47 +0900 Subject: [PATCH 4/4] [FMV][AArch64] Set HAS_*_FMV macro and skip test if symbol is unavailable - Selects __init_cpu_features_resolver for Darwin, and __init_cpu_features for Linux. - Attempts to compile a dummy program to detect availability of the symbol via TARGET_LLVMGCC. - Adds corresponding macro (HAS_DARWIN_FMV or HAS_LINUX_FMV) if detection succeeds. - Skips test if the symbol is undefined. Credit to @momchil-velikov and @labrinea for their valuable input and support during review. --- SingleSource/Benchmarks/Misc/Makefile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/SingleSource/Benchmarks/Misc/Makefile b/SingleSource/Benchmarks/Misc/Makefile index 43b21fc238..7dd9198770 100644 --- a/SingleSource/Benchmarks/Misc/Makefile +++ b/SingleSource/Benchmarks/Misc/Makefile @@ -14,10 +14,24 @@ endif ifeq ($(ARCH),AArch64) ifeq ($(TARGET_OS),Darwin) -CFLAGS += -DHAS_DARWIN_FMV +SYMBOL = __init_cpu_features_resolver endif ifeq ($(TARGET_OS),Linux) -CFLAGS += -DHAS_LINUX_FMV +SYMBOL = __init_cpu_features +endif +# TARGET_LLVMGCC refers to the compiler specified with the --cc option, +# and can be checked in the build-tools.log file in the test results directory. +SYMBOL := $(shell echo "extern void $(SYMBOL)(void); void (*p)() = $(SYMBOL); int main() {}" | \ + $(TARGET_LLVMGCC) --rtlib=compiler-rt -x c - -o /dev/null 2>/dev/null && \ + echo $(SYMBOL) || echo undefined) +ifeq ($(SYMBOL),__init_cpu_features_resolver) +CFLAGS += --rtlib=compiler-rt -DHAS_DARWIN_FMV +endif +ifeq ($(SYMBOL),__init_cpu_features) +CFLAGS += --rtlib=compiler-rt -DHAS_LINUX_FMV +endif +ifeq ($(SYMBOL),undefined) +PROGRAMS_TO_SKIP := aarch64-init-cpu-features endif endif