From 44650065fcf95f80e1a8194a83ecb3ba721e9af0 Mon Sep 17 00:00:00 2001 From: Corentin Kerisit Date: Fri, 28 Nov 2025 16:31:40 +0100 Subject: [PATCH 1/3] fix: handle overrding settings even if it is set to false --- zig/private/zig_configure.bzl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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.", From afa5e1e1fd6f7c6ac69007f125e9fc8cdbe188db Mon Sep 17 00:00:00 2001 From: Corentin Kerisit Date: Wed, 14 Jan 2026 17:51:17 +0100 Subject: [PATCH 2/3] docs --- docs/rules.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 | `[]` | From 8be804efc6314fd48748c74fb5cc6a7408e6dbae Mon Sep 17 00:00:00 2001 From: Corentin Kerisit Date: Thu, 15 Jan 2026 12:29:02 +0100 Subject: [PATCH 3/3] fix --- .../shared-library/BUILD.bazel | 10 +++++----- .../static-library/BUILD.bazel | 8 ++++---- e2e/workspace/linkopts-attr/BUILD.bazel | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) 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(