Merge "Add clang_verify property for cc." into main
This commit is contained in:
@@ -46,18 +46,18 @@ var (
|
|||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Depfile: "${out}.d",
|
Depfile: "${out}.d",
|
||||||
Deps: blueprint.DepsGCC,
|
Deps: blueprint.DepsGCC,
|
||||||
Command: "$relPwd ${config.CcWrapper}$ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
|
Command: "$relPwd ${config.CcWrapper}$ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in$postCmd",
|
||||||
CommandDeps: []string{"$ccCmd"},
|
CommandDeps: []string{"$ccCmd"},
|
||||||
},
|
},
|
||||||
"ccCmd", "cFlags")
|
"ccCmd", "cFlags", "postCmd")
|
||||||
|
|
||||||
// Rule to invoke gcc with given command and flags, but no dependencies.
|
// Rule to invoke gcc with given command and flags, but no dependencies.
|
||||||
ccNoDeps = pctx.AndroidStaticRule("ccNoDeps",
|
ccNoDeps = pctx.AndroidStaticRule("ccNoDeps",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$relPwd $ccCmd -c $cFlags -o $out $in",
|
Command: "$relPwd $ccCmd -c $cFlags -o $out $in$postCmd",
|
||||||
CommandDeps: []string{"$ccCmd"},
|
CommandDeps: []string{"$ccCmd"},
|
||||||
},
|
},
|
||||||
"ccCmd", "cFlags")
|
"ccCmd", "cFlags", "postCmd")
|
||||||
|
|
||||||
// Rules to invoke ld to link binaries. Uses a .rsp file to list dependencies, as there may
|
// Rules to invoke ld to link binaries. Uses a .rsp file to list dependencies, as there may
|
||||||
// be many.
|
// be many.
|
||||||
@@ -400,6 +400,7 @@ type builderFlags struct {
|
|||||||
gcovCoverage bool
|
gcovCoverage bool
|
||||||
sAbiDump bool
|
sAbiDump bool
|
||||||
emitXrefs bool
|
emitXrefs bool
|
||||||
|
clangVerify bool
|
||||||
|
|
||||||
assemblerWithCpp bool // True if .s files should be processed with the c preprocessor.
|
assemblerWithCpp bool // True if .s files should be processed with the c preprocessor.
|
||||||
|
|
||||||
@@ -591,6 +592,7 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
|||||||
var moduleToolingFlags string
|
var moduleToolingFlags string
|
||||||
|
|
||||||
var ccCmd string
|
var ccCmd string
|
||||||
|
var postCmd string
|
||||||
tidy := flags.tidy
|
tidy := flags.tidy
|
||||||
coverage := flags.gcovCoverage
|
coverage := flags.gcovCoverage
|
||||||
dump := flags.sAbiDump
|
dump := flags.sAbiDump
|
||||||
@@ -635,6 +637,10 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
|||||||
|
|
||||||
ccCmd = "${config.ClangBin}/" + ccCmd
|
ccCmd = "${config.ClangBin}/" + ccCmd
|
||||||
|
|
||||||
|
if flags.clangVerify {
|
||||||
|
postCmd = " && touch $$out"
|
||||||
|
}
|
||||||
|
|
||||||
var implicitOutputs android.WritablePaths
|
var implicitOutputs android.WritablePaths
|
||||||
if coverage {
|
if coverage {
|
||||||
gcnoFile := android.ObjPathWithExt(ctx, subdir, srcFile, "gcno")
|
gcnoFile := android.ObjPathWithExt(ctx, subdir, srcFile, "gcno")
|
||||||
@@ -651,8 +657,9 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
|||||||
Implicits: cFlagsDeps,
|
Implicits: cFlagsDeps,
|
||||||
OrderOnly: pathDeps,
|
OrderOnly: pathDeps,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"cFlags": shareFlags("cFlags", moduleFlags),
|
"cFlags": shareFlags("cFlags", moduleFlags),
|
||||||
"ccCmd": ccCmd, // short and not shared
|
"ccCmd": ccCmd, // short and not shared
|
||||||
|
"postCmd": postCmd,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
1
cc/cc.go
1
cc/cc.go
@@ -260,6 +260,7 @@ type Flags struct {
|
|||||||
GcovCoverage bool // True if coverage files should be generated.
|
GcovCoverage bool // True if coverage files should be generated.
|
||||||
SAbiDump bool // True if header abi dumps should be generated.
|
SAbiDump bool // True if header abi dumps should be generated.
|
||||||
EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe
|
EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe
|
||||||
|
ClangVerify bool // If true, append cflags "-Xclang -verify" and append "&& touch $out" to the clang command line.
|
||||||
|
|
||||||
// The instruction set required for clang ("arm" or "thumb").
|
// The instruction set required for clang ("arm" or "thumb").
|
||||||
RequiredInstructionSet string
|
RequiredInstructionSet string
|
||||||
|
@@ -3218,3 +3218,32 @@ func TestVendorSdkVersion(t *testing.T) {
|
|||||||
testSdkVersionFlag("libfoo", "30")
|
testSdkVersionFlag("libfoo", "30")
|
||||||
testSdkVersionFlag("libbar", "29")
|
testSdkVersionFlag("libbar", "29")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClangVerify(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
ctx := testCc(t, `
|
||||||
|
cc_library {
|
||||||
|
name: "lib_no_clang_verify",
|
||||||
|
srcs: ["libnocv.cc"],
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "lib_clang_verify",
|
||||||
|
srcs: ["libcv.cc"],
|
||||||
|
clang_verify: true,
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
module := ctx.ModuleForTests("lib_no_clang_verify", "android_arm64_armv8-a_shared")
|
||||||
|
|
||||||
|
cFlags_no_cv := module.Rule("cc").Args["cFlags"]
|
||||||
|
if strings.Contains(cFlags_no_cv, "-Xclang") || strings.Contains(cFlags_no_cv, "-verify") {
|
||||||
|
t.Errorf("expected %q not in cflags, got %q", "-Xclang -verify", cFlags_no_cv)
|
||||||
|
}
|
||||||
|
|
||||||
|
cFlags_cv := ctx.ModuleForTests("lib_clang_verify", "android_arm64_armv8-a_shared").Rule("cc").Args["cFlags"]
|
||||||
|
if strings.Contains(cFlags_cv, "-Xclang") && strings.Contains(cFlags_cv, "-verify") {
|
||||||
|
t.Errorf("expected %q in cflags, got %q", "-Xclang -verify", cFlags_cv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -120,6 +120,10 @@ type BaseCompilerProperties struct {
|
|||||||
// ban targeting bpf in cc rules instead use bpf_rules. (b/323415017)
|
// ban targeting bpf in cc rules instead use bpf_rules. (b/323415017)
|
||||||
Bpf_target *bool
|
Bpf_target *bool
|
||||||
|
|
||||||
|
// Add "-Xclang -verify" to the cflags and appends "touch $out" to
|
||||||
|
// the clang command line.
|
||||||
|
Clang_verify bool
|
||||||
|
|
||||||
Yacc *YaccProperties
|
Yacc *YaccProperties
|
||||||
Lex *LexProperties
|
Lex *LexProperties
|
||||||
|
|
||||||
@@ -390,6 +394,11 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
|||||||
flags.Yacc = compiler.Properties.Yacc
|
flags.Yacc = compiler.Properties.Yacc
|
||||||
flags.Lex = compiler.Properties.Lex
|
flags.Lex = compiler.Properties.Lex
|
||||||
|
|
||||||
|
flags.ClangVerify = compiler.Properties.Clang_verify
|
||||||
|
if compiler.Properties.Clang_verify {
|
||||||
|
flags.Local.CFlags = append(flags.Local.CFlags, "-Xclang", "-verify")
|
||||||
|
}
|
||||||
|
|
||||||
// Include dir cflags
|
// Include dir cflags
|
||||||
localIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Local_include_dirs)
|
localIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Local_include_dirs)
|
||||||
if len(localIncludeDirs) > 0 {
|
if len(localIncludeDirs) > 0 {
|
||||||
|
@@ -68,6 +68,7 @@ func flagsToBuilderFlags(in Flags) builderFlags {
|
|||||||
needTidyFiles: in.NeedTidyFiles,
|
needTidyFiles: in.NeedTidyFiles,
|
||||||
sAbiDump: in.SAbiDump,
|
sAbiDump: in.SAbiDump,
|
||||||
emitXrefs: in.EmitXrefs,
|
emitXrefs: in.EmitXrefs,
|
||||||
|
clangVerify: in.ClangVerify,
|
||||||
|
|
||||||
systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
|
systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user