Support grouping static libraries
LLVM has complicated static library layering that sometimes changes. The make solution was to list all the static libraries twice, but Soong dedups the list. Add a group_static_libs flag to allow surrounding the static libs with -Wl,--start-group and -Wl,--end-group. Test: mmma -j external/llvm Change-Id: Ic08a183d7def9c9249d4a3014760759f16b68d04
This commit is contained in:
parent
2d8e3b9bfe
commit
18c0c5afbd
|
@ -187,6 +187,8 @@ type builderFlags struct {
|
||||||
clang bool
|
clang bool
|
||||||
tidy bool
|
tidy bool
|
||||||
|
|
||||||
|
groupStaticLibs bool
|
||||||
|
|
||||||
stripKeepSymbols bool
|
stripKeepSymbols bool
|
||||||
stripKeepMiniDebugInfo bool
|
stripKeepMiniDebugInfo bool
|
||||||
stripAddGnuDebuglink bool
|
stripAddGnuDebuglink bool
|
||||||
|
@ -439,7 +441,13 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if flags.groupStaticLibs && len(staticLibs) > 0 {
|
||||||
|
libFlagsList = append(libFlagsList, "-Wl,--start-group")
|
||||||
|
}
|
||||||
libFlagsList = append(libFlagsList, staticLibs.Strings()...)
|
libFlagsList = append(libFlagsList, staticLibs.Strings()...)
|
||||||
|
if flags.groupStaticLibs && len(staticLibs) > 0 {
|
||||||
|
libFlagsList = append(libFlagsList, "-Wl,--end-group")
|
||||||
|
}
|
||||||
|
|
||||||
if groupLate && !ctx.Darwin() && len(lateStaticLibs) > 0 {
|
if groupLate && !ctx.Darwin() && len(lateStaticLibs) > 0 {
|
||||||
libFlagsList = append(libFlagsList, "-Wl,--start-group")
|
libFlagsList = append(libFlagsList, "-Wl,--start-group")
|
||||||
|
|
2
cc/cc.go
2
cc/cc.go
|
@ -110,6 +110,8 @@ type Flags struct {
|
||||||
DynamicLinker string
|
DynamicLinker string
|
||||||
|
|
||||||
CFlagsDeps android.Paths // Files depended on by compiler flags
|
CFlagsDeps android.Paths // Files depended on by compiler flags
|
||||||
|
|
||||||
|
GroupStaticLibs bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ObjectLinkerProperties struct {
|
type ObjectLinkerProperties struct {
|
||||||
|
|
|
@ -76,6 +76,10 @@ type BaseLinkerProperties struct {
|
||||||
// don't link in crt_begin and crt_end. This flag should only be necessary for
|
// don't link in crt_begin and crt_end. This flag should only be necessary for
|
||||||
// compiling crt or libc.
|
// compiling crt or libc.
|
||||||
Nocrt *bool `android:"arch_variant"`
|
Nocrt *bool `android:"arch_variant"`
|
||||||
|
|
||||||
|
// group static libraries. This can resolve missing symbols issues with interdependencies
|
||||||
|
// between static libraries, but it is generally better to order them correctly instead.
|
||||||
|
Group_static_libs *bool `android:"arch_variant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBaseLinker() *baseLinker {
|
func NewBaseLinker() *baseLinker {
|
||||||
|
@ -193,6 +197,10 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||||
flags.LdFlags = append(flags.LdFlags, toolchain.ToolchainLdflags())
|
flags.LdFlags = append(flags.LdFlags, toolchain.ToolchainLdflags())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Bool(linker.Properties.Group_static_libs) {
|
||||||
|
flags.GroupStaticLibs = true
|
||||||
|
}
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,8 @@ func flagsToBuilderFlags(in Flags) builderFlags {
|
||||||
toolchain: in.Toolchain,
|
toolchain: in.Toolchain,
|
||||||
clang: in.Clang,
|
clang: in.Clang,
|
||||||
tidy: in.Tidy,
|
tidy: in.Tidy,
|
||||||
|
|
||||||
|
groupStaticLibs: in.GroupStaticLibs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue