Skip to content

Commit 8566635

Browse files
add musl build
1 parent e865adf commit 8566635

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

musl/Dockerfile.musl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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

musl/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
docker build --tag clangbuiltlinux/containers:musl . -f Dockerfile.musl

musl/hello.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include <stdio.h>
2+
int main() { puts("hello world"); }

0 commit comments

Comments
 (0)