Skip to content

Conversation

@vadorovsky
Copy link
Member

@vadorovsky vadorovsky commented Nov 12, 2025

Linking bitcode produced by different LLVM versions can lead either to:

  • The backend failing to lower the IR to bytecode (an easier-to-debug scenario that throws a descriptive error).
  • "Successful" compilation but with broken BTF (DI sanitization modifies DI operands, which have incompatibilities across versions).

To prevent both cases, always throw an error when the bitcode is incompatible.

Fixes: #319


This change is Reviewable

@vadorovsky vadorovsky force-pushed the check-bc-ver branch 6 times, most recently from 1fcce64 to ff51b6e Compare November 12, 2025 21:06
Rust 1.91.0 is the newest stable version that uses LLVM 21.

Rust 1.86.0 makes it impossible to honor the recent clippy lints.
@vadorovsky vadorovsky force-pushed the check-bc-ver branch 9 times, most recently from c9c623d to fe849dc Compare November 14, 2025 12:23
LLVM bitcode is not backwards compatible and linking bitode objects
produced by different LLVM versions, even when it does not always
trigger any error in the backend, can lead to miscompilation (e.g.
aya-rs#318).

Using clang 15 for a compile test  was "working" out of luck, because
the program was simple enough to not cause a miscompilation. But given
that it's wrong, ensure that clang version matches LLVM version
Linking bitcode produced by different LLVM versions can lead either to:

- The backend failing to lower the IR to bytecode (an easier-to-debug
  scenario that throws a descriptive error).
- "Successful" compilation but with broken BTF (DI sanitization modifies
  DI operands, which have incompatibilities across versions).

To prevent both cases, always throw an error when the bitcode is
incompatible.

Fixes: aya-rs#319
@vadorovsky vadorovsky force-pushed the check-bc-ver branch 2 times, most recently from dda1a14 to ad3cbcf Compare November 14, 2025 15:40
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.

feat: prevent linking when LLVM bytecode version isn't the one expected by the linker

1 participant