Documentation

Edit

C / C++ Rules

cc_binary

cc_binary(name, deps, srcs, data, args, compatible_with, copts, defines, deprecation, distribs, features, includes, licenses, linkopts, linkshared, linkstatic, malloc, nocopts, output_licenses, restricted_to, stamp, tags, testonly, toolchains, visibility, win_def_file)

Implicit output targets

  • name.stripped (only built if explicitly requested): A stripped version of the binary. strip -g is run on the binary to remove debug symbols. Additional strip options can be provided on the command line using --stripopt=-foo. This output is only built if explicitly requested.
  • name.dwp (only built if explicitly requested): If Fission is enabled: a debug information package file suitable for debugging remotely deployed binaries. Else: an empty file.

Arguments

Attributes
name

Name; required

A unique name for this rule.

deps

List of labels; optional

The list of other libraries to be linked in to the binary target.

These can be cc_library, cc_inc_library, or objc_library targets.

srcs

List of labels; optional

The list of C and C++ files that are processed to create the target. These are C/C++ source and header files, either non-generated (normal source code) or generated.

All .cc, .c, and .cpp files will be compiled. These might be generated files: if a named file is in the outs of some other rule, this rule will automatically depend on that other rule.

A .h file will not be compiled, but will be available for inclusion by sources in this rule. Both .cc and .h files can directly include headers listed in these srcs or in the hdrs of any rule listed in the deps argument.

All #included files must be mentioned in the srcs attribute of this rule, or in the hdrs attribute of referenced cc_library()s. The recommended style is for headers associated with a library to be listed in that library's hdrs attribute, and any remaining headers associated with this rule's sources to be listed in srcs. See "Header inclusion checking" for a more detailed description.

If a rule's name is in the srcs, then this rule automatically depends on that one. If the named rule's outs are C or C++ source files, they are compiled into this rule; if they are library files, they are linked in.

Permitted srcs file types:

  • C and C++ source files: .c, .cc, .cpp, .cxx, .c++, .C
  • C and C++ header files: .h, .hh, .hpp, .hxx, .inc
  • Assembler with C preprocessor: .S
  • Archive: .a, .pic.a
  • "Always link" library: .lo, .pic.lo
  • Shared library, versioned or unversioned: .so, .so.version
  • Object file: .o, .pic.o

...and any rules that produce those files. Different extensions denote different programming languages in accordance with gcc convention.

copts

List of strings; optional

Add these options to the C++ compilation command. Subject to "Make variable" substitution and Bourne shell tokenization.

Each string in this attribute is added in the given order to COPTS before compiling the binary target. The flags take effect only for compiling this target, not its dependencies, so be careful about header files included elsewhere. All paths should be relative to the workspace, not to the current package.

If the package declares the feature no_copts_tokenization, Bourne shell tokenization applies only to strings that consist of a single "Make" variable.

defines

List of strings; optional

List of defines to add to the compile line. Subject to "Make" variable substitution and Bourne shell tokenization. Each string, which must consist of a single Bourne shell token, is prepended with -D (or /D on Windows) and added to COPTS. Unlike copts, these flags are added for the target and every rule that depends on it! Be very careful, since this may have far-reaching effects. When in doubt, add "-D" (or /D on Windows) flags to copts instead.
includes

List of strings; optional

List of include dirs to be added to the compile line.

Subject to "Make variable" substitution. Each string is prepended with -isystem and added to COPTS. Unlike COPTS, these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to COPTS instead.

Headers must be added to srcs or hdrs, otherwise they will not be available to dependent rules when compilation is sandboxed (the default).

linkopts

List of strings; optional

Add these flags to the C++ linker command. Subject to "Make" variable substitution, Bourne shell tokenization and label expansion. Each string in this attribute is added to LINKOPTS before linking the binary target.

Each element of this list that does not start with $ or - is assumed to be the label of a target in deps. The list of files generated by that target is appended to the linker options. An error is reported if the label is invalid, or is not declared in deps.

linkshared

Boolean; optional; nonconfigurable; default is 0

Create a shared library. To enable this attribute, include linkshared=1 in your rule. By default this option is off. If you enable it, you must name your binary libfoo.so (or whatever is the naming convention of libraries on the target platform) for some sensible value of foo.

