summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2024-12-05 14:06:17 -0800
committer Colin Cross <ccross@android.com> 2024-12-09 22:59:13 -0800
commit190a66abb243f22995d46e6dd90808f4d69eeeeb (patch)
tree08d690dfd92c35a3c46d7a83e5e5d27f6098a015
parent6a730045b5bfcfdc3e0709f4283ade8a541dc618 (diff)
Move parent static check in cc.Module.DepIsInSameApex into tag
In order to prepare for splitting DepIsInSameApex so it can be called separately on the outgoing and incoming modules during a transtion, add fromStatic to libraryDependencyTag so that the check doesn't need to access both the parent and the child module. This also fixes cases where the static parent was misdetected, which causes a single test failure that seems correct, TestApexWithTests. cc.Module.DepIsInSameApex correctly identifies that the "mytest" module is static and the "mylib" shared library dependency is not used in the apex. Fix the test to make "mytest" non-static so that "mylib" is included. Bug: 372543712 Test: all Soong tests pass Change-Id: Ibb0cfff77adefb804ff6c66467ac761b723597de
-rw-r--r--apex/apex_test.go1
-rw-r--r--cc/cc.go25
-rw-r--r--cc/linkable.go4
-rw-r--r--rust/rust.go2
-rw-r--r--rust/sanitize.go4
5 files changed, 19 insertions, 17 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 282cd1dd3..5cd0541b9 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -5818,7 +5818,6 @@ func TestApexWithTests(t *testing.T) {
relative_install_path: "test",
shared_libs: ["mylib"],
system_shared_libs: [],
- static_executable: true,
stl: "none",
data: [":fg"],
}
diff --git a/cc/cc.go b/cc/cc.go
index 802332426..326f9236c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -731,6 +731,9 @@ type libraryDependencyTag struct {
Kind libraryDependencyKind
Order libraryDependencyOrder
+ // fromStatic is true when the parent module is a static library or binary
+ fromStatic bool
+
wholeStatic bool
reexportFlags bool
@@ -2552,7 +2555,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
for _, lib := range deps.HeaderLibs {
- depTag := libraryDependencyTag{Kind: headerLibraryDependency}
+ depTag := libraryDependencyTag{Kind: headerLibraryDependency, fromStatic: c.static()}
if inList(lib, deps.ReexportHeaderLibHeaders) {
depTag.reexportFlags = true
}
@@ -2594,7 +2597,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
for _, lib := range deps.WholeStaticLibs {
- depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true}
+ depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true, fromStatic: c.static()}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
@@ -2603,7 +2606,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
for _, lib := range deps.StaticLibs {
// Some dependencies listed in static_libs might actually be rust_ffi rlib variants.
- depTag := libraryDependencyTag{Kind: staticLibraryDependency}
+ depTag := libraryDependencyTag{Kind: staticLibraryDependency, fromStatic: c.static()}
if inList(lib, deps.ReexportStaticLibHeaders) {
depTag.reexportFlags = true
@@ -2620,7 +2623,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
// so that native libraries/binaries are linked with static unwinder
// because Q libc doesn't have unwinder APIs
if deps.StaticUnwinderIfLegacy {
- depTag := libraryDependencyTag{Kind: staticLibraryDependency, staticUnwinder: true}
+ depTag := libraryDependencyTag{Kind: staticLibraryDependency, staticUnwinder: true, fromStatic: c.static()}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, depTag, staticUnwinder(actx))
@@ -2630,7 +2633,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
var sharedLibNames []string
for _, lib := range deps.SharedLibs {
- depTag := libraryDependencyTag{Kind: sharedLibraryDependency}
+ depTag := libraryDependencyTag{Kind: sharedLibraryDependency, fromStatic: c.static()}
if inList(lib, deps.ReexportSharedLibHeaders) {
depTag.reexportFlags = true
}
@@ -2651,14 +2654,14 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
for _, lib := range deps.LateStaticLibs {
- depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency}
+ depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency, fromStatic: c.static()}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, depTag, lib)
}
for _, lib := range deps.UnexportedStaticLibs {
- depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency, unexportedSymbols: true}
+ depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency, unexportedSymbols: true, fromStatic: c.static()}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, depTag, lib)
@@ -2671,7 +2674,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
// linking against both the stubs lib and the non-stubs lib at the same time.
continue
}
- depTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency}
+ depTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency, fromStatic: c.static()}
variations := []blueprint.Variation{
{Mutator: "link", Variation: "shared"},
}
@@ -2719,7 +2722,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
version := ctx.sdkVersion()
- ndkStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, ndk: true, makeSuffix: "." + version}
+ ndkStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, ndk: true, makeSuffix: "." + version, fromStatic: c.static()}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "version", Variation: version},
{Mutator: "link", Variation: "shared"},
@@ -2729,7 +2732,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
{Mutator: "link", Variation: "shared"},
}, ndkStubDepTag, apiNdkLibs...)
- ndkLateStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency, ndk: true, makeSuffix: "." + version}
+ ndkLateStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency, ndk: true, makeSuffix: "." + version, fromStatic: c.static()}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "version", Variation: version},
{Mutator: "link", Variation: "shared"},
@@ -3771,7 +3774,7 @@ func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
if cc.IsLlndk() {
return false
}
- if isLibDepTag && c.static() && libDepTag.shared() {
+ if isLibDepTag && libDepTag.fromStatic && libDepTag.shared() {
// shared_lib dependency from a static lib is considered as crossing
// the APEX boundary because the dependency doesn't actually is
// linked; the dependency is used only during the compilation phase.
diff --git a/cc/linkable.go b/cc/linkable.go
index 1a9a9abbc..1fade717a 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -294,8 +294,8 @@ func DepTagMakeSuffix(depTag blueprint.DependencyTag) string {
}
// SharedDepTag returns the dependency tag for any C++ shared libraries.
-func SharedDepTag() blueprint.DependencyTag {
- return libraryDependencyTag{Kind: sharedLibraryDependency}
+func SharedDepTag(fromStatic bool) blueprint.DependencyTag {
+ return libraryDependencyTag{Kind: sharedLibraryDependency, fromStatic: fromStatic}
}
// StaticDepTag returns the dependency tag for any C++ static libraries.
diff --git a/rust/rust.go b/rust/rust.go
index eeb228ceb..1417c0881 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -1683,7 +1683,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
for _, lib := range deps.SharedLibs {
- depTag := cc.SharedDepTag()
+ depTag := cc.SharedDepTag(mod.Static())
name, version := cc.StubsLibNameAndVersion(lib)
variations := []blueprint.Variation{
diff --git a/rust/sanitize.go b/rust/sanitize.go
index b8f922fe2..4c82de5e8 100644
--- a/rust/sanitize.go
+++ b/rust/sanitize.go
@@ -281,7 +281,7 @@ func rustSanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
} else {
variations = append(variations,
blueprint.Variation{Mutator: "link", Variation: "shared"})
- depTag = cc.SharedDepTag()
+ depTag = cc.SharedDepTag(mod.Static())
deps = []string{config.LibclangRuntimeLibrary(mod.toolchain(mctx), "asan")}
}
} else if mod.IsSanitizerEnabled(cc.Hwasan) {
@@ -296,7 +296,7 @@ func rustSanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
// library during final link if necessary
variations = append(variations,
blueprint.Variation{Mutator: "link", Variation: "shared"})
- depTag = cc.SharedDepTag()
+ depTag = cc.SharedDepTag(mod.Static())
deps = []string{config.LibclangRuntimeLibrary(mod.toolchain(mctx), "hwasan")}
}