forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 344
Avoid importing dynamic libraries and frameworks are already in the t… #4077
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
adrian-prantl
merged 1 commit into
swiftlang:stable/20211026
from
adrian-prantl:88974768
Mar 24, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public typealias MyNumber = Int | ||
public class C { | ||
public init() { n = MyNumber(23) } | ||
let n : MyNumber | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
SWIFT_SOURCES := main.swift | ||
|
||
SWIFTFLAGS_EXTRAS = -F $(BUILDDIR) | ||
|
||
all: Lazy.framework $(EXE) | ||
|
||
include Makefile.rules | ||
|
||
Lazy.framework: $(SRCDIR)/Lazy.swift | ||
$(MAKE) -f $(MAKEFILE_RULES) \ | ||
DYLIB_NAME=Lazy \ | ||
DYLIB_SWIFT_SOURCES=Lazy.swift \ | ||
DYLIB_MODULENAME=Lazy \ | ||
FRAMEWORK=Lazy | ||
rm -f $(BUILDDIR)/Lazy.swiftmodule $(BUILDDIR)/Lazy.swiftinterface |
35 changes: 35 additions & 0 deletions
35
lldb/test/API/lang/swift/lazy_framework/TestSwiftLazyFramework.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import lldb | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbtest as lldbtest | ||
import lldbsuite.test.lldbutil as lldbutil | ||
import os | ||
import unittest2 | ||
|
||
|
||
class TestSwiftLazyFramework(lldbtest.TestBase): | ||
|
||
NO_DEBUG_INFO_TESTCASE = True | ||
mydir = lldbtest.TestBase.compute_mydir(__file__) | ||
|
||
@swiftTest | ||
@skipIf(oslist=no_match(["macosx"])) | ||
def test_system_framework(self): | ||
"""Test that a framework that is registered as autolinked in a Swift | ||
module used in the target, but not linked against the target is | ||
automatically loaded by LLDB.""" | ||
self.build() | ||
self.expect("settings set target.swift-auto-import-frameworks true") | ||
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( | ||
self, 'break here', lldb.SBFileSpec('main.swift')) | ||
|
||
# Verify that lazy is not linked in. | ||
self.runCmd("image list") | ||
output = self.res.GetOutput() | ||
self.assertIn("dyld", output) | ||
self.assertNotIn("Lazy.framework/Versions/A/Lazy", output) | ||
# FIXME: we should automatically retry the expression on dylib import. | ||
self.expect("expression -- 1", error=True) | ||
self.expect("expression -- C()", substrs=['23']) | ||
|
||
# Verify that lazy has been dynamically loaded. | ||
self.expect("image list", substrs=["Lazy.framework/Versions/A/Lazy"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Lazy | ||
let n = MyNumber(42) | ||
print("break here") | ||
print(n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
public struct D { public init() {} } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
SWIFT_SOURCES := main.swift | ||
|
||
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR) -F$(BUILDDIR) | ||
|
||
FRAMEWORKS=$(patsubst %,a%.framework,$(shell seq -s " " 0 $(N))) | ||
|
||
all: $(FRAMEWORKS) dylib $(EXE) | ||
|
||
include Makefile.rules | ||
|
||
lib%.a: %.swift | ||
$(MAKE) -f $(MAKEFILE_RULES) \ | ||
DYLIB_NAME=static \ | ||
SWIFT_SOURCES=$(patsubst lib%.a,%.swift,$@) \ | ||
MODULENAME=$(patsubst lib%.a,%,$@) \ | ||
SWIFTFLAGS_EXTRAS="$(patsubst %,-F%/DOES_NOT_EXIST,$(FRAMEWORKS))" \ | ||
$(patsubst lib%.a,%.o,$@) \ | ||
$(patsubst lib%.a,%.swiftmodule,$@) | ||
ar -r $@ $(BUILDDIR)/$(patsubst lib%.a,%.o,$@) | ||
|
||
%.framework: lib%.a | ||
mkdir -p $(BUILDDIR)/$@/Headers | ||
mkdir -p $(BUILDDIR)/$@/Modules | ||
mkdir -p $(BUILDDIR)/$@/Resources | ||
mv $< $(BUILDDIR)/$@/$(patsubst lib%.a,%,$<) | ||
mkdir -p $(BUILDDIR)/$@/Modules/$(patsubst lib%.a,%.swiftmodule,$<) | ||
mv $(BUILDDIR)/$(patsubst lib%.a,%.swiftmodule,$<) $(BUILDDIR)/$@/Modules/$(patsubst lib%.a,%.swiftmodule,$<)/$(ARCH)-apple-macos.swiftmodule | ||
mv $(BUILDDIR)/$(patsubst lib%.a,%.swiftinterface,$<) $(BUILDDIR)/$@/Modules/ | ||
|
||
dylib: Dylib.swift | ||
$(MAKE) -f $(MAKEFILE_RULES) \ | ||
DYLIB_NAME=Dylib \ | ||
DYLIB_SWIFT_SOURCES=Dylib.swift \ | ||
DYLIB_MODULENAME=Dylib \ | ||
FRAMEWORK=Dylib | ||
rm -f $(BUILDDIR)/Dylib.swiftmodule $(BUILDDIR)/Dylib.swiftinterface |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worthwhile to note here that the auto-import setting overrides the value of import_dylib.