r/Compilers • u/Retired-69 • Jun 27 '26
Thoughts on multi-target compilation?
I've just finished adding multi-target compilation to my language, and it actually works. Incremental compilation currently halts before the code generation stage, which is intentional and I have no plans to change that.
Currently, the compiler can target x86-64, ARM64, and RISC-V from the same frontend.Raw machine code and assembly.
Are there any common pitfalls or edge cases I should be aware of as I wrap up the backend?
Everything is handwritten—I'm not using LLVM or any other compiler framework. I started by writing raw machine code in Notepad, built an assembler from that, then ported everything to Linux. I'm in the final stage now, and if everything goes according to plan, I should have a demo ready in about 1–2 months.
1
u/Retired-69 Jun 29 '26
I figured out multi-target code generation as well, and I'll have a public demo ready soon.
This is probably my farewell project after nearly four decades in the software industry. I've started documenting the architecture, although I haven't decided where to publish the papers yet.
Within the next month or two, I plan to release a public research/demo compiler. It will demonstrate ideas I've been experimenting with, including a flat-node AST architecture, order-independent parsing, and generics implemented without AST cloning or name mangling.
Until then, I'm going offline again to focus on finishing it.
As one of the stress tests:
struct W<T> { T value; }; W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<i32>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> super_nested_generic_box;
1
u/Karyo_Ten Jun 27 '26
Are you only targeting Linux? Because each OS can have its own ABI
1
u/matthieum Jun 27 '26
How high (or low) level can your language go?
In C, for example, the choice of targets affects the front-end/middle-end:
intcan be 2 or 4 bytes,doublecan be 4-bytes aligned or 8-bytes aligned. This in turn affects the layout ofstructandunionin memory.rdtsc, but ARM or RISC-V have something slightly different.A high-level language may not care about these differences: size/alignment may never be exposed anyway, intrinsics are never exposed either, and OS abstractions are provided by a "blessed" library possibly written in a different language.
If the language allows reaching these levels of details, then there will be impacts in the front-end and middle-end.
3
u/[deleted] Jun 27 '26
[removed] — view removed comment