Dedup version-script handling code.
This is common to binaries and libraries, so move it from library.link
and binary.link to baseLinker.linkerFlags and baseLinker.linkerDeps.
Test: make checkbuild
Bug: None
Change-Id: I5fb24118e601673ae0713a6adc773a1565749be8
diff --git a/cc/library.go b/cc/library.go
index 5da36dc..147dd8e 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -44,8 +44,6 @@
Shared_libs []string `android:"arch_variant"`
} `android:"arch_variant"`
- // local file name to pass to the linker as --version_script
- Version_script *string `android:"arch_variant"`
// local file name to pass to the linker as -unexported_symbols_list
Unexported_symbols_list *string `android:"arch_variant"`
// local file name to pass to the linker as -force_symbols_not_weak_list
@@ -65,12 +63,6 @@
// export headers generated from .proto sources
Export_proto_headers *bool
}
- Target struct {
- Vendor struct {
- // version script for this vendor variant
- Version_script *string `android:"arch_variant"`
- }
- }
Static_ndk_lib *bool
}
@@ -231,8 +223,6 @@
// shlib suffix.
libName string
- sanitize *sanitize
-
sabi *sabi
// Output archive of gcno coverage information files
@@ -432,7 +422,7 @@
func (library *libraryDecorator) linkerInit(ctx BaseModuleContext) {
location := InstallInSystem
- if library.sanitize.inSanitizerDir() {
+ if library.baseLinker.sanitize.inSanitizerDir() {
location = InstallInSanitizerDir
}
library.baseInstaller.location = location
@@ -483,11 +473,9 @@
deps.StaticLibs = removeListFromList(deps.StaticLibs, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs)
}
- android.ExtractSourceDeps(ctx, library.Properties.Version_script)
android.ExtractSourceDeps(ctx, library.Properties.Unexported_symbols_list)
android.ExtractSourceDeps(ctx, library.Properties.Force_symbols_not_weak_list)
android.ExtractSourceDeps(ctx, library.Properties.Force_symbols_weak_list)
- android.ExtractSourceDeps(ctx, library.Properties.Target.Vendor.Version_script)
return deps
}
@@ -526,23 +514,10 @@
var linkerDeps android.Paths
linkerDeps = append(linkerDeps, flags.LdFlagsDeps...)
- versionScript := ctx.ExpandOptionalSource(library.Properties.Version_script, "version_script")
unexportedSymbols := ctx.ExpandOptionalSource(library.Properties.Unexported_symbols_list, "unexported_symbols_list")
forceNotWeakSymbols := ctx.ExpandOptionalSource(library.Properties.Force_symbols_not_weak_list, "force_symbols_not_weak_list")
forceWeakSymbols := ctx.ExpandOptionalSource(library.Properties.Force_symbols_weak_list, "force_symbols_weak_list")
- if ctx.useVndk() && library.Properties.Target.Vendor.Version_script != nil {
- versionScript = ctx.ExpandOptionalSource(library.Properties.Target.Vendor.Version_script, "target.vendor.version_script")
- }
if !ctx.Darwin() {
- if versionScript.Valid() {
- flags.LdFlags = append(flags.LdFlags, "-Wl,--version-script,"+versionScript.String())
- linkerDeps = append(linkerDeps, versionScript.Path())
- if library.sanitize.isSanitizerEnabled(cfi) {
- cfiExportsMap := android.PathForSource(ctx, cfiExportsMapPath)
- flags.LdFlags = append(flags.LdFlags, "-Wl,--version-script,"+cfiExportsMap.String())
- linkerDeps = append(linkerDeps, cfiExportsMap)
- }
- }
if unexportedSymbols.Valid() {
ctx.PropertyErrorf("unexported_symbols_list", "Only supported on Darwin")
}
@@ -553,9 +528,6 @@
ctx.PropertyErrorf("force_symbols_weak_list", "Only supported on Darwin")
}
} else {
- if versionScript.Valid() {
- ctx.PropertyErrorf("version_script", "Not supported on Darwin")
- }
if unexportedSymbols.Valid() {
flags.LdFlags = append(flags.LdFlags, "-Wl,-unexported_symbols_list,"+unexportedSymbols.String())
linkerDeps = append(linkerDeps, unexportedSymbols.Path())
@@ -768,7 +740,7 @@
if Bool(library.Properties.Static_ndk_lib) && library.static() &&
!ctx.useVndk() && !ctx.inRecovery() && ctx.Device() &&
- library.sanitize.isUnsanitizedVariant() {
+ library.baseLinker.sanitize.isUnsanitizedVariant() {
installPath := getNdkSysrootBase(ctx).Join(
ctx, "usr/lib", config.NDKTriple(ctx.toolchain()), file.Base())
@@ -827,9 +799,8 @@
BuildStatic: true,
},
baseCompiler: NewBaseCompiler(),
- baseLinker: NewBaseLinker(),
+ baseLinker: NewBaseLinker(module.sanitize),
baseInstaller: NewBaseInstaller("lib", "lib64", InstallInSystem),
- sanitize: module.sanitize,
sabi: module.sabi,
}