Skip to content
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

Cannot build an (even the simplest) app on ARMv6 #94

Open
nicolaspernoud opened this issue Apr 17, 2023 · 5 comments
Open

Cannot build an (even the simplest) app on ARMv6 #94

nicolaspernoud opened this issue Apr 17, 2023 · 5 comments

Comments

@nicolaspernoud
Copy link

nicolaspernoud commented Apr 17, 2023

Hello,

Using that Dockerfile :

FROM rust:1.68
RUN rustup target add arm-unknown-linux-musleabihf
RUN apt update && apt install -y musl-tools musl-dev binutils-arm-linux-gnueabihf gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu libcap2-bin
RUN ln -s /usr/bin/arm-linux-gnueabihf-gcc /usr/bin/arm-linux-musleabihf-gcc
RUN ln -s /usr/bin/aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-musl-gcc

WORKDIR /build

COPY . .

RUN cargo build --release --target arm-unknown-linux-musleabihf

Works for building the Mimalloc Rust crate directly, but not when building the simplest example application with :

  • Cargo.toml :
[package]
name = "mimalloc_test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
mimalloc = "0.1"
  • main.rs :
use mimalloc::MiMalloc;

#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

fn main() {
    let _s = String::from("TEST");
    println!("Hello, world!");
}

The error is then :

 > [8/8] RUN cargo build --release --target arm-unknown-linux-musleabihf:                                                      
#0 0.662     Updating crates.io index                                                                                          
#0 60.34  Downloading crates ...                                                                                               
#0 60.53   Downloaded mimalloc v0.1.36                                                                                         
#0 60.54   Downloaded cc v1.0.79                                                                                               
#0 60.55   Downloaded libc v0.2.141
#0 60.61   Downloaded libmimalloc-sys v0.1.32
#0 60.73    Compiling cc v1.0.79
#0 60.73    Compiling libc v0.2.141
#0 61.49    Compiling libmimalloc-sys v0.1.32
#0 64.25    Compiling mimalloc v0.1.36
#0 64.37    Compiling mimalloc_test v0.1.0 (/build)
#0 64.53 error: linking with `cc` failed: exit status: 1
#0 64.53   |
#0 64.53   = 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" "cc" "/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/rustcDVTz23/symbols.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-1028ca129bacc567.mimalloc_test.ec68869b-cgu.0.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-1028ca129bacc567.mimalloc_test.ec68869b-cgu.1.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-1028ca129bacc567.mimalloc_test.ec68869b-cgu.2.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-1028ca129bacc567.mimalloc_test.ec68869b-cgu.3.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-1028ca129bacc567.mimalloc_test.ec68869b-cgu.4.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-1028ca129bacc567.mimalloc_test.ec68869b-cgu.5.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-1028ca129bacc567.mimalloc_test.ec68869b-cgu.6.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-1028ca129bacc567.mimalloc_test.ec68869b-cgu.7.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-1028ca129bacc567.5f9bw7r2pmjbtmj8.rcgu.o" "-Wl,--as-needed" "-L" "/build/target/arm-unknown-linux-musleabihf/release/deps" "-L" "/build/target/release/deps" "-L" "/build/target/arm-unknown-linux-musleabihf/release/build/libmimalloc-sys-b7fd4f6c2fed1648/out" "-L" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib" "-Wl,-Bstatic" "/build/target/arm-unknown-linux-musleabihf/release/deps/libmimalloc-42b3f935fd55b22f.rlib" "/build/target/arm-unknown-linux-musleabihf/release/deps/liblibmimalloc_sys-f583ddf93b4852e5.rlib" "/build/target/arm-unknown-linux-musleabihf/release/deps/liblibc-8cbac95de92d3f8a.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libstd-156f4170e33b8df4.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libpanic_unwind-e270422b4fca28e3.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libobject-49cd4b382f505f9d.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libmemchr-eed355165f4866e0.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libaddr2line-7e4a417a98d3e1fb.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libgimli-19ab14456ef67ec3.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/librustc_demangle-94668fbad859bad0.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libstd_detect-ddbf1f9293a44a9c.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libhashbrown-fac09f5d7f857f6b.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libminiz_oxide-f840348d8fb3422c.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libadler-f7fa56e66eb13c9f.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/librustc_std_workspace_alloc-9cb6dfec2a561167.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libunwind-b9f2e553466d47cf.rlib" "-lunwind" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libcfg_if-fc80282540c648fb.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/liblibc-9f5698308f331dfe.rlib" "-lc" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/liballoc-5cb9b7f1b32dd35b.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/librustc_std_workspace_core-b2b48d67f7264a3c.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libcore-21361f74a01c8c9e.rlib" "/usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libcompiler_builtins-eb461ae3a10c4720.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-nostartfiles" "-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/deps/mimalloc_test-1028ca129bacc567" "-Wl,--gc-sections" "-static" "-no-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs" "/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 64.53   = note: /usr/bin/ld: /usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 64.53           /usr/bin/ld: /usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 64.53           /usr/bin/ld: /usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 64.53           /usr/bin/ld: /usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 64.53           /usr/bin/ld: /usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 64.53           /usr/bin/ld: /usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 64.53           /usr/bin/ld: /usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 64.53           /usr/bin/ld: /usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 64.53           /usr/bin/ld: /usr/local/rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: error adding symbols: file in wrong format
#0 64.53           collect2: error: ld returned 1 exit status
#0 64.53           
#0 64.53 
#0 64.53 error: could not compile `mimalloc_test` due to previous error
------
Dockerfile:11
--------------------
   9 |     COPY . .
  10 |     
  11 | >>> RUN cargo build --release --target arm-unknown-linux-musleabihf
