-
Notifications
You must be signed in to change notification settings - Fork 13.5k
llvm-exegesis build on x86 doesn't set LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET #38369
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
Comments
assigned to @legrosbuffle |
Thanks for the analysis When https://reviews.llvm.org/D48778 introduced the PARENT_SCOPE there was only one target, so this was invisible. This started happening when a second target was added and only when building for both X86 and AArch64 targets. I think your solution is reasonable, I've created //reviews.llvm.org/D52343. Thanks ! |
Hans - this probably needs to be fixed in the 7.0 dot release |
Fixed by D52343/r342865. |
Noted, thanks! |
Reopened until merged for 7.0.1 |
Clement, is this OK to merge to the release_70 branch? |
Sorry, I've already replied by email: Yes, this can be merged. |
Merged: r347811 |
mentioned in issue #38454 |
Extended Description
Something's up with the llvm-exegesis build process on 7.0.0 release. On my x86 machines they always complain "no exegesis target for x86_64-pc-linux-gnu, using default", and this seems to be because LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET never gets set by CMake.
The CMake scripts try to set LLVM_EXEGESIS_TARGETS in the lib subdirectory, but this doesn't seem to work properly. I made this change to figure out what's happening:
diff --git a/tools/llvm-exegesis/CMakeLists.txt b/tools/llvm-exegesis/CMakeLists.txt
index 65b1ada8529..94842519ca7 100644
--- a/tools/llvm-exegesis/CMakeLists.txt
+++ b/tools/llvm-exegesis/CMakeLists.txt
@@ -8,7 +8,9 @@ add_llvm_tool(llvm-exegesis
llvm-exegesis.cpp
)
+message(WARNING "LLVM_EXEGESIS_TARGETS at parent scope before: ${LLVM_EXEGESIS_TARGETS}")
add_subdirectory(lib)
+message(FATAL_ERROR "LLVM_EXEGESIS_TARGETS at parent scope after: ${LLVM_EXEGESIS_TARGETS}")
Link the native exegesis target if compiled and on the right host.
if ((LLVM_TARGETS_TO_BUILD MATCHES "${LLVM_NATIVE_ARCH}") AND (LLVM_EXEGESIS_TARGETS MATCHES "${LLVM_NATIVE_ARCH}"))
diff --git a/tools/llvm-exegesis/lib/CMakeLists.txt b/tools/llvm-exegesis/lib/CMakeLists.txt
index 175c2adf9de..4dc91ef125c 100644
--- a/tools/llvm-exegesis/lib/CMakeLists.txt
+++ b/tools/llvm-exegesis/lib/CMakeLists.txt
@@ -1,12 +1,18 @@
+message( WARNING "LLVM_EXEGESIS_TARGETS before: ${LLVM_EXEGESIS_TARGETS}" )
+
if (LLVM_TARGETS_TO_BUILD MATCHES "X86")
add_subdirectory(X86)
set(LLVM_EXEGESIS_TARGETS "${LLVM_EXEGESIS_TARGETS} X86" PARENT_SCOPE)
endif()
if (LLVM_TARGETS_TO_BUILD MATCHES "AArch64")
add_subdirectory(AArch64)
set(LLVM_EXEGESIS_TARGETS "${LLVM_EXEGESIS_TARGETS} AArch64" PARENT_SCOPE)
endif()
+message( WARNING "LLVM_EXEGESIS_TARGETS after: ${LLVM_EXEGESIS_TARGETS}" )
+
add_library(LLVMExegesis
STATIC
Analysis.cpp
This results in this behavior (extraneous newlines removed for readability):
CMake Warning at tools/llvm-exegesis/CMakeLists.txt:11 (message):
LLVM_EXEGESIS_TARGETS at parent scope before:
CMake Warning at tools/llvm-exegesis/lib/CMakeLists.txt:1 (message):
LLVM_EXEGESIS_TARGETS before:
CMake Warning at tools/llvm-exegesis/lib/CMakeLists.txt:5 (message):
Appending X86
CMake Warning at tools/llvm-exegesis/lib/CMakeLists.txt:10 (message):
Appending AArch64
CMake Warning at tools/llvm-exegesis/lib/CMakeLists.txt:14 (message):
LLVM_EXEGESIS_TARGETS after:
CMake Error at tools/llvm-exegesis/CMakeLists.txt:13 (message):
LLVM_EXEGESIS_TARGETS at parent scope after: AArch64
So reading the LLVM_EXEGESIS_TARGETS variable in lib/CMakeLists.txt doesn't work properly, and the second set(... PARENT_SCOPE) just sees the empty LLVM_EXEGESIS_TARGETS value, overwriting the previously appended X86 value.
Any ideas on how to fix this? I'm doing this locally but it seems sloppy:
diff --git a/tools/llvm-exegesis/lib/CMakeLists.txt b/tools/llvm-exegesis/lib/CMakeLists.txt
index 175c2adf9de..194304adf98 100644
--- a/tools/llvm-exegesis/lib/CMakeLists.txt
+++ b/tools/llvm-exegesis/lib/CMakeLists.txt
@@ -1,12 +1,16 @@
+set(TARGETS_TO_APPEND "")
+
if (LLVM_TARGETS_TO_BUILD MATCHES "X86")
add_subdirectory(X86)
endif()
if (LLVM_TARGETS_TO_BUILD MATCHES "AArch64")
add_subdirectory(AArch64)
endif()
+set(LLVM_EXEGESIS_TARGETS "${LLVM_EXEGESIS_TARGETS} ${TARGETS_TO_APPEND}" PARENT_SCOPE)
+
add_library(LLVMExegesis
STATIC
Analysis.cpp
The text was updated successfully, but these errors were encountered: