aboutsummaryrefslogtreecommitdiffstats
path: root/apex
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2018-12-20 18:18:08 +0900
committerJiyong Park <jiyong@google.com>2018-12-21 18:01:39 +0900
commit16e91a067d13698c59323349d5251aab9dca479f (patch)
treec369b353de0dc695c3c88bc182cb4d10dd2158d6 /apex
parentda6eb592bfc991e2063de39d77a2f1886c9b92b5 (diff)
downloadbuild_soong-16e91a067d13698c59323349d5251aab9dca479f.tar.gz
build_soong-16e91a067d13698c59323349d5251aab9dca479f.tar.bz2
build_soong-16e91a067d13698c59323349d5251aab9dca479f.zip
Fix: static dependency across an APEX is lost
This change fixes following problem: 1) a native lib having stubs is defined. 2) the lib is included in an APEX. 3) a static binary is linking the lib from outside of the APEX. 4) then, the dependency from the binary to the lib is vanishing. This is happening because cc.depsToPaths() mistakely does not distinguish static lib deps from shared lib deps. For shared lib deps, it creates two dependencies (one for stubs variant and the other for non-stubs variant) and choose the stubs variant when the lib and the current module is not in the same APEX (i.e. dependency to the non-stubs variant is discarded). However, since we don't have stubs variant for static library, it ends up having no dependency to the library if the link is static. Fixing the issue by skipping the variant selection routine when the link is static. Test: m (apex_test added) Test: build with https://android-review.googlesource.com/c/platform/bionic/+/849044 Change-Id: I21102a31cc5c0b105da2affdd035bd5cc571a6ab
Diffstat (limited to 'apex')
-rw-r--r--apex/apex_test.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 77117c55..dd5bf708 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -41,6 +41,7 @@ func testApex(t *testing.T, bp string) *android.TestContext {
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory))
ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(cc.LibrarySharedFactory))
+ ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(cc.BinaryFactory))
ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory))
ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory))
ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory))
@@ -614,3 +615,54 @@ func TestUseVendor(t *testing.T) {
ensureNotContains(t, inputsString, "android_arm64_armv8-a_core_shared_myapex/mylib.so")
ensureNotContains(t, inputsString, "android_arm64_armv8-a_core_shared_myapex/mylib2.so")
}
+
+func TestStaticLinking(t *testing.T) {
+ ctx := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ native_shared_libs: ["mylib"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ stubs: {
+ versions: ["1", "2", "3"],
+ },
+ }
+
+ cc_binary {
+ name: "not_in_apex",
+ srcs: ["mylib.cpp"],
+ static_libs: ["mylib"],
+ static_executable: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_object {
+ name: "crtbegin_static",
+ stl: "none",
+ }
+
+ cc_object {
+ name: "crtend_android",
+ stl: "none",
+ }
+
+ `)
+
+ ldFlags := ctx.ModuleForTests("not_in_apex", "android_arm64_armv8-a_core").Rule("ld").Args["libFlags"]
+
+ // Ensure that not_in_apex is linking with the static variant of mylib
+ ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_core_static/mylib.a")
+}