--------------------
ERROR: failed to solve: process "/bin/sh -c cargo build --release --target arm-unknown-linux-musleabihf" did not complete successfully: exit code: 101

There is another issue on mimalloc related : microsoft/mimalloc#719 .

@nicolaspernoud
Copy link
Author

Using mimalloc = "0.1.37", I still have the linking issue :

 > [8/8] RUN cargo build --release --target arm-unknown-linux-musleabihf:
#0 6.479     Updating crates.io index
#0 84.56  Downloading crates ...
#0 85.10   Downloaded libc v0.2.141
#0 85.18   Downloaded mimalloc v0.1.37
#0 85.18   Downloaded libmimalloc-sys v0.1.33
#0 85.40   Downloaded cc v1.0.79
#0 85.58    Compiling libc v0.2.141
#0 85.58    Compiling cc v1.0.79
#0 87.28    Compiling libmimalloc-sys v0.1.33
#0 92.96    Compiling mimalloc v0.1.37
#0 93.12    Compiling mimalloc_test v0.1.0 (/build)
#0 93.31 error: linking with `cc` failed: exit status: 1
#0 93.31   |
#0 93.31   = note: LC_ALL="C" PATH="/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/rustup/toolchains/1.69.0-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" "cc" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crti.o" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crtbegin.o" "/tmp/rustcwBHKjU/symbols.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-0dd013925a891581.mimalloc_test.20080a45-cgu.0.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-0dd013925a891581.mimalloc_test.20080a45-cgu.1.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-0dd013925a891581.mimalloc_test.20080a45-cgu.2.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-0dd013925a891581.mimalloc_test.20080a45-cgu.3.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-0dd013925a891581.mimalloc_test.20080a45-cgu.4.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-0dd013925a891581.mimalloc_test.20080a45-cgu.5.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-0dd013925a891581.mimalloc_test.20080a45-cgu.6.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-0dd013925a891581.mimalloc_test.20080a45-cgu.7.rcgu.o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-0dd013925a891581.ssojj11ycp7gnke.rcgu.o" "-Wl,--as-needed" "-L" "/build/target/arm-unknown-linux-musleabihf/release/deps" "-L" "/build/target/release/deps" "-L" "/build/target/arm-unknown-linux-musleabihf/release/build/libmimalloc-sys-a0485197edb752df/out" "-L" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib" "-Wl,-Bstatic" "/build/target/arm-unknown-linux-musleabihf/release/deps/libmimalloc-ea0159e9580ea75a.rlib" "/build/target/arm-unknown-linux-musleabihf/release/deps/liblibmimalloc_sys-e3ce8485e44d8658.rlib" "/build/target/arm-unknown-linux-musleabihf/release/deps/liblibc-1d35e53f1586ef64.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libstd-fbbd886251fe1a89.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libpanic_unwind-1bd35c941b382326.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libobject-20ab481ab8e3f957.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libmemchr-6d5fa66af62812db.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libaddr2line-c5d7090aa83583f0.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libgimli-e7814b2b78a60b29.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/librustc_demangle-f416c52974a5b58b.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libstd_detect-36d61d6924dae007.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libhashbrown-75360821ed2ae48e.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libminiz_oxide-01f71d17d25e0689.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libadler-07396f3249a0ab27.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/librustc_std_workspace_alloc-1023e934ee76baba.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libunwind-69a54df3a7ca128a.rlib" "-lunwind" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libcfg_if-0f0cb69d8bf032e0.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/liblibc-eb499cd33737ec75.rlib" "-lc" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/liballoc-04652832e0f93b15.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/librustc_std_workspace_core-43de1fa801649533.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libcore-9688301b6972aad9.rlib" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/libcompiler_builtins-8de29b66878012ac.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-nostartfiles" "-L" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib" "-L" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained" "-o" "/build/target/arm-unknown-linux-musleabihf/release/deps/mimalloc_test-0dd013925a891581" "-Wl,--gc-sections" "-static" "-no-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crtend.o" "/usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crtn.o"
#0 93.31   = note: /usr/bin/ld: /usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 93.31           /usr/bin/ld: /usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 93.31           /usr/bin/ld: /usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 93.31           /usr/bin/ld: /usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 93.31           /usr/bin/ld: /usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 93.31           /usr/bin/ld: /usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 93.31           /usr/bin/ld: /usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 93.31           /usr/bin/ld: /usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: relocations in generic ELF (EM: 40)
#0 93.31           /usr/bin/ld: /usr/local/rustup/toolchains/1.69.0-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crt1.o: error adding symbols: file in wrong format
#0 93.31           collect2: error: ld returned 1 exit status
#0 93.31           
#0 93.31 
#0 93.33 error: could not compile `mimalloc_test` due to previous error

