aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-12-16 13:16:14 -0800
committerGitHub <noreply@github.com>2021-12-16 13:16:14 -0800
commit58f669dc8c4fa9f78d73d014e805a506009f3d30 (patch)
tree4343603e48044a8c1123ef5ad495a88bb164788d /src/Compilation.zig
parent877a1f2a2986e02269c64a05456dff521da27ac1 (diff)
parent9257669cd4ecb10c51baea2bccee993e0c82bd20 (diff)
downloadzig-58f669dc8c4fa9f78d73d014e805a506009f3d30.tar.gz
zig-58f669dc8c4fa9f78d73d014e805a506009f3d30.zip
Merge pull request #10339 from ziglang/update-glibc
update glibc to 2.34
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index d58394de65..b3c2608c05 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -1586,9 +1586,23 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
// If we need to build glibc for the target, add work items for it.
// We go through the work queue so that building can be done in parallel.
if (comp.wantBuildGLibCFromSource()) {
- try comp.addBuildingGLibCJobs();
+ if (!target_util.canBuildLibC(comp.getTarget())) return error.LibCUnavailable;
+
+ if (glibc.needsCrtiCrtn(comp.getTarget())) {
+ try comp.work_queue.write(&[_]Job{
+ .{ .glibc_crt_file = .crti_o },
+ .{ .glibc_crt_file = .crtn_o },
+ });
+ }
+ try comp.work_queue.write(&[_]Job{
+ .{ .glibc_crt_file = .scrt1_o },
+ .{ .glibc_crt_file = .libc_nonshared_a },
+ .{ .glibc_shared_objects = {} },
+ });
}
if (comp.wantBuildMuslFromSource()) {
+ if (!target_util.canBuildLibC(comp.getTarget())) return error.LibCUnavailable;
+
try comp.work_queue.ensureUnusedCapacity(6);
if (musl.needsCrtiCrtn(comp.getTarget())) {
comp.work_queue.writeAssumeCapacity(&[_]Job{
@@ -1607,6 +1621,8 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
});
}
if (comp.wantBuildWasiLibcFromSource()) {
+ if (!target_util.canBuildLibC(comp.getTarget())) return error.LibCUnavailable;
+
const wasi_emulated_libs = comp.bin_file.options.wasi_emulated_libs;
try comp.work_queue.ensureUnusedCapacity(wasi_emulated_libs.len + 2); // worst-case we need all components
for (wasi_emulated_libs) |crt_file| {
@@ -1620,6 +1636,8 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
});
}
if (comp.wantBuildMinGWFromSource()) {
+ if (!target_util.canBuildLibC(comp.getTarget())) return error.LibCUnavailable;
+
const static_lib_jobs = [_]Job{
.{ .mingw_crt_file = .mingw32_lib },
.{ .mingw_crt_file = .msvcrt_os_lib },
@@ -3397,6 +3415,14 @@ pub fn addCCArgs(
try argv.append(libunwind_include_path);
}
+ if (comp.bin_file.options.link_libc and target.isGnuLibC()) {
+ const target_version = target.os.version_range.linux.glibc;
+ const glibc_minor_define = try std.fmt.allocPrint(arena, "-D__GLIBC_MINOR__={d}", .{
+ target_version.minor,
+ });
+ try argv.append(glibc_minor_define);
+ }
+
const llvm_triple = try @import("codegen/llvm.zig").targetTriple(arena, target);
try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple });
@@ -4038,16 +4064,6 @@ pub fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const
return full_path;
}
-fn addBuildingGLibCJobs(comp: *Compilation) !void {
- try comp.work_queue.write(&[_]Job{
- .{ .glibc_crt_file = .crti_o },
- .{ .glibc_crt_file = .crtn_o },
- .{ .glibc_crt_file = .scrt1_o },
- .{ .glibc_crt_file = .libc_nonshared_a },
- .{ .glibc_shared_objects = {} },
- });
-}
-
fn wantBuildLibCFromSource(comp: Compilation) bool {
const is_exe_or_dyn_lib = switch (comp.bin_file.options.output_mode) {
.Obj => false,