summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2018-08-29 08:42:30 +0200
committerBert Belder <bertbelder@gmail.com>2018-08-29 12:28:15 +0200
commit4cadf6e6096de374c67d18e26422c5d452539b31 (patch)
tree44260dc104f94d9be5cfa0656e1cdf0880762df4
parent542eb542544b89ce5c870c63b7bdbb563f007184 (diff)
build: work around sccache false positives due to asm .incbin usage
-rw-r--r--BUILD.gn45
1 files changed, 45 insertions, 0 deletions
diff --git a/BUILD.gn b/BUILD.gn
index f41652f2e..c5f28dcbe 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1,4 +1,5 @@
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
+import("//build/toolchain/cc_wrapper.gni")
import("//third_party/v8/gni/v8.gni")
import("//third_party/v8/snapshot_toolchain.gni")
import("//build_extra/flatbuffers/flatbuffer.gni")
@@ -102,6 +103,27 @@ static_library("libdeno") {
":deno_bindings",
]
configs += [ ":deno_config" ]
+
+ # from_snapshot.cc uses an assembly '.incbin' directive to embed the snapshot.
+ # This causes trouble when using sccache: since the snapshot file is not
+ # inlined by the c preprocessor, sccache doesn't take its contents into
+ # consideration, leading to false-positive cache hits.
+ # Maybe other caching tools have this issue too, but ccache is unaffected.
+ # Therefore, if a cc_wrapper is used that isn't ccache, include a generated
+ # header file that contains the the sha256 hash of the snapshot.
+ if (cc_wrapper != "" && cc_wrapper != "ccache") {
+ hash_h = "$target_gen_dir/bundle/hash.h"
+ inputs += [ hash_h ]
+ deps += [ ":bundle_hash_h" ]
+ if (is_win) {
+ cflags = [ "/FI" + rebase_path(hash_h, target_out_dir) ]
+ } else {
+ cflags = [
+ "-include",
+ rebase_path(hash_h, target_out_dir),
+ ]
+ }
+ }
}
# Only functionality needed for libdeno_test and snapshot_creator
@@ -241,6 +263,29 @@ run_node("bundle") {
]
}
+action("bundle_hash_h") {
+ script = "//tools/sha256sum.py"
+ inputs = get_target_outputs(":bundle")
+ outputs = [
+ "$target_gen_dir/bundle/hash.h",
+ ]
+ deps = [
+ ":bundle",
+ ]
+ args = [
+ "--format",
+ "__attribute__((__unused__)) static const int dummy_%s = 0;",
+ "--outfile",
+ rebase_path(outputs[0], root_build_dir),
+ ]
+ foreach(input, inputs) {
+ args += [
+ "--infile",
+ rebase_path(input, root_build_dir),
+ ]
+ }
+}
+
source_set("libdeno_nosnapshot") {
bundle_outputs = get_target_outputs(":bundle")
bundle_location = rebase_path(bundle_outputs[0], root_build_dir)