Skip to content

Undefined symbols from pthread in empty staticlib for wasip1 #155971

@benozol

Description

@benozol

Code

I tried this code:

I expected to see this happen: compiling an empty lib with crate type staticlib to target wasm32-wasi creates a relocatable Wasm .a without undefined symbols for pthreads.

Instead, this happened: the .a contains undefined symbols for pthreads (the .wasm has no undefined symbols)

repro.sh

rustc 1.93.1 (01f6ddf75 2026-02-11)
=== undefined pthread symbols ===

rustc 1.94.1 (e408947bf 2026-03-25)
=== undefined pthread symbols ===
--- std-c91e563353c7e174.std.728e8bab36f00-cgu.0.rcgu.o ---
   - 454: F <env.pthread_join> func=91 [ undefined binding=global vis=default ]
   - 1278: F <env.pthread_detach> func=142 [ undefined binding=global vis=default ]
 
rustc 1.95.0 (59807616e 2026-04-14)
=== undefined pthread symbols ===
--- std-d64733c6df5094a8.std.a88812da5ee6ad9e-cgu.0.rcgu.o ---
   - 281: F <env.pthread_attr_init> func=52 [ undefined binding=global vis=default ]
   - 282: F <env.pthread_attr_setstacksize> func=53 [ undefined binding=global vis=default ]
   - 285: F <env.pthread_attr_destroy> func=55 [ undefined binding=global vis=default ]
   - 292: F <env.pthread_create> func=56 [ undefined binding=global vis=default ]
   - 294: F <env.pthread_join> func=57 [ undefined binding=global vis=default ]
   - 819: F <env.pthread_detach> func=114 [ undefined binding=global vis=default ]
   - 
rustc 1.97.0-nightly (37d85e592 2026-04-28)
=== undefined pthread symbols ===
--- std-e31abec1fa1087a7.std.22fe8ebee811282d-cgu.0.rcgu.o ---
   - 281: F <env.pthread_attr_init> func=52 [ undefined binding=global vis=default ]
   - 282: F <env.pthread_attr_setstacksize> func=53 [ undefined binding=global vis=default ]
   - 285: F <env.pthread_attr_destroy> func=55 [ undefined binding=global vis=default ]
   - 292: F <env.pthread_create> func=56 [ undefined binding=global vis=default ]
   - 294: F <env.pthread_join> func=57 [ undefined binding=global vis=default ]
   - 826: F <env.pthread_detach> func=114 [ undefined binding=global vis=default ]

Triggered by #153634?

Version it worked on

It most recently worked on: 1.93

Version with regression

rustup run 1.94 rustc --version --verbose:

rustc 1.94.1 (e408947bf 2026-03-25)
binary: rustc
commit-hash: e408947bfd200af42db322daf0fadfe7e26d3bd1
commit-date: 2026-03-25
host: aarch64-apple-darwin
release: 1.94.1
LLVM version: 21.1.8

rustup run nightly rustc --version --verbose:

rustc 1.97.0-nightly (37d85e592 2026-04-28)
binary: rustc
commit-hash: 37d85e592f9ae5f20f7d9a9f99785246fa7298da
commit-date: 2026-04-28
host: aarch64-apple-darwin
release: 1.97.0-nightly
LLVM version: 22.1.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/O-wasm32v1-noneTarget: wasm32v1-noneT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions