OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 1:31 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Osdev with MinGW
PostPosted: Mon Dec 13, 2004 11:12 am 
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 ?


Top
  
 
 Post subject: Re:Osdev with MinGW
PostPosted: Mon Dec 13, 2004 11:20 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
there are several issues with MingW for osdev'ing. You should *really* consider using cygwin instead.

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Osdev with MinGW
PostPosted: Mon Dec 13, 2004 12:01 pm 
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?


Top
  
 
 Post subject: Re:Osdev with MinGW
PostPosted: Tue Dec 14, 2004 12:11 am 
Offline
Member
Member

Joined: Sat Nov 25, 2006 12:50 am
Posts: 454
..


Last edited by Perica on Tue Dec 05, 2006 9:35 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re:Osdev with MinGW
PostPosted: Tue Dec 14, 2004 3:04 am 
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.


Top
  
 
 Post subject: Re:Osdev with MinGW
PostPosted: Fri Dec 17, 2004 10:22 pm 
>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


Top
  
 
 Post subject: Re: Osdev with MinGW
PostPosted: Sun Feb 08, 2009 1:07 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
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 ]


Top
 Profile  
 
 Post subject: Re: Osdev with MinGW
PostPosted: Sun Feb 08, 2009 4:57 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2008 2:34 pm
Posts: 548
Location: Belgium
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.

Strange as it may sound, it worked perfectly! Then I switched to a cross-compiler and set everything to ELF. You might also want to know that MinGW uses GCC 3.4.5 (?) which is a pretty old version since the latest GCC release is 4.3.3 (?) at the time of writing this post. Another reason to create a cross-compiler ;).

_________________
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.


Top
 Profile  
 
 Post subject: Re: Osdev with MinGW
PostPosted: Sun Feb 08, 2009 8:32 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
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 ]


Top
 Profile  
 
 Post subject: Re: Osdev with MinGW
PostPosted: Sun Feb 08, 2009 10:34 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
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).

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Re:Osdev with MinGW
PostPosted: Tue Nov 02, 2021 8:11 pm 
Offline
Member
Member

Joined: Fri Nov 17, 2006 5:26 am
Posts: 232
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 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).

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?


Top
 Profile  
 
 Post subject: Re: Osdev with MinGW
PostPosted: Tue Nov 02, 2021 10:36 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
kerravon wrote:
I have produced my own gcc 3.2.3 build for Windows,
So, fittingly for a necropost, you resurrected an old compiler. You do know the current version is GCC 10 or something, right?

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).
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:
For people who wish to produce "yet another Windows clone" instead of "yet another Posix OS".
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.

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!


Top
 Profile  
 
 Post subject: Re: Osdev with MinGW
PostPosted: Tue Nov 02, 2021 11:39 pm 
Offline
Member
Member

Joined: Fri Nov 17, 2006 5:26 am
Posts: 232
nullplan wrote:
kerravon wrote:
I have produced my own gcc 3.2.3 build for Windows,
So, fittingly for a necropost, you resurrected an old compiler. You do know the current version is GCC 10 or something, right?

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.

Quote:
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).
Chaining together compiler, assembler, and linker is supposed to be the one job of a compiler driver.

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.

Quote:
You have stripped out so much stuff from gcc that it ceases being useful.

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.

Quote:
kerravon wrote:
For people who wish to produce "yet another Windows clone" instead of "yet another Posix OS".
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.

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.

Quote:
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.

If someone had updated the Wiki so that it doesn't point here for the "latest information", I wouldn't be here.


Top
 Profile  
 
 Post subject: Re: Osdev with MinGW
PostPosted: Wed Nov 03, 2021 12:07 am 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
Is this you, bzt?

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: Osdev with MinGW
PostPosted: Wed Nov 03, 2021 3:17 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
kerravon wrote:
If someone had updated the Wiki so that it doesn't point here for the "latest information", I wouldn't be here.
Everyone is someone.

Even you are someone.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Kamal123, MichaelPetch and 63 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group