Add preliminary support for cosmocc -mclang

C++ code compiles very slowly with cosmocc, possibly because we're using
LLVM LIBCXX with GCC, and LLVM doesn't work as hard to make GCC go fast.
Therefore, it should be possible, to ask cosmocc to favor Clang over GCC
under the hood. On llamafile, my intention's to use this to make certain
files, e.g. llama.cpp/common.cpp, go from taking 17 seconds to 5 seconds

This new -mclang flag isn't ready for production yet since there's still
the question of how to get Clang to generate SJLJ exception code. If you
use this, then it's recommended you also pass -fno-exceptions.

The tradeoff is we're adding a 121mb binary to the cosmocc distribution.
There are no plans as of yet to fully migrate to Clang since GCC is very
good and has always treated us well.
This commit is contained in:
Justine Tunney 2024-08-26 12:29:59 -07:00
parent 111ec9a989
commit e7b586e7f8
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
6 changed files with 42 additions and 16 deletions

View file

@ -182,12 +182,17 @@ fetch() {
OLD=$PWD
cd "$OUTDIR/"
if [ ! -x bin/x86_64-linux-cosmo-gcc ]; then
fetch https://github.com/ahgamut/superconfigure/releases/download/z0.0.52/aarch64-gcc.zip
unzip aarch64-gcc.zip
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 &
wait
unzip aarch64-gcc.zip &
unzip x86_64-gcc.zip &
unzip llvm.zip bin/clang-18 &
wait
rm -f aarch64-gcc.zip
fetch https://github.com/ahgamut/superconfigure/releases/download/z0.0.52/x86_64-gcc.zip
unzip x86_64-gcc.zip
rm -f x86_64-gcc.zip
mv bin/clang-18 bin/cosmo-clang
fi
rm -f bin/*-cpp
rm -f bin/*-gcc-*