Darwin: Implement sysroot flag#2077
Conversation
|
@swift-ci please test |
| if let sysroot = parsedOptions.getLastArgument(.sysroot)?.asSingle { | ||
| commandLine.appendFlag("--sysroot") | ||
| try commandLine.appendPath(VirtualPath(path: sysroot)) | ||
| } else if let sdkPath = targetInfo.sdkPath?.path { |
There was a problem hiding this comment.
This might be better expressed as:
if let sysroot = parsedOptions.getLastArgument(.sysroot)?.asSingle ?? targetInfo.sdkPath?.path {
commandLine.appendFlag("--sysroot")
try commandLine.appendPath(VirtualPath(path: sysroot))
}There was a problem hiding this comment.
the sdkPath is a VirtualPath.Handle, not a string. I don't think we can merge these like this.
There was a problem hiding this comment.
It might make sense to refactor constructing the virtual path for the sysroot though?
There was a problem hiding this comment.
For the next PR, refactors this to store both as TextualVirtualPath objects in the driver so that we can merge these clauses: etcwilde@fe2bd92
| "-target", "x86_64-apple-macosx10.14", | ||
| "-sdk", sdk.pathString, | ||
| "-sysroot", customSysroot.pathString, | ||
| "foo.swift"], env: envVars) |
There was a problem hiding this comment.
I tend to prefer test.swift or something other than "foo" given its unfortunate history.
There was a problem hiding this comment.
I feel like I missed something while I was out. When was foo disallowed, and why?
535db50 to
c1ce976
Compare
|
The test failure is:
in one of the explicit module build tests. I don't believe that this change is related to that failure, but it looks like things haven't been testing or merging cleanly for a while here so I can't really make out what I should expect. |
|
You need to run That failure is fixed in #2074 and I just merged. There might still be other issue. |
|
@swift-ci please test |
|
@swift-ci please test Windows |
The sysroot flag is designed to control where the compiler looks for the C runtimes and headers that one would normally find in an SDK for a system. Apple SDKs contain both the Swift runtimes and the other platform libraries, so under normal circumstances, this flag isn't needed. It is useful, however, for consistency and testing purposes. As we're bringing up the split runtime/compiler build on the main repository, having the ability to tell the compiler under test to use the just-built Swift runtimes, but also where to find the existing system libraries (libsystem.tbd, e.g.) is incredibly useful. If the sysroot flag is set, it take precedence for the clang importer and clang-linker. If the sysroot flag is left unset but an sdk flag is set, the compiler should implicitly fall back on the sdk flag, which is the current behavior. Finally, if neither are set, it falls back on whatever default the frontend uses, and no special flags are forwarded.
c1ce976 to
0e7acd4
Compare
|
@swift-ci please test |
|
@swift-ci please test Windows |
Not just for that, I took a look at the macOS CI after we discussed this new flag on the Build and Packaging workgroup call a couple weeks ago and I see that the If the plan is to move that Darwin build to this |
The sysroot flag is designed to control where the compiler looks for the C runtimes and headers that one would normally find in an SDK for a system. Apple SDKs contain both the Swift runtimes and the other platform libraries, so under normal circumstances, this flag isn't needed.
It is useful, however, for consistency and testing purposes. As we're bringing up the split runtime/compiler build on the main repository, having the ability to tell the compiler under test to use the just-built Swift runtimes, but also where to find the existing system libraries (libsystem.tbd, e.g.) is incredibly useful.
If the sysroot flag is set, it take precedence for the clang importer and clang-linker.
If the sysroot flag is left unset but an sdk flag is set, the compiler should implicitly fall back on the sdk flag, which is the current behavior.
Finally, if neither are set, it falls back on whatever default the frontend uses, and no special flags are forwarded.