[PATCH] D60011: If MSVC and cross compiling use CMAKE_NM for gen_exports_msvc

Nathan Lanza via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 29 13:53:14 PDT 2019


lanza created this revision.
Herald added subscribers: llvm-commits, jdoerfert, mgorny.
Herald added a project: LLVM.

LLVM-C.dll was recently set to build by default. However, the script
attempts to use the just-built llvm-nm. If you are crosscompiling then
this tool is for the wrong platform. In the case that you are
croscompiling, instead opt to use the CMAKE_NM.


Repository:
  rL LLVM

https://reviews.llvm.org/D60011

Files:
  tools/llvm-shlib/CMakeLists.txt


Index: tools/llvm-shlib/CMakeLists.txt
===================================================================
--- tools/llvm-shlib/CMakeLists.txt
+++ tools/llvm-shlib/CMakeLists.txt
@@ -164,8 +164,21 @@
 
   set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.exports)
 
+  # If we are crosscompiling with clang-cl MSVC reports as true yet the llvm-nm
+  # in the build directory can not run on the host. If so, default to the nm
+  # found by cmake.
+  if (CMAKE_CROSSCOMPILING)
+    if (CMAKE_NM)
+      set(GEN_NM ${CMAKE_NM})
+    else()
+      message(FATAL_ERROR "Building LLVM-C requires the nm tool. Either disable it or set -DCMAKE_NM=/path/to/nm")
+    endif()
+  else()
+    set(GEN_NM ${LLVM_TOOLS_BINARY_DIR}/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}
+    COMMAND ${PYTHON_EXECUTABLE} ${GEN_SCRIPT} --libsfile ${LIBSFILE} ${GEN_UNDERSCORE} --nm ${GEN_NM} -o ${LLVM_EXPORTED_SYMBOL_FILE}
     DEPENDS ${LIB_NAMES} llvm-nm
     COMMENT "Generating export list for LLVM-C"
     VERBATIM )


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60011.192905.patch
Type: text/x-patch
Size: 1221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190329/d481c74b/attachment.bin>


More information about the llvm-commits mailing list