Release Cosmopolitan v3.8.0

This change switches c++ exception handling from sjlj to standard dwarf.
It's needed because clang for aarch64 doesn't support sjlj. It turns out
that libunwind had a bare-metal configuration that made this easy to do.

This change gets the new experimental cosmocc -mclang flag in a state of
working so well that it can now be used to build all of llamafile and it
goes 3x faster in terms of build latency, without trading away any perf.

The int_fast16_t and int_fast32_t types are now always defined as 32-bit
in the interest of having more abi consistency between cosmocc -mgcc and
-mclang mode.
This commit is contained in:
Justine Tunney 2024-08-30 20:12:26 -07:00
parent 5b9862907c
commit c9152b6f14
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
188 changed files with 199063 additions and 636 deletions

View file

@ -9,13 +9,13 @@ reach a broader audience from the platform(s) of your choosing.
## What's Included
This toolchain bundles GCC 14.1.0, Cosmopolitan Libc, LLVM LIBCXX, LLVM
compiler-rt, and LLVM OpenMP. Additional libraries were provided by Musl
Libc, and the venerable BSDs OSes. This lets you benefit from the
awesome modern GCC compiler with the strongest GPL barrier possible. The
preprocessor advertises cross compilers as both `__COSMOCC__` and
`__COSMOPOLITAN__` whereas `cosmocc` additionally defines
`__FATCOSMOCC__`.
This toolchain bundles GCC 14.1.0, Clang 19, Cosmopolitan Libc, LLVM
LIBCXX, LLVM compiler-rt, and LLVM OpenMP. Additional libraries were
provided by Musl Libc, and the venerable BSDs OSes. This lets you
benefit from the awesome modern GCC compiler with the strongest GPL
barrier possible. The preprocessor advertises cross compilers as both
`__COSMOCC__` and `__COSMOPOLITAN__` whereas `cosmocc` additionally
defines `__FATCOSMOCC__`.
## Getting Started
@ -153,6 +153,14 @@ The following supplemental flags are defined by cosmocc:
Including `cosmo.h` has a similar effect, however it's recommended
that any program that uses cosmo-specific APIs pass this flag.
- `-mclang` (experimental) may be passed to the `cosmocc` command to use
Clang instead of GCC under the hood. This can help C++ code compile 3x
faster.
- `-mgcc` may be passed to the `cosmocc` command to use GCC instead of
Clang under the hood. Since this is the default mode, this flag may be
used to override the effect of passing the `-mclang` flag earlier.
- `-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`.
@ -417,7 +425,7 @@ statements instead, so that Cosmopolitan Libc's system constants will
work as expected. Our modifications to GNU GCC are published under the
ISC license at <https://github.com/ahgamut/gcc/tree/portcosmo-14.1>. The
binaries you see here were first published at
<https://github.com/ahgamut/superconfigure/releases/tag/z0.0.53> which
<https://github.com/ahgamut/superconfigure/releases/tag/z0.0.54> which
is regularly updated.
## Legal

View file

@ -75,14 +75,31 @@ elif [ ! -d "$TMPDIR" ]; then
fi
fi
CLANG=0
CC_X86_64="$BIN/x86_64-linux-cosmo-gcc"
CC_AARCH64="$BIN/aarch64-linux-cosmo-gcc"
CXX_X86_64="$BIN/x86_64-linux-cosmo-g++"
CXX_AARCH64="$BIN/aarch64-linux-cosmo-g++"
FPORTCOSMO="-fportcosmo"
TARGET_X86_64=
TARGET_AARCH64=
use_gcc() {
CLANG=0
CC_X86_64="$BIN/x86_64-linux-cosmo-gcc"
CC_AARCH64="$BIN/aarch64-linux-cosmo-gcc"
CXX_X86_64="$BIN/x86_64-linux-cosmo-g++"
CXX_AARCH64="$BIN/aarch64-linux-cosmo-g++"
TARGET_X86_64=
TARGET_AARCH64=
FPORTCOSMO="-fportcosmo"
FNO_INLINE_FUNCTIONS_CALLED_ONCE="-fno-inline-functions-called-once"
}
use_clang() {
CLANG=1
CC_X86_64="$BIN/cosmo-clang"
CC_AARCH64="$BIN/cosmo-clang"
CXX_X86_64="$BIN/cosmo-clang"
CXX_AARCH64="$BIN/cosmo-clang"
TARGET_X86_64="--target=x86_64"
TARGET_AARCH64="--target=aarch64"
FPORTCOSMO=
FNO_INLINE_FUNCTIONS_CALLED_ONCE="-fno-inline-functions-called-once"
}
use_gcc
X=
OPT=
@ -196,14 +213,10 @@ EOF
MODE=optlinux
continue
elif [ x"$x" = x"-mclang" ]; then
CLANG=1
CC_X86_64="$BIN/cosmo-clang"
CC_AARCH64="$BIN/cosmo-clang"
CXX_X86_64="$BIN/cosmo-clang++"
CXX_AARCH64="$BIN/cosmo-clang++"
TARGET_X86_64="--target=x86_64"
TARGET_AARCH64="--target=aarch64"
FPORTCOSMO=
use_clang
continue
elif [ x"$x" = x"-mgcc" ]; then
use_gcc
continue
elif [ x"$x" = x"-m64" ]; then
continue
@ -315,10 +328,14 @@ elif [ -n "$OUTPUT" ] && [ $INPUT_FILE_COUNT -gt 1 ]; then
fi
fi
if [ $INTENT = ld ]; then
use_gcc
fi
PLATFORM="-D__COSMOPOLITAN__ -D__COSMOCC__ -D__FATCOSMOCC__"
PREDEF="-include libc/integral/normalize.inc"
CPPFLAGS="-fno-pie -nostdinc -isystem $BIN/../include"
CFLAGS="$FPORTCOSMO -fno-dwarf2-cfi-asm -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-semantic-interposition"
CFLAGS="$FPORTCOSMO -fno-semantic-interposition"
LDFLAGS="-static -nostdlib -no-pie -fuse-ld=bfd -Wl,-z,noexecstack -Wl,-z,norelro -Wl,--gc-sections"
PRECIOUS="-fno-omit-frame-pointer"
@ -345,9 +362,6 @@ fi
if [ $CPLUSPLUS -eq 1 ]; then
CC_X86_64=$CXX_X86_64
CC_AARCH64=$CXX_AARCH64
if [ $INTENT != cpp ]; then
CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -fuse-cxa-atexit"
fi
CPPFLAGS="-isystem $BIN/../include/third_party/libcxx $CPPFLAGS"
else
CFLAGS="$CFLAGS -Wno-implicit-int"
@ -386,8 +400,8 @@ if [ x"$MODE" = x"optlinux" ]; then
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"
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
if [ $CPLUSPLUS -eq 1 ]; then

