[PATCH] D77162: libclc: Fix LLVM library linking on Windows
Daniel Stone via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 31 12:33:20 PDT 2020
daniels created this revision.
daniels added reviewers: jvesely, tstellar.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.
CMake requires library lists on Windows to be split by semi-colons,
rather than the spaces we get from llvm-config. Fix this by a
substitution on Windows. As LLVM will only build static libraries on
Windows, this also requires prepare_builtins.exe to be statically
linked.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77162
Files:
libclc/CMakeLists.txt
Index: libclc/CMakeLists.txt
===================================================================
--- libclc/CMakeLists.txt
+++ libclc/CMakeLists.txt
@@ -75,6 +75,11 @@
OUTPUT_VARIABLE LLVM_BINDIR
OUTPUT_STRIP_TRAILING_WHITESPACE )
+if (WIN32)
+ string(REPLACE ".lib " ".lib;" LLVM_SYSTEM_LIBS "${LLVM_SYSTEM_LIBS}")
+ string(REPLACE ".lib " ".lib;" LLVM_LIBS "${LLVM_LIBS}")
+endif()
+
# These were not properly reported in early LLVM and we don't need them
set( LLVM_CXX_FLAGS ${LLVM_CXX_FLAGS} -fno-rtti -fno-exceptions )
@@ -102,6 +107,12 @@
message( FATAL_ERROR "toolchain incomplete!" )
endif()
+if(WIN32)
+ set( LLVM_STATIC_FLAGS "/MT" )
+else()
+ set( LLVM_STATIC_FLAGS "" )
+endif()
+
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake )
set( CMAKE_CLC_COMPILER ${LLVM_CLANG} )
set( CMAKE_CLC_ARCHIVE ${LLVM_LINK} )
@@ -121,7 +132,7 @@
# Setup prepare_builtins tools
add_executable( prepare_builtins utils/prepare-builtins.cpp )
-target_compile_options( prepare_builtins PRIVATE ${LLVM_CXX_FLAGS} )
+target_compile_options( prepare_builtins PRIVATE ${LLVM_CXX_FLAGS} ${LLVM_STATIC_FLAGS} )
target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} )
target_link_libraries( prepare_builtins PRIVATE ${LLVM_SYSTEM_LIBS} )
target_link_libraries( prepare_builtins PRIVATE ${LLVM_LIBS} )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77162.253964.patch
Type: text/x-patch
Size: 1332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200331/ef07152f/attachment-0001.bin>
More information about the llvm-commits
mailing list