From 640d1aec04ce1e9aa20be643a777856d03260eb6 Mon Sep 17 00:00:00 2001 From: Farid Zakaria Date: Sat, 8 Jul 2023 02:15:36 +0000 Subject: [PATCH] various fixes * getopt changes * removed some tbb call * used the new demangle callsite --- libc/sysv/consts/sig.h | 2 +- third_party/mold/common.h | 2 +- third_party/mold/config.h | 3 +++ third_party/mold/demangle.cc | 3 ++- third_party/mold/elf/cmdline.cc | 2 +- third_party/mold/elf/input-files.cc | 2 +- third_party/mold/elf/jobs.cc | 2 +- third_party/mold/elf/lto-unix.cc | 2 +- third_party/mold/elf/main.cc | 2 +- third_party/mold/elf/mold-wrapper.c | 4 ++-- third_party/mold/elf/mold.h | 2 +- third_party/mold/elf/subprocess.cc | 4 ++-- third_party/mold/main.cc | 11 ++++++----- third_party/mold/mold.mk | 2 ++ third_party/mold/test/elf/absolute-symbols.sh | 2 +- third_party/mold/test/elf/mold-wrapper.sh | 2 +- third_party/mold/test/elf/tls-alignment-multi.sh | 2 +- third_party/mold/test/elf/x86_64_preinit-array.sh | 2 +- third_party/xxhash/xxhash.h | 2 +- 19 files changed, 30 insertions(+), 23 deletions(-) create mode 100644 third_party/mold/config.h diff --git a/libc/sysv/consts/sig.h b/libc/sysv/consts/sig.h index 4ee3146b5..451588ccf 100644 --- a/libc/sysv/consts/sig.h +++ b/libc/sysv/consts/sig.h @@ -70,8 +70,8 @@ COSMOPOLITAN_C_END_ #define SIGWINCH 28 #define SIGXCPU 24 #define SIGXFSZ 25 +#define SIGBUS 7 -#define SIGBUS SIGBUS #define SIGTHR SIGTHR #define SIGCHLD SIGCHLD #define SIGCONT SIGCONT diff --git a/third_party/mold/common.h b/third_party/mold/common.h index 2c14b14bb..09fd5da7b 100644 --- a/third_party/mold/common.h +++ b/third_party/mold/common.h @@ -71,7 +71,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "libc/isystem/getopt.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" #endif diff --git a/third_party/mold/config.h b/third_party/mold/config.h new file mode 100644 index 000000000..8f99876c9 --- /dev/null +++ b/third_party/mold/config.h @@ -0,0 +1,3 @@ +#define MOLD_VERSION "1.11.0" +#define MOLD_LIBDIR "/usr/local/lib" +#define MOLD_IS_SOLD 0 \ No newline at end of file diff --git a/third_party/mold/demangle.cc b/third_party/mold/demangle.cc index c99835484..65aa37e6f 100644 --- a/third_party/mold/demangle.cc +++ b/third_party/mold/demangle.cc @@ -2,6 +2,7 @@ #include "third_party/mold/common.h" #include "third_party/libcxx/cstdlib" +#include "libc/stdio/stdio.h" #ifndef _WIN32 // MISSING #include @@ -38,7 +39,7 @@ std::optional cpp_demangle(std::string_view name) { #ifndef _WIN32 if (name.starts_with("_Z")) { int status; - char *p = abi::__cxa_demangle(std::string(name).c_str(), buf, &buflen, &status); + char *p = __cxa_demangle(std::string(name).c_str(), buf, &buflen, &status); if (status == 0) { buf = p; return p; diff --git a/third_party/mold/elf/cmdline.cc b/third_party/mold/elf/cmdline.cc index 685f41469..af1bc12dc 100644 --- a/third_party/mold/elf/cmdline.cc +++ b/third_party/mold/elf/cmdline.cc @@ -36,7 +36,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" #endif diff --git a/third_party/mold/elf/input-files.cc b/third_party/mold/elf/input-files.cc index 5638cee4d..61906ebce 100644 --- a/third_party/mold/elf/input-files.cc +++ b/third_party/mold/elf/input-files.cc @@ -16,7 +16,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" #endif diff --git a/third_party/mold/elf/jobs.cc b/third_party/mold/elf/jobs.cc index 451419c8f..1e8757deb 100644 --- a/third_party/mold/elf/jobs.cc +++ b/third_party/mold/elf/jobs.cc @@ -39,7 +39,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" #endif diff --git a/third_party/mold/elf/lto-unix.cc b/third_party/mold/elf/lto-unix.cc index eec570251..7b68a397a 100644 --- a/third_party/mold/elf/lto-unix.cc +++ b/third_party/mold/elf/lto-unix.cc @@ -107,7 +107,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" diff --git a/third_party/mold/elf/main.cc b/third_party/mold/elf/main.cc index d8d512ab5..645be0d50 100644 --- a/third_party/mold/elf/main.cc +++ b/third_party/mold/elf/main.cc @@ -50,7 +50,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" #endif diff --git a/third_party/mold/elf/mold-wrapper.c b/third_party/mold/elf/mold-wrapper.c index db3df5306..6d3ebd8e3 100644 --- a/third_party/mold/elf/mold-wrapper.c +++ b/third_party/mold/elf/mold-wrapper.c @@ -29,7 +29,7 @@ #include "libc/stdio/temp.h" #include "libc/str/str.h" #include "libc/sysv/consts/exit.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/rand48.h" #include "libc/mem/alg.h" @@ -45,7 +45,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" diff --git a/third_party/mold/elf/mold.h b/third_party/mold/elf/mold.h index 07ee9dc31..a67c239ac 100644 --- a/third_party/mold/elf/mold.h +++ b/third_party/mold/elf/mold.h @@ -42,7 +42,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" #endif diff --git a/third_party/mold/elf/subprocess.cc b/third_party/mold/elf/subprocess.cc index 3892bea5c..fedc9c45c 100644 --- a/third_party/mold/elf/subprocess.cc +++ b/third_party/mold/elf/subprocess.cc @@ -2,7 +2,7 @@ #if !defined(_WIN32) && !defined(__APPLE__) #include "third_party/mold/elf/mold.h" -// MISSING #include "config.h" +#include "third_party/mold/config.h" #include "third_party/libcxx/filesystem" #include "libc/calls/calls.h" @@ -51,7 +51,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" diff --git a/third_party/mold/main.cc b/third_party/mold/main.cc index 0012c58b5..73c4aa5a8 100644 --- a/third_party/mold/main.cc +++ b/third_party/mold/main.cc @@ -1,6 +1,6 @@ // clang-format off #include "third_party/mold/common.h" -// MISSING #include "config.h" +#include "third_party/mold/config.h" #include "third_party/libcxx/cstring" #include "third_party/libcxx/filesystem" @@ -29,7 +29,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" #endif @@ -167,10 +167,11 @@ void install_signal_handler() { #endif i64 get_default_thread_count() { + // TODO(fzakaria): disable tbb callsites // mold doesn't scale well above 32 threads. - int n = tbb::global_control::active_value( - tbb::global_control::max_allowed_parallelism); - return std::min(n, 32); + // int n = tbb::global_control::active_value( + // tbb::global_control::max_allowed_parallelism); + return 1; } } // namespace mold diff --git a/third_party/mold/mold.mk b/third_party/mold/mold.mk index 68eaa4320..a29cadb58 100644 --- a/third_party/mold/mold.mk +++ b/third_party/mold/mold.mk @@ -15,12 +15,14 @@ THIRD_PARTY_MOLD_A_DIRECTDEPS = \ THIRD_PARTY_LIBCXX \ THIRD_PARTY_ZSTD \ THIRD_PARTY_XXHASH \ + THIRD_PARTY_GETOPT \ THIRD_PARTY_ZLIB THIRD_PARTY_MOLD_A_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_MOLD_A_DIRECTDEPS),$($(x)))) # https://github.com/rui314/mold/blob/d4d93d7fb72dd19c44aafa4dd5397e35787d33ad/CMakeLists.txt#L62 +# TODO(fzakaria): figure out solution for -Wno-error=class-memaccess $(THIRD_PARTY_MOLD_OBJS): private \ CPPFLAGS += \ -std=gnu++20 \ diff --git a/third_party/mold/test/elf/absolute-symbols.sh b/third_party/mold/test/elf/absolute-symbols.sh index 60ada3ec6..a2ee30a90 100755 --- a/third_party/mold/test/elf/absolute-symbols.sh +++ b/third_party/mold/test/elf/absolute-symbols.sh @@ -41,7 +41,7 @@ cat < diff --git a/third_party/mold/test/elf/mold-wrapper.sh b/third_party/mold/test/elf/mold-wrapper.sh index c1cbd65fe..788097580 100755 --- a/third_party/mold/test/elf/mold-wrapper.sh +++ b/third_party/mold/test/elf/mold-wrapper.sh @@ -39,7 +39,7 @@ cat <<'EOF' | $CC -xc -o $t/exe - #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/time/time.h" -#include "third_party/getopt/getopt.h" +#include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" diff --git a/third_party/mold/test/elf/tls-alignment-multi.sh b/third_party/mold/test/elf/tls-alignment-multi.sh index 58cf8bd7b..8a280f504 100755 --- a/third_party/mold/test/elf/tls-alignment-multi.sh +++ b/third_party/mold/test/elf/tls-alignment-multi.sh @@ -24,7 +24,7 @@ cat <