Skip to content

[Interpreter] Fall back to loading Swift dylibs from /usr/lib/swift on Apple platforms. #24838

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
merged 2 commits into from
Jul 2, 2019

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented May 16, 2019

Continue to load the dylibs next to the compiler if they exist. If they don't, then use the OS's dylibs.

Requires LLDB PR apple/swift-lldb#1596.

rdar://problem/47528005

@mikeash
Copy link
Contributor Author

mikeash commented May 16, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 5e8da93e3862803ce16406392af10c28fefc3b83

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 5e8da93e3862803ce16406392af10c28fefc3b83

@mikeash
Copy link
Contributor Author

mikeash commented May 17, 2019

apple/swift-lldb#1596

@swift-ci please test

@mikeash mikeash force-pushed the usrlibswift-fallback branch from 5e8da93 to 83570c2 Compare June 19, 2019 19:37
@mikeash
Copy link
Contributor Author

mikeash commented Jun 19, 2019

apple/swift-lldb#1596

@swift-ci please test

@mikeash mikeash force-pushed the usrlibswift-fallback branch from 83570c2 to d64d138 Compare June 27, 2019 20:31
@mikeash
Copy link
Contributor Author

mikeash commented Jun 27, 2019

apple/swift-lldb#1596

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d64d138c6fe4ec98478015019c685c53967edcd9

@mikeash mikeash marked this pull request as ready for review June 27, 2019 20:41
@mikeash
Copy link
Contributor Author

mikeash commented Jun 27, 2019

apple/swift-lldb#1596

@swift-ci please test os x platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d64d138c6fe4ec98478015019c685c53967edcd9

SearchPathOpts.RuntimeLibraryPath = LibPath.str();
SearchPathOpts.RuntimeLibraryPaths.clear();
SearchPathOpts.RuntimeLibraryPaths.push_back(LibPath.str());
#if defined(__APPLE__) && defined(__MACH__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do this in terms of the target triple rather than the host architecture? I know we can only JIT in-process if they're the same, but it's the principle of the thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

if (resourceDir.empty()) return false;
return path.startswith(resourceDir);
for (auto &RuntimeLibraryPath : ctx.SearchPathOpts.RuntimeLibraryPaths) {
if (path.startswith(RuntimeLibraryPath)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be using RuntimeResourcePath to begin with. The system libraries are not in the compiler resource directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right you are.

@@ -38,7 +38,7 @@ namespace immediate {
/// calls or \c null if an error occurred.
///
/// \param runtimeLibPath Path to search for compiler-relative stdlib dylibs.
void *loadSwiftRuntime(StringRef runtimeLibPath);
void *loadSwiftRuntime(const std::vector<std::string> &runtimeLibPaths);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: ArrayRef<std::string> would be preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll fix it.

void *swift::immediate::loadSwiftRuntime(StringRef runtimeLibPath) {
return loadRuntimeLib("libswiftCore" LTDL_SHLIB_EXT, runtimeLibPath);
static void *loadRuntimeLib(StringRef sharedLibName,
const std::vector<std::string> runtimeLibPaths) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…which would have avoided the accidental copy here.

@mikeash
Copy link
Contributor Author

mikeash commented Jun 28, 2019

apple/swift-lldb#1596

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d64d138c6fe4ec98478015019c685c53967edcd9

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d64d138c6fe4ec98478015019c685c53967edcd9

@mikeash
Copy link
Contributor Author

mikeash commented Jun 28, 2019

@jrose-apple How's that look?

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mikeash
Copy link
Contributor Author

mikeash commented Jun 28, 2019

apple/swift-lldb#1596

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 01b5703fc27839ed7f1b95fbaf7469039d5f5d28

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 01b5703fc27839ed7f1b95fbaf7469039d5f5d28

mikeash added 2 commits July 1, 2019 13:08
…n Apple platforms.

Continue to load the dylibs next to the compiler if they exist. If they don't, then use the OS's dylibs.

rdar://problem/47528005
- Check the target triple at runtime to decide whether to use the fallback.
- Change isInResourceDir to actually check the resource dir.
- Use ArrayRef<std::string> instead of std::vector<std::string>.
@mikeash mikeash force-pushed the usrlibswift-fallback branch from 01b5703 to 9df513a Compare July 1, 2019 17:28
@mikeash
Copy link
Contributor Author

mikeash commented Jul 1, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2019

Build failed
Swift Test OS X Platform
Git Sha - 01b5703fc27839ed7f1b95fbaf7469039d5f5d28

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2019

Build failed
Swift Test Linux Platform
Git Sha - 01b5703fc27839ed7f1b95fbaf7469039d5f5d28

@mikeash
Copy link
Contributor Author

mikeash commented Jul 1, 2019

Forgot to mention the LLDB PR this time!

@mikeash
Copy link
Contributor Author

mikeash commented Jul 1, 2019

apple/swift-lldb#1596

@swift-ci please test

@mikeash mikeash merged commit 4a5c1a0 into swiftlang:master Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants