stargazing/cosmo-yices/Dockerfile

119 lines
4 KiB
Docker

# MAIN: https://yices.csl.sri.com/
# REPO: https://github.com/SRI-CSL/yices2/
FROM localhost/notwa-util AS downloader
ENV YICES_COMMIT=d28304671590ed04f13ce930aaae27015542c8ea
ENV YICES_SHA256=f1bd9979a9070e515fdc60d07836912e0058263f431b9b1a18f8975be1b95242
# MAIN: https://gmplib.org/
# REPO: https://gmplib.org/repo/
ENV GMP_VERSION=6.2.1
ENV GMP_SHA256=fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
# MAIN: http://fmv.jku.at/kissat/
# REPO: https://github.com/arminbiere/kissat
# FORK: https://github.com/BrunoDutertre/kissat
ENV KISSAT_COMMIT=315cd3227fd2321d29d10f7d8572011bf00174a5
ENV KISSAT_SHA256=031fca7efcb17c6f1921dd056052bd373de724e445fc2ed37bfdd5954148119f
RUN --mount=type=cache,id=common,target=/media/common,sharing=locked \
--mount=type=tmpfs,target=/tmp : \
&& acquire from=github repo=SRI-CSL/yices2 dest=/yices \
commit="$YICES_COMMIT" checksum="$YICES_SHA256" \
\
&& name=gmp \
&& remote_fn="$name-$GMP_VERSION.tar.xz" \
&& export local_fn="$remote_fn" \
&& export remote_url="https://gmplib.org/download/gmp/$remote_fn" \
&& export dest=/$name \
&& export sha256="$GMP_SHA256" \
&& acquire \
\
&& acquire from=github repo=arminbiere/kissat dest=/kissat \
commit="$KISSAT_COMMIT" checksum="$KISSAT_SHA256" \
;
FROM localhost/cosmo AS builder
RUN apk add --no-cache autoconf gperf make
RUN : \
&& cd /cosmopolitan \
&& tar zxf dist/headers.tar.gz \
;
COPY --chmod=0755 --from=localhost/notwa-util /nu/cosmocc /nu/quickconf /nu/shed /usr/bin/
COPY --from=downloader /kissat /kissat
WORKDIR /kissat
RUN : \
# the alarm function is located here: \
&& shed src/application.c '/#include <unistd.h>/i\\#include <time.h>' \
# completely override CFLAGS: \
&& shed configure '/passtocompiler -fpic/i\\CFLAGS=" -O2 -g -Wall"' \
# we don't need -static here because it's already part of cosmocc: \
&& CC=cosmocc ./configure \
;
RUN : \
&& make -j2 \
&& install -m 0644 -D -t /usr/local/lib build/libkissat.a \
&& install -m 0644 -D -t /usr/local/include -m644 src/kissat.h \
;
COPY --from=downloader /gmp /gmp
WORKDIR /gmp
RUN : \
&& CC=cosmocc CFLAGS="-O2 -g" \
# specify some generic old CPU for best compatibility/reproduciblity. \
# core2 introduced SSSE3, which cosmopolitan depends on, so use that: \
ac_cv_build='core2-pc-linux-gnu' \
ac_cv_host='core2-pc-linux-gnu' \
# this check takes ages for some reason, so just hardcode it here: \
gmp_cv_c_double_format='IEEE little endian' \
quickconf --disable-shared \
;
RUN : \
&& make -j2 \
&& make install \
;
COPY --from=downloader /yices /yices
WORKDIR /yices
RUN : \
# patch up some trivial incompatibilities with cosmopolitan: \
&& shed src/context/context.c 's/\bdonothing\b/&_/g' \
&& shed src/terms/bv_constants.c 's/\bhextoint\b/&_/g' \
&& shed src/terms/bv64_constants.c 's/\bhextoint\b/&_/g' \
&& shed src/utils/timeout.c '/#include <unistd.h>/i\\#include <time.h>' \
# the static-lib target attempts to build a dynamic library. don't do that. \
&& shed src/Makefile 's/ $(static_libyices_dynamic)//g' \
\
&& autoconf \
&& CC=cosmocc \
CFLAGS="-O2 -g" \
CPPFLAGS="-I/usr/local/include -DHAVE_KISSAT" \
LDFLAGS="-L/usr/local/lib" \
LIBS="-lkissat" \
quickconf --prefix= \
;
RUN make -j2 static-dist
RUN : \
&& mv build/x86_64-pc-linux-gnu-release/static_dist dist \
&& cd dist/bin \
&& for bin in yices yices-sat yices-smt yices-smt2 \
;do : \
&& mv "$bin" "$bin.com.dbg" \
&& objcopy -S -O binary "$bin.com.dbg" "$bin.com" \
;done \
&& cd /kissat/build \
&& mv "kissat" "kissat.com.dbg" \
&& objcopy -S -O binary "kissat.com.dbg" "kissat.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 --from=builder /yices/config.cache /yices/config.log /yices/config.status /var/local/
COPY --from=builder /yices/dist/bin /bin
COPY --chmod=0755 --from=builder /kissat/build/kissat.com /kissat/build/kissat.com.dbg /bin/
ENTRYPOINT ["/bin/ape", "/bin/yices.com"]