[Lldb-commits] [lldb] 7c58d4d - [lldb][AArch64] Fix launching Arm32 applications on AArch64 Linux (#211692)

via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 28 01:17:04 PDT 2026


Author: Igor Kudrin
Date: 2026-07-28T09:16:59+01:00
New Revision: 7c58d4de4af550ba3d54bf217f27a1e6b3736dbc

URL: https://github.com/llvm/llvm-project/commit/7c58d4de4af550ba3d54bf217f27a1e6b3736dbc
DIFF: https://github.com/llvm/llvm-project/commit/7c58d4de4af550ba3d54bf217f27a1e6b3736dbc.diff

LOG: [lldb][AArch64] Fix launching Arm32 applications on AArch64 Linux (#211692)

When LLDB runs on an AArch64 Linux, it adds both 64- and 32-bit
architectures as supported; see `PlatformLinux` ctor. The triple for the
32-bit variant is computed by replacing the architecture while keeping
all other fields; i.e., for the main host triple
`aarch64-unknown-linux-gnu`, the generated 32-bit triple is
`arm-unknown-linux-gnu`.

When a 32-bit target is created, its triple would be something like
`arm--linux-eabihf`. This triple is incompatible with the one added to
the supported architectures per condition in `ArchSpec::IsMatch()`,
which checks for compatibility between environments. As a result, LLDB
fails to launch this target:

```
> arm-linux-gnueabihf-g++ -g test.cpp -o test.out
> lldb
(lldb) file test.out
Current executable set to '/tmp/test.out' (arm).
(lldb) run
error: failed to launch or debug process
```

Clearing the environment of the computed triple for Arm32 allows the
compatibility check to pass.

---------

Co-authored-by: David Spickett <david.spickett at arm.com>

Added: 
    

Modified: 
    lldb/source/Host/linux/HostInfoLinux.cpp
    lldb/unittests/Host/HostInfoTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp
index bb929f18505ed..788f2bf7e0fb9 100644
--- a/lldb/source/Host/linux/HostInfoLinux.cpp
+++ b/lldb/source/Host/linux/HostInfoLinux.cpp
@@ -147,6 +147,16 @@ void HostInfoLinux::ComputeHostArchitectureSupport(ArchSpec &arch_32,
   if (arch_32.IsValid()) {
     if (arch_32.GetTriple().getVendor() == llvm::Triple::UnknownVendor)
       arch_32.GetTriple().setVendorName(llvm::StringRef());
+    // For AArch64 and Arm (32-bit) Linux, the environment components will not
+    // match. For example "aarch64-unkown-linux-gnu" vs.
+    // "arm-unknown-linux-gnueabi". We can safely ignore the environment
+    // component because any of the Arm environments can run on an Armv8.0+
+    // machine that has AArch32 mode, because they all have hardware floating
+    // point support (and whether the machine has the right C library and 32-bit
+    // libraries installed is not lldb's concern).
+    if (arch_64.IsValid() && arch_64.GetTriple().isAArch64() &&
+        arch_64.GetTriple().getEnvironment() == llvm::Triple::GNU)
+      arch_32.GetTriple().setEnvironment(llvm::Triple::UnknownEnvironment);
   }
   if (arch_64.IsValid()) {
     if (arch_64.GetTriple().getVendor() == llvm::Triple::UnknownVendor)

diff  --git a/lldb/unittests/Host/HostInfoTest.cpp b/lldb/unittests/Host/HostInfoTest.cpp
index 0b3bae5c56f2f..997091ff2be3c 100644
--- a/lldb/unittests/Host/HostInfoTest.cpp
+++ b/lldb/unittests/Host/HostInfoTest.cpp
@@ -132,3 +132,11 @@ TEST_F(HostInfoTest, FindComponentInPath) {
   EXPECT_EQ("", HostInfoTester::FindComponentInPath("/path/to/foo", "bar"));
 }
 #endif
+
+#if defined(__linux__) && defined(__aarch64__)
+TEST_F(HostInfoTest, Arm32OnAArch64Compatibility) {
+  ArchSpec host_spec = HostInfo::GetArchitecture(HostInfo::eArchKind32);
+  ArchSpec target_spec("arm--linux-eabihf");
+  EXPECT_TRUE(target_spec.IsCompatibleMatch(host_spec));
+}
+#endif


        


More information about the lldb-commits mailing list