authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-11-08 02:34:44-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-11-08 02:34:44-08:00
logbe4eaed7c41fb194014d862648ff586797e39e84
tree0125e7d1e36f1b5b342fbbb5901ddc2650b6267b
parent43eb9b52ccac894023800115e8395cdb413be14a
parentda77d306b637f9ecd4ad4657978b22063c9ecf1d
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #25860 from squeek502/coalesce-to-std-zig

Move/coalesce `CompressDebugSections` and `RcIncludes` enums to `std.zig`

6 files changed, 30 insertions(+), 29 deletions(-)

lib/std/Build/Step/Compile.zig+2-4
...@@ -34,8 +34,7 @@ kind: Kind,...@@ -34,8 +34,7 @@ kind: Kind,
34major_only_filename: ?[]const u8,34major_only_filename: ?[]const u8,
35name_only_filename: ?[]const u8,35name_only_filename: ?[]const u8,
36formatted_panics: ?bool = null,36formatted_panics: ?bool = null,
37// keep in sync with src/link.zig:CompressDebugSections37compress_debug_sections: std.zig.CompressDebugSections = .none,
38compress_debug_sections: enum { none, zlib, zstd } = .none,
39verbose_link: bool,38verbose_link: bool,
40verbose_cc: bool,39verbose_cc: bool,
41bundle_compiler_rt: ?bool = null,40bundle_compiler_rt: ?bool = null,
...@@ -67,13 +66,12 @@ installed_headers: std.array_list.Managed(HeaderInstallation),...@@ -67,13 +66,12 @@ installed_headers: std.array_list.Managed(HeaderInstallation),
67/// created otherwise.66/// created otherwise.
68installed_headers_include_tree: ?*Step.WriteFile = null,67installed_headers_include_tree: ?*Step.WriteFile = null,
6968
70// keep in sync with src/Compilation.zig:RcIncludes
71/// Behavior of automatic detection of include directories when compiling .rc files.69/// Behavior of automatic detection of include directories when compiling .rc files.
72/// any: Use MSVC if available, fall back to MinGW.70/// any: Use MSVC if available, fall back to MinGW.
73/// msvc: Use MSVC include paths (must be present on the system).71/// msvc: Use MSVC include paths (must be present on the system).
74/// gnu: Use MinGW include paths (distributed with Zig).72/// gnu: Use MinGW include paths (distributed with Zig).
75/// none: Do not use any autodetected include paths.73/// none: Do not use any autodetected include paths.
76rc_includes: enum { any, msvc, gnu, none } = .any,74rc_includes: std.zig.RcIncludes = .any,
7775
78/// (Windows) .manifest file to embed in the compilation76/// (Windows) .manifest file to embed in the compilation
79/// Set via options; intended to be read-only after that.77/// Set via options; intended to be read-only after that.
lib/std/zig.zig+13
...@@ -377,6 +377,19 @@ pub const Subsystem = enum {...@@ -377,6 +377,19 @@ pub const Subsystem = enum {
377 pub const EfiRuntimeDriver: Subsystem = .efi_runtime_driver;377 pub const EfiRuntimeDriver: Subsystem = .efi_runtime_driver;
378};378};
379379
380pub const CompressDebugSections = enum { none, zlib, zstd };
381
382pub const RcIncludes = enum {
383 /// Use MSVC if available, fall back to MinGW.
384 any,
385 /// Use MSVC include paths (MSVC install + Windows SDK, must be present on the system).
386 msvc,
387 /// Use MinGW include paths (distributed with Zig).
388 gnu,
389 /// Do not use any autodetected include paths.
390 none,
391};
392
380/// Renders a `std.Target.Cpu` value into a textual representation that can be parsed393/// Renders a `std.Target.Cpu` value into a textual representation that can be parsed
381/// via the `-mcpu` flag passed to the Zig compiler.394/// via the `-mcpu` flag passed to the Zig compiler.
382/// Appends the result to `buffer`.395/// Appends the result to `buffer`.
src/Compilation.zig+3-14
...@@ -195,7 +195,7 @@ self_exe_path: ?[]const u8,...@@ -195,7 +195,7 @@ self_exe_path: ?[]const u8,
195dirs: Directories,195dirs: Directories,
196libc_include_dir_list: []const []const u8,196libc_include_dir_list: []const []const u8,
197libc_framework_dir_list: []const []const u8,197libc_framework_dir_list: []const []const u8,
198rc_includes: RcIncludes,198rc_includes: std.zig.RcIncludes,
199mingw_unicode_entry_point: bool,199mingw_unicode_entry_point: bool,
200thread_pool: *ThreadPool,200thread_pool: *ThreadPool,
201201
...@@ -954,17 +954,6 @@ pub const RcSourceFile = struct {...@@ -954,17 +954,6 @@ pub const RcSourceFile = struct {
954 extra_flags: []const []const u8 = &.{},954 extra_flags: []const []const u8 = &.{},
955};955};
956956
957pub const RcIncludes = enum {
958 /// Use MSVC if available, fall back to MinGW.
959 any,
960 /// Use MSVC include paths (MSVC install + Windows SDK, must be present on the system).
961 msvc,
962 /// Use MinGW include paths (distributed with Zig).
963 gnu,
964 /// Do not use any autodetected include paths.
965 none,
966};
967
968const Job = union(enum) {957const Job = union(enum) {
969 /// Given the generated AIR for a function, put it onto the code generation queue.958 /// Given the generated AIR for a function, put it onto the code generation queue.
970 /// This `Job` exists (instead of the `link.ZcuTask` being directly queued) to ensure that959 /// This `Job` exists (instead of the `link.ZcuTask` being directly queued) to ensure that
...@@ -1680,7 +1669,7 @@ pub const CreateOptions = struct {...@@ -1680,7 +1669,7 @@ pub const CreateOptions = struct {
1680 c_source_files: []const CSourceFile = &.{},1669 c_source_files: []const CSourceFile = &.{},
1681 rc_source_files: []const RcSourceFile = &.{},1670 rc_source_files: []const RcSourceFile = &.{},
1682 manifest_file: ?[]const u8 = null,1671 manifest_file: ?[]const u8 = null,
1683 rc_includes: RcIncludes = .any,1672 rc_includes: std.zig.RcIncludes = .any,
1684 link_inputs: []const link.Input = &.{},1673 link_inputs: []const link.Input = &.{},
1685 framework_dirs: []const []const u8 = &[0][]const u8{},1674 framework_dirs: []const []const u8 = &[0][]const u8{},
1686 frameworks: []const Framework = &.{},1675 frameworks: []const Framework = &.{},
...@@ -1730,7 +1719,7 @@ pub const CreateOptions = struct {...@@ -1730,7 +1719,7 @@ pub const CreateOptions = struct {
1730 linker_tsaware: bool = false,1719 linker_tsaware: bool = false,
1731 linker_nxcompat: bool = false,1720 linker_nxcompat: bool = false,
1732 linker_dynamicbase: bool = true,1721 linker_dynamicbase: bool = true,
1733 linker_compress_debug_sections: ?link.File.Lld.Elf.CompressDebugSections = null,1722 linker_compress_debug_sections: ?std.zig.CompressDebugSections = null,
1734 linker_module_definition_file: ?[]const u8 = null,1723 linker_module_definition_file: ?[]const u8 = null,
1735 linker_sort_section: ?link.File.Lld.Elf.SortSection = null,1724 linker_sort_section: ?link.File.Lld.Elf.SortSection = null,
1736 major_subsystem_version: ?u16 = null,1725 major_subsystem_version: ?u16 = null,
src/link.zig+1-1
...@@ -428,7 +428,7 @@ pub const File = struct {...@@ -428,7 +428,7 @@ pub const File = struct {
428 tsaware: bool,428 tsaware: bool,
429 nxcompat: bool,429 nxcompat: bool,
430 dynamicbase: bool,430 dynamicbase: bool,
431 compress_debug_sections: Lld.Elf.CompressDebugSections,431 compress_debug_sections: std.zig.CompressDebugSections,
432 bind_global_refs_locally: bool,432 bind_global_refs_locally: bool,
433 import_symbols: bool,433 import_symbols: bool,
434 import_table: bool,434 import_table: bool,
src/link/Lld.zig+3-2
...@@ -95,11 +95,12 @@ pub const Elf = struct {...@@ -95,11 +95,12 @@ pub const Elf = struct {
95 soname: ?[]const u8,95 soname: ?[]const u8,
96 allow_undefined_version: bool,96 allow_undefined_version: bool,
97 enable_new_dtags: ?bool,97 enable_new_dtags: ?bool,
98 compress_debug_sections: CompressDebugSections,98 compress_debug_sections: std.zig.CompressDebugSections,
99 bind_global_refs_locally: bool,99 bind_global_refs_locally: bool,
100 pub const HashStyle = enum { sysv, gnu, both };100 pub const HashStyle = enum { sysv, gnu, both };
101 pub const SortSection = enum { name, alignment };101 pub const SortSection = enum { name, alignment };
102 pub const CompressDebugSections = enum { none, zlib, zstd };102 /// Deprecated; use 'std.zig.CompressDebugSections' instead. To be removed after 0.16.0 is tagged.
103 pub const CompressDebugSections = std.zig.CompressDebugSections;
103104
104 fn init(comp: *Compilation, options: link.File.OpenOptions) !Elf {105 fn init(comp: *Compilation, options: link.File.OpenOptions) !Elf {
105 const PtrWidth = enum { p32, p64 };106 const PtrWidth = enum { p32, p64 };
src/main.zig+8-8
...@@ -850,7 +850,7 @@ fn buildOutputType(...@@ -850,7 +850,7 @@ fn buildOutputType(
850 var disable_c_depfile = false;850 var disable_c_depfile = false;
851 var linker_sort_section: ?link.File.Lld.Elf.SortSection = null;851 var linker_sort_section: ?link.File.Lld.Elf.SortSection = null;
852 var linker_gc_sections: ?bool = null;852 var linker_gc_sections: ?bool = null;
853 var linker_compress_debug_sections: ?link.File.Lld.Elf.CompressDebugSections = null;853 var linker_compress_debug_sections: ?std.zig.CompressDebugSections = null;
854 var linker_allow_shlib_undefined: ?bool = null;854 var linker_allow_shlib_undefined: ?bool = null;
855 var allow_so_scripts: bool = false;855 var allow_so_scripts: bool = false;
856 var linker_bind_global_refs_locally: ?bool = null;856 var linker_bind_global_refs_locally: ?bool = null;
...@@ -918,7 +918,7 @@ fn buildOutputType(...@@ -918,7 +918,7 @@ fn buildOutputType(
918 var extra_cflags: std.ArrayListUnmanaged([]const u8) = .empty;918 var extra_cflags: std.ArrayListUnmanaged([]const u8) = .empty;
919 var extra_rcflags: std.ArrayListUnmanaged([]const u8) = .empty;919 var extra_rcflags: std.ArrayListUnmanaged([]const u8) = .empty;
920 var symbol_wrap_set: std.StringArrayHashMapUnmanaged(void) = .empty;920 var symbol_wrap_set: std.StringArrayHashMapUnmanaged(void) = .empty;
921 var rc_includes: Compilation.RcIncludes = .any;921 var rc_includes: std.zig.RcIncludes = .any;
922 var manifest_file: ?[]const u8 = null;922 var manifest_file: ?[]const u8 = null;
923 var linker_export_symbol_names: std.ArrayListUnmanaged([]const u8) = .empty;923 var linker_export_symbol_names: std.ArrayListUnmanaged([]const u8) = .empty;
924924
...@@ -1167,11 +1167,11 @@ fn buildOutputType(...@@ -1167,11 +1167,11 @@ fn buildOutputType(
1167 } else if (mem.eql(u8, arg, "-install_name")) {1167 } else if (mem.eql(u8, arg, "-install_name")) {
1168 install_name = args_iter.nextOrFatal();1168 install_name = args_iter.nextOrFatal();
1169 } else if (mem.cutPrefix(u8, arg, "--compress-debug-sections=")) |param| {1169 } else if (mem.cutPrefix(u8, arg, "--compress-debug-sections=")) |param| {
1170 linker_compress_debug_sections = std.meta.stringToEnum(link.File.Lld.Elf.CompressDebugSections, param) orelse {1170 linker_compress_debug_sections = std.meta.stringToEnum(std.zig.CompressDebugSections, param) orelse {
1171 fatal("expected --compress-debug-sections=[none|zlib|zstd], found '{s}'", .{param});1171 fatal("expected --compress-debug-sections=[none|zlib|zstd], found '{s}'", .{param});
1172 };1172 };
1173 } else if (mem.eql(u8, arg, "--compress-debug-sections")) {1173 } else if (mem.eql(u8, arg, "--compress-debug-sections")) {
1174 linker_compress_debug_sections = link.File.Lld.Elf.CompressDebugSections.zlib;1174 linker_compress_debug_sections = .zlib;
1175 } else if (mem.eql(u8, arg, "-pagezero_size")) {1175 } else if (mem.eql(u8, arg, "-pagezero_size")) {
1176 const next_arg = args_iter.nextOrFatal();1176 const next_arg = args_iter.nextOrFatal();
1177 pagezero_size = std.fmt.parseUnsigned(u64, eatIntPrefix(next_arg, 16), 16) catch |err| {1177 pagezero_size = std.fmt.parseUnsigned(u64, eatIntPrefix(next_arg, 16), 16) catch |err| {
...@@ -2335,7 +2335,7 @@ fn buildOutputType(...@@ -2335,7 +2335,7 @@ fn buildOutputType(
2335 if (it.only_arg.len == 0) {2335 if (it.only_arg.len == 0) {
2336 linker_compress_debug_sections = .zlib;2336 linker_compress_debug_sections = .zlib;
2337 } else {2337 } else {
2338 linker_compress_debug_sections = std.meta.stringToEnum(link.File.Lld.Elf.CompressDebugSections, it.only_arg) orelse {2338 linker_compress_debug_sections = std.meta.stringToEnum(std.zig.CompressDebugSections, it.only_arg) orelse {
2339 fatal("expected [none|zlib|zstd] after --compress-debug-sections, found '{s}'", .{it.only_arg});2339 fatal("expected [none|zlib|zstd] after --compress-debug-sections, found '{s}'", .{it.only_arg});
2340 };2340 };
2341 }2341 }
...@@ -2523,7 +2523,7 @@ fn buildOutputType(...@@ -2523,7 +2523,7 @@ fn buildOutputType(
2523 try linker_export_symbol_names.append(arena, linker_args_it.nextOrFatal());2523 try linker_export_symbol_names.append(arena, linker_args_it.nextOrFatal());
2524 } else if (mem.eql(u8, arg, "--compress-debug-sections")) {2524 } else if (mem.eql(u8, arg, "--compress-debug-sections")) {
2525 const arg1 = linker_args_it.nextOrFatal();2525 const arg1 = linker_args_it.nextOrFatal();
2526 linker_compress_debug_sections = std.meta.stringToEnum(link.File.Lld.Elf.CompressDebugSections, arg1) orelse {2526 linker_compress_debug_sections = std.meta.stringToEnum(std.zig.CompressDebugSections, arg1) orelse {
2527 fatal("expected [none|zlib|zstd] after --compress-debug-sections, found '{s}'", .{arg1});2527 fatal("expected [none|zlib|zstd] after --compress-debug-sections, found '{s}'", .{arg1});
2528 };2528 };
2529 } else if (mem.cutPrefix(u8, arg, "-z")) |z_rest| {2529 } else if (mem.cutPrefix(u8, arg, "-z")) |z_rest| {
...@@ -6787,8 +6787,8 @@ fn accessFrameworkPath(...@@ -6787,8 +6787,8 @@ fn accessFrameworkPath(
6787 return false;6787 return false;
6788}6788}
67896789
6790fn parseRcIncludes(arg: []const u8) Compilation.RcIncludes {6790fn parseRcIncludes(arg: []const u8) std.zig.RcIncludes {
6791 return std.meta.stringToEnum(Compilation.RcIncludes, arg) orelse6791 return std.meta.stringToEnum(std.zig.RcIncludes, arg) orelse
6792 fatal("unsupported rc includes type: '{s}'", .{arg});6792 fatal("unsupported rc includes type: '{s}'", .{arg});
6793}6793}
67946794