[compiler-rt] Check for missing CMAKE_C_COMPILER_TARGET when using COMPILER_RT_DEFAUL...
authorDavid Spickett <david.spickett@linaro.org>
Wed, 5 Apr 2023 09:00:54 +0000 (09:00 +0000)
committerDavid Spickett <david.spickett@linaro.org>
Thu, 6 Apr 2023 12:55:48 +0000 (12:55 +0000)
commit0ecd4f6c55c0cb4e9ba0e03758925da8cef66088
tree22914a10aecf8c71e5380f6956bec984009ea5fa
parent846712b0cb133f0ebfaf5be41818183b4c86f0a1
[compiler-rt] Check for missing CMAKE_C_COMPILER_TARGET when using COMPILER_RT_DEFAULT_TARGET_ONLY

COMPILER_RT_DEFAULT_TARGET_ONLY is the goto workaround for building
only one of a multilib setup while still being able to autodetect the native target.
For example only building 64 bit libraries on Intel instead of 32 and 64 bit.
Which may fail without 32 bit compatibility libs installed.

As reported in https://discourse.llvm.org/t/configuring-compiler-rt-to-use-default-target-only-does-not-work/62727
this build config hasn't worked in a while.

It relies on a variable usually set during cross compliation,
though my testing shows you can set it in other scenarios too.
https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_TARGET.html

So the options you need to provide are:
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DCMAKE_C_COMPILER_TARGET="aarch64-unknown-linux-gnu"

And we should error if CMAKE_C_COMPILER_TARGET isn't set.

Reviewed By: glaubitz

Differential Revision: https://reviews.llvm.org/D147598
compiler-rt/cmake/Modules/CompilerRTUtils.cmake