mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 03:08:31 +00:00
Introduce cosmocc flags -mdbg -mtiny -moptlinux
The cosmocc.zip toolchain will now include four builds of the libcosmo.a runtime libraries. You can pass the -mdbg flag if you want to debug your cosmopolitan runtime. You can pass the -moptlinux flag if you don't want windows code lurking in your binary. See tool/cosmocc/README.md for more details on how these flags may be used and their important implications.
This commit is contained in:
parent
59692b0882
commit
642e9cb91a
22 changed files with 404 additions and 56 deletions
|
@ -516,7 +516,11 @@ void AddArg(char *actual) {
|
|||
}
|
||||
|
||||
static int GetBaseCpuFreqMhz(void) {
|
||||
#ifdef __x86_64__
|
||||
return KCPUIDS(16H, EAX) & 0x7fff;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void PlanResource(int resource, struct rlimit rlim) {
|
||||
|
|
|
@ -373,7 +373,11 @@ int SetLimit(int r, long lo, long hi) {
|
|||
}
|
||||
|
||||
static int GetBaseCpuFreqMhz(void) {
|
||||
#ifdef __x86_64__
|
||||
return KCPUIDS(16H, EAX) & 0x7fff;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int SetCpuLimit(int secs) {
|
||||
|
|
|
@ -142,6 +142,116 @@ and AARCH64, which is K8 and ARMv8.0. You can pass architecture specific
|
|||
flags to use newer ISAs by using the `-Xx86_64` and `-Xaarch64` prefixes
|
||||
like `-Xx86_64-mssse3` and `-Xaarch64-march=armv8.2-a+dotprod`.
|
||||
|
||||
## Flags
|
||||
|
||||
The following supplemental flags are defined by cosmocc:
|
||||
|
||||
- `-mcosmo` causes `_COSMO_SOURCE` to be defined. This has a similar
|
||||
effect to defining `_GNU_SOURCE`. When you use this flag, many
|
||||
non-standard GNU, BSD, and Cosmo Libc APIs will become visible in
|
||||
headers, e.g. `stdlib.h` will now define `ShowCrashReports()`.
|
||||
Including `cosmo.h` has a similar effect, however it's recommended
|
||||
that any program that uses cosmo-specific APIs pass this flag.
|
||||
|
||||
- `-mdbg` may be passed when linking programs. It has the same effect as
|
||||
`export MODE=dbg` in that it will cause an alternative build of the
|
||||
Cosmopolitan Libc runtime to be linked that was built with `-O0 -g`.
|
||||
Under the normal build mode, `--ftrace` output is oftentimes missing
|
||||
important pieces of the puzzle due to inlining. This mode makes it
|
||||
more comprehensible. It's also the only way to make using GDB to
|
||||
troubleshoot issues inside Cosmo Libc work reliably. Please be warned
|
||||
that this flag may enable some heavyweight runtime checks. For
|
||||
example, mmap() will become O(n) rather than O(logn) in an effort to
|
||||
spot data structure corruption. Lastly, the linked Cosmo runtime was
|
||||
compiled with `-fsanitize=undefined` (UBSAN) although you still need
|
||||
to pass that flag too if you want it for your own code.
|
||||
|
||||
- `-mtiny` may be passed when linking programs. It has the same effect
|
||||
as `export MODE=tiny` in that it will cause an alternative build of
|
||||
the Cosmopolitan Libc runtime to be linked that's optimized for code
|
||||
size. In the normal build mode, the smallest possible binary size will
|
||||
be on the order of hundreds of kb, due to heavyweight features like
|
||||
`--ftrace` and `--strace` being part of the mandatory runtime. Those
|
||||
features don't exist in the tiny runtime, which should produce ~147kb
|
||||
fat binaries and ~36kb x86-only binaries. You may also use this flag
|
||||
when compiling objects. Since there's no function tracing, using this
|
||||
will eliminate the NOPs that get inserted into the prologues of your
|
||||
functions to make them hookable, which also greatly reduces code size.
|
||||
Please note that this does not specify an `-O` flag, so you may want
|
||||
to pass `-Os` too. Please note that this mode is granted leeway to
|
||||
trade away performance whenever possible. Functions like memmove()
|
||||
will stop using fancy vectorization which can dramatically decrease
|
||||
the performance of certain use cases. malloc() will stop using cookies
|
||||
which add bloat but are considered important by some people for both
|
||||
security and reporting errors on corruption. APIs will also begin
|
||||
refraining from detecting usage errors that are the fault of the
|
||||
caller, so this mode isn't recommended for development.
|
||||
|
||||
- `-moptlinux` uses the optimized Linux-only version of Cosmopolitan
|
||||
Libc runtime libraries. Your program will only be able to run on
|
||||
Linux. The runtime is compiled at `-O3` although it still supports AMD
|
||||
K8+ (c. 2003). Optimizations like red zone that wouldn't otherwise be
|
||||
possible are enabled. Function call tracing and system call logging is
|
||||
disabled. All the Windows polyfills go away and your binaries will be
|
||||
significantly tinier. The `cosmocc` compiler will generate a shell
|
||||
script with the magic `jartsr='` so you won't get unwanted attention
|
||||
from Windows virus scanners. You're even allowed to use flags like
|
||||
`-fomit-frame-pointer` when you use this mode. Users report optlinux
|
||||
has helped them make the Python interpreter 5% faster, like distros,
|
||||
optlinux will salt the earth if it gains a 1% advantage on benchmark
|
||||
games. Therefore this mode gives you an apples-to-apples comparison
|
||||
between cosmocc versus the gcc/clang configs used by linux distros.
|
||||
|
||||
## Raw Toolchains
|
||||
|
||||
The `cosmocc` and `cosmoar` programs use shell script magic to run both
|
||||
toolchains under the hood. Sometimes this magic doesn't work when you're
|
||||
building software that needs to do things like run the C preprocessor in
|
||||
aarch64 mode. In such cases, cosmocc provides x86\_64 and aarch64 only
|
||||
toolchains which give you more power and control over your builds.
|
||||
|
||||
- `x86_64-unknown-cosmo-cc`, `x86_64-unknown-cosmo-c++`, and
|
||||
`x86_64-linux-cosmo-as` let you build multi-OS programs that only run
|
||||
on x86\_64. You'll need this if you want to compile complex projects
|
||||
like Emacs and OpenSSL. These are shell scripts that help you make
|
||||
sure your software is compiled with the correct set of flags.
|
||||
|
||||
- `aarch64-unknown-cosmo-cc`, `aarch64-unknown-cosmo-c++`, and
|
||||
`aarch64-linux-cosmo-as` let you build multi-OS programs that only run
|
||||
on ARM64. You'll need this if you want to compile complex projects
|
||||
like Emacs and OpenSSL. These are shell scripts that help you make
|
||||
sure your software is compiled with the correct set of flags.
|
||||
|
||||
- `aarch64-linux-cosmo-cc`, `aarch64-linux-cosmo-c++`,
|
||||
`aarch64-linux-cosmo-as`, and `aarch64-linux-cosmo-ld` are the actual
|
||||
compiler executables. Using these grants full control over your
|
||||
compiler and maximum performance. This is the approach favored for
|
||||
instance by the Cosmopolitan Mono Repo's Makefile. If you use these,
|
||||
then you should have zero expectation of support, because you'll be
|
||||
assuming all responsibility for knowing about all the ABI-related
|
||||
flags your Cosmopolitan runtime requires.
|
||||
|
||||
When you use the "unknown" OS compilers, they'll link ELF executables
|
||||
which embed an APE program image. This is so it's possible to have DWARF
|
||||
debugging data. If you say:
|
||||
|
||||
```
|
||||
x86_64-unknown-cosmo-cc -Os -mtiny -o hello hello.c
|
||||
./hello
|
||||
x86_64-linux-cosmo-objcopy -SO binary hello hello.com
|
||||
./hello.com
|
||||
```
|
||||
|
||||
Then you can unwap the raw stripped APE executable and get a much
|
||||
smaller file than you otherwise would using the `-s` flag.
|
||||
|
||||
If you compile your software twice, using both the x86\_64 and aarch64
|
||||
compilers, then it's possible to link the two binaries into a single fat
|
||||
binary yourself via the `apelink` program. To understand how this
|
||||
process works, it works best if you use the `BUILDLOG` variable, to see
|
||||
how the shell script wrappers are doing it. You can also consult the
|
||||
build configs of the ahgamut/superconfigure project on GitHub.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Your `cosmocc` compiler runs a number commands under the hood. If
|
||||
|
|
|
@ -156,6 +156,15 @@ for x; do
|
|||
elif [ x"$x" = x"-mcosmo" ]; then
|
||||
MCOSMO=1
|
||||
continue
|
||||
elif [ x"$x" = x"-mdbg" ]; then
|
||||
MODE=dbg
|
||||
continue
|
||||
elif [ x"$x" = x"-mtiny" ]; then
|
||||
MODE=tiny
|
||||
continue
|
||||
elif [ x"$x" = x"-moptlinux" ]; then
|
||||
MODE=optlinux
|
||||
continue
|
||||
elif [ x"$x" = x"-fomit-frame-pointer" ]; then
|
||||
# Quoth Apple: "The frame pointer register must always address a
|
||||
# valid frame record. Some functions — such as leaf functions or
|
||||
|
@ -243,10 +252,10 @@ LDFLAGS="-static -nostdlib -no-pie -fuse-ld=bfd -Wl,-z,noexecstack -Wl,-z,norelr
|
|||
PRECIOUS="-fno-omit-frame-pointer"
|
||||
|
||||
# these features screw with backtraces so avoid them
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"$MODE" != x"tiny" ]; then
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"$MODE" != x"tiny" ] && [ x"$MODE" != x"optlinux" ]; then
|
||||
CFLAGS="$CFLAGS -fno-optimize-sibling-calls -mno-omit-leaf-frame-pointer"
|
||||
fi
|
||||
if [ x"$OPT" != x"-O3" ]; then
|
||||
if [ x"$OPT" != x"-O3" ] && [ x"$MODE" != x"optlinux" ]; then
|
||||
CFLAGS="$CFLAGS -fno-schedule-insns2"
|
||||
fi
|
||||
|
||||
|
@ -261,19 +270,39 @@ else
|
|||
CFLAGS="$CFLAGS -Wno-implicit-int"
|
||||
fi
|
||||
|
||||
CRT_X86_64="$BIN/../x86_64-linux-cosmo/lib/ape.o $BIN/../x86_64-linux-cosmo/lib/crt.o"
|
||||
CPPFLAGS_X86_64="$CPPFLAGS -mno-red-zone"
|
||||
if [ x"$MODE" = x"dbg" ]; then
|
||||
LIB_X86_64="$BIN/../x86_64-linux-cosmo/lib/dbg"
|
||||
LIB_AARCH64="$BIN/../aarch64-linux-cosmo/lib/dbg"
|
||||
elif [ x"$MODE" = x"tiny" ]; then
|
||||
LIB_X86_64="$BIN/../x86_64-linux-cosmo/lib/tiny"
|
||||
LIB_AARCH64="$BIN/../aarch64-linux-cosmo/lib/tiny"
|
||||
elif [ x"$MODE" = x"optlinux" ]; then
|
||||
LIB_X86_64="$BIN/../x86_64-linux-cosmo/lib/optlinux"
|
||||
LIB_AARCH64="$BIN/../aarch64-linux-cosmo/lib/optlinux"
|
||||
else
|
||||
LIB_X86_64="$BIN/../x86_64-linux-cosmo/lib"
|
||||
LIB_AARCH64="$BIN/../aarch64-linux-cosmo/lib"
|
||||
fi
|
||||
|
||||
CRT_X86_64="$LIB_X86_64/ape.o $LIB_X86_64/crt.o"
|
||||
CPPFLAGS_X86_64="$CPPFLAGS"
|
||||
CFLAGS_X86_64="$CFLAGS -mno-tls-direct-seg-refs"
|
||||
LDFLAGS_X86_64="$LDFLAGS -L$BIN/../x86_64-linux-cosmo/lib -Wl,-T,$BIN/../x86_64-linux-cosmo/lib/ape.lds -Wl,-z,common-page-size=4096 -Wl,-z,max-page-size=16384"
|
||||
LDFLAGS_X86_64="$LDFLAGS -L$LIB_X86_64 -L$BIN/../x86_64-linux-cosmo/lib -Wl,-T,$LIB_X86_64/ape.lds -Wl,-z,common-page-size=4096 -Wl,-z,max-page-size=16384"
|
||||
LDLIBS_X86_64="-lcosmo"
|
||||
|
||||
CRT_AARCH64="$BIN/../aarch64-linux-cosmo/lib/crt.o"
|
||||
CRT_AARCH64="$LIB_AARCH64/crt.o"
|
||||
CPPFLAGS_AARCH64="$CPPFLAGS -fsigned-char"
|
||||
CFLAGS_AARCH64="$CFLAGS -ffixed-x18 -ffixed-x28 -mno-outline-atomics"
|
||||
LDFLAGS_AARCH64="$LDFLAGS -L$BIN/../aarch64-linux-cosmo/lib -Wl,-T,$BIN/../aarch64-linux-cosmo/lib/aarch64.lds -Wl,-z,common-page-size=16384 -Wl,-z,max-page-size=16384"
|
||||
LDFLAGS_AARCH64="$LDFLAGS -L$LIB_AARCH64 -L$BIN/../aarch64-linux-cosmo/lib -Wl,-T,$LIB_AARCH64/aarch64.lds -Wl,-z,common-page-size=16384 -Wl,-z,max-page-size=16384"
|
||||
LDLIBS_AARCH64="-lcosmo"
|
||||
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"$MODE" != x"tiny" ]; then
|
||||
SUPPORT_VECTOR=-1
|
||||
if [ x"$MODE" = x"optlinux" ]; then
|
||||
CPPFLAGS_X86_64="$CPPFLAGS_X86_64 -mno-red-zone"
|
||||
SUPPORT_VECTOR=linux
|
||||
fi
|
||||
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"$MODE" != x"tiny" ] && [ x"$MODE" != x"optlinux" ]; then
|
||||
CFLAGS_X86_64="${CFLAGS_X86_64} -fpatchable-function-entry=18,16 -fno-inline-functions-called-once -DFTRACE -DSYSDEBUG"
|
||||
CFLAGS_AARCH64="${CFLAGS_AARCH64} -fpatchable-function-entry=7,6 -fno-inline-functions-called-once -DFTRACE -DSYSDEBUG"
|
||||
fi
|
||||
|
@ -526,6 +555,7 @@ fi
|
|||
|
||||
set -- \
|
||||
"$BIN/apelink" \
|
||||
-V "$SUPPORT_VECTOR" \
|
||||
-l "$BIN/ape-x86_64.elf" \
|
||||
-l "$BIN/ape-aarch64.elf" \
|
||||
-M "$BIN/ape-m1.c" \
|
||||
|
@ -536,10 +566,12 @@ set -- \
|
|||
log_command "$@"
|
||||
"$@" || Exit
|
||||
|
||||
set -- \
|
||||
"$BIN/pecheck" "$OUTPUT"
|
||||
log_command "$@"
|
||||
"$@" || Exit
|
||||
if [ x"$MODE" != "optlinux" ]; then
|
||||
set -- \
|
||||
"$BIN/pecheck" "$OUTPUT"
|
||||
log_command "$@"
|
||||
"$@" || Exit
|
||||
fi
|
||||
|
||||
if [ $INTENT = ld ] && [ $SAVE_TEMPS -eq 0 ]; then
|
||||
mv -f "$OUTPUT_X86_64" "${OUTPUT%.com}.com.dbg" || Exit
|
||||
|
|
|
@ -59,13 +59,33 @@ if [ x"$ARCH" = x"$PROG" ]; then
|
|||
fatal_error "cosmocross must be run via cross compiler"
|
||||
fi
|
||||
|
||||
for x; do
|
||||
if [ x"$x" = x"-mtiny" ]; then
|
||||
MODE=tiny
|
||||
elif [ x"$x" = x"-mdbg" ]; then
|
||||
MODE=dbg
|
||||
elif [ x"$x" = x"-moptlinux" ]; then
|
||||
MODE=optlinux
|
||||
fi
|
||||
done
|
||||
|
||||
if [ x"$MODE" = x"dbg" ]; then
|
||||
LIB="$BIN/../$ARCH-linux-cosmo/lib/dbg"
|
||||
elif [ x"$MODE" = x"tiny" ]; then
|
||||
LIB="$BIN/../$ARCH-linux-cosmo/lib/tiny"
|
||||
elif [ x"$MODE" = x"optlinux" ]; then
|
||||
LIB="$BIN/../$ARCH-linux-cosmo/lib/optlinux"
|
||||
else
|
||||
LIB="$BIN/../$ARCH-linux-cosmo/lib"
|
||||
fi
|
||||
|
||||
CC="$BIN/$ARCH-linux-cosmo-gcc"
|
||||
CRT="$BIN/../$ARCH-linux-cosmo/lib/crt.o"
|
||||
CRT="$LIB/crt.o"
|
||||
LDLIBS="-lcosmo"
|
||||
if [ -z "$COSMOS" ]; then
|
||||
LDFLAGS="$LDFLAGS -L$BIN/../$ARCH-linux-cosmo/lib"
|
||||
LDFLAGS="$LDFLAGS -L$LIB -L$BIN/../$ARCH-linux-cosmo/lib"
|
||||
else
|
||||
LDFLAGS="$LDFLAGS -L$COSMOS/lib -L$BIN/../$ARCH-linux-cosmo/lib"
|
||||
LDFLAGS="$LDFLAGS -L$COSMOS/lib -L$LIB -L$BIN/../$ARCH-linux-cosmo/lib"
|
||||
CPPFLAGS="$CPPFLAGS -I$COSMOS/include"
|
||||
fi
|
||||
if [ x"$PROG" != x"${PROG%++}" ]; then
|
||||
|
@ -80,16 +100,20 @@ fi
|
|||
PAGESZ=4096
|
||||
if [ x"$ARCH" = x"x86_64" ]; then
|
||||
OBJCOPYFLAGS="-S -O binary"
|
||||
CRT="$BIN/../$ARCH-linux-cosmo/lib/ape-no-modify-self.o $CRT"
|
||||
CPPFLAGS="$CPPFLAGS -mno-red-zone"
|
||||
CRT="$LIB/ape-no-modify-self.o $CRT"
|
||||
CFLAGS="$CFLAGS -mno-tls-direct-seg-refs"
|
||||
LDFLAGS="$LDFLAGS -Wl,-T,$BIN/../$ARCH-linux-cosmo/lib/ape.lds"
|
||||
LDFLAGS="$LDFLAGS -Wl,-T,$LIB/ape.lds"
|
||||
if [ x"$MODE" = x"optlinux" ]; then
|
||||
CPPFLAGS="$CPPFLAGS -mred-zone"
|
||||
else
|
||||
CPPFLAGS="$CPPFLAGS -mno-red-zone"
|
||||
fi
|
||||
elif [ x"$ARCH" = x"aarch64" ]; then
|
||||
OBJCOPYFLAGS="-S"
|
||||
PAGESZ=16384
|
||||
CPPFLAGS="$CPPFLAGS -fsigned-char"
|
||||
CFLAGS="$CFLAGS -ffixed-x18 -ffixed-x28 -mno-outline-atomics"
|
||||
LDFLAGS="$LDFLAGS -Wl,-T,$BIN/../$ARCH-linux-cosmo/lib/aarch64.lds"
|
||||
LDFLAGS="$LDFLAGS -Wl,-T,$LIB/aarch64.lds"
|
||||
else
|
||||
fatal_error "$ARCH: unsupported architecture"
|
||||
fi
|
||||
|
@ -142,6 +166,12 @@ for x; do
|
|||
elif [ x"$x" = x"-mcosmo" ]; then
|
||||
CPPFLAGS="$CPPFLAGS -D_COSMO_SOURCE"
|
||||
continue
|
||||
elif [ x"$x" = x"-mdbg" ]; then
|
||||
continue
|
||||
elif [ x"$x" = x"-mtiny" ]; then
|
||||
continue
|
||||
elif [ x"$x" = x"-moptlinux" ]; then
|
||||
continue
|
||||
elif [ x"$x" != x"${x#-o}" ]; then
|
||||
OUTPUT=${x#-o}
|
||||
elif [ x"$x" = x"-fpic" ]; then
|
||||
|
@ -189,6 +219,7 @@ fi
|
|||
|
||||
# support --ftrace unless optimizing for size
|
||||
if [ x"$OPT" != x"-Os" ] && # $OPT != -Os
|
||||
[ x"$MODE" != x"optlinux" ] && # $MODE not optlinux
|
||||
[ x"${MODE%tiny}" = x"${MODE}" ]; then # $MODE not in (tiny, aarch64-tiny)
|
||||
if [ x"$ARCH" = x"x86_64" ]; then
|
||||
CFLAGS="$CFLAGS -fpatchable-function-entry=18,16 -fno-inline-functions-called-once"
|
||||
|
@ -199,10 +230,11 @@ fi
|
|||
|
||||
# maximize frame pointers unless optimizing for size
|
||||
if [ x"$OPT" != x"-Os" ] && # $OPT != "-Os"
|
||||
[ x"$MODE" != x"optlinux" ] && # $MODE not optlinux
|
||||
[ x"$MODE" != x"${MODE%tiny}" ]; then # endswith($MODE, "tiny")
|
||||
CFLAGS="$CFLAGS -fno-optimize-sibling-calls -mno-omit-leaf-frame-pointer"
|
||||
fi
|
||||
if [ x"$OPT" != x"-O3" ]; then
|
||||
if [ x"$OPT" != x"-O3" ] && [ x"$MODE" != x"optlinux" ]; then
|
||||
CFLAGS="$CFLAGS -fno-schedule-insns2"
|
||||
fi
|
||||
|
||||
|
|
|
@ -61,6 +61,42 @@ make -j64 m=$AMD64 \
|
|||
o/$AMD64/third_party/make/make.dbg \
|
||||
o/$AMD64/third_party/ctags/ctags.dbg
|
||||
|
||||
make -j64 m=$AMD64-tiny \
|
||||
o/cosmocc.h.txt \
|
||||
o/$AMD64-tiny/ape/ape.lds \
|
||||
o/$AMD64-tiny/libc/crt/crt.o \
|
||||
o/$AMD64-tiny/ape/ape.elf \
|
||||
o/$AMD64-tiny/ape/ape.macho \
|
||||
o/$AMD64-tiny/ape/ape.o \
|
||||
o/$AMD64-tiny/ape/ape-copy-self.o \
|
||||
o/$AMD64-tiny/ape/ape-no-modify-self.o \
|
||||
o/$AMD64-tiny/cosmopolitan.a \
|
||||
o/$AMD64-tiny/third_party/libcxx/libcxx.a \
|
||||
|
||||
make -j64 m=$AMD64-dbg \
|
||||
o/cosmocc.h.txt \
|
||||
o/$AMD64-dbg/ape/ape.lds \
|
||||
o/$AMD64-dbg/libc/crt/crt.o \
|
||||
o/$AMD64-dbg/ape/ape.elf \
|
||||
o/$AMD64-dbg/ape/ape.macho \
|
||||
o/$AMD64-dbg/ape/ape.o \
|
||||
o/$AMD64-dbg/ape/ape-copy-self.o \
|
||||
o/$AMD64-dbg/ape/ape-no-modify-self.o \
|
||||
o/$AMD64-dbg/cosmopolitan.a \
|
||||
o/$AMD64-dbg/third_party/libcxx/libcxx.a \
|
||||
|
||||
make TARGET_ARCH= -j64 m=$AMD64-optlinux \
|
||||
o/cosmocc.h.txt \
|
||||
o/$AMD64-optlinux/ape/ape.lds \
|
||||
o/$AMD64-optlinux/libc/crt/crt.o \
|
||||
o/$AMD64-optlinux/ape/ape.elf \
|
||||
o/$AMD64-optlinux/ape/ape.macho \
|
||||
o/$AMD64-optlinux/ape/ape.o \
|
||||
o/$AMD64-optlinux/ape/ape-copy-self.o \
|
||||
o/$AMD64-optlinux/ape/ape-no-modify-self.o \
|
||||
o/$AMD64-optlinux/cosmopolitan.a \
|
||||
o/$AMD64-optlinux/third_party/libcxx/libcxx.a \
|
||||
|
||||
make -j64 m=$ARM64 \
|
||||
o/$ARM64/ape/ape.elf \
|
||||
o/$ARM64/ape/aarch64.lds \
|
||||
|
@ -95,6 +131,33 @@ make -j64 m=$ARM64 \
|
|||
o/$ARM64/third_party/make/make.dbg \
|
||||
o/$ARM64/third_party/ctags/ctags.dbg
|
||||
|
||||
make -j64 m=$ARM64-tiny \
|
||||
o/$ARM64-tiny/ape/ape.elf \
|
||||
o/$ARM64-tiny/ape/aarch64.lds \
|
||||
o/$ARM64-tiny/libc/crt/crt.o \
|
||||
o/$ARM64-tiny/ape/ape-copy-self.o \
|
||||
o/$ARM64-tiny/ape/ape-no-modify-self.o \
|
||||
o/$ARM64-tiny/cosmopolitan.a \
|
||||
o/$ARM64-tiny/third_party/libcxx/libcxx.a \
|
||||
|
||||
make -j64 m=$ARM64-dbg \
|
||||
o/$ARM64-dbg/ape/ape.elf \
|
||||
o/$ARM64-dbg/ape/aarch64.lds \
|
||||
o/$ARM64-dbg/libc/crt/crt.o \
|
||||
o/$ARM64-dbg/ape/ape-copy-self.o \
|
||||
o/$ARM64-dbg/ape/ape-no-modify-self.o \
|
||||
o/$ARM64-dbg/cosmopolitan.a \
|
||||
o/$ARM64-dbg/third_party/libcxx/libcxx.a \
|
||||
|
||||
make -j64 m=$ARM64-optlinux \
|
||||
o/$ARM64-optlinux/ape/ape.elf \
|
||||
o/$ARM64-optlinux/ape/aarch64.lds \
|
||||
o/$ARM64-optlinux/libc/crt/crt.o \
|
||||
o/$ARM64-optlinux/ape/ape-copy-self.o \
|
||||
o/$ARM64-optlinux/ape/ape-no-modify-self.o \
|
||||
o/$ARM64-optlinux/cosmopolitan.a \
|
||||
o/$ARM64-optlinux/third_party/libcxx/libcxx.a \
|
||||
|
||||
mkdir -p "$OUTDIR/bin/"
|
||||
cp tool/cosmocc/README.md "$OUTDIR/"
|
||||
cp tool/cosmocc/LICENSE.* "$OUTDIR/"
|
||||
|
@ -155,19 +218,51 @@ cd "$OLD"
|
|||
|
||||
for arch in $AMD64 $ARM64; do
|
||||
mkdir -p "$OUTDIR/$arch-linux-cosmo/lib/"
|
||||
mkdir -p "$OUTDIR/$arch-linux-cosmo/lib/dbg"
|
||||
mkdir -p "$OUTDIR/$arch-linux-cosmo/lib/tiny"
|
||||
mkdir -p "$OUTDIR/$arch-linux-cosmo/lib/optlinux"
|
||||
|
||||
cp -f o/$arch/libc/crt/crt.o "$OUTDIR/$arch-linux-cosmo/lib/"
|
||||
cp -f o/$arch-dbg/libc/crt/crt.o "$OUTDIR/$arch-linux-cosmo/lib/dbg/"
|
||||
cp -f o/$arch-tiny/libc/crt/crt.o "$OUTDIR/$arch-linux-cosmo/lib/tiny/"
|
||||
cp -f o/$arch-optlinux/libc/crt/crt.o "$OUTDIR/$arch-linux-cosmo/lib/optlinux/"
|
||||
|
||||
cp -f o/$arch/cosmopolitan.a "$OUTDIR/$arch-linux-cosmo/lib/libcosmo.a"
|
||||
cp -f o/$arch-dbg/cosmopolitan.a "$OUTDIR/$arch-linux-cosmo/lib/dbg/libcosmo.a"
|
||||
cp -f o/$arch-tiny/cosmopolitan.a "$OUTDIR/$arch-linux-cosmo/lib/tiny/libcosmo.a"
|
||||
cp -f o/$arch-optlinux/cosmopolitan.a "$OUTDIR/$arch-linux-cosmo/lib/optlinux/libcosmo.a"
|
||||
|
||||
cp -f o/$arch/third_party/libcxx/libcxx.a "$OUTDIR/$arch-linux-cosmo/lib/"
|
||||
cp -f o/$arch-dbg/third_party/libcxx/libcxx.a "$OUTDIR/$arch-linux-cosmo/lib/dbg/"
|
||||
cp -f o/$arch-tiny/third_party/libcxx/libcxx.a "$OUTDIR/$arch-linux-cosmo/lib/tiny/"
|
||||
cp -f o/$arch-optlinux/third_party/libcxx/libcxx.a "$OUTDIR/$arch-linux-cosmo/lib/optlinux/"
|
||||
|
||||
for lib in c dl gcc_s m crypt pthread resolv rt dl unwind gomp stdc++; do
|
||||
printf '\041\074\141\162\143\150\076\012' >"$OUTDIR/$arch-linux-cosmo/lib/lib$lib.a"
|
||||
done
|
||||
mkdir -p "$OUTDIR/lib/gcc/"
|
||||
touch "$OUTDIR/lib/gcc/libgomp.spec" # needed if user passes -fopenmp but not -lgomp
|
||||
done
|
||||
|
||||
cp -f o/$AMD64/ape/ape.o "$OUTDIR/x86_64-linux-cosmo/lib/"
|
||||
cp -f o/$AMD64-dbg/ape/ape.o "$OUTDIR/x86_64-linux-cosmo/lib/dbg/"
|
||||
cp -f o/$AMD64-tiny/ape/ape.o "$OUTDIR/x86_64-linux-cosmo/lib/tiny/"
|
||||
cp -f o/$AMD64-optlinux/ape/ape.o "$OUTDIR/x86_64-linux-cosmo/lib/optlinux/"
|
||||
|
||||
cp -f o/$AMD64/ape/ape.lds "$OUTDIR/x86_64-linux-cosmo/lib/"
|
||||
cp -f o/$AMD64-dbg/ape/ape.lds "$OUTDIR/x86_64-linux-cosmo/lib/dbg/"
|
||||
cp -f o/$AMD64-tiny/ape/ape.lds "$OUTDIR/x86_64-linux-cosmo/lib/tiny/"
|
||||
cp -f o/$AMD64-optlinux/ape/ape.lds "$OUTDIR/x86_64-linux-cosmo/lib/optlinux/"
|
||||
|
||||
cp -f o/$ARM64/ape/aarch64.lds "$OUTDIR/aarch64-linux-cosmo/lib/"
|
||||
cp -f o/$ARM64-dbg/ape/aarch64.lds "$OUTDIR/aarch64-linux-cosmo/lib/dbg/"
|
||||
cp -f o/$ARM64-tiny/ape/aarch64.lds "$OUTDIR/aarch64-linux-cosmo/lib/tiny/"
|
||||
cp -f o/$ARM64-optlinux/ape/aarch64.lds "$OUTDIR/aarch64-linux-cosmo/lib/optlinux/"
|
||||
|
||||
cp -f o/$AMD64/ape/ape-no-modify-self.o "$OUTDIR/x86_64-linux-cosmo/lib/"
|
||||
cp -f o/$AMD64-dbg/ape/ape-no-modify-self.o "$OUTDIR/x86_64-linux-cosmo/lib/dbg/"
|
||||
cp -f o/$AMD64-tiny/ape/ape-no-modify-self.o "$OUTDIR/x86_64-linux-cosmo/lib/tiny/"
|
||||
cp -f o/$AMD64-optlinux/ape/ape-no-modify-self.o "$OUTDIR/x86_64-linux-cosmo/lib/optlinux/"
|
||||
|
||||
cp -f ape/ape-m1.c "$OUTDIR/bin/"
|
||||
cp -af tool/cosmocc/bin/* "$OUTDIR/bin/"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue