davidgiven / ack

The Amsterdam Compiler Kit
http://tack.sf.net
Other
421 stars 59 forks source link

[question/feature/optimization] Dynamicly/modularly assemble standard libraries before linking them? #143

Open Fabrizio-Caruso opened 5 years ago

Fabrizio-Caruso commented 5 years ago

The CP/M is barely usable with the standard library because (if I understand well) the libraries are not rebuilt dynamicly but simply linked entirely when used by the code.

Other 8-bit compilers (such as Z88DK), use pragmas to exclude portions of the standard library such as for example:

#pragma printf = "%c %u" to only include some converters
#pragma output CLIB_MALLOC_HEAP_SIZE = 0 to set the heap to zero
#pragma output CLIB_STDIO_HEAP_SIZE = 0 to disable file open/close 

The library arre then rebuilt on the fly without the unnecessary features.

Would a similar solution be possible?

davidgiven commented 5 years ago

The obvious solution is to simply build multiple copies of printf/scanf with different sets of options into their own library, and then let the user select which one they want at link time. I suspect it might not even be very hard. Let me think about that.

Fabrizio-Caruso commented 5 years ago

Hi David! Thanks for the recent progress! I was just proposing the solution other dev-kits use (such as Z88DK). They just have one library which is rebuilt if some pragmas/options are passed. You cannot take into account the exponential number of combinations unless you restrict yourself to just 2 or 3 options.

Fabrizio-Caruso commented 5 years ago

Anyway, any solution that can reduce the size of the binary for 8-bit targets is great. The rest is just details.