fix(openssl): depend on xim:perl and probe perl by running it - #141
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #140.
问题
./config是 shell 脚本,exec掉Configure;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/perlv5.42.2,find / -name FindBin.pm无结果。descriptor 的注释其实已经写着"a stripped container may not [ship perl]",但当时
索引里没有 perl 包可以声明为 build dep,所以它只能探测然后祈祷。
改动
声明
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 包导致解析直接失败"那个坑。)
把那个 perl 的 bindir 放到每一步构建命令的 PATH 最前面。
这才是真正起作用的机制:shebang 是
#!/usr/bin/env perl,决定用哪个解释器的是PATH,不是我们敲的命令。Configure 随后把它记进
$config{PERL}(取自$^X),后续
make的所有 perl helper 也跟着用同一个。探测改成"真的把 perl 跑起来",而不是查它在不在。
这条留给 fallback 路径(build dep 解析不出来时仍能用宿主完整的 perl 构建),
但检查的是真正要紧的性质:
perl -MConfig -MFindBin -MFile::Path -MFile::Spec -MFile::Basename -MPOSIX -e exit。失败时的报错也换成能直接照做的那句。build environment 日志现在打印
perl: $(command -v perl)—— 在与构建相同的 PATH 下,所以日志记的是 Configure 实际拿到的解释器,而不是我们希望它拿到的那个。
验证
mcpp test -p openssl→test result ok. 1 passed(先删掉已装的 compat-x-openssl强制重跑 install(),不是缓存命中)。
mcpp test -p asio-ssl→test result ok. 1 passed(另一个消费方向,openssl 作为asio
sslfeature 的依赖)。PERL=同样指向它。宿主上的是/usr/bin/perlv5.38.2 —— 两者不同,说明 PATH 前置确实生效了。
FindBin.pm删掉,复现 compat.openssl 的 install() 只探测 perl 是否存在,不验证 perl 是否可用 —— perl 缺核心模块(如 FindBin.pm)时报错晦涩 #140 那台机器的形态:command -v perl不在本 PR 范围内
issue 里另外提到的两条属于 xlings/mcpp 引擎侧,不是 index 能修的,单独记一下:
.xpkg.lua,下次install_packages直接返回{"exitCode":0}且不再重跑
install()—— 在包目录被清理前,真实失败被掩盖。{"dataKind":"install_summary","payload":{"failed":1,...}},但没被透传,mcpp 那边只看到 "xlings emitted no structured error"。