Search code examples
cross-compilingguix

cross-compilation for a missing target with guix build


for example, i can build for the target mips64el-linux-gnu:

$ guix build --no-substitutes --target=mips64el-linux-gnu hello
...
successfully built /gnu/store/sdhhi1fhgbldl5qyfwvwlzhf2gq41n0j-hello-2.10.drv
/gnu/store/rbl4yrjyj3vxn27cap1y24z5wkr90p8y-hello-2.10

but not for the target mipsel-linux-gnu:

$ guix build --no-substitutes --target=mipsel-linux-gnu hello
Backtrace:
In guix/store.scm:
   1341:2 19 (map/accumulate-builds #<store-connection 256.99 7f2ad…> …)
In srfi/srfi-1.scm:
   586:17 18 (map1 (#<package [email protected] gnu/packages/base.scm:74 7…>))
In guix/store.scm:
   1300:8 17 (call-with-build-handler #<procedure build-accumulator…> …)
In guix/scripts/build.scm:
   576:18 16 (_ _)
In guix/packages.scm:
  1169:16 15 (package-cross-derivation _ #<package [email protected] gnu/p…> …)
  1510:22 14 (thunk)
  1447:22 13 (bag->cross-derivation #<store-connection 256.99 7f2ad…> …)
In srfi/srfi-1.scm:
   586:17 12 (map1 (("cross-gcc" #<package gcc-cross-mipsel-lin…>) …))
In guix/packages.scm:
  1212:16 11 (expand-input #<store-connection 256.99 7f2ad8295910> #f …)
  1169:16 10 (package-derivation _ #<package gcc-cross-mipsel-linux…> …)
  1486:22  9 (thunk)
  1169:16  8 (package->bag _ _ _ #:graft? _)
  1279:43  7 (thunk)
In gnu/packages/cross-base.scm:
    265:9  6 (arguments #<package [email protected] g…>)
   121:20  5 (cross-gcc-arguments "mipsel-linux-gnu" #<package gcc@…> …)
In gnu/packages/gcc.scm:
   235:52  4 (arguments #<package [email protected] gnu/packages/gcc.scm:364…>)
In gnu/packages/bootstrap.scm:
   306:14  3 (glibc-dynamic-linker _)
In ice-9/boot-9.scm:
  1669:16  2 (raise-exception _ #:continuable? _)
  1669:16  1 (raise-exception _ #:continuable? _)
  1669:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1669:16: In procedure raise-exception:
dynamic linker name not known for this system "mipsel-linux"

how to build for this target? or at least find out the full list of available targets?


Solution

  • find out the full list of available targets

    all active targets are listed in the glibc-dynamic-linker function in gnu/packages/bootstrap.scm.

    how to build for this target?

    you can:

    1. create an empty directory with your future packages;

    2. save the path to it into the environment variable $GUIX_PACKAGE_PATH;

    3. place the mentioned bootstrap.scm file here: $GUIX_PACKAGE_PATH/gnu/packages/bootstrap.scm;

    4. make the necessary changes to it:

      diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
      index 5a8028a465..102e7378ae 100644
      --- a/gnu/packages/bootstrap.scm
      +++ b/gnu/packages/bootstrap.scm
      @@ -317,6 +317,7 @@ or false to signal an error."
               ((string=? system "alpha-linux") "/lib/ld-linux.so.2")
               ((string=? system "s390x-linux") "/lib/ld64.so.1")
               ((string=? system "riscv64-linux") "/lib/ld-linux-riscv64-lp64d.so.1")
      +        ((string=? system "mipsel-linux") "/lib/ld.so.1")
      
               ;; XXX: This one is used bare-bones, without a libc, so add a case
               ;; here just so we can keep going.
      
    5. and build a package (at the same time, a complete set of compiler/binutils/etc. - gcc-toolchain - will be built):

      $ guix build --target=mipsel-linux-gnu hello
      ...
      /gnu/store/2vcvqn3c4ngif1l6s2dxambcpdmyywgc-hello-2.10