Explicitly pass .swiftmodule and .swiftinterface files as action inputs#1583
Explicitly pass .swiftmodule and .swiftinterface files as action inputs#1583adincebic wants to merge 1 commit intobazelbuild:mainfrom
Conversation
dd23624 to
efa3f31
Compare
9ea7b48 to
89c0878
Compare
|
@brentleyjones can I have your opinion on this one? |
|
|
||
| return ConfigResultInfo( | ||
| inputs = prerequisites.transitive_swiftmodules, | ||
| inputs = transitive_inputs, |
There was a problem hiding this comment.
We should make it so prerequisites.transitive_swiftmodules has the right things (and probably rename it to transitive_included_modules... though maybe we don't do that for now to keep cherry-picks easier). Also, we should only add one or the other. We should add swift_module.swiftmodule if it exists, otherwise swift_module.private_swiftinterface, otherwise swift_module.swiftinterface.
There was a problem hiding this comment.
I am running into issues if I pick only one of those files since -swiftmodule is getting generated even though it is not explicitly passed. I am assuming that .swiftmodule is produced as a result of building swift_import target with .swiftinterface.
Basically we need to keep logic as is.
There was a problem hiding this comment.
I am assuming that
.swiftmoduleis produced as a result of buildingswift_importtarget with.swiftinterface
Ideally we wouldn't compile .swiftinterface and just pass it along as an importable module. You should only need to compile a (private) interface into a module if you needed access to package/protected types, right?
There was a problem hiding this comment.
I am not really familiar with how swift_import rule is implemented. But essentially I am building https://github.com/wesprint-io/swift-syntax-prebuilt/releases and it only exposes swift_import targets with no .swiftmodule files yet they are produced at some point and if I pick either .swiftmodule or .swiftinterface the build fails because it won't pick up the .swiftinterface since .swiftmodule appears and it gets selected. Only way that I was able to make it work is by including both of them like in this PR.
There was a problem hiding this comment.
@brentleyjones given the following swift_import target
swift_import(
name = "SwiftBasicFormat",
archives = select({":darwin_arm64": ["arm64/libSwiftBasicFormat.a"]}),
module_name = "SwiftBasicFormat",
swiftdoc = select({":darwin_arm64": "arm64/SwiftBasicFormat.swiftdoc"}),
swiftinterface = select({":darwin_arm64": "arm64/SwiftBasicFormat.swiftinterface"}),
visibility = ["//visibility:public"],
deps = [":SwiftSyntax"],
)
after executing build bazel build :SwiftBasicFormat I see the following files produced
SwiftSyntax601.swiftmodule-0.params
SwiftBasicFormat.swiftmodule
SwiftBasicFormat.swiftmodule-0.params
SwiftSyntax.swiftmodule
SwiftSyntax.swiftmodule-0.params
SwiftSyntax509.swiftmodule
SwiftSyntax509.swiftmodule-0.params
SwiftSyntax510.swiftmodule
SwiftSyntax510.swiftmodule-0.params
SwiftSyntax600.swiftmodule
SwiftSyntax600.swiftmodule-0.params
SwiftSyntax601.swiftmodule
I also added print staments to track this while build is in progress
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax509.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax509.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax510.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax510.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax600.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax600.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax601.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax601.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax509.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax509.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax510.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax510.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax600.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax600.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax601.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax601.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax.private.swiftinterface>
There was a problem hiding this comment.
if I pick either
.swiftmoduleor.swiftinterfacethe build fails because it won't pick up the.swiftinterfacesince.swiftmoduleappears and it gets selected. Only way that I was able to make it work is by including both of them like in this PR.
This sounds like a search path issue. VFS overlays, explicit modules, sandboxing, or swift.add_target_name_to_output should fix this, right?
I don't feel good about this change.
89c0878 to
c640605
Compare
|
|
||
| # Include both swiftmodule and swiftinterface files as inputs to ensure | ||
| # they are available in the sandbox for compilation | ||
| transitive_inputs = [prerequisites.vfsoverlay_file] |
There was a problem hiding this comment.
Do we need to do the same thing for explicit_swift_module_map_file?
|
|
||
| return ConfigResultInfo( | ||
| inputs = prerequisites.transitive_swiftmodules, | ||
| inputs = transitive_inputs, |
There was a problem hiding this comment.
if I pick either
.swiftmoduleor.swiftinterfacethe build fails because it won't pick up the.swiftinterfacesince.swiftmoduleappears and it gets selected. Only way that I was able to make it work is by including both of them like in this PR.
This sounds like a search path issue. VFS overlays, explicit modules, sandboxing, or swift.add_target_name_to_output should fix this, right?
I don't feel good about this change.
Previously when building
swift_importtargets that depend on otherswift_importtargets with.swiftinterfacefiles failed when using Bazel sandbox with error:The
SWIFT_ACTION_COMPILE_MODULE_INTERFACEaction was missing transitive dependency files as inputs so I made sure that they are explicitly listed.