bazel packages: add --record_rule_instantiation_callstack flag
This flag (default: false) causes each rule to record the Starlark
call stack at the moment of its instantiation.
The stacks are displayed by blaze query --output=build.
Example output:
# /workspace/x/BUILD:2:1
cc_library(
name = "a",
...
)
# Instantiation stack:
# /workspace/x/inc.bzl:4:3 called from g
# /workspace/x/inc.bzl:2:3 called from f
# /workspace/x/BUILD:2:1 called from <toplevel>
By combining two optimizations, prefix sharing using a linked tree,
and element compression using packed integers, this feature
imposes an additional retained heap space cost of only 1.5%
for deps(//X) where X is Google's web server.
PiperOrigin-RevId: 300408104
diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
index f1d6490..c1a5470 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
@@ -165,7 +165,8 @@
"--incompatible_require_linker_input_cc_api=" + rand.nextBoolean(),
"--incompatible_restrict_string_escapes=" + rand.nextBoolean(),
"--incompatible_use_cc_configure_from_rules_cc=" + rand.nextBoolean(),
- "--internal_skylark_flag_test_canary=" + rand.nextBoolean());
+ "--internal_skylark_flag_test_canary=" + rand.nextBoolean(),
+ "--record_rule_instantiation_callstack=" + rand.nextBoolean());
}
/**
@@ -220,6 +221,7 @@
.incompatibleRestrictStringEscapes(rand.nextBoolean())
.incompatibleUseCcConfigureFromRulesCc(rand.nextBoolean())
.internalSkylarkFlagTestCanary(rand.nextBoolean())
+ .recordRuleInstantiationCallstack(rand.nextBoolean())
.build();
}