diff --git a/docs/rules.md b/docs/rules.md index 647a5074..81449d2d 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -171,7 +171,7 @@ zig_configure( | mode | The build mode setting, corresponds to the `-O` Zig compiler flag. | String | optional | `""` | | target | The target platform, expects a label to a Bazel target platform used to select a `zig_target_toolchain` instance. | Label | optional | `None` | | threaded | The threaded setting, corresponds to the `-fsingle-threaded` Zig compiler flag. | String | optional | `""` | -| use_cc_common_link | Whether to use cc_common.link to link zig binaries, tests and shared libraries. | Boolean | optional | `False` | +| use_cc_common_link | Whether to use cc_common.link to link zig binaries, tests and shared libraries. Possible values: [-1, 0, 1]. -1 means use current configuration value for //zig/settings:experimental_use_cc_common_link. 0 means do not use cc_common.link (use zig build-exe instead). 1 means use cc_common.link. | Integer | optional | `-1` | | zig_version | The Zig SDK version, must be registered using the `zig` module extension. | String | optional | `""` | | zigopt | Additional list of flags passed to the zig compiler for all Zig compile actions.

The flags specified by this setting do not override those specified via the `zigopts` attribute of `zig_*` rules. Instead, they are prepended to the command line before module specific flags.

This is an advanced feature that can conflict with attributes, build settings, and other flags defined by the toolchain itself. Use this at your own risk of hitting undefined behaviors. | List of strings | optional | `[]` | @@ -238,7 +238,7 @@ zig_configure_binary( | mode | The build mode setting, corresponds to the `-O` Zig compiler flag. | String | optional | `""` | | target | The target platform, expects a label to a Bazel target platform used to select a `zig_target_toolchain` instance. | Label | optional | `None` | | threaded | The threaded setting, corresponds to the `-fsingle-threaded` Zig compiler flag. | String | optional | `""` | -| use_cc_common_link | Whether to use cc_common.link to link zig binaries, tests and shared libraries. | Boolean | optional | `False` | +| use_cc_common_link | Whether to use cc_common.link to link zig binaries, tests and shared libraries. Possible values: [-1, 0, 1]. -1 means use current configuration value for //zig/settings:experimental_use_cc_common_link. 0 means do not use cc_common.link (use zig build-exe instead). 1 means use cc_common.link. | Integer | optional | `-1` | | zig_version | The Zig SDK version, must be registered using the `zig` module extension. | String | optional | `""` | | zigopt | Additional list of flags passed to the zig compiler for all Zig compile actions.

The flags specified by this setting do not override those specified via the `zigopts` attribute of `zig_*` rules. Instead, they are prepended to the command line before module specific flags.

This is an advanced feature that can conflict with attributes, build settings, and other flags defined by the toolchain itself. Use this at your own risk of hitting undefined behaviors. | List of strings | optional | `[]` | @@ -305,7 +305,7 @@ zig_configure_test( | mode | The build mode setting, corresponds to the `-O` Zig compiler flag. | String | optional | `""` | | target | The target platform, expects a label to a Bazel target platform used to select a `zig_target_toolchain` instance. | Label | optional | `None` | | threaded | The threaded setting, corresponds to the `-fsingle-threaded` Zig compiler flag. | String | optional | `""` | -| use_cc_common_link | Whether to use cc_common.link to link zig binaries, tests and shared libraries. | Boolean | optional | `False` | +| use_cc_common_link | Whether to use cc_common.link to link zig binaries, tests and shared libraries. Possible values: [-1, 0, 1]. -1 means use current configuration value for //zig/settings:experimental_use_cc_common_link. 0 means do not use cc_common.link (use zig build-exe instead). 1 means use cc_common.link. | Integer | optional | `-1` | | zig_version | The Zig SDK version, must be registered using the `zig` module extension. | String | optional | `""` | | zigopt | Additional list of flags passed to the zig compiler for all Zig compile actions.

The flags specified by this setting do not override those specified via the `zigopts` attribute of `zig_*` rules. Instead, they are prepended to the command line before module specific flags.

This is an advanced feature that can conflict with attributes, build settings, and other flags defined by the toolchain itself. Use this at your own risk of hitting undefined behaviors. | List of strings | optional | `[]` | diff --git a/e2e/workspace/configure-use_cc_common_link/shared-library/BUILD.bazel b/e2e/workspace/configure-use_cc_common_link/shared-library/BUILD.bazel index 7a6dcc66..98cc07a5 100644 --- a/e2e/workspace/configure-use_cc_common_link/shared-library/BUILD.bazel +++ b/e2e/workspace/configure-use_cc_common_link/shared-library/BUILD.bazel @@ -38,7 +38,7 @@ zig_configure_binary( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) zig_static_library( @@ -60,7 +60,7 @@ zig_configure( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) zig_shared_library( @@ -82,7 +82,7 @@ zig_configure( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) zig_test( @@ -106,7 +106,7 @@ zig_configure_test( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) zig_shared_library( @@ -127,7 +127,7 @@ zig_configure( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) genrule( diff --git a/e2e/workspace/configure-use_cc_common_link/static-library/BUILD.bazel b/e2e/workspace/configure-use_cc_common_link/static-library/BUILD.bazel index 4c551280..b3ed3309 100644 --- a/e2e/workspace/configure-use_cc_common_link/static-library/BUILD.bazel +++ b/e2e/workspace/configure-use_cc_common_link/static-library/BUILD.bazel @@ -25,7 +25,7 @@ zig_configure_binary( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) zig_static_library( @@ -44,7 +44,7 @@ zig_configure( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) zig_shared_library( @@ -63,7 +63,7 @@ zig_configure( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) zig_test( @@ -84,7 +84,7 @@ zig_configure_test( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) genrule( diff --git a/e2e/workspace/linkopts-attr/BUILD.bazel b/e2e/workspace/linkopts-attr/BUILD.bazel index 8ab7868d..918010b5 100644 --- a/e2e/workspace/linkopts-attr/BUILD.bazel +++ b/e2e/workspace/linkopts-attr/BUILD.bazel @@ -32,7 +32,7 @@ zig_configure_binary( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) zig_configure( @@ -45,7 +45,7 @@ zig_configure( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) zig_configure_test( @@ -58,7 +58,7 @@ zig_configure_test( "@zig_toolchains//:0.15.2": ["@platforms//:incompatible"], "//conditions:default": [], }), - use_cc_common_link = True, + use_cc_common_link = 1, ) build_test( diff --git a/zig/private/zig_configure.bzl b/zig/private/zig_configure.bzl index 38157d0d..fccc0416 100644 --- a/zig/private/zig_configure.bzl +++ b/zig/private/zig_configure.bzl @@ -107,8 +107,8 @@ def _zig_transition_impl(settings, attr): result["//command_line_option:platforms"] = str(attr.target) if attr.zig_version: result["@zig_toolchains//:version"] = str(attr.zig_version) - if attr.use_cc_common_link: - result["//zig/settings:use_cc_common_link"] = attr.use_cc_common_link + if attr.use_cc_common_link != -1: + result["//zig/settings:use_cc_common_link"] = attr.use_cc_common_link == 1 if attr.mode: result["//zig/settings:mode"] = attr.mode if attr.threaded: @@ -159,9 +159,17 @@ def _make_attrs(*, executable): doc = "The Zig SDK version, must be registered using the `zig` module extension.", mandatory = False, ), - "use_cc_common_link": attr.bool( - doc = "Whether to use cc_common.link to link zig binaries, tests and shared libraries.", + "use_cc_common_link": attr.int( + doc = ( + "Whether to use cc_common.link to link zig binaries, tests and shared libraries. " + + "Possible values: [-1, 0, 1]. " + + "-1 means use current configuration value for //zig/settings:experimental_use_cc_common_link. " + + "0 means do not use cc_common.link (use zig build-exe instead). " + + "1 means use cc_common.link." + ), mandatory = False, + values = [-1, 0, 1], + default = -1, ), "mode": attr.string( doc = "The build mode setting, corresponds to the `-O` Zig compiler flag.",