diff --git a/libc/sysv/consts/sig.h b/libc/sysv/consts/sig.h index 4ee3146b5852..451588ccf814 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 2c14b14bbc45..09fd5da7bddd 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 000000000000..8f99876c9f8a --- /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 c99835484128..65aa37e6ffcb 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 685f41469e29..af1bc12dcba9 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 5638cee4d52a..61906ebce1d1 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 451419c8ff50..1e8757deb1a2 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 eec570251b6f..7b68a397abb4 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 d8d512ab53c3..645be0d50b63 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 db3df53063bf..6d3ebd8e3729 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 07ee9dc315de..a67c239ac53d 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 3892bea5cde6..fedc9c45ca47 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 0012c58b5e03..73c4aa5a8815 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 68eaa4320978..a29cadb58db2 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 60ada3ec6973..a2ee30a90a3b 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 c1cbd65fe002..788097580afc 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 58cf8bd7b389..8a280f5046e3 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 <