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

[lld] Disable ability to link Mach-O for Darwin platforms (but not non-Darwin firmware) in Swift LLVM fork #8119

Merged

Conversation

kubamracek
Copy link

For Embedded Swift, we want to start including lld even in Darwin toolchains to be able to link ELF files even on Darwin, see swiftlang/swift#70715. To avoid accidentally using lld to link Mach-O files, let's disable this ability in the Apple fork of llvm-project. Linking Mach-Os is only supported using the Xcode-provided Darwin linker (ld/ld64).

Copy link
Member

@rauhul rauhul left a comment

Choose a reason for hiding this comment

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

I think this should only be compiled out on darwin. When building lld for linux you should still be able to try to build and link machos even if they wont work in all cases. Artificially nerfing the linux -> Darwin build feels user hostile

@kubamracek kubamracek force-pushed the 20230725-lld-no-macho branch from 893ef7f to 71ad316 Compare March 23, 2024 02:14
@kubamracek kubamracek changed the title [lld] Disable Darwin/Mach-O driver in lld [lld] Disable ability to link Mach-O for Darwin platforms (but not non-Darwin firmware) in Swift LLVM fork Mar 23, 2024
@kubamracek
Copy link
Author

Changed this PR to not disable Mach-O linking completely, but only when building for Darwin userspace platforms. @rauhul does that seem reasonable now?

@kubamracek kubamracek requested a review from rauhul March 23, 2024 02:15
Copy link
Member

@rauhul rauhul left a comment

Choose a reason for hiding this comment

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

Yup

@kubamracek
Copy link
Author

@swift-ci please test

@kabiroberai
Copy link

Apologies if I'm missing something, but how would one go about doing a Linux -> Darwin cross link after this commit? Prior to this ld64.lld would work fine on Linux but I'm now tripping this error message no matter what. Currently resorting to patching lld (kabiroberai/darwin-tools-linux-llvm@a3d91eb) and rebuilding from source to support the 6.1 snapshots, which is unfortunate because I could pretty much use the Swift toolchain's lld in 6.0.2.

@kabiroberai
Copy link

Hi folks, I created a PR to update this check to only abort on Darwin hosts. Would appreciate your review! #9698

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