View file

@ -47,7 +47,7 @@ log_command() {
ORIGINAL="$0 $*"
PLATFORM="-D__COSMOPOLITAN__ -D__COSMOCC__"
PREDEF="-include libc/integral/normalize.inc"
CFLAGS="-fportcosmo -fno-dwarf2-cfi-asm -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-semantic-interposition"
CFLAGS="-fportcosmo -fno-semantic-interposition"
CPPFLAGS="-fno-pie -nostdinc -isystem $BIN/../include"
LDFLAGS="-static -no-pie -nostdlib -fuse-ld=bfd -Wl,-z,noexecstack"
APEFLAGS="-Wl,--gc-sections"
@ -109,7 +109,6 @@ else
fi
if [ $CPLUSPLUS -eq 1 ]; then
CC="$BIN/$ARCH-linux-cosmo-g++"
CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -fuse-cxa-atexit"
CPPFLAGS="-isystem $BIN/../include/third_party/libcxx $CPPFLAGS"
LDLIBS="-lcxx $LDLIBS"
else

View file

@ -102,8 +102,6 @@ make -j$NPROC m=$ARM64 \
o/$ARM64/ape/ape.elf \
o/$ARM64/ape/aarch64.lds \
o/$ARM64/libc/crt/crt.o \
o/$ARM64/ape/ape-copy-self.o \
o/$ARM64/ape/ape-no-modify-self.o \
o/$ARM64/cosmopolitan.a \
o/$ARM64/third_party/libcxx/libcxx.a \
o/$ARM64/tool/build/assimilate.dbg \
@ -136,8 +134,6 @@ make -j$NPROC 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 \
@ -145,8 +141,6 @@ make -j$NPROC 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 \
@ -154,8 +148,6 @@ make -j$NPROC 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 \
@ -182,17 +174,18 @@ fetch() {
OLD=$PWD
cd "$OUTDIR/"
if [ ! -x bin/x86_64-linux-cosmo-gcc ]; then
fetch https://github.com/ahgamut/superconfigure/releases/download/z0.0.53/aarch64-gcc.zip &
fetch https://github.com/ahgamut/superconfigure/releases/download/z0.0.53/x86_64-gcc.zip &
fetch https://github.com/ahgamut/superconfigure/releases/download/z0.0.53/llvm.zip &
fetch https://github.com/ahgamut/superconfigure/releases/download/z0.0.54/aarch64-gcc.zip &
fetch https://github.com/ahgamut/superconfigure/releases/download/z0.0.54/x86_64-gcc.zip &
fetch https://github.com/ahgamut/superconfigure/releases/download/z0.0.54/llvm.zip &
wait
unzip aarch64-gcc.zip &
unzip x86_64-gcc.zip &
unzip llvm.zip bin/clang-18 &
unzip llvm.zip bin/clang-19 &
wait
rm -f aarch64-gcc.zip
rm -f x86_64-gcc.zip
mv bin/clang-18 bin/cosmo-clang
rm -f llvm.zip
mv bin/clang-19 bin/cosmo-clang
fi
rm -f bin/*-cpp
rm -f bin/*-gcc-*