Open erikkerber opened 1 year ago
A quick hack workaround is to pass --swiftcopt=-wmo --swiftcopt=-num-threads --swiftcopt=0
but this might have other downsides
@keith Think we should close this one as will-never-happen or think there's a maybe-world where this is possible?
I'll close as a dup of that one, if that one ever moves we should re-evaluate if we need to make changes
I'm re-opening because it seems like Bazel will not be able to support this within Starlark (analysis time) but if we can move this work to the execution phase to match rules like objc_library
which do work with directory artifacts then thats something worth discussing.
When using a directory in the
srcs
ofswift_library
, the rules declare an incorrect intermediate object file for the directory and the build fails:This works using
objc_library
:Repro (credit @thii)
``` # rule.bzl def _impl(ctx): dir_name = ctx.attr.name out = ctx.actions.declare_directory(dir_name) ctx.actions.run_shell( outputs = [out], command = """ cd {} mkdir {} touch {}/File{} """.format( ctx.bin_dir.path, dir_name, dir_name, ctx.attr.ext, dir_name, ctx.attr.ext, ), ) return [DefaultInfo(files = depset([out]))] my_rule = rule( _impl, attrs = { "ext": attr.string() }, ) ``` ``` # BUILD load(":rule.bzl", "my_rule") load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") my_rule( name = "a", ext = ".m", ) objc_library( name = "b", srcs = [":a"], ) my_rule( name = "c", ext = ".swift", ) swift_library( name = "d", srcs = [":c"], ) ```