binutils and gcc?

Programming, for all ages and all languages.
Post Reply
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

binutils and gcc?

Post by Sam111 »

I am curious I have looked at this http://www.gnu.org/software/binutils/

and this http://gcc.gnu.org/

And I know you have to rebuild both packages to make a cross compiler/linker ,...etc
Thats not my problem I can follow the instructions and do this fine.

My question is when I download or apt-get install gcc normally when I programmed in c/c++ ld was already their didn't have to download binutils as well.

This is confusing me since does ld come with gcc or binutils?

In theory if gcc is just a compiler suite all it can do is create object file format .o files
And not exe , bin , or any machine runnable files.

You would need binutils to link to get an executable... correct?

So I am confused about when downloading gcc how it has all the other stuff with it ld , objdump. ( am i some how indirectly downloading binutils when I download gcc and visa-versa)

Is this only because I downloaded/installed it using apt-get (some package dependency thing that I get binutils installed for free each time making me not aware of ever needing to install binutils)

Like if I was to wget just gcc or download and unzip just gcc could I then build it / use it without binutils if I just wanted to make .o files. Or when you ./configure , make gcc it won't let you build gcc with out binutils.

I am just shooting in the dark looking for the correct reason.

I am sure somebody here knows
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Re: binutils and gcc?

Post by JackScott »

Debian's (and pretty much all other Linux distributions as well) package management does indeed install Binutils as a dependency when you install GCC. The 'ld' program is a part of binutils.

When you run gcc to make a normal userspace executable ("gcc fred.c -o fred.exe") what gcc does is actually call the linker (ld) and assembler (gas) invisibly for you. You basically can't have a working C compiler without also having a working linker, assembler and runtime. Compiling kernels (freestanding mode) is a bit different, but not by much.
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: binutils and gcc?

Post by Sam111 »

Compiling kernels (freestanding mode) is a bit different, but not by much
I don't get what you mean by this?

Question
Are you saying if I downloaded just gcc and tried to ./configure , make it I would run into dependency issues. And I cann't build gcc with out binutils?

If that is true then why the heck would they separate the two into two different packages...if they are both need for a working compiler or application,...etc

I just don't follow their logic on that one.

Anyway if you cann't use gcc with out binutils being their.
Then how about if one just downloaded binutils and ./configure , made it could one do that without gcc. Or is that not possible either.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: binutils and gcc?

Post by Solar »

Sam111 wrote:Are you saying if I downloaded just gcc and tried to ./configure , make it I would run into dependency issues. And I cann't build gcc with out binutils?
That is correct. (On most platforms.)
If that is true then why the heck would they separate the two into two different packages...
Because that is how the GNU userspace works. To build GCC, you need a compiler, make, libgmp, libmpfr, libmpc, gettext (if you want a localized version)... those aren't handled by the GCC maintainers either.

The binutils package is concerned with object and executable file formats, processor architectures and the like. Whereas the GCC package is concerned with language frontends. It should be obvious how working on either requires very different skillsets.

On certain platforms, you would be using GCC with a native assembler / linker backend, i.e. you don't need binutils at all on those.

For >99% of all users, the dependency issue is handled transparently by the package manager (apt-get, in your case). Building the compiler from source is a special case, and thus you are expected to handle the special case... specially.
Then how about if one just downloaded binutils and ./configure , made it could one do that without gcc. Or is that not possible either.
Well, obviously you need some compiler to build binutils, but that need not be GCC.
Every good solution is obvious once you've found it.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: binutils and gcc?

Post by JamesM »

berkus wrote:JamesM can hold your hand on this question.
I can also ban you, but I'm not going to do either.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: binutils and gcc?

Post by JamesM »

berkus wrote:
JamesM wrote:
berkus wrote:JamesM can hold your hand on this question.
I can also ban you, but I'm not going to do either.
Because either wouldn't change anything.
Oh sorry, I thought we were just listing things that I could do.
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: binutils and gcc?

Post by Sam111 »

Well, obviously you need some compiler to build binutils, but that need not be GCC.
Thats not necessarily obvious since a person doesn't need a compiler necessarily to create a program.

They could in theory just use "as" the assembler and ld the linker.

