-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix linking on riscv64 #74167
base: main
Are you sure you want to change the base?
fix linking on riscv64 #74167
Conversation
As libatomic is not included in libgcc_s, when building on riscv64 (on Ubuntu 22.04) using rtlib set to libgcc and gnu ld as the linker, the linking of dsymutil fails on some __atomic_X symbols provided by libatomic. reviews.llvm.org/D137799 has commented out the line potentially adding a `-latomic` when linking by using the LLVM_ATOMIC_LIB variable without providing any reason. Revert this piece of the change.
As libatomic is not included in libgcc_s, when building on riscv64 (on Ubuntu 22.04) using rtlib set to libgcc and gnu ld as the linker, the linking of several libMLIR consumers fails on some __atomic_X symbols provided by libatomic. Add the LLVM_ATOMIC_LIB variable potentially adding a `-latomic` when linking.
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-debuginfo Author: Vincent Palatin (vpalatin) ChangesAs libatomic is not included in libgcc_s, when building on riscv64 For dsymutils, actually reviews.llvm.org/D137799 has commented out the line potentially adding a For several libMLIR consumers, add the LLVM_ATOMIC_LIB variable where needed. Full diff: https://github.com/llvm/llvm-project/pull/74167.diff 4 Files Affected:
diff --git a/llvm/tools/dsymutil/CMakeLists.txt b/llvm/tools/dsymutil/CMakeLists.txt
index c612bfd9150c47f..de1da71a64dc124 100644
--- a/llvm/tools/dsymutil/CMakeLists.txt
+++ b/llvm/tools/dsymutil/CMakeLists.txt
@@ -44,4 +44,4 @@ if(APPLE AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
target_link_libraries(dsymutil PRIVATE "-framework CoreFoundation")
endif(APPLE AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
-# target_link_libraries(dsymutil PRIVATE ${LLVM_ATOMIC_LIB})
+target_link_libraries(dsymutil PRIVATE ${LLVM_ATOMIC_LIB})
diff --git a/mlir/lib/Pass/CMakeLists.txt b/mlir/lib/Pass/CMakeLists.txt
index 5ca9b4163bb8a8f..d2628aaa7274ec4 100644
--- a/mlir/lib/Pass/CMakeLists.txt
+++ b/mlir/lib/Pass/CMakeLists.txt
@@ -16,4 +16,6 @@ add_mlir_library(MLIRPass
LINK_LIBS PUBLIC
MLIRAnalysis
MLIRIR
+ PRIVATE
+ ${LLVM_ATOMIC_LIB}
)
diff --git a/mlir/lib/Tools/lsp-server-support/CMakeLists.txt b/mlir/lib/Tools/lsp-server-support/CMakeLists.txt
index 48a96016b792fce..8f7e26340067f1e 100644
--- a/mlir/lib/Tools/lsp-server-support/CMakeLists.txt
+++ b/mlir/lib/Tools/lsp-server-support/CMakeLists.txt
@@ -10,4 +10,6 @@ add_mlir_library(MLIRLspServerSupportLib
LINK_LIBS PUBLIC
MLIRSupport
+ PRIVATE
+ ${LLVM_ATOMIC_LIB}
)
diff --git a/mlir/tools/mlir-shlib/CMakeLists.txt b/mlir/tools/mlir-shlib/CMakeLists.txt
index 32fe833cee4ea78..59e0f7078288355 100644
--- a/mlir/tools/mlir-shlib/CMakeLists.txt
+++ b/mlir/tools/mlir-shlib/CMakeLists.txt
@@ -39,6 +39,8 @@ if(LLVM_BUILD_LLVM_DYLIB)
${_OBJECTS}
LINK_LIBS
${_DEPS}
+ PRIVATE
+ ${LLVM_ATOMIC_LIB}
LINK_COMPONENTS
${mlir_llvm_link_components}
|
@abrachet |
Looking at the overall diff it looks like that might have been an unrelated change that snuck in and no one noticed. |
@@ -16,4 +16,6 @@ add_mlir_library(MLIRPass | |||
LINK_LIBS PUBLIC | |||
MLIRAnalysis | |||
MLIRIR | |||
PRIVATE | |||
${LLVM_ATOMIC_LIB} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this part of add_mlir_library
? Seems a bit random to add this here and there right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair point
I just put it in the specific places where it was needed (ie using the libatomic symbols) the same way it was done in other places in llvm (mlir never had support for this case).
but this will require some 'manual' maintenance as it is not obvious where these functions are used.
adding it globally to the helper might be a better avenue.
As libatomic is not included in libgcc_s, when building on riscv64
(on Ubuntu 22.04) using rtlib set to libgcc and gnu ld as the linker,
the linking of a few utilities fails on some __atomic_X symbols provided by libatomic.
For dsymutils, actually reviews.llvm.org/D137799 has commented out the line potentially adding a
-latomic
when linking by using the LLVM_ATOMIC_LIB variable without providing any reason. Revert this piece of the change.For several libMLIR consumers, add the LLVM_ATOMIC_LIB variable where needed.