gcc: Cross-profiling

1 
1 10.5 Data File Relocation to Support Cross-Profiling
1 ====================================================
1 
1 Running the program will cause profile output to be generated.  For each
1 source file compiled with '-fprofile-arcs', an accompanying '.gcda' file
1 will be placed in the object file directory.  That implicitly requires
1 running the program on the same system as it was built or having the
1 same absolute directory structure on the target system.  The program
1 will try to create the needed directory structure, if it is not already
1 present.
1 
1  To support cross-profiling, a program compiled with '-fprofile-arcs'
1 can relocate the data files based on two environment variables:
1 
1    * GCOV_PREFIX contains the prefix to add to the absolute paths in the
1      object file.  Prefix can be absolute, or relative.  The default is
1      no prefix.
1 
1    * GCOV_PREFIX_STRIP indicates the how many initial directory names to
1      strip off the hardwired absolute paths.  Default value is 0.
1 
1      _Note:_ If GCOV_PREFIX_STRIP is set without GCOV_PREFIX is
1      undefined, then a relative path is made out of the hardwired
1      absolute paths.
1 
1  For example, if the object file '/user/build/foo.o' was built with
1 '-fprofile-arcs', the final executable will try to create the data file
1 '/user/build/foo.gcda' when running on the target system.  This will
1 fail if the corresponding directory does not exist and it is unable to
1 create it.  This can be overcome by, for example, setting the
1 environment as 'GCOV_PREFIX=/target/run' and 'GCOV_PREFIX_STRIP=1'.
1 Such a setting will name the data file '/target/run/build/foo.gcda'.
1 
1  You must move the data files to the expected directory tree in order to
1 use them for profile directed optimizations ('-fprofile-use'), or to use
1 the 'gcov' tool.
1