Reputation: 4052
I've compiled PGO-instrumented build from A/src and collected the profile. Now I want to apply this profile when building from B/src. Is this possible? GCC complains about the lack of profile since absolute paths are different, but otherwise the code is exactly the same.
Upvotes: 1
Views: 487
Reputation: 50205
See the docs on -fprofile-prefix-path
:
-fprofile-prefix-path=path
This option can be used in combination with profile-generate=profile_dir and profile-use=profile_dir to inform GCC where is the base directory of built source tree. By default profile_dir will contain files with mangled absolute paths of all object files in the built project. This is not desirable when directory used to build the instrumented binary differs from the directory used to build the binary optimized with profile feedback because the profile data will not be found during the optimized build. In such setups -fprofile-prefix-path=path with path pointing to the base directory of the build can be used to strip the irrelevant part of the path and keep all file names relative to the main build directory.
So when building from A/
, set the prefix path to A/
, and likewise for B/
.
Upvotes: 1