From 1ae5e60208ccefa783e34fb81dfec547cd49ed9f Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Mon, 12 Jun 2023 15:40:04 +0200 Subject: [PATCH] split `do_everything` into separate files (for gcc9) --- notwa-util/cosmo-kuroko9 | 117 ++++++++ notwa-util/cosmo-mini9 | 50 ++++ notwa-util/cosmo-muon9 | 27 ++ notwa-util/cosmo-yices9 | 64 +++++ notwa-util/cosmopolitan-bootstrap9 | 57 ++++ notwa-util/cosmopolitan-install9 | 55 ++++ notwa-util/cosmopolitan9 | 32 +++ notwa-util/do_everything | 434 +---------------------------- 8 files changed, 409 insertions(+), 427 deletions(-) create mode 100755 notwa-util/cosmo-kuroko9 create mode 100755 notwa-util/cosmo-mini9 create mode 100755 notwa-util/cosmo-muon9 create mode 100755 notwa-util/cosmo-yices9 create mode 100755 notwa-util/cosmopolitan-bootstrap9 create mode 100755 notwa-util/cosmopolitan-install9 create mode 100755 notwa-util/cosmopolitan9 diff --git a/notwa-util/cosmo-kuroko9 b/notwa-util/cosmo-kuroko9 new file mode 100755 index 0000000..eca21ed --- /dev/null +++ b/notwa-util/cosmo-kuroko9 @@ -0,0 +1,117 @@ +#!/usr/bin/false +if [ ! -e /cosmo-kuroko.done ]; then +: \ + && cd /root \ + && acquire from=github repo=kuroko-lang/kuroko dest=/root/kuroko env=KUROKO \ + && cd /root/kuroko \ + && cp -r . ../kuroko.orig \ + && shed src/os.c \ +'s@.*char \*\* environ.*@#ifndef COSMOPOLITAN_LIBC_RUNTIME_RUNTIME_H_\n&\n#endif@' \ +\ + && shed src/vm.c \ +'/static.*cache/c\\static KrkClassCacheEntry * cache = 0;' \ +$'/define CACHE_SIZE/,/nextCount/{N;w /temp\nd}' \ +$'/void krk_initVM/{r /temp\nN}' \ +$'/Reset current thread/i\\\tcache = calloc(CACHE_SIZE, sizeof(KrkClassCacheEntry));' \ +$'/krk_freeMemoryDebugger();/a\\\tcache = (free(cache), NULL);' \ +\ + && shed src/threads.c '/define gettid/d' \ + && shed src/vm.c '/"initial-exec"/d' \ +\ + && shed src/vm.c \ +$'/Ensure we don\'t have a macro/i\\ +\\#ifdef KRK_DISABLE_DYNAMIC\\ +KrkValue krk_module_onload_math(void);\\ +KrkValue krk_module_onload_random(void);\\ +KrkValue krk_module_onload_socket(void);\\ +KrkValue krk_module_onload_timeit(void);\\ +KrkValue krk_module_onload_wcwidth(void);\\ +\\#endif\\ +\\ +\\#define BUILTIN_MODULE(name, init) { \\\\\\ +\tKrkInstance * module = (KrkInstance*)AS_OBJECT(init()); \\\\\\ +\tkrk_attachNamedObject(&vm.modules, name, (KrkObj*)module); \\\\\\ +\tkrk_attachNamedObject(&module->fields, "__name__", (KrkObj*)S(name)); \\\\\\ +\tkrk_attachNamedValue(&module->fields, "__file__", NONE_VAL()); \\\\\\ +}\\ +' \ +$'/krk_module_init_dis/a\\ +\\#endif\\ +\\#ifdef KRK_DISABLE_DYNAMIC\\ +\t\tBUILTIN_MODULE("math", krk_module_onload_math)\\ +\t\tBUILTIN_MODULE("random", krk_module_onload_random)\\ +\t\tBUILTIN_MODULE("socket", krk_module_onload_socket)\\ +\t\tBUILTIN_MODULE("timeit", krk_module_onload_timeit)\\ +\t\tBUILTIN_MODULE("wcwidth", krk_module_onload_wcwidth)\\ +' \ +\ + && shed src/modules/module_socket.c \ +'/netdb\.h/a\#include ' \ +$'/switch (afval)/{i\\ +\tif (afval == AF_INET) return "AF_INET";\\ +\tif (afval == AF_INET6) return "AF_INET6";\\ +\tif (afval == AF_UNIX) return "AF_UNIX";\\ +\tsnprintf(tmp,30,"%d",afval);\\ +\treturn tmp; +} +/switch (afval)/,/}/d' \ +\ + && shed src/kuroko.c \ +$'/strlen(buf)-1/{ +s/if .*/if (buf[buflen-1] == \'\\\\n\') {/ +i\\ +\t\t\t\tsize_t buflen = strlen(buf); +a\\ +\t\t\t\t\t\\if (buflen >= 2 && buf[buflen-2] == \'\\\\r\') buf[buflen-2] = \'\\\\n\', buf[buflen-1] = \'\\0\';\\ +\t\t\t\t} else { +}' \ +\ + && shed Makefile \ +$'/ifdef KRK_DISABLE_THREADS/i\\ +ifdef KRK_DISABLE_DYNAMIC\\ + BIN_OBJS += src/modules/module_math.o src/modules/module_random.o src/modules/module_socket.o src/modules/module_timeit.o src/modules/module_wcwidth.o\\ + CFLAGS += -DKRK_DISABLE_DYNAMIC -DSTATIC_ONLY\\ +endif\\ +' \ +$'/CFLAGS += -DKRK_DISABLE_THREADS/a\\ +else\\ + CFLAGS += -DKRK_MEDIOCRE_TLS\\ +' \ +'/shell tools\/can-floor-without-libm\.sh/,/endif/d' \ +\ + && cd /root \ + && { diff -NrU3 kuroko.orig/ kuroko/ > kuroko.patch; [ $? -le 1 ]; } \ + || exit $? +# diff exit status is normally 0 or 1, anything greater is an error. + +# this isn't included in the patch because it's super specific to cosmopolitan. \ +: \ + && cd /root/kuroko \ + && shed src/kuroko.c 's/int main/dontinline int _main/' \ + && printf %s >>src/kuroko.c $' +STATIC_YOINK("__die"); +void ShowCrashReports(void); +int LoadZipArgs(int *, char ***); +int main(int argc, char * argv[]) { +\tShowCrashReports(); +\tLoadZipArgs(&argc, &argv); +\treturn _main(argc, argv); +} +' \ + || exit $? + +: \ + && cd /root/kuroko \ + && CC=cosmocc CFLAGS="-Os -g" AR=ar.com ARFLAGS=rcsD \ + make.com kuroko modules/codecs/sbencs.krk modules/codecs/dbdata.krk \ + -j2 KRK_DISABLE_RLINE=1 KRK_DISABLE_DYNAMIC=1 \ + && cp kuroko kuroko.com.dbg \ + && objcopy -S -O binary kuroko.com.dbg kuroko.com \ +\ + && rm test/day23.krk \ + && rm test/testAnnotations.krk \ + && rm test/testSubclassPropertySuperCall.krk \ + && make.com test \ + && touch /cosmo-kuroko.done \ + || exit $? +fi diff --git a/notwa-util/cosmo-mini9 b/notwa-util/cosmo-mini9 new file mode 100755 index 0000000..7f2c947 --- /dev/null +++ b/notwa-util/cosmo-mini9 @@ -0,0 +1,50 @@ +#!/usr/bin/false +if [ ! -e /cosmo-mini.done ]; then +: \ + && export CC=cosmocc CFLAGS="-fdiagnostics-color=always -Os -g -Wall -Wextra -Wwrite-strings -Wno-unused" \ + && acquire from=github repo=skeeto/endlessh dest=/root/endlessh env=ENDLESSH \ + && acquire from=github repo=leahneukirchen/lr dest=/root/lr env=LR \ + && acquire from=github repo=leahneukirchen/xe dest=/root/xe env=XE \ + && acquire from=github repo=cksystemsteaching/selfie dest=/root/selfie env=SELFIE \ + && acquire from=github repo=atomicobject/heatshrink dest=/root/heatshrink env=HEATSHRINK \ +\ + && cd /root/endlessh \ + && shed endlessh.c \ +'s/\bINET6_ADDRSTRLEN\b/65/g' \ +'/\bswitch (errno) {/,/default:/s/\bcase \([A-Z]\+\):/} else if (errno == \1) {/g' \ +'/\bswitch (errno) {/,/default:/s/default\:/} else {/' \ +'s/\bswitch (errno) {/if (0) {/' \ +'/ENDLESSH_VERSION/i\static const struct in6_addr in6addr_any = {0};' \ +'s/int fd = accept(server, 0, 0);/struct sockaddr_in dummy1; unsigned int dummy2 = sizeof(dummy1); int fd = accept(server, (struct sockaddr *)\&dummy1, \&dummy2);/' \ + && ofc endlessh.c \ +\ + && cd /root/lr \ + && patch -p1 -i /vagrant/cosmo-mini/lr.patch \ + && shed lr.c \ +'/_GNU_SOURCE/a\\#include "libc/dce.h"' \ +'s/\bnlink_t\b/uint32_t/g' \ +'s/\bdefined(__/&sometimes_/g' \ +'s/\b__linux__\b/__sometimes_linux__/g' \ +'/#warning fstype/d' \ + && ofc lr.c \ +\ + && cd /root/xe \ + && ofc xe.c \ +\ + && cd /root/selfie \ + && shed selfie.c '/\bPAGESIZE\b/i\\#undef PAGESIZE' \ + && ofc selfie.c \ +\ + && cd /root/heatshrink \ + && shed heatshrink.c '/encoder\.h/a\\#include "heatshrink_encoder.c"' \ + && shed heatshrink.c '/decoder\.h/a\\#include "heatshrink_decoder.c"' \ + && shed heatshrink_encoder.c 's/\b\(output_info\|st_yield_literal\)\b/&_e/g' \ + && shed heatshrink_decoder.c 's/\b\(output_info\|st_yield_literal\)\b/&_d/g' \ + && CFLAGS="$CFLAGS -Wno-implicit-fallthrough" ofc heatshrink.c \ +\ + && cd /root \ + && mkdir -p /opt/mini \ + && install -p -m 0755 -t /opt/mini/ */*.com.dbg */*.com \ + && touch /cosmo-mini.done \ + || exit $? +fi diff --git a/notwa-util/cosmo-muon9 b/notwa-util/cosmo-muon9 new file mode 100755 index 0000000..31bb480 --- /dev/null +++ b/notwa-util/cosmo-muon9 @@ -0,0 +1,27 @@ +#!/usr/bin/false +if [ ! -e /cosmo-muon.done ]; then +: \ + && export CC=cosmocc CFLAGS="-Os -g -fdiagnostics-color=always" \ + && acquire from=sourcehut repo=lattis/muon dest=/root/muon env=MUON \ +\ + && cd /root/muon \ + && ./bootstrap.sh build \ +\ + && shed src/platform/posix/rpath_fixer.c \ +'/\bcase ELFCLASS32:/,/\bbreak;/d' \ +'s@.*Elf32.*@/* & */@' \ + && 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 \ + && touch /cosmo-muon.done \ + || exit $? +fi diff --git a/notwa-util/cosmo-yices9 b/notwa-util/cosmo-yices9 new file mode 100755 index 0000000..63ebf1b --- /dev/null +++ b/notwa-util/cosmo-yices9 @@ -0,0 +1,64 @@ +#!/usr/bin/false +if [ ! -e /cosmo-yices.done ]; then +: \ + && acquire from=github repo=SRI-CSL/yices2 dest=/root/yices env=YICES \ +\ + && remote_fn="gmp-$GMP_VERSION.tar.xz" \ + && export local_fn="$remote_fn" \ + && export remote_url="https://gmplib.org/download/gmp/$remote_fn" \ + && export dest=/root/gmp \ + && export sha256="$GMP_SHA256" \ + && acquire \ +\ + && acquire from=github repo=arminbiere/kissat dest=/root/kissat env=KISSAT \ +\ + && cd /root/kissat \ + && shed src/application.c '/#include /i\\#include ' \ + && shed configure '/passtocompiler -fpic/i\\CFLAGS=" -O2 -g -Wall"' \ + && CC=cosmocc ./configure \ + && 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 \ +\ + && cd /root/gmp \ + && rm -r printf \ + && shed configure 's_ printf/Makefile _ _g' '/printf\/Makefile/d' \ + && shed Makefile.in 's_ printf _ _g' 's/$(PRINTF_OBJECTS) //g' \ + && CC=cosmocc CFLAGS="-O2 -g" \ + ac_cv_build='core2-pc-linux-gnu' \ + ac_cv_host='core2-pc-linux-gnu' \ + gmp_cv_c_double_format='IEEE little endian' \ + quickconf --disable-shared \ + && make -j2 \ + && make install \ +\ + && cd /root/yices \ + && 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 /i\\#include ' \ + && shed src/Makefile 's/ $(static_libyices_dynamic)//g' \ + && shed src/Makefile '/^\t$(STRIP)/d' \ + && shed src/Makefile '/\*\.dll/d' \ + && autoconf \ + && CC=cosmocc \ + CFLAGS="-O2 -g" \ + CPPFLAGS="-I/usr/local/include -DHAVE_KISSAT" \ + LDFLAGS="-L/usr/local/lib" \ + LIBS="-lkissat" \ + quickconf --prefix= \ + && make -j2 static-dist \ + && 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 /root/kissat/build \ + && mv "kissat" "kissat.com.dbg" \ + && objcopy -S -O binary "kissat.com.dbg" "kissat.com" \ +\ + && touch /cosmo-yices.done \ + || exit $? +fi diff --git a/notwa-util/cosmopolitan-bootstrap9 b/notwa-util/cosmopolitan-bootstrap9 new file mode 100755 index 0000000..ec7aa77 --- /dev/null +++ b/notwa-util/cosmopolitan-bootstrap9 @@ -0,0 +1,57 @@ +#!/usr/bin/false +if [ ! -e /cosmopolitan-bootstrap.done ]; then +: \ + && cd /root \ + && acquire from=github repo=jart/cosmopolitan dest=/root/cosmopolitan env=COSMO \ + && cd /root/cosmopolitan \ + && export V=0 COLUMNS=80 TMPDIR=/tmp \ + && shed build/config.mk 's/-march=native/-march=haswell -mno-pclmul -mtune=generic/' \ + && sed -i 's/skip=" 76" count=" 128"/skip=76 count=128 /' build/bootstrap/*.com \ + && install -m0755 build/bootstrap/ape.elf /usr/bin/ape \ + && shed Makefile \ +'/\bNET_HTTP\b/i\\tTHIRD_PARTY_LINENOISE\t\t\\' \ +'/\bNET_HTTP\b/i\\tTOOL_ARGS\t\t\\' \ + && shed libc/elf/elf.h '/"libc\/elf\/struct\/ehdr.h"/i\\#include "libc/elf/struct/dyn.h"' \ + && shed third_party/awk/main.c '/pledge.*{/,/}/d' \ + && shed libc/calls/unveil.c \ +'/^ if (landlock_abi_version == -1) {/i\ + landlock_abi_version = landlock_create_ruleset(0, 0, LANDLOCK_CREATE_RULESET_VERSION);' \ + && sed -i '/#\t/d' third_party/third_party.mk \ + && { [ "$COSMO_FLAVOR" != def ] && mode="$COSMO_FLAVOR" || mode= ;} \ + && printf '%s="%s"\n' >env \ + commit "$COSMO_COMMIT" \ + flavor "$COSMO_FLAVOR" \ + mode "$mode" \ + && printf '%s\n' >makeit '#!/usr/bin/env sh' \ + "build/bootstrap/make.com -j2 MODE='$mode'"' "$@"' \ + && printf '%s\n' >expand '#!/usr/bin/env sh' \ + "o='o/$mode' once=false" \ + 'for f; do g="${f#?//}"; case "$f" in' \ + '(a//*) f="$o/ape/$g";;' \ + '(b//*) f="$o/tool/build/$g";;' \ + '(e//*) f="$o/examples/$g";;' \ + '(o//*) f="$o/$g";;' \ + '(t//*) f="$o/third_party/$g";;' \ + '(T//*) f="third_party/$g";;' \ + 'esac; $once && set -- "$@" "$f" || set -- "$f"; once=true; done' \ + '"$@"' \ + && chmod +x makeit expand \ + && ./expand ./makeit \ + a//ape-copy-self.o a//ape-no-modify-self.o a//ape.elf \ + a//ape.lds a//ape.macho a//ape.o \ + a//public/ape.lds o//cosmopolitan.a o//libc/crt/crt.o \ + o/cosmopolitan.h \ + && rebuild() { ./expand ./makeit "$@" && ./expand cp -int build/bootstrap "$@" ;} \ + && rebuild \ + t//make/make.com b//ar.com b//cocmd.com \ + b//compile.com b//cp.com b//echo.com \ + b//fixupobj.com b//gzip.com b//mkdeps.com \ + b//mkdir.com b//package.com b//pwd.com \ + b//rm.com b//touch.com b//unbundle.com \ + b//zipobj.com \ + && ./expand install -m0755 a//ape.elf /usr/bin/ape \ + && ./expand ./makeit \ + t//unzip/unzip.com t//zip/zip.com \ + && touch /cosmopolitan-bootstrap.done \ + || exit $? +fi diff --git a/notwa-util/cosmopolitan-install9 b/notwa-util/cosmopolitan-install9 new file mode 100755 index 0000000..aca7c9d --- /dev/null +++ b/notwa-util/cosmopolitan-install9 @@ -0,0 +1,55 @@ +#!/usr/bin/false +if [ ! -e /cosmopolitan-install.done ]; then +#&& find o -name '*.com' ! -type d -exec printf 'cp -int /tmp/bin %s\n' {} + | sort && exit 1 \ +: \ + && cd /root/cosmopolitan \ + && . ./env \ +\ + && find o '(' -name '*.com' -o -name '*.com.dbg' ')' \ + '!' -name '*_test.*' '!' -name 'test_*' -exec \ + install -m0755 -t /usr/local/bin {} \ + + \ + && find o -type f '(' -name '*.com.dbg' -o -name '*_test.*' -o -name 'test_*' ')' -delete \ +\ + && { [ ! -d dist ] || rm -r dist ;} \ + && mkdir -p "dist/$flavor/public" \ + && ./expand cp -int "dist/$flavor" \ + a//ape-copy-self.o a//ape-no-modify-self.o a//ape.elf \ + a//ape.lds a//ape.macho a//ape.o \ + o//cosmopolitan.a o//libc/crt/crt.o o/cosmopolitan.h \ + && cp -int "dist/$flavor/public" "o/$mode/ape/public/ape.lds" \ +\ + && install -m0755 "dist/$flavor/ape.elf" /usr/bin/ape \ + && find libc -name '*.h' >headers.txt \ + && ./expand tar zcf dist/headers.tar.gz -T headers.txt \ + ape/config.h libc/integral T//gdtoa/gdtoa.h \ + T//getopt/getopt.h T//linenoise/linenoise.h T//musl/crypt.h \ + T//musl/fnmatch.h T//musl/lockf.h T//musl/passwd.h \ + T//musl/rand48.h T//musl/tempnam.h T//regex/regex.h \ + T//zlib/zconf.h T//zlib/zlib.h \ + && { ! [ -d "$COSMO" ] || rm -r "$COSMO" ;} \ + && mkdir -p "$COSMO" /tmp/bin \ + && find o -name '*.sym' -delete \ + && find o -name 'aarch64-linux-musl*' -exec rm -r '{}' + \ + && dedupe o/third_party/gcc "$COSMO/gcc/" \ + bin/x86_64-linux-musl-gcc \ + bin/x86_64-linux-musl-g++ \ + bin/x86_64-linux-musl-ld.bfd \ + && dedupe dist "$COSMO/dist/" "$flavor/cosmopolitan.h" \ + && ./expand cp -int /tmp/bin \ + t//make/make.com t//unzip/unzip.com t//zip/zip.com \ + b//ar.com b//cocmd.com b//compile.com \ + b//cp.com b//echo.com b//fixupobj.com \ + b//gzip.com b//mkdeps.com b//mkdir.com \ + b//package.com b//pwd.com b//rm.com \ + b//rollup.com b//symtab.com b//touch.com \ + b//unbundle.com b//zipobj.com \ + && dedupe /tmp/bin "$COSMO/bin/" \ + && cp "dist/$flavor/ape.elf" "$COSMO/bin/ape" \ + && cp /root/cosmopolitan/env "$COSMO/env" \ +\ + && rm -r /root/cosmopolitan/dist \ + && tar zxf "$COSMO/dist/headers.tar.gz" -C "$COSMO" \ + && touch /cosmopolitan-install.done \ + || exit $? +fi diff --git a/notwa-util/cosmopolitan9 b/notwa-util/cosmopolitan9 new file mode 100755 index 0000000..429b553 --- /dev/null +++ b/notwa-util/cosmopolitan9 @@ -0,0 +1,32 @@ +#!/usr/bin/false +if [ ! -e /cosmopolitan.done ]; then +: \ + && cd /root/cosmopolitan \ + && export V=0 COLUMNS=80 TMPDIR=/tmp \ + && export COSMO_FLAVOR=opt \ + && . ./env \ + && { [ "$COSMO_FLAVOR" != def ] && mode="$COSMO_FLAVOR" || mode= ;} \ + && printf '%s="%s"\n' >env \ + commit "$commit" \ + flavor "$COSMO_FLAVOR" \ + mode "$mode" \ + COSMO "/opt/cosmo" \ + COSMO_DIST "/opt/cosmo/dist/$COSMO_FLAVOR" \ +\ + && shed expand "s_o='o/[^']*'_o='o/$mode' _g" \ +\ + && . ./env \ + && { ./makeit MODE="$mode" depend || find o -name '*.o' -delete ;} \ + && ./makeit MODE="$mode" "o/$mode/third_party/make/make.com" \ + && cp -int build/bootstrap "o/$mode/third_party/make/make.com" \ +\ + && skip() { mkdir -p "${1%/*}" && touch -d @2222222222 "$1" ;} \ + && skip "o/$mode/test/libc/calls/getgroups_test.com.runs" \ + && `#skip "o/$mode/test/libc/calls/getpriority_test.com.runs"` \ + && `#skip "o/$mode/test/libc/stdio/tmpfile_test.com.runs"` \ + && skip "o/$mode/third_party/python/Lib/test/test_ioctl.py.runs" `# SIGSEGV` \ + && skip "o/$mode/third_party/python/Lib/test/test_tarfile.py.runs" \ + && ./makeit MODE="$mode" all \ + && touch /cosmopolitan.done \ + || exit $? +fi diff --git a/notwa-util/do_everything b/notwa-util/do_everything index 41b9bb0..f99aaf9 100755 --- a/notwa-util/do_everything +++ b/notwa-util/do_everything @@ -52,438 +52,18 @@ if [ ! -e /notwa-util.done ]; then || exit $? fi -# NOTE: it's not necessary to build busybox anymore, but oh well. -if [ ! -e /busybox.done ]; then -: \ - && cd /root \ - && remote_fn="busybox-$BUSYBOX_VERSION.tar.bz2" \ - && export local_fn="$remote_fn" \ - && export remote_url="http://busybox.net/downloads/$remote_fn" \ - && export dest=/root/busybox \ - && export sha256="$BUSYBOX_SHA256" \ - && acquire \ - && { : \ - && cd /root/busybox \ - && install -p /vagrant/notwa-util/busybox.config .config \ - && make -j2 \ - && du -h busybox \ - ;} \ - && touch /busybox.done \ - || exit $? -fi - -unset local_fn remote_url dest sha256 - -if [ ! -e /cosmopolitan-bootstrap.done ]; then -: \ - && cd /root \ - && acquire from=github repo=jart/cosmopolitan dest=/root/cosmopolitan env=COSMO \ - && cd /root/cosmopolitan \ - && export V=0 COLUMNS=80 TMPDIR=/tmp \ - && shed build/config.mk 's/-march=native/-march=haswell -mno-pclmul -mtune=generic/' \ - && sed -i 's/skip=" 76" count=" 128"/skip=76 count=128 /' build/bootstrap/*.com \ - && install -m0755 build/bootstrap/ape.elf /usr/bin/ape \ - && shed Makefile \ -'/\bNET_HTTP\b/i\\tTHIRD_PARTY_LINENOISE\t\t\\' \ -'/\bNET_HTTP\b/i\\tTOOL_ARGS\t\t\\' \ - && shed libc/elf/elf.h '/"libc\/elf\/struct\/ehdr.h"/i\\#include "libc/elf/struct/dyn.h"' \ - && shed third_party/awk/main.c '/pledge.*{/,/}/d' \ - && shed libc/calls/unveil.c \ -'/^ if (landlock_abi_version == -1) {/i\ - landlock_abi_version = landlock_create_ruleset(0, 0, LANDLOCK_CREATE_RULESET_VERSION);' \ - && sed -i '/#\t/d' third_party/third_party.mk \ - && { [ "$COSMO_FLAVOR" != def ] && mode="$COSMO_FLAVOR" || mode= ;} \ - && printf '%s="%s"\n' >env \ - commit "$COSMO_COMMIT" \ - flavor "$COSMO_FLAVOR" \ - mode "$mode" \ - && printf '%s\n' >makeit '#!/usr/bin/env sh' \ - "build/bootstrap/make.com -j2 MODE='$mode'"' "$@"' \ - && printf '%s\n' >expand '#!/usr/bin/env sh' \ - "o='o/$mode' once=false" \ - 'for f; do g="${f#?//}"; case "$f" in' \ - '(a//*) f="$o/ape/$g";;' \ - '(b//*) f="$o/tool/build/$g";;' \ - '(e//*) f="$o/examples/$g";;' \ - '(o//*) f="$o/$g";;' \ - '(t//*) f="$o/third_party/$g";;' \ - '(T//*) f="third_party/$g";;' \ - 'esac; $once && set -- "$@" "$f" || set -- "$f"; once=true; done' \ - '"$@"' \ - && chmod +x makeit expand \ - && ./expand ./makeit \ - a//ape-copy-self.o a//ape-no-modify-self.o a//ape.elf \ - a//ape.lds a//ape.macho a//ape.o \ - a//public/ape.lds o//cosmopolitan.a o//libc/crt/crt.o \ - o/cosmopolitan.h \ - && rebuild() { ./expand ./makeit "$@" && ./expand cp -int build/bootstrap "$@" ;} \ - && rebuild \ - t//make/make.com b//ar.com b//cocmd.com \ - b//compile.com b//cp.com b//echo.com \ - b//fixupobj.com b//gzip.com b//mkdeps.com \ - b//mkdir.com b//package.com b//pwd.com \ - b//rm.com b//touch.com b//unbundle.com \ - b//zipobj.com \ - && ./expand install -m0755 a//ape.elf /usr/bin/ape \ - && ./expand ./makeit \ - t//unzip/unzip.com t//zip/zip.com \ - && touch /cosmopolitan-bootstrap.done \ - || exit $? -fi - -if [ ! -e /cosmopolitan.done ]; then -: \ - && cd /root/cosmopolitan \ - && export V=0 COLUMNS=80 TMPDIR=/tmp \ - && export COSMO_FLAVOR=opt \ - && . ./env \ - && { [ "$COSMO_FLAVOR" != def ] && mode="$COSMO_FLAVOR" || mode= ;} \ - && printf '%s="%s"\n' >env \ - commit "$commit" \ - flavor "$COSMO_FLAVOR" \ - mode "$mode" \ - COSMO "/opt/cosmo" \ - COSMO_DIST "/opt/cosmo/dist/$COSMO_FLAVOR" \ -\ - && shed expand "s_o='o/[^']*'_o='o/$mode' _g" \ -\ - && . ./env \ - && { ./makeit MODE="$mode" depend || find o -name '*.o' -delete ;} \ - && ./makeit MODE="$mode" "o/$mode/third_party/make/make.com" \ - && cp -int build/bootstrap "o/$mode/third_party/make/make.com" \ -\ - && skip() { mkdir -p "${1%/*}" && touch -d @2222222222 "$1" ;} \ - && skip "o/$mode/test/libc/calls/getgroups_test.com.runs" \ - && `#skip "o/$mode/test/libc/calls/getpriority_test.com.runs"` \ - && `#skip "o/$mode/test/libc/stdio/tmpfile_test.com.runs"` \ - && skip "o/$mode/third_party/python/Lib/test/test_ioctl.py.runs" `# SIGSEGV` \ - && skip "o/$mode/third_party/python/Lib/test/test_tarfile.py.runs" \ - && ./makeit MODE="$mode" all \ - && touch /cosmopolitan.done \ - || exit $? -fi - +. /vagrant/notwa-util/cosmopolitan-bootstrap9 || exit $? +. /vagrant/notwa-util/cosmopolitan9 || exit $? cd /root/cosmopolitan && . ./env || exit $? export COSMO COSMO_DIST - -if [ ! -e /cosmopolitan-install.done ]; then -#&& find o -name '*.com' ! -type d -exec printf 'cp -int /tmp/bin %s\n' {} + | sort && exit 1 \ -: \ - && cd /root/cosmopolitan \ - && . ./env \ -\ - && find o '(' -name '*.com' -o -name '*.com.dbg' ')' \ - '!' -name '*_test.*' '!' -name 'test_*' -exec \ - install -m0755 -t /usr/local/bin {} \ - + \ - && find o -type f '(' -name '*.com.dbg' -o -name '*_test.*' -o -name 'test_*' ')' -delete \ -\ - && { [ ! -d dist ] || rm -r dist ;} \ - && mkdir -p "dist/$flavor/public" \ - && ./expand cp -int "dist/$flavor" \ - a//ape-copy-self.o a//ape-no-modify-self.o a//ape.elf \ - a//ape.lds a//ape.macho a//ape.o \ - o//cosmopolitan.a o//libc/crt/crt.o o/cosmopolitan.h \ - && cp -int "dist/$flavor/public" "o/$mode/ape/public/ape.lds" \ -\ - && install -m0755 "dist/$flavor/ape.elf" /usr/bin/ape \ - && find libc -name '*.h' >headers.txt \ - && ./expand tar zcf dist/headers.tar.gz -T headers.txt \ - ape/config.h libc/integral T//gdtoa/gdtoa.h \ - T//getopt/getopt.h T//linenoise/linenoise.h T//musl/crypt.h \ - T//musl/fnmatch.h T//musl/lockf.h T//musl/passwd.h \ - T//musl/rand48.h T//musl/tempnam.h T//regex/regex.h \ - T//zlib/zconf.h T//zlib/zlib.h \ - && { ! [ -d "$COSMO" ] || rm -r "$COSMO" ;} \ - && mkdir -p "$COSMO" /tmp/bin \ - && find o -name '*.sym' -delete \ - && find o -name 'aarch64-linux-musl*' -exec rm -r '{}' + \ - && dedupe o/third_party/gcc "$COSMO/gcc/" \ - bin/x86_64-linux-musl-gcc \ - bin/x86_64-linux-musl-g++ \ - bin/x86_64-linux-musl-ld.bfd \ - && dedupe dist "$COSMO/dist/" "$flavor/cosmopolitan.h" \ - && ./expand cp -int /tmp/bin \ - t//make/make.com t//unzip/unzip.com t//zip/zip.com \ - b//ar.com b//cocmd.com b//compile.com \ - b//cp.com b//echo.com b//fixupobj.com \ - b//gzip.com b//mkdeps.com b//mkdir.com \ - b//package.com b//pwd.com b//rm.com \ - b//rollup.com b//symtab.com b//touch.com \ - b//unbundle.com b//zipobj.com \ - && dedupe /tmp/bin "$COSMO/bin/" \ - && cp "dist/$flavor/ape.elf" "$COSMO/bin/ape" \ - && cp /root/cosmopolitan/env "$COSMO/env" \ -\ - && rm -r /root/cosmopolitan/dist \ - && tar zxf "$COSMO/dist/headers.tar.gz" -C "$COSMO" \ - && touch /cosmopolitan-install.done \ - || exit $? -fi - +. /vagrant/notwa-util/cosmopolitan-install9 || exit $? cd /root && export PATH="$COSMO/bin:$COSMO/gcc/bin:$PATH" || exit $? unset V COLUMNS TMPDIR - -if [ ! -e /cosmo-kuroko.done ]; then -: \ - && cd /root \ - && acquire from=github repo=kuroko-lang/kuroko dest=/root/kuroko env=KUROKO \ - && cd /root/kuroko \ - && cp -r . ../kuroko.orig \ - && shed src/os.c \ -'s@.*char \*\* environ.*@#ifndef COSMOPOLITAN_LIBC_RUNTIME_RUNTIME_H_\n&\n#endif@' \ -\ - && shed src/vm.c \ -'/static.*cache/c\\static KrkClassCacheEntry * cache = 0;' \ -$'/define CACHE_SIZE/,/nextCount/{N;w /temp\nd}' \ -$'/void krk_initVM/{r /temp\nN}' \ -$'/Reset current thread/i\\\tcache = calloc(CACHE_SIZE, sizeof(KrkClassCacheEntry));' \ -$'/krk_freeMemoryDebugger();/a\\\tcache = (free(cache), NULL);' \ -\ - && shed src/threads.c '/define gettid/d' \ - && shed src/vm.c '/"initial-exec"/d' \ -\ - && shed src/vm.c \ -$'/Ensure we don\'t have a macro/i\\ -\\#ifdef KRK_DISABLE_DYNAMIC\\ -KrkValue krk_module_onload_math(void);\\ -KrkValue krk_module_onload_random(void);\\ -KrkValue krk_module_onload_socket(void);\\ -KrkValue krk_module_onload_timeit(void);\\ -KrkValue krk_module_onload_wcwidth(void);\\ -\\#endif\\ -\\ -\\#define BUILTIN_MODULE(name, init) { \\\\\\ -\tKrkInstance * module = (KrkInstance*)AS_OBJECT(init()); \\\\\\ -\tkrk_attachNamedObject(&vm.modules, name, (KrkObj*)module); \\\\\\ -\tkrk_attachNamedObject(&module->fields, "__name__", (KrkObj*)S(name)); \\\\\\ -\tkrk_attachNamedValue(&module->fields, "__file__", NONE_VAL()); \\\\\\ -}\\ -' \ -$'/krk_module_init_dis/a\\ -\\#endif\\ -\\#ifdef KRK_DISABLE_DYNAMIC\\ -\t\tBUILTIN_MODULE("math", krk_module_onload_math)\\ -\t\tBUILTIN_MODULE("random", krk_module_onload_random)\\ -\t\tBUILTIN_MODULE("socket", krk_module_onload_socket)\\ -\t\tBUILTIN_MODULE("timeit", krk_module_onload_timeit)\\ -\t\tBUILTIN_MODULE("wcwidth", krk_module_onload_wcwidth)\\ -' \ -\ - && shed src/modules/module_socket.c \ -'/netdb\.h/a\#include ' \ -$'/switch (afval)/{i\\ -\tif (afval == AF_INET) return "AF_INET";\\ -\tif (afval == AF_INET6) return "AF_INET6";\\ -\tif (afval == AF_UNIX) return "AF_UNIX";\\ -\tsnprintf(tmp,30,"%d",afval);\\ -\treturn tmp; -} -/switch (afval)/,/}/d' \ -\ - && shed src/kuroko.c \ -$'/strlen(buf)-1/{ -s/if .*/if (buf[buflen-1] == \'\\\\n\') {/ -i\\ -\t\t\t\tsize_t buflen = strlen(buf); -a\\ -\t\t\t\t\t\\if (buflen >= 2 && buf[buflen-2] == \'\\\\r\') buf[buflen-2] = \'\\\\n\', buf[buflen-1] = \'\\0\';\\ -\t\t\t\t} else { -}' \ -\ - && shed Makefile \ -$'/ifdef KRK_DISABLE_THREADS/i\\ -ifdef KRK_DISABLE_DYNAMIC\\ - BIN_OBJS += src/modules/module_math.o src/modules/module_random.o src/modules/module_socket.o src/modules/module_timeit.o src/modules/module_wcwidth.o\\ - CFLAGS += -DKRK_DISABLE_DYNAMIC -DSTATIC_ONLY\\ -endif\\ -' \ -$'/CFLAGS += -DKRK_DISABLE_THREADS/a\\ -else\\ - CFLAGS += -DKRK_MEDIOCRE_TLS\\ -' \ -'/shell tools\/can-floor-without-libm\.sh/,/endif/d' \ -\ - && cd /root \ - && { diff -NrU3 kuroko.orig/ kuroko/ > kuroko.patch; [ $? -le 1 ]; } \ - || exit $? -# diff exit status is normally 0 or 1, anything greater is an error. - -# this isn't included in the patch because it's super specific to cosmopolitan. \ -: \ - && cd /root/kuroko \ - && shed src/kuroko.c 's/int main/dontinline int _main/' \ - && printf %s >>src/kuroko.c $' -STATIC_YOINK("__die"); -void ShowCrashReports(void); -int LoadZipArgs(int *, char ***); -int main(int argc, char * argv[]) { -\tShowCrashReports(); -\tLoadZipArgs(&argc, &argv); -\treturn _main(argc, argv); -} -' \ - || exit $? - -: \ - && cd /root/kuroko \ - && CC=cosmocc CFLAGS="-Os -g" AR=ar.com ARFLAGS=rcsD \ - make.com kuroko modules/codecs/sbencs.krk modules/codecs/dbdata.krk \ - -j2 KRK_DISABLE_RLINE=1 KRK_DISABLE_DYNAMIC=1 \ - && cp kuroko kuroko.com.dbg \ - && objcopy -S -O binary kuroko.com.dbg kuroko.com \ -\ - && rm test/day23.krk \ - && rm test/testAnnotations.krk \ - && rm test/testSubclassPropertySuperCall.krk \ - && make.com test \ - && touch /cosmo-kuroko.done \ - || exit $? -fi - -if [ ! -e /cosmo-mini.done ]; then -: \ - && export CC=cosmocc CFLAGS="-fdiagnostics-color=always -Os -g -Wall -Wextra -Wwrite-strings -Wno-unused" \ - && acquire from=github repo=skeeto/endlessh dest=/root/endlessh env=ENDLESSH \ - && acquire from=github repo=leahneukirchen/lr dest=/root/lr env=LR \ - && acquire from=github repo=leahneukirchen/xe dest=/root/xe env=XE \ - && acquire from=github repo=cksystemsteaching/selfie dest=/root/selfie env=SELFIE \ - && acquire from=github repo=atomicobject/heatshrink dest=/root/heatshrink env=HEATSHRINK \ -\ - && cd /root/endlessh \ - && shed endlessh.c \ -'s/\bINET6_ADDRSTRLEN\b/65/g' \ -'/\bswitch (errno) {/,/default:/s/\bcase \([A-Z]\+\):/} else if (errno == \1) {/g' \ -'/\bswitch (errno) {/,/default:/s/default\:/} else {/' \ -'s/\bswitch (errno) {/if (0) {/' \ -'/ENDLESSH_VERSION/i\static const struct in6_addr in6addr_any = {0};' \ -'s/int fd = accept(server, 0, 0);/struct sockaddr_in dummy1; unsigned int dummy2 = sizeof(dummy1); int fd = accept(server, (struct sockaddr *)\&dummy1, \&dummy2);/' \ - && ofc endlessh.c \ -\ - && cd /root/lr \ - && patch -p1 -i /vagrant/cosmo-mini/lr.patch \ - && shed lr.c \ -'/_GNU_SOURCE/a\\#include "libc/dce.h"' \ -'s/\bnlink_t\b/uint32_t/g' \ -'s/\bdefined(__/&sometimes_/g' \ -'s/\b__linux__\b/__sometimes_linux__/g' \ -'/#warning fstype/d' \ - && ofc lr.c \ -\ - && cd /root/xe \ - && ofc xe.c \ -\ - && cd /root/selfie \ - && shed selfie.c '/\bPAGESIZE\b/i\\#undef PAGESIZE' \ - && ofc selfie.c \ -\ - && cd /root/heatshrink \ - && shed heatshrink.c '/encoder\.h/a\\#include "heatshrink_encoder.c"' \ - && shed heatshrink.c '/decoder\.h/a\\#include "heatshrink_decoder.c"' \ - && shed heatshrink_encoder.c 's/\b\(output_info\|st_yield_literal\)\b/&_e/g' \ - && shed heatshrink_decoder.c 's/\b\(output_info\|st_yield_literal\)\b/&_d/g' \ - && CFLAGS="$CFLAGS -Wno-implicit-fallthrough" ofc heatshrink.c \ -\ - && cd /root \ - && mkdir -p /opt/mini \ - && install -p -m 0755 -t /opt/mini/ */*.com.dbg */*.com \ - && touch /cosmo-mini.done \ - || exit $? -fi - -if [ ! -e /cosmo-muon.done ]; then -: \ - && export CC=cosmocc CFLAGS="-Os -g -fdiagnostics-color=always" \ - && acquire from=sourcehut repo=lattis/muon dest=/root/muon env=MUON \ -\ - && cd /root/muon \ - && ./bootstrap.sh build \ -\ - && shed src/platform/posix/rpath_fixer.c \ -'/\bcase ELFCLASS32:/,/\bbreak;/d' \ -'s@.*Elf32.*@/* & */@' \ - && 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 \ - && touch /cosmo-muon.done \ - || exit $? -fi - +. /vagrant/notwa-util/cosmo-kuroko9 || exit $? +. /vagrant/notwa-util/cosmo-mini9 || exit $? +. /vagrant/notwa-util/cosmo-muon9 || exit $? unset CC CFLAGS - -if [ ! -e /cosmo-yices.done ]; then -: \ - && acquire from=github repo=SRI-CSL/yices2 dest=/root/yices env=YICES \ -\ - && remote_fn="gmp-$GMP_VERSION.tar.xz" \ - && export local_fn="$remote_fn" \ - && export remote_url="https://gmplib.org/download/gmp/$remote_fn" \ - && export dest=/root/gmp \ - && export sha256="$GMP_SHA256" \ - && acquire \ -\ - && acquire from=github repo=arminbiere/kissat dest=/root/kissat env=KISSAT \ -\ - && cd /root/kissat \ - && shed src/application.c '/#include /i\\#include ' \ - && shed configure '/passtocompiler -fpic/i\\CFLAGS=" -O2 -g -Wall"' \ - && CC=cosmocc ./configure \ - && 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 \ -\ - && cd /root/gmp \ - && rm -r printf \ - && shed configure 's_ printf/Makefile _ _g' '/printf\/Makefile/d' \ - && shed Makefile.in 's_ printf _ _g' 's/$(PRINTF_OBJECTS) //g' \ - && CC=cosmocc CFLAGS="-O2 -g" \ - ac_cv_build='core2-pc-linux-gnu' \ - ac_cv_host='core2-pc-linux-gnu' \ - gmp_cv_c_double_format='IEEE little endian' \ - quickconf --disable-shared \ - && make -j2 \ - && make install \ -\ - && cd /root/yices \ - && 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 /i\\#include ' \ - && shed src/Makefile 's/ $(static_libyices_dynamic)//g' \ - && shed src/Makefile '/^\t$(STRIP)/d' \ - && shed src/Makefile '/\*\.dll/d' \ - && autoconf \ - && CC=cosmocc \ - CFLAGS="-O2 -g" \ - CPPFLAGS="-I/usr/local/include -DHAVE_KISSAT" \ - LDFLAGS="-L/usr/local/lib" \ - LIBS="-lkissat" \ - quickconf --prefix= \ - && make -j2 static-dist \ - && 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 /root/kissat/build \ - && mv "kissat" "kissat.com.dbg" \ - && objcopy -S -O binary "kissat.com.dbg" "kissat.com" \ -\ - && touch /cosmo-yices.done \ - || exit $? -fi - +. /vagrant/notwa-util/cosmo-yices9 || exit $? unset local_fn remote_url dest sha256 # kuroko.orig/kuroko.com # wtf?