@octavonce octavonce reopened this Apr 26, 2023
@zouyalong-coder
Copy link

It's caused by a wrong linker. You can make it by setting the right one.
Add such lines into .cargo/config.toml

[target.aarch64-unknown-linux-musl]
linker = "aarch64-openwrt-linux-musl-gcc"

@nicolaspernoud
Copy link
Author

No, it does not change anything, beside the compilation target is arm here and not aarch64.
Please test before posting comments.

For reference, it does not work if the arm linker as well :

[target.arm-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-ld"

@notorca
Copy link
Contributor

notorca commented May 16, 2024

cargo test fails when running on on armv6hf device, with link error. Cross-compilation is not used.

 "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /usr/bin/ld: /home/lorca/src/mimalloc_rust/target/debug/deps/liblibmimalloc_sys-f8df32c9818934ff.rlib(98cfcaec7182b1d8-static.o): in function `mi_atomic_addi64_relaxed':
          /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/include/mimalloc/atomic.h:116: undefined reference to `__atomic_fetch_add_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/target/debug/deps/liblibmimalloc_sys-f8df32c9818934ff.rlib(98cfcaec7182b1d8-static.o): in function `mi_atomic_maxi64_relaxed':
          /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/include/mimalloc/atomic.h:119: undefined reference to `__atomic_load_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/include/mimalloc/atomic.h:120: undefined reference to `__atomic_compare_exchange_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/target/debug/deps/liblibmimalloc_sys-f8df32c9818934ff.rlib(98cfcaec7182b1d8-static.o): in function `mi_arena_schedule_purge':
          /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/src/arena.c:489: undefined reference to `__atomic_load_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/src/arena.c:491: undefined reference to `__atomic_fetch_add_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/src/arena.c:494: undefined reference to `__atomic_store_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/target/debug/deps/liblibmimalloc_sys-f8df32c9818934ff.rlib(98cfcaec7182b1d8-static.o): in function `mi_arena_try_purge':
          /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/src/arena.c:530: undefined reference to `__atomic_load_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/src/arena.c:535: undefined reference to `__atomic_compare_exchange_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/src/arena.c:577: undefined reference to `__atomic_compare_exchange_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/target/debug/deps/liblibmimalloc_sys-f8df32c9818934ff.rlib(98cfcaec7182b1d8-static.o): in function `mi_manage_os_memory_ex2':
          /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/src/arena.c:923: undefined reference to `__atomic_store_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/target/debug/deps/liblibmimalloc_sys-f8df32c9818934ff.rlib(98cfcaec7182b1d8-static.o): in function `mi_process_info':
          /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/src/stats.c:449: undefined reference to `__atomic_load_8'
          /usr/bin/ld: /home/lorca/src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/src/stats.c:450: undefined reference to `__atomic_load_8'
          collect2: error: ld returned 1 exit status

@notorca
Copy link
Contributor

notorca commented May 16, 2024

Adding linking with libatomic fixes the build, I'll prepare a PR with conditional linking for arm-unknown-linux-musleabihf

diff --git a/libmimalloc-sys/build.rs b/libmimalloc-sys/build.rs
index fc1743e..ee72de8 100644
--- a/libmimalloc-sys/build.rs
+++ b/libmimalloc-sys/build.rs
@@ -53,4 +53,5 @@ fn main() {
     }

     build.compile("mimalloc");
+    println!("cargo:rustc-link-lib=dylib=atomic");
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants