From 9cf3d3eed9144ccc870fd13268af8dcdb3d60232 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 4 Oct 2022 04:55:30 -0700 Subject: [PATCH] add cosmo-muon --- cosmo-muon/Dockerfile | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 cosmo-muon/Dockerfile diff --git a/cosmo-muon/Dockerfile b/cosmo-muon/Dockerfile new file mode 100644 index 0000000..9b33d22 --- /dev/null +++ b/cosmo-muon/Dockerfile @@ -0,0 +1,53 @@ +# MAIN: https://muon.build/ +# REPO: https://git.sr.ht/~lattis/muon +FROM localhost/notwa-util AS downloader +ARG MUON_COMMIT=679b0b40e3d813650c8b8505d8675e7e56b86a4d +ARG MUON_SHA256=a774901cba8b2c5dde58d746e5aaf9234bf513434a3e5df83736de0a90c1c356 +RUN --mount=type=cache,id=common,target=/media/common,sharing=locked \ + --mount=type=tmpfs,target=/tmp : \ + && acquire from=sourcehut repo=lattis/muon dest=/muon \ + commit="$MUON_COMMIT" checksum="$MUON_SHA256" \ +; + +FROM localhost/cosmo AS builder + +RUN apk add --no-cache ninja +COPY --chmod=0755 --from=localhost/notwa-util /nu/cosmocc /usr/bin/ + +ENV CC=cosmocc CFLAGS="-Os -g -fdiagnostics-color=always" + +# TODO: why is this test failing? +# c compiler: supports argument '-Wundef': NO +COPY --from=downloader /muon /muon +WORKDIR /muon +RUN : \ + && tar zxf /cosmopolitan/dist/headers.tar.gz -C /cosmopolitan \ + && ./bootstrap.sh build \ +; + +COPY --chmod=0755 --from=localhost/notwa-util /nu/shed /usr/bin/ +RUN : \ +# forcibly disable handling of 32-bit ELF files (we lack the headers) \ + && shed src/platform/posix/rpath_fixer.c \ +'/\bcase ELFCLASS32:/,/\bbreak;/d' \ +'s@.*Elf32.*@/* & */@' \ +# use cosmopolitan linenoise instead of bestline \ + && echo >subprojects/bestline/bestline.c \ + && printf '%s\n' >subprojects/bestline/bestline.h \ +'#include "third_party/linenoise/linenoise.h"' \ +'#define bestlineHistoryAdd linenoiseHistoryAdd' \ +'#define bestlineHistoryFree linenoiseHistoryFree' \ +'#define bestlineWithHistory linenoiseWithHistory' \ +\ + && build/muon setup -Dstatic=true build \ + && ninja -j2 -C build \ + && cd build \ + && mv muon muon.com.dbg \ + && objcopy -S -O binary muon.com.dbg muon.com \ +; + +FROM scratch AS runner +COPY --chmod=0755 --from=localhost/notwa-util /nu/busybox /bin/busybox +COPY --chmod=0755 --from=builder /cosmopolitan/dist/def/ape.elf /bin/ape +COPY --chmod=0755 --from=builder /muon/build/muon.com /muon/build/muon.com.dbg /bin/ +ENTRYPOINT ["/bin/ape", "/bin/muon.com"]