Skip to content

fix: match stub signature of lean_uv_dns_get_info to real implementation#13234

Merged
hargoniX merged 1 commit intoleanprover:masterfrom
kjsdesigns:fix-wasm-dns-stub-signature
Apr 7, 2026
Merged

fix: match stub signature of lean_uv_dns_get_info to real implementation#13234
hargoniX merged 1 commit intoleanprover:masterfrom
kjsdesigns:fix-wasm-dns-stub-signature

Conversation

@kjsdesigns
Copy link
Copy Markdown
Contributor

@kjsdesigns kjsdesigns commented Apr 1, 2026

This PR fixes a build issue when Lean is not linked against libuv.

Problem

In src/runtime/uv/dns.cpp, the non-libuv stub of lean_uv_dns_get_info (in the #else branch, compiled when building without libuv) has a 4-parameter signature:

lean_uv_dns_get_info(b_obj_arg name, b_obj_arg service, uint8_t family, int8_t protocol)

But the real implementation above the #else has only 3 parameters:

lean_uv_dns_get_info(b_obj_arg name, b_obj_arg service, uint8_t family)

The Lean @[extern] declaration also expects 3 parameters. The stub has an extra int8_t protocol parameter that the real function and the Lean FFI caller do not use.

Fix

Remove the extra protocol parameter from the stub so both branches have the same signature.

Evidence

Discovered while building Lean4 to WASM via Emscripten for a production project (specify-lean) since v4.27.0. The stub branch is compiled in this configuration, and the signature mismatch was caught at link time. The fix has been stable in production across multiple Lean version bumps.

Related: Zulip thread on WASM build fixes (2026-03-21).

The non-libuv stub of lean_uv_dns_get_info (in the #else branch for
builds without libuv) has a 4-parameter signature including int8_t
protocol, but the real implementation above the #else has only 3
parameters (name, service, family). The Lean @[extern] declaration
also expects 3 parameters.

This mismatch means the stub has never matched the real function's
ABI. Remove the extra protocol parameter so both branches agree.

Discovered while building Lean4 to WASM via Emscripten, where the
stub branch is compiled. The fix has been in production use since
v4.27.0.
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Apr 1, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 8b52f4e8f701a9b56a76e6e0e118ef587621c3e0 --onto fc0cf68539ad3b481a1802414c22c44506519c9d. You can force Mathlib CI using the force-mathlib-ci label. (2026-04-01 15:38:48)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 8b52f4e8f701a9b56a76e6e0e118ef587621c3e0 --onto cfa8c5a036d6990635c6ec50b02d0e806995cec3. You can force reference manual CI using the force-manual-ci label. (2026-04-01 15:38:50)

@hargoniX hargoniX added the changelog-compiler Compiler, runtime, and FFI label Apr 7, 2026
@hargoniX hargoniX added this pull request to the merge queue Apr 7, 2026
Merged via the queue into leanprover:master with commit ba33c3d Apr 7, 2026
25 of 27 checks passed
wkrozowski pushed a commit to wkrozowski/lean4 that referenced this pull request Apr 10, 2026
…ion (leanprover#13234)

This PR fixes a build issue when Lean is not linked against libuv.

## Problem

In `src/runtime/uv/dns.cpp`, the non-libuv stub of
`lean_uv_dns_get_info` (in the `#else` branch, compiled when building
without libuv) has a **4-parameter** signature:

```cpp
lean_uv_dns_get_info(b_obj_arg name, b_obj_arg service, uint8_t family, int8_t protocol)
```

But the real implementation above the `#else` has only **3 parameters**:

```cpp
lean_uv_dns_get_info(b_obj_arg name, b_obj_arg service, uint8_t family)
```

The Lean `@[extern]` declaration also expects 3 parameters. The stub has
an extra `int8_t protocol` parameter that the real function and the Lean
FFI caller do not use.

## Fix

Remove the extra `protocol` parameter from the stub so both branches
have the same signature.

## Evidence

Discovered while building Lean4 to WASM via Emscripten for a production
project ([specify-lean](https://github.com/kjsdesigns/specify)) since
v4.27.0. The stub branch is compiled in this configuration, and the
signature mismatch was caught at link time. The fix has been stable in
production across multiple Lean version bumps.

Related: [Zulip thread on WASM build
fixes](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/WASM.20build.20fixes.3A.20libuv.20symbol.20leakage.20.28.236817.29.20and.20unique_lo/with/580836892)
(2026-03-21).

Co-authored-by: Keith Seim <keith@MacBook-Pro.local>
volodeyka pushed a commit that referenced this pull request Apr 16, 2026
…ion (#13234)

This PR fixes a build issue when Lean is not linked against libuv.

## Problem

In `src/runtime/uv/dns.cpp`, the non-libuv stub of
`lean_uv_dns_get_info` (in the `#else` branch, compiled when building
without libuv) has a **4-parameter** signature:

```cpp
lean_uv_dns_get_info(b_obj_arg name, b_obj_arg service, uint8_t family, int8_t protocol)
```

But the real implementation above the `#else` has only **3 parameters**:

```cpp
lean_uv_dns_get_info(b_obj_arg name, b_obj_arg service, uint8_t family)
```

The Lean `@[extern]` declaration also expects 3 parameters. The stub has
an extra `int8_t protocol` parameter that the real function and the Lean
FFI caller do not use.

## Fix

Remove the extra `protocol` parameter from the stub so both branches
have the same signature.

## Evidence

Discovered while building Lean4 to WASM via Emscripten for a production
project ([specify-lean](https://github.com/kjsdesigns/specify)) since
v4.27.0. The stub branch is compiled in this configuration, and the
signature mismatch was caught at link time. The fix has been stable in
production across multiple Lean version bumps.

Related: [Zulip thread on WASM build
fixes](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/WASM.20build.20fixes.3A.20libuv.20symbol.20leakage.20.28.236817.29.20and.20unique_lo/with/580836892)
(2026-03-21).

Co-authored-by: Keith Seim <keith@MacBook-Pro.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-compiler Compiler, runtime, and FFI toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants