From 83d9f71cc595d6a9bb194846165a47ec1779e6cd Mon Sep 17 00:00:00 2001 From: Vishwath Mohan Date: Thu, 16 Mar 2017 11:01:23 -0700 Subject: [PATCH] Allow custom ar flags to be set. Adds the ability to set custom flags for ar in Soong, similar to how they can currently be set for make. Bug: 36290748 Test: sanitize.go is able to correct set custom ar flags for CFI. CFI enabled Soong components build and boot without issue. Change-Id: I3212793aa84ba51df910c184d8bb376b3650376e --- cc/builder.go | 4 ++++ cc/cc.go | 1 + cc/util.go | 1 + 3 files changed, 6 insertions(+) diff --git a/cc/builder.go b/cc/builder.go index 9a871d55e..f3a4bcb44 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -184,6 +184,7 @@ func init() { type builderFlags struct { globalFlags string + arFlags string asFlags string cFlags string conlyFlags string @@ -367,6 +368,9 @@ func TransformObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths, arCmd := gccCmd(flags.toolchain, "ar") arFlags := "crsPD" + if flags.arFlags != "" { + arFlags += " " + flags.arFlags + } ctx.ModuleBuild(pctx, android.ModuleBuildParams{ Rule: ar, diff --git a/cc/cc.go b/cc/cc.go index ec951887a..c5f1c3575 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -96,6 +96,7 @@ type PathDeps struct { type Flags struct { GlobalFlags []string // Flags that apply to C, C++, and assembly source files + ArFlags []string // Flags that apply to ar AsFlags []string // Flags that apply to assembly source files CFlags []string // Flags that apply to C and C++ source files ConlyFlags []string // Flags that apply to C source files diff --git a/cc/util.go b/cc/util.go index 570052eae..919e14c7e 100644 --- a/cc/util.go +++ b/cc/util.go @@ -88,6 +88,7 @@ func moduleToLibName(module string) (string, error) { func flagsToBuilderFlags(in Flags) builderFlags { return builderFlags{ globalFlags: strings.Join(in.GlobalFlags, " "), + arFlags: strings.Join(in.ArFlags, " "), asFlags: strings.Join(in.AsFlags, " "), cFlags: strings.Join(in.CFlags, " "), conlyFlags: strings.Join(in.ConlyFlags, " "),