This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

profiling support for i386-gnu specs file


Hi,

I fixed the Hurd specs file to support profiling (which was broken for
statically linked programs).  The specs file I successfully used is
attached, an analysis of what it does (or should do) is in the table below.
The only relevant part of the specs file (the only parts which I changed)
are "cc1" and "startfile".

The Hurd has the i386-gnu architecture.

Thanks,
Marcus

To profile the program only:
$ gcc -o main main.c -pg 
$ ./main
$ gprof main gmon.out

To profile the program and the C library:
$ gcc -o main main.c -profile
$ ./main
$ gprof main gmon.out

The specs file implement the following option combinations:
Notes: -shared overrides (and prevents) profiling options at the linking stage
       -profile forces to link the profiling C library statically
       -pg/-p does link to the normal C library (dynamically or statically)

The cc1 option -p is added for all of -p/-pg/-profile (for the first
two automatically, for the third there is a rule in the specs file).

static	shared	pg	p	profile	=>lib
Y/N	N	Y/N	Y/N	N	-lc
N	Y	Y/N	Y/N	Y/N	-lc

Y/N	N	Y/N	Y/N	Y	-lc_p

static	shared	pg	p	profile	=>startfile
N	N	N	N	N	crt1.o crti.o crtbegin.o
Y	N	N	N	N	crt0.o crti.o crtbegin.o
N	Y	Y/N	Y/N	Y/N	crti.o crtbeginS.o

N	N	Y/N	Y/N	Y	gcrt0.o crti.o crtbegin.o
Y	N	Y/N	Y/N	Y/N	gcrt0.o crti.o crtbegin.o
                ^^^^^^^^^^^^^^^^^^^ at least one Y

N	N	Y/N	Y/N	N	gcrt1.o crti.o crtbegin.o
                ^^^^^^^^^^^ at least one Y

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de
*asm:
%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}

*asm_final:
%|

*cpp:
%(cpp_cpu)   %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__}   %{posix:-D_POSIX_SOURCE} %{bsd:-D_BSD_SOURCE}

*cc1:
%(cc1_cpu) %{profile:-p}

*cc1plus:


*endfile:
%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s

*link:
-m elf_i386 %{shared:-shared}   %{!shared:     %{!static:       %{rdynamic:-export-dynamic}       %{!dynamic-linker:-dynamic-linker /lib/ld.so}}     %{static:-static}}

*lib:
%{bsd:-lbsd-compat} %{shared:-lc}%{!shared:%{profile:-lc_p}%{!profile:-lc}}

*libgcc:
-lgcc

*startfile:
%{!shared: %{!static: %{profile:gcrt0.o%s} %{!profile:%{pg:gcrt1.o%s}%{!pg:%{p:gcrt1.o%s}%{!p:crt1.o%s}}}}    %{static:  %{profile:gcrt0.o%s} %{!profile:%{pg:gcrt0.o%s}%{!pg:%{p:gcrt0.o%s}%{!p:crt0.o%s}}}}} crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}

*switches_need_spaces:


*signed_char:
%{funsigned-char:-D__CHAR_UNSIGNED__}

*predefines:
-D__ELF__ -D__i386__ -DMACH -Asystem(mach)   -Dunix -Asystem(unix) -Asystem(posix) -D__GNU__ -Asystem(gnu)

*cross_compile:
0

*version:
2.95.2

*multilib:
. ;

*multilib_defaults:


*multilib_extra:


*multilib_matches:


*linker:
collect2

*cpp_486:
%{!ansi:-Di486} -D__i486 -D__i486__

*cpp_586:
%{!ansi:-Di586 -Dpentium} 	-D__i586 -D__i586__ -D__pentium -D__pentium__

*cpp_k6:
%{!ansi:-Di586 -Dk6} 	-D__i586 -D__i586__ -D__k6 -D__k6__

*cpp_686:
%{!ansi:-Di686 -Dpentiumpro} 	-D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__

*cpp_cpu_default:


*cpp_cpu:
-Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__ %{mcpu=i486:%(cpp_486)} %{m486:%(cpp_486)} %{mpentium:%(cpp_586)} %{mcpu=pentium:%(cpp_586)} %{mpentiumpro:%(cpp_686)} %{mcpu=pentiumpro:%(cpp_686)} %{mcpu=k6:%(cpp_k6)} %{!mcpu*:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}}

*cc1_cpu:
%{!mcpu*: %{m386:-mcpu=i386 -march=i386} %{m486:-mcpu=i486 -march=i486} %{mpentium:-mcpu=pentium} %{mpentiumpro:-mcpu=pentiumpro}}

*link_command:
%{!fsyntax-only:  %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} 			%{r} %{s} %{t} %{u*} %{x} %{z} %{Z}			%{!A:%{!nostdlib:%{!nostartfiles:%S}}}			%{static:} %{L*} %D %o			%{!nostdlib:%{!nodefaultlibs:%G %L %G}}			%{!A:%{!nostdlib:%{!nostartfiles:%E}}}			%{T*}			
 }}}}}}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]