Skip to content

Commit cc74a29

Browse files
jhuber6IanWood1
authored andcommitted
[Offload] Override linker for device build (llvm#137246)
Summary: Override the default linker in case the user is passing it separately. This requires `lld` but it always did. This will be fixed *properly* when llvm#136729 lands. Fixes llvm#136822
1 parent 3a55a06 commit cc74a29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

offload/DeviceRTL/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ function(compileDeviceRTLLibrary target_name target_triple)
132132
BUILD_RPATH ""
133133
INSTALL_RPATH ""
134134
RUNTIME_OUTPUT_NAME libomptarget-${target_name}.bc)
135-
target_compile_options(libomptarget-${target_name} PRIVATE "--target=${target_triple}" "-march=")
135+
target_compile_options(libomptarget-${target_name} PRIVATE "--target=${target_triple}" "-fuse-ld=lld" "-march=")
136136
target_link_options(libomptarget-${target_name} PRIVATE "--target=${target_triple}"
137-
"-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm" "-march=")
137+
"-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm" "-fuse-ld=lld" "-march=")
138138
install(TARGETS libomptarget-${target_name}
139139
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ
140140
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${target_triple}")
@@ -151,6 +151,8 @@ function(compileDeviceRTLLibrary target_name target_triple)
151151
LINKER_LANGUAGE CXX
152152
)
153153
target_link_libraries(omptarget.${target_name} PRIVATE omptarget.${target_name}.all_objs)
154+
target_link_options(omptarget.${target_name} PRIVATE "--target=${target_triple}"
155+
"-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm" "-fuse-ld=lld" "-march=")
154156

155157
install(TARGETS omptarget.${target_name}
156158
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${target_triple}")

0 commit comments

Comments
 (0)