79 lines · plain
1set( LLVM_LINK_COMPONENTS2 ${LLVM_TARGETS_TO_BUILD}3 Core4 LineEditor5 Option6 OrcJIT7 OrcShared8 Support9 TargetParser10 )11 12add_clang_tool(clang-repl13 ClangRepl.cpp14 15 EXPORT_SYMBOLS16 )17 18if(MSVC)19 set_target_properties(clang-repl PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)20 21 # RTTI/C++ symbols22 set(clang_repl_exports ${clang_repl_exports} ??_7type_info@@6B@,DATA23 ?__type_info_root_node@@3U__type_info_node@@A,DATA24 ?nothrow@std@@3Unothrow_t@1@B,DATA25 )26 27 # Compiler added symbols for static variables. NOT for VStudio < 201528 set(clang_repl_exports ${clang_repl_exports} _Init_thread_abort _Init_thread_epoch,DATA29 _Init_thread_footer _Init_thread_header _tls_index,DATA30 )31 32 if(CMAKE_SIZEOF_VOID_P EQUAL 8)33 # new/delete variants needed when linking to static msvc runtime (esp. Debug)34 set(clang_repl_exports ${clang_repl_exports}35 ??2@YAPEAX_K@Z36 ??3@YAXPEAX@Z37 ??_U@YAPEAX_K@Z38 ??_V@YAXPEAX@Z39 ??3@YAXPEAX_K@Z40 )41 else()42 set(clang_repl_exports ${clang_repl_exports}43 ??2@YAPAXI@Z44 ??3@YAXPAX@Z45 ??3@YAXPAXI@Z46 ??_U@YAPAXI@Z47 ??_V@YAXPAX@Z48 ??_V@YAXPAXI@Z49 )50 endif()51 52 # List to '/EXPORT:sym0 /EXPORT:sym1 /EXPORT:sym2 ...'53 # The 'SHELL' prefix tells CMake to use a space instead of comma as the54 # separator between the driver and linker options, which we need since MSVC's55 # linker uses `,DATA` as a suffix to indicate that data is being exported.56 list(TRANSFORM clang_repl_exports PREPEND "LINKER:SHELL:/EXPORT:")57 58 set_property(TARGET clang-repl APPEND PROPERTY LINK_OPTIONS ${clang_repl_exports})59 60endif(MSVC)61 62clang_target_link_libraries(clang-repl PRIVATE63 clangAST64 clangBasic65 clangFrontend66 clangInterpreter67 )68 69# The clang-repl binary can get huge with static linking in debug mode.70# Some 32-bit targets use PLT slots with limited branch range by default and we71# start to exceed this limit, e.g. when linking for arm-linux-gnueabihf with72# gold. This flag tells the linker to build a PLT for the full address range.73# Linkers without this flag are assumed to support proper PLTs by default.74set(flag_long_plt "LINKER:--long-plt")75check_linker_flag(CXX ${flag_long_plt} HAVE_LINKER_FLAG_LONG_PLT)76if(HAVE_LINKER_FLAG_LONG_PLT)77 target_link_options(clang-repl PRIVATE ${flag_long_plt})78endif()79