[llvm] r232662 - CMake: Disable ENABLE_EXPORTS for executables with MSVC

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Mar 18 13:24:29 PDT 2015


Fixed in r232663.

On 18 March 2015 at 16:21, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
> I am getting errors like:
>
> CMake Error at cmake/modules/AddLLVM.cmake:495 (set_target_properties):
>   set_target_properties Can not find target to add properties to: llvm-stress
> Call Stack (most recent call first):
>   tools/lli/CMakeLists.txt:42 (export_executable_symbols)
>
> On 18 March 2015 at 16:09, Reid Kleckner <reid at kleckner.net> wrote:
>> Author: rnk
>> Date: Wed Mar 18 15:09:13 2015
>> New Revision: 232662
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=232662&view=rev
>> Log:
>> 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.
>>
>> Modified:
>>     llvm/trunk/CMakeLists.txt
>>     llvm/trunk/cmake/modules/AddLLVM.cmake
>>     llvm/trunk/examples/ExceptionDemo/CMakeLists.txt
>>     llvm/trunk/tools/bugpoint/CMakeLists.txt
>>     llvm/trunk/tools/llc/CMakeLists.txt
>>     llvm/trunk/tools/lli/CMakeLists.txt
>>     llvm/trunk/tools/llvm-stress/CMakeLists.txt
>>     llvm/trunk/tools/opt/CMakeLists.txt
>>
>> Modified: llvm/trunk/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=232662&r1=232661&r2=232662&view=diff
>> ==============================================================================
>> --- llvm/trunk/CMakeLists.txt (original)
>> +++ llvm/trunk/CMakeLists.txt Wed Mar 18 15:09:13 2015
>> @@ -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)
>>
>> Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=232662&r1=232661&r2=232662&view=diff
>> ==============================================================================
>> --- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
>> +++ llvm/trunk/cmake/modules/AddLLVM.cmake Wed Mar 18 15:09:13 2015
>> @@ -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
>>
>> Modified: llvm/trunk/examples/ExceptionDemo/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ExceptionDemo/CMakeLists.txt?rev=232662&r1=232661&r2=232662&view=diff
>> ==============================================================================
>> --- llvm/trunk/examples/ExceptionDemo/CMakeLists.txt (original)
>> +++ llvm/trunk/examples/ExceptionDemo/CMakeLists.txt Wed Mar 18 15:09:13 2015
>> @@ -15,4 +15,4 @@ add_llvm_example(ExceptionDemo
>>    ExceptionDemo.cpp
>>    )
>>
>> -set_target_properties(ExceptionDemo PROPERTIES ENABLE_EXPORTS 1)
>> +export_executable_symbols(ExceptionDemo)
>>
>> Modified: llvm/trunk/tools/bugpoint/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/CMakeLists.txt?rev=232662&r1=232661&r2=232662&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/bugpoint/CMakeLists.txt (original)
>> +++ llvm/trunk/tools/bugpoint/CMakeLists.txt Wed Mar 18 15:09:13 2015
>> @@ -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)
>>
>> Modified: llvm/trunk/tools/llc/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/CMakeLists.txt?rev=232662&r1=232661&r2=232662&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/llc/CMakeLists.txt (original)
>> +++ llvm/trunk/tools/llc/CMakeLists.txt Wed Mar 18 15:09:13 2015
>> @@ -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)
>>
>> Modified: llvm/trunk/tools/lli/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/CMakeLists.txt?rev=232662&r1=232661&r2=232662&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/lli/CMakeLists.txt (original)
>> +++ llvm/trunk/tools/lli/CMakeLists.txt Wed Mar 18 15:09:13 2015
>> @@ -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)
>>
>> Modified: llvm/trunk/tools/llvm-stress/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-stress/CMakeLists.txt?rev=232662&r1=232661&r2=232662&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/llvm-stress/CMakeLists.txt (original)
>> +++ llvm/trunk/tools/llvm-stress/CMakeLists.txt Wed Mar 18 15:09:13 2015
>> @@ -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)
>>
>> Modified: llvm/trunk/tools/opt/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/CMakeLists.txt?rev=232662&r1=232661&r2=232662&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/opt/CMakeLists.txt (original)
>> +++ llvm/trunk/tools/opt/CMakeLists.txt Wed Mar 18 15:09:13 2015
>> @@ -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)
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list