Add -fdebug-compilation-dir option

The main use of this flag is to be to make both the debug info
and the build command line be independent of the compilation dir.
See: https://reviews.llvm.org/D63387 & https://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html

Removed -fdebug-prefix-map and PWD variable being set in the compile
command line - these were workarounds we originally did to ensure that
the compile output is independent of the working directory and are no
longer needed now that we have -fdebug-compilation-dir.

Test: Ran "m
out/target/product/crosshatch/obj/SHARED_LIBRARIES/libexif.vendor_intermediates/same_vndk_variants.timestamp"
which fails on an RBE hardened stack without this change and passes with
this change.

Bug: b/169266636
Change-Id: Ib0f271e55f6cf0c89a30e65d3a0b25fe3f3a8f48
This commit is contained in:
Kousik Kumar
2020-10-14 08:34:44 -04:00
parent 36e4ad1f4d
commit 578ba0021f
2 changed files with 10 additions and 7 deletions

View File

@@ -44,14 +44,14 @@ var (
blueprint.RuleParams{
Depfile: "${out}.d",
Deps: blueprint.DepsGCC,
Command: "$relPwd ${config.CcWrapper}$ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
Command: "${config.CcWrapper}$ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
CommandDeps: []string{"$ccCmd"},
},
"ccCmd", "cFlags")
ccNoDeps = pctx.AndroidStaticRule("ccNoDeps",
blueprint.RuleParams{
Command: "$relPwd $ccCmd -c $cFlags -o $out $in",
Command: "$ccCmd -c $cFlags -o $out $in",
CommandDeps: []string{"$ccCmd"},
},
"ccCmd", "cFlags")
@@ -220,7 +220,7 @@ var (
Labels: map[string]string{"type": "abi-dump", "tool": "header-abi-dumper"},
ExecStrategy: "${config.REAbiDumperExecStrategy}",
Platform: map[string]string{
remoteexec.PoolKey: "${config.RECXXPool}",
remoteexec.PoolKey: "${config.RECXXPool}",
},
}, []string{"cFlags", "exportDirs"}, nil)

View File

@@ -53,6 +53,13 @@ var (
"-Werror=pragma-pack",
"-Werror=pragma-pack-suspicious-include",
"-Werror=unreachable-code-loop-increment",
// -fdebug-compilation-dir=. is used to make both the action command line and the output
// independent of the working directory of the action.
// Using cc1 flags since RBE's input processor does not yet have the updated version
// of LLVM that promotes the cc1 flag to driver level flag.
// See: https://reviews.llvm.org/D63387
"-Xclang,-fdebug-compilation-dir,.",
}
commonGlobalConlyflags = []string{}
@@ -150,10 +157,6 @@ var (
var pctx = android.NewPackageContext("android/soong/cc/config")
func init() {
if android.BuildOs == android.Linux {
commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=")
}
pctx.StaticVariable("CommonGlobalConlyflags", strings.Join(commonGlobalConlyflags, " "))
pctx.StaticVariable("DeviceGlobalCppflags", strings.Join(deviceGlobalCppflags, " "))
pctx.StaticVariable("DeviceGlobalLdflags", strings.Join(deviceGlobalLdflags, " "))