Skip to content

[FMV][AArch64] Fix missing FMV defines for AArch64 in LNT Makefile #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

IamYJLee
Copy link
Contributor

@IamYJLee IamYJLee commented Jul 21, 2025

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.

This patch reflects the changes from llvm/llvm-test-suite@d24d5dcd.

ERROR CONTEXT

Before this patch, LNT test runs on AArch64 platforms (e.g., macOS arm64) could fail with missing symbol errors:

--- Tested: 140 tests --
FAIL: SingleSource/Benchmarks/Misc/aarch64-init-cpu-features.compile_time (1 of 140)
FAIL: SingleSource/Benchmarks/Misc/aarch64-init-cpu-features.execution_time (29 of 140)
Processing Times
Undefined symbols for architecture arm64:
  "_RUNTIME_INIT", referenced from:
      _main in aarch64-init-cpu-features.llvm.o
      _main in aarch64-init-cpu-features.llvm.o
      _main in aarch64-init-cpu-features.llvm.o
ld: symbol(s) not found for architecture arm64

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.
@davemgreen davemgreen requested a review from labrinea July 21, 2025 07:42
@labrinea
Copy link
Contributor

I am a bit puzzled with the equivalent cmake code

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CheckHasAArch64FMV.h "void __init_cpu_features_resolver(void);")
check_symbol_exists(__init_cpu_features_resolver ${CMAKE_CURRENT_BINARY_DIR}/CheckHasAArch64FMV.h HAS_AARCH64_FMV)

The way I read it HAS_AARCH64_FMV is always true? Am I mistaken, do we need it here too perhaps? cc @jroelofs

@IamYJLee
Copy link
Contributor Author

@labrinea Thank you for your comment.

I've confirmed how check_symbol_exists functions and understand that HAS_AARCH64_FMV is not always true. In my environment, when I configure the project using CMakeLists.txt, HAS_AARCH64_FMV is set to False.

However, when I run LNT with a Makefile that includes my modifications, the build and execution complete without any issues.

In other words, even though check_symbol_exists confirms that the __init_cpu_features_resolver symbol is missing, there are no problems compiling and running aarch64-init-cpu-features.c.

- 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
@IamYJLee
Copy link
Contributor Author

@labrinea
I'm using the following command and encountering an Undefined Symbol error.

./mysandbox/bin/lnt runtest nt --sandbox ./result --cc ./llvm-project/build/bin/clang --test-suite ./llvm-test-suite -j 16 --only-test SingleSource/Benchmarks/Misc --isysroot `xcrun --show-sdk-path`

To match the CMakeLists.txt configuration and resolve this, I've made the following changes:

  1. I added an #if defined() directive to aarch64-init-cpu-features.c to prevent the problematic code from being compiled when HAS_***_FW is False. (My initial attempt to use PROGRAM_TO_SKIP to exclude the file did not work.)

  2. To replicate the logic from the CMakeLists.txt (below code), I added a step that generates and compiles a temporary header file. The result of this check is stored in the CHECK_FMV variable.

    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CheckHasAArch64FMV.h "void __init_cpu_features_resolver(void);")
    check_symbol_exists(__init_cpu_features_resolver ${CMAKE_CURRENT_BINARY_DIR}/CheckHasAArch64FMV.h HAS_AARCH64_FMV)

Testing

In my local environment, the check for the __init_cpu_features* symbol always results in 'no'. I've confirmed my changes work as intended by manually setting the CHECK_FMV variable to both 'yes' and 'no'.

Could you please test these changes in an environment where the __init_cpu_features* symbol check would result in 'yes'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants