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 )