Skip to content

[Cherry-pick into stable/20230725] Update testcases for upstream Makefile.rules change that removed TRIPLE #7635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,8 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
const std::string &m_description,
llvm::raw_ostream &error,
bool &got_serialized_options,
bool &found_swift_modules) {
bool &found_swift_modules,
bool search_paths_only = false) {
bool found_validation_errors = false;
got_serialized_options = false;

Expand Down Expand Up @@ -1278,7 +1279,7 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,

/// Initialize the compiler invocation with it the search paths from a
/// serialized AST.
auto deserializeCompilerFlags = [&]() -> bool {
auto deserializeCompilerFlags = [&](swift::CompilerInvocation &invocation) {
auto result = invocation.loadFromSerializedAST(moduleData);
if (result != swift::serialization::Status::Valid) {
error << "Could not deserialize " << info.name << ":\n"
Expand Down Expand Up @@ -1401,13 +1402,17 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
return true;
};

got_serialized_options |= deserializeCompilerFlags();

LOG_PRINTF(
GetLog(LLDBLog::Types), "SDK path from module \"%s\" was \"%s\".",
info.name.str().c_str(), invocation.getSDKPath().str().c_str());
// We will deduce a matching SDK path from DWARF later.
invocation.setSDKPath("");
if (search_paths_only) {
swift::CompilerInvocation fresh_invocation;
got_serialized_options |= deserializeCompilerFlags(fresh_invocation);
} else {
got_serialized_options |= deserializeCompilerFlags(invocation);
LOG_PRINTF(
GetLog(LLDBLog::Types), "SDK path from module \"%s\" was \"%s\".",
info.name.str().c_str(), invocation.getSDKPath().str().c_str());
// We will deduce a matching SDK path from DWARF later.
invocation.setSDKPath("");
}
}
}

Expand Down Expand Up @@ -8371,7 +8376,7 @@ bool SwiftASTContextForExpressions::CacheUserImports(
invocation, ast_file, {file_or_err->get()->getBuffer()},
path_remap, discover_implicit_search_paths,
m_description.str().str(), errs, got_serialized_options,
found_swift_modules)) {
found_swift_modules, /*search_paths_only = */true)) {
LOG_PRINTF(GetLog(LLDBLog::Types), "Could not parse %s: %s",
ast_file.str().c_str(), error.str().str().c_str());
}
Expand Down
1 change: 1 addition & 0 deletions lldb/test/API/lang/swift/availability/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SWIFT_SOURCES := main.swift
SWIFTFLAGS_EXTRAS := -target $(TRIPLE)

include Makefile.rules
Empty file.
22 changes: 22 additions & 0 deletions lldb/test/API/lang/swift/late_expr_dylib/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This Makefile recursively calls itself, hence the ?=.
SWIFT_SOURCES ?= main.swift
SWIFTFLAGS_EXTRAS ?= -target $(TRIPLE) -I$(BUILDDIR)
all: Dylib $(EXE)

include Makefile.rules

.PHONY: Dylib
Dylib:
$(MAKE) MAKE_DSYM=$(MAKE_DSYM) CC=$(CC) SWIFTC=$(SWIFTC) \
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
VPATH=$(SRCDIR) -I $(SRCDIR) \
SWIFT_SOURCES= \
SWIFTFLAGS_EXTRAS="-target $(DYLIB_TRIPLE) -I__PATH_FROM_DYLIB__" \
-f $(SRCDIR)/Makefile \
DYLIB_FILENAME=Dylib.dylib \
DYLIB_SWIFT_SOURCES=Dylib.swift \
DYLIB_NAME=Dylib \
DYLIB_ONLY=YES \
LD_EXTRAS="-lSwiftCore" \
Dylib.dylib

29 changes: 29 additions & 0 deletions lldb/test/API/lang/swift/late_expr_dylib/TestSwiftLateExprDylib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil


class TestSwiftLateDylib(TestBase):
mydir = TestBase.compute_mydir(__file__)

@skipUnlessDarwin
@swiftTest
@skipIfDarwinEmbedded
def test(self):
"""Test that a late loaded Swift dylib is debuggable"""
arch = self.getArchitecture()
self.build(dictionary={"TRIPLE": arch + "-apple-macosx11.0.0", "ARCH": arch,
"DYLIB_TRIPLE": arch + "-apple-macosx12.0.0"})
log = self.getBuildArtifact("types.log")
self.runCmd('log enable lldb types -f "%s"' % log)
lldbutil.run_to_source_breakpoint(self, "break here",
lldb.SBFileSpec("main.swift"))
self.expect("expr -- import Dylib")
# Scan through the types log.
self.filecheck('platform shell cat "%s"' % log, __file__)
# CHECK: SwiftASTContextForExpressions::LogConfiguration(){{.*}}Architecture{{.*}}-apple-macosx11.0.0
# CHECK-NOT: __PATH_FROM_DYLIB__
# Verify that the deployment target didn't change:
# CHECK: SwiftASTContextForExpressions::LogConfiguration(){{.*}}Architecture{{.*}}-apple-macosx11.0.0
# But LLDB has picked up extra paths:
# CHECK: SwiftASTContextForExpressions::LogConfiguration(){{.*}}__PATH_FROM_DYLIB__
1 change: 1 addition & 0 deletions lldb/test/API/lang/swift/late_expr_dylib/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("break here")
7 changes: 6 additions & 1 deletion lldb/test/API/lang/swift/xcode_sdk/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
SWIFT_SOURCES := main.swift
ifeq "$(TRIPLE)" ""
SWIFTFLAGS_EXTRAS := -Xfrontend -no-serialize-debugging-options
else
# Target override for the simulator testcase.
SWIFTFLAGS_EXTRAS := -Xfrontend -no-serialize-debugging-options -target $(TRIPLE)
endif
SWIFT_BRIDGING_HEADER := bridging-header.h
LD_EXTRAS := ignored.o

all: ignored.o $(EXE)

# Artificially inject a wrong SDK into a C file to test that it is ebing ignored.
# Artificially inject a wrong SDK into a C file to test that it is being ignored.
ignored.o: ignored.c
$(CC) -target $(ARCH)-apple-macos -c $< -o $@ \
-isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path)
Expand Down