compiler that just does "compiling"... nothing more...

Programming, for all ages and all languages.
Post Reply
Cemre
Member
Member
Posts: 31
Joined: Fri Nov 09, 2007 5:25 am

compiler that just does "compiling"... nothing more...

Post by Cemre »

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.
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: compiler that just does "compiling"... nothing more...

Post by suthers »

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
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: compiler that just does "compiling"... nothing more...

Post by JamesM »

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.
Cemre
Member
Member
Posts: 31
Joined: Fri Nov 09, 2007 5:25 am

Re: compiler that just does "compiling"... nothing more...

Post by Cemre »

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.
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Re: compiler that just does "compiling"... nothing more...

Post by JackScott »

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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: compiler that just does "compiling"... nothing more...

Post by JamesM »

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.
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

Re: compiler that just does "compiling"... nothing more...

Post by iammisc »

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?
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: compiler that just does "compiling"... nothing more...

Post by suthers »

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
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Re: compiler that just does "compiling"... nothing more...

Post by JackScott »

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.
niteice
Member
Member
Posts: 59
Joined: Tue Oct 03, 2006 3:49 pm

Re: compiler that just does "compiling"... nothing more...

Post by niteice »

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

Re: compiler that just does "compiling"... nothing more...

Post by Cemre »

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... :)
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Re: compiler that just does "compiling"... nothing more...

Post by Alboin »

Totally wasn't paying attention to this thread, but once reading it, Nwcc comes to mind.
C8H10N4O2 | #446691 | Trust the nodes.
Cemre
Member
Member
Posts: 31
Joined: Fri Nov 09, 2007 5:25 am

Re: compiler that just does "compiling"... nothing more...

Post by Cemre »

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"
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: compiler that just does "compiling"... nothing more...

Post by Brynet-Inc »

Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
AndrewAPrice
Member
Member
Posts: 2300
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: compiler that just does "compiling"... nothing more...

Post by AndrewAPrice »

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.
Post Reply