[Lldb-commits] [lldb] [lldb] Set default object format to `MachO` in `ObjectFileMachO` (PR #142704)

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 5 16:18:54 PDT 2025


jasonmolenda wrote:

In `ArchSpec::SetArchitecture` if we passed in the vendor in addition to the architecture, that would set the ObjectFile to MachO correctly *without* calling `Triple::setObjectFormat` which adds the object file name to the triple as an environment, if there is no environment.  something like 

```
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index 70b9800f4da..aead2f7f364 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -887,6 +887,9 @@ bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu,
         // Always use the architecture name because it might be more
         // descriptive than the architecture enum ("armv7" ->
         // llvm::Triple::arm).
+        std::string initial_triple = core_def->name;
+        if (arch_type == eArchTypeMachO)
+          initial_triple += "-apple-";
         m_triple.setArchName(llvm::StringRef(core_def->name));
         if (arch_type == eArchTypeMachO) {
           m_triple.setVendor(llvm::Triple::Apple);
```

although that's not very prettily done.

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


More information about the lldb-commits mailing list