Skip to content

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

Merged
bors merged 4 commits into
rust-lang:masterfrom
bjorn3:ignore_invalid_bitcode
Mar 1, 2025
Merged

Don't error when adding a staticlib with bitcode files compiled by newer LLVM#137017
bors merged 4 commits into
rust-lang:masterfrom
bjorn3:ignore_invalid_bitcode

Conversation

@bjorn3

Copy link
Copy Markdown
Member

@rustbot

Copy link
Copy Markdown
Collaborator

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

@rustbotrustbot 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
Comment threadcompiler/rustc_codegen_llvm/src/back/archive.rs Outdated
Comment threadcompiler/rustc_codegen_llvm/src/back/archive.rs Outdated
@bjorn3
bjorn3force-pushed the ignore_invalid_bitcode branch 2 times, most recently from 8113404 to 1c12171CompareFebruary 14, 2025 09:37
Comment threadcompiler/rustc_codegen_llvm/src/back/archive.rs Outdated
@bjorn3

Copy link
Copy Markdown
MemberAuthor

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.

@rustbotrustbot 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.

Comment threadtests/run-make/staticlib-broken-bitcode/rmake.rs Outdated
@bjorn3
bjorn3force-pushed the ignore_invalid_bitcode branch from dc821c8 to d87c536CompareFebruary 14, 2025 10:54
@bjorn3
bjorn3force-pushed the ignore_invalid_bitcode branch from d87c536 to 9147b6dCompareFebruary 14, 2025 10:55
@bjorn3

Copy link
Copy Markdown
MemberAuthor

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.

Comment threadcompiler/rustc_codegen_llvm/src/back/archive.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@pcc

pcc commented Feb 14, 2025

Copy link
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Contributor

I had an inline question above

@rustbot reviewed 😆

@bjorn3

Copy link
Copy Markdown
MemberAuthor

@rustbot ready

@oli-obk

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Feb 26, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 9f190d7 has been approved by oli-obk

It is now in the queue for this repository.

@borsbors 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)
@jieyouxujieyouxu mentioned this pull request Feb 28, 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)
This was referenced Feb 28, 2025
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:masterMar 1, 2025
@rustbotrustbot 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-makeArea: port run-make Makefiles to rmake.rsS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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

@bjorn3@rustbot@rust-log-analyzer@pcc@oli-obk@bors@lqd