Skip to content

Switch to using clang as linker on darwin #1111

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

Conversation

keith
Copy link
Member

@keith keith commented Jun 12, 2022

This allows us to remove lots of duplicated logic from the clang driver.

@keith
Copy link
Member Author

keith commented Jun 12, 2022

@swift-ci please test

@keith
Copy link
Member Author

keith commented Jun 12, 2022

This isn't done, but I just want to see how CI feels about it vs my local test

@keith keith force-pushed the ks/switch-to-using-clang-as-linker-on-darwin branch from 7a877c0 to 7c5160d Compare June 13, 2022 18:32
@keith
Copy link
Member Author

keith commented Jun 13, 2022

@swift-ci please test

@keith
Copy link
Member Author

keith commented Jun 13, 2022

@swift-ci Please test source compatibility

@artemcm
Copy link
Contributor

artemcm commented Jun 13, 2022

There's no source-compat testing on this repo, it needs to be requested from swift with cross-repo testing.

@keith
Copy link
Member Author

keith commented Jun 13, 2022

thanks, doing on swiftlang/swift#59414

@keith keith force-pushed the ks/switch-to-using-clang-as-linker-on-darwin branch from 7c5160d to b7bf20c Compare June 13, 2022 19:18
@compnerd
Copy link
Member

Thanks for doing this! I had mentioned to @artemcm that I would like to see this done but wanted to ensure that Apple was okay with the change. Unifying the behaviour and relying on clang to drive the linker is definitely going to help simplify the code base, but also help the C++ interop functionality as well IMO.

@keith
Copy link
Member Author

keith commented Jun 13, 2022

but wanted to ensure that Apple was okay with the change

I haven't consulted with anyone on this so I would definitely be interested to hear what folks think about this

@keith
Copy link
Member Author

keith commented Jun 13, 2022

@swift-ci please test

@keith
Copy link
Member Author

keith commented Jun 13, 2022

source compatibility on swiftlang/swift#59414 looks good, realistically im not entirely sure how we'll be 100% confident here though

@keith keith marked this pull request as ready for review June 18, 2022 23:48
@keith
Copy link
Member Author

keith commented Jul 5, 2022

@artemcm can you take a look? 🙏🏻

@artemcm artemcm self-requested a review July 15, 2022 16:55
Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

@keith this change looks good to me, and this is a huge improvement, thank you!
Let's merge this now and keep an eye out for any possible regressions.

@artemcm
Copy link
Contributor

artemcm commented Jul 15, 2022

@swift-ci please test

This allows us to remove lots of duplicated logic from the clang driver.
@keith keith force-pushed the ks/switch-to-using-clang-as-linker-on-darwin branch from b7bf20c to 7d910ed Compare July 15, 2022 17:19
@keith
Copy link
Member Author

keith commented Jul 15, 2022

awesome thanks! sorry i just rebased, will kick off ci again

@keith
Copy link
Member Author

keith commented Jul 15, 2022

@swift-ci please test

@keith
Copy link
Member Author

keith commented Jul 15, 2022

if you hear about any definitely cc me, i wouldn't be surprised if there is something i missed but i think fixes should be straight forward if so!

@artemcm artemcm merged commit 26895b4 into swiftlang:main Jul 15, 2022
@keith keith deleted the ks/switch-to-using-clang-as-linker-on-darwin branch July 15, 2022 17:49
commandLine.appendPath(VirtualPath.lookup(sdkPath))
}

commandLine.appendFlags(
"-fobjc-link-runtime",
Copy link
Contributor

Choose a reason for hiding this comment

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

@keith, what was the reason for always adding this flag?
It appears it does not match previous behavior and causes clang to always import Foundation, whether it is needed or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hrm, I don't recall since it has been a while, but I agree I don't see where it clearly came from. I checked clang as well in case I was trying to mirror that and don't see it there either. I suppose I could have pulled it from a -v invocation of what this was doing before, but if that flag is present there I don't see where it's coming from.

Note that it does look like https://github.com/apple/llvm-project/blob/c10fcd3e640b3736a7b2442f00db8feca674648c/clang/lib/Driver/ToolChains/Darwin.cpp#L745-L746 relies on this being passed, so maybe it was required for that case?

Copy link
Member

Choose a reason for hiding this comment

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

This really should be gated on -enable-objc-interop I think. -lSystem is also rather odd. This should no longer be needed as we now rely on clang as the driver which will add -lSystem as appropriate.

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