|
| 1 | +FROM alpine:edge |
| 2 | + |
| 3 | +# TODO: change to container registry |
| 4 | +COPY --from=clangbuiltlinux/containers:llvm-project llvm-project/llvm/build/bin /usr/local/bin |
| 5 | +COPY --from=clangbuiltlinux/containers:llvm-project /usr/local/lib /usr/local/lib |
| 6 | +COPY --from=clangbuiltlinux/containers:llvm-project /usr/local/include /usr/local/include |
| 7 | +RUN ln -s /usr/local/lib/x86_64-alpine-linux-musl/libc++abi.so.1 /usr/lib/. && \ |
| 8 | + ln -s /usr/local/lib/x86_64-alpine-linux-musl/libc++.a /usr/lib/. && \ |
| 9 | + ln -s /usr/local/lib/x86_64-alpine-linux-musl/libc++abi.a /usr/lib/. && \ |
| 10 | + ln -s /usr/local/lib/x86_64-alpine-linux-musl/libc++.so.1 /usr/lib/. && \ |
| 11 | + ln -s /usr/local/lib/x86_64-alpine-linux-musl/libunwind.so.1 /usr/lib/. && \ |
| 12 | + ln -s /usr/local/lib/x86_64-alpine-linux-musl/libunwind.a /usr/lib/. |
| 13 | + |
| 14 | +RUN apk add wget |
| 15 | + |
| 16 | +RUN wget --no-clobber --no-verbose https://musl.libc.org/releases/musl-1.2.3.tar.gz && \ |
| 17 | + tar xvf musl-1.2.3.tar.gz |
| 18 | + |
| 19 | +# TODO: doesn't musl need the kernel headers? |
| 20 | +#COPY --from=clangbuiltlinux/containers:linux /sysroot /sysroot |
| 21 | + |
| 22 | +RUN mkdir musl-1.2.3/build |
| 23 | +RUN cd musl-1.2.3/build && \ |
| 24 | + CC=clang ../configure --prefix=/usr --syslibdir=/usr/lib |
| 25 | + |
| 26 | +# TODO: build llvm-ar |
| 27 | +RUN apk add make llvm13 |
| 28 | +RUN cd musl-1.2.3/build && \ |
| 29 | + make -j$(nproc) AR=llvm-ar RANLIB=llvm-ranlib |
| 30 | + |
| 31 | +RUN cd musl-1.2.3/build && \ |
| 32 | + make -j$(nproc) DESTDIR=/sysroot install-headers |
| 33 | + |
| 34 | +RUN cd musl-1.2.3/build && \ |
| 35 | + make -j$(nproc) DESTDIR=/sysroot install-libs |
| 36 | + |
| 37 | +COPY hello.c . |
| 38 | +RUN clang --sysroot=/sysroot hello.c && ./a.out |
0 commit comments