General
cancel
Showing results for 
Search instead for 
Did you mean: 

gcc: need to understand the Makefile

Robinson W
Occasional Advisor

gcc: need to understand the Makefile

Hi,
Can anyone help me with this?

* gcc-4.2.3 is installed from the source code.

* Source dir:
/home/robin/gcc-4.2/binutils
/home/robin/gcc-4.2/gcc

* On configuration directory
/home/robin/gcc-4.2/gccobj
is generated which is root of all Makefiles.

* All object files created inside subfolders of gccobj.

* This is one of the makefile generated...
/home/robin/gcc-4.2/gccobj/gcc/Makefile

*Part of its code is...

CC = /home/robin/gcc-4.2/gccobj/./prev-gcc/xgcc -B/home/robin/gcc-4.2/gccobj/./prev-gcc/ -B/usr/local/ia64-hp-hpux11.23/bin/

.c.o:
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $< $(OUTPUT_OPTION)

??? please tell me what is the actual thing behind this. After creating a separate objfolder they created some sort of compiler xgcc. Why this is? And options like -B, -W, -I, -c, -o, etc. is used.
*** cc was used in one of the makefile.

??? Can I replace it with cc ? If so, how can I do it?

Kind Regards,
Robin
12 REPLIES
Safarali
Valued Contributor

Re: gcc: need to understand the Makefile

Hi Robin
You can compile your c programs
using with gcc

gcc program.c
it will give an a.out file

then you can move mv a.out program name

Regaqrds
Safar
Robinson W
Occasional Advisor

Re: gcc: need to understand the Makefile

* Actually my main aim is to achieve the object file using cc -c.

* CC = /home/robin/gcc-4.2/gccobj/./prev-gcc/xgcc -B/home/robin/gcc-4.2/gccobj/./prev-gcc/ -B/usr/local/ia64-hp-hpux11.23/bin/

In the above if I substitute /home/robin/gcc-4.2/gccobj/./prev-gcc/xgcc with cc, I get error that -B option is unknown. Is there a possible way that I can use cc.
Steven Schweda
Honored Contributor

Re: gcc: need to understand the Makefile

> ??? please tell me what is the actual thing
> behind this. [...]

Please tell me exactly what you did to build
GCC.

The normal procedure
("http://gcc.gnu.org/install/") is to
extract it, configure it, and "make" it using
commands like these (with various options
and adjustments possible):

cd xxx/gcc
bzip2 -dc gcc-4.3.0.tar.bz2 | gtar -xf -
mkdir gcc-4.3.0_obj
cd gcc-4.3.0_obj
../gcc-4.3.0/configure
gmake bootstrap-lean
gmake install

The builders use some existing C compiler
(default: gcc) to build an initial edition
("stage 1") of the new GCC compiler. If that
works, they use the stage 1 compiler to build
it all again, making "stage 2". If that
works, they use stage 2 to make "stage 3",
and compare stage 2 with stage 3. If those
editions match, they declare success.

> Why this is?

Isn't this all explained in the
documentation?

http://gcc.gnu.org/install/build.html

I haven't looked at the details, but I'd
assume that "xgcc" is one of those
intermediate compilers.

> *** cc was used in one of the makefile.

With some context, this comment might be
interesting. With no context, it's a waste of
bits.

> ??? Can I replace it with cc ? If so, how
> can I do it?

So, you wish to dive into the middle of the
three-stage GCC bootstrap build procedure,
and slip in a different compiler while it's
not looking? Why? (And why would you think
this a sound idea?)

Perhaps it would be useful to describe
exactly what you're doing, and exactly what
happens when you do it, rather than to pull
some stray command out of the middle of
someplace and start fiddling with it. The
GCC build procedure is long and complex, and
it's often imperfect, but it is a well
integrated whole, and poking around randomly
in its middle is seldom wise.
Robinson W
Occasional Advisor

Re: gcc: need to understand the Makefile

