Closed L1Q closed 2 years ago
Thanks for reporting this issue!
As far as I can tell, it's connected to your LDFLAGS
configuration. Passing LDFLAGS
from the environment to the Go linker seems to be an Arch Go package guideline requirement:
https://aur.archlinux.org/packages/protonutils/#comment-835684
However, as far as I can tell, this only applies to dependencies using C code and protonutils
currently does not use any.
Feel free to retest with different LDFLAGS
; I will need some time to setup a VM again and figure this out.
What should be in my LDFLAGS
? It's currently empty.
I also tested with empty LDFLAGS
as I recall. I did not yet have the chance to retest in a VM, though.
I also tested with Go 1.17.3 and with the same go build ...
command (should mean, we used the same CLFAGS
and LDFLAGS
).
Excerpt from my makepkg.conf
:
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
But I think the idea that LDFLAGS
could be the problem is wrong anyway... :smile:
-mod=readonly
is recommended in the Arch Linux Go package guidelines but it seems it's unneccessary since Go 1.16 anyway.
I removed the option from the Makefile, released v1.2.9
and updated the PKGBUILD. Please let me know if it works for you!
Thanks for reporting & testing!
==> Making package: protonutils 1.2.9-1 (Sat 04 Dec 2021 10:00:23 PM EET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Found protonutils-1.2.9.tar.gz
==> Validating source files with sha256sums...
protonutils-1.2.9.tar.gz ... Passed
==> Removing existing $srcdir/ directory...
==> Extracting sources...
-> Extracting protonutils-1.2.9.tar.gz with bsdtar
==> Starting prepare()...
==> Sources are ready.
==> Making package: protonutils 1.2.9-1 (Sat 04 Dec 2021 10:00:26 PM EET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Starting build()...
rm -f cmd/protonutils/protonutils
cd cmd/protonutils; go build -ldflags "-X main.Version=v1.2.9 -X main.Buildtime=20211204200026 -s -w -linkmode external -extldflags \"-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now\"" -trimpath -buildmode=pie -modcacherw
build flag -modcacherw only valid when using modules
make: *** [Makefile:20: cmd/protonutils/protonutils] Error 1
==> ERROR: A failure occurred in build().
Aborting...
-modcacherw
was also suggested by the Arch guidelines and it's not useful for protonutils
. I removed it and released v1.2.10
. For me, the build works on Fedora and in a Arch Linux container (with recent archlinux:base-devel
image).
it still failed on my end and here is how
cd cmd/protonutils; go build -ldflags "-X main.Version=v -X main.Buildtime=20211205122116 -s -w -linkmode external -extldflags \"\"" -trimpath -buildmode=pie
ge.go:18:2: cannot find package "github.com/dustin/go-humanize" in any of:
/usr/lib/go/src/github.com/dustin/go-humanize (from $GOROOT)
/home/l1q/Documents/tmp/protonutils-build/aur/protonutils/src/gopath/src/github.com/dustin/go-humanize (from $GOPATH)
appid.go:7:2: cannot find package "github.com/nning/protonutils/steam" in any of:
/usr/lib/go/src/github.com/nning/protonutils/steam (from $GOROOT)
/home/l1q/Documents/tmp/protonutils-build/aur/protonutils/src/gopath/src/github.com/nning/protonutils/steam (from $GOPATH)
ge.go:20:2: cannot find package "github.com/nning/protonutils/utils" in any of:
/usr/lib/go/src/github.com/nning/protonutils/utils (from $GOROOT)
/home/l1q/Documents/tmp/protonutils-build/aur/protonutils/src/gopath/src/github.com/nning/protonutils/utils (from $GOPATH)
appid.go:8:2: cannot find package "github.com/spf13/cobra" in any of:
/usr/lib/go/src/github.com/spf13/cobra (from $GOROOT)
/home/l1q/Documents/tmp/protonutils-build/aur/protonutils/src/gopath/src/github.com/spf13/cobra (from $GOPATH)
main.go:8:2: cannot find package "github.com/spf13/cobra/doc" in any of:
/usr/lib/go/src/github.com/spf13/cobra/doc (from $GOROOT)
/home/l1q/Documents/tmp/protonutils-build/aur/protonutils/src/gopath/src/github.com/spf13/cobra/doc (from $GOPATH)
make: *** [Makefile:20: cmd/protonutils/protonutils] Error 1
This got me thinking: if it can't find modules now and all the errors I was getting were all about "when using modules" it has to do with the go config. Now that you tested it on your container and have it working I'm even more sure.
I did export GO111MODULE=on
before running makepkg
and got it built with no problem.
[l1q@l1q-mj protonutils]$ export GO111MODULE=on
[l1q@l1q-mj protonutils]$ makepkg
==> Making package: protonutils 1.2.10-1 (Sun 05 Dec 2021 02:25:12 PM EET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Found protonutils-1.2.10.tar.gz
==> Validating source files with sha256sums...
protonutils-1.2.10.tar.gz ... Passed
==> Extracting sources...
-> Extracting protonutils-1.2.10.tar.gz with bsdtar
==> Starting prepare()...
src dir is /home/l1q/Documents/tmp/protonutils-build/aur/protonutils/src
==> Removing existing $pkgdir/ directory...
==> Starting build()...
rm -f cmd/protonutils/protonutils
cd cmd/protonutils; go build -ldflags "-X main.Version=v1.2.10 -X main.Buildtime=20211205122512 -s -w -linkmode external -extldflags \"-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now\"" -trimpath -buildmode=pie
go: downloading github.com/spf13/cobra v1.2.1
go: downloading github.com/MrWaggel/gosteamconv v0.0.0-20190214041723-97e1fbb6de26
go: downloading github.com/andygrunwald/vdf v1.0.0
go: downloading github.com/dustin/go-humanize v1.0.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.1
go: downloading github.com/russross/blackfriday/v2 v2.1.0
==> Entering fakeroot environment...
==> Starting package()...
==> Tidying install...
-> Removing libtool files...
-> Purging unwanted files...
-> Removing static library files...
-> Stripping unneeded symbols from binaries and libraries...
-> Compressing man and info pages...
==> Checking for packaging issues...
==> Creating package "protonutils"...
-> Generating .PKGINFO file...
-> Generating .BUILDINFO file...
-> Generating .MTREE file...
-> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: protonutils 1.2.10-1 (Sun 05 Dec 2021 02:25:23 PM EET)
[l1q@l1q-mj protonutils]$
Tested 1.2.8 PKGBUILD with export GO111MODULE=on
right before export CGO_CPPFLAGS="$CPPFLAGS"
and it built perfectly fine too. So the -mod=readonly
and -modcacherw
can be safely restored.
so yeah, restore the flags, here is how build()
should look like in PKGBUILD
:
build() {
cd $pkgname-$pkgver
export GO111MODULE=on
export CGO_CPPFLAGS="$CPPFLAGS"
export CGO_CFLAGS="$CFLAGS"
export CGO_CXXFLAGS="$CXXFLAGS"
export CGO_LDFLAGS="$LDFLAGS"
make clean build_pie VERSION=v$pkgver
./cmd/$pkgname/$pkgname -m man1
go clean -modcache
}
see this issue for example https://github.com/golangci/golangci-lint/issues/1502#issuecomment-752095870
Nice discovery, thanks for your help! I updated the PKGBUILD and also restored the two build options (although I'm not sure, they are of much use).