OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 2:41 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: compiler that just does "compiling"... nothing more...
PostPosted: Wed Jun 25, 2008 3:51 am 
Offline
Member
Member

Joined: Fri Nov 09, 2007 5:25 am
Posts: 31
Hello,

that might not be a totally osdev question but I couldn't find the answer on net.

I want to build a compiler ( gcc ) that just does "compiling" i.e. it takes a ( already preprocessed ) source file and produces assembly code for it. nothing more, no assembling, no objects, no linking, no external libraries, no calling of external programs etc... I read the "building cross gcc" tutorial on wiki but no answer there too... How can I ( or can I ) build gcc without binutils? I will use the gcc only with "-S" option ( produce asm code ) if gcc can't do this, can another open source c++ compiler do it?

Thanks, best regards.


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Wed Jun 25, 2008 5:28 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 20, 2007 3:00 pm
Posts: 672
Location: London UK
You should have put this is the general programming Forum.
-S in the gcc command line, will make it only output assembly, but I have no idea how to remove preprocessing
Jules


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Wed Jun 25, 2008 5:41 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
As mentioned, -S. There's no need to remove preprocessing because if you've already preprocessed the file, there will be no preprocessor instructions left in it.

Wrong forum.

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Wed Jun 25, 2008 6:08 am 
Offline
Member
Member

Joined: Fri Nov 09, 2007 5:25 am
Posts: 31
ok... May be i couldn't tell exactly what i need... I know about the "-S" option as I mentioned.

My OS currently has a minimal ( almost no ) filesystem support. I simulate standard C files ( stdin and stdout ) to memory, so programs are not able to call and execute an external program like gcc. gcc tries to call "cpp (preprocessor)" "as" and "ld". I want to "build" a gcc that only takes an input from stdin and produces the assembly code to stdout. My question is: how can I configure gcc so that it will not include any code which will try to call an external program. How can I exclude this unneeded part of gcc from build?

For the "wrong forum" thing; can an admin move this thread to the appropriate forum?

Thanks, Best regards.


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Wed Jun 25, 2008 6:12 am 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 3:03 am
Posts: 1029
Location: Hobart, Australia
I very much doubt you would find an off the shelf way to do this, it's not a common thing to want to do. The place to start looking would be the help file to ./configure. If there isn't an option in there (and I doubt there will be), then it's time to go off and start hacking the sources. At that stage, you'd want to pick a simple compiler... GCC isn't the most friendly thing, with all it's backends.

_________________
My Personal Blog | My Software Company - Loop Foundry | My Github Page


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Wed Jun 25, 2008 9:00 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
There isn't an off-the-shelf way to do it. You'd have to manually run cc1 and collect2, and who knows what cans of worms that will uncover.

All in all, getting a compiler like GCC to run without the proper runtime support is a losing game. Implement a filesystem.

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Thu Jun 26, 2008 3:35 pm 
Offline
Member
Member

Joined: Thu Nov 09, 2006 6:23 pm
Posts: 269
What's the point of a C compiler if there is no filesystem and no way of running programs from a filesystem? Are you going to actually type a program in and then just hope that there are no mistakes?


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Thu Jun 26, 2008 3:43 pm 
Offline
Member
Member
User avatar

Joined: Tue Feb 20, 2007 3:00 pm
Posts: 672
Location: London UK
iammisc wrote:
What's the point of a C compiler if there is no filesystem and no way of running programs from a filesystem? Are you going to actually type a program in and then just hope that there are no mistakes?

200,000 lines of code, the most complex God knows what known to man...
*Power failure* :twisted: :lol:
jules


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Fri Jun 27, 2008 2:31 am 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 3:03 am
Posts: 1029
Location: Hobart, Australia
It's a bit like going back to the times when they used punch cards... just hoping that the huge program you've written all at once works.

_________________
My Personal Blog | My Software Company - Loop Foundry | My Github Page


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Fri Jun 27, 2008 11:07 am 
Offline
Member
Member

Joined: Tue Oct 03, 2006 3:49 pm
Posts: 59
If you're targeting i386 or ARM, there's tcc, which includes a C preprocessor, compiler, assembler and linker all in one binary.


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Fri Jun 27, 2008 12:42 pm 
Offline
Member
Member

Joined: Fri Nov 09, 2007 5:25 am
Posts: 31
niteice wrote:
If you're targeting i386 or ARM, there's tcc, which includes a C preprocessor, compiler, assembler and linker all in one binary.

Thank you :D very much... this link ( tinycc ) is very helpful... :)


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Fri Jun 27, 2008 2:09 pm 
Offline
Member
Member
User avatar

Joined: Thu Jan 04, 2007 3:29 pm
Posts: 1466
Location: Noricum and Pannonia
Totally wasn't paying attention to this thread, but once reading it, Nwcc comes to mind.

_________________
C8H10N4O2 | #446691 | Trust the nodes.


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Fri Jun 27, 2008 3:03 pm 
Offline
Member
Member

Joined: Fri Nov 09, 2007 5:25 am
Posts: 31
Alboin wrote:
Totally wasn't paying attention to this thread, but once reading it, Nwcc comes to mind.
niteice wrote:
If you're targeting i386 or ARM, there's tcc, which includes a C preprocessor, compiler, assembler and linker all in one binary.

Thank you both :) both links are really helpful... :D
Both links are really close to what i want: "compiler that just produces asm code from c,c++ code"


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Fri Jun 27, 2008 3:10 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 9:29 pm
Posts: 2426
Location: Canada
tcc? nwcc? how about pcc or tack? 8)

http://pcc.ludd.ltu.se/
http://tack.sourceforge.net/

_________________
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.


Top
 Profile  
 
 Post subject: Re: compiler that just does "compiling"... nothing more...
PostPosted: Wed Jul 30, 2008 8:13 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
Cemre wrote:
Thank you both :) both links are really helpful... :D
Both links are really close to what i want: "compiler that just produces asm code from c,c++ code"


Virtually every compiler has a switch that only outputs assembly code. That's how I compile things for my console since I use my own tool for assembling and linking.

_________________
My OS is Perception.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 158 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