Bring in PGO (Profile Guided Optimization)
This enable PGO (Profile Guided Optimization) on Fedora >=41 and RHEL >= 9 for
non x86 machines.
This is a four step process:
1. We use the system clang compiler to build an instrumented version of LLVM.
The first build of LLVM is rather small because it only features the native
subset of targets to build (`LLVM_TARGETS_TO_BUILD=Native`) and no tests or
whatsoever is built.
2. We run a special `cmake` target (`generate-profdata`) that collects profile
data information. Eventually this information is also packaged as
`llvm-pgo.profdata`.
3. We feed the profile information into another final build of LLVM that gets
packaged later.
4. If we are on a platform that provides the `llvm-test-suite` package we run a
performance comparison of the system compiler against the PGOed compiler.
This is meant as a sanity check. We package the output of that comparison (if
available) as `results-system-vs-pgo.txt`. The criteria to run this
performance comparison is influenced by the `run_pgo_perf_comparison` global.
For snapshot builds we even run the comparison for RHEL platforms where
usually the `llvm-test-suite` is not available. There we provide it through
this COPR project:
[@fedora-llvm-team/llvm-test-suite](https://copr.fedorainfracloud.org/coprs/g/fedora-llvm-team/llvm-test-suite/).
We pass `--build-id=sha1` to lld when building final stage with PGO LLD uses
"fast" as the algortithm for generating build-id values while ld.bfd uses "sha1"
by default. We need to get lld to use the same algorithm or otherwise we end up
with errors like thise one:
```
build-id found in [...]/usr/lib64/llvm21/bin/llvm-debuginfod-find too small
```
NOTE: We decided to not do a bootstrap build of clang.
NOTE: To disable PGO change `%bcond_without pgo` to `%bcond_with pgo` in the one
line where it is conditionally defined. All the relevant changes are
build-condition fenced with `%if %{with pgo}`.