lto: Rebuild saved parallel LTRANS outputs

Parallel LTRANS emits make targets without prerequisites.  With
-save-temps, a later link can select the same output name.  Make then
accepts the old object as current.  Profile generation followed by
profile use can therefore link an instrumented LTRANS object without
libgcov.

Mark each persistent non-cache LTRANS output as phony in the generated
makefile.  Make then runs its recipe for the current link.  Temporary
outputs and LTRANS cache entries keep their current behavior.

Add a tree-profile test that forces parallel LTRANS with -flto=2 and
reuses the saved output name between profile generation and profile use.

The test reproduced the stale object failure on x86_64 before the change
and passed after it.  On AArch64, this test and the six affected LTO
profile tests passed in both PGO and AutoFDO modes.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

	* lto-wrapper.cc (run_gcc): Make saved parallel LTRANS outputs phony.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-prof/lto-save-temps-profile-use.c: New test.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
2 files changed