Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lldb/packages/Python/lldbsuite/test/builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def getCompiler(self):

def getTriple(self, arch):
"""Returns the triple for the given architecture or None."""
return None
return configuration.triple

def getExtraMakeArgs(self):
"""
Expand All @@ -37,6 +37,9 @@ def getExtraMakeArgs(self):

def getArchCFlags(self, architecture):
"""Returns the ARCH_CFLAGS for the make system."""
triple = self.getTriple(architecture)
if triple:
return ["ARCH_CFLAGS=-target {}".format(triple)]
Copy link
Member

@dzhidzhoev dzhidzhoev Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work if ARCH_CFLAGS is overridden in the Makefile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Make, command-line variables have higher precedence than variables set in the Makefile itself, so this does not overwrite the value when it's passed by the builder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, thanks.

return []

def getMake(self, test_subdir, test_name):
Expand Down
4 changes: 4 additions & 0 deletions lldb/packages/Python/lldbsuite/test/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
sdkroot = None
make_path = None

# Allow specifying a triple for cross compilation.
triple = None

# The overriden dwarf verison.
# Don't use this to test the current compiler's
# DWARF version, as this won't be set if the
Expand Down Expand Up @@ -141,6 +144,7 @@
# Typical values include Debug, Release, RelWithDebInfo and MinSizeRel
cmake_build_type = None


def shouldSkipBecauseOfCategories(test_categories):
if use_categories:
if (
Expand Down
5 changes: 5 additions & 0 deletions lldb/packages/Python/lldbsuite/test/dotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,13 @@ def parseOptionsAndInitTestdirs():
logging.error("No SDK found with the name %s; aborting...", args.apple_sdk)
sys.exit(-1)

if args.triple:
configuration.triple = args.triple

if args.arch:
configuration.arch = args.arch
elif args.triple:
configuration.arch = args.triple.split("-")[0]
else:
configuration.arch = platform_machine

Expand Down
8 changes: 8 additions & 0 deletions lldb/packages/Python/lldbsuite/test/dotest_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ def create_parser():
"""Specify the path to sysroot. This overrides apple_sdk sysroot."""
),
)
group.add_argument(
"--triple",
metavar="triple",
dest="triple",
help=textwrap.dedent(
"""Specify the target triple. Used for cross compilation."""
),
)
if sys.platform == "darwin":
group.add_argument(
"--apple-sdk",
Expand Down
10 changes: 10 additions & 0 deletions lldb/packages/Python/lldbsuite/test/make/Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ else
endif
endif

#----------------------------------------------------------------------
# Use LLD when cross compiling on Darwin.
#----------------------------------------------------------------------
ifeq "$(HOST_OS)" "Darwin"
ifneq (,$(filter $(OS), FreeBSD Linux NetBSD Windows_NT))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(OS) is checked against "Android" in other places, I'd add that too.

LDFLAGS += -fuse-ld=lld
endif
endif


#----------------------------------------------------------------------
# ARCHFLAG is the flag used to tell the compiler which architecture
# to compile for. The default is the flag that clang accepts.
Expand Down
Loading