Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ build --cxxopt='-stdlib=libc++' --host_cxxopt='-stdlib=libc++'
build --linkopt='-stdlib=libc++' --host_linkopt='-stdlib=libc++'

build --action_env=BAZEL_COMPILER=clang
build --action_env=CC=/usr/lib/llvm-15/bin/clang
build --action_env=CXX=/usr/lib/llvm-15/bin/clang++
build --action_env=CC=clang
build --action_env=CXX=clang++

build --@capnp-cpp//src/kj:openssl=True --@capnp-cpp//src/kj:zlib=True --@capnp-cpp//src/kj:libdl=True

Expand All @@ -15,12 +15,10 @@ build --cxxopt='-Wextra' --host_cxxopt='-Wextra'
build --cxxopt='-Wno-strict-aliasing' --host_cxxopt='-Wno-strict-aliasing'
build --cxxopt='-Wno-sign-compare' --host_cxxopt='-Wno-sign-compare'
build --cxxopt='-Wno-unused-parameter' --host_cxxopt='-Wno-unused-parameter'
build --cxxopt='-Wno-deprecated-experimental-coroutine' --host_cxxopt='-Wno-deprecated-experimental-coroutine'
build --cxxopt='-Wno-missing-field-initializers' --host_cxxopt='-Wno-missing-field-initializers'
build --cxxopt='-Wno-ignored-qualifiers' --host_cxxopt='-Wno-ignored-qualifiers'

# Our dependencies (ICU, zlib, etc.) produce a lot of these warnings, so we disable them.
# TODO(cleanup): Can we disable warnings altogether from our dependencies, without disabling them
# for workerd?
build --cxxopt='-Wno-ambiguous-reversed-operator' --host_cxxopt='-Wno-ambiguous-reversed-operator'
build --copt='-Wno-deprecated-non-prototype' --host_copt='-Wno-deprecated-non-prototype'
12 changes: 5 additions & 7 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
load("//:build/wd_cc_embed.bzl", "wd_cc_embed")
load("@capnp-cpp//src/capnp:cc_capnp_library.bzl", "cc_capnp_library")

wd_cc_embed(
cc_capnp_library(
name = "icudata-embed",
base_name = "icudata-embed",
srcs = ["icudata-embed.capnp"],
strip_include_prefix = "",
defines = [
"WORKERD_ICU_DATA_EMBED=EMBED_com_googlesource_chromium_icu_common_icudtl_dat"
],
data = ["@com_googlesource_chromium_icu//:icudata"],
visibility = ["//visibility:public"],
data = ["@com_googlesource_chromium_icu//:icudata"],
defines = [ "WORKERD_ICU_DATA_EMBED" ],
)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ Windows users should run `workerd` under WSL2.
To build `workerd`, you need:

* [Bazel](https://bazel.build/)
* Clang 15
* libc++ 15
* Clang 11+ (e.g. package `clang` on Debian Bullseye)
* libc++ 11+ (e.g. packages `libc++-dev` and `libc++abi-dev` on Debian Bullseye)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we explicitly recommend at least clang 15 still?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, I don't think it matters. The only difference I'm aware of is the one missing use of concepts but it doesn't seem like enough to tell people to do extra work.


You may then build using:

Expand Down
73 changes: 0 additions & 73 deletions build/scripts/gen-embed.sh

This file was deleted.

60 changes: 0 additions & 60 deletions build/wd_cc_embed.bzl

This file was deleted.

13 changes: 13 additions & 0 deletions icudata-embed.capnp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@0x9ed733e2dd15598b;
# This file is a hack to embed the ICU data file which libicu needs at runtime to do its thing.
# It's inconvenient to ship this file separately so we bake it into the binary. (V8's normal GN
# build can actually do this for us, but we use the Bazel build which doesn't have this option.)
#
# We use Cap'n Proto to do the embedding because it's conveniently cross-platform, but this is
# pretty ugly as it generates a 57MB C++ source file (containing a giant byte array literal).
# It would be nice to use some more direct way of embedding binary data into a symbol in the
# executable, but I couldn't figure out how to do this portably. (See the commit which introduced
# this file to see the old Linux-only solution, but it didn't work on Mac and I didn't want to
# figure it out.)

const embeddedIcuDataFile :Data = embed "external/com_googlesource_chromium_icu/common/icudtl.dat";
2 changes: 1 addition & 1 deletion src/workerd/api/r2-rpc.c++
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ kj::Promise<R2Result> doR2HTTPGetRequest(kj::Own<kj::HttpClient> client,
});
}

