mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-08 10:50:28 +00:00
wip: removed tbb use
This commit is contained in:
parent
474350c602
commit
a5ab4fa2cb
7 changed files with 37 additions and 19 deletions
6
third_party/mold/README.cosmo
vendored
6
third_party/mold/README.cosmo
vendored
|
@ -16,3 +16,9 @@ SOURCE
|
||||||
Date: Mon Jun 19 12:35:20 2023 +0900
|
Date: Mon Jun 19 12:35:20 2023 +0900
|
||||||
|
|
||||||
Format
|
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
|
||||||
|
|
16
third_party/mold/common.h
vendored
16
third_party/mold/common.h
vendored
|
@ -10,6 +10,7 @@
|
||||||
#include "third_party/libcxx/cassert"
|
#include "third_party/libcxx/cassert"
|
||||||
#include "third_party/libcxx/cstdio"
|
#include "third_party/libcxx/cstdio"
|
||||||
#include "third_party/libcxx/cstring"
|
#include "third_party/libcxx/cstring"
|
||||||
|
#include "third_party/libcxx/unordered_map"
|
||||||
#include "libc/calls/calls.h"
|
#include "libc/calls/calls.h"
|
||||||
#include "libc/calls/struct/flock.h"
|
#include "libc/calls/struct/flock.h"
|
||||||
#include "libc/calls/weirdtypes.h"
|
#include "libc/calls/weirdtypes.h"
|
||||||
|
@ -44,8 +45,6 @@
|
||||||
#include "libc/intrin/newbie.h"
|
#include "libc/intrin/newbie.h"
|
||||||
#include "libc/sock/select.h"
|
#include "libc/sock/select.h"
|
||||||
#include "libc/sysv/consts/endian.h"
|
#include "libc/sysv/consts/endian.h"
|
||||||
// MISSING #include <tbb/concurrent_vector.h>
|
|
||||||
// MISSING #include <tbb/enumerable_thread_specific.h>
|
|
||||||
#include "third_party/libcxx/vector"
|
#include "third_party/libcxx/vector"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -758,21 +757,22 @@ private:
|
||||||
// Counter is used to collect statistics numbers.
|
// Counter is used to collect statistics numbers.
|
||||||
class Counter {
|
class Counter {
|
||||||
public:
|
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;
|
static std::mutex mu;
|
||||||
std::scoped_lock lock(mu);
|
std::scoped_lock lock(mu);
|
||||||
instances.push_back(this);
|
instances.push_back(this);
|
||||||
|
values[this] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter &operator++(int) {
|
Counter &operator++(int) {
|
||||||
if (enabled) [[unlikely]]
|
if (enabled) [[unlikely]]
|
||||||
values.local()++;
|
values[this]++;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter &operator+=(int delta) {
|
Counter &operator+=(int delta) {
|
||||||
if (enabled) [[unlikely]]
|
if (enabled) [[unlikely]]
|
||||||
values.local() += delta;
|
values[this] += delta;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -784,7 +784,7 @@ private:
|
||||||
i64 get_value();
|
i64 get_value();
|
||||||
|
|
||||||
std::string_view name;
|
std::string_view name;
|
||||||
tbb::enumerable_thread_specific<i64> values;
|
static thread_local std::unordered_map<Counter*, i64> values;
|
||||||
|
|
||||||
static inline std::vector<Counter *> instances;
|
static inline std::vector<Counter *> instances;
|
||||||
};
|
};
|
||||||
|
@ -797,7 +797,7 @@ struct TimerRecord {
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
TimerRecord *parent;
|
TimerRecord *parent;
|
||||||
tbb::concurrent_vector<TimerRecord *> children;
|
std::vector<TimerRecord *> children;
|
||||||
i64 start;
|
i64 start;
|
||||||
i64 end;
|
i64 end;
|
||||||
i64 user;
|
i64 user;
|
||||||
|
@ -806,7 +806,7 @@ struct TimerRecord {
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
print_timer_records(tbb::concurrent_vector<std::unique_ptr<TimerRecord>> &);
|
print_timer_records(std::vector<std::unique_ptr<TimerRecord>> &);
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
class Timer {
|
class Timer {
|
||||||
|
|
6
third_party/mold/compress.cc
vendored
6
third_party/mold/compress.cc
vendored
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
#include "third_party/mold/common.h"
|
#include "third_party/mold/common.h"
|
||||||
|
|
||||||
// MISSING #include <tbb/parallel_for_each.h>
|
#include "third_party/mold/fake_tbb.h"
|
||||||
// MISSING #include <zlib.h>
|
#include "third_party/zlib/zlib.h"
|
||||||
// MISSING #include <zstd.h>
|
#include "third_party/zstd/zstd.h"
|
||||||
|
|
||||||
#define CHECK(fn) \
|
#define CHECK(fn) \
|
||||||
do { \
|
do { \
|
||||||
|
|
6
third_party/mold/demangle.cc
vendored
6
third_party/mold/demangle.cc
vendored
|
@ -19,9 +19,9 @@ std::string_view demangle(std::string_view name) {
|
||||||
// Try to demangle as a Rust symbol. Since legacy-style Rust symbols
|
// 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
|
// are also valid as a C++ mangled name, we need to call this before
|
||||||
// cpp_demangle.
|
// cpp_demangle.
|
||||||
p = rust_demangle(std::string(name).c_str(), 0);
|
// p = rust_demangle(std::string(name).c_str(), 0);
|
||||||
if (p)
|
// if (p)
|
||||||
return p;
|
// return p;
|
||||||
|
|
||||||
// Try to demangle as a C++ symbol.
|
// Try to demangle as a C++ symbol.
|
||||||
if (std::optional<std::string_view> s = cpp_demangle(name))
|
if (std::optional<std::string_view> s = cpp_demangle(name))
|
||||||
|
|
4
third_party/mold/elf/input-sections.cc
vendored
4
third_party/mold/elf/input-sections.cc
vendored
|
@ -2,8 +2,8 @@
|
||||||
#include "third_party/mold/elf/mold.h"
|
#include "third_party/mold/elf/mold.h"
|
||||||
|
|
||||||
#include "third_party/libcxx/limits"
|
#include "third_party/libcxx/limits"
|
||||||
// MISSING #include <zlib.h>
|
#include "third_party/zlib/zlib.h"
|
||||||
// MISSING #include <zstd.h>
|
#include "third_party/zstd/zstd.h"
|
||||||
|
|
||||||
namespace mold::elf {
|
namespace mold::elf {
|
||||||
|
|
||||||
|
|
8
third_party/mold/fake_tbb.h
vendored
8
third_party/mold/fake_tbb.h
vendored
|
@ -11,5 +11,13 @@ namespace tbb {
|
||||||
void parallel_for_each(Range& rng, const Body& body) {
|
void parallel_for_each(Range& rng, const Body& body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Range, typename Body>
|
||||||
|
void parallel_for( const Range& range, const Body& body ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Index, typename Function>
|
||||||
|
void parallel_for(Index first, Index last, const Function& f) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
10
third_party/mold/mold.mk
vendored
10
third_party/mold/mold.mk
vendored
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
PKGS += THIRD_PARTY_MOLD
|
PKGS += THIRD_PARTY_MOLD
|
||||||
|
|
||||||
private CPPFLAGS += -std=c++20
|
|
||||||
|
|
||||||
THIRD_PARTY_MOLD_ARTIFACTS += THIRD_PARTY_MOLD_A
|
THIRD_PARTY_MOLD_ARTIFACTS += THIRD_PARTY_MOLD_A
|
||||||
THIRD_PARTY_MOLD = $(THIRD_PARTY_MOLD_A_DEPS) $(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
|
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_MOLD_A_DIRECTDEPS = \
|
||||||
THIRD_PARTY_LIBCXX \
|
THIRD_PARTY_LIBCXX \
|
||||||
THIRD_PARTY_XXHASH
|
THIRD_PARTY_ZSTD \
|
||||||
|
THIRD_PARTY_XXHASH \
|
||||||
|
THIRD_PARTY_ZLIB
|
||||||
|
|
||||||
THIRD_PARTY_MOLD_A_DEPS := \
|
THIRD_PARTY_MOLD_A_DEPS := \
|
||||||
$(call uniq,$(foreach x,$(THIRD_PARTY_MOLD_A_DIRECTDEPS),$($(x))))
|
$(call uniq,$(foreach x,$(THIRD_PARTY_MOLD_A_DIRECTDEPS),$($(x))))
|
||||||
|
@ -43,6 +43,10 @@ $(THIRD_PARTY_MOLD_A).pkg: \
|
||||||
$(THIRD_PARTY_MOLD_OBJS) \
|
$(THIRD_PARTY_MOLD_OBJS) \
|
||||||
$(foreach x,$(THIRD_PARTY_MOLD_A_DIRECTDEPS),$($(x)_A).pkg)
|
$(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: \
|
o/$(MODE)/third_party/mold/mold.com.dbg: \
|
||||||
$(THIRD_PARTY_MOLD) \
|
$(THIRD_PARTY_MOLD) \
|
||||||
o/$(MODE)/third_party/awk/main.o \
|
o/$(MODE)/third_party/awk/main.o \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue