From 43d7456bafd6f950a83f873c0b1ecf99786dc7d2 Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Aug 07 2022 10:54:45 +0000 Subject: Convert LDFLAGS to GOLDFLAGS and BUILTAGS to GOBUILDTAGS --- diff --git a/bin/go-rpm-integration b/bin/go-rpm-integration index f6d3a52..34f20ea 100755 --- a/bin/go-rpm-integration +++ b/bin/go-rpm-integration @@ -398,7 +398,7 @@ GOPATH="${workroot}${GOPATH+:${GOPATH}}" GO111MODULE=off \ GOPATH="${workroot}${GOPATH:+:${GOPATH}}:${gopath}" \ PATH="${workbin:+${workbin}:}${PATH}" \ GO111MODULE=off \ - go test ${GO_TEST_FLAGS} -ldflags "${LDFLAGS:+${LDFLAGS} }-extldflags '${GO_TEST_EXT_LD_FLAGS}'" + go test ${GO_TEST_FLAGS} -ldflags "${GOLDFLAGS:+${GOLDFLAGS} }-extldflags '${GO_TEST_EXT_LD_FLAGS}'" popd >/dev/null done } @@ -458,7 +458,7 @@ case $action in echo " PATH: ${workbin:+${workbin}:}${PATH}" echo " GOPATH: ${workroot}${GOPATH:+:${GOPATH}}:${gopath}" echo " GO111MODULE: off" - echo " command: go test ${GO_TEST_FLAGS} -ldflags \"${LDFLAGS:+${LDFLAGS} }-extldflags '${GO_TEST_EXT_LD_FLAGS}'\"" + echo " command: go test ${GO_TEST_FLAGS} -ldflags \"${GOLDFLAGS:+${GOLDFLAGS} }-extldflags '${GO_TEST_EXT_LD_FLAGS}'\"" echo " testing: ${goipath}" checks "${goipath}" ;; provides) while read lockfile ; do diff --git a/rpm/macros.d/macros.go-compilers-golang b/rpm/macros.d/macros.go-compilers-golang index 74428a3..76f70b1 100644 --- a/rpm/macros.d/macros.go-compilers-golang +++ b/rpm/macros.d/macros.go-compilers-golang @@ -29,7 +29,7 @@ # # %make GOBUILDFLAGS="%gobuildflags" # -%gobuildflags() %{expand:%{gocompilerflags} -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-} %{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -compressdwarf=false -linkmode=external -extldflags '%{build_ldflags} %{?__golang_extldflags}'" -a -v -x} +%gobuildflags() %{expand:%{gocompilerflags} -tags="rpm_crashtraceback ${GOBUILDTAGS:-}" -ldflags "${GOLDFLAGS:-} %{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -compressdwarf=false -linkmode=external -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x} # Turn off Go modules %gomodulesmode GO111MODULE=off @@ -37,10 +37,6 @@ # Define commands for building # BUILD_ID can be generated for golang build no matter of debuginfo %gobuild(o:) %{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. - %undefine _auto_set_build_flags # https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12 %global _dwz_low_mem_die_limit 0 %{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} %{?gomodulesmode} \\ @@ -52,6 +48,5 @@ ${workroot}${GOPATH:+:${GOPATH}} %gotestflags %{gocompilerflags} %gotestextldflags %{build_ldflags} %{?__golang_extldflags} %gotest() %{expand: - %undefine _auto_set_build_flags - %{?gomodulesmode} go test %{gotestflags} -ldflags "${LDFLAGS:-} %{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**}; + %{?gomodulesmode} go test %{gotestflags} -ldflags "${GOLDFLAGS:-} %{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**}; } diff --git a/rpm/macros.d/macros.go-rpm b/rpm/macros.d/macros.go-rpm index 8890023..96dce7b 100644 --- a/rpm/macros.d/macros.go-rpm +++ b/rpm/macros.d/macros.go-rpm @@ -351,7 +351,7 @@ local function process(suffix) zsuffix = "-z " .. suffix .. " " end print(rpm.expand('%goenv ' .. zsuffix .. myenvflags .. '\\n' .. - '%{?currentgoldflags:LDFLAGS="${LDFLAGS} %{?currentgoldflags}" }' .. + '%{?currentgoldflags:GOLDFLAGS="${GOLDFLAGS} %{?currentgoldflags}" }' .. '%{?gotestflags:GO_TEST_FLAGS="%{gotestflags}" }' .. '%{?gotestextldflags:GO_TEST_EXT_LD_FLAGS="%{gotestextldflags}" }' .. 'go-rpm-integration check ' .. mycheckflags .. '\\n'))