[libc-commits] [libc] [libc] Make hdrgen support macro_header YAML field. (PR #123265)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Wed Jan 29 10:00:25 PST 2025
nickdesaulniers wrote:
Ah, so this is more of "add checks to generated headers that if a given macro isn't defined as expected, we will `#error` out.
Coincidentally, I just reviewed a patch to bionic where I learned that they have dedicated header tests (seemingly only for POSIX IIUC): https://android.googlesource.com/platform/bionic/+/main/tests/headers/posix/
So I guess those are two different means of testing the generated headers. The trade off being that with the approach in this PR, our headers are bigger; we pay that cost of the preprocessor checking, rechecking, rechecking, ... for every compile, regardless of whether or not we just mean to do a sanity check.
Privately, you seemed to indicate that your had more patches that build on top of this PR. Can you describe a little more how you plan to extend this feature?
Otherwise, I think I mildly prefer bionic's approach of just having unit tests. We already have this concept in the tests under `libc/test/include/`. I don't see why this could just be:
```c
#ifndef RTLD_LAZY
#error "WTF"
#endif
#ifndef ...
```
which is effectively what the bionic tests are doing. That way, we keep our generated headers smaller (FWIW), and can remove macro_name/macro_value support from hdrgen (#124957). cc @enh-google
https://github.com/llvm/llvm-project/pull/123265
More information about the libc-commits
mailing list