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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
build --cxxopt=-std=c++17
build --cxxopt=-O3
build --cxxopt=-no-canonical-prefixes
build --cxxopt=-DEMSCRIPTEN_PROTOBUF_LITE=1

# try to optimize un-used code
build --cxxopt=-fdata-sections
build --cxxopt=-ffunction-sections

build --linkopt=-Wl,--gc-sections

# https://github.com/bazelbuild/bazel/issues/9451
# ideally we want this, but it doesn't work...
# build --cxxopt=-fno-canonical-system-headers
Expand All @@ -22,4 +11,4 @@ build --cpu=wasm
# Use the default Bazel C++ toolchain to build the tools used during the
# build.

build --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
59 changes: 58 additions & 1 deletion toolchain/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,63 @@ def _impl(ctx):
],
)

cxx17_feature = feature(
name = "c++17",
enabled = True,
flag_sets = [
flag_set(
actions = [ACTION_NAMES.cpp_compile],
flag_groups = [flag_group(flags = ["-std=c++17"])],
),
],
)

no_canonical_prefixes_feature = feature(
name = "no-canonical-prefixes",
enabled = True,
flag_sets = [
flag_set(
actions = [
ACTION_NAMES.c_compile,
ACTION_NAMES.cpp_compile,
ACTION_NAMES.cpp_link_executable,
ACTION_NAMES.cpp_link_dynamic_library,
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
],
flag_groups = [
flag_group(
flags = [
"-no-canonical-prefixes",
],
),
],
),
],
)

opt_feature = feature(
name = "opt",
enabled = True,
flag_sets = [
flag_set(
actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
flag_groups = [
flag_group(
flags = ["-O3", "-ffunction-sections", "-fdata-sections"],
),
],
),
flag_set(
actions = [
ACTION_NAMES.cpp_link_dynamic_library,
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
ACTION_NAMES.cpp_link_executable,
],
flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])],
),
],
)

return cc_common.create_cc_toolchain_config_info(
ctx = ctx,
toolchain_identifier = "wasm-toolchain",
Expand All @@ -107,7 +164,7 @@ def _impl(ctx):
"external/emscripten_toolchain/upstream/emscripten/system/include/libcxx",
"external/emscripten_toolchain/upstream/emscripten/system/include/libc",
],
# features = [toolchain_include_directories_feature],
features = [cxx17_feature, no_canonical_prefixes_feature, opt_feature],
)

cc_toolchain_config = rule(
Expand Down