profiling support for i386-gnu specs file
>Submitter-Id: net
>Originator: Marcus Brinkmann
>Organization: To organize is to destroy.
>Confidential: no
>Synopsis: profiling support for i386-gnu specs file
>Severity: non-critical
>Priority: low
>Category: target
>Class: sw-bug
>Release: 3.0.2 (Debian) (Debian testing/unstable)
>Environment:
System: GNU/Hurd ulysses 2.4.0-test9 #1 Mon Okt 30 20:36:05 CET 2000 i686 unknown
Architecture: i686
host: i386-pc-gnu
build: i386-pc-gnu
target: i386-pc-gnu
configured with: ../src/configure -v --enable-languages=c,c++,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --with-cpp-install-dir=bin --enable-objc-gc i386-gnu
>Description:
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.
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
>How-To-Repeat:
>Fix:
--- specs.old Fri Dec 28 19:49:19 2001
+++ specs Fri Dec 28 19:49:15 2001
@@ -21,7 +21,7 @@
%{traditional|ftraditional|traditional-cpp:trad}cpp0
*cc1:
-%(cc1_cpu)
+%(cc1_cpu) %{profile:-p}
*cc1_options:
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*} %{g*} %{O*} %{W*} %{w} %{pedantic*} %{std*} %{ansi} %{traditional} %{v:-version} %{pg:-p} %{p} %{f*} %{Qn:-fno-ident} %{--help:--help} %{--target-help:--target-help} %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}} %{fsyntax-only:-o %j} %{-param*}
@@ -36,13 +36,13 @@
-m elf_i386 %{shared:-shared} %{!shared: %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /lib/ld.so}} %{static:-static}}
*lib:
-%{bsd:-lbsd-compat} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}
+%{bsd:-lbsd-compat} %{shared:-lc}%{!shared:%{profile:-lc_p}%{!profile:-lc}}
*libgcc:
%{shared-libgcc:-lgcc_s%M -lgcc}%{static-libgcc:-lgcc}%{!shared-libgcc:%{!static-libgcc:%{shared:-lgcc_s%M -lgcc}}}%{!shared-libgcc:%{!static-libgcc:%{!shared:-lgcc}}}
*startfile:
-%{!shared: %{!static: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} %{static:crt0.o%s}} crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
+%{!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:
Reply to: