How to determine the architecture that clang/llvm will compile in CMake.

I’ve been working on getting the LLVM OpenMP library to build smoothly alongside llvm/clang using CMake, but one problem I’m having is determining exactly which CMake option designates the architecture the compiler will compile. I see LLVM_TARGET_ARCH, LLVM_TARGETS_TO_BUILD, LLVM_DEFAULT_TARGET_TRIPLE, etc.

I thought I should just ask which one designates the architecture the compiler will build, but I wouldn’t mind an explanation for all of them J

And yes, I’ve looked at http://llvm.org/docs/CMake.html, but am still confused.

Any help is greatly appreciated!

– Johnny

Hi,

The default CMake options produce a compiler that is capable of targeting all the architectures that were present in the source tree. The list of supported architectures can be reduced using LLVM_TARGETS_TO_BUILD in case you want to save disk-space, compilation-time, etc… The default architecture targeted by the resulting compiler is specified by LLVM_TARGET_ARCH and LLVM_DEFAULT_TARGET_TRIPLE.

Hope that helps.

Thank you. It does help!

– Johnny

Thank you. It does help!

Another suggestion: You should model this after the equivalent support in compiler-rt as it has to solve the same problem.

Be especially mindful of the distinction between the just-built clang, and the host compiler being used to build clang. The cmake flag `LLVM_BUILD_EXTERNAL_COMPILER_RT` is used to make sure that compiler-rt is built using the just-built clang. See clang/runtime/CMakeLists.txt.

Jon