[PATCH] D60025: [llvm-shlib] Fix cross-compilation for LLVM-C

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 29 19:36:58 PDT 2019


smeenai created this revision.
smeenai added reviewers: beanz, compnerd, phosek, rnk, Wallbraker.
Herald added subscribers: jdoerfert, mgorny.
Herald added a project: LLVM.

When we're cross-compiling, build and use a native llvm-nm instead of
attempting to use the one from the target's build tree.

A nice follow-up would be to add a cache variable to allow specifying a
path to an external native llvm-nm instead of building one ourselves,
similar to LLVM_TABLEGEN and LLVM_CONFIG_PATH.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60025

Files:
  llvm/tools/llvm-shlib/CMakeLists.txt


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===================================================================
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -164,9 +164,18 @@
 
   set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.exports)
 
+  if(CMAKE_CROSSCOMPILING)
+    build_native_tool(TARGET llvm-nm
+                      OUTPUT_PATH_VAR llvm_nm)
+    set(llvm_nm_target "${llvm_nm}")
+  else()
+    set(llvm_nm $<TARGET_FILE:llvm-nm>)
+    set(llvm_nm_target llvm-nm)
+  endif()
+
   add_custom_command(OUTPUT ${LLVM_EXPORTED_SYMBOL_FILE}
-    COMMAND ${PYTHON_EXECUTABLE} ${GEN_SCRIPT} --libsfile ${LIBSFILE} ${GEN_UNDERSCORE} --nm ${LLVM_TOOLS_BINARY_DIR}/llvm-nm -o ${LLVM_EXPORTED_SYMBOL_FILE}
-    DEPENDS ${LIB_NAMES} llvm-nm
+    COMMAND ${PYTHON_EXECUTABLE} ${GEN_SCRIPT} --libsfile ${LIBSFILE} ${GEN_UNDERSCORE} --nm "${llvm_nm}" -o ${LLVM_EXPORTED_SYMBOL_FILE}
+    DEPENDS ${LIB_NAMES} ${llvm_nm_target}
     COMMENT "Generating export list for LLVM-C"
     VERBATIM )
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60025.192957.patch
Type: text/x-patch
Size: 1061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190330/2fffe2f8/attachment.bin>


More information about the llvm-commits mailing list