Skip to content
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

[SR-13255] [swift-driver] Darwin-specific argument validation #1213

Closed
swift-ci opened this issue Jul 20, 2020 · 7 comments
Closed

[SR-13255] [swift-driver] Darwin-specific argument validation #1213

swift-ci opened this issue Jul 20, 2020 · 7 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-13255
Radar None
Original Reporter owenvoorhees (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s
Labels Improvement, StarterBug, swift-driver
Assignee srinikhil07 (JIRA)
Priority Medium

md5: fc54056e575ca013a03072c8d28f5400

Issue Description:

The current argument validation implementation specific to Darwin platforms (macOS, iOS, etc.) is incomplete. DarwinToolchain.validateArguments contains a number of TODOs for porting over validation steps from the C++ driver. The original implementation of these checks can be found here: https://github.com/apple/swift/blob/d3ecf8848ede62368896410ec6b891c1a34f2e4c/lib/Driver/DarwinToolChains.cpp#L932

@swift-ci
Copy link
Contributor Author

Comment by Nikhil (JIRA)

owenvoorhees (JIRA User)

I would like to work on this. Please guide me with starting steps.

@swift-ci
Copy link
Contributor Author

Comment by Owen Voorhees (JIRA)

srinikhil07 (JIRA User) Hi! I'd recommend starting by checking out and building swift-driver if you haven't already and making sure you can run the tests. There are directions on how to do that in the README here: https://github.com/apple/swift-driver/blob/master/README.md.

After that, if you take a look at the first link in description you'll see that there are three TODOs in DarwinToolchain.validateArguments that correspond to three validation steps the C++ driver is performing in the second link. Of those, `// TODO: Validating darwin unsupported -static-stdlib argument.` is probably the best starting point. This check emits a diagnostic if somebody passes the `-static-stdlib` argument to the driver when compiling for a Darwin platform (macOS/iOS/etc.), and can probably be included directly in DarwinToolchain.validateArguments. Once that's implemented, you should be able to add a test in SwiftDriverTests.swift which verifies the diagnostic is emitted.

Feel free to let me know if you have any questions! The README also links to some other documentation about the driver that might be helpful.

@swift-ci
Copy link
Contributor Author

Comment by Nikhil (JIRA)

owenvoorhees (JIRA User)

Hi. Thanks for the steps.

I could build the swift-driver, but any test I run I get the below error. Guess I am missing something,

/Users/user/Code/driver-swift/swift-driver/Sources/SwiftDriver/Execution/DriverExecutor.swift:67: error: -[SwiftDriverTests.AssertDiagnosticsTests testAssertDriverDiagosotics] : failed: caught error: "keyNotFound(CodingKeys(stringValue: "compilerVersion", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"compilerVersion\", intValue: nil) (\"compilerVersion\").", underlyingError: nil))"

I have done the three TODOs and wrote tests as well. I have to test them.

@swift-ci
Copy link
Contributor Author

Comment by Owen Voorhees (JIRA)

srinikhil07 (JIRA User) That error usually occurs if swift-driver is finding an older Swift toolchain. To run the tests, I think you'll need to install a recent trunk snapshot from swift.org, or use a locally built swift. Then, you can use it in tests by setting the SWIFT_DRIVER_SWIFT_FRONTEND_EXEC environment variable to point to it. Something like the following should work, or you can add the variable in the Xcode scheme editor:

SWIFT_DRIVER_SWIFT_FRONTEND_EXEC=path/to/snapshot/toolchain/bin/swift-frontend swift test

@swift-ci
Copy link
Contributor Author

Comment by Nikhil (JIRA)

owenvoorhees (JIRA User)

Please review #184

Do we have anything like clang-format for formatting Swift code here.

Also, I am not sure where to ask, so I am asking here

  1. Searching for TODO gave me 31 results, I am interesting to contribute, so can you assign me some,

  2. I have seen below comment for class DarwinToolchain. I am curious about how this is fixed. Can I try ?

//FIXME: This class is not thread-safe.

Thanks.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis
Copy link

@owenv Could you see if we can close this (the associated pull request is merged)? Thanks.

@shahmishal Could we transfer this issue to the swift-driver repo?

@owenv
Copy link
Contributor

owenv commented Oct 3, 2022

Yes, this can be closed now, thanks for checking

@owenv owenv closed this as completed Oct 3, 2022
@hborla hborla transferred this issue from swiftlang/swift Nov 2, 2022
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

No branches or pull requests

3 participants