Go cross compilation #50835
Go cross compilation #50835
Conversation
|
It works!
|
pkgs/development/compilers/go/1.11.nix
Outdated
Show resolved
Hide resolved
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}" |
Mic92
Nov 20, 2018
Author
Contributor
I wonder if we should remove the prefix already in the buildPhase
in case someone breaks it by overriding installPhase
?
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 |
pkgs/development/compilers/go/1.11.nix
Outdated
Show resolved
Hide resolved
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)
|
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} |
Mic92
Nov 22, 2018
Author
Contributor
@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.
@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.
matthewbauer
Nov 23, 2018
Member
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.
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.
Mic92
Nov 23, 2018
Author
Contributor
It does link against glibc for things like gethostbyname
via nss modules.
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 |
Ericson2314
Nov 30, 2018
Member
That comment was pending and I forgot to submit it.
That comment was pending and I forgot to submit it.
Ericson2314
Nov 30, 2018
Member
Putting my thing another way, you can do either way (manual var or depsBuildBuild) the same way for !(build == host == target)
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)