Merge "Strip libgcc to only keep fallback symbols"
am: 940ef9bc89
Change-Id: I98df02ead7f6cca4e76ec92d4f880de4e03f5b5c
This commit is contained in:
@@ -255,6 +255,7 @@ type builderFlags struct {
|
||||
groupStaticLibs bool
|
||||
|
||||
stripKeepSymbols bool
|
||||
stripKeepSymbolsList string
|
||||
stripKeepMiniDebugInfo bool
|
||||
stripAddGnuDebuglink bool
|
||||
stripUseGnuStrip bool
|
||||
@@ -835,6 +836,9 @@ func TransformStrip(ctx android.ModuleContext, inputFile android.Path,
|
||||
if flags.stripKeepSymbols {
|
||||
args += " --keep-symbols"
|
||||
}
|
||||
if flags.stripKeepSymbolsList != "" {
|
||||
args += " -k" + flags.stripKeepSymbolsList
|
||||
}
|
||||
if flags.stripUseGnuStrip {
|
||||
args += " --use-gnu-strip"
|
||||
}
|
||||
|
@@ -1833,13 +1833,13 @@ func TestStaticLibDepExport(t *testing.T) {
|
||||
// Check the shared version of lib2.
|
||||
variant := "android_arm64_armv8-a_core_shared"
|
||||
module := ctx.ModuleForTests("lib2", variant).Module().(*Module)
|
||||
checkStaticLibs(t, []string{"lib1", "libclang_rt.builtins-aarch64-android", "libatomic", "libgcc"}, module)
|
||||
checkStaticLibs(t, []string{"lib1", "libclang_rt.builtins-aarch64-android", "libatomic", "libgcc_stripped"}, module)
|
||||
|
||||
// Check the static version of lib2.
|
||||
variant = "android_arm64_armv8-a_core_static"
|
||||
module = ctx.ModuleForTests("lib2", variant).Module().(*Module)
|
||||
// libc++_static is linked additionally.
|
||||
checkStaticLibs(t, []string{"lib1", "libc++_static", "libclang_rt.builtins-aarch64-android", "libatomic", "libgcc"}, module)
|
||||
checkStaticLibs(t, []string{"lib1", "libc++_static", "libclang_rt.builtins-aarch64-android", "libatomic", "libgcc_stripped"}, module)
|
||||
}
|
||||
|
||||
var compilerFlagsTestCases = []struct {
|
||||
|
@@ -228,10 +228,10 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
// libclang_rt.builtins, libgcc and libatomic have to be last on the command line
|
||||
if !Bool(linker.Properties.No_libcrt) {
|
||||
deps.LateStaticLibs = append(deps.LateStaticLibs, config.BuiltinsRuntimeLibrary(ctx.toolchain()))
|
||||
}
|
||||
|
||||
deps.LateStaticLibs = append(deps.LateStaticLibs, "libatomic")
|
||||
if !Bool(linker.Properties.No_libgcc) {
|
||||
deps.LateStaticLibs = append(deps.LateStaticLibs, "libatomic")
|
||||
deps.LateStaticLibs = append(deps.LateStaticLibs, "libgcc_stripped")
|
||||
} else if !Bool(linker.Properties.No_libgcc) {
|
||||
deps.LateStaticLibs = append(deps.LateStaticLibs, "libatomic")
|
||||
deps.LateStaticLibs = append(deps.LateStaticLibs, "libgcc")
|
||||
}
|
||||
|
||||
|
17
cc/strip.go
17
cc/strip.go
@@ -15,15 +15,19 @@
|
||||
package cc
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
type StripProperties struct {
|
||||
Strip struct {
|
||||
None *bool
|
||||
All *bool
|
||||
Keep_symbols *bool
|
||||
}
|
||||
None *bool `android:"arch_variant"`
|
||||
All *bool `android:"arch_variant"`
|
||||
Keep_symbols *bool `android:"arch_variant"`
|
||||
Keep_symbols_list []string `android:"arch_variant"`
|
||||
Use_gnu_strip *bool `android:"arch_variant"`
|
||||
} `android:"arch_variant"`
|
||||
}
|
||||
|
||||
type stripper struct {
|
||||
@@ -42,9 +46,14 @@ func (stripper *stripper) strip(ctx ModuleContext, in android.Path, out android.
|
||||
} else {
|
||||
if Bool(stripper.StripProperties.Strip.Keep_symbols) {
|
||||
flags.stripKeepSymbols = true
|
||||
} else if len(stripper.StripProperties.Strip.Keep_symbols_list) > 0 {
|
||||
flags.stripKeepSymbolsList = strings.Join(stripper.StripProperties.Strip.Keep_symbols_list, ",")
|
||||
} else if !Bool(stripper.StripProperties.Strip.All) {
|
||||
flags.stripKeepMiniDebugInfo = true
|
||||
}
|
||||
if Bool(stripper.StripProperties.Strip.Use_gnu_strip) {
|
||||
flags.stripUseGnuStrip = true
|
||||
}
|
||||
if ctx.Config().Debuggable() && !flags.stripKeepMiniDebugInfo {
|
||||
flags.stripAddGnuDebuglink = true
|
||||
}
|
||||
|
@@ -69,6 +69,13 @@ func GatherRequiredDepsForTest(os android.OsType) string {
|
||||
src: "",
|
||||
}
|
||||
|
||||
toolchain_library {
|
||||
name: "libgcc_stripped",
|
||||
vendor_available: true,
|
||||
recovery_available: true,
|
||||
src: "",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libc",
|
||||
no_libgcc: true,
|
||||
|
@@ -34,6 +34,8 @@ type toolchainLibraryProperties struct {
|
||||
type toolchainLibraryDecorator struct {
|
||||
*libraryDecorator
|
||||
|
||||
stripper
|
||||
|
||||
Properties toolchainLibraryProperties
|
||||
}
|
||||
|
||||
@@ -45,7 +47,7 @@ func (*toolchainLibraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
func (library *toolchainLibraryDecorator) linkerProps() []interface{} {
|
||||
var props []interface{}
|
||||
props = append(props, library.libraryDecorator.linkerProps()...)
|
||||
return append(props, &library.Properties)
|
||||
return append(props, &library.Properties, &library.stripper.StripProperties)
|
||||
}
|
||||
|
||||
// toolchain_library is used internally by the build tool to link the specified
|
||||
@@ -78,7 +80,17 @@ func (library *toolchainLibraryDecorator) link(ctx ModuleContext,
|
||||
return android.PathForSource(ctx, "")
|
||||
}
|
||||
|
||||
return android.PathForSource(ctx, *library.Properties.Src)
|
||||
srcPath := android.PathForSource(ctx, *library.Properties.Src)
|
||||
|
||||
if library.stripper.StripProperties.Strip.Keep_symbols_list != nil {
|
||||
fileName := ctx.ModuleName() + staticLibraryExtension
|
||||
outputFile := android.PathForModuleOut(ctx, fileName)
|
||||
buildFlags := flagsToBuilderFlags(flags)
|
||||
library.stripper.strip(ctx, srcPath, outputFile, buildFlags)
|
||||
return outputFile
|
||||
}
|
||||
|
||||
return srcPath
|
||||
}
|
||||
|
||||
func (library *toolchainLibraryDecorator) nativeCoverage() bool {
|
||||
|
Reference in New Issue
Block a user