From: q66 <q66@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] build-style/go: allow usage with gccgo compiler
Date: Wed, 15 Apr 2020 20:26:35 +0200 [thread overview]
Message-ID: <20200415182635.LCHnMzfYMOB5O6tkRhz3ufS-KT4_6NfKXh88jMtn_nE@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20996@inbox.vuxu.org>
[-- Attachment #1: Type: text/plain, Size: 2415 bytes --]
There is an updated pull request by q66 against master on the void-packages repository
https://github.com/void-ppc/void-packages gccgo-style
https://github.com/void-linux/void-packages/pull/20996
build-style/go: allow usage with gccgo compiler
This checks if `gcc-go-tools` have been specified in host deps and if so, use gccgo to build (`gcc-go-tools` conflicts with go).
Also, since gccgo is not a multi-compiler, we need to override `GCCGO` to get cross-builds. The gccgo for target is always installed, as it's a part of our cross-toolchains.
Basically, in summary, the behavior with this patch is:
1) Use `go` by default, always
2) If a template explicitly chooses to install `gcc-go-tools` in `hostmakedepends`, that indicates to the `build-style` that we're to build with gccgo (current behavior: conflicting packages will cause the build to fail)
Since `gcc-go-tools` provides the same regular `go` frontend as the main `go` package, the `build-style` will generally work OOTB, unchanged, and it respects `GOCACHE`, `GOARCH`, `GOOS` and so on. The only differences need to be:
1) No default `archs`; `gccgo` is available everywhere
2) No `nostrip`, since it's using a regular GNU toolchain with GCC backend, so it generates debug symbols same as usual
3) No `nopie`, as our `--enable-default-pie` for GCC applies here
4) The `GCCGO` variable needs to be set to point to the target's compiler, but otherwise `GOARCH` is still respected everywhere else, so it's handled outside the conditional block
## Usage
I have one place where I'd like to use this and that's `PopCorn`. It's a fairly trivial application and has been tested to work well under `gccgo` (I use it for stats reporting on big-endian architectures where the regular compiler doesn't exist and have been for months). To switch, we'd basically just do this:
```
--- a/srcpkgs/PopCorn/template
+++ b/srcpkgs/PopCorn/template
@@ -8,7 +8,7 @@ go_package="${go_import_path}/cmd/popcorn
${go_import_path}/cmd/popcornctl
${go_import_path}/cmd/statrepo
${go_import_path}/cmd/pqueryd"
-hostmakedepends="git"
+hostmakedepends="gcc-go-tools git"
depends="snooze"
short_desc="Package statistics system"
maintainer="Michael Aldridge <maldridge@voidlinux.org>"
```
With the `build-style` change, that just works.
A patch file from https://github.com/void-linux/void-packages/pull/20996.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-gccgo-style-20996.patch --]
[-- Type: text/x-diff, Size: 1419 bytes --]
From 897406887fcdba95195ec079eb736eb2fe467878 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Mon, 11 Nov 2019 03:03:14 +0100
Subject: [PATCH] build-style/go: allow usage with gccgo compiler
This checks if gcc-go-tools have been specified in host deps
and if so, use gccgo to build (gcc-go-tools conflicts with go).
Also, since gccgo is not a multi-compiler, we need to override GCCGO
to get cross-builds. The gccgo for target is always installed, as
it's a part of our cross-toolchains.
[ci skip]
---
common/environment/build-style/go.sh | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh
index ce0bdcc18b4..a0cf330d600 100644
--- a/common/environment/build-style/go.sh
+++ b/common/environment/build-style/go.sh
@@ -1,9 +1,18 @@
-if [ -z "$archs" ]; then
- archs="aarch64* armv[567]* i686* x86_64* ppc64le*"
+if [ "${hostmakedepends##*gcc-go-tools*}" ]; then
+ # gc compiler
+ if [ -z "$archs" ]; then
+ archs="aarch64* armv[567]* i686* x86_64* ppc64le*"
+ fi
+ hostmakedepends+=" go"
+ nopie=yes
+else
+ # gccgo compiler
+ if [ "$CROSS_BUILD" ]; then
+ # target compiler to use; otherwise it'll just call gccgo
+ export GCCGO="${XBPS_CROSS_TRIPLET}-gccgo"
+ fi
fi
-hostmakedepends+=" go"
nostrip=yes
-nopie=yes
case "$XBPS_TARGET_MACHINE" in
aarch64*) export GOARCH=arm64;;
next prev parent reply other threads:[~2020-04-15 18:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 2:07 [PR PATCH] " q66
2020-04-15 2:16 ` the-maldridge
2020-04-15 2:17 ` the-maldridge
2020-04-15 2:21 ` q66
2020-04-15 2:21 ` q66
2020-04-15 7:58 ` travankor
2020-04-15 9:08 ` travankor
2020-04-15 14:27 ` q66
2020-04-15 18:26 ` q66 [this message]
2020-04-15 18:27 ` q66
2020-04-15 18:27 ` q66
2020-04-15 21:17 ` travankor
2020-04-15 21:19 ` travankor
2020-04-15 21:41 ` q66
2020-04-15 22:14 ` travankor
2020-04-15 22:21 ` travankor
2020-04-15 22:36 ` q66
2020-04-16 14:41 ` Duncaen
2020-04-16 14:57 ` q66
2020-04-16 15:01 ` Duncaen
2020-04-16 15:02 ` Duncaen
2020-04-17 2:53 ` [PR PATCH] [Merged]: " q66
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200415182635.LCHnMzfYMOB5O6tkRhz3ufS-KT4_6NfKXh88jMtn_nE@z \
--to=q66@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).