[libc-commits] [PATCH] D141997: [libc][NFC] Detect host CPU features using try_compile instead of try_run.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jan 18 09:29:48 PST 2023


sivachandra added a comment.

In D141997#4061578 <https://reviews.llvm.org/D141997#4061578>, @gchatelet wrote:

> I think this can be improved further.
>
> Here is what I have in mind :
>
> - Add preprocessor feature detection to something like `libc/src/__support/cpu_features.h` (we already have `LIBC_TARGET_HAS_FMA` in `libc/src/__support/architectures.h`). This file would only depend on freestanding headers like `compiler_features.h` or `architectures.h` (sidenote we should probably make it clear in the filename that these headers are freestanding / only preprocessor)
> - Create one cpp file per feature with a filename similar to the LIBC preprocessor definition. We don't have a lot of features so the number of files will stay low. This file would use the libc header so we have consistent detection between CMake (Bazel?) and the code.
>
> WDYT? I can take a look at it if you want?

I think the essential idea you are proposing is to move feature detection from config time to build time. Is that correct? If yes, that sounds OK to me as long as we can do the detection without having to run fully linked executables (which is the core problem this patch is trying to solve.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141997/new/

https://reviews.llvm.org/D141997



More information about the libc-commits mailing list