llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[libc] Enforce that libc shared header libraries don't depend on .cpp files

Open vonosmas opened this issue 1 year ago • 1 comments

Headers in libc/shared/ are supposed to be included from other LLVM projects (e.g. libc++), and themselves also include internal bits of llvm-libc implementation. By design, all the functionality should be implemented in headers only.

We need to ensure and enforce (by adding build system checks) that libraries exposed in libc/shared won't end up including an internal header that would need a corresponding .cpp file to provide certain definitions. Notably, it's not the case now, as __support/str_to_integer.h includes libc_errno.h, which needs libc_errno.cpp to provide internal Errno class methods definitions. @michaelrj-google says we should fix this specific case by breaking this dependency.

Assigning to @lntue who's already working on reworking CMake dependency propagation. I'll look if we can enforce it in Bazel as well, now that we have filegroup construction through genrules for all internal building blocks.

vonosmas avatar Mar 26 '25 16:03 vonosmas

@llvm/issue-subscribers-libc

Author: Alexey Samsonov (vonosmas)

Headers in `libc/shared/` are supposed to be included from other LLVM projects (e.g. libc++), and themselves also include internal bits of llvm-libc implementation. By design, all the functionality should be implemented in headers only.

We need to ensure and enforce (by adding build system checks) that libraries exposed in libc/shared won't end up including an internal header that would need a corresponding .cpp file to provide certain definitions. Notably, it's not the case now, as __support/str_to_integer.h includes libc_errno.h, which needs libc_errno.cpp to provide internal Errno class methods definitions. @michaelrj-google says we should fix this specific case by breaking this dependency.

Assigning to @lntue who's already working on reworking CMake dependency propagation. I'll look if we can enforce it in Bazel as well, now that we have filegroup construction through genrules for all internal building blocks.

llvmbot avatar Mar 26 '25 16:03 llvmbot