[libcxx-commits] [PATCH] D92057: [libc++] Do not include sysctl.h when building with musl libc

Pengxuan Zheng via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 25 12:58:22 PST 2020


pzheng added a comment.

The issue here is that the header file "sysctl.h" uses some macros (__BEGIN_DECLS/__END_DECLS) which are only defined by glibc and not by musl libc (refer to https://wiki.musl-libc.org/faq.html). Therefore, when we build with musl libc, we are seeing the following build failures.

  usr/include/sys/sysctl.h:65:1: error: unknown type name '__BEGIN_DECLS'
  __BEGIN_DECLS
  ^

This patch tries to guard the include of sysctl.h with !defined(_LIBCPP_HAS_MUSL_LIBC) so that the header file is not included when musl libc is used. We started to see the libcxx build failure above after 477a687 <https://reviews.llvm.org/rG477a68760b24f07a45253fb41e89368328b3a4a8> landed. 477a687 <https://reviews.llvm.org/rG477a68760b24f07a45253fb41e89368328b3a4a8> removed some #if guards which seem to have exposed the issue. Before 477a687 <https://reviews.llvm.org/rG477a68760b24f07a45253fb41e89368328b3a4a8>, those guards actually prevented sysctl.h from being included in our build. However, I think the root cause is not 477a687 <https://reviews.llvm.org/rG477a68760b24f07a45253fb41e89368328b3a4a8>, but the unconditional include of sysctl.h. I hope this gives a little bit more background on what this patch is trying to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92057



More information about the libcxx-commits mailing list