Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

including system include directory on native compatible target #23325

Open
Jan200101 opened this issue Mar 22, 2025 · 0 comments
Open

including system include directory on native compatible target #23325

Jan200101 opened this issue Mar 22, 2025 · 0 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.

Comments

@Jan200101
Copy link
Contributor

Jan200101 commented Mar 22, 2025

it would be useful if the system include path is included when compiling for a compatible target e.g. compiling for x86_64-linux-gnu.2.17 when running on a x86_64-linux.4.19...6.5.7-gnu.2.39 machine.

the people working on lite-xl ran into this while trying out zig cc as an alternative to compiling on an old CentOS machine specifically so that they can build binaries that run on older distros.

lite-xl uses meson (which can handle zig cc and detects zld since 1.5.0)
meson deals with dependencies similar to zig, it calls pkg-config and if it can't find anything it will just pick something with the right enough name.
pkg-config omits system paths such as /usr/include from being included directly
this results in headers that are directly in the system include directory from not being able to be included such as wayland-util.h which is required by any code generated by wayland-scanner.

pkg-config does have a flag which makes it add system paths PKG_CONFIG_ALLOW_SYSTEM_CFLAGS but doing so will put /usr/include ahead of the zig included C headers, resulting in linking errors down the line because some functions are macros to others in newer glibc verisons (e.g. fcntl -> fcntl64 in glibc 2.28)

the current workaround is to add the cflag -idirafter /usr/include, which is essentially what I am advocating for here.

In the zulip thread there was some concern about ABI sensitive libc types being exchanged however this issue also affects projects that are statically compiled and in some cases its even commonplace, most notably SDL where it uses the header of whatever library version at compile time and then dynamically loads the dependency at runtime, regardless of version.


zulip thread
https://zsf.zulipchat.com/#narrow/channel/454360-compiler/topic/including.20system.20include.20directory.20on.20native.20compatible.20targ

@alexrp alexrp added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

2 participants