Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] build-style/go: allow usage with gccgo compiler
@ 2020-04-15  2:07 q66
  2020-04-15  2:16 ` the-maldridge
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: q66 @ 2020-04-15  2:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2410 bytes --]

There is a new 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: 1435 bytes --]

From df0fce474d7de9c0fc37f140a4006651f26abfb2 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 | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh
index ce0bdcc18b4..6dccf90f6a9 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"
+	nostrip=yes
+	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;;

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2020-04-17  2:53 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15  2:07 [PR PATCH] build-style/go: allow usage with gccgo compiler 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 ` [PR PATCH] [Updated] " q66
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

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).