[clang] Add no-rosegment by default for API 29 and earlier. (PR #117611)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 25 11:07:30 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-driver

Author: AdityaK (hiraditya)

<details>
<summary>Changes</summary>

Details in: https://github.com/android/ndk/issues/1196
Fixes: https://github.com/android/ndk/issues/1294

---
Full diff: https://github.com/llvm/llvm-project/pull/117611.diff


1 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Linux.cpp (+8) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index d1cb625613415b..5cc3d6feaa434f 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -256,6 +256,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
       ExtraOpts.push_back("-z");
       ExtraOpts.push_back("max-page-size=16384");
     }
+    if (Triple.isAndroidVersionLT(29)) {
+      // https://github.com/android/ndk/issues/1196
+      // The unwinder used by the crash handler on versions of Android prior to
+      // API 29 did not correctly handle binaries built with rosegment, which is
+      // enabled by default for LLD. Android only supports LLD, so it's not an
+      // issue that this flag is not accepted by other linkers.
+      ExtraOpts.push_back("--no-rosegment");
+    }
   }
 
   if (GCCInstallation.getParentLibPath().contains("opt/rh/"))

``````````

</details>


https://github.com/llvm/llvm-project/pull/117611


More information about the cfe-commits mailing list