-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support building with tcc compiler #63
Comments
Wow!, I'm a bit scared for this amount of changes in the core. This will require a lot of testing. Some questions:
Changes:
|
Thankfully, we're in the final stretch. The only change remaining after this one is kexec for linux!
The kernel stack is left where it was set at the start of the kernel. I didn't see a reason to relocate the stack.
Yes, tcc has a strange behavior of moving arguments into registers automatically, and in a strange order. Consider the following syscall:
Here is how tcc compiles this:
(Note the pointer to "/dev/console" appears as a zero in the instruction So, %0 is eax, %1 is ecx, %2 is edx, and %3 is ebx. I've changed the macro to the following:
I have made this change.
Sorry, this was a mistake. The change in SAVE_ALL was replacing pushal/popal with pusha/popa.
I was surprised by this as well. I had to look at the assembly to understand why tcc was having a problem but gcc was not. It turns out that gcc was either not using ebx or using it in a way that avoided problems but tcc uses ebx more often.
tcc uses memmove to copy structures. Wherever a structure is assigned to another structure tcc inserts a call to memmove. Normally, memmove is included in the executable by linking with libtcc. However, we compile with I have moved memmove to lib/strings.c
I have made this change. |
Nice, it has been a long road. You did a lot of changes to fit Fiwix into the live-bootstrap project. Congratulations.
Ah yes, I missed that, sorry. Now I thought, shouldn't be better to point kernel stack at
Yes, the comment will clear up things. Thanks.
Somehow this change is good and sanitizes the code. |
This shouldn't be necessary but there is no harm in doing so. You can see from this pseudocode that the stack register is decremented before the value is stored in memory: So, the first push will already go into 0xFFFC. |
This explains it is not necessary, indeed. |
Thank you very much. |
I'm reviewing the code and I think that when Fiwix is built by the tcc compiler, it will show something like this:
This is because the following line: Line 82 in 00974ef
is the same on each compiler, it just changes the constant I think that a best approach would be:
Thoughts? With this change we don't need to regenerate a new |
Yes, your suggested change looks better to me. |
I've checked that this change did not make any difference when compiling Fiwix using GCC. Please, check if all is also correct when using TCC. |
It works fine with tcc. |
Perfect! |
The live-bootstrap project must compile Fiwix with tcc because gcc is not available until much later.
Note that the tcc used to build Fiwix must be patched to handle the physical / virtual addresss scheme used by Fiwix.
With gcc, the address scheme is handled by a linker script but tcc does not support linker scripts.
In the forthcoming PR, documentation is provided in docs/tcc.txt which explains where to get tcc, how to patch it, and how to build Fiwix.
The following is an explanation of the various changes to support tcc.
Some of these changes are significant and so I am open to discussing better alternatives.
Makefile:
gcc
ortcc
compilerdrivers/block/ata.c:
fiwix.ld:
_start
instead ofstart
so I changed linker script to use_start
The _kstack section is not available, so I eliminate changing the kernel stack.
The kernel stack is kept at 0xF000 to 0x10000 as specified originally in setup_kernel.
I hestitated to remove all the _kstack related code but honestly, changing the kernel
stack does not appear to have an clear purpose and Fiwix appears to work fine without
doing that.
include/fiwix/asm.h:
include/fiwix/config.h:
kernel/boot.S:
pushal
. Both tcc and gcc recognizepusha
so that is used instead.kernel/init.c:
lib/printk.c
mm/memory.c
The text was updated successfully, but these errors were encountered: