| ... | @@ -290,6 +290,9 @@ const QueuedJobs = struct { | ... | @@ -290,6 +290,9 @@ const QueuedJobs = struct { |
| 290 | fuzzer_lib: bool = false, | 290 | fuzzer_lib: bool = false, |
| 291 | update_builtin_zig: bool, | 291 | update_builtin_zig: bool, |
| 292 | musl_crt_file: [@typeInfo(musl.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(musl.CrtFile).@"enum".fields.len, | 292 | musl_crt_file: [@typeInfo(musl.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(musl.CrtFile).@"enum".fields.len, |
| | 293 | glibc_crt_file: [@typeInfo(glibc.CrtFile).@"enum".fields.len]bool = [1]bool{false} ** @typeInfo(glibc.CrtFile).@"enum".fields.len, |
| | 294 | /// all of the glibc shared objects |
| | 295 | glibc_shared_objects: bool = false, |
| 293 | }; | 296 | }; |
| 294 | | 297 | |
| 295 | pub const default_stack_protector_buffer_size = target_util.default_stack_protector_buffer_size; | 298 | pub const default_stack_protector_buffer_size = target_util.default_stack_protector_buffer_size; |
| ... | @@ -385,10 +388,6 @@ const Job = union(enum) { | ... | @@ -385,10 +388,6 @@ const Job = union(enum) { |
| 385 | /// Fully resolve the given `struct` or `union` type. | 388 | /// Fully resolve the given `struct` or `union` type. |
| 386 | resolve_type_fully: InternPool.Index, | 389 | resolve_type_fully: InternPool.Index, |
| 387 | | 390 | |
| 388 | /// one of the glibc static objects | | |
| 389 | glibc_crt_file: glibc.CrtFile, | | |
| 390 | /// all of the glibc shared objects | | |
| 391 | glibc_shared_objects, | | |
| 392 | /// one of the mingw-w64 static objects | 391 | /// one of the mingw-w64 static objects |
| 393 | mingw_crt_file: mingw.CrtFile, | 392 | mingw_crt_file: mingw.CrtFile, |
| 394 | | 393 | |
| ... | @@ -1830,22 +1829,19 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil | ... | @@ -1830,22 +1829,19 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1830 | if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; | 1829 | if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; |
| 1831 | | 1830 | |
| 1832 | if (glibc.needsCrtiCrtn(target)) { | 1831 | if (glibc.needsCrtiCrtn(target)) { |
| 1833 | try comp.queueJobs(&[_]Job{ | 1832 | comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.crti_o)] = true; |
| 1834 | .{ .glibc_crt_file = .crti_o }, | 1833 | comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.crtn_o)] = true; |
| 1835 | .{ .glibc_crt_file = .crtn_o }, | | |
| 1836 | }); | | |
| 1837 | comp.remaining_prelink_tasks += 2; | 1834 | comp.remaining_prelink_tasks += 2; |
| 1838 | } | 1835 | } |
| 1839 | if (glibc.needsCrt0(comp.config.output_mode)) |f| { | 1836 | if (glibc.needsCrt0(comp.config.output_mode)) |f| { |
| 1840 | try comp.queueJobs(&.{.{ .glibc_crt_file = f }}); | 1837 | comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true; |
| 1841 | comp.remaining_prelink_tasks += 1; | 1838 | comp.remaining_prelink_tasks += 1; |
| 1842 | } | 1839 | } |
| 1843 | try comp.queueJobs(&[_]Job{ | 1840 | comp.queued_jobs.glibc_shared_objects = true; |
| 1844 | .{ .glibc_shared_objects = {} }, | | |
| 1845 | .{ .glibc_crt_file = .libc_nonshared_a }, | | |
| 1846 | }); | | |
| 1847 | comp.remaining_prelink_tasks += 1; | | |
| 1848 | comp.remaining_prelink_tasks += glibc.sharedObjectsCount(&target); | 1841 | comp.remaining_prelink_tasks += glibc.sharedObjectsCount(&target); |
| | 1842 | |
| | 1843 | comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.libc_nonshared_a)] = true; |
| | 1844 | comp.remaining_prelink_tasks += 1; |
| 1849 | } else if (target.isWasm() and target.os.tag == .wasi) { | 1845 | } else if (target.isWasm() and target.os.tag == .wasi) { |
| 1850 | if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; | 1846 | if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; |
| 1851 | | 1847 | |
| ... | @@ -3730,10 +3726,22 @@ fn performAllTheWorkInner( | ... | @@ -3730,10 +3726,22 @@ fn performAllTheWorkInner( |
| 3730 | comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node }); | 3726 | comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node }); |
| 3731 | } | 3727 | } |
| 3732 | | 3728 | |
| 3733 | inline for (@typeInfo(musl.CrtFile).@"enum".fields) |field| { | 3729 | for (0..@typeInfo(musl.CrtFile).@"enum".fields.len) |i| { |
| 3734 | const tag = @field(musl.CrtFile, field.name); | 3730 | if (testAndClear(&comp.queued_jobs.musl_crt_file[i])) { |
| 3735 | if (testAndClear(&comp.queued_jobs.musl_crt_file[@intFromEnum(tag)])) | 3731 | const tag: musl.CrtFile = @enumFromInt(i); |
| 3736 | comp.link_task_wait_group.spawnManager(buildMuslCrtFile, .{ comp, tag, main_progress_node }); | 3732 | comp.link_task_wait_group.spawnManager(buildMuslCrtFile, .{ comp, tag, main_progress_node }); |
| | 3733 | } |
| | 3734 | } |
| | 3735 | |
| | 3736 | for (0..@typeInfo(glibc.CrtFile).@"enum".fields.len) |i| { |
| | 3737 | if (testAndClear(&comp.queued_jobs.glibc_crt_file[i])) { |
| | 3738 | const tag: glibc.CrtFile = @enumFromInt(i); |
| | 3739 | comp.link_task_wait_group.spawnManager(buildGlibcCrtFile, .{ comp, tag, main_progress_node }); |
| | 3740 | } |
| | 3741 | } |
| | 3742 | |
| | 3743 | if (testAndClear(&comp.queued_jobs.glibc_shared_objects)) { |
| | 3744 | comp.link_task_wait_group.spawnManager(buildGlibcSharedObjects, .{ comp, main_progress_node }); |
| 3737 | } | 3745 | } |
| 3738 | | 3746 | |
| 3739 | { | 3747 | { |
| ... | @@ -3966,30 +3974,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre | ... | @@ -3966,30 +3974,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre |
| 3966 | error.AnalysisFail => return, | 3974 | error.AnalysisFail => return, |
| 3967 | }; | 3975 | }; |
| 3968 | }, | 3976 | }, |
| 3969 | .glibc_crt_file => |crt_file| { | | |
| 3970 | const named_frame = tracy.namedFrame("glibc_crt_file"); | | |
| 3971 | defer named_frame.end(); | | |
| 3972 | | | |
| 3973 | glibc.buildCrtFile(comp, crt_file, prog_node) catch |err| { | | |
| 3974 | // TODO Surface more error details. | | |
| 3975 | comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc CRT file: {s}", .{ | | |
| 3976 | @errorName(err), | | |
| 3977 | }); | | |
| 3978 | }; | | |
| 3979 | }, | | |
| 3980 | .glibc_shared_objects => { | | |
| 3981 | const named_frame = tracy.namedFrame("glibc_shared_objects"); | | |
| 3982 | defer named_frame.end(); | | |
| 3983 | | | |
| 3984 | glibc.buildSharedObjects(comp, prog_node) catch |err| { | | |
| 3985 | // TODO Surface more error details. | | |
| 3986 | comp.lockAndSetMiscFailure( | | |
| 3987 | .glibc_shared_objects, | | |
| 3988 | "unable to build glibc shared objects: {s}", | | |
| 3989 | .{@errorName(err)}, | | |
| 3990 | ); | | |
| 3991 | }; | | |
| 3992 | }, | | |
| 3993 | .mingw_crt_file => |crt_file| { | 3977 | .mingw_crt_file => |crt_file| { |
| 3994 | const named_frame = tracy.namedFrame("mingw_crt_file"); | 3978 | const named_frame = tracy.namedFrame("mingw_crt_file"); |
| 3995 | defer named_frame.end(); | 3979 | defer named_frame.end(); |
| ... | @@ -4771,6 +4755,28 @@ fn buildMuslCrtFile( | ... | @@ -4771,6 +4755,28 @@ fn buildMuslCrtFile( |
| 4771 | }; | 4755 | }; |
| 4772 | } | 4756 | } |
| 4773 | | 4757 | |
| | 4758 | fn buildGlibcCrtFile( |
| | 4759 | comp: *Compilation, |
| | 4760 | crt_file: glibc.CrtFile, |
| | 4761 | prog_node: std.Progress.Node, |
| | 4762 | ) void { |
| | 4763 | glibc.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { |
| | 4764 | error.SubCompilationFailed => return, // error reported already |
| | 4765 | else => comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc {s}: {s}", .{ |
| | 4766 | @tagName(crt_file), @errorName(err), |
| | 4767 | }), |
| | 4768 | }; |
| | 4769 | } |
| | 4770 | |
| | 4771 | fn buildGlibcSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) void { |
| | 4772 | glibc.buildSharedObjects(comp, prog_node) catch |err| switch (err) { |
| | 4773 | error.SubCompilationFailed => return, // error reported already |
| | 4774 | else => comp.lockAndSetMiscFailure(.glibc_shared_objects, "unable to build glibc shared objects: {s}", .{ |
| | 4775 | @errorName(err), |
| | 4776 | }), |
| | 4777 | }; |
| | 4778 | } |
| | 4779 | |
| 4774 | fn reportRetryableCObjectError( | 4780 | fn reportRetryableCObjectError( |
| 4775 | comp: *Compilation, | 4781 | comp: *Compilation, |
| 4776 | c_object: *CObject, | 4782 | c_object: *CObject, |