Skip to content

Revert "Switch to using clang as linker on darwin" #1142

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

artemcm
Copy link
Contributor

@artemcm artemcm commented Jul 20, 2022

Reverts #1111

@artemcm artemcm requested a review from keith July 20, 2022 16:45
@artemcm
Copy link
Contributor Author

artemcm commented Jul 20, 2022

@keith we are seeing failures in CI with:

ld: file not found: /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/toolchain-macosx-x86_64/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a\nclang-13: error: linker command failed with exit code 1 (use -v to see invocation)\nninja: build stopped: subcommand failed.\n'

Most likely because we removed the logic in this PR to add -force_load for the libArcLite the driver locates:
https://github.com/apple/swift-driver/pull/1111/files#diff-d44ec7a906797a39be2e42ecb334167ae217537ad09a726d1f905c4ba9130200L169

Could you please take a look?

@artemcm
Copy link
Contributor Author

artemcm commented Jul 20, 2022

@artemcm
Copy link
Contributor Author

artemcm commented Jul 20, 2022

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Jul 20, 2022

@DougGregor also pointed out that the issue is due to special logic in clang for this:
https://github.com/apple/llvm-project/blob/next/clang/lib/Driver/ToolChains/Darwin.cpp#L1296
Uses getXcodeDeveloperPath:
https://github.com/apple/llvm-project/blob/next/clang/lib/Driver/ToolChains/Darwin.cpp#L1266

Which isn't doing the right thing to find Xcode. Instead, it should be using:

xcrun -toolchain default -f clang

@artemcm
Copy link
Contributor Author

artemcm commented Jul 20, 2022

So we can either re-add the removed logic for handling arclite back to this driver, or investigate fixing up what Clang driver is doing possibly incorrectly here.

@artemcm artemcm requested review from glessard and DougGregor July 20, 2022 17:02
Copy link
Contributor

@glessard glessard left a comment

Choose a reason for hiding this comment

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

Thanks!

@glessard glessard merged commit d8640a2 into main Jul 20, 2022
@DougGregor
Copy link
Member

The Swift Driver does something a bit more robust than Clang, by checking if the lib/arc actually exists and, if not, fallback back to asking xcrun where the default toolchain is. See https://github.com/apple/swift-driver/blob/60ed7665e3845175dc44c6acf06c4b7b31ddaf55/Sources/SwiftDriver/Jobs/DarwinToolchain%2BLinkerSupport.swift#L18-L48

@DougGregor DougGregor deleted the revert-1111-ks/switch-to-using-clang-as-linker-on-darwin branch July 20, 2022 17:05
@DougGregor
Copy link
Member

I have a Clang fix that should work: swiftlang/llvm-project#5007

@DougGregor DougGregor restored the revert-1111-ks/switch-to-using-clang-as-linker-on-darwin branch July 20, 2022 19:23
@DougGregor DougGregor deleted the revert-1111-ks/switch-to-using-clang-as-linker-on-darwin branch July 20, 2022 19:23
@DougGregor
Copy link
Member

I have a PR to reinstate this in #1143

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