summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-03-18 20:09:13 +0000
committerReid Kleckner <reid@kleckner.net>2015-03-18 20:09:13 +0000
commit3e8c445c9695bde9856ba912841cb3ee4901e607 (patch)
tree8a18fd615e5a55758bad1f4796e5469a286d3904 /llvm
parent3d86b235119e4bd90c944228803c2d6fa622f3f8 (diff)
downloadbcm5719-llvm-3e8c445c9695bde9856ba912841cb3ee4901e607.tar.gz
bcm5719-llvm-3e8c445c9695bde9856ba912841cb3ee4901e607.zip
CMake: Disable ENABLE_EXPORTS for executables with MSVC
The MSVC linker won't produce a .lib file for an executable that doesn't export anything, and LLVM doesn't maintain dllexport annotations or .def files listing all C++ symbols. It also doesn't support exporting all symbols, like binutils ld. CMake 3.2 changed the Ninja generator to list both the .exe and .lib files as outputs of executable build targets. Ninja would always re-link executables with ENABLE_EXPORTS because the .lib output file was not present, and therefore the target was out of date. llvm-svn: 232662
Diffstat (limited to 'llvm')
-rw-r--r--llvm/CMakeLists.txt2
-rw-r--r--llvm/cmake/modules/AddLLVM.cmake6
-rw-r--r--llvm/examples/ExceptionDemo/CMakeLists.txt2
-rw-r--r--llvm/tools/bugpoint/CMakeLists.txt2
-rw-r--r--llvm/tools/llc/CMakeLists.txt2
-rw-r--r--llvm/tools/lli/CMakeLists.txt2
-rw-r--r--llvm/tools/llvm-stress/CMakeLists.txt2
-rw-r--r--llvm/tools/opt/CMakeLists.txt2
8 files changed, 13 insertions, 7 deletions
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index cfbf9562f03..b91ba15f553 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -557,7 +557,7 @@ if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
# Make sure we don't get -rdynamic in every binary. For those that need it,
-# use set_target_properties(target PROPERTIES ENABLE_EXPORTS 1)
+# use export_executable_symbols(target).
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
include(AddLLVM)
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index de542f54b3a..83897935e27 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -490,6 +490,12 @@ macro(add_llvm_executable name)
endif( LLVM_COMMON_DEPENDS )
endmacro(add_llvm_executable name)
+function(export_executable_symbols target)
+ if (NOT MSVC) # MSVC's linker doesn't support exporting all symbols.
+ set_target_properties(${target} PROPERTIES ENABLE_EXPORTS 1)
+ endif()
+endfunction()
+
set (LLVM_TOOLCHAIN_TOOLS
llvm-ar
diff --git a/llvm/examples/ExceptionDemo/CMakeLists.txt b/llvm/examples/ExceptionDemo/CMakeLists.txt
index 9cadd94c24a..2a7667dfba4 100644
--- a/llvm/examples/ExceptionDemo/CMakeLists.txt
+++ b/llvm/examples/ExceptionDemo/CMakeLists.txt
@@ -15,4 +15,4 @@ add_llvm_example(ExceptionDemo
ExceptionDemo.cpp
)
-set_target_properties(ExceptionDemo PROPERTIES ENABLE_EXPORTS 1)
+export_executable_symbols(ExceptionDemo)
diff --git a/llvm/tools/bugpoint/CMakeLists.txt b/llvm/tools/bugpoint/CMakeLists.txt
index d71e097918c..daf502e16cc 100644
--- a/llvm/tools/bugpoint/CMakeLists.txt
+++ b/llvm/tools/bugpoint/CMakeLists.txt
@@ -31,7 +31,7 @@ add_llvm_tool(bugpoint
ToolRunner.cpp
bugpoint.cpp
)
-set_target_properties(bugpoint PROPERTIES ENABLE_EXPORTS 1)
+export_executable_symbols(bugpoint)
if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
target_link_libraries(bugpoint Polly)
diff --git a/llvm/tools/llc/CMakeLists.txt b/llvm/tools/llc/CMakeLists.txt
index 484ff4028f8..dcbcf9da612 100644
--- a/llvm/tools/llc/CMakeLists.txt
+++ b/llvm/tools/llc/CMakeLists.txt
@@ -17,4 +17,4 @@ set(LLVM_NO_DEAD_STRIP 1)
add_llvm_tool(llc
llc.cpp
)
-set_target_properties(llc PROPERTIES ENABLE_EXPORTS 1)
+export_executable_symbols(llc)
diff --git a/llvm/tools/lli/CMakeLists.txt b/llvm/tools/lli/CMakeLists.txt
index 463c8530894..aad8367f34e 100644
--- a/llvm/tools/lli/CMakeLists.txt
+++ b/llvm/tools/lli/CMakeLists.txt
@@ -39,4 +39,4 @@ add_llvm_tool(lli
RemoteTarget.cpp
RemoteTargetExternal.cpp
)
-set_target_properties(lli PROPERTIES ENABLE_EXPORTS 1)
+export_executable_symbols(llvm-stress)
diff --git a/llvm/tools/llvm-stress/CMakeLists.txt b/llvm/tools/llvm-stress/CMakeLists.txt
index 106ced14194..d5c10e13f5b 100644
--- a/llvm/tools/llvm-stress/CMakeLists.txt
+++ b/llvm/tools/llvm-stress/CMakeLists.txt
@@ -7,4 +7,4 @@ set(LLVM_LINK_COMPONENTS
add_llvm_tool(llvm-stress
llvm-stress.cpp
)
-set_target_properties(llvm-stress PROPERTIES ENABLE_EXPORTS 1)
+export_executable_symbols(llvm-stress)
diff --git a/llvm/tools/opt/CMakeLists.txt b/llvm/tools/opt/CMakeLists.txt
index 12dc4f0a9f5..5f825220cc8 100644
--- a/llvm/tools/opt/CMakeLists.txt
+++ b/llvm/tools/opt/CMakeLists.txt
@@ -31,7 +31,7 @@ add_llvm_tool(opt
PrintSCC.cpp
opt.cpp
)
-set_target_properties(opt PROPERTIES ENABLE_EXPORTS 1)
+export_executable_symbols(opt)
if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
target_link_libraries(opt Polly)
OpenPOWER on IntegriCloud