bazelbuild / rules_swift

Bazel rules to build Swift on Apple and Linux platforms
Apache License 2.0
309 stars 133 forks source link

Infer emit-bc feature if -lto is passed #1207

Closed mjburghard closed 3 months ago

mjburghard commented 3 months ago

When passing -lto=llvm-thin or -lto=llvm-full to swiftc, it switches from emitting object files to bitcode files. To include llvm-bc instead of object in the generated output-file-map, the feature SWIFT_FEATURE_EMIT_BC (swift.emit_bc) must be inferred. This PR implements this similar to SWIFT_FEATURE__WMO_IN_SWIFTCOPTS.

keith commented 3 months ago

i think probably instead of doing this we should add new features for LTO which add these flags automatically, as well as the required feature?

mjburghard commented 3 months ago

@keith Something like swift.thin_lto and swift.full_lto? I found the feature for the unix_cc_toolchain. I may need a couple of pointers, but can look into this.

keith commented 3 months ago

yea that's what im thinking. generally we use new features for this stuff vs checking in on the command line args. at least one reason why that's nicer is command line arguments can be negated / overwritten and we'd probably need to handle that

mjburghard commented 3 months ago

First draft is in https://github.com/bazelbuild/rules_swift/pull/1208