Board.KolibriOS.org

Официальный форум KolibriOS
Текущее время: Пт ноя 24, 2017 11:24 pm

Часовой пояс: UTC+03:00




Начать новую тему  Ответить на тему  [ 9 сообщений ] 
Автор Сообщение
 Заголовок сообщения: Complete kolibri gcc cross-compiler
СообщениеДобавлено: Ср фев 17, 2016 4:58 pm 
Не в сети

Зарегистрирован: Вт дек 06, 2011 7:24 pm
Сообщения: 11
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.


Вернуться к началу
 Заголовок сообщения: Re: Complete kolibri gcc cross-compiler
СообщениеДобавлено: Чт фев 18, 2016 4:41 pm 
Не в сети
Mentor

Зарегистрирован: Вт мар 11, 2014 11:37 am
Сообщения: 183
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)

_________________
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!


Вернуться к началу
 Заголовок сообщения: Re: Complete kolibri gcc cross-compiler
СообщениеДобавлено: Чт фев 18, 2016 5:35 pm 
Не в сети

Зарегистрирован: Вт дек 06, 2011 7:24 pm
Сообщения: 11
ashmew2 писал(а):
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 am currently a UK college student (18), and I wasn't thinking of applying to GSoC.

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.


Вернуться к началу
 Заголовок сообщения: Re: Complete kolibri gcc cross-compiler
СообщениеДобавлено: Чт фев 18, 2016 7:14 pm 
Не в сети
Mentor

Зарегистрирован: Вт мар 11, 2014 11:37 am
Сообщения: 183
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


Вложения:
binutils-diff.diff [3.65 КБ]
50 скачиваний
gcc-diff.diff [544 байт]
50 скачиваний
kolibri_INSTRUCTIONS [2.99 КБ]
53 скачивания

_________________
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!
Вернуться к началу
 Заголовок сообщения: Re: Complete kolibri gcc cross-compiler
СообщениеДобавлено: Чт фев 18, 2016 9:02 pm 
Не в сети

Зарегистрирован: Вт дек 06, 2011 7:24 pm
Сообщения: 11
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.


Вернуться к началу
 Заголовок сообщения: Re: Complete kolibri gcc cross-compiler
СообщениеДобавлено: Пт фев 19, 2016 5:52 pm 
Не в сети
Mentor

Зарегистрирован: Вт мар 11, 2014 11:37 am
Сообщения: 183
mariuszp писал(а):
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.


Ah, I missed the kolibri.h file. Please find it attached to this post.
It was added to this location: ./gcc-5.2.0/gcc/config/kolibri.h .

You will add support to build kolibri executables directly? :D 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.


Вложения:
kolibri.h [763 байт]
43 скачивания

_________________
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!
Вернуться к началу
 Заголовок сообщения: Re: Complete kolibri gcc cross-compiler
СообщениеДобавлено: Сб фев 20, 2016 10:50 pm 
Не в сети

Зарегистрирован: Вт дек 06, 2011 7:24 pm
Сообщения: 11
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.


Вложения:
kolibri.zip [1.69 КБ]
53 скачивания
Вернуться к началу
 Заголовок сообщения: Re: Complete kolibri gcc cross-compiler
СообщениеДобавлено: Вс фев 28, 2016 11:53 am 
Не в сети
Mentor

Зарегистрирован: Вт мар 11, 2014 11:37 am
Сообщения: 183
mariuszp писал(а):
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.


Did you get around to trying this yet? Does it work?

_________________
---
Check out the Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!


Вернуться к началу
 Заголовок сообщения: Re: Complete kolibri gcc cross-compiler
СообщениеДобавлено: Чт мар 03, 2016 8:35 pm 
Не в сети

Зарегистрирован: Вт дек 06, 2011 7:24 pm
Сообщения: 11
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.


Вернуться к началу
Показать сообщения за:  Поле сортировки  
Начать новую тему  Ответить на тему  [ 9 сообщений ] 

Часовой пояс: UTC+03:00


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 3 гостя


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
cron
Создано на основе phpBB® Forum Software © phpBB Limited
Русская поддержка phpBB