summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Cotty <raphael.cotty@gmail.com>2021-09-01 14:09:12 +0200
committerRaphaël Cotty <raphael.cotty@gmail.com>2021-09-03 10:37:31 +0000
commit21184c9d9eb42592a9f14f2235e634ac0b4a4e6d (patch)
treecebf1da1978da89355a4ac4a2f2efa11486658c3
parentfab34969088f950d2206eca027ef972e2e0075d2 (diff)
downloadqbs-21184c9d9eb42592a9f14f2235e634ac0b4a4e6d.tar.gz
Android: Add buildId option to the ndk for the linker
Allow to overwrite default value (sha1) for the --build-id linker flag. Task-number: QBS-1668 Change-Id: Ib26904019eb68c94d345d0e33648b04ccf830de1 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--doc/reference/modules/android-ndk-module.qdoc11
-rw-r--r--share/qbs/modules/Android/ndk/ndk.qbs14
-rw-r--r--share/qbs/modules/Android/ndk/utils.js5
-rw-r--r--share/qbs/modules/cpp/android-gcc.qbs2
4 files changed, 29 insertions, 3 deletions
diff --git a/doc/reference/modules/android-ndk-module.qdoc b/doc/reference/modules/android-ndk-module.qdoc
index 4740480b3..d3b16e2bf 100644
--- a/doc/reference/modules/android-ndk-module.qdoc
+++ b/doc/reference/modules/android-ndk-module.qdoc
@@ -78,6 +78,17 @@
*/
/*!
+ \qmlproperty string Android.ndk::buildId
+
+ Value to pass to the --build-id linker flag.
+ Plain --build-id option is used when buildId property is empty.
+
+ \since Qbs 1.21
+
+ \defaultvalue \c "sha1"
+*/
+
+/*!
\qmlproperty string Android.ndk::appStl
The library to use for C++. The possible values are:
diff --git a/share/qbs/modules/Android/ndk/ndk.qbs b/share/qbs/modules/Android/ndk/ndk.qbs
index 39042c086..3b223e4fb 100644
--- a/share/qbs/modules/Android/ndk/ndk.qbs
+++ b/share/qbs/modules/Android/ndk/ndk.qbs
@@ -50,6 +50,20 @@ Module {
description: "Supported Android ABIs"
allowedValues: ["arm64-v8a", "armeabi-v7a", "x86", "x86_64"]
}
+ // From https://android.googlesource.com/platform/ndk/+/refs/heads/ndk-release-r21/docs/BuildSystemMaintainers.md
+ // Android Studio‘s LLDB debugger uses a binary’s build ID to locate debug information. To
+ // ensure that LLDB works with a binary, pass an option like -Wl,--build-id=sha1 to Clang when
+ // linking. Other --build-id= modes are OK, but avoid a plain --build-id argument when using
+ // LLD, because Android Studio‘s version of LLDB doesn’t recognize LLD's default 8-byte build
+ // ID. See Issue 885.
+
+ // Plain --build-id option is nevertheless implemented when buildId property is empty.
+
+ // Possible values (from man page of ld.lld — ELF linker from the LLVM project):
+ // one of fast, md5, sha1, tree, uuid, 0xhex-string, and none. tree is an alias for sha1.
+ // Build-IDs of type fast, md5, sha1, and tree are calculated from the object contents. fast is
+ // not intended to be cryptographically secure.
+ property string buildId: "sha1"
// See https://developer.android.com/ndk/guides/cpp-support.html
property string appStl: "c++_shared"
diff --git a/share/qbs/modules/Android/ndk/utils.js b/share/qbs/modules/Android/ndk/utils.js
index e763ed9b6..ab312921e 100644
--- a/share/qbs/modules/Android/ndk/utils.js
+++ b/share/qbs/modules/Android/ndk/utils.js
@@ -96,8 +96,9 @@ function commonCompilerFlags(toolchain, buildVariant, ndk) {
return flags;
}
-function commonLinkerFlags(abi) {
- return ["-z", "noexecstack", "-z", "relro", "-z", "now", "--build-id=sha1", "--gc-sections" ];
+function commonLinkerFlags(ndk) {
+ var buildId = (ndk.buildId) ? "--build-id=" + ndk.buildId : "--build-id";
+ return ["-z", "noexecstack", "-z", "relro", "-z", "now", buildId, "--gc-sections"];
}
function stlFileName(prefix, ndk, suffix) {
diff --git a/share/qbs/modules/cpp/android-gcc.qbs b/share/qbs/modules/cpp/android-gcc.qbs
index 17e1f72ed..a5061e166 100644
--- a/share/qbs/modules/cpp/android-gcc.qbs
+++ b/share/qbs/modules/cpp/android-gcc.qbs
@@ -100,7 +100,7 @@ LinuxGCC {
commonCompilerFlags: NdkUtils.commonCompilerFlags(qbs.toolchain, qbs.buildVariant, Android.ndk)
- linkerFlags: NdkUtils.commonLinkerFlags(Android.ndk.abi);
+ linkerFlags: NdkUtils.commonLinkerFlags(Android.ndk);
driverLinkerFlags: {
var flags = ["-fuse-ld=lld", "-Wl,--exclude-libs,libgcc.a", "-nostdlib++"];
// See https://android.googlesource.com/platform/ndk/+/ndk-release-r21/docs/BuildSystemMaintainers.md#Unwinding