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

Don't error when adding a staticlib with bitcode files compiled by newer LLVM #137017

Merged
merged 4 commits into from
Mar 1, 2025

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Feb 14, 2025

@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2025

r? @oli-obk

rustbot has assigned @oli-obk.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 14, 2025
@bjorn3 bjorn3 force-pushed the ignore_invalid_bitcode branch 2 times, most recently from 8113404 to 1c12171 Compare February 14, 2025 09:37
@bjorn3
Copy link
Member Author

bjorn3 commented Feb 14, 2025

For testing this how I can create a minimal LLVM bitcode file which is guaranteed to be interpreted as having an invalid LLVM version? Something obviously bogus like BC\xC0\xDEaaaa doesn't make rustc emit an error and nm only says "bfd plugin: LLVM gold plugin has failed to create LTO module: Bitcode file does not contain any modules", which seems to suggest that the bitcode file is technically valid, just missing any contents.

@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Feb 14, 2025
@rustbot

This comment was marked as off-topic.

@bjorn3 bjorn3 force-pushed the ignore_invalid_bitcode branch from dc821c8 to d87c536 Compare February 14, 2025 10:54
@bjorn3 bjorn3 force-pushed the ignore_invalid_bitcode branch from d87c536 to 9147b6d Compare February 14, 2025 10:55
@bjorn3
Copy link
Member Author

bjorn3 commented Feb 14, 2025

The test uncovered two memory corruption bugs due to accidentally trying to use both an io::Error and a Cow<str> as String on the other side of the FFI. These are now fixed.

@rust-log-analyzer

This comment has been minimized.

@pcc
Copy link
Contributor

pcc commented Feb 14, 2025

For testing this how I can create a minimal LLVM bitcode file which is guaranteed to be interpreted as having an invalid LLVM version? Something obviously bogus like BC\xC0\xDEaaaa doesn't make rustc emit an error and nm only says "bfd plugin: LLVM gold plugin has failed to create LTO module: Bitcode file does not contain any modules", which seems to suggest that the bitcode file is technically valid, just missing any contents.

There are some invalid bitcode files in LLVM's test suite, e.g. https://github.com/llvm/llvm-project/blob/24830ea7108197c7880939aa2e32db3aa4bc6284/llvm/test/Bindings/llvm-c/Inputs/invalid.ll.bc

@bjorn3
Copy link
Member Author

bjorn3 commented Feb 21, 2025

Looks like telling llvm-ar to not attempt to produce a symbol table is enough to make the test pass on CI.

@rustbot ready

@oli-obk
Copy link
Contributor

oli-obk commented Feb 21, 2025

I had an inline question above

@rustbot reviewed 😆

@bjorn3
Copy link
Member Author

bjorn3 commented Feb 26, 2025

@rustbot ready

@oli-obk
Copy link
Contributor

oli-obk commented Feb 26, 2025

@bors r+

@bors
Copy link
Contributor

bors commented Feb 26, 2025

📌 Commit 9f190d7 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 26, 2025
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Feb 28, 2025
…li-obk

Don't error when adding a staticlib with bitcode files compiled by newer LLVM

cc rust-lang#128955 (comment)
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Feb 28, 2025
…li-obk

Don't error when adding a staticlib with bitcode files compiled by newer LLVM

cc rust-lang#128955 (comment)
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 1, 2025
Rollup of 10 pull requests

Successful merges:

 - rust-lang#134943 (Add FileCheck annotations to mir-opt/issues)
 - rust-lang#137017 (Don't error when adding a staticlib with bitcode files compiled by newer LLVM)
 - rust-lang#137197 (Update some comparison codegen tests now that they pass in LLVM20)
 - rust-lang#137540 (Fix (more) test directives that were accidentally ignored)
 - rust-lang#137551 (import `simd_` intrinsics)
 - rust-lang#137599 (tests: use minicore more)
 - rust-lang#137673 (Fix Windows `Command` search path bug)
 - rust-lang#137676 (linker: Fix escaping style for response files on Windows)
 - rust-lang#137693 (Re-enable `--generate-link-to-defintion` for tools internal rustdoc)
 - rust-lang#137770 (Fix sized constraint for unsafe binder)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 61e9004 into rust-lang:master Mar 1, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 1, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 1, 2025
Rollup merge of rust-lang#137017 - bjorn3:ignore_invalid_bitcode, r=oli-obk

Don't error when adding a staticlib with bitcode files compiled by newer LLVM

cc rust-lang#128955 (comment)
@bjorn3 bjorn3 deleted the ignore_invalid_bitcode branch March 3, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants