all: use shed utility
This commit is contained in:
parent
39dc4acfca
commit
c5d5b03b25
4 changed files with 50 additions and 46 deletions
|
@ -22,27 +22,29 @@ FROM localhost/cosmo AS builder
|
|||
COPY --from=downloader /kuroko /kuroko
|
||||
WORKDIR /kuroko
|
||||
|
||||
COPY --chmod=0755 --from=localhost/notwa-util /usr/local/bin/shed /usr/bin/
|
||||
RUN : \
|
||||
&& cp -r . ../kuroko.orig \
|
||||
\
|
||||
&& sed -i '/bind(gamma)/{N;N;d;}' src/modules/module_math.c \
|
||||
&& sed -i '/MATH_ONE(gamma)/d' src/modules/module_math.c \
|
||||
&& shed src/os.c \
|
||||
's@.*char \*\* environ.*@#ifndef COSMOPOLITAN_LIBC_RUNTIME_RUNTIME_H_\n&\n#endif@' \
|
||||
\
|
||||
&& sed -i 's@.*char \*\* environ.*@#ifndef COSMOPOLITAN_LIBC_RUNTIME_RUNTIME_H_\n&\n#endif@' src/os.c \
|
||||
&& shed src/vm.c \
|
||||
'/FUNC_SIG(list,append)/d' \
|
||||
'/void _callSetName/i\\extern FUNC_SIG(list,append);' \
|
||||
\
|
||||
&& sed -i '/FUNC_SIG(list,append)/d' src/vm.c \
|
||||
&& sed -i '/void _callSetName/i\\extern FUNC_SIG(list,append);' src/vm.c \
|
||||
&& 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);' \
|
||||
\
|
||||
&& sed -i '/static.*cache/c\\static KrkClassCacheEntry * cache = 0;' src/vm.c \
|
||||
&& sed -i $'/define CACHE_SIZE/,/nextCount/{N;w /temp\nd}' src/vm.c \
|
||||
&& sed -i $'/void krk_initVM/{r /temp\nN}' src/vm.c \
|
||||
&& sed -i $'/Reset current thread/i\\\tcache = calloc(CACHE_SIZE, sizeof(KrkClassCacheEntry));' src/vm.c \
|
||||
&& sed -i $'/krk_freeMemoryDebugger();/a\\\tcache = (free(cache), NULL);' src/vm.c \
|
||||
&& shed src/threads.c '/define gettid/d' \
|
||||
&& shed src/vm.c '/"initial-exec"/d' \
|
||||
\
|
||||
&& sed -i '/define gettid/d' src/threads.c \
|
||||
&& sed -i '/"initial-exec"/d' src/vm.c \
|
||||
\
|
||||
&& sed -i $'/Ensure we don\'t have a macro/{\ni\\\
|
||||
&& shed src/vm.c \
|
||||
$'/Ensure we don\'t have a macro/i\\\
|
||||
\#ifdef KRK_DISABLE_DYNAMIC\\\n\
|
||||
KrkValue krk_module_onload_math(void);\\\n\
|
||||
KrkValue krk_module_onload_random(void);\\\n\
|
||||
|
@ -50,18 +52,14 @@ KrkValue krk_module_onload_socket(void);\\\n\
|
|||
KrkValue krk_module_onload_timeit(void);\\\n\
|
||||
KrkValue krk_module_onload_wcwidth(void);\\\n\
|
||||
\#endif\\\n\
|
||||
\n\
|
||||
}' src/vm.c \
|
||||
&& sed -i $'/Ensure we don\'t have a macro/{\ni\\\
|
||||
\\\n\
|
||||
\#define BUILTIN_MODULE(name, init) { \\\\\\\n\
|
||||
\tKrkInstance * module = (KrkInstance*)AS_OBJECT(init()); \\\\\\\n\
|
||||
\tkrk_attachNamedObject(&vm.modules, name, (KrkObj*)module); \\\\\\\n\
|
||||
\tkrk_attachNamedObject(&module->fields, "__name__", (KrkObj*)S(name)); \\\\\\\n\
|
||||
\tkrk_attachNamedValue(&module->fields, "__file__", NONE_VAL()); \\\\\\\n\
|
||||
} \\\n\
|
||||
\n\
|
||||
}' src/vm.c \
|
||||
&& sed -i $'/krk_module_init_dis/{\na\\\
|
||||
} \\' \
|
||||
$'/krk_module_init_dis/a\\\
|
||||
\#endif\\\n\
|
||||
\#ifdef KRK_DISABLE_DYNAMIC\\\n\
|
||||
\t\tBUILTIN_MODULE("math", krk_module_onload_math)\\\n\
|
||||
|
@ -69,44 +67,47 @@ KrkValue krk_module_onload_wcwidth(void);\\\n\
|
|||
\t\tBUILTIN_MODULE("socket", krk_module_onload_socket)\\\n\
|
||||
\t\tBUILTIN_MODULE("timeit", krk_module_onload_timeit)\\\n\
|
||||
\t\tBUILTIN_MODULE("wcwidth", krk_module_onload_wcwidth)\n\
|
||||
}' src/vm.c \
|
||||
' \
|
||||
\
|
||||
&& sed -i '/netdb\.h/a\#include <netinet/in.h>' src/modules/module_socket.c \
|
||||
&& sed -i $'/switch (afval)/{\ni\\\
|
||||
&& shed src/modules/module_socket.c \
|
||||
'/netdb\.h/a\#include <netinet/in.h>' \
|
||||
$'/switch (afval)/{\ni\\\
|
||||
\tif (afval == AF_INET) return "AF_INET";\\\n\
|
||||
\tif (afval == AF_INET6) return "AF_INET6";\\\n\
|
||||
\tif (afval == AF_UNIX) return "AF_UNIX";\\\n\
|
||||
\tsnprintf(tmp,30,"%d",afval);\\\n\
|
||||
\treturn tmp;\n\
|
||||
}\n\
|
||||
/switch (afval)/,/}/d' src/modules/module_socket.c \
|
||||
/switch (afval)/,/}/d' \
|
||||
\
|
||||
&& sed -i $'/strlen(buf)-1/{\n\
|
||||
&& shed src/kuroko.c \
|
||||
$'/strlen(buf)-1/{\n\
|
||||
s/if .*/if (buf[buflen-1] == \'\\\\n\') {/\n\
|
||||
i\\\
|
||||
\t\t\t\tsize_t buflen = strlen(buf);\n\
|
||||
a\\\
|
||||
\t\t\t\t\t\\if (buflen >= 2 && buf[buflen-2] == \'\\\\r\') buf[buflen-2] = \'\\\\n\', buf[buflen-1] = \'\\\\0\';\\\n\
|
||||
\t\t\t\t} else {\n\
|
||||
}' src/kuroko.c \
|
||||
}' \
|
||||
\
|
||||
&& sed -i $'/ifdef KRK_DISABLE_THREADS/i\\\
|
||||
&& shed Makefile \
|
||||
$'/ifdef KRK_DISABLE_THREADS/i\\\
|
||||
ifdef KRK_DISABLE_DYNAMIC\\\n\
|
||||
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\\\n\
|
||||
CFLAGS += -DKRK_DISABLE_DYNAMIC -DSTATIC_ONLY\\\n\
|
||||
endif\\\n\
|
||||
' Makefile \
|
||||
&& sed -i $'/CFLAGS += -DKRK_DISABLE_THREADS/a\\\
|
||||
' \
|
||||
$'/CFLAGS += -DKRK_DISABLE_THREADS/a\\\
|
||||
else\\\n\
|
||||
CFLAGS += -DKRK_MEDIOCRE_TLS\
|
||||
' Makefile \
|
||||
' \
|
||||
\
|
||||
&& { diff -NrU3 /kuroko.orig/ /kuroko/ > /kuroko.patch; [ $? -le 1 ]; }
|
||||
# diff exit status is normally 0 or 1, anything greater is an error.
|
||||
|
||||
RUN : \
|
||||
# this isn't included in the patch because it's super specific to cosmopolitan. \
|
||||
&& sed -i 's/int main/dontinline int _main/' src/kuroko.c \
|
||||
&& shed src/kuroko.c 's/int main/dontinline int _main/' \
|
||||
&& printf %s >>src/kuroko.c $'\n\
|
||||
STATIC_YOINK("__die");\n\
|
||||
void ShowCrashReports(void);\n\
|
||||
|
|
|
@ -75,10 +75,11 @@ RUN : \
|
|||
|
||||
WORKDIR perl
|
||||
|
||||
COPY --chmod=0755 --from=localhost/notwa-util /usr/local/bin/shed /usr/bin/
|
||||
RUN : \
|
||||
&& sed -i '/x86_64-linux-musl/d' hints/cosmo.sh \
|
||||
&& sed -i 's/.*-musl-objcopy/\tobjcopy/g' Makefile.SH \
|
||||
&& sed -i '/^cosmo\//d' MANIFEST \
|
||||
&& shed hints/cosmo.sh '/x86_64-linux-musl/d' \
|
||||
&& shed Makefile.SH 's/.*-musl-objcopy/\tobjcopy/g' \
|
||||
&& shed MANIFEST '/^cosmo\//d' \
|
||||
\
|
||||
&& COSMO_MODE="" COSMO_REPO="/cosmopolitan" sh Configure -d -e \
|
||||
-Dprefix="/zip" \
|
||||
|
|
|
@ -49,15 +49,15 @@ RUN : \
|
|||
&& cd /cosmopolitan \
|
||||
&& tar zxf dist/headers.tar.gz \
|
||||
;
|
||||
COPY --chmod=0755 --from=localhost/notwa-util /usr/local/bin/cosmocc /usr/local/bin/quickconf /usr/bin/
|
||||
COPY --chmod=0755 --from=localhost/notwa-util /usr/local/bin/cosmocc /usr/local/bin/quickconf /usr/local/bin/shed /usr/bin/
|
||||
|
||||
COPY --from=downloader /kissat /kissat
|
||||
WORKDIR /kissat
|
||||
RUN : \
|
||||
# the alarm function is located here: \
|
||||
&& sed -i '/#include <unistd.h>/i\\#include <time.h>' src/application.c \
|
||||
&& shed src/application.c '/#include <unistd.h>/i\\#include <time.h>' \
|
||||
# completely override CFLAGS: \
|
||||
&& sed -i '/passtocompiler -fpic/i\\CFLAGS=" -O2 -g -Wall"' configure \
|
||||
&& 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 \
|
||||
;
|
||||
|
@ -90,11 +90,12 @@ COPY --from=downloader /yices /yices
|
|||
WORKDIR /yices
|
||||
RUN : \
|
||||
# patch up some trivial incompatibilities with cosmopolitan: \
|
||||
&& sed -i 's/\bdonothing\b/&_/g' src/context/context.c \
|
||||
&& sed -i 's/\bhextoint\b/&_/g' src/terms/bv_constants.c src/terms/bv64_constants.c \
|
||||
&& sed -i '/#include <unistd.h>/i\\#include <time.h>' src/utils/timeout.c \
|
||||
&& 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. \
|
||||
&& sed -i 's/ $(static_libyices_dynamic)//g' src/Makefile \
|
||||
&& shed src/Makefile 's/ $(static_libyices_dynamic)//g' \
|
||||
\
|
||||
&& autoconf \
|
||||
&& CC=cosmocc \
|
||||
|
|
|
@ -29,18 +29,19 @@ WORKDIR /cosmopolitan
|
|||
# tell makefiles to be less noisy, also use /tmp:
|
||||
ENV V=0 COLUMNS=80 TMPDIR=/tmp
|
||||
|
||||
COPY --chmod=0755 --from=localhost/notwa-util /usr/local/bin/shed /usr/bin/
|
||||
RUN : \
|
||||
# allow optimized builds to be more portable, so the container is too. \
|
||||
&& sed -i 's/-march=native/-march=haswell -mno-pclmul -mtune=generic/' build/config.mk \
|
||||
&& shed build/config.mk 's/-march=native/-march=haswell -mno-pclmul -mtune=generic/' \
|
||||
# fix execution on alpine (although installing the loader mitigates this) \
|
||||
&& sed -i 's/skip=" 76" count=" 128"/skip=76 count=128 /' build/bootstrap/*.com \
|
||||
&& install -m0755 build/bootstrap/ape.elf /usr/bin/ape \
|
||||
# include LoadZipArgs in cosmopolitan.a \
|
||||
&& sed -i '/COSMOPOLITAN_OBJECTS =/a\\tTOOL_ARGS\t\t\\' Makefile \
|
||||
&& shed Makefile '/COSMOPOLITAN_OBJECTS =/a\\tTOOL_ARGS\t\t\\' \
|
||||
# include nsync_cv_signal and nsync_cv_wait_with_deadline in cosmopolitan.a \
|
||||
&& sed -i '/THIRD_PARTY_NSYNC_MALLOC/i\\tTHIRD_PARTY_NSYNC_MEM\t\t\\' Makefile \
|
||||
&& shed Makefile '/THIRD_PARTY_NSYNC_MALLOC/i\\tTHIRD_PARTY_NSYNC_MEM\t\t\\' \
|
||||
# awk's pledge isn't working for me for whatever reason \
|
||||
&& sed -i '/pledge.*{/,/}/d' third_party/awk/main.c \
|
||||
&& shed third_party/awk/main.c '/pledge.*{/,/}/d' \
|
||||
# create a mapping from flavor to mode (possibly an empty string) \
|
||||
&& { [ "$COSMO_FLAVOR" != def ] && mode="$COSMO_FLAVOR" || mode=; } \
|
||||
&& printf '%s="%s"\n' >env \
|
||||
|
|
Loading…
Reference in a new issue