ghaerr / elks

Embeddable Linux Kernel Subset - Linux for 8086
Other
960 stars 103 forks source link

C compiler #1443

Open stevexyz opened 1 year ago

stevexyz commented 1 year ago

Maybe I'm wrong (I just tried to install elks on an original PC IBM XT), but seems to me that no C compiler is included inside elks (I've found the basic language interpreter though), while I think that's one of the basic thing of every Linux system.

If that's the case, I understand that a mammoth GCC might not really fit the project, but maybe the small and powerful tcc might be an option!

tyama501 commented 4 weeks ago

OK, I could build the libc by setting WATDIR /bin/watcom and INCLUDES += -I$(WATDIR)/h in watcom.inc image I need to compile ewcc and ewlink.

tyama501 commented 4 weeks ago

I needed to also modify WATCINCLUDE in ewcc and ewlink.

ewcc worked but it seems that I don't have os2.lib for ewlink. image

Where should this be? (Maybe tomorrow...)

Thank you.

tyama501 commented 4 weeks ago

Oh, there is basic. image

ghaerr commented 4 weeks ago

I needed to also modify WATCINCLUDE in ewcc and ewlink.

Ok, we can consider what might need to change with our compiler scripts once we get your and other programmer's installations working. This likely means that those changes need to reside in libc/watcom just like libc/watcom/watcom.model does.

ewcc worked but it seems that I don't have os2.lib for ewlink.

That is normal, there is no os2.lib since we don't want to incorrectly link with an OS/2 library. Instead, you will see that ewlink links with libc/libc.lib. I think that might want to be renamed perhaps to something like "wclib.lib".

Oh, there is basic.

Yes, that is the correct one. It is smaller because the math routines aren't included yet.

Here is my build script for basic:

ewcc basic.c
ewcc host.c
ewcc host-stubs.cj
ewlink basic.obj host.obj host-stubs.obj
tyama501 commented 3 weeks ago

Hello @ghaerr ,

Thank you. The basic (for the IBM) worked.

I will try to add fmemalloc system call as we talked in https://github.com/ghaerr/elks/pull/1912#issuecomment-2150346984

ghaerr commented 19 hours ago

Now that the capability to run multisegment large-model programs is working via #1924, the stage is set such that the OpenWatcom C compiler itself should be able to be compiled to run on ELKS, along with the ELKS C library. This should be possible since OWC builds a 16-bit MSDOS version when built from source.

Actually getting to that point will likely take some time, as the compilation for OWC (the entire toolchain) on my macOS system takes 45+ minutes, so much more needs to be learned about OWC internals to speed up the development process.

Given the many Intel 8086 architecture segment-oriented capabilities of OpenWatcom C, I believe it to be a superior choice for a self-hosted ELKS C compiler. I have to say, back in 2022 when @stevexyz first opened this issue, I didn't believe there'd be a suitable compiler for ELKS until @tyama501 mentioned the owtarget16 project and OWC in May! Thank you for everyone's comments.