{"id":51018664,"url":"https://github.com/agagniere/libc-query","last_synced_at":"2026-06-21T14:01:33.513Z","repository":{"id":363347444,"uuid":"1260756535","full_name":"agagniere/libc-query","owner":"agagniere","description":"Query about libc features for a given target when cross compiling with zig build","archived":false,"fork":false,"pushed_at":"2026-06-08T14:41:00.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-08T15:18:27.321Z","etag":null,"topics":["zig-build","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agagniere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-06-05T20:53:07.000Z","updated_at":"2026-06-08T14:43:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/agagniere/libc-query","commit_stats":null,"previous_names":["agagniere/libc-query"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/agagniere/libc-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agagniere%2Flibc-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agagniere%2Flibc-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agagniere%2Flibc-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agagniere%2Flibc-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agagniere","download_url":"https://codeload.github.com/agagniere/libc-query/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agagniere%2Flibc-query/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34610832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["zig-build","zig-package"],"created_at":"2026-06-21T14:01:31.608Z","updated_at":"2026-06-21T14:01:33.505Z","avatar_url":"https://github.com/agagniere.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libc-query\n\nCompile-time detection of libc symbol and header availability for Zig cross-compilation targets.\n\nCovers **glibc**, **musl**, **macOS**, **FreeBSD**, **OpenBSD**, **NetBSD**, **DragonFly**, **Windows (mingw64)**, and **WASI** (preview 1 and preview 2).\n\n## What is tracked\n\n**`libc_features`** — optional libc functions:\n`accept4`, `alarm`, `arc4random`, `arc4random_buf`, `arc4random_uniform`, `asprintf`,\n`backtrace_symbols`, `clock_gettime`, `copy_file_range`, `copyfile`, `elf_aux_info`, `eventfd`,\n`explicit_bzero`, `fcntl`, `fdatasync`, `fnmatch`, `freeaddrinfo`, `freezero`, `fseeko`,\n`fsetxattr`, `ftruncate`, `getaddrinfo`, `getaddrinfo_threadsafe`, `getauxval`, `getdelim`,\n`getentropy`, `geteuid`, `gethostbyname_r`, `gethostname`, `getifaddrs`, `getline`, `getopt`,\n`getpagesize`, `getpass_r`, `getpeereid`, `getpeername`, `getppid`, `getprogname`, `getpwuid`,\n`getpwuid_r`, `getrandom`, `getrlimit`, `getsockname`, `gettimeofday`, `gmtime_r`,\n`if_nametoindex`, `inet_aton`, `inet_ntop`, `inet_pton`, `localtime_r`, `localeconv_l`,\n`mbstowcs_l`, `memmem`, `memrchr`, `memset_s`, `mkdtemp`, `opendir`, `pipe`, `pipe2`, `poll`,\n`posix_fadvise`, `posix_fallocate`, `ppoll`, `preadv`, `pwritev`, `readpassphrase`, `reallocarray`,\n`recallocarray`, `recv`, `sched_yield`, `select`, `send`, `sendmmsg`, `sendmsg`, `setlocale`,\n`setmode`, `setproctitle`, `setrlimit`, `sigaction`, `siginterrupt`, `sigsetjmp`, `signal`,\n`snprintf`, `socket`, `socketpair`, `strcasecmp`, `strchrnul`, `strdup`, `strerror_r`, `strlcat`,\n`strlcpy`, `strncasecmp`, `strndup`, `strnlen`, `strsep`, `strsignal`, `strtonum`,\n`sync_file_range`, `syncfs`, `syslog`, `timingsafe_bcmp`, `timingsafe_memcmp`, `uselocale`,\n`utimes`, `vasprintf`, `wcstombs_l`.\n\n**`libc_headers`** — system headers: headers always present on all supported targets (e.g. `stdlib.h`,\n`string.h`, `fcntl.h`) plus OS-specific ones such as `sys/epoll.h`, `sys/event.h`, `sys/ucred.h`,\n`netinet/tcp.h`, `sys/ioctl.h`, `sys/resource.h`, `linux/tcp.h` (Linux only), `crtdefs.h` (Windows\nonly), and others.\n\n**`libc_types`** — struct field and typedef presence: `sa_family_t`, `socklen_t`, `suseconds_t`\n(all POSIX targets including WASI), `struct_sockaddr_sa_len` (BSDs and macOS),\n`struct_sockaddr_storage` and `struct_timeval` (all named targets including WASI and Windows),\n`struct_tm_tm_zone` (all POSIX targets except WASI, which uses `__tm_zone`).\n\n**`libc_constants`** — constant/declaration availability: `clock_monotonic` (all POSIX targets\nincluding WASI), `clock_monotonic_raw` (Linux and Darwin), `f_fullfsync` (macOS only),\n`msg_nosignal` (Linux, BSDs, DragonFly, macOS 14.0+), `o_nonblock` (all POSIX targets\nincluding WASI).\n\nFor glibc, function availability is per-architecture and derived from Zig's bundled `abilists` file.\n\n## Usage\n\nAdd this repo as a dependency to your `build.zig.zon`:\n\n```shell\nzig fetch --save git+https://github.com/agagniere/libc-query\n```\n\nThen in your `build.zig`:\n\n```zig\nconst libcquery = @import(\"libcquery\");\n\n// Then, in your build function:\n\nconst features   = libcquery.libc_features.detect(target.result);\nconst headers    = libcquery.libc_headers.detect(target.result);\nconst types      = libcquery.libc_types.detect(target.result);\nconst constants  = libcquery.libc_constants.detect(target.result);\n\nif (features.strlcpy)                  { ... }\nif (headers.sys_epoll_h)               { ... }\nif (types.struct_sockaddr_sa_len)      { ... }\nif (constants.f_fullfsync)             { ... }\n```\n\nEach `detect()` takes a `std.Target` and returns a struct of `bool` fields. Fields default to\n`false` for unknown targets (except POSIX-ubiquitous ones which default to `true`).\n\n## Regenerating generated files\n\n`glibc_abi.zig` and `libc_headers.zig` are generated from Zig's bundled libc data:\n\n```sh\npython3 generate_glibc_abi.py | zig fmt --stdin \u003e glibc_abi.zig\npython3 generate_libc_headers.py | zig fmt --stdin \u003e libc_headers.zig\n```\n\nRequires `zig` on `PATH`. Run after upgrading the Zig toolchain.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagagniere%2Flibc-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagagniere%2Flibc-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagagniere%2Flibc-query/lists"}