| ... | @@ -47,7 +47,8 @@ gpa: Allocator, | ... | @@ -47,7 +47,8 @@ gpa: Allocator, |
| 47 | arena_state: std.heap.ArenaAllocator.State, | 47 | arena_state: std.heap.ArenaAllocator.State, |
| 48 | bin_file: *link.File, | 48 | bin_file: *link.File, |
| 49 | c_object_table: std.AutoArrayHashMapUnmanaged(*CObject, void) = .{}, | 49 | c_object_table: std.AutoArrayHashMapUnmanaged(*CObject, void) = .{}, |
| 50 | win32_resource_table: std.AutoArrayHashMapUnmanaged(*Win32Resource, void) = .{}, | 50 | win32_resource_table: if (build_options.only_core_functionality) void else std.AutoArrayHashMapUnmanaged(*Win32Resource, void) = |
| | 51 | if (build_options.only_core_functionality) {} else .{}, |
| 51 | /// This is a pointer to a local variable inside `update()`. | 52 | /// This is a pointer to a local variable inside `update()`. |
| 52 | whole_cache_manifest: ?*Cache.Manifest = null, | 53 | whole_cache_manifest: ?*Cache.Manifest = null, |
| 53 | whole_cache_manifest_mutex: std.Thread.Mutex = .{}, | 54 | whole_cache_manifest_mutex: std.Thread.Mutex = .{}, |
| ... | @@ -64,7 +65,7 @@ c_object_work_queue: std.fifo.LinearFifo(*CObject, .Dynamic), | ... | @@ -64,7 +65,7 @@ c_object_work_queue: std.fifo.LinearFifo(*CObject, .Dynamic), |
| 64 | | 65 | |
| 65 | /// These jobs are to invoke the RC compiler to create a compiled resource file (.res), which | 66 | /// These jobs are to invoke the RC compiler to create a compiled resource file (.res), which |
| 66 | /// gets linked with the Compilation. | 67 | /// gets linked with the Compilation. |
| 67 | win32_resource_work_queue: std.fifo.LinearFifo(*Win32Resource, .Dynamic), | 68 | win32_resource_work_queue: if (build_options.only_core_functionality) void else std.fifo.LinearFifo(*Win32Resource, .Dynamic), |
| 68 | | 69 | |
| 69 | /// These jobs are to tokenize, parse, and astgen files, which may be outdated | 70 | /// These jobs are to tokenize, parse, and astgen files, which may be outdated |
| 70 | /// since the last compilation, as well as scan for `@import` and queue up | 71 | /// since the last compilation, as well as scan for `@import` and queue up |
| ... | @@ -81,7 +82,8 @@ failed_c_objects: std.AutoArrayHashMapUnmanaged(*CObject, *CObject.ErrorMsg) = . | ... | @@ -81,7 +82,8 @@ failed_c_objects: std.AutoArrayHashMapUnmanaged(*CObject, *CObject.ErrorMsg) = . |
| 81 | | 82 | |
| 82 | /// The ErrorBundle memory is owned by the `Win32Resource`, using Compilation's general purpose allocator. | 83 | /// The ErrorBundle memory is owned by the `Win32Resource`, using Compilation's general purpose allocator. |
| 83 | /// This data is accessed by multiple threads and is protected by `mutex`. | 84 | /// This data is accessed by multiple threads and is protected by `mutex`. |
| 84 | failed_win32_resources: std.AutoArrayHashMapUnmanaged(*Win32Resource, ErrorBundle) = .{}, | 85 | failed_win32_resources: if (build_options.only_core_functionality) void else std.AutoArrayHashMapUnmanaged(*Win32Resource, ErrorBundle) = |
| | 86 | if (build_options.only_core_functionality) {} else .{}, |
| 85 | | 87 | |
| 86 | /// Miscellaneous things that can fail. | 88 | /// Miscellaneous things that can fail. |
| 87 | misc_failures: std.AutoArrayHashMapUnmanaged(MiscTask, MiscError) = .{}, | 89 | misc_failures: std.AutoArrayHashMapUnmanaged(MiscTask, MiscError) = .{}, |
| ... | @@ -1671,7 +1673,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1671,7 +1673,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1671 | .work_queue = std.fifo.LinearFifo(Job, .Dynamic).init(gpa), | 1673 | .work_queue = std.fifo.LinearFifo(Job, .Dynamic).init(gpa), |
| 1672 | .anon_work_queue = std.fifo.LinearFifo(Job, .Dynamic).init(gpa), | 1674 | .anon_work_queue = std.fifo.LinearFifo(Job, .Dynamic).init(gpa), |
| 1673 | .c_object_work_queue = std.fifo.LinearFifo(*CObject, .Dynamic).init(gpa), | 1675 | .c_object_work_queue = std.fifo.LinearFifo(*CObject, .Dynamic).init(gpa), |
| 1674 | .win32_resource_work_queue = std.fifo.LinearFifo(*Win32Resource, .Dynamic).init(gpa), | 1676 | .win32_resource_work_queue = if (build_options.only_core_functionality) {} else std.fifo.LinearFifo(*Win32Resource, .Dynamic).init(gpa), |
| 1675 | .astgen_work_queue = std.fifo.LinearFifo(*Module.File, .Dynamic).init(gpa), | 1677 | .astgen_work_queue = std.fifo.LinearFifo(*Module.File, .Dynamic).init(gpa), |
| 1676 | .embed_file_work_queue = std.fifo.LinearFifo(*Module.EmbedFile, .Dynamic).init(gpa), | 1678 | .embed_file_work_queue = std.fifo.LinearFifo(*Module.EmbedFile, .Dynamic).init(gpa), |
| 1677 | .keep_source_files_loaded = options.keep_source_files_loaded, | 1679 | .keep_source_files_loaded = options.keep_source_files_loaded, |
| ... | @@ -1731,16 +1733,18 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1731,16 +1733,18 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1731 | } | 1733 | } |
| 1732 | | 1734 | |
| 1733 | // Add a `Win32Resource` for each `rc_source_files`. | 1735 | // Add a `Win32Resource` for each `rc_source_files`. |
| 1734 | try comp.win32_resource_table.ensureTotalCapacity(gpa, options.rc_source_files.len); | 1736 | if (!build_options.only_core_functionality) { |
| 1735 | for (options.rc_source_files) |rc_source_file| { | 1737 | try comp.win32_resource_table.ensureTotalCapacity(gpa, options.rc_source_files.len); |
| 1736 | const win32_resource = try gpa.create(Win32Resource); | 1738 | for (options.rc_source_files) |rc_source_file| { |
| 1737 | errdefer gpa.destroy(win32_resource); | 1739 | const win32_resource = try gpa.create(Win32Resource); |
| 1738 | | 1740 | errdefer gpa.destroy(win32_resource); |
| 1739 | win32_resource.* = .{ | 1741 | |
| 1740 | .status = .{ .new = {} }, | 1742 | win32_resource.* = .{ |
| 1741 | .src = rc_source_file, | 1743 | .status = .{ .new = {} }, |
| 1742 | }; | 1744 | .src = rc_source_file, |
| 1743 | comp.win32_resource_table.putAssumeCapacityNoClobber(win32_resource, {}); | 1745 | }; |
| | 1746 | comp.win32_resource_table.putAssumeCapacityNoClobber(win32_resource, {}); |
| | 1747 | } |
| 1744 | } | 1748 | } |
| 1745 | | 1749 | |
| 1746 | const have_bin_emit = comp.bin_file.options.emit != null or comp.whole_bin_sub_path != null; | 1750 | const have_bin_emit = comp.bin_file.options.emit != null or comp.whole_bin_sub_path != null; |
| ... | @@ -1900,7 +1904,9 @@ pub fn destroy(self: *Compilation) void { | ... | @@ -1900,7 +1904,9 @@ pub fn destroy(self: *Compilation) void { |
| 1900 | self.work_queue.deinit(); | 1904 | self.work_queue.deinit(); |
| 1901 | self.anon_work_queue.deinit(); | 1905 | self.anon_work_queue.deinit(); |
| 1902 | self.c_object_work_queue.deinit(); | 1906 | self.c_object_work_queue.deinit(); |
| 1903 | self.win32_resource_work_queue.deinit(); | 1907 | if (!build_options.only_core_functionality) { |
| | 1908 | self.win32_resource_work_queue.deinit(); |
| | 1909 | } |
| 1904 | self.astgen_work_queue.deinit(); | 1910 | self.astgen_work_queue.deinit(); |
| 1905 | self.embed_file_work_queue.deinit(); | 1911 | self.embed_file_work_queue.deinit(); |
| 1906 | | 1912 | |
| ... | @@ -1949,15 +1955,17 @@ pub fn destroy(self: *Compilation) void { | ... | @@ -1949,15 +1955,17 @@ pub fn destroy(self: *Compilation) void { |
| 1949 | } | 1955 | } |
| 1950 | self.failed_c_objects.deinit(gpa); | 1956 | self.failed_c_objects.deinit(gpa); |
| 1951 | | 1957 | |
| 1952 | for (self.win32_resource_table.keys()) |key| { | 1958 | if (!build_options.only_core_functionality) { |
| 1953 | key.destroy(gpa); | 1959 | for (self.win32_resource_table.keys()) |key| { |
| 1954 | } | 1960 | key.destroy(gpa); |
| 1955 | self.win32_resource_table.deinit(gpa); | 1961 | } |
| | 1962 | self.win32_resource_table.deinit(gpa); |
| 1956 | | 1963 | |
| 1957 | for (self.failed_win32_resources.values()) |*value| { | 1964 | for (self.failed_win32_resources.values()) |*value| { |
| 1958 | value.deinit(gpa); | 1965 | value.deinit(gpa); |
| | 1966 | } |
| | 1967 | self.failed_win32_resources.deinit(gpa); |
| 1959 | } | 1968 | } |
| 1960 | self.failed_win32_resources.deinit(gpa); | | |
| 1961 | | 1969 | |
| 1962 | for (self.lld_errors.items) |*lld_error| { | 1970 | for (self.lld_errors.items) |*lld_error| { |
| 1963 | lld_error.deinit(gpa); | 1971 | lld_error.deinit(gpa); |
| ... | @@ -2123,9 +2131,11 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void | ... | @@ -2123,9 +2131,11 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void |
| 2123 | | 2131 | |
| 2124 | // For compiling Win32 resources, we rely on the cache hash system to avoid duplicating work. | 2132 | // For compiling Win32 resources, we rely on the cache hash system to avoid duplicating work. |
| 2125 | // Add a Job for each Win32 resource file. | 2133 | // Add a Job for each Win32 resource file. |
| 2126 | try comp.win32_resource_work_queue.ensureUnusedCapacity(comp.win32_resource_table.count()); | 2134 | if (!build_options.only_core_functionality) { |
| 2127 | for (comp.win32_resource_table.keys()) |key| { | 2135 | try comp.win32_resource_work_queue.ensureUnusedCapacity(comp.win32_resource_table.count()); |
| 2128 | comp.win32_resource_work_queue.writeItemAssumeCapacity(key); | 2136 | for (comp.win32_resource_table.keys()) |key| { |
| | 2137 | comp.win32_resource_work_queue.writeItemAssumeCapacity(key); |
| | 2138 | } |
| 2129 | } | 2139 | } |
| 2130 | | 2140 | |
| 2131 | if (comp.bin_file.options.module) |module| { | 2141 | if (comp.bin_file.options.module) |module| { |
| ... | @@ -2450,9 +2460,11 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes | ... | @@ -2450,9 +2460,11 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes |
| 2450 | man.hash.addListOfBytes(key.src.extra_flags); | 2460 | man.hash.addListOfBytes(key.src.extra_flags); |
| 2451 | } | 2461 | } |
| 2452 | | 2462 | |
| 2453 | for (comp.win32_resource_table.keys()) |key| { | 2463 | if (!build_options.only_core_functionality) { |
| 2454 | _ = try man.addFile(key.src.src_path, null); | 2464 | for (comp.win32_resource_table.keys()) |key| { |
| 2455 | man.hash.addListOfBytes(key.src.extra_flags); | 2465 | _ = try man.addFile(key.src.src_path, null); |
| | 2466 | man.hash.addListOfBytes(key.src.extra_flags); |
| | 2467 | } |
| 2456 | } | 2468 | } |
| 2457 | | 2469 | |
| 2458 | man.hash.addListOfBytes(comp.rc_include_dir_list); | 2470 | man.hash.addListOfBytes(comp.rc_include_dir_list); |
| ... | @@ -2697,8 +2709,10 @@ pub fn totalErrorCount(self: *Compilation) u32 { | ... | @@ -2697,8 +2709,10 @@ pub fn totalErrorCount(self: *Compilation) u32 { |
| 2697 | @intFromBool(self.alloc_failure_occurred) + | 2709 | @intFromBool(self.alloc_failure_occurred) + |
| 2698 | self.lld_errors.items.len; | 2710 | self.lld_errors.items.len; |
| 2699 | | 2711 | |
| 2700 | for (self.failed_win32_resources.values()) |errs| { | 2712 | if (!build_options.only_core_functionality) { |
| 2701 | total += errs.errorMessageCount(); | 2713 | for (self.failed_win32_resources.values()) |errs| { |
| | 2714 | total += errs.errorMessageCount(); |
| | 2715 | } |
| 2702 | } | 2716 | } |
| 2703 | | 2717 | |
| 2704 | if (self.bin_file.options.module) |module| { | 2718 | if (self.bin_file.options.module) |module| { |
| ... | @@ -2791,7 +2805,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle { | ... | @@ -2791,7 +2805,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle { |
| 2791 | } | 2805 | } |
| 2792 | } | 2806 | } |
| 2793 | | 2807 | |
| 2794 | { | 2808 | if (!build_options.only_core_functionality) { |
| 2795 | var it = self.failed_win32_resources.iterator(); | 2809 | var it = self.failed_win32_resources.iterator(); |
| 2796 | while (it.next()) |entry| { | 2810 | while (it.next()) |entry| { |
| 2797 | try bundle.addBundleAsRoots(entry.value_ptr.*); | 2811 | try bundle.addBundleAsRoots(entry.value_ptr.*); |
| ... | @@ -3268,11 +3282,13 @@ pub fn performAllTheWork( | ... | @@ -3268,11 +3282,13 @@ pub fn performAllTheWork( |
| 3268 | }); | 3282 | }); |
| 3269 | } | 3283 | } |
| 3270 | | 3284 | |
| 3271 | while (comp.win32_resource_work_queue.readItem()) |win32_resource| { | 3285 | if (!build_options.only_core_functionality) { |
| 3272 | comp.work_queue_wait_group.start(); | 3286 | while (comp.win32_resource_work_queue.readItem()) |win32_resource| { |
| 3273 | try comp.thread_pool.spawn(workerUpdateWin32Resource, .{ | 3287 | comp.work_queue_wait_group.start(); |
| 3274 | comp, win32_resource, &win32_resource_prog_node, &comp.work_queue_wait_group, | 3288 | try comp.thread_pool.spawn(workerUpdateWin32Resource, .{ |
| 3275 | }); | 3289 | comp, win32_resource, &win32_resource_prog_node, &comp.work_queue_wait_group, |
| | 3290 | }); |
| | 3291 | } |
| 3276 | } | 3292 | } |
| 3277 | } | 3293 | } |
| 3278 | | 3294 | |