使用 guix build 交叉编译缺少的目标
Posted
技术标签:
【中文标题】使用 guix build 交叉编译缺少的目标【英文标题】:cross-compilation for a missing target with guix build 【发布时间】:2022-01-20 11:37:38 【问题描述】:例如,我可以为目标 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"
如何为这个目标构建?或者至少找出可用目标的完整列表?
【问题讨论】:
【参考方案1】:找出可用目标的完整列表
所有活动目标都列在gnu/packages/bootstrap.scm
的glibc-dynamic-linker
函数中。
如何为这个目标构建?
你可以:
用你未来的包创建一个空目录;
将其路径保存到环境变量$GUIX_PACKAGE_PATH
中;
将提到的bootstrap.scm
文件放在这里:$GUIX_PACKAGE_PATH/gnu/packages/bootstrap.scm
;
对其进行必要的更改:
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.
并构建一个包(同时会构建一整套compiler/binutils/etc.-gcc-toolchain-):
$ guix build --target=mipsel-linux-gnu hello
...
/gnu/store/2vcvqn3c4ngif1l6s2dxambcpdmyywgc-hello-2.10
【讨论】:
以上是关于使用 guix build 交叉编译缺少的目标的主要内容,如果未能解决你的问题,请参考以下文章