I am yet to try this (will do later), but having built a cross-compiler for my OS, I think this solution will work for cross-compiling from Linux to KolibriOS.
We basically follows this tutorial:
http://wiki.osdev.org/OS_Specific_Toolchain
Replacing "myos" with "kolibri".
In the kolibri.h file (gcc/config/kolibri.h) we set STARTFILE_SPEC to "kolibri_head.o" and LINK_SPEC to "-T /kolibri/lib/kolibri.ld".
kolibri_head.o would be an ELF file containing a section called ".kolibri_head", which would contain the standard KolibriOS executable header, plus a starting point that would call main() and then exit.
The sysroot would be /kolibri. /kolibri/lib/kolibri.ld would be a linker script which links to a flat binary, placing the .kolibri_head section first, following by .text, .rodata, .data and .bss.
The result would be an "i586-kolibri-gcc" which can directly compile a C program to KolibriOS binary format.
Has anyone tried this? If not, I shall set that up later. According to the wiki, getting a cross-compiler was one of the goal for google summer of code 2016.
Complete kolibri gcc cross-compiler
Hello maruiszp,
I think you have the barebone basics correct regarding the path you should take for constructing a cross compiler.
I've already built an ELF32 version of the executable. As I have some other tasks to deal with at the moment (like C layer etc), maybe it would save you some time to continue the work I have already done.
The cross compiler I wrote was based on the latest binutils/GCC combination I could find to be working at the time I wrote it (about a month ago, so pretty recent I believe).
I was writing a tutorial / HOWTO on how to get a cross compiler built for kolibrios, so maybe it might help you.
PS - Are you a prospective student who wants to apply for GSoC 2016? (Just curious)
I think you have the barebone basics correct regarding the path you should take for constructing a cross compiler.
I've already built an ELF32 version of the executable. As I have some other tasks to deal with at the moment (like C layer etc), maybe it would save you some time to continue the work I have already done.
The cross compiler I wrote was based on the latest binutils/GCC combination I could find to be working at the time I wrote it (about a month ago, so pretty recent I believe).
I was writing a tutorial / HOWTO on how to get a cross compiler built for kolibrios, so maybe it might help you.
PS - Are you a prospective student who wants to apply for GSoC 2016? (Just curious)
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!
I am currently a UK college student (18), and I wasn't thinking of applying to GSoC.ashmew2 wrote:Hello maruiszp,
I think you have the barebone basics correct regarding the path you should take for constructing a cross compiler.
I've already built an ELF32 version of the executable. As I have some other tasks to deal with at the moment (like C layer etc), maybe it would save you some time to continue the work I have already done.
The cross compiler I wrote was based on the latest binutils/GCC combination I could find to be working at the time I wrote it (about a month ago, so pretty recent I believe).
I was writing a tutorial / HOWTO on how to get a cross compiler built for kolibrios, so maybe it might help you.
PS - Are you a prospective student who wants to apply for GSoC 2016? (Just curious)
Do you have a link to the tutorial you mentioned?
I am currently working on my own hobby OS but I can contribute my code to KolibriOS too.
Hello!
To clarify what I said earlier, it is not exactly a tutorial , but more of an experience about what I went through.
You probably know all of this if you have your own hobby OS, but here it goes...If not you, I hope this helps someone..
Please check the attached files to this post.
As far as newlib is concerned, I was looking into porting it, but a port is already available on kolibriOS SVN tree inside contrib/ . I think i will contribute to this port rather than create a new one. I think it would be a sane choice for you (or anyone else..) as well in case you want to hack around with newlib.
If you have any criticism or views on the diff / instructions , let me know . I'll be glad to improve it so it is helpful for someone else / myself.
DISCLAIMER: This was the first cross compiler I tried to build, so you might find some options are a complete mess or stuff that probably shouldn't even be there..but then, you wouldn't know until you try.
DISCLAIMER2: Currently, it does not create kolibri Executables..but only regular ELF32 executables that can be worked with some linker magic. But please note that the preferred format is PE instead of ELF32 (Currently)
Regards,
ashmew2
To clarify what I said earlier, it is not exactly a tutorial , but more of an experience about what I went through.
You probably know all of this if you have your own hobby OS, but here it goes...If not you, I hope this helps someone..
Please check the attached files to this post.
As far as newlib is concerned, I was looking into porting it, but a port is already available on kolibriOS SVN tree inside contrib/ . I think i will contribute to this port rather than create a new one. I think it would be a sane choice for you (or anyone else..) as well in case you want to hack around with newlib.
If you have any criticism or views on the diff / instructions , let me know . I'll be glad to improve it so it is helpful for someone else / myself.
DISCLAIMER: This was the first cross compiler I tried to build, so you might find some options are a complete mess or stuff that probably shouldn't even be there..but then, you wouldn't know until you try.
DISCLAIMER2: Currently, it does not create kolibri Executables..but only regular ELF32 executables that can be worked with some linker magic. But please note that the preferred format is PE instead of ELF32 (Currently)
Regards,
ashmew2
- Attachments
-
-
binutils-diff.diff (3.65 KiB)Downloaded 253 times
-
gcc-diff.diff (544 Bytes)Downloaded 255 times
-
kolibri_INSTRUCTIONS (2.99 KiB)Downloaded 259 times
-
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!
It looks like your GCC patch does not inlcude a config/gcc/kolibri.h file. Did you add one?
I can probably get the cross-compiler to output Kolibri executables directly if that helps.
I can probably get the cross-compiler to output Kolibri executables directly if that helps.
Ah, I missed the kolibri.h file. Please find it attached to this post.mariuszp wrote:It looks like your GCC patch does not inlcude a config/gcc/kolibri.h file. Did you add one?
I can probably get the cross-compiler to output Kolibri executables directly if that helps.
It was added to this location: ./gcc-5.2.0/gcc/config/kolibri.h .
You will add support to build kolibri executables directly? That's great. By all means, feel free to hack this cross compiler and make it better.
In case you decide to share your work with me (or you are welcome to do it yourself), I'd be glad to push this to the SVN trunk and use it in my projects as well.
Regards.
Hello, I have attached a modified version of "kolibri.h" as well as some support files. kolibri_head.o goes into your kolibri sysroot lib directory (sorry, I wrote it in NASM assembly; translation, if necessary, should be trivial, it's literally just the Kolibri executable header with some placeholders that the linker will resolve). kolibri.ld goes into /usr/lib/ (I couldn't figure out how to put it in the kolibri sysroot) [as specified in kolibri.h]. I did not have to try this yet. If you have time, please try this out and tell me how it goes, I can fix any bugs. I'll try myself either today or tomorrow.
- Attachments
-
-
kolibri.zip (1.69 KiB)Downloaded 256 times
-
Did you get around to trying this yet? Does it work?mariuszp wrote:Hello, I have attached a modified version of "kolibri.h" as well as some support files. kolibri_head.o goes into your kolibri sysroot lib directory (sorry, I wrote it in NASM assembly; translation, if necessary, should be trivial, it's literally just the Kolibri executable header with some placeholders that the linker will resolve). kolibri.ld goes into /usr/lib/ (I couldn't figure out how to put it in the kolibri sysroot) [as specified in kolibri.h]. I did not have to try this yet. If you have time, please try this out and tell me how it goes, I can fix any bugs. I'll try myself either today or tomorrow.
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!
The binutils patch you provided fails to build "eelf_i386_kolibri.o".
It will probably be easier if you try my additions to your already-existing build.
It will probably be easier if you try my additions to your already-existing build.
Who is online
Users browsing this forum: No registered users and 2 guests