Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
* getopt changes
* removed some tbb call
* used the new demangle callsite
  • Loading branch information
fzakaria committed Jul 8, 2023
1 parent 1c942ae commit bf16a7d
Show file tree
Hide file tree
Showing 19 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion libc/sysv/consts/sig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions third_party/mold/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define MOLD_VERSION "1.11.0"
#define MOLD_LIBDIR "/usr/local/lib"
#define MOLD_IS_SOLD 0
3 changes: 2 additions & 1 deletion third_party/mold/demangle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "third_party/mold/common.h"

#include "third_party/libcxx/cstdlib"
#include "libc/stdio/stdio.h"

#ifndef _WIN32
// MISSING #include <cxxabi.h>
Expand Down Expand Up @@ -38,7 +39,7 @@ std::optional<std::string_view> 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;
Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/elf/cmdline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/elf/input-files.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/elf/jobs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/elf/lto-unix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/elf/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions third_party/mold/elf/mold-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/elf/mold.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions third_party/mold/elf/subprocess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down
11 changes: 6 additions & 5 deletions third_party/mold/main.cc
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions third_party/mold/mold.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/test/elf/absolute-symbols.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ cat <<EOF | $CC -o $t/b.o -c -fno-PIC -xc -
#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"
// MISSING #include <ucontext.h>
Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/test/elf/mold-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/test/elf/tls-alignment-multi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cat <<EOF | $CC -fPIC -c -o $t/a.o -xc -
#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"
Expand Down
2 changes: 1 addition & 1 deletion third_party/mold/test/elf/x86_64_preinit-array.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cat <<EOF | $CC -c -o $t/b.o -xc -
#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"
Expand Down
2 changes: 1 addition & 1 deletion third_party/xxhash/xxhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,7 @@ static void XXH_free(void* p) { (void)p; }
#include "libc/stdio/temp.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/exit.h"
#include "third_party/getopt/getopt.internal.h"
#include "third_party/getopt/long.h"
#include "third_party/musl/crypt.h"
#include "third_party/musl/rand48.h"

Expand Down

0 comments on commit bf16a7d

Please sign in to comment.