Files
ci-emsdk/bazel/emscripten_toolchain/BUILD.bazel
John Firebaugh 93f21c9ef3 Optimize sandbox performance (#1045)
* Optimize sandbox performance

Link just the files needed to compile, link, or archive, rather than the entire directory tree. This drastically improves build times on macOS, where the sandbox is known to be slow (https://github.com/bazelbuild/bazel/issues/8230).

* Linux wants clang to link

* all_files not needed?

* Linux wants llc

* And llvm-ar

* Templated build_file_content
2022-05-09 14:30:43 -04:00

93 lines
2.0 KiB
Python

load(":crosstool.bzl", "emscripten_cc_toolchain_config_rule")
package(default_visibility = ["//visibility:public"])
# Name depends on rules_nodejs version being used.
# https://github.com/emscripten-core/emsdk/issues/1020
# https://github.com/bazelbuild/rules_nodejs/issues/3375
node_files = "@nodejs_host//:node_files" if existing_rule("@nodejs_host//:node_files") else "@nodejs//:node_files"
filegroup(
name = "common_files",
srcs = [
"emscripten_config",
"env.sh",
"env.bat",
node_files,
],
)
filegroup(
name = "compiler_files",
srcs = [
"emcc.sh",
"emcc.bat",
"@emsdk//:compiler_files",
":common_files",
],
)
filegroup(
name = "linker_files",
srcs = [
"emcc_link.sh",
"emcc_link.bat",
"link_wrapper.py",
"@emsdk//:linker_files",
":common_files",
],
)
filegroup(
name = "ar_files",
srcs = [
"emar.sh",
"emar.bat",
"@emsdk//:ar_files",
":common_files",
],
)
filegroup(name = "empty")
# dlmalloc.bc is implictly added by the emscripten toolchain
cc_library(name = "malloc")
emscripten_cc_toolchain_config_rule(
name = "wasm",
cpu = "wasm",
em_config = "emscripten_config",
emscripten_binaries = "@emsdk//:compiler_files",
script_extension = select({
"@bazel_tools//src/conditions:host_windows": "bat",
"//conditions:default": "sh",
}),
)
cc_toolchain(
name = "cc-compiler-wasm",
all_files = ":empty",
ar_files = ":ar_files",
as_files = ":empty",
compiler_files = ":compiler_files",
dwp_files = ":empty",
linker_files = ":linker_files",
objcopy_files = ":empty",
strip_files = ":empty",
toolchain_config = "wasm",
toolchain_identifier = "emscripten-wasm",
)
cc_toolchain_suite(
name = "everything",
toolchains = {
"wasm": ":cc-compiler-wasm",
"wasm|emscripten": ":cc-compiler-wasm",
},
)
py_binary(
name = "wasm_binary",
srcs = ["wasm_binary.py"],
)