3 ms·
Are there any Z80 compilers with link time optimization? This is the exact problem that lto is designed to help with. ie. rather than emitting machine code in
by monocasa 6y ago
Are there any Z80 compilers with link time optimization? This is the exact problem that lto is designed to help with. ie. rather than emitting machine code in the object files (or in addition to), emit compiler IR so you can do additional optimization passes with the whole binary present at link time.
- Gibbon1 6y agoOne C compiler I used 30 years ago sacrificed reentrancy for variable folding. It did call chain analysis so that it could alias local variable and function parameters to single global scratch pad variables. That allowed you to write non trivial programs in C for the 8031/32 without external RAM.
- billforsternz 6y agoI remember using that one as well, Keil right?
- CyberDildonics 6y agoIt is probably pretty realistic at this point to compile any program for a Z80 into a single compilation unit.
- monocasa 6y agoSure, but codebases aren't structured that way.
- megameter 6y agoConcatenate it into an amalgamated unit at build time, then. This only adds a style requirement in that you can't use linking to enforce namespacing.
- monocasa 6y agoTo expect the compiler to take advantage of that, you'd need to mark pretty much every function with static.
- loeg 6y ago-fwhole-program? Or -fvisibility=hidden.
- monocasa 6y agoGCC doesn't have a mature Z80 backend.
- loeg 6y agoI didn't mention GCC in that comment. The concept of default visibility is hardly GCC-specific. Also, it is not clear that the thread is still on the topic of z80 specifically or whole-project LTO generally. If you find yourself doing the latter outside of z80, you may find GCC useful. And hidden visibility is often useful a good default. If you want a z80-specific LTO option, sorry, I'm unfamiliar with any. That's a pretty niche ask.
- monocasa 6y ago> I didn't mention GCC in that comment. The concept of default visibility is hardly GCC-specific. Those options you gave are GCC-specific. I don't know of a mature Z80 compiler that supports LTO. The thread at this point is on the topic of "so your compiler doesn't support LTO, how can we 80/20 our way to the same semantics"
- Reelin 6y agoI believe the LTO implementations of modern compilers handle this for you? (https://clang.llvm.org/docs/LTOVisibility.html https://clang.llvm.org/docs/LTOVisibility.html) Edit: Wow, as a result of your other comment about GCC I was surprised to learn that none of the Z80 compilers I could find appear to support this sort of thing. It looks like there was (previously?) an effort to put together a Z80 backend for LLVM, but my search results didn't look promising.