Skip to content

Commit

Permalink
feat: llvm compiler-rt via osxcross
Browse files Browse the repository at this point in the history
it adds llvm compiler-rt https://compiler-rt.llvm.org/
compiler-rt can be needed to build code using `__builtin_available()`

it fixes the following error on latest rust-linux-darwin-builder:1.60.0 or earlier

docker run --rm -it -v $PWD:/root/src \
    joseluisq/rust-linux-darwin-builder:1.60.0 \
    sh -c "x86_64-apple-darwin21.1-clang -mmacosx-version-min=10.12 main.c"

Undefined symbols for architecture x86_64:
  "___isOSVersionAtLeast", referenced from:
      _main in main-9c241f.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
  • Loading branch information
joseluisq committed May 4, 2022
1 parent 651d6a6 commit 35c121e
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ ARG OSX_CROSS_COMMIT=be2b79f444aa0b43b8695a4fb7b920bf49ecc01c
RUN set -eux \
&& DEBIAN_FRONTEND=noninteractive apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \
autoconf \
automake \
build-essential \
ca-certificates \
clang \
Expand All @@ -48,21 +50,27 @@ RUN set -eux \
file \
gcc-arm-linux-gnueabihf \
git \
libbz2-dev \
libgmp-dev \
libicu-dev \
libmpc-dev \
libmpfr-dev \
libpq-dev \
libsqlite3-dev \
libssl-dev \
libtool \
libxml2-dev \
linux-libc-dev \
llvm-dev \
lzma-dev \
musl-dev \
musl-tools \
patch \
pkgconf \
python \
python3 \
xutils-dev \
yasm \
zlib1g-dev \
# Clean up local repository of retrieved packages and remove the package lists
&& apt-get clean \
Expand Down Expand Up @@ -188,12 +196,29 @@ RUN set -eux \
&& echo "${OSX_SDK_SUM} ./tarballs/MacOSX${OSX_SDK_VERSION}.sdk.tar.xz" \
| sha256sum -c - \
&& env UNATTENDED=yes OSX_VERSION_MIN=${OSX_VERSION_MIN} ./build.sh \
&& rm -rf *~ taballs *.tar.xz \
&& rm -rf /tmp/* \
&& true

RUN set -eux \
&& cd /usr/local/osxcross \
&& echo "Building osxcross with compiler-rt..." \
# compiler-rt can be needed to build code using `__builtin_available()`
&& env DISABLE_PARALLEL_ARCH_BUILD=1 ./build_compiler_rt.sh \
&& true

ENV PATH $PATH:/usr/local/osxcross/target/bin

RUN set -eux \
&& echo "Testing osxcross with compiler-rt..." \
&& echo "int main(void){return 0;}" | xcrun clang -xc -o/dev/null -v - 2>&1 | grep "libclang_rt" 1>/dev/null \
&& echo "compiler-rt installed and working successfully!" \
&& true

RUN set -eux \
&& echo "Removing osxcross temp files..." \
&& rm -rf *~ taballs *.tar.xz \
&& rm -rf /tmp/* \
&& true

WORKDIR /root/src

CMD ["bash"]
Expand Down

0 comments on commit 35c121e

Please sign in to comment.