GCC 4.0 & C++ ABI

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ineo

GCC 4.0 & C++ ABI

Post by ineo »

I guess most of you already know gcc 4.0 is released. Among the changes, the C++ ABI has been updated. For those interested in writing an OS using C++, this might be a great step forward. I have no time yet to read the enhancements, but I had some troubles with it in the past.
In the hope this will be more standard, less hacky...

INeo
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:GCC 4.0 & C++ ABI

Post by distantvoices »

according to some rants on OSNEWS, they've implemented some generalized optimization stuff based on the parsed tree structure of the program - is said to be much more like the program.

Gonna see, how performant and bug save this one is. It shouldn't do too much harm to give it a compile and test run.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
AR

Re:GCC 4.0 & C++ ABI

Post by AR »

I've already compiled a cross compiler for GCC 4.0.0, I had some minor problems during the build (needed to manually create symbolic links because the relative paths in the makefiles were wrong).

The optimizer is nuts as well, it broke my GDT code (It completely stripped the constructing code for the GDT load descriptor because it was only used as "&gdt" by the inline assembly...). The new optimizations look powerful but I don't recommend this version for kernel development if you want to use optimization [if you only intend to use -O0 or maybe -O1 then it should be fine], should be good for user space apps but watch out for what it does to inline assembly as well.

Code: Select all

__asm__ ("INVLPG (%0)" : : "g" (Address));
/* Got compiled into... */
INVLPG (-52(%esp))
/* ... which GAS chokes on */
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:GCC 4.0 & C++ ABI

Post by Pype.Clicker »

AR wrote: watch out for what it does to inline assembly as well.

Code: Select all

__asm__ ("INVLPG (%0)" : : "g" (Address));
/* Got compiled into... */
INVLPG (-52(%esp))
/* ... which GAS chokes on */
I'd dare to say it wasn't a very wise use of inline assembly... i mean, telling the compiler "put Address in whatever form you want" and then "use that form within a [reference]" ... at least you should have used "invlpg(%0)"::"r"(Address) or even "invlpg %0"::"m"(*(dword*)m)), which was once suggested by Can'tRememberWhomButThatMightBeTimTheGrey.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:GCC 4.0 & C++ ABI

Post by distantvoices »

Well .. sometimes one uses a hack and later on discovers a more elegant and nice method to do the same thing. :-)

I've also heard(read) rumors about gcc 4.0 having build issues in certain spots - which do not hinder it to compile&bind completely. I daresay the developers should give the thing a more proper testing phase ere they publish it as production ready.

re - TimTheGrey: where is he actually? bound in Military Service or just dropped OS Dev outta thin air?
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
AR

Re:GCC 4.0 & C++ ABI

Post by AR »

Thanks, I've been having difficulty getting a decent list of all the parameters for inline assembly. I still don't know how to get rid of the first problem without dummy code though.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:GCC 4.0 & C++ ABI

Post by Pype.Clicker »

you could try to make the assembly that uses "&gdt" volatile.
AR

Re:GCC 4.0 & C++ ABI

Post by AR »

That didn't work but you pointed me in the right direction, I made the variable itself volatile and it is now working properly.

Another thing as well, they've added a new error/warning:

Code: Select all

if(Mem = Memory::Physical::GetPage())
This refuses to build (using -Wall -Werror, didn't try without), it requires the internal part be wrapped in brackets:

Code: Select all

if( (Mem = Memory::Physical::GetPage()) )
This should help with those accidentally leaving out the second equals bugs.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:GCC 4.0 & C++ ABI

Post by Pype.Clicker »

AR wrote: This should help with those accidentally leaving out the second equals bugs.
That one has been there in -Wall for long time (iirc, i have it down to 2.95.3 !)
AR

Re:GCC 4.0 & C++ ABI

Post by AR »

I only found this now as it only just started complaining, I've been using -Wall -Werror on GCC-3.4.3 for ages and it never complained.
User avatar
Candy
Member
Member
Posts: 3883
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:GCC 4.0 & C++ ABI

Post by Candy »

That might've been in -pedantic or something, at least, I've had the message a few times in the past (long time ago, so 3.2 or 2.95.x).
Post Reply