From 4c57596b811645d56301a8026489a500ead0852f Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 25 Aug 2020 17:05:41 +0900 Subject: [PATCH] Don't enable version lib for libadb_sysdeps When use_version_lib is set to true, but build::GetBuildNumber() isn't used, the library can't be processed by symbol_inject. For example, $ m out/soong/.intermediates/system/core/adb/libadb_sysdeps/android/arm64_armv8-a_shared/versioned/libadb_sysdeps.so FAILED: out/soong/.intermediates/system/core/adb/libadb_sysdeps/android_arm64_armv8-a_shared/versioned/libadb_sysdeps.so out/soong/host/linux-x86/bin/symbol_inject -i out/soong/.intermediates/system/core/adb/libadb_sysdeps/android_arm64_armv8-a_shared/unstripped/libadb_sysdeps.so -o out/soong/.intermediates/system/core/adb/libadb_sysdeps/android_arm64_armv8-a_shared/versioned/libadb_sysdeps.so -s soong_build_number -from 'SOONG BUILD NUMBER PLACEHOLDER' -v $(cat out/soong/build_number.txt) symbol not found 17:09:10 ninja failed with: exit status 1 This is because the visibility of the symbol `soong_build_number` in libbuildversion.a is hidden via the -fvisibility=hidden flag for the library. In addition, -Wl,--gc-sections strips the hidden symbol when it is not referenced. This fortunately hasn't caused a problem because, for the device target, the output of symbol_inject was used only for dist outputs. libadb_sysdeps wasn't registered as dists. So versioned/libadb_sysprops.so never had a chance to be built. For the host target, in the other hand, the output of symbol_inject is used always, but --gc-sections is not used for host targets. So the symbol wasn't stripped and therefore symbol_inject could always find the symbol. This however is expected to cause a problem when the support for LinuxCross is added. It is one of the host targets, therefore symbol_inject is always used. However, unlike other host targets, --gc-sections is turned on because it inherits most of the flags from Android/ARM64. To avoid the problem, we might want to disable --gc-sections for the target. But regardless of the decision, having a build rule that always fails is not desirable - even though the build rule is essentially never triggered. Therefore, we choose to not use version lib for libadb_sysdeps because GetBuildNumber() is not used in the lib. Bug: 159685774 Test: m \ out/soong/.intermediates/system/core/adb/libadb_sysdeps/android/\ arm64_armv8-a_shared/versioned/libadb_sysdeps.so Change-Id: Ide1056b5b55e409ab809e302a697d10d759c92ce --- adb/Android.bp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adb/Android.bp b/adb/Android.bp index 8addf95aa..5351b3fbb 100644 --- a/adb/Android.bp +++ b/adb/Android.bp @@ -270,6 +270,8 @@ cc_library { host_supported: true, compile_multilib: "both", min_sdk_version: "apex_inherit", + // This library doesn't use build::GetBuildNumber() + use_version_lib: false, srcs: [ "sysdeps/env.cpp",