[libcxx-commits] [libcxx] [libc++] Remove explicit mentions of __need_FOO macros (PR #119025)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 19 21:16:54 PST 2024
zeroomega wrote:
Not sure if it is helpful for understanding the underlying issue. I reproduced the issue locally and used -dD and -E to see the pre-processed file. And noticed a difference in handling the headers
Before this patch:
system wchar.h ->(include) libcxx/stdio.h ->(include) system stdio.h ->(end of included file) libcxx/stdio.h ->(include) system wchar.h -> define mbstate_t type -> ... -> (include) system _G_config.h -> define __need_mbstate_t -> (include) system wchar.h (but skipped due to header macro) -> used __need_mbstate_t
After this patch:
system wchar.h ->(include) libcxx/stdio.h ->(include) system stdio.h -> (end of included file) libcxx/stdio.h -> (include) system stdio.h -> (end of included file) libcxx/stdio.h ->(include) system stdio.h -> ... -> system _G_config.h -> define __need_mbstate_t -> system wchar.h (but skipped due to header macro) -> use before define error
It appears to me after this patch, during the processing of `wchar.h`, before the definition of the `mbstate_t` types, libcxx stdio.h header caused the `_G_config.h` to be included and processed. Despite the `_G_config.h`includes the `wchar.h`, the wchar's include macro was already defined at this point so it has no effect. Before this patch, the `wchar.h` will finish processing before `_G_config.h` was included. In a local experiment, I reverted your change to the `stdio.h` but keep the rest of the patch unchanged, the build passed. Also in my local reproduction, the i386-linux and x64-linux runtimes are also affected by this build failure, not just arm64.
https://github.com/llvm/llvm-project/pull/119025
More information about the libcxx-commits
mailing list