Skip to content

Commit 20bb835

Browse files
Merge pull request swiftlang#614 from adrian-prantl/SR-7388
Cherry-pick the fixes for SR-7388 to swift-4.1-branch apple-llvm-split-commit: 26a670affb2b4443491f75bb70466fdde07d3e1a apple-llvm-split-dir: lldb/
2 parents 98e9ebf + e2b8c34 commit 20bb835

File tree

8 files changed

+76
-4
lines changed

8 files changed

+76
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
LEVEL = ../../../make
2+
SWIFT_SOURCES := main.swift
3+
SWIFT_OBJC_INTEROP = 1
4+
include $(LEVEL)/Makefile.rules
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# TestSwiftFoundation.py
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2018 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
# ------------------------------------------------------------------------------
12+
import lldbsuite.test.lldbinline as lldbinline
13+
import lldbsuite.test.decorators as decorators
14+
15+
lldbinline.MakeInlineTest(__file__, globals())
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// main.swift
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
// -----------------------------------------------------------------------------
12+
import Foundation
13+
14+
// Test that importing Foundation and printing a value for which
15+
// no data formatter exists works consistently on all platforms.
16+
func main() {
17+
var point = NSPoint(x: 23, y: 42)
18+
print(point) //% self.expect("frame variable -- point", substrs=['x', '23', 'y', '42'])
19+
//% self.expect("expression -- point", substrs=['x', '23', 'y', '42'])
20+
}
21+
22+
main()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
LEVEL = ../../../make
2+
SWIFT_SOURCES := main.swift
3+
include $(LEVEL)/Makefile.rules
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Dispatch
2+
3+
// The dispatch clang module is either imported as Objective-C or as C
4+
// with blocks, and both varints should work in LLDB's expression evaluator.
5+
6+
func main() {
7+
let label = "lldbtest"
8+
let queue = DispatchQueue(label: label)
9+
print(queue) //% self.expect("fr var -- label", substrs=['lldbtest'])
10+
//% self.expect("expr -- label", substrs=['lldbtest'])
11+
}
12+
13+
main()

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,16 @@ endif
482482
# Check if we need the Swift/ObjC interop features
483483
#----------------------------------------------------------------------
484484
ifeq "$(SWIFT_OBJC_INTEROP)" "1"
485-
SWIFTFLAGS += -framework Foundation -framework CoreGraphics
486-
LDFLAGS +=-lswiftObjectiveC -lswiftFoundation -framework Foundation -framework CoreGraphics
485+
ifeq "$(OS)" "Darwin"
486+
SWIFTFLAGS += -framework Foundation -framework CoreGraphics
487+
LDFLAGS += -lswiftObjectiveC -lswiftFoundation -framework Foundation -framework CoreGraphics
488+
else
489+
# CFLAGS_EXTRAS is used via "dotest.py -E" to pass the -I and -L paths
490+
# for Foundation and libdispatch on Linux.
491+
SWIFTFLAGS += $(CFLAGS_EXTRAS)
492+
LDFLAGS += $(CFLAGS_EXTRAS)
493+
endif
494+
487495
endif
488496

489497
#----------------------------------------------------------------------

lldb/source/API/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ if(NOT LLDB_BUILT_STANDALONE)
170170
set(clang_headers_target symlink_clang_headers)
171171
endif()
172172

173+
# Copy the clang resource directory.
173174
add_custom_command_target(
174175
unused_var
175-
COMMAND "${CMAKE_COMMAND}" "-E" "copy_directory" "${CLANG_RESOURCE_PATH}" "${lib_dir}/lldb/clang"
176-
OUTPUT "${lib_dir}/lldb/clang"
176+
COMMAND "${CMAKE_COMMAND}" "-E" "copy_directory" "${CLANG_RESOURCE_PATH}" "${lib_dir}/lldb/clang/${LLVM_PACKAGE_VERSION}"
177+
OUTPUT "${lib_dir}/lldb/clang/${LLVM_PACKAGE_VERSION}"
177178
VERBATIM
178179
ALL
179180
DEPENDS ${clang_headers_target})

lldb/source/Symbol/SwiftASTContext.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,12 @@ bool SwiftASTContext::SetTriple(const char *triple_cstr, Module *module) {
20202020
this, triple_cstr, triple.c_str(),
20212021
m_target_wp.lock() ? " (target)" : "");
20222022
m_compiler_invocation_ap->setTargetTriple(triple);
2023+
2024+
// Every time the triple is changed the LangOpts must be
2025+
// updated too, because Swift default-initializes the
2026+
// EnableObjCInterop flag based on the triple.
2027+
GetLanguageOptions().EnableObjCInterop = llvm_triple.isOSDarwin();
2028+
20232029
return true;
20242030
} else {
20252031
if (log)

0 commit comments

Comments
 (0)