utargets
This document provides an overview of the commands and options available under buck2 utargets.
buck2 utargets
Show details about the specified targets.
This command is meant to only handle unconfigured targets, but for historical reasons, with certain flags it can also work with configured targets.
Usage: buck2 utargets [OPTIONS] [TARGET_PATTERNS]...
Arguments:
<TARGET_PATTERNS>Patterns to interpret
Options:
-
--jsonPrint targets as JSON -
--json-linesPrint targets as JSON-lines -
--statsPrint statistics of how many entries were processed -
--resolve-aliasPrint the fully-qualified build target for the specified aliases -
--show-target-hashPrint a stable hash of each target after the target name -
--show-unconfigured-target-hashPrint a stable unconfigured hash of each target after the target name -
--target-hash-file-mode <TARGET_HASH_FILE_MODE>Modifies computation of target hashes. If set toPATHS_AND_CONTENTS(the default), the contents of all files referenced from the targets will be used to compute the target hash. If set toPATHS_ONLY, only files' paths contribute to the hash. If set toNONEno files will be used. See also --target-hash-modified-paths- Default value:
paths_and_contents - Possible values:
paths_onlypaths_and_contentsnone
- Default value:
-
--target-hash-modified-paths <TARGET_HASH_MODIFIED_PATHS>Modifies computation of target hashes. Only effective when --target-hash-file-mode is set toPATHS_ONLY. If a target or its dependencies reference a file from this set, the target's hash will be different than if this option was omitted. Otherwise, the target's hash will be the same as if this option was omitted -
--target-hash-function <TARGET_HASH_FUNCTION>Selects either the "fast" or the "strong" target hash function to be used for computing target hashes. While we don't specify the exact algorithm, the "strong" algorithm should be a reasonable cryptographic hash (ex. blake3) while the "fast" function will likely be a non-crypto hash. Both functions are guaranteed to be deterministic and to have the same value across different platforms/architectures- Default value:
fast - Possible values:
sha1sha256murmur-hash3faststrong
- Default value:
-
--target-hash-recursive <TARGET_HASH_RECURSIVE>When true, emit the hash or target node and all dependencies recursively. When false, hash only the target node- Default value:
true - Possible values:
truefalse
- Default value:
-
-A, --output-all-attributesOutput all attributes, equivalent of --output-attribute ''.Avoid using this flag in automation because it may be expensive to produce certain attributes, and because it makes harder to track which special attributes are used.
-
-B, --output-basic-attributesOutput basic attributes, namely those the user can supply, plus rule type and package name -
-a, --output-attribute <ATTRIBUTE>Regular expressions to match attributes. Regular expressions are used in "search" mode, so for example empty string matches all attributes including special attributes.When using in automation, please specify the regular expression to match the attribute precisely, for example
--output-attribute '^headers$'to make it easier to track which special attributes are used. -
--output-attributes <ATTRIBUTE>Deprecated: Use--output-attributeinstead.List of space-separated attributes to output, --output-attributes attr1 attr2.
-
--include-defaultsEnables printing of default attributes. This would be attributes in a target that aren't explicitly set in the target but instead use the default set in the rule declaration -
--show-outputPrint the path to the output for each of the rules relative to the project root -
--show-full-outputPrint the absolute path to the output for each of the rules -
--show-simple-outputPrint only the path to the output for each of the rules relative to the project root -
--show-full-simple-outputPrint only the absolute path to the output for each of the rules -
--show-json-outputPrint the output paths relative to the project root, in JSON format -
--show-full-json-outputPrint the output absolute paths, in JSON format -
--keep-goingOn loading errors, put buck.error in the output stream and continue -
--streamingWrite output as soon as it is available. The order of the output items is non-deterministic and if multiple patterns cover the same target, may have duplicates -
--no-cacheDon't cache the target information on the build graph -
--importsShow the imports of each package/import. Shows an additional output per package/import (not per target), including implicit dependencies (e.g. the prelude) but only direct dependencies (not the transitive closure) -
--package-valuesShow the package values. Produces an additional attribute representing all the package values for the package containing the target -
--package-values-regex <VALUES>Regular expressions to match package values. Produces an additional attribute representing package values for the package containing the target. Regular expressions are used in "search" mode so, for example, empty string matches all package values -
-o, --output <PATH>File to put the output in, rather than sending to stdout.File will be created if it does not exist, and overwritten if it does.
-
--compression <SCHEME>Compress the output- Default value:
none - Possible values:
nonegzipzstd
- Default value:
-
-j, --num-threads <THREADS>Number of threads to use during execution (default is # cores) -
--target-platforms <PLATFORM>Configuration target (one) to use to configure targets -
-m, --modifier <VALUE>A configuration modifier to configure all targets on the command line. This may be a constraint value target. -
-c, --config <SECTION.OPTION=VALUE>List of config options -
--config-file <PATH>List of config file paths -
--fake-host <HOST>- Possible values:
defaultlinuxmacoswindows
- Possible values:
-
--fake-arch <ARCH>- Possible values:
defaultaarch64x8664
- Possible values:
-
--fake-xcode-version <VERSION-BUILD>Value must be formatted as: version-build (e.g., 14.3.0-14C18 or 14.1-14B47b) -
--reuse-current-configRe-uses any--configvalues (inline or via modefiles) if there's a previous command, otherwise the flag is ignored.If there is a previous command and
--reuse-current-configis set, then the old config is used, ignoring any overrides.If there is no previous command but the flag was set, then the flag is ignored, the command behaves as if the flag was not set at all.
-
--preemptible <PREEMPTIBLE>Used to configure when this command could be preempted by another command for the same isolation dir.Normally, when you run two commands - from different terminals, say - buck2 will attempt to run them in parallel. However, if the two commands are based on different state, that is they either have different configs or different filesystem states, buck2 cannot run them in parallel. The default behavior in this case is to block the second command until the first completes.
- Possible values:
never: (default) When another command starts that cannot run in parallel with this one, block that commandalways: When another command starts, interrupt this command, even if they could run in parallel. There is no good reason to use this other than that it provides slightly nicer superconsole outputondifferentstate: When another command starts that cannot run in parallel with this one, interrupt this command
- Possible values:
-
--exit-when <EXIT_WHEN>Whether to proceed with or fail this invocation based on the daemon state- Possible values:
never: (default) Execute this command normallydifferentstate: Fail this command if another command is already running with a different statenotidle: Fail this command if another command is already running (regardless of daemon state)
- Possible values:
-
--disable-starlark-typesDisable runtime type checking in Starlark interpreter.This option is not stable, and can be used only locally to diagnose evaluation performance problems.
-
--stackRecord or show target call stacks.Starlark call stacks will be included in duplicate targets error.
If a command outputs targets (like
targetscommand), starlark call stacks will be printed after the targets. -
--profile-patterns <PROFILE_PATTERNS>Enables profiling for all evaluations whose evaluation identifier matches one of the provided patterns.Some examples identifiers: analysis/cell//buck2/app/buck2_action_impl:buck2_action_impl (cfg:linux-x86_64#27ac5723e0c99706) load/cell//build_defs/json.bzl load/prelude//playground/test.bxl load/cell//build_defs/json.bzl@other_cell load_buildfile/fbcode//third-party-buck/platform010/build/ncurses load_packagefile/fbcode//cli/rust/cli_delegate anon_analysis/anon//:_anon_link_rule (anon: 766183dc9b6f680a) (fbcode//buck2/platform/execution:linux-x86_64#08961b14cfb182aa) bxl/prelude//playground/test.bxl:playground
You can pass
--profile-patterns=.*to enable no-op profiling for everything (additionally pass--profile-patterns-mode=noneto use no-op profiling to just get a list of all the identifiers).The profile results will be written to individual .profile files in
<ROOT_OUTPUT>/<data+time>-<uuid>/where ROOT_OUTPUT comes from the --profile-patterns-output flag. In that directory there will also be a file listing all the identifiers that were profiled.Enabling/disabling profiling of an evaluation will invalidate the results of that evaluation and it will be recomputed. In some cases, this will cause other work to also need to be redone (for example, invalidating the result of loading PACKAGE files causes all consumers to be recomputed). But if you keep profiling options consistent between commands, only the work that is otherwise invalidated will be redone (and only for those would profiling results be created).
You must also pass --profile-patterns-mode and --profile-patterns-output.
-
--profile-patterns-output <PATH> -
--profile-patterns-mode <PROFILE_PATTERNS_MODE>Profile mode.Memory profiling modes have suffixes either
-allocatedor-retained.-retainedmeans memory kept in frozen starlark heaps after analysis completes.-retaineddoes not work when profiling loading, because no memory is retained after loading and frozen heap is not even created. This is probably what you want when profiling analysis.-allocatedmeans allocated memory, including memory which is later garbage collected.- Possible values:
time-flameheap-allocatedheap-retainedheap-flame-allocatedheap-flame-retainedheap-summary-allocatedheap-summary-retainedstatementbytecodebytecode-pairstypecheckcoveragenone
- Possible values:
-
--console <super|simple|...>Which console to use for this command- Default value:
auto - Possible values:
autononesimplesimplenottysimplettysuper
- Default value:
-
--ui <UI>Configure additional superconsole ui components.Accepts a comma-separated list of superconsole components to add. Possible values are:
dice - shows information about evaluated dice nodes debugevents - shows information about the flow of events from buckd
These components can be turned on/off interactively. Press 'h' for help when superconsole is active.
- Possible values:
dicedebugeventsio: I/O panelre: RE panel
- Possible values:
-
--no-interactive-consoleDisable console interactions -
--event-log <PATH>Write events to this log file -
--write-build-id <PATH>Write command invocation id into this file -
--unstable-write-invocation-record <PATH>Write the invocation record (as JSON) to this path. No guarantees whatsoever are made regarding the stability of the format -
--command-report-path <PATH>Write the command report to this path. A command report is always written tobuck-out/v2/<uuid>/command_reporteven without this flag