From 9a02a687f06efbcd1d5181fc370c04a1128a7b10 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Thu, 22 Feb 2024 19:07:22 -0800 Subject: [PATCH] Set -g0 to make cc_pie_obj produce deterministic output to help Bazel caching. The output object file contains debug information, which, by default, contains the absolute path to source files. These absolute paths are volatile data because they contain host/user specific paths, which makes the files differ between invocations. This then negatively affects Bazel's ability to accurately detect changes and cache them, which means people need to rebuilt it much more frequently. To fix, specify `-g0`, which will omit debugging information entirely. PiperOrigin-RevId: 609575453 --- pkg/sentry/platform/systrap/sysmsg/build.bzl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/sentry/platform/systrap/sysmsg/build.bzl b/pkg/sentry/platform/systrap/sysmsg/build.bzl index ec4886f78..f72e02a8f 100644 --- a/pkg/sentry/platform/systrap/sysmsg/build.bzl +++ b/pkg/sentry/platform/systrap/sysmsg/build.bzl @@ -24,7 +24,12 @@ def cc_pie_obj(name, srcs, outs): " -fno-builtin " + "-ffreestanding " + "-mgeneral-regs-only " + - "-g " + + # Set -g0 to omit debugging information because it contains + # absolute paths, which are volatile build information and results + # in Bazel being unable to properly cache the output. If debugging + # information is desired, the flags -fdebug-compilation-dir or + # -fdebug-prefix-map can be used. + "-g0 " + "-Wa,--noexecstack " + "-fno-asynchronous-unwind-tables " + "-fno-stack-protector " +