Skip to content

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

Closed
tycho opened this issue Sep 20, 2018 · 10 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla cmake Build system in general and CMake in particular

Comments

@tycho
Copy link
Member

tycho commented Sep 20, 2018

Bugzilla Link 39021
Resolution FIXED
Resolved on Nov 28, 2018 13:46
Version 7.0
OS Linux
Blocks #38454
CC @legrosbuffle,@gchatelet,@zmodem,@RKSimon,@tstellar
Fixed by commit(s) r342865 r347811

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)

  • message( WARNING "Appending X86" )
    set(LLVM_EXEGESIS_TARGETS "${LLVM_EXEGESIS_TARGETS} X86" PARENT_SCOPE)
    endif()
    if (LLVM_TARGETS_TO_BUILD MATCHES "AArch64")
    add_subdirectory(AArch64)
  • message( WARNING "Appending 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)

  • set(LLVM_EXEGESIS_TARGETS "${LLVM_EXEGESIS_TARGETS} X86" PARENT_SCOPE)
  • set(TARGETS_TO_APPEND "${TARGETS_TO_APPEND} X86")
    endif()
    if (LLVM_TARGETS_TO_BUILD MATCHES "AArch64")
    add_subdirectory(AArch64)
  • set(LLVM_EXEGESIS_TARGETS "${LLVM_EXEGESIS_TARGETS} AArch64" PARENT_SCOPE)
  • set(TARGETS_TO_APPEND "${TARGETS_TO_APPEND} AArch64")
    endif()

+set(LLVM_EXEGESIS_TARGETS "${LLVM_EXEGESIS_TARGETS} ${TARGETS_TO_APPEND}" PARENT_SCOPE)
+
add_library(LLVMExegesis
STATIC
Analysis.cpp

@tycho
Copy link
Member Author

tycho commented Sep 20, 2018

assigned to @legrosbuffle

@legrosbuffle
Copy link
Contributor

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 !

@RKSimon
Copy link
Collaborator

RKSimon commented Sep 21, 2018

Hans - this probably needs to be fixed in the 7.0 dot release

@legrosbuffle
Copy link
Contributor

Fixed by D52343/r342865.

@zmodem
Copy link
Collaborator

zmodem commented Sep 24, 2018

Hans - this probably needs to be fixed in the 7.0 dot release

Noted, thanks!

@RKSimon
Copy link
Collaborator

RKSimon commented Sep 29, 2018

Reopened until merged for 7.0.1

@tstellar
Copy link
Collaborator

Clement, is this OK to merge to the release_70 branch?

@legrosbuffle
Copy link
Contributor

Sorry, I've already replied by email: Yes, this can be merged.

@tstellar
Copy link
Collaborator

Merged: r347811

@tstellar
Copy link
Collaborator

mentioned in issue #38454

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla cmake Build system in general and CMake in particular
Projects
None yet
Development

No branches or pull requests

5 participants