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

GIMME_ARCH arm64 does not set GOARCH to arm64 #154

Open
csandanov opened this issue Jul 3, 2018 · 7 comments
Open

GIMME_ARCH arm64 does not set GOARCH to arm64 #154

csandanov opened this issue Jul 3, 2018 · 7 comments

Comments

@csandanov
Copy link

...
env:
  matrix:
    - GIMME_OS=linux GIMME_ARCH=arm
    - GIMME_OS=linux GIMME_ARCH=arm64
...

GIMME_ARCH=arm works fine and sets GOARCH=arm unlike arm64. I don't know, maybe it's just not supported? Could not find a list of supported GIMME_ARCHs.

@philpennock
Copy link
Contributor

The GIMME_ARCH is mostly just passed through to GOARCH or HOSTGOARCH as appropriate. There's some normalization to clean things up and handle some aliases, so that a few more values are valid, but otherwise if GOARCH supports a given value then so does GIMME_ARCH.

For arm64, there's an additional sanity-check to enforce a minimum Go version (1.5) and to pick a cross-compiler if the host architecture is not arm64.

What's the evidence that GOARCH was not set?

@csandanov
Copy link
Author

So I've created a simple repo to demonstrate the issue, built it on travis-ci.com and, to my surprise, both arm and arm64 jobs show empty $GOARCH.

So I got back to my original (open sourced as well) repo with the issue which is built via travis-ci.org and it really shows empty $GOARCH on arm64 and expected $GOARCH=arm on arm.

Also, I've noticed that gimme arm environment takes a few minute to start unlike arm64, both on .ci and .org.

@tianon
Copy link
Contributor

tianon commented Jul 4, 2018

Your linked YAML has a typo:

echo $GOARH

(Should be GOARCH instead.)

@csandanov
Copy link
Author

🤦‍♂️I'm sorry, fixed the typo, now .org version also shows that $GOARCH is missing for arm64 but present for arm: https://travis-ci.com/csandanov/gimme/builds/78049895

@philpennock
Copy link
Contributor

That shows that for GIMME_ARCH=amd64, gimme errored out.

This line:

GIMME_OUTPUT="$(gimme 1.10.x | tee -a $HOME/.bashrc)" && eval "$GIMME_OUTPUT"

The | tee is suppressing the error. If this is guaranteed to be bash, then there needs to be a set -o pipefail for this construct to work. As it stands, it's buggy, because the && collapses to ; in this scenarios (unless tee can't write to ~/.bashrc). That's a Travis issue. No idea if setting pipefail will break a lot of user-scripts, but perhaps Travis could set it for the duration that it needs it, or just simplify the construction by breaking it into a couple of command-lines instead of trying to be clever. @tianon ?

Back to Gimme, rather than Travis's setup:
https://travis-ci.com/csandanov/gimme/jobs/132721199#L422-L424

The I don't have any idea what to do with '1.10.3'. is gimme failing to do stuff and bombing out.

When I grab a Linux box and run GIMME_DEBUG=3 GIMME_OS=linux GIMME_ARCH=arm64 gimme 1.10.3 I get an error caused by the cross-compilation binary being missing:

go tool dist: cannot invoke C compiler map["":"aarch64-linux-gnu-gcc" "linux/amd64":"gcc"]: exec: "aarch64-linux-gnu-gcc": executable file not found in $PATH

Now I've never used with cross-compilation with Gimme, so this is my first time, but AFAICT the required packages for Ubuntu are gcc-arm-linux-gnueabi binutils-arm-linux-gnueabi and after installing those, the cross-compiler is arm-linux-gnueabi-gcc whereas in this scenario gimme is defaulting the cross-compiler to aarch64-linux-gnu-gcc.

When I set GIMME_CC_FOR_TARGET=arm-linux-gnueabi-gcc I get a build. I'm not happy with the isolation offered by these directory names, but I have an existing PR which lays the groundwork for some cleanup here, so I'm not going to work on this until that's merged.

% GIMME_CC_FOR_TARGET=arm-linux-gnueabi-gcc gimme 1.10.3

unset GOOS;
export GOARCH="arm64";
export GOROOT='/home/pdp/.gimme/versions/go1.10.3.src';
export PATH="/home/pdp/.gimme/versions/go1.10.3.src/bin:${PATH}";
go version >&2;

export GIMME_ENV='/home/pdp/.gimme/envs/go1.10.3.src.env';

@csandanov please add that GIMME_CC_FOR_TARGET=arm-linux-gnueabi-gcc to the arm64 matrix line and confirm if this solves things for you?

Any cross-compilation experts who can say how we should be defaulting this?

I think we probably need to:

  1. switch the cross-compile names so that we're safe against multi-arch NFS mounting of homedirs
  2. figure out what is needed for cross-compilation; do we even need the above any more, or does modern Go handle cross-compilation to arm64 without needing to coerce gcc?
  3. if we determine that we do need/want an external cross-compiler, we should test if it's installed early, to avoid a lot of work
  4. cache download tarballs

@csandanov
Copy link
Author

@philpennock
Copy link
Contributor

@csandanov Looks like Travis might be missing the cross-compilation tools needed.

I'm bowing out. (I don't work for Travis, I just contribute to gimme).

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

3 participants