Skip to content

Commit 4e85bc4

Browse files
committed
Make sure the Swift REPL is initialized with host OS availablity.
This is fixed by unifying the code that updates the ArchSpec after finding a fat binary with how it is done for a lean binary. <rdar://problem/66024437> (cherry picked from commit 9f22fa5) Conflicts: lldb/source/Target/TargetList.cpp
1 parent e31457a commit 4e85bc4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lldb/source/Target/TargetList.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ Status TargetList::CreateTargetInternal(
254254
// If we have a valid architecture, make sure the current platform is
255255
// compatible with that architecture.
256256
if (!prefer_platform_arch && arch.IsValid()) {
257-
if (!platform_sp->IsCompatibleArchitecture(arch, false, nullptr)) {
257+
ArchSpec compatible_arch;
258+
if (!platform_sp->IsCompatibleArchitecture(arch, false, &compatible_arch)) {
258259
platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
259260
if (!is_dummy_target && platform_sp)
260261
debugger.GetPlatformList().SetSelectedPlatform(platform_sp);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// -*- mode: swift; -*-
2+
// Test that the REPL is launched with the current OS as availability target.
3+
// REQUIRES: system-darwin
4+
5+
// RUN: mkdir -p %t.dir
6+
// RUN: echo '@available(macOS '>%t.dir/NewModule.swift
7+
// RUN: sw_vers | grep ProductVersion | cut -d : -f 2 >>%t.dir/NewModule.swift
8+
// RUN: echo ', *) public let message = "Hello"' >>%t.dir/NewModule.swift
9+
// RUN: %target-swiftc -module-name NewModule -emit-module -emit-library -o %t.dir/libNewModule%target-shared-library-suffix %t.dir/NewModule.swift
10+
11+
// RUN: %lldb --repl="-I%t.dir -L%t.dir -lNewModule" --repl-language swift < %s | FileCheck %s
12+
import NewModule
13+
message
14+
// CHECK: $R0{{.*}}Hello

0 commit comments

Comments
 (0)