-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[autolink-extract] Support (and ignore) LLVM IR files. #71142
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
Conversation
In Linux, the current implementation of swift-autolink-extract does not support LLVM IR files resulting from using LTO. If one tries to build LLVM using LTO and then try to link one of the targets that use `swiftc` to link, but link against LLVM object files (like `swift-plugin-server`), `swift-autolink-extract` will fail saying that some object files are not valid. To deal with LLVM IR files correctly, create and pass a `llvm::LLVMContext` around, which allows the APIs in `llvm::object` to read LLVM IR files. Additionally, handle the case of `IRObjectFile` when extracting, but perform no action.
@swift-ci please test |
@swift-ci please test Linux platform |
@drodriguez For bitcode linker input files, we already emit So I'm curious about what invokes swift-autolink-extract in your scenario. |
The setup is complicated. We always build Swift not standalone, but using
The provided test jumps over the usage of the Swift driver, but more or less reproduces what's going on: some step compiles a C++ files with LTO, the Swift driver is invoked and given those bitcode objects (both in the form of single objects and also in the form of archives of bitcode objects), the driver passes all the paths with extensions |
@drodriguez Thank you for your elaboration! Given that situation, accepting and ignoring object files from foreign sources makes sense to me. I'd like to hear @compnerd opinion just in case. |
@compnerd: added you as a reviewer. @kateinoigakukun above wanted to know your opinion. |
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, this makes sense - the autolink-extract
is meant to serve as a workaround for non-lld linker compatibility. The IR files will be emitted to objects and passed to the linker subsequently. We still need to use swift-autolink-extract
on it at some point, but the IR files themselves would not contribute. I think that this change is insufficient for enabling thin lto, but is improving the state of the world.
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 change makes sense to me, thank you.
In Linux, the current implementation of swift-autolink-extract does not support LLVM IR files resulting from using LTO.
If one tries to build LLVM using LTO and then try to link one of the targets that use
swiftc
to link, but link against LLVM object files (likeswift-plugin-server
),swift-autolink-extract
will fail saying that some object files are not valid.To deal with LLVM IR files correctly, create and pass a
llvm::LLVMContext
around, which allows the APIs inllvm::object
to read LLVM IR files. Additionally, handle the case ofIRObjectFile
when extracting, but perform no action.