[libc-commits] [libc] [libc] Include sys/socket.h from netinet/tcp.h (PR #241698)

Alexey Samsonov via libc-commits libc-commits at lists.llvm.org
Thu Nov 12 22:03:52 PST 2026


vonosmas wrote:

Thank you for sharing the background behind this effort, as well as some quantitative data! We appreciate the effort to run an actual system on top of LLVM-libc and upstreaming your work.

Would you be able to attend the LLVM-libc monthly dev meeting next Thursday? That would be a good venue to clarify the ensure an agreement among the community members and receive guidance for the problem you're trying to solve -- basically, how much changes we want to make ln libc in the name of compatibility, and where we'll draw the line and will mandate client code changes.

As for specific issues you list in the table, I believe those should be resolved on the case-by-case basis, with some rules-of-thumb:
* if POSIX standard explicitly says that certain types / declarations from one header shall be available in the other header -- we should just do that.
  * E.g. "sys/time.h also gives select and fd_set" -- definitely YES, because POSIX says so.
  * "pthread.h also gives time.h" -- also YES (I believe I've already merged the PR for that recently)
* if POSIX says "may make visible", then we will most likely consider adding transitive inclusions, since it's reasonable for the code to have this dependency
  * e.g. "netdb.h also gives netinet/in.h" would probably be accepted, and in that case forward-decl is a natural way to accomplish it
* if the transitive header is just a glibc legacy way of organizing headers, not reflected in standard, we'll likely push back on the change
  * "sys/types.h also gives fd_set" - we'll _try_ to avoid that, as fd_set was explicitly pulled out to be in a separate header `<sys/select.h>` outside of catch-all `<sys/types.h>` when it was standardized in POSIX. The current inclusion is a legacy artifact.

and so on. We will try to make practical considerations for other cases (esp. non-standard things) - e.g. see our decision `alloca` to declare it in both `stdlib.h` and `alloca.h` because various headers are used on various systems.

HTH

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


More information about the libc-commits mailing list