Further improve fatcosmocc

This commit is contained in:
Justine Tunney 2023-08-13 01:44:39 -07:00
parent 3f2f0e3a74
commit ab9a284640
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
39 changed files with 96 additions and 28 deletions

View file

@ -235,7 +235,7 @@ for x; do
elif [ x"$x" = x"-" ] || # is alias for stdin
[ x"$x" = x"${x#-*}" ]; then # !startswith(x, "-")
if [ x"$x" != x"${x%.s}" ] ||
[ x"$x" != x"${x%.S}" ]; then
[ x"$x" != x"${x%.S}" ]; then
fatal_error "$x: assembler input files not supported"
elif [ x"$x" != x"${x%.so}" ] ||
[ x"$x" != x"${x%.dll}" ] ||
@ -466,9 +466,10 @@ for x in $ARGS; do
OUTPUT_AARCH64="$mangled_path"
build_object $FLAGS -c "$x"
else
# e.g. `cc -c foo.c` builds foo.o
OUTPUT_X86_64="${x%.*}.o"
mangle_object_path "${x%.*}.o" aarch64
# e.g. `cc -c dir/foo.c` builds foo.o
o=${x##*/}
OUTPUT_X86_64="${o%.*}.o"
mangle_object_path "${o%.*}.o" aarch64
OUTPUT_AARCH64="$mangled_path"
build_object $FLAGS -c "$x"
fi

View file

@ -1,5 +1,22 @@
#!/bin/sh
# the `install -s` strip flag provided by gnu coreutils surprisngly
# enough understands the portable executable format however it will
# silently corrupt any actually portable executable it touches, due
# to how it overwrites the whole mz header and removes the dos stub
FIRST=1
for x; do
if [ $FIRST -eq 1 ]; then
set --
FIRST=0
fi
if [ x"$x" = x"-s" ]; then
continue
fi
set -- "$@" "$x"
done
# now magically copy multi-architecture build artifacts
if [ $# -gt 1 ]; then
# parse `install [$flags]... $src $dst`
@ -11,7 +28,7 @@ if [ $# -gt 1 ]; then
for x; do
if [ x"$x" != x"${x#* }" ]; then
# give up if any arguments contain spaces
exec /usr/bin/install "$@"
exec install "$@"
fi
src=$dst
dst=$x
@ -48,8 +65,8 @@ if [ $# -gt 1 ]; then
if [ ! -d "$dstdir.$arch" ]; then
mkdir -p "$dstdir.$arch" || exit
fi
/usr/bin/install $flags $src $dst || exit
exec /usr/bin/install $flags \
install $flags $src $dst || exit
exec install $flags \
"$srcdir.$arch/$srcbas" \
"$dstdir.$arch/$dstbas"
fi
@ -73,13 +90,11 @@ if [ $# -gt 1 ]; then
if [ ! -d "$dst/.$arch" ]; then
mkdir -p "$dst/.$arch" || exit
fi
/usr/bin/install $flags $src $dst || exit
exec /usr/bin/install $flags \
"$srcdir.$arch/$srcbas" \
"$dst/.$arch"
install $flags $src $dst || exit
exec install $flags "$srcdir.$arch/$srcbas" "$dst/.$arch"
fi
fi
fi
exec /usr/bin/install "$@"
exec install "$@"