[Insight-developers] gcc compilation flag conflict when profiling with gprof

gang song songgang97 at gmail.com
Mon Jul 25 16:54:34 EDT 2011


Hi,

I am trying to profile ITK codes using gprof in Linux, which needs to
add flag -pg in gcc compilation and linking. However, -pg conflicts
with -fomit-frame-pointer.  Here is what I added in ccmake:
CMAKE_CXX_FLAGS                  -pg
CMAKE_C_FLAGS                    -pg
CMAKE_EXE_LINKER_FLAGS           -pg


[ 44%] Building C object
Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/H5make_libsettings.dir/H5make_libsettings.c.o
gcc: -pg and -fomit-frame-pointer are incompatible
make[3]: *** [Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/H5make_libsettings.dir/H5make_libsettings.c.o]
Error 1
make[2]: *** [Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/H5make_libsettings.dir/all]
Error 2
make[1]: *** [Modules/Registration/Refactoring/test/CMakeFiles/ITK-RegistrationRefactoringTestDriver.dir/rule]
Error 2
make: *** [ITK-RegistrationRefactoringTestDriver] Error 2

-fomit-frame-pointer is used in
ITK/Modules/ThirdParty/HDF5/src/itkhdf5/CMakeLists.txt, line 361. ITK
compiles fine if removing it:

IF (CMAKE_COMPILER_IS_GNUCC)
#  SET (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS} -std=c99
-fomit-frame-pointer -finline-functions -fno-common")
SET (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS} -std=c99
-finline-functions -fno-common")
ENDIF (CMAKE_COMPILER_IS_GNUCC)


Is this a good way to make "-pg" flag working?


Thanks

-Gang


More information about the Insight-developers mailing list