Repository navigation
Closed as not planned
Labels
staleIssue has seen no recent activity
Description
Forwarding this issue. Original is here: purpleprotocol/mimalloc_rust#91
This is the build error:
#0 331.7 error: linking with `arm-linux-gnueabihf-ld` failed: exit status: 1
#0 331.7 |
#0 331.7 = note: LC_ALL="C" PATH="/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "arm-linux-gnueabihf-ld" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crti.o" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crtbegin.o" "/tmp/rustcTnL0FL/symbols.o" "/build/target/arm-unknown-linux-musleabihf/release_optimized/deps/atrium-9d7c42d4a7254134.atrium.436a5141-cgu.0.rcgu.o" "--as-needed" "-L" "/build/target/arm-unknown-linux-musleabihf/release_optimized/deps" "-L" "/build/target/release_optimized/deps" "-L" "/build/target/arm-unknown-linux-musleabihf/release_optimized/build/ring-f953b60540da6b61/out" "-L" "/build/target/arm-unknown-linux-musleabihf/release_optimized/build/libmimalloc-sys-7044e007f4223565/out" "-L" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib" "-Bstatic" "/tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib" "/tmp/rustcTnL0FL/libring-61e880a3b28c0c72.rlib" "-lunwind" "-lc" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libcompiler_builtins-eb461ae3a10c4720.rlib" "-Bdynamic" "--eh-frame-hdr" "-znoexecstack" "-L" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib" "-L" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained" "-o" "/build/target/arm-unknown-linux-musleabihf/release_optimized/deps/atrium-9d7c42d4a7254134" "--gc-sections" "-static" "-zrelro" "-znow" "-O1" "--strip-all" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crtend.o" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crtn.o"
#0 331.7 = note: arm-linux-gnueabihf-ld: /tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib(static.o): in function `mi_stat_add.constprop.0':
#0 331.7 static.c:(.text.mi_stat_add.constprop.0+0x3c): undefined reference to `__atomic_fetch_add_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text.mi_stat_add.constprop.0+0x4c): undefined reference to `__atomic_fetch_add_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text.mi_stat_add.constprop.0+0x5c): undefined reference to `__atomic_fetch_add_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text.mi_stat_add.constprop.0+0x6c): undefined reference to `__atomic_fetch_add_8'
#0 331.7 arm-linux-gnueabihf-ld: /tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib(static.o): in function `mi_stats_add.constprop.0':
#0 331.7 static.c:(.text.mi_stats_add.constprop.0+0xe4): undefined reference to `__atomic_fetch_add_8'
#0 331.7 arm-linux-gnueabihf-ld: /tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib(static.o):static.c:(.text.mi_stats_add.constprop.0+0xf4): more undefined references to `__atomic_fetch_add_8' follow
#0 331.7 arm-linux-gnueabihf-ld: /tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib(static.o): in function `_mi_stat_increase':
#0 331.7 static.c:(.text._mi_stat_increase+0xc0): undefined reference to `__atomic_load_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text._mi_stat_increase+0xec): undefined reference to `__atomic_compare_exchange_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text._mi_stat_increase+0x108): undefined reference to `__atomic_fetch_add_8'
#0 331.7 arm-linux-gnueabihf-ld: /tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib(static.o): in function `_mi_stat_decrease':
#0 331.7 static.c:(.text._mi_stat_decrease+0xa8): undefined reference to `__atomic_fetch_add_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text._mi_stat_decrease+0xd0): undefined reference to `__atomic_load_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text._mi_stat_decrease+0xfc): undefined reference to `__atomic_compare_exchange_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text._mi_stat_decrease+0x118): undefined reference to `__atomic_fetch_add_8'
#0 331.7 arm-linux-gnueabihf-ld: /tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib(static.o): in function `mi_process_info':
#0 331.7 static.c:(.text.mi_process_info+0x60): undefined reference to `__atomic_load_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text.mi_process_info+0x70): undefined reference to `__atomic_load_8'
#0 331.7 arm-linux-gnueabihf-ld: /tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib(static.o): in function `mi_segment_cache_purge.constprop.0':
#0 331.7 static.c:(.text.mi_segment_cache_purge.constprop.0+0xc4): undefined reference to `__atomic_load_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text.mi_segment_cache_purge.constprop.0+0x128): undefined reference to `__atomic_load_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text.mi_segment_cache_purge.constprop.0+0x17c): undefined reference to `__atomic_store_8'
#0 331.7 arm-linux-gnueabihf-ld: /tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib(static.o): in function `mi_segment_cache_purge.constprop.1':
#0 331.7 static.c:(.text.mi_segment_cache_purge.constprop.1+0x70): undefined reference to `__atomic_load_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text.mi_segment_cache_purge.constprop.1+0xc0): undefined reference to `__atomic_load_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text.mi_segment_cache_purge.constprop.1+0x110): undefined reference to `__atomic_store_8'
#0 331.7 arm-linux-gnueabihf-ld: /tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib(static.o): in function `mi_segment_cache_pop_ex':
#0 331.7 static.c:(.text.mi_segment_cache_pop_ex+0x118): undefined reference to `__atomic_store_8'
#0 331.7 arm-linux-gnueabihf-ld: /tmp/rustcTnL0FL/liblibmimalloc_sys-868a4ff9e7af301d.rlib(static.o): in function `_mi_segment_cache_push':
#0 331.7 static.c:(.text._mi_segment_cache_push+0xec): undefined reference to `__atomic_store_8'
#0 331.7 arm-linux-gnueabihf-ld: static.c:(.text._mi_segment_cache_push+0x23c): undefined reference to `__atomic_store_8'
#0 331.7
#0 331.7 = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
#0 331.7 = note: use the `-l` flag to specify native libraries to link
#0 331.7 = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
Metadata
Metadata
Assignees
Labels
staleIssue has seen no recent activity
Activity
daanx commentedon Apr 7, 2023
Ah, it looks like it cannot find the atomic functions?
Can you try to use the
-DMI_USE_LIBATOMIC=ONflag to cmake to see if this solves the issue?(the cmake should detect automatically if -latomic is needed but it seems to fail here? is it due to musl ?)
octavonce commentedon Apr 7, 2023
Nicolas PERNOUD (@nicolaspernoud)
nicolaspernoud commentedon Apr 7, 2023
I can try, where do I need to put the flag ? Somewhere in the cargo build command ?
devnexen commentedon Apr 7, 2023
if you mean the libmimalloc-sys/build.rs then yes.
nicolaspernoud commentedon Apr 10, 2023
Well, that is very strange, as trying to isolate the problem gives another error... both for armv6 and arm64 (arm64 used to work).
Using that Dockerfile :
It works when building the Mimalloc Rust crate directly, but not when building the simplest example application with :
The error is then :
daanx commentedon Apr 14, 2023
ah, that looks like a strange error; not sure if this comes from mimalloc?
It may have been resolved with pr #724 which may have caused a link error? (latest
dev/dev-sliceinclude this patch).nicolaspernoud commentedon Apr 17, 2023
Well, with forcing mimalloc to latest dev-slice, that gives the following error :
nicolaspernoud commentedon Apr 17, 2023
I created an issue on the rust crate, since it is difficult to work out where the problem comes from : purpleprotocol/mimalloc_rust#94 .
possible fix for warnings on armv6 (issue #719)
daanx commentedon Apr 17, 2023
If I look at this post it seems to me that the C or C++ compiler is not consistent -- this is especially tricky with
musl-gccand cross compilation. Maybe theCCandCXXenvironment is not set correctly whencmakeis invoked the first time for mimalloc?(Note that to fix this you need to remove the cmake build directory first as this is cached so make clean is not enough.)
Also, perhaps it is C versus C++ compilation (mimalloc uses the C compiler by default and you need
-DMI_USE_CXX=ONto build as a C++ library).octavonce commentedon Apr 17, 2023
Daan (@daanx) Rust uses the C abi and C++ is always invoked through a C layer so cmake is not used. The native gcc compiler is invoked through the build file. The only time a C++ compiler is used is on Windows with msvc.
daanx commentedon Apr 24, 2023
Does the latest release fix the build issue?
octavonce commentedon Apr 25, 2023
Daan (@daanx) Compiles on musl: https://github.com/purpleprotocol/purplecoin/actions/runs/4801721022/jobs/8544297845
nicolaspernoud commentedon Apr 26, 2023
Using
mimalloc = "0.1.37", I still have the linking issue :daanx commentedon Apr 26, 2023
Ah strange. But given the error I believe this is not a mimalloc issue. If we see this post it seems a cross compilation issue to me in the build files. I see the build command invokes
"cc"for example, shouldn't that be"$CC"? I am guessing one of the.ofiles has been compiled not for armv6 or musl (but x86_64 or glibc) and that causes trouble later on. Maybe it is found in one of the paths, likes/usr/localbefore it looks at/usr/sbinor something? Maybe you can useobj dumpornmto see if any of the linked.o/.afiles has been build for another platform?Maybe
mimallochas been build with for the wrong platform, or maybe linked with a wrong.ofile? (mimalloc has few dependencies, but perhaps libatomic or pthread?Try to run the build verbosely so we can see all exact build commands.
nicolaspernoud commentedon Apr 28, 2023
I just made a gist with the code : . It is possible to git clone it with
git clone https://gist.github.com/a1400af7d11ae4fd52d2de23b49e07bd.gitand to runtest.shto get the results.objdump gives the following result with /usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o:
file format elf32-little
architecture: UNKNOWN!, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000
It seems that it is ARM !?
Gelbpunkt commentedon May 22, 2023
The error message makes it pretty clear that it is attempting to link using
ld.ldis not able to link for any architecture other than the one it is built for. If you want to actually link ARMv6 objects on x86_64, you will have to use a cross-compiledldor simply the LLVMlld, which is able to handle all architectures that LLVM supports.To use a linker capable of handling ARMv6, you can e.g. just tell it to use your
gccby adding.cargo/config.toml:Which will make it compile further and fail with the same atomic errors.
nicolaspernoud commentedon May 22, 2023
Thanks, my bad, I had actually that set up on my main code but I forgot to include it in the gist.
The gist has been updated, to reproduce the issue :
The output is still :
github-actions commentedon Aug 29, 2026
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 14 days. Thank you for your contributions!
github-actions commentedon Sep 12, 2026
This issue was closed because it has been inactive for 14 days since being marked as stale. Please feel free to reopen if this is still an active issue.