Skip to main content

cxx_universal_executable

cxx_universal_executable

def cxx_universal_executable(
*,
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 = "gh_facebook_buck2_shims_meta//:cxx",
executable: str,
executable_name: None | str = None,
labels: list[str] = [],
universal: None | bool = None,
) -> None

A cxx_universal_executable() rule takes a target via its binary attribute, builds it for multiple architectures and combines the result into a single binary using lipo.

Parameters

  • name: name of the target

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

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

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

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

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

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

  • metadata: a key-value map of metadata associated with this target

  • tests: a list of targets that provide tests for this one

  • modifiers: an array of modifiers associated with this target

  • executable: A build target identifying the binary which will be built for multiple architectures. The target will be transitioned into different configurations, with distinct architectures.

    The target can be one of:

    • cxx_binary()
    • [shared] subtarget cxx_library()
    • cxx_library() which have preferred_linkage = shared attribute
  • executable_name: By default, the name of the universal executable is same as the name of the binary from the binary target attribute. Set executable_name to override the default.

  • universal: Controls whether the output is universal binary. Any value overrides the presence of the config//cpu/constraints:universal-enabled constraint. Read the rule docs for more information on resolution.

Details

The output of the rule is a universal binary:

  • If config//cpu/constraints:universal-enabled is present in the target platform.
  • If the universal attribute is set to True.

If none of the conditions are met, then the rule acts as a nop alias().

The universal attribute, if present, takes precedence over constraint. For example, if universal = False, then the presence of the constraint would not affect the output.