Skip to content

Commit fb9a82b

Browse files
[clang-repl] Refine fix for linker error: PLT offset too large
This is a follow-up improvement after the discussion in #78959
1 parent fe0e632 commit fb9a82b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

clang/tools/clang-repl/CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ if(CLANG_PLUGIN_SUPPORT)
2323
export_executable_symbols_for_plugins(clang-repl)
2424
endif()
2525

26-
string(TOUPPER "${CMAKE_SYSTEM_PROCESSOR}" system_processor)
27-
if(system_processor MATCHES "ARM")
28-
set(FLAG_LONG_PLT "-Wl,--long-plt")
29-
llvm_check_linker_flag(CXX ${FLAG_LONG_PLT} LINKER_HAS_FLAG_LONG_PLT)
30-
# Linkers without this flag are assumed to have long PLTs by default
31-
if(LINKER_HAS_FLAG_LONG_PLT)
32-
target_link_options(clang-repl PRIVATE ${FLAG_LONG_PLT})
33-
endif()
26+
# The clang-repl binary can get huge with static linking in debug mode.
27+
# Some 32-bit targets use PLT slots with limited branch range by default and we
28+
# start to exceed this limit, e.g. when linking for arm-linux-gnueabihf with
29+
# gold. This flag tells the linker to build a PLT for the full address range.
30+
# Linkers without this flag are assumed to support proper PLTs by default.
31+
set(flag_long_plt "-Wl,--long-plt")
32+
llvm_check_linker_flag(CXX ${flag_long_plt} HAVE_LINKER_FLAG_LONG_PLT)
33+
if(HAVE_LINKER_FLAG_LONG_PLT)
34+
target_link_options(clang-repl PRIVATE ${flag_long_plt})
3435
endif()

0 commit comments

Comments
 (0)