Fabrizio-Caruso / CROSS-LIB

CROSS LIB - A universal 8-bit library and some games built with it
314 stars 30 forks source link

Please add SDCC support #292

Closed dgchrt closed 11 months ago

dgchrt commented 1 year ago

SDCC is not just easier to use than Z88DK because there are readily available packages, but it also outperformed it in tests: http://www.cpcmania.com/Docs/Programming/SDCC_vs_z88dk_Comparing_size_and_speed.htm

Fabrizio-Caruso commented 12 months ago

SDCC is already supported in Z88DK. So it is also supported in Cross-Lib. I even have an option to set its options in Cross-Lib's configuration file: https://github.com/Fabrizio-Caruso/CROSS-LIB/blob/master/src/config.ini#L11

Z88DK comes with 3 different compilers: SCC80, ZSDCC (basically the official SDCC with more optimizations) and recently CLANG. ZSDCC in Z88DK has an improved optimizer but it strictly follows and takes all SDCC improvements. It is regularly synched to SDCC.

ZSDCC has several shortcomings when compared to SCCZ80, though:

On the other hand, ZSDCC can produce faster and shorter binaries if I enable all optimizations but not always and not always by a large margin when compared to SCCZ80. So I only use ZSDCC on some of the slowest targets because SDCC with all Z88DK new optimizations can produce faster and smaller binaries.

One thing that I plan to do is to let the user more easily choose which compiler (SCCZ80 vs ZSDCC) to use for Z88DK targets. This is somehow already possible with the configuration file by passing the right options but it is not clean.

Fabrizio-Caruso commented 11 months ago

@diogoeichert If you want to compile a game for a Zilog 80 target and you want to use sdcc, just edit config.ini and change the sccz80_opts parameter as follows:

sccz80_compiler_opts = -compiler=sdcc -SO3

This line alone will tell Cross-Lib to always use sdcc instead of sccz80 with a high level of optimizations. You can use much heavier and slower optimizations with:

sccz80_compiler_opts = -compiler=sdcc -SO3 --max-allocs-per-node200000

But you may need to prepare a coffee for this because for large projects it may take minutes. As a rule, I would first develop my project only with sccz80 and only later switch to sdcc with the heavy optimizations, if I need extra speed but then, if you use sdcc, you need to retest your game.

I am closing this issue but feel free to ask more questions.

Fabrizio-Caruso commented 11 months ago

Hi again,

I have now changed the name of the configuration parameter in config.ini to z88dk_compiler_opts (to avoid confusion). You can specify there any option including which compiler. For example: