Thank you, Szabolcs. But as I understand, libc has dependency on os's api, and musl is designed target for linux, right? Why musl provide a set of header files without directly use user header files from linux? I also wonder by current solution for musl, how to keep alignment with kernel, I mean if linux changes some in uapi, would musl have to make the corresponding changes to catch up with it? Doesn't it look better to directly use linux uapi header files? Best Regards Wang Chen From: Szabolcs Nagy Date: 2020-11-02 16:04 To: Chen Wang CC: musl Subject: Re: [musl] [Question] somequestions about kernel header files for musl? * Chen Wang [2020-11-02 15:44:38 +0800]: > hi, I'm a newbie learning msul, I have some questions about kernel header files for musl. Appreciated if anybody can answer my quesitons, thanks in adv. > > Q1) What's the rule to pick up kernel header files for musl? Do we need to catch up the latest kernel when the kernel is upgraded? What version of kernel is musl currently in usage? musl can be built without linux headers. you can use whatever linux version to build your toolchain, but recent ones (e.g. linux v5.*) will have less issues when libc and linux headers are included together in some code. > Q2) I see duplicated headers files in different folders, for example: unistd.h, I see it under both "include/unistd.h" and "src/include/unistd.h". Why we need multiple copies? Are they used for different purpose? src/* is musl internal, it is only used for building musl. > Q3) For different arch, such as arm/x86/riscv, do they share the same kernel header files? I double checked android bionic and found it has different kernel header files for differnet arch. musl does not use linux headers. it uses its own target specific definitions see arch/*/bits/*.h, an installed header set is only valid for one arch because the bits/ directory is arch specific. linux headers are similar: different targets cannot share the same headers because the asm/ directory is arch specific.