[Bazel] Support generating a secondary cache (#1405)
This is a working solution for generating a separate Emscripten cache.
Note that this requires an additional entry in the workspace as follows:
```starlark
load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache")
emsdk_emscripten_cache()
```
When used like this, the default Emscripten cache will be used. However,
if the entry is as follows:
```starlark
load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache")
emsdk_emscripten_cache(flags = ["--lto"])
```
Then embuilder will be called to build all system libraries and ports
(i.e., the `ALL` option to embuilder) with the LTO option enabled. This
can take awhile, so I have also made possible to specify which libraries
you want to build explicitly:
```starlark
load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache")
emsdk_emscripten_cache(
flags = ["--lto"],
libraries = [
"crtbegin",
"libprintf_long_double-debug",
"libstubs-debug",
"libnoexit",
"libc-debug",
"libdlmalloc",
"libcompiler_rt",
"libc++-noexcept",
"libc++abi-debug-noexcept",
"libsockets"
]
)
```
Resolves #807, resolves #971, resolves #1099, resolves #1362, resolves
#1401
2024-07-01 18:23:07 +02:00
|
|
|
local_repository(
|
|
|
|
|
name = "emsdk",
|
|
|
|
|
path = "..",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
load("@emsdk//:deps.bzl", "deps")
|
|
|
|
|
|
|
|
|
|
deps()
|
|
|
|
|
|
|
|
|
|
load("@emsdk//:emscripten_deps.bzl", "emscripten_deps")
|
|
|
|
|
|
|
|
|
|
emscripten_deps()
|
|
|
|
|
|
|
|
|
|
load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains")
|
|
|
|
|
|
|
|
|
|
register_emscripten_toolchains(cache = {
|
|
|
|
|
"configuration": ["--lto"],
|
|
|
|
|
"targets": [
|
|
|
|
|
"crtbegin",
|
|
|
|
|
"libprintf_long_double-debug",
|
|
|
|
|
"libstubs-debug",
|
|
|
|
|
"libnoexit",
|
|
|
|
|
"libc-debug",
|
|
|
|
|
"libdlmalloc",
|
|
|
|
|
"libcompiler_rt",
|
|
|
|
|
"libc++-noexcept",
|
|
|
|
|
"libc++abi-debug-noexcept",
|
2025-01-13 17:18:45 -08:00
|
|
|
"libsockets",
|
|
|
|
|
"libdlmalloc-debug"
|
[Bazel] Support generating a secondary cache (#1405)
This is a working solution for generating a separate Emscripten cache.
Note that this requires an additional entry in the workspace as follows:
```starlark
load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache")
emsdk_emscripten_cache()
```
When used like this, the default Emscripten cache will be used. However,
if the entry is as follows:
```starlark
load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache")
emsdk_emscripten_cache(flags = ["--lto"])
```
Then embuilder will be called to build all system libraries and ports
(i.e., the `ALL` option to embuilder) with the LTO option enabled. This
can take awhile, so I have also made possible to specify which libraries
you want to build explicitly:
```starlark
load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache")
emsdk_emscripten_cache(
flags = ["--lto"],
libraries = [
"crtbegin",
"libprintf_long_double-debug",
"libstubs-debug",
"libnoexit",
"libc-debug",
"libdlmalloc",
"libcompiler_rt",
"libc++-noexcept",
"libc++abi-debug-noexcept",
"libsockets"
]
)
```
Resolves #807, resolves #971, resolves #1099, resolves #1362, resolves
#1401
2024-07-01 18:23:07 +02:00
|
|
|
]
|
|
|
|
|
})
|