Skip to content

Conversation

@jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Apr 24, 2025

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 #136729 lands.

Fixes #136822

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.
@llvmbot
Copy link
Member

llvmbot commented Apr 24, 2025

@llvm/pr-subscribers-offload

Author: Joseph Huber (jhuber6)

Changes

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 #136729 lands.

Fixes #136822


Full diff: https://github.com/llvm/llvm-project/pull/137246.diff

1 Files Affected:

  • (modified) offload/DeviceRTL/CMakeLists.txt (+4-2)
diff --git a/offload/DeviceRTL/CMakeLists.txt b/offload/DeviceRTL/CMakeLists.txt
index b1c48cbaefe16..f8a6d8563916a 100644
--- a/offload/DeviceRTL/CMakeLists.txt
+++ b/offload/DeviceRTL/CMakeLists.txt
@@ -132,9 +132,9 @@ function(compileDeviceRTLLibrary target_name target_triple)
     BUILD_RPATH ""
     INSTALL_RPATH ""
     RUNTIME_OUTPUT_NAME libomptarget-${target_name}.bc)
-  target_compile_options(libomptarget-${target_name} PRIVATE "--target=${target_triple}" "-march=")
+  target_compile_options(libomptarget-${target_name} PRIVATE "--target=${target_triple}" "-fuse-ld=lld" "-march=")
   target_link_options(libomptarget-${target_name} PRIVATE "--target=${target_triple}"
-                      "-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm" "-march=")
+                      "-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm" "-fuse-ld=lld" "-march=")
   install(TARGETS libomptarget-${target_name}
           PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ
           DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${target_triple}")
@@ -151,6 +151,8 @@ function(compileDeviceRTLLibrary target_name target_triple)
     LINKER_LANGUAGE CXX
   )
   target_link_libraries(omptarget.${target_name} PRIVATE omptarget.${target_name}.all_objs)
+  target_link_options(omptarget.${target_name} PRIVATE "--target=${target_triple}"
+                      "-r" "-nostdlib" "-flto" "-Wl,--lto-emit-llvm" "-fuse-ld=lld" "-march=")
 
   install(TARGETS omptarget.${target_name}
           ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${target_triple}")

Copy link
Contributor

@jplehr jplehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable for the meantime

@sylvestre sylvestre merged commit 346792a into llvm:main Apr 25, 2025
11 checks passed
@jhuber6 jhuber6 deleted the LLD branch April 25, 2025 15:45
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ubuntu Jammy: fails to build with "--lto-CGO2: unknown option"

4 participants