[libc-commits] [libc] [libc] Make use of 32-bit time_t a config option (PR #102012)

via libc-commits libc-commits at lists.llvm.org
Mon Aug 5 22:03:53 PDT 2024


https://github.com/lntue commented:

This way of selecting headers to be copying over for public includes is probably cleanest for full build, but it will be a bit troublesome for proxy-headers and other headers inside `libc/include` that directly include `llvm-libc-types/time_t.h`.

For the proxy-header `libc/src/types/time_t.h`, you can use some flag like `LIBC_TYPES_TIME_T_IS_64_BIT` and `LIBC_TYPES_TIME_T_IS_32_BIT` to include the correct ones, and define it in common flags for objects:  inside the if at https://github.com/llvm/llvm-project/blob/main/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake#L86 and similar one in the same file for tests.

For the other problem that other headers inside `libc/include/` also directly include `time_t`, I can think of a solution, that is directly copy either `time_t_64.h`/`time_t_32.h` to `libc/include/llvm-libc-types/time_t.h` instead.

And I think this might be a simpler solution: is you do the selection and copy to `time_t.h` in the same folder, before `add_header(time_t HDR time_t.h DEPENDS <copy_command>)`.  And in that case, you will not need to update proxy headers or add extra compile options.  WDYT?

https://github.com/llvm/llvm-project/pull/102012


More information about the libc-commits mailing list