-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
rustc_metadata: don't let LLVM confuse rmeta blobs for COFF object files. #66235
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
Awaiting bors try build completion |
rustc_metadata: don't let LLVM confuse rmeta blobs for COFF object files. This has likely been a silent issue since 1.10 but only caused trouble recently (see #65536 (comment)), when recent changes to the `rmeta` schema introduced more opportunities for COFF parse errors. To prevent any undesired interactions with old compilers, I've renamed the file inside `rlib`s from `rust.metadata.bin` to `lib.rmeta` (not strongly attached to it, suggestions welcome). Fixes #65536. <hr/> Before: ``` $ llvm-objdump -all-headers build/*/stage1-std/*/release/deps/libcore-*.rmeta build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-6b9e8b5a59b79a1d.rmeta: file format COFF-<unknown arch> architecture: unknown start address: 0x00000000 Sections: Idx Name Size VMA Type SYMBOL TABLE: ``` After: ``` $ llvm-objdump -all-headers build/*/stage1-std/*/release/deps/libcore-*.rmeta llvm-objdump: error: 'build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-6b9e8b5a59b79a1d.rmeta': The file was not recognized as a valid object file ```
r=me |
☀️ Try build successful - checks-azure |
Queued b3b0b7a with parent 9e34664, future comparison URL. |
Finished benchmarking try commit b3b0b7a, comparison URL. |
Alright, nothing too interesting going on there, I guess LLVM wasn't wasting that much time on parsing rmeta as COFF, after all. @bors r=nagisa |
📌 Commit 0da85d6 has been approved by |
rustc_metadata: don't let LLVM confuse rmeta blobs for COFF object files. This has likely been a silent issue since 1.10 but only caused trouble recently (see rust-lang#65536 (comment)), when recent changes to the `rmeta` schema introduced more opportunities for COFF parse errors. To prevent any undesired interactions with old compilers, I've renamed the file inside `rlib`s from `rust.metadata.bin` to `lib.rmeta` (not strongly attached to it, suggestions welcome). Fixes rust-lang#65536. <hr/> Before: ``` $ llvm-objdump -all-headers build/*/stage1-std/*/release/deps/libcore-*.rmeta build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-6b9e8b5a59b79a1d.rmeta: file format COFF-<unknown arch> architecture: unknown start address: 0x00000000 Sections: Idx Name Size VMA Type SYMBOL TABLE: ``` After: ``` $ llvm-objdump -all-headers build/*/stage1-std/*/release/deps/libcore-*.rmeta llvm-objdump: error: 'build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-6b9e8b5a59b79a1d.rmeta': The file was not recognized as a valid object file ```
Rollup of 7 pull requests Successful merges: - #65719 (Refactor sync::Once) - #65831 (Don't cast directly from &[T; N] to *const T) - #66048 (Correct error in documentation for Ipv4Addr method) - #66058 (Correct deprecated `is_global` IPv6 documentation) - #66216 ([mir-opt] Handle return place in ConstProp and improve SimplifyLocals pass) - #66217 (invalid_value lint: use diagnostic items) - #66235 (rustc_metadata: don't let LLVM confuse rmeta blobs for COFF object files.) Failed merges: r? @ghost
This test was added in emscripten-core#10300 to check if we can handle non-objects in archives, especially rust metadata files that start with two leading zeroes. LLVM's file magic identifier thinks files with two leading zeroes are COFF files. But Rust metadata files used to start with two leading zeroes too, resulting in an error in LLVM tools. So emscripten-core#10300 bypassed use of `llvm-nm` to avoid that. We were still using `llvm-ranlib`, which also ran the LLVM magic identifier when trying to create a symbol table for an object, but `llvm-ranlib` so far has ignored those errors. But recently llvm/llvm-project@a20168d made them explicit errors, so we couldn't run `llvm-ranlib` anymore with archives containing objects that start with two leading zeroes. But this is not relevant anymore because Rust fixed their object file format in rust-lang/rust#66235, so their files are not mistaken by LLVM for COFF files anymore. So this PR fixes this test to not include a binary with two leading zeros, while still testing archival of non-object files.
This test was added in #10300 to check if we can handle non-objects in archives, especially rust metadata files that start with two leading zeroes. LLVM's file magic identifier thinks files with two leading zeroes are COFF files. But Rust metadata files used to start with two leading zeroes too, resulting in an error in LLVM tools. So #10300 bypassed use of `llvm-nm` to avoid that. We were still using `llvm-ranlib`, which also ran the LLVM magic identifier when trying to create a symbol table for an object, but `llvm-ranlib` so far has ignored those errors. But recently llvm/llvm-project@a20168d made them explicit errors, so we couldn't run `llvm-ranlib` anymore with archives containing objects that start with two leading zeroes. But this is not relevant anymore because Rust fixed their object file format in rust-lang/rust#66235, so their files are not mistaken by LLVM for COFF files anymore. So this PR fixes this test to not include a binary with two leading zeros, while still testing archival of non-object files.
This has likely been a silent issue since 1.10 but only caused trouble recently (see #65536 (comment)), when recent changes to the
rmeta
schema introduced more opportunities for COFF parse errors.To prevent any undesired interactions with old compilers, I've renamed the file inside
rlib
s fromrust.metadata.bin
tolib.rmeta
(not strongly attached to it, suggestions welcome).Fixes #65536.
Before:
After: