aboutsummaryrefslogtreecommitdiff
path: root/src/glibc.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-09-11 16:37:03 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-09-11 16:37:03 -0700
commit65bea514ae3860a5169d044d22ece7170c445bd3 (patch)
tree64bc55e984c908f1056fdfd101757612d119d2fc /src/glibc.zig
parentaec0e595f2a679f10e927ea4531b8f58ced7080a (diff)
downloadzig-65bea514ae3860a5169d044d22ece7170c445bd3.tar.gz
zig-65bea514ae3860a5169d044d22ece7170c445bd3.zip
Compilation: handle system C compiler not found
When linking libc and compiling natively, Zig tries to integrate with the system C compiler. However, this caused Zig to fail when no system C compiler is installed, despite the fact that Zig is perfectly capable of compiling & linking libc without one. This commit makes Zig fall back to using its own ability to provide libc in the case that no C compiler is installed. For glibc, it means sometimes getting the warning "zig cannot build new glibc version abc, providing instead xyz". Ideally, Zig would do some more validation about the system libraries being linked against, and report an error in case it could not provide the exact correct libc version of the system libraries (or that the system libraries themselves conflict with each other), however, I think it is fair to call that a separate enhancement.
Diffstat (limited to 'src/glibc.zig')
-rw-r--r--src/glibc.zig9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/glibc.zig b/src/glibc.zig
index 4e33867169..3dd7565e96 100644
--- a/src/glibc.zig
+++ b/src/glibc.zig
@@ -719,17 +719,16 @@ pub fn buildSharedObjects(comp: *Compilation) !void {
.lt => continue,
.gt => {
// TODO Expose via compile error mechanism instead of log.
- log.err("invalid target glibc version: {}", .{target_version});
+ log.warn("invalid target glibc version: {}", .{target_version});
return error.InvalidTargetGLibCVersion;
},
}
- } else {
+ } else blk: {
const latest_index = metadata.all_versions.len - 1;
- // TODO Expose via compile error mechanism instead of log.
- log.err("zig does not yet provide glibc version {}, the max provided version is {}", .{
+ log.warn("zig cannot build new glibc version {}; providing instead {}", .{
target_version, metadata.all_versions[latest_index],
});
- return error.InvalidTargetGLibCVersion;
+ break :blk latest_index;
};
{