diff --git a/third_party/mold/README.cosmo b/third_party/mold/README.cosmo index 7694651d6be2..605a7e10d99f 100644 --- a/third_party/mold/README.cosmo +++ b/third_party/mold/README.cosmo @@ -16,3 +16,9 @@ SOURCE Date: Mon Jun 19 12:35:20 2023 +0900 Format + +CHANGES + * removed tbb by including a fake implementation + * made the parallel_for effectively single-threaded + * changed tbb:enumerable_thread_specific to thread_local + * removed rust demangle support diff --git a/third_party/mold/common.h b/third_party/mold/common.h index f8ef1300e370..2c14b14bbc45 100644 --- a/third_party/mold/common.h +++ b/third_party/mold/common.h @@ -10,6 +10,7 @@ #include "third_party/libcxx/cassert" #include "third_party/libcxx/cstdio" #include "third_party/libcxx/cstring" +#include "third_party/libcxx/unordered_map" #include "libc/calls/calls.h" #include "libc/calls/struct/flock.h" #include "libc/calls/weirdtypes.h" @@ -44,8 +45,6 @@ #include "libc/intrin/newbie.h" #include "libc/sock/select.h" #include "libc/sysv/consts/endian.h" -// MISSING #include -// MISSING #include #include "third_party/libcxx/vector" #ifdef _WIN32 @@ -758,21 +757,22 @@ class ZstdCompressor : public Compressor { // Counter is used to collect statistics numbers. class Counter { public: - Counter(std::string_view name, i64 value = 0) : name(name), values(value) { + Counter(std::string_view name, i64 value = 0) : name(name) { static std::mutex mu; std::scoped_lock lock(mu); instances.push_back(this); + values[this] = value; } Counter &operator++(int) { if (enabled) [[unlikely]] - values.local()++; + values[this]++; return *this; } Counter &operator+=(int delta) { if (enabled) [[unlikely]] - values.local() += delta; + values[this] += delta; return *this; } @@ -784,7 +784,7 @@ class Counter { i64 get_value(); std::string_view name; - tbb::enumerable_thread_specific values; + static thread_local std::unordered_map values; static inline std::vector instances; }; @@ -797,7 +797,7 @@ struct TimerRecord { std::string name; TimerRecord *parent; - tbb::concurrent_vector children; + std::vector children; i64 start; i64 end; i64 user; @@ -806,7 +806,7 @@ struct TimerRecord { }; void -print_timer_records(tbb::concurrent_vector> &); +print_timer_records(std::vector> &); template class Timer { diff --git a/third_party/mold/compress.cc b/third_party/mold/compress.cc index 32cc7ba3986f..b2d8f07aa2a1 100644 --- a/third_party/mold/compress.cc +++ b/third_party/mold/compress.cc @@ -17,9 +17,9 @@ #include "third_party/mold/common.h" -// MISSING #include -// MISSING #include -// MISSING #include +#include "third_party/mold/fake_tbb.h" +#include "third_party/zlib/zlib.h" +#include "third_party/zstd/zstd.h" #define CHECK(fn) \ do { \ diff --git a/third_party/mold/demangle.cc b/third_party/mold/demangle.cc index e4e478b36990..c99835484128 100644 --- a/third_party/mold/demangle.cc +++ b/third_party/mold/demangle.cc @@ -19,9 +19,9 @@ std::string_view demangle(std::string_view name) { // Try to demangle as a Rust symbol. Since legacy-style Rust symbols // are also valid as a C++ mangled name, we need to call this before // cpp_demangle. - p = rust_demangle(std::string(name).c_str(), 0); - if (p) - return p; + // p = rust_demangle(std::string(name).c_str(), 0); + // if (p) + // return p; // Try to demangle as a C++ symbol. if (std::optional s = cpp_demangle(name)) diff --git a/third_party/mold/elf/input-sections.cc b/third_party/mold/elf/input-sections.cc index 2446c2d61002..55f3ab35a545 100644 --- a/third_party/mold/elf/input-sections.cc +++ b/third_party/mold/elf/input-sections.cc @@ -2,8 +2,8 @@ #include "third_party/mold/elf/mold.h" #include "third_party/libcxx/limits" -// MISSING #include -// MISSING #include +#include "third_party/zlib/zlib.h" +#include "third_party/zstd/zstd.h" namespace mold::elf { diff --git a/third_party/mold/fake_tbb.h b/third_party/mold/fake_tbb.h index 63bfc2b2b6c9..008966707c26 100644 --- a/third_party/mold/fake_tbb.h +++ b/third_party/mold/fake_tbb.h @@ -11,5 +11,13 @@ namespace tbb { void parallel_for_each(Range& rng, const Body& body) { } + template + void parallel_for( const Range& range, const Body& body ) { + } + + template + void parallel_for(Index first, Index last, const Function& f) { + } + } #endif diff --git a/third_party/mold/mold.mk b/third_party/mold/mold.mk index e109116a7220..68eaa4320978 100644 --- a/third_party/mold/mold.mk +++ b/third_party/mold/mold.mk @@ -3,8 +3,6 @@ PKGS += THIRD_PARTY_MOLD -private CPPFLAGS += -std=c++20 - THIRD_PARTY_MOLD_ARTIFACTS += THIRD_PARTY_MOLD_A THIRD_PARTY_MOLD = $(THIRD_PARTY_MOLD_A_DEPS) $(THIRD_PARTY_MOLD_A) THIRD_PARTY_MOLD_A = o/$(MODE)/third_party/mold/mold.a @@ -15,7 +13,9 @@ THIRD_PARTY_MOLD_OBJS = $(THIRD_PARTY_MOLD_SRCS:%.cc=o/$(MODE)/%.o) THIRD_PARTY_MOLD_A_DIRECTDEPS = \ THIRD_PARTY_LIBCXX \ - THIRD_PARTY_XXHASH + THIRD_PARTY_ZSTD \ + THIRD_PARTY_XXHASH \ + THIRD_PARTY_ZLIB THIRD_PARTY_MOLD_A_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_MOLD_A_DIRECTDEPS),$($(x)))) @@ -43,6 +43,10 @@ $(THIRD_PARTY_MOLD_A).pkg: \ $(THIRD_PARTY_MOLD_OBJS) \ $(foreach x,$(THIRD_PARTY_MOLD_A_DIRECTDEPS),$($(x)_A).pkg) +$(THIRD_PARTY_MOLD_A_OBJS): private \ + CPPFLAGS += \ + -std=c++20 + o/$(MODE)/third_party/mold/mold.com.dbg: \ $(THIRD_PARTY_MOLD) \ o/$(MODE)/third_party/awk/main.o \