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
This commit is contained in:
Andrei Vagin
2024-02-22 19:11:08 -08:00
committed by gVisor bot
parent 89ccdfe98a
commit 9a02a687f0
+6 -1
View File
@@ -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 " +