Skip to content

Commit

Permalink
feat: create libm.a instead of ld script on x86_64 for gnu static lin…
Browse files Browse the repository at this point in the history
…kage (#83)

Changes:
* [x] Add `file` utility to check info about the files
* [x] Add `nano` text editor for debugging purposes
* [x] For `x86_64` (`linux/amd64`) change `libm.a` from LD script (which
is like that only on this platform) to an actual static archive
consisting of `libm.a` and `ibmvec.a`. This is mandatory for `cargo` to
use this library properly when statically linking with `glibc` on GNU
targets.
  • Loading branch information
antonbaliasnikov authored Aug 2, 2024
1 parent 1c32e4f commit a9a4388
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions images/llvm_runner/ubuntu22-llvm17.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ RUN apt-get update && \
g++-9=9.* \
software-properties-common=0.99.* \
libz3-dev=4.8.* \
file=1:5.* \
nano=6.* \
&& rm -rf /var/lib/apt/lists/*

# Install LLVM 17
Expand Down Expand Up @@ -78,3 +80,12 @@ ENV PATH=/usr/lib/llvm-17/bin:${PATH} \
LD_LIBRARY_PATH=/usr/lib/llvm-17/lib:${LD_LIBRARY_PATH} \
LLVM_VERSION=17 \
CI_RUNNING=true

# Replace default libm.a which is a linker script on x86_64 to an actual lib implementation
# to allow Rust to link against it without issues
ARG TARGETPLATFORM
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
rm -f /lib/x86_64-linux-gnu/libm.a && \
ar -cqT /lib/x86_64-linux-gnu/libm.a /lib/x86_64-linux-gnu/libm-2.35.a /lib/x86_64-linux-gnu/libmvec.a && \
bash -c 'ar -M <<< $(echo -e "create /lib/x86_64-linux-gnu/libm.a\naddlib /lib/x86_64-linux-gnu/libm.a\nsave\nend")'; \
fi

0 comments on commit a9a4388

Please sign in to comment.