Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 680906 - dev-lang/go bootstrap used even if bootstrap is not needed
Summary: dev-lang/go bootstrap used even if bootstrap is not needed
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords: EBUILD
Depends on:
Blocks:
 
Reported: 2019-03-18 22:13 UTC by Michel Ganguin
Modified: 2019-03-19 19:11 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Ebuild proposal (go-1.12.ebuild,5.71 KB, text/plain)
2019-03-18 22:21 UTC, Michel Ganguin
Details
go-1.12.1.ebuild (go-1.12.1.ebuild,5.73 KB, text/plain)
2019-03-18 22:22 UTC, Michel Ganguin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Ganguin 2019-03-18 22:13:18 UTC
dev-lang/go always downloads and uses go-linux-{arch}-bootstrap-1.8.tbz for building a new version of go even if the the already installed version can be used.

Reproducible: Always

Steps to Reproduce:
1. emerge --depclean go # ensure go is not installed
2. emerge go
3. rm /usr/portage/distfiles/go-linux-*-bootstrap-1.8.tbz
4. emerge go
Actual Results:  
emerge go in step 4 downloads go-linux-{arch}-bootstrap-1.8.tbz and uses it for building go

Expected Results:  
installed go should be used for building new go

It may seems minor, but it is important if user patches are applied. AFAIK dev-java/openjdk and dev-java/icedtea require an older version or -bin version to be installed for bootstrapping, shouldn't a similar dependency be applied to dev-lang/go
Comment 1 Michel Ganguin 2019-03-18 22:21:22 UTC
Created attachment 569738 [details]
Ebuild proposal

add system-bootstrap USE flag, that uses /usr/lib/go for bootstrapping. This implies a circular dependency if the USE flag is enabled when dev-lang/go is not already installed.

If the circular dependency is a problem, dev-lang/go-bin should be created and used a dependency:

|| (
  >=dev-lang/go-1.8.0
  >=dev-lang/go-bin-1.8.0
)

Having a go-bin ebuild would also make the system-bootstrap USE flag useless
Comment 2 Michel Ganguin 2019-03-18 22:22:22 UTC
Created attachment 569740 [details]
go-1.12.1.ebuild
Comment 3 Michel Ganguin 2019-03-18 22:30:02 UTC
This would also fix issue about building dev-lang/go on musl:

* Bug 576290 -  dev-lang/go no longer builds on musl (no bootstrap tarball is available, and sys-devel/gcc[go] does not build)
* Bug 606970 - dev-lang/go-1.7.4 fails to compile on amd64-musl-hardened (./make.bash: line 132: /var/tmp/portage/dev-lang/go-1.7.4/work/go-linux-amd64-bootstrap/bin/go: No such file or directory)
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2019-03-18 22:30:46 UTC
Comment on attachment 569740 [details]
go-1.12.1.ebuild

--- go-1.12.1.ebuild    2019-03-17 22:34:25.907048328 +0100
+++ -   2019-03-18 23:30:05.817661561 +0100
@@ -47,16 +47,16 @@
                ;;
        esac
 esac
-SRC_URI+="!gccgo? ( ${BOOTSTRAP_URI} )"
+SRC_URI+="!gccgo? ( !system-bootstrap? ( ${BOOTSTRAP_URI} ) )"

 DESCRIPTION="A concurrent garbage collected and typesafe programming language"
 HOMEPAGE="https://golang.org"

 LICENSE="BSD"
 SLOT="0/${PV}"
-IUSE="gccgo"
+IUSE="gccgo system-bootstrap"

-BDEPEND="gccgo? ( >=sys-devel/gcc-5[go] )"
+BDEPEND="gccgo? ( >=sys-devel/gcc-5[go] ) system-bootstrap? ( >=dev-lang/go-1.8.0 )"
 RDEPEND="!<dev-go/go-tools-0_pre20150902"

 # These test data objects have writable/executable stacks.
@@ -156,7 +156,11 @@

 src_compile()
 {
-       export GOROOT_BOOTSTRAP="${WORKDIR}"/go-$(go_os ${CBUILD})-$(go_arch ${CBUILD})-bootstrap
+       if use system-bootstrap; then
+               export GOROOT_BOOTSTRAP="/usr/lib/go"
+       else
+               export GOROOT_BOOTSTRAP="${WORKDIR}"/go-$(go_os ${CBUILD})-$(go_arch ${CBUILD})-bootstrap
+       fi
        if use gccgo; then
                mkdir -p "${GOROOT_BOOTSTRAP}/bin" || die
                local go_binary=$(gcc-config --get-bin-path)/go-$(gcc-major-version)
Comment 5 William Hubbs gentoo-dev 2019-03-19 17:38:06 UTC
(In reply to Michel Ganguin from comment #0)
> dev-lang/go always downloads and uses go-linux-{arch}-bootstrap-1.8.tbz for
> building a new version of go even if the the already installed version can
> be used.

I don't see how the installed version could be used without breaking builds under crossdev (see bug #671394)
The short version is the bootstrap binaries have to be run on the machine doing the building which may be different from where go is actually installed.

If I offer a go-bin ebuild, it will download from upstream (https://golang.org/dl), and the go and go-bin ebuilds would block each other. Also, upstream does not support all of our architectures.
Comment 6 Piotr Karbowski (RETIRED) gentoo-dev 2019-03-19 19:05:25 UTC
I do not really like the idea with system-bootstrap, as it will fail in case if golang was not yet present on the system.

It would also means we do have non deterministic build process during update and the re-installation of package, as first it would use old version of golang to bootstrap, and on re-installation it would use the new version, meaning in theory running while update is in the tree:

    emerge -1u dev-lang/go
    emerge -1 dev-lang/go

while USE=system-go is set would produce different results.

May I ask what problem are you trying to solve here?
Comment 7 William Hubbs gentoo-dev 2019-03-19 19:11:41 UTC
I am marking this invalid because I don't see a way I can avoid the
downloads.

Please feel free to re-open if you can come up with something that will
still work in a crossdev environment.