-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Go cross compilation #50835
Go cross compilation #50835
Conversation
|
It works!
|
buildGoPackage still needs a fix to not put all binaries into a subdirectory:
|
The cross-compiled go compiler suffers from the same problem:
@Ericson2314 I am pretty sure there is an easy fix to distinguish between a go compiler |
Success on aarch64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
|
@@ -184,8 +187,8 @@ go.stdenv.mkDerivation ( | |||
runHook preInstall | |||
|
|||
mkdir -p $bin | |||
dir="$NIX_BUILD_TOP/go/bin" | |||
[ -e "$dir" ] && cp -r $dir $bin | |||
dir="$NIX_BUILD_TOP/go/bin/${gobin_prefix}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should remove the prefix already in the buildPhase
in case someone breaks it by overriding installPhase
?
Success on x86_64-darwin (full log) Attempted: go_1_11 Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
Success on x86_64-darwin (full log) Attempted: go_1_11 Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
Also support C bindings like a charm! |
@GrahamcOfBorg build pkgsCross.aarch64-multiplatform.direnv |
Unexpected error: command failed with exit code 1 on x86_64-linux (full log) Attempted: pkgsCross.aarch64-multiplatform.direnv Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: pkgsCross.aarch64-multiplatform.direnv Partial log (click to expand)
|
Failure on aarch64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
Timed out, unknown build status on x86_64-darwin (full log) Attempted: go_1_11 Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
@GrahamcOfBorg build direnv |
@GrahamcOfBorg build pkgsCross.aarch64-multiplatform.direnv |
Success on aarch64-linux (full log) Attempted: direnv Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: pkgsCross.aarch64-multiplatform.direnv Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: pkgsCross.aarch64-multiplatform.direnv Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
Timed out, unknown build status on x86_64-darwin (full log) Attempted: go_1_11 Partial log (click to expand)
|
Timed out, unknown build status on x86_64-darwin (full log) Attempted: direnv Partial log (click to expand)
|
'' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then '' | ||
mv bin/*_*/* bin | ||
rmdir bin/*_* | ||
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dtzWill is cross compilation for pkgsCross.musl64
something we aim for?
The go compiler would break in this case because ${GOHOSTOS}_${GOHOSTARCH}
is equal to
${GOOS}_${GOARCH}
, which means it would delete the go binaries in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could probably make make the condition GOOS != GOHOSTOS
etc. since go doesn’t use a libc it’s kind of irrelevant here… but it should still work in the sense that you have a working compiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does link against glibc for things like gethostbyname
via nss modules.
Timed out, unknown build status on x86_64-darwin (full log) Attempted: go_1_11 Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: direnv Partial log (click to expand)
|
Failure on x86_64-darwin (full log) Attempted: pkgsCross.aarch64-multiplatform.direnv Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
Timed out, unknown build status on x86_64-darwin (full log) Attempted: go_1_11 Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: go_1_11 Partial log (click to expand)
|
|
||
# {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those | ||
# to be different from CC/CXX | ||
CC_FOR_TARGET = if (stdenv.hostPlatform != stdenv.targetPlatform) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ericson2314 is that the correct way here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That comment was pending and I forgot to submit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting my thing another way, you can do either way (manual var or depsBuildBuild) the same way for !(build == host == target)
Motivation for this change
Mentally prepare myself to cross-compile rust.
Things that work:
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)