[libclc] Split off library build system into helpers (#15914)
This splits off several key parts of the build system into utility
methods. This will be used in upcoming patches to help provide
additional sets of target-specific builtin libraries.
Running llvm-diff on the resulting LLVM bytecode binaries, and regular
diff on SPIR-V binaries, shows no differences before and after this
patch.
---------
This is a cherry-pick of upstream commit
183b38eb2261164fdfd6b7deac002edf27a39fe7. The conflicts weren't trivial
so I thought I'd resolve them myself and not wait for a pulldown. CC
@jsji