ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.96k stars 2.55k forks source link

TLS issue when using Zig Linker with Rust #16780

Open j-baker opened 1 year ago

j-baker commented 1 year ago

Zig Version

0.10.1.post1 (python wheel)

Steps to Reproduce and Observed Behavior

I have a Rust crate built with Maturin, using pyo3 for Python bindings. I use the zig linker so as to provide simple cross platform code. So, the rough flow is:

When this crate is imported in a Python library with lots of dependencies, upon startup loading fails, claiming cannot allocate memory in static TLS block. I can work around by setting LD_PRELOAD=my_library.so though this is inconvinent as the library references Python symbols, so any Python program must unset LD_PRELOAD or child processes will fail to launch. We are on glibc2.31 since using Ubuntu 20.04.

Wondering if this is caused by https://github.com/ziglang/zig/issues/16152 but given size of intervening stack, no smoking gun.

Expected Behavior

Linking succeeds.

kubkon commented 1 year ago

Could you provide more complete repro steps, something I could immediately work with to see repro the failure locally?