From f843e63aea4901b64048f46e54659678629432e2 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Mon, 22 Jul 2024 15:35:37 -0400 Subject: [PATCH] arg(): allow redefining {BUILD,TARGET}{OS,ARCH,VARIANT} Comments based on testing suggest that it's an incompatible mistake to flag attempts to redefine TARGETOS, TARGETARCH, and TARGETVARIANT, but it's okay to not allow TARGETPLATFORM to be redefined. Do the same for BUILD... Signed-off-by: Nalin Dahyabhai --- dispatchers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dispatchers.go b/dispatchers.go index 3cf86aa1..020eb8e2 100644 --- a/dispatchers.go +++ b/dispatchers.go @@ -755,7 +755,7 @@ func arg(b *Builder, args []string, attributes map[string]bool, flagArgs []strin // If the stage introduces one of the predefined args, add the // predefined value to the list of values known in this stage if value, defined := builtinArgDefaults[name]; defined { - if haveDefault { + if haveDefault && (name == "TARGETPLATFORM" || name == "BUILDPLATFORM") { return fmt.Errorf("attempted to redefine %q: %w", name, errdefs.ErrInvalidArgument) } if b.BuiltinArgDefaults == nil {