#40 Try again to fix failures with https://fedoraproject.org/wiki/Changes/SetBuildFlagsBuildCheck
Merged by gotmax23. Opened by tstellar.
tstellar/go-rpm-macros ld-flags-fix-v2  into  master

Download 40.patch

The original fix wasn't working correctly, because %golang_filter_ldflags was expanded before $LDFLAGS was set. This new fixes complete disables the new automatic %set_build_flag call in spec files that use %gobuild or %gotest.

This looks good to me. I tested it on copr and confirmed that it works properly.

Pull-Request has been merged by gotmax23

@gotmax23 @tstellar This is not working for me in %check:
https://copr.fedorainfracloud.org/coprs/eclipseo/gotests2/build/3259438/

I have:

go-rpm-macros x86_64 3.0.14-1.fc36 https_kojipkgs_fedoraproject_org_repos_f36_build_latest_basearch 34 k

But it still fails in %check:

Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.2ahsVB
+ umask 022
+ cd /builddir/build/BUILD
+ CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
+ export CFLAGS
+ CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
+ export CXXFLAGS
+ FFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules'
+ export FFLAGS
+ FCFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules'
+ export FCFLAGS
+ LDFLAGS='-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/oras-go-1.1.0/.package_note-golang-oras-1.1.0-1.fc36.x86_64.ld'
+ export LDFLAGS
+ LT_SYS_LIBRARY_PATH=/usr/lib64:
+ export LT_SYS_LIBRARY_PATH
+ CC=gcc
+ export CC
+ CXX=g++
+ export CXX
+ '[' -f /usr/lib/rpm/generate-rpm-note.sh ']'
+ /usr/lib/rpm/generate-rpm-note.sh golang-oras 1.1.0-1.fc36 x86_64
+ cd oras-go-1.1.0
+ LDFLAGS='-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/oras-go-1.1.0/.package_note-golang-oras-1.1.0-1.fc36.x86_64.ld -X oras.land/oras-go/version=1.1.0'
+ GO_TEST_FLAGS='-buildmode pie -compiler gc'
+ GO_TEST_EXT_LD_FLAGS='-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/oras-go-1.1.0/.package_note-golang-oras-1.1.0-1.fc36.x86_64.ld '
+ go-rpm-integration check -i oras.land/oras-go -b /builddir/build/BUILD/oras-go-1.1.0/_build/bin -s /builddir/build/BUILD/oras-go-1.1.0/_build -V 1.1.0-1.fc36 -p /builddir/build/BUILDROOT/golang-oras-1.1.0-1.fc36.x86_64 -g /usr/share/gocode -r '.*example.*'
Testing    in: /builddir/build/BUILD/oras-go-1.1.0/_build/src
         PATH: /builddir/build/BUILD/oras-go-1.1.0/_build/bin:/builddir/.local/bin:/builddir/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
       GOPATH: /builddir/build/BUILD/oras-go-1.1.0/_build:/usr/share/gocode
  GO111MODULE: off
      command: go test -buildmode pie -compiler gc -ldflags "-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/oras-go-1.1.0/.package_note-golang-oras-1.1.0-1.fc36.x86_64.ld -X oras.land/oras-go/version=1.1.0 -extldflags '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/oras-go-1.1.0/.package_note-golang-oras-1.1.0-1.fc36.x86_64.ld '"
      testing: oras.land/oras-go
oras.land/oras-go/pkg/artifact
?       oras.land/oras-go/pkg/artifact  [no test files]
oras.land/oras-go/pkg/auth
# oras.land/oras-go/pkg/auth.test
flag provided but not defined: -Wl,-z,relro

Are you sure that you're using the latest version of go-rpm-macros that I pushed to Rawhide in your copr? I did not see this problem.

Yes I have version 3.0.14-1.fc36 from the f36 repo: https_kojipkgs_fedoraproject_org_repos_f36_build_latest_basearch

Same here with a package that was imported 2 days ago that started to fail today:

https://koschei.fedoraproject.org/package/golang-github-sagikazarmark-crypt?collection=f36

And another package that also is failing:

https://koji.fedoraproject.org/koji/taskinfo?taskID=82103130

It seems that this is failing on packages that contain %gocheck but not %gobuild, because %undefine _auto_set_build_flags is included in the %gobuild definition but not the %gocheck definition. I apologize for the breakage I caused!

It seems that this is failing on packages that contain %gocheck but not %gobuild, because %undefine _auto_set_build_flags is included in the %gobuild definition but not the %gocheck definition. I apologize for the breakage I caused!

https://pagure.io/go-rpm-macros/pull-request/42 should fix the issue. Can you please take a look?

Metadata