Thank u steven it was really helpfull.

* For some purpose I need to attach a tool with the compiler
i.e. $(tool) $(CC) -c source

* But the tool works only with HP C/aCC compiler i.e. CC = cc.

* The source code was from http://hpux.cs.utah.edu/hppd/hpux/Gnu/gcc-4.2.3/

* After extracting I get a folder gcc-4.2.3 inside which
1. folders binutils and gcc.
2. Files like installit, Makefile is present.

* Im familiar with gmake and gmake install. But here we just need to run ./installit and the script does this automatically(I cant even use --prefix option).

* On installation we get a folder gccobj and has mixed object files from both the source folders binutils and gcc I feel.

* This is taken from one of the manual named HPUX.Install. Im using HP-UX 11.23 on itanium server.
--------------------------------------------
This release of gcc requires an ANSI C compiler to build and hence
we have only tested this release with HP's optional ANSI C compilers on
PA-RISC and Itanium platforms. Note, however, that the Itanium "bundled" C
compiler (aka "cc_bundled") is actually ANSI C-compliant and can be used to
build gcc. The same is *not* true of the PA-RISC cc_bundled compiler - if you
only have that compiler, you will have to install the PA-RISC binary depot
of gcc instead of building the package yourself.

If you are using HP's ANSI C compiler to build gcc, please ensure it is
patched to the latest release - further information on this is available
here:

http://hpux.connect.org.uk/hppd/answers/4-4.html

In theory, it is possible to use an older (binary) version of HP-UX gcc
to build this release, but we have not done this ourselves and cannot help
if you have problems with such a build. It also creates a "chicken and egg"
situation (i.e. you'd need gcc to build gcc) that users starting from
scratch may find hard to solve.
--------------------------------------------
Steven Schweda
Honored Contributor

Re: gcc: need to understand the Makefile

> * For some purpose I need to attach a tool with the compiler
> i.e. $(tool) $(CC) -c source

I don't understand this.

> * But the tool works only with HP C/aCC compiler i.e. CC = cc.

Nor that.

If all you need is a C compiler which you can
run as "cc" (instead of "gcc"), than a link
(/usr/local/bin/cc -> gcc) and an appropriate
PATH should do the job.

> * The source code was from http://hpux.cs.utah.edu/hppd/hpux/Gnu/gcc-4.2.3/

I have not tried building GCC from one of
these modified source kits. On my 11.11
PA-RISC system, I started with one of the
binary kits, gcc-4.1.2-hppa-11.11.depot.
After installing that, I used it to build
gcc-4.2.1 and, later, 4.2.2 from unmodified
source kits, after also installing all the
prerequsites from _their_ source kits. My
notes suggest that I needed GNU "bison", GNU
"diff", and GNU "m4", and I needed to put
/usr/local/bin at the front of my PATH, so
that the builders would find the GNU
programs (like "diff") instead of the
standard HP-UX programs with the same names.

Also, there were problems in the Java builds,
so I cut back the configuration to avoid
those problems:

# langs='c,c++,objc,obj-c++,treelang'
# ../gcc-4.2.1/configure --enable-languages=$langs

After installing even more prerequsite kits
(GMP and MPFR), I built GCC 4.3.0 on that
system with no limitations or problems.

> Im using HP-UX 11.23 on itanium server.

On my IA64 11.31 system, I did roughly the
same things, starting with the binary depot
gcc-4.2.2-ia64-11.31.depot. My notes are
incomplete here, but I believe that after
that was installed, I built GCC 4.2.2 from
an unmodified source kit, again without
Java. An attempt to build GCC 4.3.0 from an
unmodified source kit on that system failed,
and I haven't looked into those problems.


Why are you trying to build GCC from source?
(I know why _I_ was doing it. Why were _you_
doing it?) What's wrong with using the
binary depot kit which is appropriate for
your system?

What, exactly, is the problem which you are
trying to solve? (The _first_ problem, that
is.)
Dennis Handly
Acclaimed Contributor

Re: gcc: need to understand the Makefile

>please tell me what is the actual thing behind this. ... they created some sort of compiler xgcc. Why this is?

As Steven says, it has to do with the bootstrap process.

>And options like -B, -W etc. is used.

gcc(1) -B says:
This option specifies where to find the executables, libraries and data files of the compiler itself.

>Can I replace it with cc? If so, how can I do it?

You would have to remove/translate any foreign devil options.

>* Actually my main aim is to achieve the object file using cc -c.

Any particular reason why? Because you know the performance of gcc compiled code is lots worse than the HP compiler?

>I get error that -B option is unknown. Is there a possible way that I can use cc?

Since -B tells it where to get the gcc pieces, this can just be removed.

>* For some purpose I need to attach a tool with the compiler i.e. $(tool) $(CC) -c source

What is the tool and why do you need to do it with the gcc sources?

>Steven:
> * For some purpose I need to attach a tool with the compiler
>>I don't understand this.

You have to take some things as a given. :-)

