BartmanAbyss / vscode-amiga-debug

One-stop Visual Studio Code Extension to compile, debug and profile Amiga C/C++ programs compiled by the bundled gcc 12.2 with the bundled WinUAE/FS-UAE.
GNU General Public License v3.0
315 stars 39 forks source link

Add libnix? #5

Open tehKaiN opened 4 years ago

tehKaiN commented 4 years ago

Hi there,

Due to recent developments of your extension, I'm trying to support both yours and Bebbo's GCC in my code.

To this point I've used stdio.h, string.h and other std headers excensively. I see that your implementation lacks lots of fns. Perhaps you could include https://github.com/bebbo/libnix (even the ks1.3+ variant) in your toolchain?

More regarding libnix: https://github.com/bebbo/amiga-gcc/wiki/Libraries

BartmanAbyss commented 4 years ago

Hi, thanks for using my extension. The focus of my extension is more on demo & game development, these don't need a std lib. As such, this is currently low on my list of priorities. However, if you want to add it to the extension, I will accept a pull request if you get it working, and it's not enabled by default.

tehKaiN commented 4 years ago

Yeah, and I'm developing a game engine/library/framework/whatever for classic Amigas since 2013 and have a bunch of games running with it. ;)

I've tried building libnix but don't have enough patience, so I've started rewriting my code. I've came up with tiny std library with functions which I use - they are not tested yet, because I'm getting some link errors:

undefined reference to `__muldi3'
undefined reference to `__clzsi2'
undefined reference to `__fixdfsi'
undefined reference to `__udivdi3'
undefined reference to `__ltdf2'
undefined reference to `__floatsidf'
undefined reference to `__muldf3'
undefined reference to `__subdf3'
undefined reference to `__adddf3'
undefined reference to `__divdf3'
undefined reference to `__gtdf2'
undefined reference to `__fixunsdfsi'
undefined reference to `__floatunsidf'
undefined reference to `__ledf2'
undefined reference to `__gedf2'
undefined reference to `__umoddi3'

Any idea how to work around that? The files are in the attachment - just paste them into project made from template and try to build.

ministd.zip

BartmanAbyss commented 4 years ago

You’re using floating point on a CPU with no FPU. You need to get these intrinsics from a m68k GC support library I guess. I have only included mulsi3, divsi3, modsi3, etc. in gcc8_support.s

tehKaiN commented 4 years ago

Not all are float related. See https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html . I can work around those missing float routines, but there are others, which are quite useful:

I know they are not present in 68000 assembly, but are quite often used. Could you consider implementing at least those?

BartmanAbyss commented 4 years ago

You can copy the implementations (as I did) from here: https://github.com/BartmanAbyss/gcc/blob/master/libgcc/config/m68k/lb1sf68.S

tehKaiN commented 4 years ago

Interestingly, missing symbols are not there, but in libgcc2.c. I've refrained from copying them to my project to prevent it from being "infected" with GPL. I've implemented some by myself, made rest of the code not to use remaining and it works!

I'm not closing this issue since libnix would be a good addition. Perhaps some other ppl could also vote for it by adding thumbs up to 1st post.

BartmanAbyss commented 4 years ago

There shouldn't be any license issues: [https://www.gnu.org/licenses/gcc-exception-3.1-faq.en.html]()

tehKaiN commented 4 years ago

I've stumbled upon yet another reason for adding libnix - it has a swapstack module which allows for automatically reallocating stack to specified size.

The default for ks1.3 is 4000, which is extremely small for bigger games, especially written in C++, since objects tend to be created in local scope, which consumes stack rapidly.

I'll include the swapstack code in my game library, but probably other toolchain users will have similar problem.