From 53a710bea19666efa3ff8d3a3fc6949b40328f08 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Jan 28 2022 05:24:10 +0000 Subject: [PATCH 1/3] Revert "Fix gotest ldflags invocation" This reverts commit 29b160bd76dc5bebdd70af0be1fcc1572556a113. --- diff --git a/rpm/macros.d/macros.go-rpm b/rpm/macros.d/macros.go-rpm index 71b7f54..f773f34 100644 --- a/rpm/macros.d/macros.go-rpm +++ b/rpm/macros.d/macros.go-rpm @@ -350,8 +350,7 @@ local function process(suffix) zsuffix = "-z " .. suffix .. " " end print(rpm.expand('%goenv ' .. zsuffix .. myenvflags .. '\\n' .. - '%{?currentgoldflags:LDFLAGS="%{golang_filter_ldflags} ' .. - '%{?currentgoldflags}" }' .. + '%{?currentgoldflags:LDFLAGS="${LDFLAGS} %{?currentgoldflags}" }' .. '%{?gotestflags:GO_TEST_FLAGS="%{gotestflags}" }' .. '%{?gotestextldflags:GO_TEST_EXT_LD_FLAGS="%{gotestextldflags}" }' .. 'go-rpm-integration check ' .. mycheckflags .. '\\n')) From 84e2747d2784f05ea027524f9d1c3c38ecdc354e Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Jan 28 2022 05:25:49 +0000 Subject: [PATCH 2/3] Revert "Fix build failures due to https://fedoraproject.org/wiki/Changes/SetBuildFlagsBuildCheck" This reverts commit 8822b49cdf553d0164b44e15176c38e1523622a2. This fix was incomplete. --- diff --git a/rpm/macros.d/macros.go-compilers-golang b/rpm/macros.d/macros.go-compilers-golang index 84d34b3..3b4a01d 100644 --- a/rpm/macros.d/macros.go-compilers-golang +++ b/rpm/macros.d/macros.go-compilers-golang @@ -29,11 +29,7 @@ # # %make GOBUILDFLAGS="%gobuildflags" # - -# Remove unsupported LDFLAGS -%golang_filter_ldflags %(echo "$LDFLAGS" | sed -e 's/-Wl,-z,relro//') - -%gobuildflags() %{expand:%{gocompilerflags} -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "%{golang_filter_ldflags} %{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -compressdwarf=false -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x} +%gobuildflags() %{expand:%{gocompilerflags} -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-} %{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -compressdwarf=false -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x} # Turn off Go modules %gomodulesmode GO111MODULE=off @@ -51,4 +47,4 @@ ${workroot}${GOPATH:+:${GOPATH}} # Define commands for testing %gotestflags %{gocompilerflags} %gotestextldflags %__global_ldflags %{?__golang_extldflags} -%gotest() %{?gomodulesmode} go test %{gotestflags} -ldflags "%{golang_filter_ldflags} %{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**}; +%gotest() %{?gomodulesmode} go test %{gotestflags} -ldflags "${LDFLAGS:-} %{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**}; From 1cc7f5d9026175bb6cb1b8c889355d0c4fc0e40a Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Jan 28 2022 05:46:21 +0000 Subject: [PATCH 3/3] Try again to fix build failures due to https://fedoraproject.org/wiki/Changes/SetBuildFlagsBuildCheck Most of the LDFLAGS are unsupported by golang, so instead of filtering them out, just disable the automatic initialization of them. --- diff --git a/rpm/macros.d/macros.go-compilers-golang b/rpm/macros.d/macros.go-compilers-golang index 3b4a01d..0426849 100644 --- a/rpm/macros.d/macros.go-compilers-golang +++ b/rpm/macros.d/macros.go-compilers-golang @@ -37,6 +37,10 @@ # 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} \\ @@ -47,4 +51,7 @@ ${workroot}${GOPATH:+:${GOPATH}} # Define commands for testing %gotestflags %{gocompilerflags} %gotestextldflags %__global_ldflags %{?__golang_extldflags} -%gotest() %{?gomodulesmode} go test %{gotestflags} -ldflags "${LDFLAGS:-} %{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**}; +%gotest() %{ + %undefine _auto_set_build_flags + %{?gomodulesmode} go test %{gotestflags} -ldflags "${LDFLAGS:-} %{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**}; +}