Strip filename and line number info

29 views
Skip to first unread message

John McFarland

unread,
Nov 4, 2009, 1:22:48 PM11/4/09
to gg95
Is there a compiler flag that will remove all filename and line number
information from the compiled executable? The example program below
illustrates how at runtime, the filename and line number associated
with the error get written to the screen:

=====fprog.f90=======
PROGRAM fprog
INTEGER :: i, j
PRINT*, 'starting prog'
WRITE(*,'(F5.2,A5)') i, j
END PROGRAM fprog
==================

Output from running program:

starting prog
At line 4 of file fprog.f90 (Unit 6)
Traceback: not available, compile with -ftrace=frame or -ftrace=full
Fortran runtime error: Expected REAL for item 1 in formatted transfer,
got INTEGER
(F5.2,A5)
^

I have tried -s and -g0, but no luck, the source code info still gets
written.

Thanks.
John

Edouard

unread,
Nov 5, 2009, 2:09:22 AM11/5/09
to gg95
Strange, usually, people prefer to get useful information from the
compiler
when a run-time error occurs... (BTW, I can give you some compiler
vendor
whom error messages are very unclear ;-).

I think that the '-s' flag you used remove only the symbol names out
of the
executable file. '(F5.2,A5)' is not a symbol, it is a format string
and the
compiler must keep it embedded in the executable file.

Regards,
Édouard

Beliavsky

unread,
Nov 5, 2009, 8:15:59 AM11/5/09
to gg95
On Nov 5, 2:09 am, Edouard <Edouard.Ca...@irisa.fr> wrote:
> Strange, usually, people prefer to get useful information from the
> compiler
> when a run-time error occurs... (BTW, I can give you some compiler
> vendor
> whom error messages are very unclear ;-).

Sure, but in a program one distributes to others, one may want to
conceal such information -- even perhaps that the program is written
in the dreaded FORTRAN language .

John McFarland

unread,
Nov 5, 2009, 9:32:12 AM11/5/09
to gg95
The error messages are very useful for debugging, but I need a way to
turn them off when we distribute the software. In the rare(?) case of
a user experiencing a runtime error, it's unacceptable for our program
to write out source code filename (with full path in some cases!) and
line number information. We already have one case of a user getting
such an error message and then coming back to ask us "I can't find
the /full/path/to/source/code/file on my system, is it possible
something isn't installed as it should be?"

aeroguy

unread,
Dec 9, 2009, 10:45:56 AM12/9/09
to gg95
In Sun solaris and unix, you can use the optiom stripe
objectfilename to strip debug information from the program
> > in the dreaded FORTRAN language .- Hide quoted text -
>
> - Show quoted text -

John McFarland

unread,
Dec 14, 2009, 1:13:11 PM12/14/09
to gg95
I have experimented a little bit with the strip program, but haven't
gotten it to do what I need:

(a) try to strip the object file and then link it into an executable:
[crash_message]$ g95 -c fprog.f90
[crash_message]$ strip fprog.o
[crash_message]$ g95 fprog.o
/path/gcc-lib/i686-unknown-linux-gnu/4.0.3//libf95.a(main.o): In
function `main':
main.c:(.text+0x3d): undefined reference to `MAIN_'

(b) try to strip the executable:
[crash_message]$ g95 fprog.f90
[crash_message]$ strip a.out
[crash_message]$ a.out
starting prog
At line 10 of file fprog.f90 (Unit 6)
Traceback: not available, compile with -ftrace=frame or -ftrace=full
Fortran runtime error: Expected REAL for item 1 in formatted transfer,
got INTEGER
(F5.2,A5)

Maybe I'm not using strip correctly?

Thanks,
John
Reply all
Reply to author
Forward
0 new messages