purpleprotocol / mimalloc_rust

A Rust wrapper over Microsoft's MiMalloc memory allocator
MIT License
481 stars 42 forks source link

libmimalloc-sys v0.1.39->v0.1.41 introduced build failure on some platforms #111

Closed hombit closed 1 month ago

hombit commented 2 months ago

I use mimalloc in one of my projects to build Rust-powered Python packages. I noticed that after the recent update from 0.1.39 to 0.1.41, the libmimalloc-sys build has failed with the following error:

cargo:warning=In file included from c_src/mimalloc/src/alloc.c:14,
  cargo:warning=                 from c_src/mimalloc/src/static.c:23:
  cargo:warning=c_src/mimalloc/include/mimalloc/prim.h: In function ‘_mi_prim_thread_id’:
  cargo:warning=c_src/mimalloc/include/mimalloc/prim.h:240:21: error: ‘__builtin_thread_pointer’ is not supported on this target
  cargo:warning=  240 |   return (uintptr_t)__builtin_thread_pointer();
  cargo:warning=      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~

  --- stderr

  error occurred: Command "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "c_src/mimalloc/include" "-I" "c_src/mimalloc/src" "-Wall" "-Wextra" "-ftls-model=initial-exec" "-DMI_DEBUG=0" "-o" "/project/target/debug/build/libmimalloc-sys-c0ac1fb27ae015bf/out/98cfcaec7182b1d8-static.o" "-c" "c_src/mimalloc/src/static.c" with args cc did not execute successfully (status code exit status: 1).

This can be reproduced with Docker, create Dockerfile and run

docker build -t build_libmimalloc-sys .
docker run --rm build_libmimalloc-sys
FROM quay.io/pypa/manylinux2014_x86_64

# Update Certificates
RUN yum install -y openssl-devel

# Install Rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y
ENV PATH="${PATH}:/root/.cargo/bin"

# Create a project
RUN cargo init /project
WORKDIR /project
RUN cargo add libmimalloc-sys

# Build the project
CMD ["cargo", "build"]

It’s even more confusing that my CI builds pass for all MUSL-based and all ARM64 images, but not for GLIBC PPC64LE: https://github.com/light-curve/light-curve-python/actions/runs/8793140128

cfvescovo commented 2 months ago

Same issue here, I do not know what caused it

octavonce commented 2 months ago

Seems to be an upstream issue. This check seems to pass in your case but __builtin_thread_pointer is not available on that target.

@daanx

hombit commented 2 months ago

Should I file an issue for the original C library?

octavonce commented 2 months ago

Yes

cfvescovo commented 2 months ago

I got it to work by changing the distro I am using for my containers. I switched from debian bullseye to ubuntu latest (LTS). However, I did not investigate further.

ldemidov commented 2 months ago

Hitting the same issue here on a centos7 based container (quay.io/pypa/manylinux2014_x86_64). Unfortunately we're stuck with this container because we need to support a glibc 2.17 compatible binary.

octavonce commented 1 month ago

Please check the latest release

hombit commented 1 month ago

Thank you, it is fixed now!