From 18bcdd00ba8e505321928666ef15fa81eb5c7f41 Mon Sep 17 00:00:00 2001 From: Omar Zuniga Date: Wed, 25 Aug 2021 07:09:23 -0700 Subject: [PATCH] LLVM BC support Using [rules_swift](https://github.com/bazelbuild/rules_swift) it is possible to generate LLVM IR BC files using `swift.emit_bc` feature, some days ago a [refactor](https://github.com/bazelbuild/rules_swift/commit/8cf36354655e6baa276fd7a5bae29b00ee5757c3#diff-535d0dbea9614c6905a30dfdb0e708df3b16fc68f8930d6aba519342509dc657R1948) to use `create_compilation_outputs` from `cc_common` was merged, it is giving us the following error since the bc extension is missing, this pr fixes it ``` Error in create_compilation_outputs: 'Somefile.swift.bc' has wrong extension. The list of possible extensions for 'objects' is: .o,.obj,.pic.o,.opb ``` Closes #13889. PiperOrigin-RevId: 392889724 (cherry picked from commit f53c389dbd4b0ae66307e9bd4a72b36b3d284ec3) --- .../google/devtools/build/lib/rules/cpp/CppFileTypes.java | 1 + .../java/com/google/devtools/build/lib/rules/cpp/Link.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java index 53aabe05ca981e..1dacd22fdcb4da 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java @@ -34,6 +34,7 @@ public final class CppFileTypes { public static final FileType OBJCPP_SOURCE = FileType.of(".mm"); public static final FileType CLIF_INPUT_PROTO = FileType.of(".ipb"); public static final FileType CLIF_OUTPUT_PROTO = FileType.of(".opb"); + public static final FileType BC_SOURCE = FileType.of(".bc"); public static final FileTypeSet ALL_C_CLASS_SOURCE = FileTypeSet.of( diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/Link.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/Link.java index 2328acd1962db4..593ac9614f9799 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/Link.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/Link.java @@ -63,7 +63,10 @@ private Link() {} // uninstantiable /** The set of object files */ public static final FileTypeSet OBJECT_FILETYPES = FileTypeSet.of( - CppFileTypes.OBJECT_FILE, CppFileTypes.PIC_OBJECT_FILE, CppFileTypes.CLIF_OUTPUT_PROTO); + CppFileTypes.OBJECT_FILE, + CppFileTypes.PIC_OBJECT_FILE, + CppFileTypes.CLIF_OUTPUT_PROTO, + CppFileTypes.BC_SOURCE); /** * Whether a particular link target requires PIC code.