Add -build-mode:llvm-bc flag to odin build that generates llvm-ir but in the bitcode format .bc.
#7198
tintin10q
started this conversation in
Ideas/Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
odin buildalready supports-build-mode:llvmand-build-mode:llvm-ir, which output.llfiles the human-readable textual representation of LLVM IR.The problem is that this textual format is not guaranteed to be stable across major LLVM versions: older textual IR is not guaranteed to parse correctly with a newer LLVM version. LLVM IR also has a second on-disk representation, the bitcode format (
.bc). Bitcode carries an explicit backwards-compatibility guarantee. A.bcfile produced by an older LLVM version will auto-upgrade cleanly when read by a newer llvm parser, all the way back to LLVM 3.0.You can convert
.llto.bcwithllvm-as, but that means round-tripping through the textual format for no reason if bitcode is what you actually want which is wastefull. That's why most LLVM frontends (clang, rustc, zig, etc.) can emit.bcdirectly. Odin currently (to my knowledge) cannot.Why does this matter? I'm running a project that compiles LLVM IR from several language frontends (including Odin) with a single shared
optbinary, so that pass behavior and cost models are identical across all inputs. Odin's frontend targets an older LLVM version than theoptbinary I'm using downstream. My setup only works when I giveoptbitcode rather than the textual IR.The solution I would like
Add a new build mode,
-build-mode:llvm-bc, that emits LLVM IR directly in bitcode form (.bc), the same way-build-mode:llvm-iremits it in the textual form.All reactions