Skip to main content

llvm_link_bitcode

An llvm_link_bitcode() rule combines a set of LLVM bitcode inputs into a single bitcode object using llvm-link.

Details

LLVM bitcode is the intermediate representation produced by Clang when compiling with -emit-llvm; merging multiple bitcode files into one allows downstream rules to perform whole-program optimization, link-time optimization (LTO), or other bitcode-level analyses on the combined module.

Inputs can be other llvm_link_bitcode() outputs, raw .bc / .o files containing bitcode, or cxx_library() rules producing bitcode artifacts.

Function Signature

def llvm_link_bitcode(
*,
name: str,
default_target_platform: None | str = None,
target_compatible_with: list[str] = [],
compatible_with: list[str] = [],
exec_compatible_with: list[str] = [],
visibility: list[str] = [],
within_view: list[str] = ["PUBLIC"],
metadata: OpaqueMetadata = {},
tests: list[str] = [],
modifiers: OpaqueMetadata = [],
_apple_platforms: dict[str, str] = {},
_cxx_toolchain: str = select({"prelude//:none": "gh_facebook_buck2_shims_meta//:cxx_no_default_deps", "DEFAULT": "gh_facebook_buck2_shims_meta//:cxx"}),
deps: list[str] = [],
deps_query: None | str = None,
srcs: list[str | (str, list[str])] = [],
) -> None

Parameters

  • name: (required)

    name of the target

  • default_target_platform: (defaults to: None)

    specifies the default target platform, used when no platforms are specified on the command line

  • target_compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with a configuration

  • compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with a configuration

  • exec_compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with an execution platform

  • visibility: (defaults to: [])

    a list of visibility patterns restricting what targets can depend on this one

  • within_view: (defaults to: ["PUBLIC"])

    a list of visibility patterns restricting what this target can depend on

  • metadata: (defaults to: {})

    a key-value map of metadata associated with this target

  • tests: (defaults to: [])

    a list of targets that provide tests for this one

  • modifiers: (defaults to: [])

    an array of modifiers associated with this target

  • deps_query: (defaults to: None)

    Status: experimental/unstable. The deps query takes a query string that accepts the following query functions, and appends the output of the query to the declared deps:

    • attrfilter
    • deps
    • except
    • intersect
    • filter
    • kind
    • set
    • union

    Some example queries:

      "filter({name_regex}, deps('//foo:foo'))".format(name_regex='//.*')
    "attrfilter(annotation_processors, com.foo.Processor, deps('//foo:foo'))"
    "deps('//foo:foo', 1)"
  • srcs: (defaults to: [])

    The set of C, C++, Objective-C, Objective-C++, or assembly source files to be preprocessed, compiled, and assembled by this rule. We determine which stages to run on each input source based on its file extension. See the GCC documentation for more detail on how file extensions are interpreted. Each element can be either a string specifying a source file (e.g. '') or a tuple of a string specifying a source file and a list of compilation flags (e.g. ('', ['-Wall', '-Werror']) ). In the latter case the specified flags will be used in addition to the rule's other flags when preprocessing and compiling that file (if applicable).

Examples


# A rule that builds and runs C/C++ test using gtest.
llvm_link_bitcode(
name = 'echo_test',
srcs = [
'echo_test.o', // Where this is a LLVM bitcode object.
'echo_other.o', // And this is another LLVM bitcode object.
],
)