The presence of this flag means that linking occurs with the -shared flag to gcc, and the resulting shared library is suitable for loading into for example a Java program. However, for build purposes it will never be linked into the dependent binary, as it is assumed that shared libraries built with a cc_binary rule are only loaded manually by other programs, so it should not be considered a substitute for the cc_library rule. For sake of scalability we recommend avoiding this approach altogether and simply letting java_library depend on cc_library rules instead.

If you specify both linkopts=['-static'] and linkshared=1, you get a single completely self-contained unit. If you specify both linkstatic=1 and linkshared=1, you get a single, mostly self-contained unit.

linkstatic

Boolean; optional; default is 0

For cc_binary and cc_test: link the binary in mostly-static mode. For cc_library.linkstatic: see below.

By default this option is on for cc_binary and off for the rest.

If enabled and this is a binary or test, this option tells the build tool to link in .a's instead of .so's for user libraries whenever possible. Some system libraries may still be linked dynamically, as are libraries for which there is no static library. So the resulting executable will still be dynamically linked, hence only mostly static.

There are really three different ways to link an executable:

  • FULLY STATIC, in which everything is linked statically; e.g. "gcc -static foo.o libbar.a libbaz.a -lm".
    This mode is enabled by specifying -static in the linkopts attribute.
  • MOSTLY STATIC, in which all user libraries are linked statically (if a static version is available), but where system libraries are linked dynamically, e.g. "gcc foo.o libfoo.a libbaz.a -lm".
    This mode is enabled by specifying linkstatic=1.
  • DYNAMIC, in which all libraries are linked dynamically (if a dynamic version is available), e.g. "gcc foo.o libfoo.so libbaz.so -lm".
    This mode is enabled by specifying linkstatic=0.

The linkstatic attribute has a different meaning if used on a cc_library() rule. For a C++ library, linkstatic=1 indicates that only static linking is allowed, so no .so will be produced.

If linkstatic=0, then the build tool will create symlinks to depended-upon shared libraries in the *.runfiles area.

malloc

Label; optional; default is @bazel_tools//tools/cpp:malloc

Override the default dependency on malloc.

By default, C++ binaries are linked against //tools/cpp:malloc, which is an empty library so the binary ends up using libc malloc. This label must refer to a cc_library. If compilation is for a non-C++ rule, this option has no effect. The value of this attribute is ignored if linkshared=1 is specified.

nocopts

String; optional

