#What is the zig compiler doing when we give him a .bc file (LLVM bitcode)?
1 messages ยท Page 1 of 1 (latest)
What are you seeking to accomplish?
Only I think that's what I'd expect, assuming that you asked Zig to build in debubg mode. (Or didn't specify.)
I'm currently learning to write LLVM passes and thought it would be fun to run it on those emitted bitcode, here are the 2 commands I used to compile
zig build-lib src/main.zig -target wasm32-freestanding -dynamic -rdynamic -O ReleaseSafe -femit-llvm-bc=module.bc
zig build-lib module.bc -target wasm32-freestanding -dynamic -rdynamic -O ReleaseSafe
So I was wondering what is the zig compiler exactly doing? I can't remember where I saw this but iirc zig doesn't use LLVM as a backend for wasm so it might be why
Hmmm. I'm not sure. That might be a bug. I'm not sure that Zig supports compiling LLVM bitcode using zig build-lib like that. ๐ค
I suppose it might if LLVM is enabled in Zig, but I'm just guessing there.
That would make sense
But I would expect that the bitcode produced by the first invocation would be built in releasesmall mode, for the record.
Though, that's probably not used very much (-femit-llvm-bc) - so might have bitrotted or otherwise be bugged.
What I noticed is that the llvm IR produced is super close to the actual wasm output
You could try running LLVM's WASM optimizer on it and see how much changes. ๐ค
LLVM, if you acquire it separately, comes with something like llvm-opt (I forget what its called)
But it's for optimizing WASM IIRC.
๐ ๐ o7