llvm.org GIT mirror llvm / 85ab1e7
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232662 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 4 years ago
8 changed file(s) with 13 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
556556 endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
557557
558558 # Make sure we don't get -rdynamic in every binary. For those that need it,
559 # use set_target_properties(target PROPERTIES ENABLE_EXPORTS 1)
559 # use export_executable_symbols(target).
560560 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
561561
562562 include(AddLLVM)
489489 endif( LLVM_COMMON_DEPENDS )
490490 endmacro(add_llvm_executable name)
491491
492 function(export_executable_symbols target)
493 if (NOT MSVC) # MSVC's linker doesn't support exporting all symbols.
494 set_target_properties(${target} PROPERTIES ENABLE_EXPORTS 1)
495 endif()
496 endfunction()
497
492498
493499 set (LLVM_TOOLCHAIN_TOOLS
494500 llvm-ar
1414 ExceptionDemo.cpp
1515 )
1616
17 set_target_properties(ExceptionDemo PROPERTIES ENABLE_EXPORTS 1)
17 export_executable_symbols(ExceptionDemo)
3030 ToolRunner.cpp
3131 bugpoint.cpp
3232 )
33 set_target_properties(bugpoint PROPERTIES ENABLE_EXPORTS 1)
33 export_executable_symbols(bugpoint)
3434
3535 if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
3636 target_link_libraries(bugpoint Polly)
1616 add_llvm_tool(llc
1717 llc.cpp
1818 )
19 set_target_properties(llc PROPERTIES ENABLE_EXPORTS 1)
19 export_executable_symbols(llc)
3838 RemoteTarget.cpp
3939 RemoteTargetExternal.cpp
4040 )
41 set_target_properties(lli PROPERTIES ENABLE_EXPORTS 1)
41 export_executable_symbols(llvm-stress)
66 add_llvm_tool(llvm-stress
77 llvm-stress.cpp
88 )
9 set_target_properties(llvm-stress PROPERTIES ENABLE_EXPORTS 1)
9 export_executable_symbols(llvm-stress)
3030 PrintSCC.cpp
3131 opt.cpp
3232 )
33 set_target_properties(opt PROPERTIES ENABLE_EXPORTS 1)
33 export_executable_symbols(opt)
3434
3535 if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
3636 target_link_libraries(opt Polly)