diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..551cc7c --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,90 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://vagrantcloud.com/search. + config.vm.box = "boxomatic/alpine-3.18" + config.vm.box_version = "20230515.0.1" + # config.vm.box = "generic/alpine317" + # config.vm.box_version = "4.2.16" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # NOTE: This will enable public access to the opened port + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine and only allow access + # via 127.0.0.1 to disable public access + # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Disable the default share of the current code directory. Doing this + # provides improved isolation between the vagrant box and your host + # by making sure your Vagrantfile isn't accessable to the vagrant box. + # If you use this you may want to enable additional shared subfolders as + # shown above. + # config.vm.synced_folder ".", "/vagrant", disabled: true + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + # vb.memory = "1024" + # end + # + # View the documentation for the provider you are using for more + # information on available options. + + # config.vm.synced_folder ".", "/vagrant" + # config.vm.hostname = "stargazing" + # config.vm.network "private_network", type: "dhcp" + # config.vm.network "private_network", ip: "192.168.13.37" + + config.ssh.insert_key = false + config.ssh.username = "root" + config.ssh.password = "vagrant" + + # Enable provisioning with a shell script. Additional provisioners such as + # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the + # documentation for more information about their specific syntax and use. + config.vm.provision "shell", inline: <<-SHELL + apk update && apk upgrade + apk add autoconf gcc gperf linux-headers make musl-dev ninja patch pkgconf xz zip + sh /vagrant/notwa-util/do_everything + SHELL +end diff --git a/notwa-util/do_everything b/notwa-util/do_everything new file mode 100755 index 0000000..41b9bb0 --- /dev/null +++ b/notwa-util/do_everything @@ -0,0 +1,548 @@ +#!/usr/bin/env sh +if ! [ -d /vagrant ]; then + printf '%s\n' 'THIS FILE IS ONLY MEANT TO BE RUN BY VAGRANT.' >&2 + exit 78 # EX_CONFIG +fi + +# NOTE: Please consider this post documenting some pitfalls of set -e: +# https://gist.github.com/notwa/5b8dda28e571b27638fb33e08dc1ba21 +# set -e + +# don't leak local IPs (i'm sure it's fine though) +unset SSH_CLIENT SSH_CONNECTION + +# NOTE: this is the last version based around gcc 9.2: +# COSMO_COMMIT=682b74ed883d1d6f9aa23179af841d9971c23e4d \ +# COSMO_SHA256=71dace03135ac2b97384021a37df5871572cf34524efb5a21812e115dca15b1b \ +# versions thereafter are based around gcc 11.2 or later. + +export \ +BUSYBOX_SHA256=b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314 \ +BUSYBOX_VERSION=1.36.1 \ +COSMO_COMMIT=682b74ed883d1d6f9aa23179af841d9971c23e4d \ +COSMO_FLAVOR=fastbuild \ +COSMO_SHA256=71dace03135ac2b97384021a37df5871572cf34524efb5a21812e115dca15b1b \ +ENDLESSH_COMMIT=dfe44eb2c5b6fc3c48a39ed826fe0e4459cdf6ef \ +ENDLESSH_SHA256=c8989988af0a8c848d1a4979962f008c504a12ed6fe6a12e032c37feaa0ae5f8 \ +GMP_SHA256=fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2 \ +GMP_VERSION=6.2.1 \ +HEATSHRINK_COMMIT=7d419e1fa4830d0b919b9b6a91fe2fb786cf3280 \ +HEATSHRINK_SHA256=b18a1b7ad6f51eac7ac1a81ca072703bd21d6d8727c05cd505843643705af65d \ +KISSAT_COMMIT=315cd3227fd2321d29d10f7d8572011bf00174a5 \ +KISSAT_SHA256=031fca7efcb17c6f1921dd056052bd373de724e445fc2ed37bfdd5954148119f \ +KUROKO_COMMIT=b88267c8289c4eeea3d0219d43193a9a5fd9982b \ +KUROKO_SHA256=52e22c2e701f58cef635f0df3faaa0734ae85dd656417aaaae01226a3a7725d3 \ +LR_COMMIT=5af9b79e4ecd07a600ded1a801023536cde97f95 \ +LR_SHA256=3901287cdcf09d0d8f77f8aaa19ca24e9a873d904e201ab8e7bf102426607dcc \ +MUON_COMMIT=6cdf084804fb8262a7f29ac9e9b614472b62b8a3 \ +MUON_SHA256=60b37463fbeb757dd595f50d03116a7f9fe1e727d2852369de0052008e696e2b \ +SELFIE_COMMIT=9d5cf9caac9b00ac48b96c527ddda6c550f652fa \ +SELFIE_SHA256=5ea9e9cd7df6e6e67e3757cd8483e8e653fa4d7469275f3fdf89483c2744d4a9 \ +XE_COMMIT=8a2a4899769335bc14c62aef12cdf26f2f487f2a \ +XE_SHA256=f1ac997912c9be92a74a67a766dde74d1f9b6b20e48d7c7e71598ad4b787b37d \ +YICES_COMMIT=36cee66d04de90da35fab6131bebdc45b6d74342 \ +YICES_SHA256=f6bbfa30c38c17401fb651a06d935bec87af732ffeea3fa0db7dd22b1916e374 \ +; + +if [ ! -e /notwa-util.done ]; then +: \ + && cd /vagrant/notwa-util \ + && install -p -m 0755 -t /usr/local/bin/ acquire cosmocc dedupe ofc quickconf shed \ + && touch /notwa-util.done \ + || 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 + +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 + +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 + +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 + +unset local_fn remote_url dest sha256 + +# kuroko.orig/kuroko.com # wtf? + +# NOTE: different programs with the same names: +# NOTE: (we actually ignore the ones in the /test/ directory) +# ar.com cosmopolitan/o/opt/tool/build/ar.com +# ar.com cosmopolitan/o/opt/tool/decode/ar.com +# hello.com cosmopolitan/o/opt/examples/hello.com +# hello.com cosmopolitan/o/opt/third_party/python/hello.com +# hello.com cosmopolitan/o/opt/tool/hello/hello.com +# life.com cosmopolitan/o/opt/examples/life.com +# life.com cosmopolitan/o/opt/test/libc/mem/prog/life.com +# life.com cosmopolitan/o/opt/tool/viz/life.com +# symtab.com cosmopolitan/o/opt/examples/symtab.com +# symtab.com cosmopolitan/o/opt/tool/build/symtab.com +# zip.com cosmopolitan/o/opt/third_party/zip/zip.com +# zip.com cosmopolitan/o/opt/tool/decode/zip.com + +: \ + && cd /root \ + && . ./cosmopolitan/env \ + && export \ + && echo \ + && mkdir -p /vagrant/out/vagrant \ + && for com in \ + endlessh/endlessh.com \ + heatshrink/heatshrink.com \ + kissat/build/kissat.com \ + kuroko/kuroko.com \ + lr/lr.com \ + muon/build/muon.com \ + selfie/selfie.com \ + xe/xe.com \ + yices/dist/bin/yices-sat.com \ + yices/dist/bin/yices-smt.com \ + yices/dist/bin/yices-smt2.com \ + yices/dist/bin/yices.com \ + ;do : \ + && du -k "$com" \ + && install -p -m 0755 -t /vagrant/out/vagrant "$com" \ + ;done \ + && echo \ + && d=/vagrant/out/vagrant/examples \ + && mkdir -p "$d" \ + && find "cosmopolitan/o/$mode/examples" -type f -name '*.com' \ + -exec install -p -m 0755 -t "$d" {} + \ + && echo \ + && d=/vagrant/out/vagrant/third_party \ + && mkdir -p "$d" \ + && find "cosmopolitan/o/$mode/third_party" -type f -name '*.com' \ + -exec install -p -m 0755 -t "$d" {} + \ + && echo \ + && d=/vagrant/out/vagrant/tool \ + && mkdir -p "$d" \ + && find "cosmopolitan/o/$mode/tool" -type f -name '*.com' \ + -exec install -p -m 0755 -t "$d" {} + \ + && echo \ + && find -type f -name '*.com' | sort \ + && echo \ + && ls -1 /*.done \ + || exit $?