Skip to content

Commit

Permalink
minor cosmetic fixups
Browse files Browse the repository at this point in the history
* fix typos and redundancies in docs
* use Target.isGnuLibc
  • Loading branch information
andrewrk committed Jan 5, 2024
1 parent cbaaf64 commit 362460e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions lib/libc/glibc/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Zig GNU C Library ("glibc") Support

*Date*: November, 2023

Zig supports building binaries that will dynamically link against the
[GNU C Library ("glibc")](https://www.gnu.org/software/libc/) when run.
This support extends across a range of glibc versions.

By default, Zig binaries will not depend on any external C library, but
they can be linked against one with the `-lc` option. The compilation
target defines which C library: `musl` for the
[musl C library](https://musl.libc.org/) or `gnu` for the GNU C library.
they can be linked against one with the `-lc` option. The target ABI defines
which C library: `musl` for the [musl C library](https://musl.libc.org/) or
`gnu` for the GNU C library.

A specific GNU C library version can be chosen with an appropriate
`-target`. For example, `-target native-native-gnu.2.19` will use the
Expand All @@ -30,7 +28,7 @@ do not reference an actual implementation.
## Targets

The GNU C Library supports a very wide set of platforms and architectures.
The current Zig support for glibc only supports Linux.
The current Zig support for glibc only includes Linux.

Zig supports glibc versions back to v2.17 (2012) as the Zig standard
library depends on symbols that were introduced in 2.17.
Expand Down Expand Up @@ -58,7 +56,7 @@ family of functions).

The related Zig https://github.com/ziglang/universal-headers is a project
designed to more robustly build multi-version header files suitable for
compliation across a variety of target C library versions.
compilation across a variety of target C library versions.

## Glibc static C-Runtime object files and libraries

Expand Down
2 changes: 1 addition & 1 deletion src/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub fn canBuildLibC(target: std.Target) bool {
return ver.min.order(libc.os_ver.?) != .lt;
}
// Ensure glibc (aka *-linux-gnu) version is supported
if ((target.os.tag == .linux) and target.abi.isGnu()) {
if (target.isGnuLibC()) {
const min_glibc_ver = libc.glibc_min orelse glibc_min_version;
const target_glibc_ver = target.os.version_range.linux.glibc;
return target_glibc_ver.order(min_glibc_ver) != .lt;
Expand Down

0 comments on commit 362460e

Please sign in to comment.