From a4349319c71c70d176ae41cb9bd143f9a97e009a Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Jul 15 2025 21:41:38 +0000 Subject: Allow passing arbitrary flags to %gobuild and %gotest Setting the argspec to "-" allows opting out of getopt processing, so we can pass arbitrary flags to the macros. This is supported since RPM 4.17 and was backported to RHEL 9.6. --- diff --git a/rpm/macros.d/macros.go-compilers-golang b/rpm/macros.d/macros.go-compilers-golang index fd4c224..b7ec50e 100644 --- a/rpm/macros.d/macros.go-compilers-golang +++ b/rpm/macros.d/macros.go-compilers-golang @@ -77,7 +77,7 @@ EOF\ # Define commands for building # BUILD_ID can be generated for golang build no matter of debuginfo -%gobuild(o:) %{expand: +%gobuild(-) %{expand: # https://pagure.io/go-rpm-macros/pull-request/38 # Most of the default LDFLAGS for Fedora are not supported so we don't want # LDFLAGS to be automatically initialized with the Fedora flags. @@ -92,7 +92,7 @@ ${workroot}${GOPATH:+:${GOPATH}} # Define commands for testing %gotestflags %{gocompilerflags} %gotestextldflags %{build_ldflags} %{?__golang_extldflags} -%gotest() %{expand: +%gotest(-) %{expand: %undefine _auto_set_build_flags %{?gomodulesmode} go test %{gotestflags} -ldflags "${GO_LDFLAGS-${LDFLAGS-}} %{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**}; }