as would create the .o files and ld would link them to an executable. (in this case everything is contend in binutils so I don't see any dependencies on gcc but I could be wrong)

I mean asm operating systems with no c/c++ or other programing language involved can be made obviously. (without using nasm and just using gas "as" I believe correct me if I am wrong)

So it stands to reason binutils can be used alone in theory .
But maybe I am wrong and you are right and their are some weird gcc package dependencies ?


I know gcc depends on binutils in using but it is not to clear if binutils depends on gcc in using.

If it is both ways then to use just the assemblier of binutils or any other program from binutils you would also have to have gcc. That seems like a **** design flaw. Don't get me wrong I am not saying the applications are shitty by no means (they are great applications) but for that one issue it kind of sucks/is tied down.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: binutils and gcc?

Post by Solar »

Sam111 wrote:
Well, obviously you need some compiler to build binutils, but that need not be GCC.
Thats not necessarily obvious since a person doesn't need a compiler necessarily to create a program.
From the over 1000 *.c source files in the binutils package it should be obvious that you need some kind of C compiler to build the package. As I wrote, that's not a dependency on GCC specifically, but simply one of the languages that binutils is implemented in. Since virtually every platform has a supporting C compiler, that's not much of a limitation.

If you download ready-built binaries from somewhere, you don't need the compiler, and yes, you could use binutils as stand-alone assembler / linker package. But to build binaries from C source, you need a C compiler, n'est pas?
Last edited by Solar on Mon Mar 19, 2012 2:23 pm, edited 3 times in total.
Every good solution is obvious once you've found it.
Rudster816
Member
Member
Posts: 141
Joined: Thu Jun 17, 2010 2:36 am

Re: binutils and gcc?

Post by Rudster816 »

Sam111 wrote:
Well, obviously you need some compiler to build binutils, but that need not be GCC.
Thats not necessarily obvious since a person doesn't need a compiler necessarily to create a program.

They could in theory just use "as" the assembler and ld the linker.

as would create the .o files and ld would link them to an executable. (in this case everything is contend in binutils so I don't see any dependencies on gcc but I could be wrong)

I mean asm operating systems with no c/c++ or other programing language involved can be made obviously. (without using nasm and just using gas "as" I believe correct me if I am wrong)

So it stands to reason binutils can be used alone in theory .
But maybe I am wrong and you are right and their are some weird gcc package dependencies ?


I know gcc depends on binutils in using but it is not to clear if binutils depends on gcc in using.

If it is both ways then to use just the assemblier of binutils or any other program from binutils you would also have to have gcc. That seems like a **** design flaw. Don't get me wrong I am not saying the applications are shitty by no means (they are great applications) but for that one issue it kind of sucks/is tied down.
You only need a C compiler to actually compile the binutils package unless your OS distro has a package for it. You don't need a C compiler to actually use binutils once you have the executables.
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: binutils and gcc?

Post by Sam111 »

From the over 1000 *.c source files in the binutils package it should be obvious that you need some kind of C compiler to build the package. As I wrote, that's not a dependency on GCC specifically, but simply one of the languages that binutils is implemented in. Since virtually every platform has a supporting C compiler, that's not much of a limitation
I got you all thanks.
And couldn't you use a C compiler that was not the gcc compiler to build binutils or does the c code have some gcc compiler specific code that you must compile with gcc to build binutils. (not completely standard c )

And go back for a second
If I downloaded gcc you cann't build gcc without binutils but once you build it , is it possible then to just use gcc and remove binutils. Because I think you could just set gcc to use another ld , as program without needing binutils at all in theory. Done that with microsofts visual studios linker/assembler in the past ... didn't have a need yet to do it for gcc though yet

So I guess binutils and gcc are only dependent on one another at build time not once they are already built or you download a pre-built copy.

Sorry if this is annoying just recapping.

Thanks I think I got it
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: binutils and gcc?

Post by Solar »

Sam111 wrote:Sorry if this is annoying just recapping.
More like talking to yourself... :?:
Every good solution is obvious once you've found it.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: binutils and gcc?

Post by piranha »

Sam111 wrote:And couldn't you use a C compiler that was not the gcc compiler to build binutils or does the c code have some gcc compiler specific code that you must compile with gcc to build binutils. (not completely standard c )
Solar wrote:As I wrote, that's not a dependency on GCC specifically
=D>
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Post Reply