Skip to content

Add codegen/linkage tests for building compiler_builtins with debug assertions #122702

New issue

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

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

Already on GitHub? # to your account

Closed
saethlin opened this issue Mar 18, 2024 · 0 comments · Fixed by #122580
Closed

Add codegen/linkage tests for building compiler_builtins with debug assertions #122702

saethlin opened this issue Mar 18, 2024 · 0 comments · Fixed by #122580
Assignees
Labels
A-codegen Area: Code generation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@saethlin
Copy link
Member

This is similar to #118393. If someone figures out how to do one it should be easy to do the other as well.

For a long time, panics from compiler_builtins would result in linker errors unless they happened to be optimized out by the linker before resolution. Since #122580, such calls will either be replaced by a backend's abort intrinsic or a compile error during code generation.

I've used this locally to assess whether the PR fixes the root problem:

RUSTFLAGS="-Copt-level=1 -Cdebug-assertions=yes" cargo +nightly build -Zbuild-std --target=x86_64-unknown-linux-gnu
objdump -r target/x86_64-unknown-linux-gnu/debug/deps/libcompiler_builtins-b10ebdb7a18763a9.rlib | grep core

This objdump -r | grep is searching for mentions of core in the relocations inside the rlib. If don't find any, then compiler_builtins does not depend on core at link-time. There may be a more fine-tuned way to write this check that would make a test more robust, but this grep is sufficient to validate the property we need.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 18, 2024
@jieyouxu jieyouxu added A-codegen Area: Code generation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 18, 2024
@saethlin saethlin self-assigned this Mar 18, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 20, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-codegen Area: Code generation 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