ARMClang: Do not automatically add cpu/arch compile or link options
The compiler options --march=<arch>
and --mcpu=<cpu>
and the
linker option --cpu=<cpu>
are automatically added by CMake based
on CMAKE_SYSTEM_PROCESSOR
or CMAKE_SYSTEM_ARCH
. But this is not
sufficient, because armclang also supports enabling or disabling
features using +<feature>
:
-mcpu=<name>[+[no]<feature>+...]
For example:
-mcpu=cortex-a57+nocrypto+nofp+nosimd+crc
(Reference: https://developer.arm.com/documentation/dui0774/k/Compiler-Command-line-Options/-mcpu?lang=en)
The problem is, even if a project adds a flag with features it needs, CMake still adds flags, resulting in code that is compiled with wrong CPU features and unable to run.
A new policy CMP0123 has been created to not automatically add compile or link options, and let projects set them instead. The problem is, even if a project adds a flag with features it needs, CMake still a add flags without features specified, resulting in code that is compiled with wrong CPU features and unable to run.
Fixes: #21173 (closed)
Topic-rename: ARMClang-cpu-arch-flags