dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.36k stars 188 forks source link

[NativeAOT-LLVM] LLVM version synchronization and verification #2599

Open SingleAccretion opened 1 month ago

SingleAccretion commented 1 month ago

We are using LLVM in three places:

1) In the compiler, to produce bitcode. The LLVM version used here is defined by what llvm-project commit we fetch in CI. I'll call this version VP. 2) In the runtime build, to compile the native runtime code. The LLVM version used here is defined by the [EM|WASI-]SDK version we download in CI. I'll call this version VR. 2) In the build, we use the [EM|WASI-]SDK clang to compile this bitcode. The LLVM version used here is defined by the SDK version installed on the user's machine. I'll call this version VC.

The compatibility relationship between these versions, taking into account the fact that older LLVM bitcode can be consumed by newer LLVM versions (generally speaking), is VP <= VR == VC. VR must be equal to VC because VC is what defines the "toolchain version" of the overall static link.

We should add tests and diagnostics that verify this: 1) Warn the user if the SDK version doesn't match one the runtime objects were compiled against. 2) Fail the runtime build if llvm-project's LLVM version > SDK's LLVM version.