Skip to content

fix(musl-gcc): anchor the gcc-flavor root at the flavor version - #428

Merged
Sunrisepeak merged 1 commit into
mainfrom
fix/musl-gcc-flavor-root-version
Jul 27, 2026
Merged

fix(musl-gcc): anchor the gcc-flavor root at the flavor version#428
Sunrisepeak merged 1 commit into
mainfrom
fix/musl-gcc-flavor-root-version

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

两个 musl gcc 配方用裸 xvm.add(root_name) 锚定 flavor 子树的虚拟根,然后把每个子节点绑定到 <root_name>@<flavor_ver>

xvm.add()version 默认取 pkginfo.version(),所以实际创建的根<root_name>@16.1.0,而子节点指向的是 <root_name>@16.1.0-musl —— 两个不同的精确节点。子节点指向的那个根从未被注册。

xlings 2026.7.27.1 开始校验这一点并整批拒绝:

error: registration binding root is not an exact batch node
  code:     xvm-binding-root-missing
  provider: xim:musl-gcc@16.1.0
  at:       xim-musl-gnu-gcc@16.1.0-musl
  field:    /nodes/37/binding
  hint:     a binding points at something the recipe never registers

对用户呈现为 [musl-gcc] failed: config hook failedxlings install musl-gcc 退出 1。

gcc.lua 用同样的裸写法却没事,只是因为它的子节点绑定到 xim-gnu-gcc@<pkginfo.version()> —— 恰好就是默认值填进去的那个。musl 配方的 flavor 后缀打破了这个巧合。这个 bug 自 flavor root 引入起就潜伏着,只是直到 xlings 开始检查才显形。

__unregister_gcc_flavor 犯了对称的错误:它移除的是裸根(即 <root>@<pkginfo.version()>),从来不是真正创建的那个节点。一并改为带版本。

验证(xlings 2026.7.27.2 + musl-gcc@15.1.0)

修复前:

$ xlings install musl-gcc@15.1.0 -y
[error] registration binding root is not an exact batch node
        code:  xvm-binding-root-missing
[error] [musl-gcc] failed: config hook failed

修复后:

$ xlings install musl-gcc@15.1.0 -y
xim:musl-gcc@15.1.0 is already installed          (exit 0,无 binding 报错)

$ musl-gcc --version
x86_64-linux-musl-gcc (GCC) 15.1.0

$ musl-gcc -static a.c -o a && ./a
(exit 0)

影响面

全索引扫过一遍同型写法:其余带 binding 的配方都把它构造成 package.name .. "@" .. pkginfo.version(),与默认值一致,因此只有这两个受影响。

上下文

发现于 mcpp 把 xlings pin 从 0.4.69 升到 2026.7.27.2mcpp-community/mcpp#292),CI 的 toolchain: musl + llvm 与两个 linux e2e 分片因此变红。合入本 PR 后那条链路才能通。

Both musl gcc recipes register a virtual root for their flavor subtree with a
bare `xvm.add(root_name)`, then bind every child to `<root_name>@<flavor_ver>`.
`xvm.add()` defaults `version` to `pkginfo.version()`, so the root actually
created is `<root_name>@16.1.0` while the children name
`<root_name>@16.1.0-musl` — a different exact node. The root they point at was
never registered.

xlings 2026.7.27.1 validates this and rejects the whole batch:

    error: registration binding root is not an exact batch node
      code:     xvm-binding-root-missing
      provider: xim:musl-gcc@16.1.0
      at:       xim-musl-gnu-gcc@16.1.0-musl
      field:    /nodes/37/binding

which surfaces to the user as `[musl-gcc] failed: config hook failed` and makes
`xlings install musl-gcc` exit 1.

gcc.lua uses the same bare form without trouble only because its children bind
to `xim-gnu-gcc@<pkginfo.version()>` — exactly what the default fills in. The
musl recipes' flavor suffix breaks that coincidence; the bug has been latent
since the flavor root was introduced and only became visible once xlings
started checking.

`__unregister_gcc_flavor` had the mirror image of the same mistake: it removed
the bare root, i.e. `<root>@<pkginfo.version()>`, never the node that was
created. Now versioned to match.

Verified against xlings 2026.7.27.2 with musl-gcc@15.1.0:

  before: `xlings install musl-gcc@15.1.0 -y` → xvm-binding-root-missing,
          config hook failed
  after:  installs clean (exit 0); `musl-gcc --version` reports
          x86_64-linux-musl-gcc (GCC) 15.1.0 and `musl-gcc -static` compiles
          and runs a binary

Swept the rest of the index for the same shape: every other recipe with a
binding builds it as `package.name .. "@" .. pkginfo.version()`, which matches
the default, so these two are the only ones affected.
@Sunrisepeak
Sunrisepeak merged commit 37c00f6 into main Jul 27, 2026
10 checks passed
@Sunrisepeak
Sunrisepeak deleted the fix/musl-gcc-flavor-root-version branch July 27, 2026 06:59
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.

2 participants