-
Notifications
You must be signed in to change notification settings - Fork 205
File list support #144
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
File list support #144
Conversation
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.
Thanks for working on this! I'd like to hear your thoughts on my alternative modeling for the file list files themselves
Okay, still a bit of work todo. Need to refactor the FileList object and ArgsResolver (also add the new VirtualPath case). Then need to write tests for everything, there are a lot of little edge cases caught by the lit tests. Also I want to pull out a few changes into other smaller PRs. Newly passing: Mostly working (Just temporary file handling, and some path formatting(I can open swift PR for this)): Issues with Driver/filelists.swift:
|
@DougGregor I've hit a snag in the ArgsResolver managing which filelists are written. In order to make the ArgsList actually keep track of this state it needs to be a class (or needs to be provided access to something else that tracks this state). Because two compile jobs can use the same filelist, the ArgsResolver then needs to use locking. Previously two jobs could resolve their arguments entirely in parallel. I'm going to move forward with the locking to see how it works out, but it does seem less than ideal. |
9ef58e3
to
4768b9e
Compare
Okay, rebased this. Most tests are failing locally due to |
Maybe you're picking up the Swift compiler/frontend executable from the default toolchain. If you haven't don't so yet, I suggest overriding the environment variable |
Yep, this was it. I'm hard coding it now for testing. Looks like There might be some legitimate failures. |
Environment variable works as well. Using that now :) |
I think the only TODO that is left is to port some of the lit tests to XCTest, so we have coverage here. |
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.
This is looking really great!
@@ -1730,7 +1782,7 @@ extension Driver { | |||
return path | |||
} | |||
|
|||
return path.parentDirectory.appending(component: "\(moduleName).\(type.rawValue)") | |||
return path.replacingExtension(with: type) |
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.
I think this and/or the change at line 1889 will break the Driver/opt-record.swift integration test, getting these path computations to match the c++ driver has been really challenging due to the architectural differences between the two implementations. Maybe we can get away with just picking better defaults in swift-driver since most clients that care about these outputs are already using output file maps...
Either way, if this can't be fixed yet and we have to make a choice between file list and optimization record tests passing in the short term, I'd choose file lists 😄
// Question: outputs.count > fileListThreshold makes sense, but c++ does the following: | ||
if primaryInputs.count * FileType.allCases.count > fileListThreshold { |
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.
I think the c++ driver has to overestimate here because it doesn't know how many outputs there will be when it does this calculation. It should be ok to use a tighter bound here if possible
// I don't like this as a global function, but it needs to be used by both Driver and Toolchain | ||
func createTemporaryFileName(prefix: String, suffix: String? = nil) -> String { |
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.
Maybe the ArgsResolver could be responsible for appending the number? Not sure if that would help much.
// This uses Yams to escape and quote strings, but not to output the whole yaml file because | ||
// it sometimes outputs mappings in explicit block format (https://yaml.org/spec/1.2/spec.html#id2798057) | ||
// and the frontend (llvm) only seems to support implicit block format. |
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.
Yeah, I can confirm the llvm yaml parser doesn't handle explicit block format unfortunately
0f3e9a1
to
48e5ff9
Compare
Okay, rebased. Resolved concerns from comments and added tests. Should be all good now :) |
@swift-ci please test |
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.
Everything here looks good to me, thanks again for working on this!
I do think we'll want to rework the temporary file naming at some point to avoid collisions better. TSC has a withTemporaryFile utility for this, but I think it has the same problem as withTemporaryDirectory - it always uses the local file system. I'm fine with merging this as-is as long as @DougGregor doesn't have any remaining concerns!
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.
This looks good to me, thank you for picking it up again!
Okay, merge when ready |
This is breaking the swift-package-manager build :-( |
swiftlang/swift-driver#144 introduced a new case in the `VirtualPath` type, resulting in the switch no longer being exhaustive. Abort if this is encountered until it can be handled properly.
Looks like a switch needs to be updated to support the new case added to VirtualPath:
|
Major changes:
case fileList(RelativePath, FileList)
fileList
case.