r/ProgrammingLanguages • u/naharashu • 14d 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?
19
Upvotes
1
u/quasar_tree 14d ago
If you're just doing this for fun/learning, generating asm is certainly very easy and straightforward, depending on how much low-level wizardry you want to expose in your language. If this is the case, don't overthink it!
If you're seriously trying to make a useful language, it depends on what exactly you want your language to do and we'd need more information to give you good advice