-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add some utility functions for obtaining runtime-relative paths. #62462
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
Closed
Conversation
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
@swift-ci Please smoke test |
compnerd
requested changes
Dec 8, 2022
mikeash
reviewed
Dec 8, 2022
d07e570
to
7d651d5
Compare
fd31c5c
to
1a11cf5
Compare
@swift-ci Please smoke test |
91e1769
to
b9f513b
Compare
@swift-ci Please smoke test |
grynspan
reviewed
Dec 15, 2022
b9f513b
to
09723c4
Compare
@swift-ci Please smoke test |
1 similar comment
@swift-ci Please smoke test |
7f1461b
to
84058ea
Compare
@swift-ci Please smoke test Windows platform |
84058ea
to
200513d
Compare
@swift-ci Please smoke test |
0c8c9c0
to
5835bab
Compare
@swift-ci Please smoke test |
compnerd
reviewed
Jan 4, 2023
a33eaeb
to
1529320
Compare
@swift-ci Please smoke test |
Adds the ability to locate files relative to the path of the Swift runtime library, libswiftCore. rdar://103071801
The path to the runtime should be something like /usr/lib/swift/libswiftCore.dylib So we want to strip lib/swift/ off to get the Swift root. We also want auxiliary executables in /usr/libexec/swift rather than just /usr/libexec (While still supporting flat layout for Windows.) rdar://103071801
Apparently the `swiftCore.lib` file is in `%target-sdk-name/%target-arch` within the build directory. rdar://103071801
Windows doesn't have a "lib" prefix on the Swift DLLs. rdar://103071801
GetMappedFilenameW() returns an NT-style path, not a Win32 path, but we need a Win32 path. rdar://103071801
On Windows, swift_getRootPath() should return the root path (i.e. outside the "bin" directory). On Linux, the path for the runtime looks like <swift-root>/lib/swift/linux/libswiftCore.so rather than <swift-root>/lib/swift/libswiftCore.so as you might expect. On macOS, the path for the runtime *can* have "macosx" in it if we're using the library from the build path. That's not how it gets installed when it's part of the operating system, but it's how we build it. Also make swift_getAuxiliaryExecutablePath() actually check that the executable exists. This does mean it can return nullptr now, but it also means that it can search through the various locations it supports to try to find the file you're after, which is more robust. rdar://103071801
Change _swift_initRootPath() to do an early return, which reduces indentation. Add a comment to reinforce that we can't use GetFinalPathNameByHandle() in _swift_initRuntimePath(). rdar://103071801
It turns out that the path to the runtime might also include the architecture as well as the platform. So we need to search <root>/lib/swift/<platform> <root>/lib/swift/<platform>/<arch> <root>/lib/swift <root>/lib/swift/<arch> <root>/bin/ <root>/bin/<arch> <root> in that order. Hopefully this now covers all the possibilities. rdar://103071801
ed35d3d
to
87932c6
Compare
@swift-ci Please smoke test |
This is going to be replaced by al45tair#8 (part of the PR stack for the initial drop of the backtracing work). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds the ability to locate files relative to the path of the Swift runtime library, libswiftCore.
rdar://103071801