[libc-commits] [PATCH] D141997: [libc][NFC] Detect host CPU features using try_compile instead of try_run.
Guillaume Chatelet via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Jan 18 02:24:28 PST 2023
gchatelet added a comment.
Thx for the patch @sivachandra! It's definitely better than what I did, I was unhappy with the design but it was a first step.
There are still a few issues in my opinion:
- in msvc features have a different name <https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170>, this means that the way we refer to features in CMake cannot be the same as what is put into the file,
- the way we detect features in CMake and in llvm libc can be different,
- what is actually compiled by CMake is hard to understand.
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?
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