mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 03:08:31 +00:00
Introduce new fatcosmocc command
This new script is an alternative to the `cosmocc` command. It's still a work in progress. It abstracts all the gory details of building separate copies of your executable and then running the apelink.com program.
This commit is contained in:
parent
8fc778162e
commit
d53c335a45
35 changed files with 1151 additions and 525 deletions
56
tool/scripts/fat-x86_64
Executable file
56
tool/scripts/fat-x86_64
Executable file
|
@ -0,0 +1,56 @@
|
|||
#!/bin/sh
|
||||
# amd64 backend compiler for fatcosmocc
|
||||
|
||||
CC="$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc"
|
||||
CCFLAGS="-mno-tls-direct-seg-refs -mno-red-zone"
|
||||
LDFLAGS="-static -nostdlib -no-pie -Wl,-melf_x86_64"
|
||||
APEFLAGS="-L$COSMOS/lib -Wl,--gc-sections -Wl,-T,$COSMO/o/$MODE/ape/public/ape.lds $COSMO/o/$MODE/ape/ape.o $COSMO/o/$MODE/libc/crt/crt.o"
|
||||
LDLIBS="$COSMO/o/$MODE/cosmopolitan.a"
|
||||
|
||||
if [ x"$PROG" != x"${PROG%++}" ]; then
|
||||
CC="$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-g++"
|
||||
CCFLAGS="$CCFLAGS -fno-rtti -fno-exceptions -fuse-cxa-atexit -fno-threadsafe-statics"
|
||||
LDLIBS="$COSMO/o/$MODE/third_party/libcxx/libcxx.a $LDLIBS"
|
||||
fi
|
||||
|
||||
OPT=
|
||||
FIRST=1
|
||||
OUTPUT=
|
||||
INTENT=ld
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
fi
|
||||
if [ x"$x" != x"${x#-O}" ]; then
|
||||
OPT=$x
|
||||
elif [ x"$x" = x"-c" ]; then
|
||||
INTENT=cc
|
||||
elif [ x"$x" != x"${x#-o}" ]; then
|
||||
OUTPUT=${x#-o}
|
||||
elif [ x"$x" = x"-march=native" ]; then
|
||||
continue # doesn't make sense for a cross compiler
|
||||
fi
|
||||
set -- "$@" "$x"
|
||||
done
|
||||
|
||||
if [ x"$MODE" = x"nox87" ]; then
|
||||
CCFLAGS="$CCFLAGS -mlong-double-64"
|
||||
fi
|
||||
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"${MODE#tiny}" != x"${MODE}" ]; then
|
||||
# support --ftrace unless optimizing for size
|
||||
CCFLAGS="$CCFLAGS -fpatchable-function-entry=18,16"
|
||||
fi
|
||||
|
||||
if [ $INTENT = cc ]; then
|
||||
set -- "$CC" $CCFLAGS "$@"
|
||||
else
|
||||
set -- "$CC" $CCFLAGS $LDFLAGS $APEFLAGS $CPPFLAGS "$@" \
|
||||
$LDLIBS -Wl,-z,common-page-size=4096 -Wl,-z,max-page-size=4096 \
|
||||
-fuse-ld=bfd
|
||||
fi
|
||||
|
||||
printf '# %s\n(cd %s; %s)\n' "$ORIGINAL" "$PWD" "$*" >>"${TMPDIR:-/tmp}/build.log"
|
||||
"$@" || exit
|
||||
"$FIXUPOBJ" "$OUTPUT" || exit
|
Loading…
Add table
Add a link
Reference in a new issue