summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jerome Gaillard <jgaillard@google.com> 2024-12-10 18:07:19 +0000
committer Jerome Gaillard <jgaillard@google.com> 2024-12-12 05:18:27 -0800
commit9b454738cd0c14a22be7fdffa1ff3f1d96eda7e5 (patch)
treecc6b6fb80cf6e5cb2419a81ef30840a45ab00a6c
parentd29a1a83c251f570d438487aafe51680e3ece76f (diff)
Support exported_symbols_list for Darwin builds
unexported_symbols_list and other linker properties are already supported by Soong. This adds exported_symbols_list to that list. This is needed by layoutlib_jni and libandroid_runtime to be able to limit the symbols they export when built for host. This provides a way to handle the dependency on a file listing the symbols to export, similar to version_script for linux builds. Bug: 382649667 Test: N/A Change-Id: I1807d26506d142c0b795c59415767a6bc70a75d6
-rw-r--r--cc/library.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/cc/library.go b/cc/library.go
index 6485ea364..44a13ee31 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -34,6 +34,8 @@ import (
// LibraryProperties is a collection of properties shared by cc library rules/cc.
type LibraryProperties struct {
+ // local file name to pass to the linker as -exported_symbols_list
+ Exported_symbols_list *string `android:"path,arch_variant"`
// local file name to pass to the linker as -unexported_symbols_list
Unexported_symbols_list *string `android:"path,arch_variant"`
// local file name to pass to the linker as -force_symbols_not_weak_list
@@ -1049,10 +1051,14 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
linkerDeps = append(linkerDeps, flags.LdFlagsDeps...)
linkerDeps = append(linkerDeps, ndkSharedLibDeps(ctx)...)
+ exportedSymbols := ctx.ExpandOptionalSource(library.Properties.Exported_symbols_list, "exported_symbols_list")
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.Darwin() {
+ if exportedSymbols.Valid() {
+ ctx.PropertyErrorf("exported_symbols_list", "Only supported on Darwin")
+ }
if unexportedSymbols.Valid() {
ctx.PropertyErrorf("unexported_symbols_list", "Only supported on Darwin")
}
@@ -1063,6 +1069,10 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
ctx.PropertyErrorf("force_symbols_weak_list", "Only supported on Darwin")
}
} else {
+ if exportedSymbols.Valid() {
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-exported_symbols_list,"+exportedSymbols.String())
+ linkerDeps = append(linkerDeps, exportedSymbols.Path())
+ }
if unexportedSymbols.Valid() {
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-unexported_symbols_list,"+unexportedSymbols.String())
linkerDeps = append(linkerDeps, unexportedSymbols.Path())