From 4dc7213e994a2156effac491e0c95d09172dc16d Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Fri, 21 Jun 2024 14:09:43 +0200 Subject: [PATCH] docs: Discourage use `go_sdk.host()` in bzlmod.md (see #3967) see https://github.com/bazelbuild/rules_go/issues/3967 and https://github.com/enola-dev/enola/issues/713 --- docs/go/core/bzlmod.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/go/core/bzlmod.md b/docs/go/core/bzlmod.md index c95ca9cb7..a373b61d4 100644 --- a/docs/go/core/bzlmod.md +++ b/docs/go/core/bzlmod.md @@ -44,6 +44,10 @@ go_sdk.download( go_sdk.host() ``` +Nota bene: The use of `go_sdk.host()` [may break builds](https://github.com/enola-dev/enola/issues/713) whenever the host Go version is upgraded +(because many OS package managers, such as Debian/Ubuntu's `apt`, distribute Go into a directory which contains the version, such as `/usr/lib/go-1.22/`). +As package upgrades happen outside of Bazel's control, this will lead to non-reproducible builds. Due to this, use of `go_sdk.host()` is discouraged. + You can register multiple Go SDKs and select which one to use on a per-target basis using [`go_cross_binary`](rules.md#go_cross_binary). As long as you specify the `version` of an SDK, it will be downloaded lazily, that is, only when it is actually needed during a particular build. The usual rules of [toolchain resolution](https://bazel.build/extending/toolchains#toolchain-resolution) apply, with SDKs registered in the root module taking precedence over those registered in dependencies.