[Lldb-commits] [lldb] 6b4ac76 - Reland "[lldb][test] Only add -m(64|32) for GCC on non Arm/AArch64 platforms"

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 10 05:37:33 PST 2023


Author: David Spickett
Date: 2023-11-10T13:36:23Z
New Revision: 6b4ac76504d120d44023618ef8240d4f907d08ca

URL: https://github.com/llvm/llvm-project/commit/6b4ac76504d120d44023618ef8240d4f907d08ca
DIFF: https://github.com/llvm/llvm-project/commit/6b4ac76504d120d44023618ef8240d4f907d08ca.diff

LOG: Reland "[lldb][test] Only add -m(64|32) for GCC on non Arm/AArch64 platforms"

This reverts commit fd5206cc55c820598d5145d799b18d66cc193356.

Fixing the test case would require some awkard %if use that I'm not
sure would even work, or splitting it into 2 copies that are almost
identical.

Instead, always add -m for clang, which allows it for all targets,
but not for gcc which does not.

Added: 
    

Modified: 
    lldb/test/Shell/helper/build.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index 2a04967c89bc305..073198a6df2df36 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -743,11 +743,21 @@ def __init__(self, toolchain_type, args):
             cmd = ["xcrun", "--sdk", args.apple_sdk, "--show-sdk-path"]
             self.apple_sdk = subprocess.check_output(cmd).strip().decode("utf-8")
 
+    def _add_m_option_if_needed(self, args):
+        # clang allows -m(32|64) for any target, gcc does not.
+        uname = platform.uname().machine.lower()
+        if self.toolchain_type != "gcc" or (
+            not "arm" in uname and not "aarch64" in uname
+        ):
+            args.append("-m" + self.arch)
+
+        return args
+
     def _get_compilation_command(self, source, obj):
         args = []
 
         args.append(self.compiler)
-        args.append("-m" + self.arch)
+        args = self._add_m_option_if_needed(args)
 
         args.append("-g")
         if self.opt == "none":
@@ -784,7 +794,8 @@ def _get_compilation_command(self, source, obj):
     def _get_link_command(self):
         args = []
         args.append(self.compiler)
-        args.append("-m" + self.arch)
+        args = self._add_m_option_if_needed(args)
+
         if self.nodefaultlib:
             args.append("-nostdlib")
             args.append("-static")


        


More information about the lldb-commits mailing list