aboutsummaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorMartin Stjernholm <mast@google.com>2020-04-01 20:38:01 +0100
committerPaul Duffin <paulduffin@google.com>2020-05-06 08:18:35 +0100
commitcd497b05066d860f47c7cc17d21240309a26d2d0 (patch)
treeae0663d3dceef11d215a56d780068884fc01d8d9 /cc
parent8c0db63809cd13aec2cdd3b259ebc0c4fd639131 (diff)
downloadbuild_soong-cd497b05066d860f47c7cc17d21240309a26d2d0.tar.gz
build_soong-cd497b05066d860f47c7cc17d21240309a26d2d0.tar.bz2
build_soong-cd497b05066d860f47c7cc17d21240309a26d2d0.zip
Propagate stubs to the SDK for libraries that have them.
Necessary to make the APEX build logic treat the libraries as API boundaries rather than dependencies to bundle. The .so files in the snapshots are the compiled stub libraries in this case. They are strictly speaking redundant since they can be generated from the .map.txt files in the snapshots, but doing that would require extending the cc_prebuilt_library(_shared) module types with a full compiler pass etc, and that would break a lot of assumptions in the cc package. Test: m nothing Test: Create an SDK snapshot with Bionic libs, drop it into a master-art tree without bionic/ in it, build ART APEXes, and check that the Soong phase completes (specifically no errors about various APEX libs requiring libc that is not available to them). Bug: 152481980 Merged-In: I31b928e6261198b6dd6f6b17196e714f07b64172 Change-Id: I31b928e6261198b6dd6f6b17196e714f07b64172 (cherry picked from commit c5dd4f7c1f3958bb68ad493088275b286a6acd6b)
Diffstat (limited to 'cc')
-rw-r--r--cc/cc.go7
-rw-r--r--cc/library.go6
-rw-r--r--cc/library_sdk_member.go21
3 files changed, 33 insertions, 1 deletions
diff --git a/cc/cc.go b/cc/cc.go
index ec0f1a08..e6731aa2 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -612,6 +612,13 @@ func (c *Module) GetDepsInLinkOrder() []android.Path {
return c.depsInLinkOrder
}
+func (c *Module) StubsSymbolFile() android.OptionalPath {
+ if library, ok := c.linker.(*libraryDecorator); ok {
+ return library.stubsSymbolFile
+ }
+ return android.OptionalPath{}
+}
+
func (c *Module) StubsVersions() []string {
if c.linker != nil {
if library, ok := c.linker.(*libraryDecorator); ok {
diff --git a/cc/library.go b/cc/library.go
index 0547e35f..1a07c438 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -367,6 +367,9 @@ type libraryDecorator struct {
// Location of the file that should be copied to dist dir when requested
distFile android.OptionalPath
+ // stubs.symbol_file
+ stubsSymbolFile android.OptionalPath
+
versionScriptPath android.ModuleGenPath
post_install_cmds []string
@@ -376,7 +379,7 @@ type libraryDecorator struct {
useCoreVariant bool
checkSameCoreVariant bool
- // Decorated interafaces
+ // Decorated interfaces
*baseCompiler
*baseLinker
*baseInstaller
@@ -603,6 +606,7 @@ func (library *libraryDecorator) shouldCreateSourceAbiDump(ctx ModuleContext) bo
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
if library.buildStubs() {
+ library.stubsSymbolFile = android.OptionalPathForModuleSrc(ctx, library.Properties.Stubs.Symbol_file)
objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Stubs.Symbol_file), library.MutatedProperties.StubsVersion, "--apex")
library.versionScriptPath = versionScript
return objs
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index 0a11af12..4e4df5b0 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -269,12 +269,21 @@ func addPossiblyArchSpecificProperties(sdkModuleContext android.ModuleContext, b
for property, dirs := range includeDirs {
outputProperties.AddProperty(property, dirs)
}
+
+ if len(libInfo.StubsVersion) > 0 {
+ symbolFilePath := filepath.Join(nativeEtcDir, libInfo.StubsSymbolFile.Path().Base())
+ builder.CopyToSnapshot(libInfo.StubsSymbolFile.Path(), symbolFilePath)
+ stubsSet := outputProperties.AddPropertySet("stubs")
+ stubsSet.AddProperty("symbol_file", symbolFilePath)
+ stubsSet.AddProperty("versions", []string{libInfo.StubsVersion})
+ }
}
const (
nativeIncludeDir = "include"
nativeGeneratedIncludeDir = "include_gen"
nativeStubDir = "lib"
+ nativeEtcDir = "etc"
)
// path to the native library. Relative to <sdk_root>/<api_dir>
@@ -335,6 +344,13 @@ type nativeLibInfoProperties struct {
// This field is exported as its contents may not be arch specific.
SystemSharedLibs []string
+ // The specific stubs version for the lib variant, or empty string if stubs
+ // are not in use.
+ StubsVersion string
+
+ // The stubs symbol file.
+ StubsSymbolFile android.OptionalPath
+
// outputFile is not exported as it is always arch specific.
outputFile android.Path
}
@@ -370,6 +386,11 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte
p.SystemSharedLibs = specifiedDeps.systemSharedLibs
}
p.exportedGeneratedHeaders = ccModule.ExportedGeneratedHeaders()
+
+ if ccModule.HasStubsVariants() {
+ p.StubsVersion = ccModule.StubsVersion()
+ p.StubsSymbolFile = ccModule.StubsSymbolFile()
+ }
}
func (p *nativeLibInfoProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {