WonderfulToolchain / wonderful-i8086

100% libre WonderSwan C toolchain
29 stars 0 forks source link

Experimental hack to hopefully allow WonderSwan toolchain to co-exist with MS-DOS cross toolchain etc. #4

Open tkchia opened 2 years ago

tkchia commented 2 years ago

Hello @asiekierka,

Currently, as you know, (my fork of) gcc-ia16 directly supports building programs for the MS-DOS and ELKS target platforms.

I have now implemented a (still experimental) -mr=runtime option in gcc-ia16 (https://github.com/tkchia/gcc-ia16/commit/7b96289013d909b86bdabac837357412fc5c8c66), which will hopefully allow it to support other target runtime environments — such as your WonderSwan target — in a more pluggable fashion.

Basically, if you say -mr=foo, the ia16-elf-gcc driver program will now try to look for a spec file named rt-specs/r-foo.spec under an install-prefix/ia16-elf/lib/ subdirectory. The spec file can then control how ia16-elf-gcc invokes the actual compiler passes, looks for include files and libraries, etc.

This is all still very preliminary and amenable to change (though I hope not too much needs changing). :slightly_smiling_face:

(Incidentally, it seems that the "standard" GNU way of porting the GNU toolchain to a new target runtime, is to

This would effectively mean having whole different sets of programs for ia16-pc-msdos-gcc, ia16-pc-elks-gcc, ia16-bandai-wswan-gcc, etc.)

Thank you!

asiekierka commented 2 years ago

Hey,

I'm happy you've added this. It will make the Makefiles cleaner (moving a lot of the hardcoded, platform-specific CFLAGS magic to a spec file) and the overall architecture easier to understand (in my opinion). However:

As such, I hope it is understandable that this issue may have a lower priority than other parts of the project (packaging binaries, further work on the standard libraries, etc).

I also don't think it will change much in terms of co-existing - if I'm using custom gcc-ia16 patches, my build still differs from upstream; conversely, if I'm not, you can still use gcc-ia16 binaries from build-ia16, as all of the magic currently happened in the CFLAGS/LDFLAGS area.

Thank you!

tkchia commented 2 years ago

Hello @asiekierka,

As such, I hope it is understandable that this issue may have a lower priority than other parts of the project (packaging binaries, further work on the standard libraries, etc).

Well, if and when you decide it is useful, just use it. Or not. :slightly_smiling_face:

  • I still have many custom steps in the build system which may not be easy to integrate into a spec file - like swanlink, which wraps the linker to allow compiling for a WonderSwan

Actually, there are a few spec string variables — such as post_link and self_spec — which might be able to help with that. See gcc/gcc.c. :wink: They are not documented in the GCC info file for some reason, but they are there.

Thank you!

asiekierka commented 1 year ago

As the Wonderful toolchain currently somewhat neatly installs itself in /opt/wonderful, arranges the equivalent of specs files via Makefile includes, and ships its own compilers/tooling, this remains a fairly low-priority task - nonetheless, I am keeping this issue open and archived.