[llvm-bugs] [Bug 39021] New: llvm-exegesis build on x86 doesn't set LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 20 09:06:15 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39021

            Bug ID: 39021
           Summary: llvm-exegesis build on x86 doesn't set
                    LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET
           Product: Build scripts
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: cmake
          Assignee: unassignedbugs at nondot.org
          Reporter: steven at uplinklabs.net
                CC: llvm-bugs at lists.llvm.org

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180920/dd0dc55b/attachment.html>


More information about the llvm-bugs mailing list