Skip to content

Commit f77fcf4

Browse files
committed
Add tests that generate and use a secondary cache with LTO
1 parent e3ae46e commit f77fcf4

File tree

9 files changed

+64
-0
lines changed

9 files changed

+64
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build --incompatible_enable_cc_toolchain_resolution
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bazel-bin
2+
bazel-out
3+
bazel-test_external
4+
bazel-testlogs

bazel/test_secondary_lto_cache/BUILD

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")
2+
3+
cc_binary(
4+
name = "hello-world",
5+
srcs = ["hello-world.cc"],
6+
linkopts = ["-flto"],
7+
)
8+
9+
wasm_cc_binary(
10+
name = "hello-world-wasm",
11+
cc_target = ":hello-world",
12+
outputs = [
13+
"hello-world.js",
14+
"hello-world.wasm",
15+
],
16+
)
17+
18+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bazel_dep(name = "platforms", version = "0.0.9")
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
local_repository(
2+
name = "emsdk",
3+
path = "..",
4+
)
5+
6+
load("@emsdk//:deps.bzl", "deps")
7+
8+
deps()
9+
10+
load("@emsdk//:emscripten_deps.bzl", "emscripten_deps")
11+
12+
emscripten_deps()
13+
14+
load("@emsdk//:emscripten_cache.bzl", "emscripten_cache")
15+
16+
emscripten_cache(flags = "--lto")
17+
18+
load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains")
19+
20+
register_emscripten_toolchains()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <iostream>
2+
3+
int main(int argc, char** argv) {
4+
std::cout << "hello world!" << std::endl;
5+
return 0;
6+
}

test/test_bazel.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ if (-not $?) { Exit $LastExitCode }
2222
# Test use of the closure compiler
2323
bazel build //:hello-embind-wasm --compilation_mode opt # release
2424
if (-not $?) { Exit $LastExitCode }
25+
26+
Set-Location ..\test_secondary_lto_cache
27+
28+
bazel build //:hello-world-wasm
29+
if (-not $?) { Exit $LastExitCode }
30+

test/test_bazel.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ bazel build //:hello-embind-wasm --compilation_mode dbg # debug
3333
bazel build //:hello-embind-wasm --compilation_mode opt # release
3434
# This function should not be minified if the externs file is loaded correctly.
3535
grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js
36+
37+
cd ../test_secondary_lto_cache
38+
bazel build //:hello-world-wasm
39+

test/test_bazel_mac.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ bazel build //hello-world:hello-world-wasm-simd
2727
cd test_external
2828
bazel build //long_command_line:long_command_line_wasm
2929
bazel build //:hello-world-wasm
30+
31+
cd ../test_secondary_lto_cache
32+
bazel build //:hello-world-wasm
33+

0 commit comments

Comments
 (0)