mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Further improve fatcosmocc
This commit is contained in:
parent
3f2f0e3a74
commit
ab9a284640
39 changed files with 96 additions and 28 deletions
|
@ -273,6 +273,7 @@ SECTIONS {
|
|||
*(.gnu.lto_*)
|
||||
*(.eh_frame)
|
||||
*(.idata.*)
|
||||
*(.yoink)
|
||||
*(.head)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 "$@"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
│ See the License for the specific language governing permissions and │
|
||||
│ limitations under the License. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/errno.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ASSERT_H_
|
||||
#define COSMOPOLITAN_LIBC_ASSERT_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
#ifdef _ASSERT_H
|
||||
#undef _ASSERT_H
|
||||
#undef assert
|
||||
#ifdef COSMO
|
||||
#undef unassert
|
||||
#undef npassert
|
||||
#ifndef NDEBUG
|
||||
#undef __assert_macro
|
||||
#endif /* NDEBUG */
|
||||
#endif /* COSMO */
|
||||
#endif /* _ASSERT_H */
|
||||
|
||||
#ifndef _ASSERT_H
|
||||
#define _ASSERT_H
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void __assert_fail(const char *, const char *, int) relegated;
|
||||
|
@ -11,7 +22,8 @@ void __assert_fail(const char *, const char *, int) relegated;
|
|||
#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__), 0)))
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
|
||||
#undef static_assert
|
||||
#define static_assert _Static_assert
|
||||
#endif
|
||||
|
||||
|
@ -47,5 +59,4 @@ extern bool __assert_disable;
|
|||
#endif /* COSMO */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_ASSERT_H_ */
|
||||
#endif /* _ASSERT_H */
|
||||
|
|
|
@ -660,6 +660,8 @@ extern const errno_t EXFULL;
|
|||
|
||||
extern errno_t __errno;
|
||||
errno_t *__errno_location(void) dontthrow pureconst;
|
||||
extern char *program_invocation_short_name;
|
||||
extern char *program_invocation_name;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
__attribute__((__weak__)) void __stack_chk_fail(void) {
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
#ifndef _ASSERT_H
|
||||
#define _ASSERT_H
|
||||
#include "libc/assert.h"
|
||||
#endif /* _ASSERT_H */
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/tls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "third_party/lua/lunix.h"
|
||||
#ifndef __x86_64__
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ typedef unsigned long jmp_buf[26];
|
|||
typedef long sigjmp_buf[12];
|
||||
|
||||
extern char **environ;
|
||||
extern char *program_invocation_name;
|
||||
extern char *program_invocation_short_name;
|
||||
|
||||
void mcount(void);
|
||||
int daemon(int, int);
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,5 +22,6 @@ COSMOPOLITAN_C_END_
|
|||
#define AT_SYMLINK_FOLLOW AT_SYMLINK_FOLLOW
|
||||
#define AT_SYMLINK_NOFOLLOW AT_SYMLINK_NOFOLLOW
|
||||
#define AT_REMOVEDIR AT_REMOVEDIR
|
||||
#define AT_EACCESS AT_EACCESS
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_AT_H_ */
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/cpuset.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/popcnt.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
|
|
|
@ -133,4 +133,9 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/cxaatexit.internal.h"
|
||||
|
|
1
third_party/getopt/getopt.c
vendored
1
third_party/getopt/getopt.c
vendored
|
@ -34,6 +34,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/errno.h"
|
||||
#include "third_party/getopt/getopt.internal.h"
|
||||
|
||||
asm(".ident\t\"\\n\
|
||||
|
|
1
third_party/make/getprogname.c
vendored
1
third_party/make/getprogname.c
vendored
|
@ -18,6 +18,7 @@
|
|||
#include "third_party/make/config.h"
|
||||
#include "third_party/make/getprogname.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "third_party/make/dirname.h"
|
||||
|
||||
char const *
|
||||
|
|
1
third_party/mbedtls/test/lib.c
vendored
1
third_party/mbedtls/test/lib.c
vendored
|
@ -17,6 +17,7 @@
|
|||
#include "third_party/mbedtls/test/lib.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
|
|
1
third_party/sed/main.c
vendored
1
third_party/sed/main.c
vendored
|
@ -34,6 +34,7 @@
|
|||
*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/fmt/libgen.h"
|
||||
#include "libc/log/bsd.h"
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "third_party/getopt/getopt.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "third_party/regex/regex.h"
|
||||
|
||||
#define VERSION \
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/errno.h"
|
||||
#include "third_party/getopt/getopt.internal.h"
|
||||
|
||||
#define USAGE \
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "libc/stdio/rand.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "libc/zip.internal.h"
|
||||
#include "third_party/getopt/getopt.internal.h"
|
||||
#include "tool/build/lib/elfwriter.h"
|
||||
#include "libc/errno.h"
|
||||
#include "tool/build/lib/stripcomponents.h"
|
||||
|
||||
char *name_;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/log/check.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/log/check.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -42,7 +42,8 @@ for x; do
|
|||
set -- "$@" "$x"
|
||||
done
|
||||
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"${MODE#aarch64-tiny}" != x"${MODE}" ]; then
|
||||
if [ x"$OPT" != x"-Os" ] && # $OPT != -Os
|
||||
[ x"${MODE%tiny}" = x"${MODE}" ]; then # $MODE not in (tiny, aarch64-tiny)
|
||||
# support --ftrace unless optimizing for size
|
||||
CCFLAGS="$CCFLAGS -fpatchable-function-entry=7,6"
|
||||
fi
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
CC="$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc"
|
||||
CFLAGS="-mno-tls-direct-seg-refs -mno-red-zone"
|
||||
LDFLAGS="-static -nostdlib -no-pie -Wl,-melf_x86_64 -Wl,-z,common-page-size=4096 -Wl,-z,max-page-size=4096 -fuse-ld=bfd"
|
||||
APEFLAGS="-L$COSMOS/lib -Wl,--gc-sections -Wl,-T,$COSMO/o/$MODE/ape/public/ape.lds $COSMO/o/$MODE/ape/ape.o"
|
||||
APEFLAGS="-L$COSMOS/lib -Wl,--gc-sections -Wl,-T,$COSMO/o/$MODE/ape/public/ape.lds"
|
||||
LDLIBS="$COSMO/o/$MODE/cosmopolitan.a"
|
||||
|
||||
if [ x"$PROG" != x"${PROG%++}" ]; then
|
||||
|
@ -44,7 +44,8 @@ if [ x"$MODE" = x"nox87" ]; then
|
|||
CFLAGS="$CFLAGS -mlong-double-64"
|
||||
fi
|
||||
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"${MODE#tiny}" != x"${MODE}" ]; then
|
||||
if [ x"$OPT" != x"-Os" ] && # $OPT != -Os
|
||||
[ x"${MODE%tiny}" = x"${MODE}" ]; then # $MODE not in (tiny, aarch64-tiny)
|
||||
# support --ftrace unless optimizing for size
|
||||
CFLAGS="$CFLAGS -fpatchable-function-entry=18,16"
|
||||
fi
|
||||
|
@ -57,6 +58,7 @@ if [ $INTENT = cc ]; then
|
|||
else
|
||||
set -- \
|
||||
"$CC" \
|
||||
"$COSMO/o/$MODE/ape/ape.o" \
|
||||
"$COSMO/o/$MODE/libc/crt/crt.o" \
|
||||
"$@" \
|
||||
$LDFLAGS \
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
|
|
@ -335,4 +335,9 @@ int main(int argc, char *argv[]) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -616,4 +616,9 @@ int main(int argc, char *argv[]) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/check.h"
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "libc/calls/struct/winsize.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "libc/calls/struct/winsize.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
|
Loading…
Reference in a new issue