git.iko.soy/typeable/nixpkgs
on master help sign in
stdenv/cross-compilation: add section on avoiding cross-compiling GCC
commit251897b40de6181b43084a1fee5dd5b5db5c7834 authorBen Siraphob <bensiraphob@gmail.com> dateSun 21 Feb 2021, 22:10 (6 years ago) parent4550d65
1 file changed+7
doc/stdenv/cross-compilation.chapter.md+7
doc/stdenv/cross-compilation.chapter.md+7
@@ -106,6 +106,13 @@ Many packages assume that an unprefixed binutils (`cc`/`ar`/`ld` etc.) is availa
106106makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];
107107```
108108
109+#### How do I avoid compiling a GCC cross-compiler from source? {#cross-qa-avoid-compiling-gcc-cross-compiler}
110+On less powerful machines, it can be inconvenient to cross-compile a package only to find out that GCC has to be compiled from source, which could take up to several hours. Nixpkgs maintains a limited [cross-related jobset on Hydra](https://hydra.nixos.org/jobset/nixpkgs/cross-trunk), which tests cross-compilation to various platforms from build platforms "x86\_64-darwin", "x86\_64-linux", and "aarch64-linux". See `pkgs/top-level/release-cross.nix` for the full list of target platforms and packages. For instance, the following invocation fetches the pre-built cross-compiled GCC for `armv6l-unknown-linux-gnueabihf` and builds GNU Hello from source.
111+
112+```ShellSession
113+$ nix-build '<nixpkgs>' -A pkgsCross.raspberryPi.hello
114+```
115+
109116#### What if my package's build system needs to build a C program to be run under the build environment? {#cross-qa-build-c-program-in-build-environment}
110117Add the following to your `mkDerivation` invocation.
111118```nix