opam switch install in foreign chroot picks version for host architecture, not guest architecture

问题描述 投票:0回答:1

我正在尝试在一堆系统上设置 OCaml,每个系统都有不同的处理器架构。操作系统是 Debian 破坏者。

编辑:amd64 以外的架构是 amd64 主机上的外部 chroot 环境。

编辑 2:目标是按需构建任何架构,只需提供目标架构作为参数。因此,工具链应该尽可能统一——不管它们是 32 位还是 64 位,或者主机和来宾架构是否相关。

来自安装脚本:

opam init -y --disable-sandboxing
eval $(opam config env)
# switches are named after the OCaml version
opam switch create $OCAML_VERSION $OCAML_VERSION -y

我已经用 OCaml 4.14.1 版试过了。这适用于 armhf 以及 amd64,但在 i386 上我收到以下错误:

#=== ERROR while compiling ocaml-base-compiler.4.14.1 =========================#
# context              2.0.3 | linux/x86_64 |  | https://opam.ocaml.org#6830df55
# path                 ~/.opam/4.14.1/.opam-switch/build/ocaml-base-compiler.4.14.1
# command              /usr/bin/make -j1
# exit-code            2
# env-file             ~/.opam/log/ocaml-base-compiler-13962-b76d46.env
# output-file          ~/.opam/log/ocaml-base-compiler-13962-b76d46.out
### output ###
# signals_osdep.h:33:57: error: ‘REG_R15’ undeclared (first use in this function); did you mean ‘REG_SS’?
# [...]
#                                                          ^~~~~~~
# signals_nat.c:228:39: note: in expansion of macro ‘CONTEXT_YOUNG_PTR’
#      Caml_state->young_ptr = (value *) CONTEXT_YOUNG_PTR;
#                                        ^~~~~~~~~~~~~~~~~

我在 4.14.0 和 4.08.1 上得到同样的错误; 4.13.1 和 4.12.1 为同一文件中的不同标识符 (

REG_RIP
) 抛出错误。然而,这些版本中至少有一个适用于 arm64、armhf、ppc64el 和 s390x(全部在外国 chroot 中)。

根据https://github.com/ocaml/ocaml/pull/11904,正在取消对 OCaml 的 32 位支持,但这适用于 arm 和 x86(而 armhf 似乎仍然有效),并且我不确定第一个 64 位版本是什么(提到了 5.x)——从 4.14.x 一直回到 4.08.x 似乎有点长。

编辑: 正如评论中所指出的,我看到 opam 将系统错误识别为 x86_64。在输出文件的第 21 行附近,我看到:

echo '#define HOST "x86_64-pc-linux-gnu"' >> build_config.h

但没有说明这是如何获得的。该值与主机系统上的

$MACHTYPE
相同,但 chroot 上的
$MACHTYPE
报告
i686-pc-linux-gnu
。其他平台的国外chroot好像没有这个问题

为什么 opam 认为它运行在 64 位平台上,我如何强制它安装 32 位版本?

ocaml opam
1个回答
1
投票

由于问题是主机架构被泄露,最简单的解决方法可能是使用

ocaml-option-32bit
选项显式请求 32 位编译器:

opam install 4.14.1+32bit ocaml-variants.4.14.1+options ocaml-option-32bit
© www.soinside.com 2019 - 2024. All rights reserved.