>> * But the tool works only with HP C/aCC compiler i.e. CC = cc.
>Nor that.

That too. It obviously means the tool only understands HP's cc options.

>Why are you trying to build GCC from source?
>What, exactly, is the problem which you are
trying to solve?

Exactly. All we know it has something to do with a "tool" but we don't know what the tool does.
Steven Schweda
Honored Contributor

Re: gcc: need to understand the Makefile

> [...] It obviously means [...]

I've said it before, and I'll say it again
(as needed): As Mr. Sumner advised Bunny in
"Desk Set", "Never assume."

The primary lesson of that movie, while
immensely valuable, does seem lost on some of
us.
Khushi
Occasional Visitor

Re: gcc: need to understand the Makefile

Sorry for my late reply, actually I want to run the tool cadvise on these source files and generate warnings from it. I have tried cadvise with gcc but it doesn't put the warnings in the database neither this compiler xgcc. It seems this tools works only with HP C/aCC. Im confused what to do?
Thanks to both of u for ur kind help.
Robinson W
Occasional Advisor

Re: gcc: need to understand the Makefile

hi,
Im extremely sorry by mistake I sent it through my fren's id.

Sorry for my late reply, actually I want to run the tool cadvise on these source files and generate warnings from it. I have tried cadvise with gcc but it doesn't put the warnings in the database neither this compiler xgcc. It seems this tools works only with HP C/aCC. Im confused what to do?
Thanks to both of u for ur kind help.
Dennis Handly
Acclaimed Contributor

Re: gcc: need to understand the Makefile

>I want to run the tool cadvise on these source files and generate warnings from it.

(Steven: That was one of the zebras I was thinking about. :-)
Any reason you want to do that? Isn't gcc perfect? :-)

>I have tried cadvise with gcc but it doesn't put the warnings in the database

It can only do that with the warnings (+wlint) from aCC6. Either from "cadvise report" on the make output, or from its own static analysis tool that cadvise runs.

>It seems this tools works only with HP C/aCC.

That's the current status.

>I'm confused what to do?

If you can "instrument" and configure gcc to build with HP's cc, you have a chance to use cadvise.

>Steven: I've said it before, and I'll say it again (as needed): As Mr. Sumner advised Bunny in "Desk Set", "Never assume."

You've never heard of immortal words "Trust but verify"? :-)
Shruti Doval (HP)
Occasional Visitor

Re: gcc: need to understand the Makefile

Hi,

The upcoming release of cadvise (C.02.05), in july, will provide support for using gcc/g++ with cadvise. We will let you know when the bits the available for download.

Regards,
Shruti
Shruti Doval (HP)
Occasional Visitor

Re: gcc: need to understand the Makefile

Hi Robin,

Sorry for not sending you a release notification before. Did you try the new version of cadvise with support for gcc? If not, you can download the same from www.hp.com/go/cadvise.

Regards,
Shruti