Skip to content

Commit b0bae44

Browse files
authored
[lld] Adds support for xros. (#83031)
1 parent 1d1186d commit b0bae44

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

lld/MachO/Driver.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,8 @@ static PlatformVersion parsePlatformVersion(const Arg *arg) {
691691
.Cases("tvos-simulator", "8", PLATFORM_TVOSSIMULATOR)
692692
.Cases("watchos-simulator", "9", PLATFORM_WATCHOSSIMULATOR)
693693
.Cases("driverkit", "10", PLATFORM_DRIVERKIT)
694+
.Cases("xros", "11", PLATFORM_XROS)
695+
.Cases("xros-simulator", "12", PLATFORM_XROS_SIMULATOR)
694696
.Default(PLATFORM_UNKNOWN);
695697
if (platformVersion.platform == PLATFORM_UNKNOWN)
696698
error(Twine("malformed platform: ") + platformStr);
@@ -985,6 +987,8 @@ PlatformType macho::removeSimulator(PlatformType platform) {
985987
return PLATFORM_TVOS;
986988
case PLATFORM_WATCHOSSIMULATOR:
987989
return PLATFORM_WATCHOS;
990+
case PLATFORM_XROS_SIMULATOR:
991+
return PLATFORM_XROS;
988992
default:
989993
return platform;
990994
}
@@ -1001,15 +1005,17 @@ static bool shouldAdhocSignByDefault(Architecture arch, PlatformType platform) {
10011005

10021006
return platform == PLATFORM_MACOS || platform == PLATFORM_IOSSIMULATOR ||
10031007
platform == PLATFORM_TVOSSIMULATOR ||
1004-
platform == PLATFORM_WATCHOSSIMULATOR;
1008+
platform == PLATFORM_WATCHOSSIMULATOR ||
1009+
platform == PLATFORM_XROS_SIMULATOR;
10051010
}
10061011

10071012
static bool dataConstDefault(const InputArgList &args) {
1008-
static const std::array<std::pair<PlatformType, VersionTuple>, 5> minVersion =
1013+
static const std::array<std::pair<PlatformType, VersionTuple>, 6> minVersion =
10091014
{{{PLATFORM_MACOS, VersionTuple(10, 15)},
10101015
{PLATFORM_IOS, VersionTuple(13, 0)},
10111016
{PLATFORM_TVOS, VersionTuple(13, 0)},
10121017
{PLATFORM_WATCHOS, VersionTuple(6, 0)},
1018+
{PLATFORM_XROS, VersionTuple(1, 0)},
10131019
{PLATFORM_BRIDGEOS, VersionTuple(4, 0)}}};
10141020
PlatformType platform = removeSimulator(config->platformInfo.target.Platform);
10151021
auto it = llvm::find_if(minVersion,
@@ -1045,11 +1051,12 @@ static bool shouldEmitChainedFixups(const InputArgList &args) {
10451051
bool isRequested = arg != nullptr;
10461052

10471053
// Version numbers taken from the Xcode 13.3 release notes.
1048-
static const std::array<std::pair<PlatformType, VersionTuple>, 4> minVersion =
1054+
static const std::array<std::pair<PlatformType, VersionTuple>, 5> minVersion =
10491055
{{{PLATFORM_MACOS, VersionTuple(11, 0)},
10501056
{PLATFORM_IOS, VersionTuple(13, 4)},
10511057
{PLATFORM_TVOS, VersionTuple(14, 0)},
1052-
{PLATFORM_WATCHOS, VersionTuple(7, 0)}}};
1058+
{PLATFORM_WATCHOS, VersionTuple(7, 0)},
1059+
{PLATFORM_XROS, VersionTuple(1, 0)}}};
10531060
PlatformType platform = removeSimulator(config->platformInfo.target.Platform);
10541061
auto it = llvm::find_if(minVersion,
10551062
[&](const auto &p) { return p.first == platform; });
@@ -1688,8 +1695,8 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
16881695
if (args.getLastArg(OPT_reproducible))
16891696
config->zeroModTime = true;
16901697

1691-
std::array<PlatformType, 3> encryptablePlatforms{
1692-
PLATFORM_IOS, PLATFORM_WATCHOS, PLATFORM_TVOS};
1698+
std::array<PlatformType, 4> encryptablePlatforms{
1699+
PLATFORM_IOS, PLATFORM_WATCHOS, PLATFORM_TVOS, PLATFORM_XROS};
16931700
config->emitEncryptionInfo =
16941701
args.hasFlag(OPT_encryptable, OPT_no_encryption,
16951702
is_contained(encryptablePlatforms, config->platform()));

lld/MachO/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def grp_version : OptionGroup<"version">, HelpText<"VERSION TARGETING">;
377377

378378
def platform_version : MultiArg<["-"], "platform_version", 3>,
379379
MetaVarName<"<platform> <min_version> <sdk_version>">,
380-
HelpText<"Platform (e.g., macos, ios, tvos, watchos, bridgeos, mac-catalyst, ios-sim, tvos-sim, watchos-sim, driverkit) and version numbers">,
380+
HelpText<"Platform (e.g., macos, ios, tvos, watchos, xros, bridgeos, mac-catalyst, ios-sim, tvos-sim, watchos-sim, xros-sim, driverkit) and version numbers">,
381381
Group<grp_version>;
382382
def sdk_version : Separate<["-"], "sdk_version">,
383383
HelpText<"This option is undocumented in ld64">,

lld/test/MachO/lc-build-version.s

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@
6464

6565
# WATCHOS-4-0: cmd LC_VERSION_MIN_WATCHOS
6666

67+
# RUN: %no-arg-lld -arch x86_64 -platform_version xros 1.0 1.1 -o %t.xros-1-0 %t.o
68+
# RUN: llvm-objdump --macho --all-headers %t.xros-1-0 | FileCheck %s --check-prefix=XROS-1-0
69+
# RUN: %no-arg-lld -arch x86_64 -platform_version xros-simulator 1.0 1.1 -o %t.xros-sim-1-0 %t.o
70+
# RUN: llvm-objdump --macho --all-headers %t.xros-sim-1-0 | FileCheck %s --check-prefix=XROS-1-0
71+
72+
# XROS-1-0: cmd LC_BUILD_VERSION
73+
6774
.text
6875
.global _main
6976
_main:

lld/test/MachO/platform-version.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# RUN: -platform_version 0 1 5 \
5656
# RUN: | FileCheck --check-prefix=FAIL-PLATFORM %s
5757
# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
58-
# RUN: -platform_version 11 1 5 \
58+
# RUN: -platform_version 13 1 5 \
5959
# RUN: | FileCheck --check-prefix=FAIL-PLATFORM %s
6060
# FAIL-PLATFORM: malformed platform: {{.*}}
6161
# FAIL-PLATFORM-NOT: malformed {{minimum|sdk}} version: {{.*}}

0 commit comments

Comments
 (0)