return result;
return kj::mv(result);
}

KJ_IF_MAYBE(m, response.headers->get(headerIds.cfBlobMetadataSize)) {
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/api/trace.c++
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ double TraceLog::getTimestamp() {

kj::StringPtr TraceLog::getLevel() {
switch (log.logLevel) {
case LogLevel::DEBUG: return "debug"_kj;
case LogLevel::DEBUG_: return "debug"_kj;
case LogLevel::INFO: return "info"_kj;
case LogLevel::LOG: return "log"_kj;
case LogLevel::WARN: return "warn"_kj;
Expand Down
5 changes: 3 additions & 2 deletions src/workerd/io/worker-interface.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

@0xf7958855f6746344;

$import "/capnp/c++.capnp".namespace("workerd::rpc");
using Cxx = import "/capnp/c++.capnp";
$Cxx.namespace("workerd::rpc");

using import "/capnp/compat/http-over-capnp.capnp".HttpMethod;
using import "/capnp/compat/http-over-capnp.capnp".HttpService;
Expand All @@ -17,7 +18,7 @@ struct Trace @0x8e8d911203762d34 {

logLevel @1 :Level;
enum Level {
debug @0;
debug @0 $Cxx.name("debug_"); # avoid collision with macro on Apple platforms
info @1;
log @2;
warn @3;
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/io/worker.c++
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ struct Worker::Isolate::Impl {
jsg::check(console.As<v8::Object>()->Set(context, methodStr, f));
};

setHandler("debug", LogLevel::DEBUG);
setHandler("debug", LogLevel::DEBUG_);
setHandler("error", LogLevel::ERROR);
setHandler("info", LogLevel::INFO);
setHandler("log", LogLevel::LOG);
Expand Down
10 changes: 10 additions & 0 deletions src/workerd/jsg/iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,23 @@ class GeneratorImpl {
friend Generator;
};

#if _LIBCPP_VERSION >= 15000
template <class Func, class T>
concept GeneratorCallback = std::invocable<Func, Lock&, T, GeneratorContext<T>&>
&& std::same_as<void, std::invoke_result_t<Func, Lock&, T, GeneratorContext<T>&>>;

template <class Func, class T>
concept AsyncGeneratorCallback = std::invocable<Func, Lock&, T, GeneratorContext<T>&>
&& std::same_as<Promise<void>, std::invoke_result_t<Func, Lock&, T, GeneratorContext<T>&>>;
#else
// These don't work in libc++ 11. I haven't tried 12-14, but they do work in 15. So we'll just
// skip the extra type checking if we don't have libc++ 15 or newer.
template <class Func, class T>
concept GeneratorCallback = true;

template <class Func, class T>
concept AsyncGeneratorCallback = true;
#endif

template <typename T>
class Generator final {
Expand Down
4 changes: 2 additions & 2 deletions src/workerd/jsg/setup.c++
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <ucontext.h>

#ifdef WORKERD_ICU_DATA_EMBED
#include <icudata-embed.h>
#include <icudata-embed.capnp.h>
#include <unicode/udata.h>
#endif

Expand Down Expand Up @@ -101,7 +101,7 @@ V8System::V8System(kj::Own<v8::Platform> platformParam, kj::ArrayPtr<const kj::S
// ourselves. `WORKERD_ICU_DATA_EMBED`, if defined, will refer to a `kj::ArrayPtr<const byte>`
// containing the data.
UErrorCode err = U_ZERO_ERROR;
udata_setCommonData(WORKERD_ICU_DATA_EMBED.begin(), &err);
udata_setCommonData(EMBEDDED_ICU_DATA_FILE->begin(), &err);
udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
KJ_ASSERT(err == U_ZERO_ERROR);
#else
Expand Down