Darryl Gove's blog

Monday May 19, 2008

Compiler forensics

If you need to find out which version of the compiler is installed use:

$ cc -V
cc: Sun C 5.9 SunOS_sparc 2007/05/03

I've not been able to find a table which maps the version numbers back to the product names. For the record this is Sun Studio 12.

A more interesting question is what compiler generated an executable.

$ mcs -p test.o
test.o:
acomp: Sun C 5.8 2005/10/13
as: Sun Compiler Common 11 2005/10/13

The test file was generated by Sun Studio 11.

Finally what flags were used to generate an executable. Use dwarfdump and grep for "command" for binaries generated with Sun Studio 12, or for C code compiled with Sun Studio 11.

$ dwarfdump test.o|grep command
                DW_AT_SUN_command_line       /opt/SUNWspro/prod/bin/cc -xtarget=generic64 -c  test.c      <   13>   DW_AT_SUN_command_line      DW_FORM_string

For older compilers use dumpstabs and grep for "CMD":

$ getr.o|grep CMD
   2:  .stabs "/export/home; /opt/SUNWspro/bin/../prod/bin/cc -c -O  getr.c",N_CMDLINE,0x0,0x0,0x0

Of course it's very unlikely that shipped binaries will contain information about compiler flags.

Comments:

Post a Comment:
Comments are closed for this entry.

Calendar

Search this blog

About

Solaris Application Programming

Book resources

The Developer's Edge

Book resources

OpenSPARC Internals

Book resources

Recent entries

Custom search

Tag cloud

book cmt communityone compiler cooltools cpu2006 dtrace gcc libraries linker openmp opensolaris opensparc optimisation optimization parallelisation parallelization performance performanceanalyzer programming solaris solarisapplicationprogramming sparc spec spot sunstudio t2 ultrasparc ultrasparct2 x86

Links

Webcasts

Articles

Presentations

Interesting docs

Navigation

Referers

Feeds