[libc][docs][POSIX] flush out documentation for the POSIX defined headers
If you go to https://pubs.opengroup.org/onlinepubs/9799919799/, then 14. Headers in the bottom left, you get a list of headers mandated by POSIX. I'd like to document them from https://libc.llvm.org/headers/index.html. We do so by manually curating some metadata about functions and preprocessor defines in yaml files. The yaml files are currently in https://github.com/llvm/llvm-project/tree/main/libc/utils/docgen. https://github.com/llvm/llvm-project/blob/main/libc/utils/docgen/arpa/inet.yaml is an example of arpa/inet.h as per POSIX. POSIX also tries to be a superset of C (though FWICT POSIX1.2024 missed C23 additions...), so most headers we have entries for already (though we should triple check since POSIX can add functions to existing C standard headers).
Once we've added entries for the new POSIX headers, you should configure your build with the 2 additional cmake flags:
-DLLVM_ENABLE_SPHINX=ON-DLIBC_INCLUDE_DOCS=ON
Then you can do ninja docs-libc-html to build html you can view locally in {build_dir}/libc/docs/html/headers/**.html.
Good pull requests should implement one header at a time, and not send a PR that implements documentation for more than one header at a time. If that means that this issue is a "meta" issue for which multiple PRs will link against, so be it.
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
- Check that no other contributor has already been assigned to this issue. If you believe that no one is actually working on it despite an assignment, ping the person. After one week without a response, the assignee may be changed.
- In the comments of this issue, request for it to be assigned to you, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
- Fix the issue locally.
- Run the test suite locally. Remember that the subdirectories under
test/create fine-grained testing targets, so you can e.g. usemake check-clang-astto only run Clang's AST tests. - Create a Git commit.
- Run
git clang-format HEAD~1to format your changes. - Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-libc
Author: Nick Desaulniers (nickdesaulniers)
Once we've added entries for the new POSIX headers, you should configure your build with the 2 additional cmake flags:
-DLLVM_ENABLE_SPHINX=ON-DLIBC_INCLUDE_DOCS=ON
Then you can do ninja docs-libc-html to build html you can view locally in {build_dir}/libc/docs/html/headers/**.html.
Good pull requests should implement one header at a time, and not send a PR that implements documentation for more than one header at a time. If that means that this issue is a "meta" issue for which multiple PRs will link against, so be it.
@llvm/issue-subscribers-good-first-issue
Author: Nick Desaulniers (nickdesaulniers)
Once we've added entries for the new POSIX headers, you should configure your build with the 2 additional cmake flags:
-DLLVM_ENABLE_SPHINX=ON-DLIBC_INCLUDE_DOCS=ON
Then you can do ninja docs-libc-html to build html you can view locally in {build_dir}/libc/docs/html/headers/**.html.
Good pull requests should implement one header at a time, and not send a PR that implements documentation for more than one header at a time. If that means that this issue is a "meta" issue for which multiple PRs will link against, so be it.
Looks like a good issue to start with, could I work on this?
From my understanding, what i want to do is:
- Check whether all the headers mandated by POSIX can be found in LLVM's reference.
- If a header is missing form LLVM's reference, create a new yaml with the functions and macros of the header from POSIX reference (also create a entry in
index.rsinlibc/docs/headers). - Check and update the current status of functions and macros of all headers in POSIX.
Now, i got some questions,
- What's the role of
C23 Standard Sectionin the reference?
Please correct me if i misunderstand something, somewhere. Thanks!
Looks like a good issue to start with, could I work on this?
Sure! I'll add you as an assignee. Feel free to work through as many as you'd like. Happy to add others to help out if folks are interested, since this is an embarrassingly parallel problem!
Check whether all the headers mandated by POSIX can be found in LLVM's reference.
Yep, each header should have a corresponding .yaml file under libc/utils/docgen/ (or a subdir of that for things like arpa/ sys/ etc).
also create a entry in index.rs in libc/docs/headers
s/index.rs/index.rst/ but yes, good catch! I forgot to mention that in the bug description. Please keep that list alphabetically sorted, too.
What's the role of C23 Standard Section in the reference?
The intent of that field is when a function/macro has a definition as per the ISO C spec, what section should folks look at to understand what that function's specified semantics are.
If a function is POSIX only, and not in ISO C, then the c23 standard section is optional, and may be omitted.
Hey @nickdesaulniers , i just made a pull request for including (aio.h) and do i have to create a separate PR for every header ?
Hi @nickdesaulniers, I would also like to work on this issue and help contribute, It would be great If you could assign me also on this, @StarOne01 Would like to work together as there are many headers to be listed. Thanks!
Hey @marcury122 , let's work on this in parallel, please tell me which header(s) you gonna work on
yeah Sure! Before that I have a doubt, any of the two can please let me know @nickdesaulniers @StarOne01, In any of the already included file, there is a subsection as "c-definition: 7.4.1.1", I want to know how is the 2nd part i.e. 7.4.1.1 is known, because I am unable to locate it on the site listed.
If you could list me the reference, it would be helpful and we can start working on it. Thanks!
Also do we have to list all the headers from the list of 86 headers on the webpage https://pubs.opengroup.org/onlinepubs/9799919799/ and then 14.headers, that are missing from the libc/utils/docgen folder or we have to list only those which are included on the webpage https://libc.llvm.org/headers/index.html
I want to know how is the 2nd part i.e. 7.4.1.1 is known, because I am unable to locate it on the site listed.
I did see a few mentions in the POSIX's reference itself, also I found this, to be helpful or a quick search does the job.
do we have to list all the headers from the list of 86 headers on the webpage and then 14.headers, that are missing from the
libc/utils/docgenfolder
Yes, we would need to list all the headers in the header section of the POSIX reference and check the existing functions and macros for changes.
Okay thanks. I will take the headers devctl.h and dlfcn.h
It would be great If you could assign me also
Done, thanks for volunteering!
I want to know how is the 2nd part i.e. 7.4.1.1 is known, because I am unable to locate it on the site listed.
Bookmark this page: https://www.open-std.org/jtc1/sc22/wg14/www/projects#9899
The latest C standard draft is what I would consider to be the most up to date specification of the C programming language. Note: the latest standard draft is updated somewhat frequently these days, which is why I recommend bookmarking the page I did; it is updated periodically with new drafts.
Ah...7.4.1.1 is a mistake I made in ctype. It should be 7.4.2.1 (etc). Want to send a patch to fix that?
all the headers from the list of 86 headers
Ideally, yes please.
I will take the headers devctl.h and dlfcn.h
Go for it! Thanks again for volunteering.
I happen to have a local patch for pthread, so I'll finish that off and get it posted.
Got it!
Two more, done!
Once we've added entries for the new POSIX headers, you should configure your build with the 2 additional cmake flags:
-DLLVM_ENABLE_SPHINX=ON-DLIBC_INCLUDE_DOCS=ONThen you can do
ninja docs-libc-htmlto build html you can view locally in{build_dir}/libc/docs/html/headers/**.html.
I am having trouble doing this step, because this step requires mingw with gcc of version graeter than 7.4, and all I could find is a mingw with gcc of version 6.3. Could you help me with that, I have tried youtube, google, chatgpt etc but couldn't get that to work.
hey @nickdesaulniers can you assign me this and want to work together with you guys @StarOne01 @marcury122