Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-compilation issues #166

Open
vitarb opened this issue Nov 1, 2018 · 0 comments
Open

Cross-compilation issues #166

vitarb opened this issue Nov 1, 2018 · 0 comments

Comments

@vitarb
Copy link

vitarb commented Nov 1, 2018

Summary

It seems that cross-compilation setup is not working if you run gimme without running it for a current OS first. Also CC setup can only be done in source mode. Is it intended way of how it should work or am I missing something?

How to reproduce the issue?

Run following on darwin:

rm -rf ~/.gimme
GIMME_OS=linux GIMME_ARCH=amd64 \
gimme 1.11.1

Expected result

gimme returns successfully and go 1.11.1 is setup under $HOME/.gimme

Actual result

gimme exits with code 1, saying "I don't have any idea what to do with '1.11.1'."

Notes

  • gimme should install linux version of go toolchain, but binaries should be compiled for GIMME_HOSTOS, instead linux version of the binary is installed.
  • setup fails in source mode with a similar message.
  • setup succeeds in sources mode if there is existing darwin installation.

Debug output

$ GIMME_DEBUG=1 GIMME_HOSTOS=darwin GIMME_HOSTARCH=amd64 GIMME_TYPE=binary GIMME_OS=linux GIMME_ARCH=amd64 gimme 1.11.1
+ readonly GIMME_VERSION=v1.5.3
+ GIMME_VERSION=v1.5.3
+ readonly 'GIMME_COPYRIGHT=Copyright (c) 2015-2018 gimme contributors'
+ GIMME_COPYRIGHT='Copyright (c) 2015-2018 gimme contributors'
+ readonly GIMME_LICENSE_URL=https://raw.githubusercontent.com/travis-ci/gimme/v1.5.3/LICENSE
+ GIMME_LICENSE_URL=https://raw.githubusercontent.com/travis-ci/gimme/v1.5.3/LICENSE
+ export GIMME_VERSION
+ export GIMME_COPYRIGHT
+ export GIMME_LICENSE_URL
++ basename /Users/vit/go-code/bin/gimme
+ program_name=gimme
+ ALLOWED_UPSTREAM_VERSION_RE='^[1-9][0-9]{0,3}(\.[0-9][0-9a-zA-Z_-]{0,9})+$'
+ sort --version-sort
+ : linux
+ : darwin
+ : amd64
+ : amd64
+ : /Users/vit/.gimme/envs
+ : /Users/vit/.gimme/versions
+ : /var/folders/6_/htkppg753px1jglygs0c297h0000gn/T//gimme
+ : https://github.com/golang/go.git
+ : binary
+ : osx10.8
+ : https://storage.googleapis.com/golang
+ : https://golang.org/dl
+ : 10800
+ case "${GIMME_VERSION_PREFIX}" in
+ true
+ case "${GIMME_OS}" in
+ force_install=0
+ force_known_update=0
+ [[ 1 -gt 0 ]]
+ case "${1}" in
+ break
+ [[ -n 1.11.1 ]]
+ GIMME_GO_VERSION=1.11.1
+ [[ -n '' ]]
+ case "${GIMME_ARCH}" in
+ case "${GIMME_HOSTARCH}" in
+ [[ 1.11.1 == \s\t\a\b\l\e ]]
+ _assert_version_given 1.11.1
+ [[ -z 1.11.1 ]]
+ [[ 1.11.1 == *.x ]]
+ [[ 1.11.1 == +([[:digit:]]).+([[:digit:]])* ]]
+ return 0
+ (( force_install ))
+ unset GOARCH
+ unset GOBIN
+ unset GOOS
+ unset GOPATH
+ unset GOROOT
+ unset CGO_ENABLED
+ unset CC_FOR_TARGET
+ unset GO111MODULE
+ mkdir -p /Users/vit/.gimme/versions /Users/vit/.gimme/envs
+ _exclude_from_backups /Users/vit/.gimme/versions
+ case "${GIMME_HOSTOS}" in
+ tmutil addexclusion /Users/vit/.gimme/versions
++ _realpath /Users/vit/.gimme/versions
++ '[' -d /Users/vit/.gimme/versions ']'
+++ cd /Users/vit/.gimme/versions
+++ pwd
++ echo /Users/vit/.gimme/versions
+ GIMME_VERSION_PREFIX=/Users/vit/.gimme/versions
++ _realpath /Users/vit/.gimme/envs
++ '[' -d /Users/vit/.gimme/envs ']'
+++ cd /Users/vit/.gimme/envs
+++ pwd
++ echo /Users/vit/.gimme/envs
+ GIMME_ENV_PREFIX=/Users/vit/.gimme/envs
+ case "${GIMME_TYPE}" in
+ _try_existing binary
+ case "${1}" in
+ local existing_ver=/Users/vit/.gimme/versions/go1.11.1.linux.amd64
+ local existing_env=/Users/vit/.gimme/envs/go1.11.1.linux.amd64.env
+ [[ -x /Users/vit/.gimme/versions/go1.11.1.linux.amd64/bin/go ]]
+ [[ -s /Users/vit/.gimme/envs/go1.11.1.linux.amd64.env ]]
+ return 1
+ _try_binary 1.11.1 amd64
+ local version=1.11.1
+ local arch=amd64
+ local bin_tgz=/var/folders/6_/htkppg753px1jglygs0c297h0000gn/T//gimme/go1.11.1.linux.amd64.tar.gz
+ local bin_dir=/Users/vit/.gimme/versions/go1.11.1.linux.amd64
+ local bin_env=/Users/vit/.gimme/envs/go1.11.1.linux.amd64.env
+ [[ 1.11.1 =~ ^[1-9][0-9]{0,3}(\.[0-9][0-9a-zA-Z_-]{0,9})+$ ]]
+ '[' linux = windows ']'
+ _binary 1.11.1 /var/folders/6_/htkppg753px1jglygs0c297h0000gn/T//gimme/go1.11.1.linux.amd64.tar.gz amd64
+ local version=1.11.1
+ local file=/var/folders/6_/htkppg753px1jglygs0c297h0000gn/T//gimme/go1.11.1.linux.amd64.tar.gz
+ local arch=amd64
+ urls=("${GIMME_DOWNLOAD_BASE}/go${version}.${GIMME_OS}-${arch}.tar.gz")
+ [[ linux == \d\a\r\w\i\n ]]
+ '[' amd64 = arm ']'
+ '[' linux = windows ']'
+ _do_curls /var/folders/6_/htkppg753px1jglygs0c297h0000gn/T//gimme/go1.11.1.linux.amd64.tar.gz https://storage.googleapis.com/golang/go1.11.1.linux-amd64.tar.gz
+ f=/var/folders/6_/htkppg753px1jglygs0c297h0000gn/T//gimme/go1.11.1.linux.amd64.tar.gz
+ shift
+ _sha256sum -c /var/folders/6_/htkppg753px1jglygs0c297h0000gn/T//gimme/go1.11.1.linux.amd64.tar.gz.sha256
+ return 0
+ _extract /var/folders/6_/htkppg753px1jglygs0c297h0000gn/T//gimme/go1.11.1.linux.amd64.tar.gz /Users/vit/.gimme/versions/go1.11.1.linux.amd64
+ mkdir -p /Users/vit/.gimme/versions/go1.11.1.linux.amd64
+ [[ /var/folders/6_/htkppg753px1jglygs0c297h0000gn/T//gimme/go1.11.1.linux.amd64.tar.gz == *.tar.gz ]]
+ tar -xf /var/folders/6_/htkppg753px1jglygs0c297h0000gn/T//gimme/go1.11.1.linux.amd64.tar.gz -C /Users/vit/.gimme/versions/go1.11.1.linux.amd64 --strip-components 1
+ _env /Users/vit/.gimme/versions/go1.11.1.linux.amd64
+ [[ -d /Users/vit/.gimme/versions/go1.11.1.linux.amd64/bin ]]
+ tee /Users/vit/.gimme/envs/go1.11.1.linux.amd64.env
+ [[ -x /Users/vit/.gimme/versions/go1.11.1.linux.amd64/bin/go ]]
+ GOROOT=/Users/vit/.gimme/versions/go1.11.1.linux.amd64
+ /Users/vit/.gimme/versions/go1.11.1.linux.amd64/bin/go version
+ return 1
+ return 1
+ echo 'I don'\''t have any idea what to do with '\''1.11.1'\''.'
I don't have any idea what to do with '1.11.1'.
+ echo '  (using download type '\''binary'\'')'
  (using download type 'binary')
+ exit 1

If I try to run binary separately I get an error indicating that it was compiled for linux:

$ /Users/vit/.gimme/versions/go1.11.1.linux.amd64/bin/go version
zsh: exec format error: /Users/vit/.gimme/versions/go1.11.1.linux.amd64/bin/go

Go env

For debugging purposes, here is my go env:

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/vit/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/vit/go-code"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6_/htkppg753px1jglygs0c297h0000gn/T/go-build630762589=/tmp/go-build -gno-record-gcc-switches -fno-common"

Successful sequence

Following sequence shows that attempt to setup linux version first fails, but if we setup darwin first then linux setup succeeds. What is not shown is that in first case gimme uses binary download type and in the second case it falls back to compiling toolchain from sources.

vit@vit-C02VF0UDHTDG ~/go-code (master) $ rm -rf ~/.gimme
vit@vit-C02VF0UDHTDG ~/go-code (master) $ GIMME_OS=linux gimme 1.11.1
Unable to setup go bootstrap from existing or binary
I don't have any idea what to do with '1.11.1'.
  (using download type 'auto')
vit@vit-C02VF0UDHTDG ~/go-code (master) $ GIMME_OS=darwin gimme 1.11.1

unset GOOS;
unset GOARCH;
export GOROOT='/Users/vit/.gimme/versions/go1.11.1.darwin.amd64';
export PATH="/Users/vit/.gimme/versions/go1.11.1.darwin.amd64/bin:${PATH}";
go version >&2;

export GIMME_ENV="/Users/vit/.gimme/envs/go1.11.1.env"
vit@vit-C02VF0UDHTDG ~/go-code (master) $ GIMME_OS=linux gimme 1.11.1

export GOOS="linux";
unset GOARCH;
export GOROOT='/Users/vit/.gimme/versions/go1.11.1.src';
export PATH="/Users/vit/.gimme/versions/go1.11.1.src/bin:${PATH}";
go version >&2;

export GIMME_ENV="/Users/vit/.gimme/envs/go1.11.1.src.env"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant