bazel: make Starlark profiler work in Bazel
Fixes https://github.com/bazelbuild/bazel/issues/10890
Details:
- configure copybara so that Bazel sees JNI.java.oss as JNI.java.
- use the correct .so library name for Bazel (no "-jni").
- add the dynamic library to to Bazel's install-base using
the platform's required name (libx.so, libx.dylib, x.dll).
- report errors during command startup, don't just store them. :)
- don't consider SIG_DFL as "signal already in use". The pthreads
package used by Bazel sets SIGPROF to DFL whereas Blaze's uses IGN.
RELNOTES:
The --starlark_cpu_profile=<file> flag writes a profile in
pprof format containing a statistical summary of CPU usage
by all Starlark execution during the bazel command. Use it
to identify slow Starlark functions in loading and analysis.
PiperOrigin-RevId: 315678587
diff --git a/src/BUILD b/src/BUILD
index 1b03374..0cb189a 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -12,6 +12,9 @@
name = "install_base_key-file" + suffix,
srcs = [
"//src/main/java/com/google/devtools/build/lib/bazel:BazelServer_deploy.jar",
+ "//src/main/java/com/google/devtools/build/lib/syntax:cpu_profiler",
+ # TODO(brandjon): ensure we haven't forgotten any package-zip items,
+ # otherwise bazel won't correctly reextract modified files.
"//src/main/cpp:client",
"//src/main/tools:build-runfiles",
"//src/main/tools:process-wrapper",
@@ -329,6 +332,8 @@
"//src/main/java/com/google/devtools/build/lib/bazel:BazelServer_deploy.jar",
"install_base_key" + suffix,
":platforms_archive",
+ # Ordinary items follow:
+ "//src/main/java/com/google/devtools/build/lib/syntax:cpu_profiler",
"//src/main/native:target-os-unix-native-lib",
"//src/main/native/windows:target-os-native-lib",
"//src/main/tools:build-runfiles",