leanprover / leanprover/lean4

linux_wasm32 libleanrt.a seems to incorrectly refer to libuv symbols

Open
#6,817 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-low pr-welcome
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

linux_wasm32 libleanrt.a seems to incorrectly refer to libuv symbols

Context

I have a project based on Thea Brick's lean2wasm which I'm trying to upgrade to the latest Lean toolchain. I'm running into some errors during the final emscripten build step.

Steps to Reproduce
$ git clone git@github.com:ianh/lean2wasm.git lean2wasm
$ cd lean2wasm
$ lake build test
$ lake exe lean2wasm

Expected behavior:

The project builds as it did with the older version.

Actual behavior:

The project fails to build. There are various errors, but the relevant errors to this issue are:

error: undefined symbol: uv_fs_mkdtemp (referenced by root reference (e.g. compiled C/C++ code))
warning: _uv_fs_mkdtemp may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: uv_fs_mkstemp (referenced by root reference (e.g. compiled C/C++ code))
warning: _uv_fs_mkstemp may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: uv_os_tmpdir (referenced by root reference (e.g. compiled C/C++ code))
warning: _uv_os_tmpdir may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: uv_strerror (referenced by root reference (e.g. compiled C/C++ code))
warning: _uv_strerror may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library

The code tries to avoid using libuv if LEAN_EMSCRIPTEN is defined, so I'm assuming the WebAssembly libleanrt.a linking these symbols is not expected.

Versions

Lean 4.15.0
macOS 14.6.1
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.57-git

Additional Information

The reason I think libleanrt.a is the one referencing these symbols is because I get the following output on my own project, which has different build settings:

wasm-ld: error: toolchains/lean-4.15.0-linux_wasm32/lib/lean/libleanrt.a(io.cpp.o): undefined symbol: uv_strerror
wasm-ld: error: toolchains/lean-4.15.0-linux_wasm32/lib/lean/libleanrt.a(io.cpp.o): undefined symbol: uv_os_tmpdir
wasm-ld: error: toolchains/lean-4.15.0-linux_wasm32/lib/lean/libleanrt.a(io.cpp.o): undefined symbol: uv_strerror
wasm-ld: error: toolchains/lean-4.15.0-linux_wasm32/lib/lean/libleanrt.a(io.cpp.o): undefined symbol: uv_fs_mkstemp
wasm-ld: error: toolchains/lean-4.15.0-linux_wasm32/lib/lean/libleanrt.a(io.cpp.o): undefined symbol: uv_os_tmpdir
wasm-ld: error: toolchains/lean-4.15.0-linux_wasm32/lib/lean/libleanrt.a(io.cpp.o): undefined symbol: uv_strerror
wasm-ld: error: toolchains/lean-4.15.0-linux_wasm32/lib/lean/libleanrt.a(io.cpp.o): undefined symbol: uv_fs_mkdtemp
Impact

Impact to anyone using the WebAssembly toolchain.

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the lean2wasm commands and inspect libleanrt.a, especially io.cpp.o, for references to libuv symbols when LEAN_EMSCRIPTEN is defined. The issue is done when the linux_wasm32 WebAssembly build completes without undefined uv_fs_mkdtemp, uv_fs_mkstemp, uv_os_tmpdir, or uv_strerror symbols.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.