Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 671394 - dev-lang/go cross compilation requires ${CBUILD} to be specified to go_os and go-arch
Summary: dev-lang/go cross compilation requires ${CBUILD} to be specified to go_os and...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: William Hubbs
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2018-11-18 05:29 UTC by matoro
Modified: 2019-04-29 16:35 UTC (History)
3 users (show)

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


Attachments
emerge --info (info.txt,4.70 KB, text/plain)
2018-11-18 05:29 UTC, matoro
Details

Note You need to log in before you can comment on or make changes to this bug.
Description matoro archtester 2018-11-18 05:29:23 UTC
Created attachment 555522 [details]
emerge --info

I ran into issues when cross-compiling dev-lang/go from amd64 to armv6j.  At first, the ebuild was downloading the bootstrap package for the target arch, which resulted in a bad bootstrap executable, and after fixing that it was trying to execute a the bootstrap executable from the old, misnamed directory (for the target rather than host arch).

The first problem I was able to solve by hardcoding the BOOTSTRAP_URI variable to amd64.  Unfortunately, I do not know how to solve this in the correct way, since the arch USE flags refer to the target rather than host arch and I do not know a way to reliably extract the portage arch code from CBUILD.  Hence this bug instead of a pull request.

The second problem I solved by changing the GOROOT_BOOTSTRAP assignment to the following:

export GOROOT_BOOTSTRAP="${WORKDIR}"/go-$(go_os ${CBUILD})-$(go_arch ${CBUILD})-bootstrap

Build logs can be uploaded if requested, however I have identified the root cause and a solution already.  The attached emerge --info represents my cross-compilation environment (armv6j-unknown-linux-gnueabihf-emerge).  Further infos can be added for host env and the real target box if necessary.
Comment 1 Larry the Git Cow gentoo-dev 2019-03-17 02:04:58 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7f034e782d85423a92e9b3815284ca7ff506fb83

commit 7f034e782d85423a92e9b3815284ca7ff506fb83
Author:     William Hubbs <williamh@gentoo.org>
AuthorDate: 2019-03-17 02:01:21 +0000
Commit:     William Hubbs <williamh@gentoo.org>
CommitDate: 2019-03-17 02:02:36 +0000

    dev-lang/go: 1.12.1 bump and cross compile fix
    
    dev-lang/go, before this commit, failed to build in an environment
    generated by sys-devel/crossdev for two reasons:
    
    1. The bootstrap download package matched the target rather than host arch.
    
    We can't determine the host arch based on use flags, so we need to
    download all bootstrap packages.
    
    2.  The GOROOT_BOOTSTRAP environment variable matched the host rather than
    target arch.
    
    To fix this, we need to pass CBUILD to the calls to go_os and go_arch.
    
    This fixes both issues for a successful cross-compile.
    
    Closes: https://bugs.gentoo.org/671394
    Package-Manager: Portage-2.3.62, Repoman-2.3.12
    Signed-off-by: William Hubbs <williamh@gentoo.org>

 dev-lang/go/Manifest         |   1 +
 dev-lang/go/go-1.12.1.ebuild | 231 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 232 insertions(+)
Comment 2 Larry the Git Cow gentoo-dev 2019-04-29 16:35:57 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=167c53006749b6bbf952c80af0e0b5a7d31eca32

commit 167c53006749b6bbf952c80af0e0b5a7d31eca32
Author:     William Hubbs <williamh@gentoo.org>
AuthorDate: 2019-04-29 16:24:04 +0000
Commit:     William Hubbs <williamh@gentoo.org>
CommitDate: 2019-04-29 16:30:30 +0000

    dev-lang/go: add system-bootstrap use flag
    
    If a previous version of dev-lang/go is installed, you can use this use
    flag to skip downloading the bootstrap archives and bootstrap the new
    version using the already-installed version.
    
    For the initial installation of dev-lang/go, we have to download all of
    the bootstrap archives to make the go ebuild work under crossdev. For
    this reason, system-bootstrap cannot be turned on by default.
    
    Bug: https://bugs.gentoo.org/671394
    closes: https://bugs.gentoo.org/684652
    Copyright: Sony Interactive Entertainment Inc.
    Package-Manager: Portage-2.3.62, Repoman-2.3.12
    Signed-off-by: William Hubbs <williamh@gentoo.org>

 dev-lang/go/go-1.11.9.ebuild | 19 ++++++++++++-------
 dev-lang/go/go-1.12.4.ebuild | 19 ++++++++++++-------
 dev-lang/go/metadata.xml     |  7 ++++++-
 3 files changed, 30 insertions(+), 15 deletions(-)