1set( LLVM_LINK_COMPONENTS 2 ${LLVM_TARGETS_TO_BUILD} 3 Core 4 LineEditor 5 Option 6 OrcJIT 7 Support 8 ) 9 10add_clang_tool(clang-repl 11 ClangRepl.cpp 12 13 EXPORT_SYMBOLS 14 ) 15 16if(MSVC) 17 set_target_properties(clang-repl PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1) 18 19 # RTTI/C++ symbols 20 set(clang_repl_exports ${clang_repl_exports} ??_7type_info@@6B@ 21 ?__type_info_root_node@@3U__type_info_node@@A 22 ?nothrow@std@@3Unothrow_t@1@B 23 ) 24 25 # Compiler added symbols for static variables. NOT for VStudio < 2015 26 set(clang_repl_exports ${clang_repl_exports} _Init_thread_abort _Init_thread_epoch 27 _Init_thread_footer _Init_thread_header _tls_index 28 ) 29 30 if(CMAKE_SIZEOF_VOID_P EQUAL 8) 31 # new/delete variants needed when linking to static msvc runtime (esp. Debug) 32 set(clang_repl_exports ${clang_repl_exports} 33 ??2@YAPEAX_K@Z 34 ??3@YAXPEAX@Z 35 ??_U@YAPEAX_K@Z 36 ??_V@YAXPEAX@Z 37 ??3@YAXPEAX_K@Z 38 ) 39 else() 40 set(clang_repl_exports ${clang_repl_exports} 41 ??2@YAPAXI@Z 42 ??3@YAXPAX@Z 43 ??3@YAXPAXI@Z 44 ??_U@YAPAXI@Z 45 ??_V@YAXPAX@Z 46 ??_V@YAXPAXI@Z 47 ) 48 endif() 49 50 # List to '/EXPORT:sym0 /EXPORT:sym1 /EXPORT:sym2 ...' 51 list(TRANSFORM clang_repl_exports PREPEND "LINKER:/EXPORT:") 52 53 set_property(TARGET clang-repl APPEND PROPERTY LINK_OPTIONS ${clang_repl_exports}) 54 55endif(MSVC) 56 57clang_target_link_libraries(clang-repl PRIVATE 58 clangAST 59 clangBasic 60 clangFrontend 61 clangInterpreter 62 ) 63 64# The clang-repl binary can get huge with static linking in debug mode. 65# Some 32-bit targets use PLT slots with limited branch range by default and we 66# start to exceed this limit, e.g. when linking for arm-linux-gnueabihf with 67# gold. This flag tells the linker to build a PLT for the full address range. 68# Linkers without this flag are assumed to support proper PLTs by default. 69set(flag_long_plt "LINKER:--long-plt") 70check_linker_flag(CXX ${flag_long_plt} HAVE_LINKER_FLAG_LONG_PLT) 71if(HAVE_LINKER_FLAG_LONG_PLT) 72 target_link_options(clang-repl PRIVATE ${flag_long_plt}) 73endif() 74