Osdev with MinGW
Osdev with MinGW
Hello,
i was using DJGPP for compiling my little kernel until now. But it is really slow and i want to use MinGW now. But i cant find any working example code with compilation instructions that works. I am experimenting the whole day now and nothing works. I get my own kernel compiled and linked, but it does not boot.
Maybe someone knows a tutorial or a sample code that uses MinGW as compiler instead of DJGPP ?
i was using DJGPP for compiling my little kernel until now. But it is really slow and i want to use MinGW now. But i cant find any working example code with compilation instructions that works. I am experimenting the whole day now and nothing works. I get my own kernel compiled and linked, but it does not boot.
Maybe someone knows a tutorial or a sample code that uses MinGW as compiler instead of DJGPP ?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Osdev with MinGW
there are several issues with MingW for osdev'ing. You should *really* consider using cygwin instead.
Re:Osdev with MinGW
well, i finally got it. i dont know why my linker had crashed with an assertion error, but now it works!
But now i want to do something... sick *g*
I Heard, that someone uses vc7 to compile his cpp files ans linkes them with MinGW (because the vc7 linker puts his whole ms stuff inside the binary)
Well i want to link vc7 .obj files with my binary. MinGW does really accept them, but all funktions of the obj stay unresolved.
Any idea how do get them linked together?
But now i want to do something... sick *g*
I Heard, that someone uses vc7 to compile his cpp files ans linkes them with MinGW (because the vc7 linker puts his whole ms stuff inside the binary)
Well i want to link vc7 .obj files with my binary. MinGW does really accept them, but all funktions of the obj stay unresolved.
Any idea how do get them linked together?
Re:Osdev with MinGW
Perica:
The issues i found out:
- you have to define __alloca and _main or MinGW will not link it.
- the linker crashes here, when i want to get the CTOR and DTOR list.
The issues i found out:
- you have to define __alloca and _main or MinGW will not link it.
- the linker crashes here, when i want to get the CTOR and DTOR list.
Re:Osdev with MinGW
>In a nutshell, what are the issues ?
MinGW is a 10+ megabyte download and, like CygWin, now requires a helper DLL (MSYS-1.0.DLL). So it's no longer "minimal".
MinGW 'make' uses 'sh' as the shell if it finds 'sh' on the path. This is the Wrong Thing. DJGPP 'make' works better: it looks at the SHELL and COMSPEC environment variables.
'strip' changes the file alignment. This will make a Multiboot-kludge kernel unbootable.
(GCC 2.95) "ld -r -d ..." doesn't get rid of all the common variables.
(GCC 2.95) BSS size is stored in the wrong location of the section header, so MinGW does not correctly interoperate with NASM.
"ld -Ttext=NNN ..." doesn't put the .text section at the correct address unless you also use the "--image-base=0" option.
Linker claims to support ELF, but says "PE operations on non PE file" if you try to use ELF.
I tip-toed around the bugs and got my kernel to build with MinGW: http://my.execpc.com/~geezer/os/index.htm#borealis
MinGW is a 10+ megabyte download and, like CygWin, now requires a helper DLL (MSYS-1.0.DLL). So it's no longer "minimal".
MinGW 'make' uses 'sh' as the shell if it finds 'sh' on the path. This is the Wrong Thing. DJGPP 'make' works better: it looks at the SHELL and COMSPEC environment variables.
'strip' changes the file alignment. This will make a Multiboot-kludge kernel unbootable.
(GCC 2.95) "ld -r -d ..." doesn't get rid of all the common variables.
(GCC 2.95) BSS size is stored in the wrong location of the section header, so MinGW does not correctly interoperate with NASM.
"ld -Ttext=NNN ..." doesn't put the .text section at the correct address unless you also use the "--image-base=0" option.
Linker claims to support ELF, but says "PE operations on non PE file" if you try to use ELF.
I tip-toed around the bugs and got my kernel to build with MinGW: http://my.execpc.com/~geezer/os/index.htm#borealis
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Osdev with MinGW
Not trying to be a necro or anything, but here's where MinGW's page on the wiki leads. I'm not sure if any of the reasons we give for MinGW not being a good choice in OSDev'ing is still true. We only mention antique versions of MinGW there and much has changed since. It's time to update. I'll check the current standard toolchain. What are your oppinions on MinGW?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Osdev with MinGW
Before I switched to a cross-compiler with Cygwin, I used MinGW and before that DJGPP. The reason I switched to DJGPP is that DJGPP wasn't too keen of my C++ code and I really wanted C++ with which MinGW seemed to perfectly agree . I had to do some strange changes though. I had to:
- Let NASM assemble my ASM files as ELF format.
- Tell the MinGW linker that I wanted x86 PE format files.
- Pass the ELF assembly files and the PE C++ object files to the linker together.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Osdev with MinGW
There's also a 4.3.0 binary for GCC in MinGW's download section so you can get that if you're too lazy to make a cross-compiler yourself.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Osdev with MinGW
both MinGW and Cygwin still target Windows and thus come with builtin stuff. A crosscompiler has no knowledge of the platform stuff and therefore it will be better (independent of mingw improvements).
Re: Re:Osdev with MinGW
I have produced my own gcc 3.2.3 build for Windows, and it is minimal (relying only on msvcrt.dll). It's a single executable - gccwin.exe and now written in pure C90 (so no fork() etc), and as such, you are required to do separate assembly and link steps yourself (ie just use a makefile - and I provide pdmake for that purpose too).Chris Giese wrote:>In a nutshell, what are the issues ?
MinGW is a 10+ megabyte download and, like CygWin, now requires a helper DLL (MSYS-1.0.DLL). So it's no longer "minimal".
I developed this for my own OS for a reason, and that reason may apply to others too - I want to run gccwin, plus my own msvcrt.dll, under my own Windows-compatible OS. For people who wish to produce "yet another Windows clone" instead of "yet another Posix OS".
The Wiki led to this thread for mingw and I'm wondering whether I should update the Wiki to mention the above alternative which is available from http://pdos.org
Any thoughts?
Re: Osdev with MinGW
So, fittingly for a necropost, you resurrected an old compiler. You do know the current version is GCC 10 or something, right?kerravon wrote:I have produced my own gcc 3.2.3 build for Windows,
Chaining together compiler, assembler, and linker is supposed to be the one job of a compiler driver. You have stripped out so much stuff from gcc that it ceases being useful.kerravon wrote: It's a single executable - gccwin.exe and now written in pure C90 (so no fork() etc), and as such, you are required to do separate assembly and link steps yourself (ie just use a makefile - and I provide pdmake for that purpose too).
Windows IS a POSIX OS, with the notable omission of fork(), but then, I am trying to build my own OS like Linux but all the BS removed, and it is not going to have fork(), either. In any case, Windows does have subprocesses and pipes, even if they work a little differently.kerravon wrote:For people who wish to produce "yet another Windows clone" instead of "yet another Posix OS".
In any case, you shouldn't necro. This thread is old enough to buy beer in Germany, and even the most recent resurrection is no longer allowed to bike on the sidewalk. Just make another topic.
Carpe diem!
Re: Osdev with MinGW
Sure, and the latest version isn't even written in C. Useless for me. I have enough trouble just supporting C90. When C90 is working to my satisfaction on all my environments, I'll maybe look at other languages.nullplan wrote:So, fittingly for a necropost, you resurrected an old compiler. You do know the current version is GCC 10 or something, right?kerravon wrote:I have produced my own gcc 3.2.3 build for Windows,
Says who? You can't do complicated stuff like that in C90. C90 exists for a reason. There are limits to what you can do on some environments. What system() does is "implementation defined". fork() doesn't exist at all.Chaining together compiler, assembler, and linker is supposed to be the one job of a compiler driver.kerravon wrote: It's a single executable - gccwin.exe and now written in pure C90 (so no fork() etc), and as such, you are required to do separate assembly and link steps yourself (ie just use a makefile - and I provide pdmake for that purpose too).
It is totally useful. It actually works on my OS. No other version does, and good luck trying to get another (more complex) version to work.You have stripped out so much stuff from gcc that it ceases being useful.
PDOS/386 doesn't have any of that, but it will run gccwin, a perfectly valid Windows executable that should work on everything from Win 95 on.Windows IS a POSIX OS, with the notable omission of fork(), but then, I am trying to build my own OS like Linux but all the BS removed, and it is not going to have fork(), either. In any case, Windows does have subprocesses and pipes, even if they work a little differently.kerravon wrote:For people who wish to produce "yet another Windows clone" instead of "yet another Posix OS".
If someone had updated the Wiki so that it doesn't point here for the "latest information", I wouldn't be here.In any case, you shouldn't necro. This thread is old enough to buy beer in Germany, and even the most recent resurrection is no longer allowed to bike on the sidewalk. Just make another topic.
Re: Osdev with MinGW
Everyone is someone.kerravon wrote:If someone had updated the Wiki so that it doesn't point here for the "latest information", I wouldn't be here.
Even you are someone.