Skip to content

Commit 6b4ac76

Browse files
committed
Reland "[lldb][test] Only add -m(64|32) for GCC on non Arm/AArch64 platforms"
This reverts commit fd5206c. 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.
1 parent 601e8fd commit 6b4ac76

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lldb/test/Shell/helper/build.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,21 @@ def __init__(self, toolchain_type, args):
743743
cmd = ["xcrun", "--sdk", args.apple_sdk, "--show-sdk-path"]
744744
self.apple_sdk = subprocess.check_output(cmd).strip().decode("utf-8")
745745

746+
def _add_m_option_if_needed(self, args):
747+
# clang allows -m(32|64) for any target, gcc does not.
748+
uname = platform.uname().machine.lower()
749+
if self.toolchain_type != "gcc" or (
750+
not "arm" in uname and not "aarch64" in uname
751+
):
752+
args.append("-m" + self.arch)
753+
754+
return args
755+
746756
def _get_compilation_command(self, source, obj):
747757
args = []
748758

749759
args.append(self.compiler)
750-
args.append("-m" + self.arch)
760+
args = self._add_m_option_if_needed(args)
751761

752762
args.append("-g")
753763
if self.opt == "none":
@@ -784,7 +794,8 @@ def _get_compilation_command(self, source, obj):
784794
def _get_link_command(self):
785795
args = []
786796
args.append(self.compiler)
787-
args.append("-m" + self.arch)
797+
args = self._add_m_option_if_needed(args)
798+
788799
if self.nodefaultlib:
789800
args.append("-nostdlib")
790801
args.append("-static")

0 commit comments

Comments
 (0)