Subject: Using with rules_rust

From: Daníel Purkhús <[email-masked]>
Date: Fri, 9 Sep 2022 19:52:39 +0000

I've been trying to build our Rust code with these rules as the C/C++
toolchain but I'm encountering an issue.
When I try to build an project that depends on
https://crates.io/crates/async-trait I get the following error:

/workspace/bazel_output_base/execroot/monorepo/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/cargo__async-stream-impl-0.3.3/libasync_stream_impl-1922333755.so:
cannot allocate memory in static TLS block

There is a similar issue posted here when using cargo-zig:

https://github.com/messense/cargo-zigbuild/issues/4

I'm having a hard time figuring out if it's possible to fix this using
rules_rust and these rules. I was wondering if
anybody in this mailing list had found a way to get past this issue?

---

From: Motiejus Jakštys <[email-masked]>
Date: Sat, 10 Sep 2022 07:52:25 +0300

> anybody in this mailing list had found a way to get past this issue?

Hi Daníel,

Both cargo-zigbuild and bazel-zig-cc are thin wrappers on top of zig
cc, so the underlying mechanism (zig cc) is the one to look out for.

The best course of action would be to make a minimal example (e.g. a
single test.rs) and peel off the build layers (bazel-zig-cc or
cargo-zigbuild; whichever is easier) and file an issue in ziglang/zig.
If you have a minimal rust example that exposes this problem, "rustc"
and "zig cc" commands to reproduce it (no cargo or bazel), that will
go a long way for whoever is interested in picking this up to
understand what happened and fix this.

Hope that helps,
Motiejus