I always wonder why you would target another language with your compiler, instead of an IR.
What is the benefit of transpiling to C++ over using LLVM?
(not meant as a criticism, genuinely curious)
It is easier to deal with, going one step further requires dealing with more low level coding and can be demotivating for some.
However I would advise to target an IR instead.
Doesn't need to be LLVM, if the purpose is only learning about compilers, do as follows:
1 - Create an IR, preferably stack based as they are quite easy to target
2 - Basic IR interpreter for testing the workflow
3 - With a macro assembler, convert the IR into machine code in a dumb way
Now you have a workable compiler, even if it won't win any prizes.
If still interesting, then proceed to improve the code generation in a proper way.
https://github.com/udem-dlteam/ribbit
https://www.iro.umontreal.ca/~feeley/papers/YvonFeeleyVMIL21...