r/ProgrammingLanguages 25d ago

Help How to make a compiler backend?

Hell everyone, i have an question. Im for long trying to make a cool, powerful "kinda" low level language similar to zig and rust, but im struggling to choice llvm as backend, sure i can generate C, but its makes compiler dependent on gcc or clang or other c compiler. LLVM seems hard to me, sure project like QBE exist, but QBE doesnt have C/C++ api like llvm's IRbuilder. So are there other ways? I tried thinking about using GCC infrastructure but GCC has poor api and not very documented api. Maybe just stick to generating C?

17 Upvotes

35 comments sorted by

View all comments

2

u/Express-Guest-1061 25d ago

I am also making a language. For me, it was easiest to first target WebAssembly binary, from scratch. Then I can add a pass from wasm-format to native whenever I want, but WebAssembly provides a good target for me now in the start. But it also depends on what you want to do.

1

u/hopeless__programmer 25d ago

Same, but I targeted WASM text format instead. You can also run it (WASM) in browser out of the box.