BoringSSL FIPS build - introduce extraLibFlags and use for STL libs.
Rationale: On non-bionic, stl.go currently adds system libraries to ldFlags, this causes problems for partialLd rules. However adding the same libraries to libFlags breaks some existing modules due to symbol conflicts as the system libraries are linked before some module code. Introduced a general mechanism for adding libraries to be linked last rather than making this STL-specific. Bug: 134581881 Bug: 137267623 Test: TH Change-Id: I779f28c6586b3fea85cc6299b686e4fde95262d3
This commit is contained in:
committed by
Colin Cross
parent
74c9bbacb6
commit
99f2fc27e6
@@ -65,14 +65,14 @@ var (
|
||||
ld = pctx.AndroidStaticRule("ld",
|
||||
blueprint.RuleParams{
|
||||
Command: "$ldCmd ${crtBegin} @${out}.rsp " +
|
||||
"${libFlags} ${crtEnd} -o ${out} ${ldFlags}",
|
||||
"${libFlags} ${crtEnd} -o ${out} ${ldFlags} ${extraLibFlags}",
|
||||
CommandDeps: []string{"$ldCmd"},
|
||||
Rspfile: "${out}.rsp",
|
||||
RspfileContent: "${in}",
|
||||
// clang -Wl,--out-implib doesn't update its output file if it hasn't changed.
|
||||
Restat: true,
|
||||
},
|
||||
"ldCmd", "crtBegin", "libFlags", "crtEnd", "ldFlags")
|
||||
"ldCmd", "crtBegin", "libFlags", "crtEnd", "ldFlags", "extraLibFlags")
|
||||
|
||||
partialLd = pctx.AndroidStaticRule("partialLd",
|
||||
blueprint.RuleParams{
|
||||
@@ -259,6 +259,7 @@ type builderFlags struct {
|
||||
cppFlags string
|
||||
ldFlags string
|
||||
libFlags string
|
||||
extraLibFlags string
|
||||
tidyFlags string
|
||||
sAbiFlags string
|
||||
yasmFlags string
|
||||
@@ -630,11 +631,12 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext,
|
||||
Inputs: objFiles,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"ldCmd": ldCmd,
|
||||
"crtBegin": crtBegin.String(),
|
||||
"libFlags": strings.Join(libFlagsList, " "),
|
||||
"ldFlags": flags.ldFlags,
|
||||
"crtEnd": crtEnd.String(),
|
||||
"ldCmd": ldCmd,
|
||||
"crtBegin": crtBegin.String(),
|
||||
"libFlags": strings.Join(libFlagsList, " "),
|
||||
"extraLibFlags": flags.extraLibFlags,
|
||||
"ldFlags": flags.ldFlags,
|
||||
"crtEnd": crtEnd.String(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
1
cc/cc.go
1
cc/cc.go
@@ -153,6 +153,7 @@ type Flags struct {
|
||||
rsFlags []string // Flags that apply to renderscript source files
|
||||
LdFlags []string // Flags that apply to linker command lines
|
||||
libFlags []string // Flags to add libraries early to the link order
|
||||
extraLibFlags []string // Flags to add libraries late in the link order after LdFlags
|
||||
TidyFlags []string // Flags that apply to clang-tidy
|
||||
SAbiFlags []string // Flags that apply to header-abi-dumper
|
||||
YasmFlags []string // Flags that apply to yasm assembly source files
|
||||
|
12
cc/stl.go
12
cc/stl.go
@@ -214,11 +214,11 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
|
||||
|
||||
if !ctx.toolchain().Bionic() {
|
||||
flags.CppFlags = append(flags.CppFlags, "-nostdinc++")
|
||||
flags.LdFlags = append(flags.LdFlags, "-nodefaultlibs")
|
||||
flags.extraLibFlags = append(flags.extraLibFlags, "-nodefaultlibs")
|
||||
if ctx.staticBinary() {
|
||||
flags.LdFlags = append(flags.LdFlags, hostStaticGccLibs[ctx.Os()]...)
|
||||
flags.extraLibFlags = append(flags.extraLibFlags, hostStaticGccLibs[ctx.Os()]...)
|
||||
} else {
|
||||
flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs[ctx.Os()]...)
|
||||
flags.extraLibFlags = append(flags.extraLibFlags, hostDynamicGccLibs[ctx.Os()]...)
|
||||
}
|
||||
if ctx.Windows() {
|
||||
// Use SjLj exceptions for 32-bit. libgcc_eh implements SjLj
|
||||
@@ -253,11 +253,11 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
|
||||
// None or error.
|
||||
if !ctx.toolchain().Bionic() {
|
||||
flags.CppFlags = append(flags.CppFlags, "-nostdinc++")
|
||||
flags.LdFlags = append(flags.LdFlags, "-nodefaultlibs")
|
||||
flags.extraLibFlags = append(flags.extraLibFlags, "-nodefaultlibs")
|
||||
if ctx.staticBinary() {
|
||||
flags.LdFlags = append(flags.LdFlags, hostStaticGccLibs[ctx.Os()]...)
|
||||
flags.extraLibFlags = append(flags.extraLibFlags, hostStaticGccLibs[ctx.Os()]...)
|
||||
} else {
|
||||
flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs[ctx.Os()]...)
|
||||
flags.extraLibFlags = append(flags.extraLibFlags, hostDynamicGccLibs[ctx.Os()]...)
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
@@ -67,6 +67,7 @@ func flagsToBuilderFlags(in Flags) builderFlags {
|
||||
rsFlags: strings.Join(in.rsFlags, " "),
|
||||
ldFlags: strings.Join(in.LdFlags, " "),
|
||||
libFlags: strings.Join(in.libFlags, " "),
|
||||
extraLibFlags: strings.Join(in.extraLibFlags, " "),
|
||||
tidyFlags: strings.Join(in.TidyFlags, " "),
|
||||
sAbiFlags: strings.Join(in.SAbiFlags, " "),
|
||||
yasmFlags: strings.Join(in.YasmFlags, " "),
|
||||
|
Reference in New Issue
Block a user