swift
swift copied to clipboard
[Driver][Frontend] Introduce `load-pass-plugin` option
Allow dynamic loading of LLVM passes via load-pass-plugin
option passed to the Swift compiler driver, similarly to current Apple Clang -fpass-plugin
option.
Previous discussion: https://forums.swift.org/t/load-external-llvm-pass-plugins-via-swift-frontend/67596
Please, let me know if anything needs to be improved as far as style conventions et alia is concerned, I'd be happy to do so.
(cc/ @DougGregor)
Gentle ping. Any feedback or suggestions would be duly appreciated. Alongside this, I believe the option should be added as part of Options.swift as well. May that be the case? (cc/ @DougGregor, @rintaro).
Hey, this may not be getting much attention because the internal driver (this one) is considered legacy. The default driver as of Xcode 13 swift-driver. You might have better luck over there.
Note: I'm not affiliated with the Swift project in any way. Just a guy who'd love to see this merged
There was some discussion on this previously in: https://github.com/apple/swift/pull/38017
The driver and frontend pieces are separate and yes, proper driver support would mean adding the logic in https://github.com/apple/swift-driver. Legacy (C++-based) driver support being optional/discouraged.
@lhames @aschwaighofer can comment better on the architecture of loading such passes in IRGen.
Thanks a lot to both for the helpful insights. Support in the new swift-driver should be addressed by https://github.com/apple/swift-driver/pull/1472. The implementation should aim to ensure a clear separation between the driver and the frontend. Also, thanks for sharing #38017, was not aware of this. Reviewed the discussion there carefully, it was very informative.
Fixed conflicts by rebasing to main, and changed test library type from MODULE
to SHARED
, as CMake seems to be defaulting to generate the plugin with .so
extension on macOS too (rather than .dylib
, this was previously leading the unittest to fail).
Gentle ping (cc/ @lhames).
Just wanted to express support for this here as it also helps with adding plugins for AD
Also expressing support for this!
Rebased to main, dropped unittest in Driver
as part of recent legacy driver deprecation, added test coverage exercizing performLLVMOptimization
. New driver support ready at https://github.com/apple/swift-driver/pull/1472. Kind ping @lhames, @aschwaighofer, @artemcm, @benlangmuir, @weliveindetail.
@lhames, @airspeedswift Gentle ping. Any chance of this getting reviewed?
Kind ping (maybe cc/ @adrian-prantl).
@adrian-prantl Addressed comments and rebased to main, thank you for reviewing this!
@swift-ci test
Rebased to main, opened sister PR @ https://github.com/apple/llvm-project/pull/8678, reflecting changes (not sure if we should have targeted a different branch instead).
@adrian-prantl Kind ping on this, CI was previously failing.
Rebased to main (fixed conflicts), https://github.com/swiftlang/llvm-project/pull/8678 PR rebased to stable/20230725
, which should be the expected branch. Very gentle remainder. I do not have commit access, could anyone kindly merge this?
I assume this should be tested with:
Please test with following PR:
https://github.com/swiftlang/llvm-project/pull/8678
https://github.com/swiftlang/swift-driver/pull/1472
@swift-ci Please test
https://github.com/swiftlang/llvm-project/pull/8678 https://github.com/swiftlang/swift-driver/pull/1472
@swift-ci test
The macOS failure is:
/Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/stdlib/private/SwiftPrivate/IO.swift:21:8: error: failed to build module 'Darwin'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.9.2 (swiftlang-5.9.2.2.11 clang-1500.1.0.2.2)', while this compiler is 'Apple Swift version 6.1-dev effective-5.10 (LLVM 97c65ef47934098, Swift c06508954544f05)'). Please select a toolchain which matches the SDK.
19 | #else
20 | #if canImport(Darwin)
21 | import Darwin
| `- error: failed to build module 'Darwin'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.9.2 (swiftlang-5.9.2.2.11 clang-1500.1.0.2.2)', while this compiler is 'Apple Swift version 6.1-dev effective-5.10 (LLVM 97c65ef47934098, Swift c06508954544f05)'). Please select a toolchain which matches the SDK.
edit: should have been fixed by https://github.com/swiftlang/swift/pull/76344
https://github.com/swiftlang/llvm-project/pull/8678 https://github.com/swiftlang/swift-driver/pull/1472
@swift-ci test macos