Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency of rustc_fluent_macros getting compiled with -Ztls-model=initial-exec #134863

Closed
bjorn3 opened this issue Dec 28, 2024 · 0 comments · Fixed by #134865
Closed

Dependency of rustc_fluent_macros getting compiled with -Ztls-model=initial-exec #134863

bjorn3 opened this issue Dec 28, 2024 · 0 comments · Fixed by #134865
Labels
A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Dec 28, 2024

Proc macros must not be compiled with -Ztls-model=initial-exec as -Ztls-model=initial-exec is incompatible with dlopen. Glibc is somewhat lenient with dlopening dylibs compiled with -Ztls-model=initial-exec for as long as there is room, but other libc implementations may not provide enough room or provide room at all. For example on FreeBSD trying to use rustc_driver results in the following error:

https://cirrus-ci.com/task/4557776715776000

error: /.rustup/toolchains/nightly-2024-12-28-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_fluent_macro-60e8ff74c2f2aaa5.so: No space available for static Thread Local Storage
  --> src/lib.rs:16:1
   |
16 | extern crate rustc_middle;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

To fix this issue, the set of exclusions at

// `-Ztls-model=initial-exec` must not be applied to proc-macros, see
// issue https://github.com/rust-lang/rust/issues/100530
if env::var("RUSTC_TLS_MODEL_INITIAL_EXEC").is_ok()
&& crate_type != Some("proc-macro")
&& !matches!(crate_name, Some("proc_macro2" | "quote" | "syn" | "synstructure"))
{
cmd.arg("-Ztls-model=initial-exec");
}
needs to be updated to include all direct and indirect dependencies of the rustc_fluent_macros crate.

@bjorn3 bjorn3 added A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 28, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 28, 2024
@clubby789 clubby789 added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 28, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 29, 2024
…zkan

bootstrap: Don't apply -Ztls-model=initial-exec to deps of proc-macros

Fixes rust-lang#134863

1. Checks if a crate name is in a static list before applying the flag
2. Adds a tidy check that gathers transitive deps of proc macros and ensures the list is up to date

cc `@bjorn3` - the issue specifies `rustc_fluent_macro` but I assume this applies to all proc macro crates.
jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 29, 2024
…zkan

bootstrap: Don't apply -Ztls-model=initial-exec to deps of proc-macros

Fixes rust-lang#134863

1. Checks if a crate name is in a static list before applying the flag
2. Adds a tidy check that gathers transitive deps of proc macros and ensures the list is up to date

cc ``@bjorn3`` - the issue specifies `rustc_fluent_macro` but I assume this applies to all proc macro crates.
@bors bors closed this as completed in c156614 Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants