Skip to content

fix(openssl): depend on xim:perl and probe perl by running it - #141

Merged
Sunrisepeak merged 1 commit into
mainfrom
fix/openssl-perl-build-dep
Aug 1, 2026
Merged

fix(openssl): depend on xim:perl and probe perl by running it#141
Sunrisepeak merged 1 commit into
mainfrom
fix/openssl-perl-build-dep

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

Closes #140.

问题

./config 是 shell 脚本,execConfigure;Configure 的 shebang 是
#!/usr/bin/env perl,开头就是 use Config; use FindBin;

所以这个构建需要的不是"PATH 上有 perl 二进制",而是"perl 的 core module 在"——
在把 perl 拆成子包的发行版、或裁剪过的容器镜像上,这两件事不是一回事。
旧的门禁 command -v perl 恰好只回答前一个问题:这类机器顺利通过探测,然后在
Configure 第 15 行左右倒在 Can't locate FindBin.pm in @INC 上 —— 一条读起来
完全像 OpenSSL 自己出问题的报错。issue 里的复现环境是 Fedora 44 (WSL2) /
/usr/sbin/perl v5.42.2,find / -name FindBin.pm 无结果。

descriptor 的注释其实已经写着"a stripped container may not [ship perl]",但当时
索引里没有 perl 包可以声明为 build dep,所以它只能探测然后祈祷。

改动

  1. 声明 xim:perl@latest 为 build dep(linux + macosx)。
    前置 PR feat(pkg): add perl 5.44.0 (static musl on linux, relocatable on macOS) openxlings/xim-pkgindex#470 已合入,xim:perl 现在可解析:
    linux x86_64/aarch64 是完全静态 musl 构建,macosx x86_64/arm64 是 relocatable-perl,
    都带完整 core module tree。
    (注意 macosx 也声明了 —— 和 xim:make 不同,xim:perl 有 macosx 条目,所以
    不会重蹈 descriptor 里已记录的"在 macosx 声明 linux-only 包导致解析直接失败"那个坑。)

  2. 把那个 perl 的 bindir 放到每一步构建命令的 PATH 最前面。
    这才是真正起作用的机制:shebang 是 #!/usr/bin/env perl,决定用哪个解释器的是
    PATH,不是我们敲的命令。Configure 随后把它记进 $config{PERL}(取自 $^X),
    后续 make 的所有 perl helper 也跟着用同一个。

  3. 探测改成"真的把 perl 跑起来",而不是查它在不在。
    这条留给 fallback 路径(build dep 解析不出来时仍能用宿主完整的 perl 构建),
    但检查的是真正要紧的性质:perl -MConfig -MFindBin -MFile::Path -MFile::Spec -MFile::Basename -MPOSIX -e exit。失败时的报错也换成能直接照做的那句。

  4. build environment 日志现在打印 perl: $(command -v perl) —— 在与构建相同的 PATH 下,
    所以日志记的是 Configure 实际拿到的解释器,而不是我们希望它拿到的那个。

验证

不在本 PR 范围内

issue 里另外提到的两条属于 xlings/mcpp 引擎侧,不是 index 能修的,单独记一下:

  • 安装失败后残留 .xpkg.lua,下次 install_packages 直接返回 {"exitCode":0} 且不再
    重跑 install() —— 在包目录被清理前,真实失败被掩盖。
  • xlings 其实输出了 {"dataKind":"install_summary","payload":{"failed":1,...}},
    但没被透传,mcpp 那边只看到 "xlings emitted no structured error"。

Closes #140.

`./config` execs `Configure`, which is `#!/usr/bin/env perl` and opens
with `use Config; use FindBin;`. The old gate was `command -v perl`,
which answers a different question: a host can have /usr/bin/perl and
no FindBin.pm (split perl packaging, trimmed container — reproduced on
Fedora 44 WSL), sail through the probe, and die fifteen lines into
Configure with `Can't locate FindBin.pm in @INC` — a message that reads
like an OpenSSL bug.

Now that xim:perl exists (openxlings/xim-pkgindex#470) the package can
declare its way out instead of auditing the host: `xim:perl@latest` is
a build dep on linux and macosx, and its bindir goes to the FRONT of
PATH for every build step. That prefix is the actual mechanism — the
shebang means PATH decides which interpreter runs Configure, not the
command we type — and Configure then records it as $config{PERL} for
the rest of the build.

The probe survives as the fallback path's gate, but it now RUNS perl
with the modules Configure needs rather than looking the binary up.
Verified both directions: a perl with FindBin.pm deleted passes
`command -v perl` and fails the new probe.
@Sunrisepeak
Sunrisepeak merged commit a385bae into main Aug 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compat.openssl 的 install() 只探测 perl 是否存在,不验证 perl 是否可用 —— perl 缺核心模块(如 FindBin.pm)时报错晦涩

2 participants