[Lldb-commits] [lldb] [lldb] Rally around triple rather than arch in the API tests (PR #191416)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 17 10:53:18 PDT 2026
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/191416
>From acf92b073ac9e5e0f4f31f7b03c70e54c0ac4599 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 10 Apr 2026 12:35:20 +0100
Subject: [PATCH 1/5] [lldb] Rally around triple rather than arch in the API
tests
---
.../Python/lldbsuite/test/builders/builder.py | 27 ++---
.../Python/lldbsuite/test/builders/darwin.py | 113 ++++++------------
.../Python/lldbsuite/test/configuration.py | 3 +-
lldb/packages/Python/lldbsuite/test/dotest.py | 9 +-
.../Python/lldbsuite/test/dotest_args.py | 22 +---
.../Python/lldbsuite/test/lldbplatformutil.py | 2 +-
.../Python/lldbsuite/test/make/Makefile.rules | 110 ++++-------------
.../expression/ptrauth-auth-traps/Makefile | 2 +-
.../commands/expression/ptrauth-objc/Makefile | 2 +-
.../expression/ptrauth-vtable/Makefile | 2 +-
.../API/commands/expression/ptrauth/Makefile | 2 +-
lldb/test/API/lang/c/ptrauth/Makefile | 2 +-
12 files changed, 87 insertions(+), 209 deletions(-)
diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 00ead78096116..08c55b98876b8 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -24,8 +24,8 @@ def getCompiler(self):
compiler = lldbutil.which(compiler)
return os.path.abspath(compiler)
- def getTriple(self, arch):
- """Returns the triple for the given architecture or None."""
+ def getTriple(self):
+ """Returns the triple."""
return configuration.triple
def getExtraMakeArgs(self):
@@ -35,11 +35,15 @@ def getExtraMakeArgs(self):
"""
return []
- def getArchCFlags(self, architecture):
- """Returns the ARCH_CFLAGS for the make system."""
- triple = self.getTriple(architecture)
+ def getTripleSpec(self):
+ """Returns the TRIPLE for the make system."""
+ triple = self.getTriple()
if triple:
- return ["ARCH_CFLAGS=-target {}".format(triple)]
+ return ["TRIPLE=" + triple]
+ return []
+
+ def getArchCFlags(self):
+ """Returns the ARCH_CFLAGS for the make system."""
return []
def getMake(self, test_subdir, test_name):
@@ -95,13 +99,6 @@ def setOrAppendVariable(k, v):
return cmdline
- def getArchSpec(self, architecture):
- """
- Helper function to return the key-value string to specify the architecture
- used for the make system.
- """
- return ["ARCH=" + architecture] if architecture else []
-
def getToolchainSpec(self, compiler):
"""
Helper function to return the key-value strings to specify the toolchain
@@ -294,8 +291,8 @@ def getBuildCommand(
self.getMake(testdir, testname),
debug_info_args,
make_targets,
- self.getArchCFlags(architecture),
- self.getArchSpec(architecture),
+ self.getArchCFlags(),
+ self.getTripleSpec(),
self.getToolchainSpec(compiler),
self.getExtraMakeArgs(),
self.getSDKRootSpec(),
diff --git a/lldb/packages/Python/lldbsuite/test/builders/darwin.py b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
index eebe0ef47fd85..78bd4dc9e8565 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -6,69 +6,23 @@
from lldbsuite.test import configuration
import lldbsuite.test.lldbutil as lldbutil
-REMOTE_PLATFORM_NAME_RE = re.compile(r"^remote-(.+)$")
-SIMULATOR_PLATFORM_RE = re.compile(r"^(.+)-simulator$")
+TRIPLE_RE = re.compile(
+ r"^(?P<arch>[a-zA-Z0-9_]+)" # arch (required)
+ r"(?:-(?P<vendor>[a-zA-Z0-9_]+))?" # vendor (optional)
+ r"(?:-(?P<os>[a-zA-Z_]+)(?P<os_version>[\d.]+)?)?" # os + version (optional)
+ r"(?:-(?P<env>[a-zA-Z0-9_]+))?" # env/abi (optional)
+ r"$"
+)
-def get_os_env_from_platform(platform):
- match = REMOTE_PLATFORM_NAME_RE.match(platform)
- if match:
- return match.group(1), ""
- match = SIMULATOR_PLATFORM_RE.match(platform)
- if match:
- return match.group(1), "simulator"
- return None, None
-
-
-def get_os_from_sdk(sdk):
- return sdk[: sdk.find(".")], ""
-
-
-def get_os_and_env():
- if configuration.lldb_platform_name:
- return get_os_env_from_platform(configuration.lldb_platform_name)
- if configuration.apple_sdk:
- return get_os_from_sdk(configuration.apple_sdk)
- return None, None
-
-
-def get_triple():
- # Construct the vendor component.
- vendor = "apple"
-
- # Construct the os component.
- os, env = get_os_and_env()
- if os is None or env is None:
- return None, None, None, None
-
- # Get the SDK from the os and env.
- sdk = lldbutil.get_xcode_sdk(os, env)
- if sdk is None:
- return None, None, None, None
-
- # Get the version from the SDK.
- version = lldbutil.get_xcode_sdk_version(sdk)
- if version is None:
- return None, None, None, None
-
- return vendor, os, version, env
-
-
-def get_triple_str(arch, vendor, os, version, env):
- if None in [arch, vendor, os, version, env]:
- return None
-
- component = [arch, vendor, os + version]
- if env:
- component.append(env)
- return "-".join(component)
+def split_triple(triple):
+ m = TRIPLE_RE.match(triple)
+ if m:
+ return m["arch"], m["vendor"], m["os"], m["os_version"], m["env"]
+ return None, None, None, None, None
class BuilderDarwin(Builder):
- def getTriple(self, arch):
- vendor, os, version, env = get_triple()
- return get_triple_str(arch, vendor, os, version, env)
-
def getExtraMakeArgs(self):
"""
Helper function to return extra argumentsfor the make system. This
@@ -87,39 +41,40 @@ def getExtraMakeArgs(self):
)
args["FRAMEWORK_INCLUDES"] = "-F{}".format(private_frameworks)
- operating_system, env = get_os_and_env()
+ triple = self.getTriple()
+ if triple:
+ _, _, operating_system, _, env = split_triple(triple)
- builder_dir = os.path.dirname(os.path.abspath(__file__))
- test_dir = os.path.dirname(builder_dir)
- if not operating_system:
- entitlements_file = "entitlements-macos.plist"
- else:
- if env == "simulator":
- entitlements_file = "entitlements-simulator.plist"
+ builder_dir = os.path.dirname(os.path.abspath(__file__))
+ test_dir = os.path.dirname(builder_dir)
+ if operating_system in [None, "darwin", "macos", "macosx"]:
+ entitlements_file = "entitlements-macos.plist"
else:
- entitlements_file = "entitlements.plist"
- entitlements = os.path.join(test_dir, "make", entitlements_file)
- args["CODESIGN"] = "codesign --entitlements {}".format(entitlements)
+ if env == "simulator":
+ entitlements_file = "entitlements-simulator.plist"
+ else:
+ entitlements_file = "entitlements.plist"
+ entitlements = os.path.join(test_dir, "make", entitlements_file)
+ args["CODESIGN"] = "codesign --entitlements {}".format(entitlements)
# Return extra args as a formatted string.
return ["{}={}".format(key, value) for key, value in args.items()]
- def getArchCFlags(self, arch):
+ def getArchCFlags(self):
"""Returns the ARCH_CFLAGS for the make system."""
# Get the triple components.
- vendor, os, version, env = get_triple()
- triple = get_triple_str(arch, vendor, os, version, env)
+ triple = self.getTriple()
if not triple:
return []
- # Construct min version argument
- version_min = ""
- if env == "simulator":
- version_min = "-m{}-simulator-version-min={}".format(os, version)
- else:
- version_min = "-m{}-version-min={}".format(os, version)
+ _, _, os, version, _ = split_triple(triple)
+
+ if os == "darwin" or not version:
+ return []
+
+ target_os = "-mtargetos={}{}".format(os, version)
- return ["ARCH_CFLAGS=-target {} {}".format(triple, version_min)]
+ return ["ARCH_CFLAGS={}".format(target_os)]
def _getDebugInfoArgs(self, debug_info):
if debug_info == "dsym":
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py
index dde1a5e52be47..d1c933b35fcdf 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -39,7 +39,8 @@
# Test suite repeat count. Can be overwritten with '-# count'.
count = 1
-# The 'arch' and 'compiler' can be specified via command line.
+# The 'arch' is derived from the triple. The 'compiler' can be specified via
+# command line.
arch = None
compiler = None
dsymutil = None
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 9b84375ba8e17..7f73fce14bcdd 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -338,12 +338,9 @@ def parseOptionsAndInitTestdirs():
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
+ configuration.arch = (
+ configuration.triple.split("-")[0] if configuration.triple else platform_machine
+ )
if args.categories_list:
configuration.categories_list = set(
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 4c0a67203755e..854507b3b3abd 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -32,12 +32,11 @@ def create_parser():
# C and Python toolchain options
group = parser.add_argument_group("Toolchain options")
group.add_argument(
- "-A",
- "--arch",
- metavar="arch",
- dest="arch",
+ "--triple",
+ metavar="triple",
+ dest="triple",
help=textwrap.dedent(
- """Specify the architecture(s) to test. This option can be specified more than once"""
+ """Specify the target triple to test with (e.g. x86_64-unknown-linux-gnu, arm64-apple-macosx)."""
),
)
group.add_argument(
@@ -58,14 +57,6 @@ 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",
@@ -94,13 +85,12 @@ def create_parser():
"Specify the path to a custom libc++ library directory. Must be used in conjunction with --libcxx-include-dir."
),
)
- # FIXME? This won't work for different extra flags according to each arch.
+ # FIXME? This won't work for different extra flags according to each triple.
group.add_argument(
"-E",
metavar="extra-flags",
help=textwrap.dedent(
- """Specify the extra flags to be passed to the toolchain when building the inferior programs to be debugged
- suggestions: do not lump the "-A arch1 -A arch2" together such that the -E option applies to only one of the architectures"""
+ """Specify the extra flags to be passed to the toolchain when building the inferior programs to be debugged"""
),
)
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 39b52d6844bee..a3fab6e49c2a7 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -345,7 +345,7 @@ def getDwarfVersion():
return str(configuration.dwarf_version)
if "clang" in getCompiler():
try:
- triple = builder_module().getTriple(getArchitecture())
+ triple = builder_module().getTriple()
target = ["-target", triple] if triple else []
driver_output = subprocess.check_output(
[getCompiler()] + target + "-g -c -x c - -o - -###".split(),
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 6c197a2317bf7..5cff3f5d91539 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -109,25 +109,33 @@ else
endif
#----------------------------------------------------------------------
-# If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more
-# from the triple alone
+# Determine the target triple. The triple is the canonical way to
+# specify the target. When only ARCH is provided we query the compiler
+# for its default triple and replace the arch component.
#----------------------------------------------------------------------
ARCH_CFLAGS :=
ifeq "$(OS)" "Android"
include $(THIS_FILE_DIR)/Android.rules
endif
-#----------------------------------------------------------------------
-# If ARCH is not defined, default to x86_64.
-#----------------------------------------------------------------------
-ifeq "$(ARCH)" ""
-ifeq "$(OS)" "Windows_NT"
- ARCH = x86
-else
- ARCH = x86_64
+ifeq "$(TRIPLE)" ""
+ ifeq "$(ARCH)" ""
+ # No triple, no arch: query the compiler for its default triple.
+ TRIPLE := $(shell $(CC) --print-target-triple)
+ else
+ # ARCH but no TRIPLE: replace the arch in the compiler's default triple.
+ TRIPLE := $(shell $(CC) --print-target-triple | sed 's/^[^-]*/$(ARCH)/')
+ endif
endif
+
+# Derive ARCH from the first component of the triple if not already set.
+ifeq "$(ARCH)" ""
+ ARCH := $(firstword $(subst -, ,$(TRIPLE)))
endif
+# Use -target to pass the triple to the compiler.
+ARCH_CFLAGS := -target $(TRIPLE)
+
#----------------------------------------------------------------------
# CC defaults to clang.
#
@@ -182,12 +190,10 @@ ifeq "$(HOST_OS)" "Darwin"
endif
endif
-
-#----------------------------------------------------------------------
-# ARCHFLAG is the flag used to tell the compiler which architecture
-# to compile for. The default is the flag that clang accepts.
-#----------------------------------------------------------------------
-ARCHFLAG ?= -arch
+# Detect x86 from ARCH.
+ifneq (,$(filter amd64 x86_64 x64 x86 i386 i686,$(ARCH)))
+ IS_X86 := 1
+endif
#----------------------------------------------------------------------
# Change any build/tool options needed
@@ -198,68 +204,6 @@ ifeq "$(OS)" "Darwin"
DSYM = $(EXE).dSYM
ARFLAGS := -static -o
else
- # On non-Apple platforms, -arch becomes -m
- ARCHFLAG := -m
-
- # i386, i686, x86 -> 32
- # amd64, x86_64, x64 -> 64
- ifeq "$(ARCH)" "amd64"
- override ARCH := $(subst amd64,64,$(ARCH))
- IS_X86 := 1
- endif
- ifeq "$(ARCH)" "x86_64"
- override ARCH := $(subst x86_64,64,$(ARCH))
- IS_X86 := 1
- endif
- ifeq "$(ARCH)" "x64"
- override ARCH := $(subst x64,64,$(ARCH))
- IS_X86 := 1
- endif
- ifeq "$(ARCH)" "x86"
- override ARCH := $(subst x86,32,$(ARCH))
- IS_X86 := 1
- endif
- ifeq "$(ARCH)" "i386"
- override ARCH := $(subst i386,32,$(ARCH))
- IS_X86 := 1
- endif
- ifeq "$(ARCH)" "i686"
- override ARCH := $(subst i686,32,$(ARCH))
- IS_X86 := 1
- endif
- ifeq "$(ARCH)" "powerpc"
- override ARCH := $(subst powerpc,32,$(ARCH))
- endif
- ifeq "$(ARCH)" "powerpc64"
- override ARCH := $(subst powerpc64,64,$(ARCH))
- endif
- ifeq "$(ARCH)" "powerpc64le"
- override ARCH := $(subst powerpc64le,64,$(ARCH))
- endif
- ifeq "$(ARCH)" "aarch64"
- override ARCH :=
- override ARCHFLAG :=
- endif
- ifeq "$(findstring arm,$(ARCH))" "arm"
- override ARCH :=
- override ARCHFLAG :=
- endif
- ifeq "$(ARCH)" "s390x"
- override ARCH :=
- override ARCHFLAG :=
- endif
- ifeq "$(ARCH)" "riscv"
- override ARCH :=
- override ARCHFLAG :=
- endif
- ifeq "$(findstring mips,$(ARCH))" "mips"
- override ARCHFLAG := -
- endif
- ifeq "$(findstring loongarch,$(ARCH))" "loongarch"
- override ARCH :=
- override ARCHFLAG :=
- endif
-
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
@@ -296,9 +240,7 @@ CFLAGS ?= $(DEBUG_INFO_FLAG) -O0
CFLAGS += $(SYSROOT_FLAGS)
ifeq "$(OS)" "Darwin"
- CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES)
-else
- CFLAGS += $(ARCHFLAG)$(ARCH)
+ CFLAGS += $(FRAMEWORK_INCLUDES)
endif
CFLAGS += -I$(LLDB_BASE_DIR)/include -I$(LLDB_OBJ_ROOT)/include
@@ -311,11 +253,7 @@ endif
CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS)
# Use this one if you want to build one part of the result without debug information:
-ifeq "$(OS)" "Darwin"
- CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS)
-else
- CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS)
-endif
+CFLAGS_NO_DEBUG = -O0 $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS)
ifeq "$(MAKE_DWO)" "YES"
CFLAGS += -gsplit-dwarf
diff --git a/lldb/test/API/commands/expression/ptrauth-auth-traps/Makefile b/lldb/test/API/commands/expression/ptrauth-auth-traps/Makefile
index ac50baa81423e..ab0fd9a46e7ed 100644
--- a/lldb/test/API/commands/expression/ptrauth-auth-traps/Makefile
+++ b/lldb/test/API/commands/expression/ptrauth-auth-traps/Makefile
@@ -1,5 +1,5 @@
C_SOURCES := main.c
-override ARCH := arm64e
+override TRIPLE := arm64e-apple-darwin
include Makefile.rules
diff --git a/lldb/test/API/commands/expression/ptrauth-objc/Makefile b/lldb/test/API/commands/expression/ptrauth-objc/Makefile
index 496df2948ac1b..c66c41ccfbbae 100644
--- a/lldb/test/API/commands/expression/ptrauth-objc/Makefile
+++ b/lldb/test/API/commands/expression/ptrauth-objc/Makefile
@@ -1,6 +1,6 @@
OBJC_SOURCES := main.m
-override ARCH := arm64e
+override TRIPLE := arm64e-apple-darwin
# We need an arm64e stdlib.
USE_SYSTEM_STDLIB := 1
diff --git a/lldb/test/API/commands/expression/ptrauth-vtable/Makefile b/lldb/test/API/commands/expression/ptrauth-vtable/Makefile
index 3c6bc2dd007e1..46852554c4e25 100644
--- a/lldb/test/API/commands/expression/ptrauth-vtable/Makefile
+++ b/lldb/test/API/commands/expression/ptrauth-vtable/Makefile
@@ -1,6 +1,6 @@
CXX_SOURCES := main.cpp
-override ARCH := arm64e
+override TRIPLE := arm64e-apple-darwin
# We need an arm64e stblib.
USE_SYSTEM_STDLIB := 1
diff --git a/lldb/test/API/commands/expression/ptrauth/Makefile b/lldb/test/API/commands/expression/ptrauth/Makefile
index ac50baa81423e..ab0fd9a46e7ed 100644
--- a/lldb/test/API/commands/expression/ptrauth/Makefile
+++ b/lldb/test/API/commands/expression/ptrauth/Makefile
@@ -1,5 +1,5 @@
C_SOURCES := main.c
-override ARCH := arm64e
+override TRIPLE := arm64e-apple-darwin
include Makefile.rules
diff --git a/lldb/test/API/lang/c/ptrauth/Makefile b/lldb/test/API/lang/c/ptrauth/Makefile
index 0b4de8245f908..ad36d69b5e072 100644
--- a/lldb/test/API/lang/c/ptrauth/Makefile
+++ b/lldb/test/API/lang/c/ptrauth/Makefile
@@ -1,5 +1,5 @@
LEVEL = ../../../make
-override ARCH := arm64e
+override TRIPLE := arm64e-apple-darwin
CFLAGS_EXTRAS = -fptrauth-calls -fptrauth-intrinsics
C_SOURCES := main.c
>From aa1f6b3e055ae194a5e70d373fe1d4eb14699a9d Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 10 Apr 2026 16:03:22 +0100
Subject: [PATCH 2/5] Address David's feedback
---
.../Python/lldbsuite/test/builders/builder.py | 1 -
.../Python/lldbsuite/test/builders/darwin.py | 22 +++++++++----------
.../Python/lldbsuite/test/dotest_args.py | 2 +-
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 08c55b98876b8..03c1af579b018 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -25,7 +25,6 @@ def getCompiler(self):
return os.path.abspath(compiler)
def getTriple(self):
- """Returns the triple."""
return configuration.triple
def getExtraMakeArgs(self):
diff --git a/lldb/packages/Python/lldbsuite/test/builders/darwin.py b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
index 78bd4dc9e8565..60a0fd418f5e6 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -7,19 +7,19 @@
import lldbsuite.test.lldbutil as lldbutil
TRIPLE_RE = re.compile(
- r"^(?P<arch>[a-zA-Z0-9_]+)" # arch (required)
- r"(?:-(?P<vendor>[a-zA-Z0-9_]+))?" # vendor (optional)
- r"(?:-(?P<os>[a-zA-Z_]+)(?P<os_version>[\d.]+)?)?" # os + version (optional)
- r"(?:-(?P<env>[a-zA-Z0-9_]+))?" # env/abi (optional)
- r"$"
+ r"""^(?P<arch>[a-zA-Z0-9_]+) # arch (required)
+ (?:-(?P<vendor>[a-zA-Z0-9_]+))? # vendor (optional)
+ (?:-(?P<os>[a-zA-Z_]+)(?P<os_version>[\d.]+)?)? # os + version (optional)
+ (?:-(?P<env>[a-zA-Z0-9_]+))? # env/abi (optional)
+ $""",
+ re.X,
)
def split_triple(triple):
- m = TRIPLE_RE.match(triple)
- if m:
- return m["arch"], m["vendor"], m["os"], m["os_version"], m["env"]
- return None, None, None, None, None
+ if m := TRIPLE_RE.match(triple):
+ return m.groups()
+ return [None] * TRIPLE_RE.groups
class BuilderDarwin(Builder):
@@ -41,8 +41,7 @@ def getExtraMakeArgs(self):
)
args["FRAMEWORK_INCLUDES"] = "-F{}".format(private_frameworks)
- triple = self.getTriple()
- if triple:
+ if triple := self.getTriple():
_, _, operating_system, _, env = split_triple(triple)
builder_dir = os.path.dirname(os.path.abspath(__file__))
@@ -61,7 +60,6 @@ def getExtraMakeArgs(self):
return ["{}={}".format(key, value) for key, value in args.items()]
def getArchCFlags(self):
- """Returns the ARCH_CFLAGS for the make system."""
# Get the triple components.
triple = self.getTriple()
if not triple:
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 854507b3b3abd..f3b0837bdc4ab 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -90,7 +90,7 @@ def create_parser():
"-E",
metavar="extra-flags",
help=textwrap.dedent(
- """Specify the extra flags to be passed to the toolchain when building the inferior programs to be debugged"""
+ """Specify the extra flags to be passed to the toolchain when building the inferior programs to be debugged."""
),
)
>From ae84cbd72164579f0f142fc658154948d10a6848 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 10 Apr 2026 16:04:08 +0100
Subject: [PATCH 3/5] Remove stray comment
---
lldb/packages/Python/lldbsuite/test/builders/darwin.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/lldb/packages/Python/lldbsuite/test/builders/darwin.py b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
index 60a0fd418f5e6..786a1a4750437 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -60,7 +60,6 @@ def getExtraMakeArgs(self):
return ["{}={}".format(key, value) for key, value in args.items()]
def getArchCFlags(self):
- # Get the triple components.
triple = self.getTriple()
if not triple:
return []
>From 67c5e35c7971a1a3eb2e3a13e8b9d571ac5fbd30 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 17 Apr 2026 10:18:58 -0700
Subject: [PATCH 4/5] Fix arm64e tests
---
.../expression/ptrauth-auth-traps/Makefile | 2 --
.../ptrauth-auth-traps/TestPtrAuthAuthTraps.py | 11 +++++++++--
.../commands/expression/ptrauth-objc/Makefile | 2 --
.../ptrauth-objc/TestPtrAuthObjectiveC.py | 17 ++++++++++++-----
.../commands/expression/ptrauth-vtable/Makefile | 2 --
.../TestPtrAuthVTableExpressions.py | 12 +++++++++---
.../API/commands/expression/ptrauth/Makefile | 2 --
.../ptrauth/TestPtrAuthExpressions.py | 15 +++++++++++----
8 files changed, 41 insertions(+), 22 deletions(-)
diff --git a/lldb/test/API/commands/expression/ptrauth-auth-traps/Makefile b/lldb/test/API/commands/expression/ptrauth-auth-traps/Makefile
index ab0fd9a46e7ed..10495940055b6 100644
--- a/lldb/test/API/commands/expression/ptrauth-auth-traps/Makefile
+++ b/lldb/test/API/commands/expression/ptrauth-auth-traps/Makefile
@@ -1,5 +1,3 @@
C_SOURCES := main.c
-override TRIPLE := arm64e-apple-darwin
-
include Makefile.rules
diff --git a/lldb/test/API/commands/expression/ptrauth-auth-traps/TestPtrAuthAuthTraps.py b/lldb/test/API/commands/expression/ptrauth-auth-traps/TestPtrAuthAuthTraps.py
index 5e9f0c4cd01a1..411c352b41ec4 100644
--- a/lldb/test/API/commands/expression/ptrauth-auth-traps/TestPtrAuthAuthTraps.py
+++ b/lldb/test/API/commands/expression/ptrauth-auth-traps/TestPtrAuthAuthTraps.py
@@ -8,14 +8,21 @@
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+from lldbsuite.test import configuration
class TestPtrAuthAuthTraps(TestBase):
NO_DEBUG_INFO_TESTCASE = True
+ SHARED_BUILD_TESTCASE = False
+
+ def build_arm64e(self):
+ self.build(
+ dictionary={"TRIPLE": configuration.triple.replace("arm64", "arm64e")}
+ )
@skipUnlessArm64eSupported
def test_static_function_pointer(self):
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.c", False)
)
@@ -32,7 +39,7 @@ def test_static_function_pointer(self):
@skipUnlessArm64eSupported
def test_indirect_call_through_caller(self):
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.c", False)
)
diff --git a/lldb/test/API/commands/expression/ptrauth-objc/Makefile b/lldb/test/API/commands/expression/ptrauth-objc/Makefile
index c66c41ccfbbae..8e9302ac72ca8 100644
--- a/lldb/test/API/commands/expression/ptrauth-objc/Makefile
+++ b/lldb/test/API/commands/expression/ptrauth-objc/Makefile
@@ -1,7 +1,5 @@
OBJC_SOURCES := main.m
-override TRIPLE := arm64e-apple-darwin
-
# We need an arm64e stdlib.
USE_SYSTEM_STDLIB := 1
diff --git a/lldb/test/API/commands/expression/ptrauth-objc/TestPtrAuthObjectiveC.py b/lldb/test/API/commands/expression/ptrauth-objc/TestPtrAuthObjectiveC.py
index 0f4b50d126d51..d9a3685c81087 100644
--- a/lldb/test/API/commands/expression/ptrauth-objc/TestPtrAuthObjectiveC.py
+++ b/lldb/test/API/commands/expression/ptrauth-objc/TestPtrAuthObjectiveC.py
@@ -2,14 +2,21 @@
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+from lldbsuite.test import configuration
class TestPtrAuthObjectiveC(TestBase):
NO_DEBUG_INFO_TESTCASE = True
+ SHARED_BUILD_TESTCASE = False
+
+ def build_arm64e(self):
+ self.build(
+ dictionary={"TRIPLE": configuration.triple.replace("arm64", "arm64e")}
+ )
@skipUnlessArm64eSupported
def test_objc_message_send(self):
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.m", False)
@@ -23,7 +30,7 @@ def test_objc_message_send(self):
@skipUnlessArm64eSupported
def test_objc_message_send_with_arg(self):
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.m", False)
@@ -37,7 +44,7 @@ def test_objc_message_send_with_arg(self):
@skipUnlessArm64eSupported
def test_objc_alloc_and_message(self):
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.m", False)
@@ -52,7 +59,7 @@ def test_objc_alloc_and_message(self):
@skipUnlessArm64eSupported
def test_objc_derived_class(self):
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.m", False)
@@ -72,7 +79,7 @@ def test_objc_derived_class(self):
@skipUnlessArm64eSupported
def test_objc_isa_check(self):
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.m", False)
diff --git a/lldb/test/API/commands/expression/ptrauth-vtable/Makefile b/lldb/test/API/commands/expression/ptrauth-vtable/Makefile
index 46852554c4e25..5ac5d6a2a7365 100644
--- a/lldb/test/API/commands/expression/ptrauth-vtable/Makefile
+++ b/lldb/test/API/commands/expression/ptrauth-vtable/Makefile
@@ -1,7 +1,5 @@
CXX_SOURCES := main.cpp
-override TRIPLE := arm64e-apple-darwin
-
# We need an arm64e stblib.
USE_SYSTEM_STDLIB := 1
diff --git a/lldb/test/API/commands/expression/ptrauth-vtable/TestPtrAuthVTableExpressions.py b/lldb/test/API/commands/expression/ptrauth-vtable/TestPtrAuthVTableExpressions.py
index 92a30b6e6548f..7376f5b7f3484 100644
--- a/lldb/test/API/commands/expression/ptrauth-vtable/TestPtrAuthVTableExpressions.py
+++ b/lldb/test/API/commands/expression/ptrauth-vtable/TestPtrAuthVTableExpressions.py
@@ -12,10 +12,16 @@
class TestPtrAuthVTableExpressions(TestBase):
NO_DEBUG_INFO_TESTCASE = True
+ SHARED_BUILD_TESTCASE = False
+
+ def build_arm64e(self):
+ self.build(
+ dictionary={"TRIPLE": configuration.triple.replace("arm64", "arm64e")}
+ )
@skipUnlessArm64eSupported
def test_virtual_call_on_debuggee_object(self):
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.cpp", False)
)
@@ -25,7 +31,7 @@ def test_virtual_call_on_debuggee_object(self):
@skipUnlessArm64eSupported
def test_virtual_call_through_base_pointer(self):
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.cpp", False)
)
@@ -34,7 +40,7 @@ def test_virtual_call_through_base_pointer(self):
@skipUnlessArm64eSupported
def test_virtual_call_via_helper(self):
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.cpp", False)
)
diff --git a/lldb/test/API/commands/expression/ptrauth/Makefile b/lldb/test/API/commands/expression/ptrauth/Makefile
index ab0fd9a46e7ed..10495940055b6 100644
--- a/lldb/test/API/commands/expression/ptrauth/Makefile
+++ b/lldb/test/API/commands/expression/ptrauth/Makefile
@@ -1,5 +1,3 @@
C_SOURCES := main.c
-override TRIPLE := arm64e-apple-darwin
-
include Makefile.rules
diff --git a/lldb/test/API/commands/expression/ptrauth/TestPtrAuthExpressions.py b/lldb/test/API/commands/expression/ptrauth/TestPtrAuthExpressions.py
index 4d0d4026cc0c4..160c04f38a0a1 100644
--- a/lldb/test/API/commands/expression/ptrauth/TestPtrAuthExpressions.py
+++ b/lldb/test/API/commands/expression/ptrauth/TestPtrAuthExpressions.py
@@ -2,10 +2,17 @@
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+from lldbsuite.test import configuration
class TestPtrAuthExpressions(TestBase):
NO_DEBUG_INFO_TESTCASE = True
+ SHARED_BUILD_TESTCASE = False
+
+ def build_arm64e(self):
+ self.build(
+ dictionary={"TRIPLE": configuration.triple.replace("arm64", "arm64e")}
+ )
@skipUnlessArm64eSupported
def test_static_function_pointer(self):
@@ -13,7 +20,7 @@ def test_static_function_pointer(self):
Test that we can call a function through a static function pointer
from the expression evaluator, which requires "fixing up" the pointer
signing via the InjectPointerSigningFixups pass."""
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.c", False)
@@ -37,7 +44,7 @@ def test_indirect_call_through_caller(self):
correctly signed. The caller() function in the debuggee forces a
genuine indirect call, preventing the compiler from folding the
function pointer call into a direct call."""
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.c", False)
@@ -62,7 +69,7 @@ def test_debuggee_signed_pointer(self):
is signed with the IB key (__ptrauth(1, 0, 0)), which is
process-specific; this verifies that auth succeeds because expressions
execute in the debuggee's process, not the debugger's."""
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.c", False)
@@ -79,7 +86,7 @@ def test_indirect_goto(self):
"""Test that computed gotos (GCC labels-as-values) work in the
expression evaluator on arm64e, where -fptrauth-indirect-gotos signs
label addresses and the indirect branch authenticates them."""
- self.build()
+ self.build_arm64e()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.c", False)
>From a125c755666059344b4e743769f7c4b69000d6c9 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 17 Apr 2026 10:52:58 -0700
Subject: [PATCH 5/5] Update TestPtrAuth after rebase
---
lldb/test/API/lang/c/ptrauth/Makefile | 1 -
lldb/test/API/lang/c/ptrauth/TestPtrAuth.py | 11 ++++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/lldb/test/API/lang/c/ptrauth/Makefile b/lldb/test/API/lang/c/ptrauth/Makefile
index ad36d69b5e072..8c13eda0b791e 100644
--- a/lldb/test/API/lang/c/ptrauth/Makefile
+++ b/lldb/test/API/lang/c/ptrauth/Makefile
@@ -1,5 +1,4 @@
LEVEL = ../../../make
-override TRIPLE := arm64e-apple-darwin
CFLAGS_EXTRAS = -fptrauth-calls -fptrauth-intrinsics
C_SOURCES := main.c
diff --git a/lldb/test/API/lang/c/ptrauth/TestPtrAuth.py b/lldb/test/API/lang/c/ptrauth/TestPtrAuth.py
index a69bb1cfe33a6..efed7e2a5ad6f 100644
--- a/lldb/test/API/lang/c/ptrauth/TestPtrAuth.py
+++ b/lldb/test/API/lang/c/ptrauth/TestPtrAuth.py
@@ -4,12 +4,21 @@
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+from lldbsuite.test import configuration
class TestPtrAuth(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+ SHARED_BUILD_TESTCASE = False
+
+ def build_arm64e(self):
+ self.build(
+ dictionary={"TRIPLE": configuration.triple.replace("arm64", "arm64e")}
+ )
+
@skipUnlessArm64eSupported
def test(self):
- self.build()
+ self.build_arm64e()
_, process, _, _ = lldbutil.run_to_source_breakpoint(
self, "// break in main", lldb.SBFileSpec("main.c")
)
More information about the lldb-commits
mailing list