purpleprotocol / mimalloc_rust

A Rust wrapper over Microsoft's MiMalloc memory allocator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ARM built on x64 does not start

nicolaspernoud opened this issue · comments

Hello,

When building a container using docker buildx on an x64 computer with the following Dockerfile :

FROM rust:1.68
RUN rustup target add aarch64-unknown-linux-musl
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 aarch64-unknown-linux-musl

ENTRYPOINT ["./target/aarch64-unknown-linux-musl/release/myapp"]

Starting the container on the target ARM 64 computer gives memory allocation of 5 bytes failed. It works well without mimalloc.

@nicolaspernoud Maybe try the new version, there were platform specific errors in the past release which were fixed today.

Yes, that seems to work now.

There is an altogether different problem as well (it was so with the previous version too) : it builds (and now starts) for arm64 but not for armv6. That is not relevant for my use case, but just to let you know, there is the build output here :

#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)