-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
ODR vialotion in mlir-cpu-runner + libmlir_async_runtime.so #61856
Comments
@llvm/issue-subscribers-mlir |
I think that this indicates that libLLVMSupport is statically linked in the two libraries. One way to handle it could be to link this as an internal library (hide all symbols): the |
Yeah, that's the case: cmake -DCMAKE_CXX_FLAGS="-Wl,--trace-symbol=_ZN4llvm23EnableABIBreakingChecksE"
ninja -v mlir_async_runtime
/usr/bin/clang++-14 -fPIC -Wl,--trace-symbol=_ZN4llvm23EnableABIBreakingChecksE -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror=mismatched-tags -Werror=global-constructors -O3 -DNDEBUG -Wl,--gdb-index -fuse-ld=lld -Wl,-z,defs -Wl,-z,nodelete -Wl,--color-diagnostics -Wl,--gc-sections -shared -Wl,-soname,libmlir_async_runtime.so.17git -o lib/libmlir_async_runtime.so.17git tools/mlir/lib/ExecutionEngine/CMakeFiles/mlir_async_runtime.dir/AsyncRuntime.cpp.o -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.a -lrt -ldl -lm /usr/lib/aarch64-linux-gnu/libz.so /usr/lib/aarch64-linux-gnu/libzstd.so /usr/lib/aarch64-linux-gnu/libtinfo.so lib/libLLVMDemangle.a && :
lib/libLLVMSupport.a(ABIBreak.cpp.o): definition of _ZN4llvm23EnableABIBreakingChecksE
So I think that this is already meant to be happening:
Just to confirm - this would "hide" the symbols, but there still would be multiple definition of / RUN: | mlir-cpu-runner \
// RUN: -e main -entry-point-result=void -O0 \
// RUN: -shared-libs=%mlir_c_runner_utils \
// RUN: -shared-libs=%mlir_runner_utils \
// RUN: -shared-libs=%mlir_async_runtime |
Yes, libSupport is an implementation detail of |
This took a bit of digging, but does the job: target_link_options(mlir_async_runtime PRIVATE "-Wl,-exclude-libs,ALL") I'll update https://reviews.llvm.org/D146935 accordingly. Does this make sense to you? |
This patch is primarily about the change in "mlir/tools/mlir-cpu-runner/CMakeLists.txt". LLJIT needs access to symbols (e.g. llvm_orc_registerEHFrameSectionWrapper) that will be defined in the executable when LLVM is linked statically. This change is consistent with how other tools within LLVM use LLJIT. It is required to make sure that: ``` $ mlir-cpu-runner --host-supports-jit ``` correctly returns `true` on platforms that do support JITting (in my case that's AArch64 Linux). The change in "mlir/lib/ExecutionEngine/CMakeLists.txt" is required to avoid ODR violations when symbols from `mlir-cpu-runner` are exported and when loading `libmlir_async_runtime.so` in `mlir-cpu-runner`. Specifically, to avoid `EnableABIBreakingChecks` being defined twice. For more context: * llvm#61712 * llvm#61856 * https://reviews.llvm.org/D146935 (this PR) This change relands ccdcfad Fixes llvm#61856 Differential Revision: https://reviews.llvm.org/D146935
Hi,
The following
RUN
line from async-group.mlir leads to ODR violation:Specifically, on my development AArch64 machine running Linux (I doubt the platform actually matters), I see the following:
And indeed, ASan is able to identify the invocation from
async-group.mlir
as ODR violation, see sanitizer-x86_64-linux-fast.This patch implements a workaround that helps silence ASan (there's also a bit more discussion there):
However, that's not a proper solution. To me it feels that
libmlir_async_runtime.so
should be refactored to fix this, but this isn't really my area of expertise and recommendations (as well as volunteers) are welcome :)CC @lhames @hctim
-Andrzej
The text was updated successfully, but these errors were encountered: