Skip to content

avoid ICE on conflicting TLS declarations - #1701

Open
amirHdev wants to merge 3 commits into
rust-lang:mainfrom
amirHdev:tls-declaration-ice
Open

amirHdev wants to merge 3 commits into
rust-lang:mainfrom
amirHdev:tls-declaration-ice

Conversation

@amirHdev

@amirHdev amirHdev commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

fixes #1691

declaring the same symbol as both thread-local and non-thread-local currently makes cg_clif ICE when Cranelift tries to merge the declarations.

we can check for the mismatch first and reports a compiler error instead

Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Comment thread src/constant.rs
"conflicting thread-local and non-thread-local declarations for `{symbol_name}`"
),
);
}

@bjorn3 bjorn3 Oct 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nicer to instead have declare_data return an error that we can catch. Opened bytecodealliance/wasmtime#14469 for this.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense but as #14469 is still unmerged and we're still on cranelift-module 0.135.0 that error isn't available here yet

I can switch this to handling the declare_data error once the Cranelift change is available here

Comment thread build_system/tests.rs Outdated
// This test checks a cg_clif diagnostic; LLVM accepts the conflicting declarations.
if matches!(cg_clif_dylib, CodegenBackend::Builtin(name) if name == "llvm") {
skip_tests.push("aot.tls_conflicting_declarations");
}

@bjorn3 bjorn3 Oct 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also disable it in .github/workflows/main.yml in the test_llvm job under "Disable JIT tests".

View changes since the review

Comment thread build_system/tests.rs
"{}{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr),
);

@bjorn3 bjorn3 Oct 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you directly check that stderr contains/does not contain the expected output instead?

View changes since the review

Comment thread build_system/tests.rs Outdated
}),
TestCase::custom("aot.tls_conflicting_declarations", &|runner| {
let variants: &[(&str, bool)] = if runner.target_compiler.target.contains("windows") {
// Matching TLS declarations currently produce a duplicate-symbol error on Windows.

@bjorn3 bjorn3 Oct 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, what is going on there?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems windows rejects the other two cases earlier with symbol EXPORTED is already defined before we reach the TLS declaration check

can we keep just the plain conflict case on windows and all three elsewhere ?

Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
@amirHdev
amirHdev force-pushed the tls-declaration-ice branch from bb316b2 to 4fdf1f8 Compare October 2, 2026 16:57
@amirHdev
amirHdev requested a review from bjorn3 October 3, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ice Can't change TLS data object to normal or in the opposite way

2 participants