Remove matching options from the C++ compilation command. Subject to "Make" variable substitution. The value of this attribute is interpreted as a regular expression. Any preexisting COPTS that match this regular expression (including values explicitly specified in the rule's copts attribute) will be removed from COPTS for purposes of compiling this rule. This attribute should rarely be needed.
stamp

Integer; optional; default is 0

Enable link stamping. Whether to encode build information into the binary. Possible values:
  • stamp = 1: Stamp the build information into the binary. Stamped binaries are only rebuilt when their dependencies change. Use this if there are tests that depend on the build information.
  • stamp = 0: Always replace build information by constant values. This gives good build result caching.
  • stamp = -1: Embedding of build information is controlled by the --[no]stamp flag.
toolchains

List of labels; optional

The set of toolchains that supply "Make variables" that this target can use in some of its attributes. Some rules have toolchains whose Make variables they can use by default.
win_def_file

Label; optional

The Windows DEF file to be passed to linker.

This attribute should only be used when Windows is the target platform. It can be used to export symbols during linking a shared library.

cc_inc_library

cc_inc_library(name, deps, data, hdrs, compatible_with, deprecation, distribs, features, licenses, prefix, restricted_to, tags, testonly, visibility)

Bazel creates a subdirectory below includes (relative to WORKSPACE) for each such rule, and makes sure that all dependent rules have a corresponding -isystem directive to add this directory into the compiler's header file search path for all compilations. Note that if a rule has multiple cc_inc_library rules from the same package in its dependencies, the first such rule will take precedence.

One use case for the cc_inc_library rule is to allow C++ #include directives to work with external libraries that are placed in a version-specific subdirectory, without the version number. For example, it allows including a header file in /library/v1/a.h using the path /library/a.h. This is useful to avoid changing a lot of code when upgrading to a newer version. In this case, there should be one cc_inc_library rule per public target. Note that only files that are declared in the hdrs attribute are available with the rewritten path.

In this case, the cc_inc_library represents the interface of the package, and should be the public top-level rule so that strict header inclusion checks can be performed.

# This rule makes the header file v1/library.h available for inclusion via the
# path /library/library.h.
cc_inc_library(
    name = "library",
    hdrs = ["v1/library.h"],
    prefix = "v1",
    deps = [":library_impl"],
)

cc_library(
    name = "library_impl",
    srcs = [
        "v1/library.c",
        "v1/library.h",
    ],
    visibility = ["//visibility:private"],
)

Arguments

Attributes
name

Name; required

A unique name for this rule.

hdrs

List of labels; required

A list of header files. These are the header files that are exported by this rule. The relative paths of all files have to start with the prefix, in the sense that they have to be below the directory indicated by the prefix. Only header files are allowed.
prefix

String; optional

A prefix for this rule. This prefix is the directory that is removed from the beginning of all declared header files. The relative paths of all files have to start with this prefix. If no trailing slash is present, it is added automatically.

cc_library

cc_library(name, deps, srcs, data, hdrs, alwayslink, compatible_with, copts, defines, deprecation, distribs, features, include_prefix, includes, licenses, linkopts, linkstatic, nocopts, restricted_to, strip_include_prefix, tags, testonly, textual_hdrs, toolchains, visibility, win_def_file)

Header inclusion checking

All header files that are used in the build must be declared in the hdrs or srcs of cc_* rules. This is enforced.

For cc_library rules, headers in hdrs comprise the public interface of the library and can be directly included both from the files in hdrs and srcs of the library itself as well as from files in hdrs and srcs of cc_* rules that list the library in their deps. Headers in srcs must only be directly included from the files in hdrs and srcs of the library itself. When deciding whether to put a header into hdrs or srcs, you should ask whether you want consumers of this library to be able to directly include it. This is roughly the same decision as between public and private visibility in programming languages.

cc_binary and cc_test rules do not have an exported interface, so they also do not have a hdrs attribute. All headers that belong to the binary or test directly should be listed in the srcs.

To illustrate these rules, look at the following example.

cc_binary(
    name = "foo",
    srcs = [
        "foo.cc",
        "foo.h",
    ],
    deps = [":bar"],
)

cc_library(
    name = "bar",
    srcs = [
        "bar.cc",
        "bar-impl.h",
    ],
    hdrs = ["bar.h"],
    deps = [":baz"],
)

cc_library(
    name = "baz",
    srcs = [
        "baz.cc",
        "baz-impl.h",
    ],
    hdrs = ["baz.h"],
)

The allowed direct inclusions in this example are listed in the table below. For example foo.cc is allowed to directly include foo.h and bar.h, but not baz.h.

Including fileAllowed inclusions
foo.hbar.h
foo.ccfoo.h bar.h
bar.hbar-impl.h baz.h
bar-impl.hbar.h baz.h
bar.ccbar.h bar-impl.h baz.h
baz.hbaz-impl.h
baz-impl.hbaz.h
baz.ccbaz.h baz-impl.h

The inclusion checking rules only apply to direct inclusions. In the example above foo.cc is allowed to include bar.h, which may include baz.h, which in turn is allowed to include baz-impl.h. Technically, the compilation of a .cc file may transitively include any header file in the hdrs or srcs in any cc_library in the transitive deps closure. In this case the compiler may read baz.h and baz-impl.h when compiling foo.cc, but foo.cc must not contain #include "baz.h". For that to be allowed, baz must be added to the deps of foo.

Unfortunately Bazel currently cannot distinguish between direct and transitive inclusions, so it cannot detect error cases where a file illegally includes a header directly that is only allowed to be included transitively. For example, Bazel would not complain if in the example above foo.cc directly includes baz.h. This would be illegal, because foo does not directly depend on baz. Currently, no error is produced in that case, but such error checking may be added in the future.

Arguments

Attributes
name

Name; required

A unique name for this rule.

deps

List of labels; optional

The list of other libraries to be linked in to the binary target.

These can be cc_library, cc_inc_library, or objc_library targets.

srcs

List of labels; optional

The list of C and C++ files that are processed to create the target. These are C/C++ source and header files, either non-generated (normal source code) or generated.

All .cc, .c, and .cpp files will be compiled. These might be generated files: if a named file is in the outs of some other rule, this rule will automatically depend on that other rule.

A .h file will not be compiled, but will be available for inclusion by sources in this rule. Both .cc and .h files can directly include headers listed in these srcs or in the hdrs of any rule listed in the deps argument.

All #included files must be mentioned in the srcs attribute of this rule, or in the hdrs attribute of referenced cc_library()s. The recommended style is for headers associated with a library to be listed in that library's hdrs attribute, and any remaining headers associated with this rule's sources to be listed in srcs. See "Header inclusion checking" for a more detailed description.

If a rule's name is in the srcs, then this rule automatically depends on that one. If the named rule's outs are C or C++ source files, they are compiled into this rule; if they are library files, they are linked in.

Permitted srcs file types:

  • C and C++ source files: .c, .cc, .cpp, .cxx, .c++, .C
  • C and C++ header files: .h, .hh, .hpp, .hxx, .inc
  • Assembler with C preprocessor: .S
  • Archive: .a, .pic.a
  • "Always link" library: .lo, .pic.lo
  • Shared library, versioned or unversioned: .so, .so.version
  • Object file: .o, .pic.o

...and any rules that produce those files. Different extensions denote different programming languages in accordance with gcc convention.

hdrs

List of labels; optional

The list of header files published by this library to be directly included by sources in dependent rules.

This is the strongly preferred location for declaring header files that describe the interface for the library. These headers will be made available for inclusion by sources in this rule or in dependent rules. Headers not meant to be included by a client of this library should be listed in the srcs attribute instead, even if they are included by a published header. See "Header inclusion checking" for a more detailed description.

Boolean; optional; nonconfigurable; default is 0

If 1, any binary that depends (directly or indirectly) on this C++ library will link in all the object files for the files listed in srcs, even if some contain no symbols referenced by the binary. This is useful if your code isn't explicitly called by code in the binary, e.g., if your code registers to receive some callback provided by some service.
copts

List of strings; optional

Add these options to the C++ compilation command. Subject to "Make variable" substitution and Bourne shell tokenization.

Each string in this attribute is added in the given order to COPTS before compiling the binary target. The flags take effect only for compiling this target, not its dependencies, so be careful about header files included elsewhere. All paths should be relative to the workspace, not to the current package.

If the package declares the feature no_copts_tokenization, Bourne shell tokenization applies only to strings that consist of a single "Make" variable.

defines

List of strings; optional

List of defines to add to the compile line. Subject to "Make" variable substitution and Bourne shell tokenization. Each string, which must consist of a single Bourne shell token, is prepended with -D (or /D on Windows) and added to COPTS. Unlike copts, these flags are added for the target and every rule that depends on it! Be very careful, since this may have far-reaching effects. When in doubt, add "-D" (or /D on Windows) flags to copts instead.
include_prefix

String; optional

The prefix to add to the paths of the headers of this rule.

When set, the headers in the hdrs attribute of this rule are accessible at is the value of this attribute prepended to their repository-relative path.

The prefix in the strip_include_prefix attribute is removed before this prefix is added.

includes

List of strings; optional

List of include dirs to be added to the compile line.

Subject to "Make variable" substitution. Each string is prepended with -isystem and added to COPTS. Unlike COPTS, these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to COPTS instead.

Headers must be added to srcs or hdrs, otherwise they will not be available to dependent rules when compilation is sandboxed (the default).

linkopts

List of strings; optional

Add these flags to the C++ linker command. Subject to "Make" variable substitution, Bourne shell tokenization and label expansion. Each string in this attribute is added to LINKOPTS before linking the binary target.

Each element of this list that does not start with $ or - is assumed to be the label of a target in deps. The list of files generated by that target is appended to the linker options. An error is reported if the label is invalid, or is not declared in deps.

linkstatic

Boolean; optional; default is 0

For cc_binary and cc_test: link the binary in mostly-static mode. For cc_library.linkstatic: see below.

By default this option is on for cc_binary and off for the rest.

If enabled and this is a binary or test, this option tells the build tool to link in .a's instead of .so's for user libraries whenever possible. Some system libraries may still be linked dynamically, as are libraries for which there is no static library. So the resulting executable will still be dynamically linked, hence only mostly static.

There are really three different ways to link an executable:

  • FULLY STATIC, in which everything is linked statically; e.g. "gcc -static foo.o libbar.a libbaz.a -lm".
    This mode is enabled by specifying -static in the linkopts attribute.
  • MOSTLY STATIC, in which all user libraries are linked statically (if a static version is available), but where system libraries are linked dynamically, e.g. "gcc foo.o libfoo.a libbaz.a -lm".
    This mode is enabled by specifying linkstatic=1.
  • DYNAMIC, in which all libraries are linked dynamically (if a dynamic version is available), e.g. "gcc foo.o libfoo.so libbaz.so -lm".
    This mode is enabled by specifying linkstatic=0.

The linkstatic attribute has a different meaning if used on a cc_library() rule. For a C++ library, linkstatic=1 indicates that only static linking is allowed, so no .so will be produced.

If linkstatic=0, then the build tool will create symlinks to depended-upon shared libraries in the *.runfiles area.

nocopts

String; optional

Remove matching options from the C++ compilation command. Subject to "Make" variable substitution. The value of this attribute is interpreted as a regular expression. Any preexisting COPTS that match this regular expression (including values explicitly specified in the rule's copts attribute) will be removed from COPTS for purposes of compiling this rule. This attribute should rarely be needed.
strip_include_prefix

String; optional

The prefix to strip from the paths of the headers of this rule.

When set, the headers in the hdrs attribute of this rule are accessible at their path with this prefix cut off.

If it's a relative path, it's taken as a package-relative one. If it's an absolute one, it's understood as a repository-relative path.

The prefix in the include_prefix attribute is added after this prefix is stripped.

textual_hdrs

List of labels; optional

The list of header files published by this library to be textually included by sources in dependent rules.

This is the location for declaring header files that cannot be compiled on their own; that is, they always need to be textually included by other source files to build valid code.

toolchains

List of labels; optional

The set of toolchains that supply "Make variables" that this target can use in some of its attributes. Some rules have toolchains whose Make variables they can use by default.
win_def_file

Label; optional

The Windows DEF file to be passed to linker.

This attribute should only be used when Windows is the target platform. It can be used to export symbols during linking a shared library.

cc_proto_library

cc_proto_library(name, deps, data, compatible_with, deprecation, distribs, features, licenses, restricted_to, tags, testonly, visibility)

cc_proto_library generates C++ code from .proto files.

deps must point to proto_library rules.

Example:

cc_library(
    name = "lib",
    deps = [":foo_cc_proto"],
)

cc_proto_library(
    name = "foo_cc_proto",
    deps = [":foo_proto"],
)

proto_library(
    name = "foo_proto",
)

Arguments

Attributes
name

Name; required

A unique name for this rule.

deps

List of labels; optional

The list of proto_library rules to generate C++ code for.

cc_test

cc_test(name, deps, srcs, data, args, compatible_with, copts, defines, deprecation, distribs, features, flaky, includes, licenses, linkopts, linkstatic, local, malloc, nocopts, restricted_to, shard_count, size, stamp, tags, testonly, timeout, toolchains, visibility, win_def_file)

Arguments

Attributes
name

Name; required

A unique name for this rule.

deps

List of labels; optional

The list of other libraries to be linked in to the binary target.

These can be cc_library, cc_inc_library, or objc_library targets.

srcs

List of labels; optional

The list of C and C++ files that are processed to create the target. These are C/C++ source and header files, either non-generated (normal source code) or generated.

All .cc, .c, and .cpp files will be compiled. These might be generated files: if a named file is in the outs of some other rule, this rule will automatically depend on that other rule.

A .h file will not be compiled, but will be available for inclusion by sources in this rule. Both .cc and .h files can directly include headers listed in these srcs or in the hdrs of any rule listed in the deps argument.

All #included files must be mentioned in the srcs attribute of this rule, or in the hdrs attribute of referenced cc_library()s. The recommended style is for headers associated with a library to be listed in that library's hdrs attribute, and any remaining headers associated with this rule's sources to be listed in srcs. See "Header inclusion checking" for a more detailed description.

If a rule's name is in the srcs, then this rule automatically depends on that one. If the named rule's outs are C or C++ source files, they are compiled into this rule; if they are library files, they are linked in.

Permitted srcs file types:

  • C and C++ source files: .c, .cc, .cpp, .cxx, .c++, .C
  • C and C++ header files: .h, .hh, .hpp, .hxx, .inc
  • Assembler with C preprocessor: .S
  • Archive: .a, .pic.a
  • "Always link" library: .lo, .pic.lo
  • Shared library, versioned or unversioned: .so, .so.version
  • Object file: .o, .pic.o

...and any rules that produce those files. Different extensions denote different programming languages in accordance with gcc convention.

copts

List of strings; optional

Add these options to the C++ compilation command. Subject to "Make variable" substitution and Bourne shell tokenization.

Each string in this attribute is added in the given order to COPTS before compiling the binary target. The flags take effect only for compiling this target, not its dependencies, so be careful about header files included elsewhere. All paths should be relative to the workspace, not to the current package.

If the package declares the feature no_copts_tokenization, Bourne shell tokenization applies only to strings that consist of a single "Make" variable.

defines

List of strings; optional

List of defines to add to the compile line. Subject to "Make" variable substitution and Bourne shell tokenization. Each string, which must consist of a single Bourne shell token, is prepended with -D (or /D on Windows) and added to COPTS. Unlike copts, these flags are added for the target and every rule that depends on it! Be very careful, since this may have far-reaching effects. When in doubt, add "-D" (or /D on Windows) flags to copts instead.
includes

List of strings; optional

List of include dirs to be added to the compile line.

Subject to "Make variable" substitution. Each string is prepended with -isystem and added to COPTS. Unlike COPTS, these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to COPTS instead.

Headers must be added to srcs or hdrs, otherwise they will not be available to dependent rules when compilation is sandboxed (the default).

linkopts

List of strings; optional

Add these flags to the C++ linker command. Subject to "Make" variable substitution, Bourne shell tokenization and label expansion. Each string in this attribute is added to LINKOPTS before linking the binary target.

Each element of this list that does not start with $ or - is assumed to be the label of a target in deps. The list of files generated by that target is appended to the linker options. An error is reported if the label is invalid, or is not declared in deps.

linkstatic

Boolean; optional; default is 0

For cc_binary and cc_test: link the binary in mostly-static mode. For cc_library.linkstatic: see below.

By default this option is on for cc_binary and off for the rest.

If enabled and this is a binary or test, this option tells the build tool to link in .a's instead of .so's for user libraries whenever possible. Some system libraries may still be linked dynamically, as are libraries for which there is no static library. So the resulting executable will still be dynamically linked, hence only mostly static.

There are really three different ways to link an executable:

  • FULLY STATIC, in which everything is linked statically; e.g. "gcc -static foo.o libbar.a libbaz.a -lm".
    This mode is enabled by specifying -static in the linkopts attribute.
  • MOSTLY STATIC, in which all user libraries are linked statically (if a static version is available), but where system libraries are linked dynamically, e.g. "gcc foo.o libfoo.a libbaz.a -lm".
    This mode is enabled by specifying linkstatic=1.
  • DYNAMIC, in which all libraries are linked dynamically (if a dynamic version is available), e.g. "gcc foo.o libfoo.so libbaz.so -lm".
    This mode is enabled by specifying linkstatic=0.

The linkstatic attribute has a different meaning if used on a cc_library() rule. For a C++ library, linkstatic=1 indicates that only static linking is allowed, so no .so will be produced.

If linkstatic=0, then the build tool will create symlinks to depended-upon shared libraries in the *.runfiles area.

malloc

Label; optional; default is @bazel_tools//tools/cpp:malloc

Override the default dependency on malloc.

By default, C++ binaries are linked against //tools/cpp:malloc, which is an empty library so the binary ends up using libc malloc. This label must refer to a cc_library. If compilation is for a non-C++ rule, this option has no effect. The value of this attribute is ignored if linkshared=1 is specified.

nocopts

String; optional

Remove matching options from the C++ compilation command. Subject to "Make" variable substitution. The value of this attribute is interpreted as a regular expression. Any preexisting COPTS that match this regular expression (including values explicitly specified in the rule's copts attribute) will be removed from COPTS for purposes of compiling this rule. This attribute should rarely be needed.
stamp

Integer; optional; default is 0

Enable link stamping. Whether to encode build information into the binary. Possible values:
  • stamp = 1: Stamp the build information into the binary. Stamped binaries are only rebuilt when their dependencies change. Use this if there are tests that depend on the build information.
  • stamp = 0: Always replace build information by constant values. This gives good build result caching.
  • stamp = -1: Embedding of build information is controlled by the --[no]stamp flag.
toolchains

List of labels; optional

The set of toolchains that supply "Make variables" that this target can use in some of its attributes. Some rules have toolchains whose Make variables they can use by default.
win_def_file

Label; optional

The Windows DEF file to be passed to linker.

This attribute should only be used when Windows is the target platform. It can be used to export symbols during linking a shared library.