Open alexrp opened 2 months ago
Sounds a bit like https://github.com/ziglang/universal-headers?
Not exactly. The idea there is to have a single set of headers to cover everything. Here I'm just talking about merging headers for targets when they're literally identical already.
Right now, we have a directory for each glibc-based target triple under
lib/libc/include
. But if you do a recursive diff between many (all?) of the related ones (riscv32-linux-gnu
vsriscv64-linux-gnu
,arm-linux-gnueabi
vsarm-linux-gnueabihf
, and so on), it becomes apparent that the only difference is the presence of the appropriatelib-names-<abi>.h
andstubs-<abi>.h
headers. The appropriate version of this header is picked by thelib-names.h
andstubs.h
files based on preprocessor defines.Also, we already have a bunch of logic for picking the right paths based on target info:
https://github.com/ziglang/zig/blob/e084c46ed6906dc51724d99b29f0992272384f5a/src/glibc.zig#L416-L663
Given these facts, I think we could enhance
process_headers.zig
to exploit this knowledge and merge these include directories together (while asserting for safety that there are no actual diffs between them). Then we'd just updatesrc/glibc.zig
to have very slightly smarter include directory selection.