forked from OSchip/llvm-project
[lldb] Extend Darwin builder to pass the ARCH_CFLAGS spec to Make.
Construct the ARCH_CFLAGS in Python rather than in Make by disassembling the TRIPLE. Differential revision: https://reviews.llvm.org/D85539
This commit is contained in:
parent
c0cbe6453a
commit
e5d08fcbac
|
@ -25,6 +25,9 @@ class Builder:
|
|||
Helper function to return extra argumentsfor the make system. This
|
||||
method is meant to be overridden by platform specific builders.
|
||||
"""
|
||||
|
||||
def getArchCFlags(self, architecture):
|
||||
"""Returns the ARCH_CFLAGS for the make system."""
|
||||
return ""
|
||||
|
||||
def getMake(self, test_subdir, test_name):
|
||||
|
@ -139,6 +142,7 @@ class Builder:
|
|||
commands.append(
|
||||
self.getMake(testdir, testname) + [
|
||||
"all",
|
||||
self.getArchCFlags(architecture),
|
||||
self.getArchSpec(architecture),
|
||||
self.getCCSpec(compiler),
|
||||
self.getExtraMakeArgs(),
|
||||
|
@ -164,6 +168,7 @@ class Builder:
|
|||
commands.append(
|
||||
self.getMake(testdir, testname) + [
|
||||
"MAKE_DSYM=NO",
|
||||
self.getArchCFlags(architecture),
|
||||
self.getArchSpec(architecture),
|
||||
self.getCCSpec(compiler),
|
||||
self.getExtraMakeArgs(),
|
||||
|
@ -188,6 +193,7 @@ class Builder:
|
|||
commands.append(
|
||||
self.getMake(testdir, testname) + [
|
||||
"MAKE_DSYM=NO", "MAKE_DWO=YES",
|
||||
self.getArchCFlags(architecture),
|
||||
self.getArchSpec(architecture),
|
||||
self.getCCSpec(compiler),
|
||||
self.getExtraMakeArgs(),
|
||||
|
@ -212,6 +218,7 @@ class Builder:
|
|||
commands.append(
|
||||
self.getMake(testdir, testname) + [
|
||||
"MAKE_DSYM=NO", "MAKE_GMODULES=YES",
|
||||
self.getArchCFlags(architecture),
|
||||
self.getArchSpec(architecture),
|
||||
self.getCCSpec(compiler),
|
||||
self.getExtraMakeArgs(),
|
||||
|
|
|
@ -1,4 +1,43 @@
|
|||
import re
|
||||
import subprocess
|
||||
|
||||
from .builder import Builder
|
||||
from lldbsuite.test import configuration
|
||||
|
||||
REMOTE_PLATFORM_NAME_RE = re.compile(r"^remote-(.+)$")
|
||||
SIMULATOR_PLATFORM_RE = re.compile(r"^(.+)-simulator$")
|
||||
|
||||
|
||||
def get_sdk(os, env):
|
||||
if os == "ios":
|
||||
if env == "simulator":
|
||||
return "iphonesimulator"
|
||||
if env == "macabi":
|
||||
return "macosx"
|
||||
return "iphoneos"
|
||||
elif os == "tvos":
|
||||
if env == "simulator":
|
||||
return "appletvsimulator"
|
||||
return "appletvos"
|
||||
elif os == "watchos":
|
||||
if env == "simulator":
|
||||
return "watchsimulator"
|
||||
return "watchos"
|
||||
return os
|
||||
|
||||
|
||||
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('.')], ""
|
||||
|
||||
from lldbsuite.test import configuration
|
||||
|
||||
|
@ -14,10 +53,62 @@ class BuilderDarwin(Builder):
|
|||
if configuration.dsymutil:
|
||||
args['DSYMUTIL'] = configuration.dsymutil
|
||||
|
||||
os, _ = self.getOsAndEnv()
|
||||
if os and os != "macosx":
|
||||
args['CODESIGN'] = 'codesign'
|
||||
|
||||
# Return extra args as a formatted string.
|
||||
return ' '.join(
|
||||
{'{}="{}"'.format(key, value)
|
||||
for key, value in args.items()})
|
||||
def getOsAndEnv(self):
|
||||
if configuration.lldb_platform_name:
|
||||
return get_os_env_from_platform(configuration.lldb_platform_name)
|
||||
elif configuration.apple_sdk:
|
||||
return get_os_from_sdk(configuration.apple_sdk)
|
||||
return None, None
|
||||
|
||||
def getArchCFlags(self, architecture):
|
||||
"""Returns the ARCH_CFLAGS for the make system."""
|
||||
|
||||
# Construct the arch component.
|
||||
arch = architecture if architecture else configuration.arch
|
||||
if not arch:
|
||||
arch = subprocess.check_output(['machine'
|
||||
]).rstrip().decode('utf-8')
|
||||
if not arch:
|
||||
return ""
|
||||
|
||||
# Construct the vendor component.
|
||||
vendor = "apple"
|
||||
|
||||
# Construct the os component.
|
||||
os, env = self.getOsAndEnv()
|
||||
if os is None or env is None:
|
||||
return ""
|
||||
|
||||
# Get the SDK from the os and env.
|
||||
sdk = get_sdk(os, env)
|
||||
if not sdk:
|
||||
return ""
|
||||
|
||||
version = subprocess.check_output(
|
||||
["xcrun", "--sdk", sdk,
|
||||
"--show-sdk-version"]).rstrip().decode('utf-8')
|
||||
if not version:
|
||||
return ""
|
||||
|
||||
# Construct the triple from its components.
|
||||
triple = "{}-{}-{}-{}".format(vendor, os, version, env)
|
||||
|
||||
# Construct min version argument
|
||||
version_min = ""
|
||||
if env == "simulator":
|
||||
version_min = "-m{}-simulator-version-min={}".format(os, version)
|
||||
elif os == "macosx":
|
||||
version_min = "-m{}-version-min={}".format(os, version)
|
||||
|
||||
return "ARCH_CFLAGS=\"-target {} {}\"".format(triple, version_min)
|
||||
|
||||
def buildDsym(self,
|
||||
sender=None,
|
||||
|
@ -31,6 +122,7 @@ class BuilderDarwin(Builder):
|
|||
commands.append(
|
||||
self.getMake(testdir, testname) + [
|
||||
"MAKE_DSYM=YES",
|
||||
self.getArchCFlags(architecture),
|
||||
self.getArchSpec(architecture),
|
||||
self.getCCSpec(compiler),
|
||||
self.getExtraMakeArgs(),
|
||||
|
|
|
@ -766,15 +766,6 @@ def getVersionForSDK(sdk):
|
|||
return ver
|
||||
|
||||
|
||||
def setDefaultTripleForPlatform():
|
||||
if configuration.lldb_platform_name == 'ios-simulator':
|
||||
triple_str = 'x86_64-apple-ios%s' % (
|
||||
getVersionForSDK('iphonesimulator'))
|
||||
os.environ['TRIPLE'] = triple_str
|
||||
return {'TRIPLE': triple_str}
|
||||
return {}
|
||||
|
||||
|
||||
def checkCompiler():
|
||||
# Add some intervention here to sanity check that the compiler requested is sane.
|
||||
# If found not to be an executable program, we abort.
|
||||
|
@ -947,14 +938,6 @@ def run_suite():
|
|||
else:
|
||||
configuration.lldb_platform_url = None
|
||||
|
||||
platform_changes = setDefaultTripleForPlatform()
|
||||
first = True
|
||||
for key in platform_changes:
|
||||
if first:
|
||||
print("Environment variables setup for platform support:")
|
||||
first = False
|
||||
print("%s = %s" % (key, platform_changes[key]))
|
||||
|
||||
if configuration.lldb_platform_working_dir:
|
||||
print("Setting remote platform working directory to '%s'..." %
|
||||
(configuration.lldb_platform_working_dir))
|
||||
|
|
|
@ -94,65 +94,6 @@ endif
|
|||
# from the triple alone
|
||||
#----------------------------------------------------------------------
|
||||
ARCH_CFLAGS :=
|
||||
ifneq "$(TRIPLE)" ""
|
||||
triple_space = $(subst -, ,$(TRIPLE))
|
||||
ARCH =$(word 1, $(triple_space))
|
||||
TRIPLE_VENDOR =$(word 2, $(triple_space))
|
||||
triple_os_and_version =$(shell echo $(word 3, $(triple_space)) | sed 's/\([a-z]*\)\(.*\)/\1 \2/')
|
||||
TRIPLE_OS =$(word 1, $(triple_os_and_version))
|
||||
TRIPLE_VERSION =$(word 2, $(triple_os_and_version))
|
||||
TRIPLE_ENV =$(word 4, $(triple_space))
|
||||
ifeq "$(TRIPLE_VENDOR)" "apple"
|
||||
ifeq "$(TRIPLE_OS)" "ios"
|
||||
ifeq "$(TRIPLE_ENV)" "simulator"
|
||||
SDK_NAME := iphonesimulator
|
||||
else
|
||||
ifeq "$(TRIPLE_ENV)" "macabi"
|
||||
SDK_NAME := macosx
|
||||
else
|
||||
SDK_NAME := iphoneos
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
ifeq "$(TRIPLE_OS)" "tvos"
|
||||
ifeq "$(TRIPLE_ENV)" "simulator"
|
||||
SDK_NAME := appletvsimulator
|
||||
else
|
||||
SDK_NAME := appletvos
|
||||
endif
|
||||
endif
|
||||
ifeq "$(TRIPLE_OS)" "watchos"
|
||||
ifeq "$(TRIPLE_ENV)" "simulator"
|
||||
SDK_NAME := watchsimulator
|
||||
else
|
||||
SDK_NAME := watchos
|
||||
endif
|
||||
endif
|
||||
ifneq "$(TRIPLE_OS)" "macosx"
|
||||
ifeq "$(TRIPLE_ENV)" ""
|
||||
CODESIGN := codesign
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq "$(SDKROOT)" ""
|
||||
SDKROOT := $(shell xcrun --sdk $(SDK_NAME) --show-sdk-path)
|
||||
endif
|
||||
ifeq "$(TRIPLE_VERSION)" ""
|
||||
ifeq "$(SDK_NAME)" ""
|
||||
$(error "SDK_NAME is empty")
|
||||
endif
|
||||
TRIPLE_VERSION := $(shell xcrun --sdk $(SDK_NAME) --show-sdk-version)
|
||||
endif
|
||||
ifeq "$(TRIPLE_ENV)" "simulator"
|
||||
ARCH_CFLAGS := -m$(TRIPLE_OS)-simulator-version-min=$(TRIPLE_VERSION)
|
||||
else
|
||||
ifneq "$(TRIPLE_OS)" "macosx"
|
||||
ARCH_CFLAGS := -m$(TRIPLE_OS)-version-min=$(TRIPLE_VERSION)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
ARCH_CFLAGS += -target $(TRIPLE)
|
||||
endif
|
||||
ifeq "$(OS)" "Android"
|
||||
include $(THIS_FILE_DIR)/Android.rules
|
||||
endif
|
||||
|
|
Loading…
Reference in New Issue