使用 guix build 交叉编译缺少的目标

cross-compilation for a missing target with guix build

例如,我可以为目标构建 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

但不适用于目标 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 hello@2.10 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 hello@2.10 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 gcc-cross-mipsel-linux-gnu@7.5.0 g…>)
   121:20  5 (cross-gcc-arguments "mipsel-linux-gnu" #<package gcc@…> …)
In gnu/packages/gcc.scm:
   235:52  4 (arguments #<package gcc@4.8.5 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"

如何为此目标构建?或者至少找出可用目标的完整列表?

find out the full list of available targets

所有活动目标都列在 gnu/packages/bootstrap.scmglibc-dynamic-linker 函数中。

how to build for this target?

您可以:

  1. 为您以后的包创建一个空目录;

  2. 将它的路径保存到环境变量中$GUIX_PACKAGE_PATH;

  3. 将提到的 bootstrap.scm 文件放在这里:$GUIX_PACKAGE_PATH/gnu/packages/bootstrap.scm;

  4. 对其进行必要的更改:

    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. 并构建一个包(同时会构建一套完整的compiler/binutils/etc.-gcc-toolchain-):

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