Hook llvm-ar into the tools bootstrap
When building base, we use the system llvm-ar. This can cause issues when the LLVM IR bitcode has been modified (and the bitcode version number bumped) and we build static/shared libraries in base with LTO.
FreeBSD recently merged llvm 12.0.0 into base in 14-CURRENT. The LLVM IR bitcode spec and implementation was modified. clang had outputted object files that contained the newer bitcode. The system llvm-ar (which is at 11.0), naturally, didn't understand the new bitcode, causing a failure.
The way to solve this chicken-and-egg scenario is to include llvm-ar in the bootstrap-tools stage in buildworld
. As of the time of writing this bug report, I made a naive attempt at hooking llvm-ar into the bootstrap-tools. The attempt failed due to llvm-ar needing to pull in the full libllvm, rather than the libllvmminimal that the bootstrap-tools installs.
Right now, in 14-CURRENT, the system must be build with MK_LTOLIB disabled for the first build. The second build can re-enable MK_LTOLIB (since the updated system has the new version of llvm-ar).