diff --git a/docs/go/core/rules.md b/docs/go/core/rules.md index 52507673af..22e08a2434 100644 --- a/docs/go/core/rules.md +++ b/docs/go/core/rules.md @@ -391,7 +391,7 @@ This builds a set of tests that can be run with `bazel test`.

| goos | Forces a binary to be cross-compiled for a specific operating system. It's usually better to control this on the command line with --platforms.

This disables cgo by default, since a cross-compiling C/C++ toolchain is rarely available. To force cgo, set pure = off.

See [Cross compilation] for more information. | String | optional | "auto" | | gotags | Enables a list of build tags when evaluating [build constraints]. Useful for conditional compilation. | List of strings | optional | [] | | importpath | The import path of this test. Tests can't actually be imported, but this may be used by [go_path] and other tools to report the location of source files. This may be inferred from embedded libraries. | String | optional | "" | -| linkmode | Determines how the binary should be built and linked. This accepts some of the same values as `go build -buildmode` and works the same way.

| String | optional | "normal" | +| linkmode | Determines how the binary should be built and linked. This accepts some of the same values as `go build -buildmode` and works the same way.

| String | optional | "auto" | | msan | Controls whether code is instrumented for memory sanitization. May be one of on, off, or auto. Not available when cgo is disabled. In most cases, it's better to control this on the command line with --@io_bazel_rules_go//go/config:msan. See [mode attributes], specifically [msan]. | String | optional | "auto" | | pure | Controls whether cgo source code and dependencies are compiled and linked, similar to setting CGO_ENABLED. May be one of on, off, or auto. If auto, pure mode is enabled when no C/C++ toolchain is configured or when cross-compiling. It's usually better to control this on the command line with --@io_bazel_rules_go//go/config:pure. See [mode attributes], specifically [pure]. | String | optional | "auto" | | race | Controls whether code is instrumented for race detection. May be one of on, off, or auto. Not available when cgo is disabled. In most cases, it's better to control this on the command line with --@io_bazel_rules_go//go/config:race. See [mode attributes], specifically [race]. | String | optional | "auto" | diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 413a19da43..7710b38919 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -46,7 +46,7 @@ load( ) load( "//go/private:mode.bzl", - "LINKMODE_NORMAL", + "LINKMODES", ) load( "@bazel_skylib//lib:structs.bzl", @@ -292,11 +292,13 @@ _go_test_kwargs = { """, ), "linkmode": attr.string( - default = LINKMODE_NORMAL, + default = "auto", + values = ["auto"] + LINKMODES, doc = """Determines how the binary should be built and linked. This accepts some of the same values as `go build -buildmode` and works the same way.