mirror of
https://github.com/ziglang/zig.git
synced 2026-02-03 13:13:40 +00:00
Merge pull request #25860 from squeek502/coalesce-to-std-zig
Move/coalesce `CompressDebugSections` and `RcIncludes` enums to `std.zig`
This commit is contained in:
commit
be4eaed7c4
@ -34,8 +34,7 @@ kind: Kind,
|
||||
major_only_filename: ?[]const u8,
|
||||
name_only_filename: ?[]const u8,
|
||||
formatted_panics: ?bool = null,
|
||||
// keep in sync with src/link.zig:CompressDebugSections
|
||||
compress_debug_sections: enum { none, zlib, zstd } = .none,
|
||||
compress_debug_sections: std.zig.CompressDebugSections = .none,
|
||||
verbose_link: bool,
|
||||
verbose_cc: bool,
|
||||
bundle_compiler_rt: ?bool = null,
|
||||
@ -67,13 +66,12 @@ installed_headers: std.array_list.Managed(HeaderInstallation),
|
||||
/// created otherwise.
|
||||
installed_headers_include_tree: ?*Step.WriteFile = null,
|
||||
|
||||
// keep in sync with src/Compilation.zig:RcIncludes
|
||||
/// Behavior of automatic detection of include directories when compiling .rc files.
|
||||
/// any: Use MSVC if available, fall back to MinGW.
|
||||
/// msvc: Use MSVC include paths (must be present on the system).
|
||||
/// gnu: Use MinGW include paths (distributed with Zig).
|
||||
/// none: Do not use any autodetected include paths.
|
||||
rc_includes: enum { any, msvc, gnu, none } = .any,
|
||||
rc_includes: std.zig.RcIncludes = .any,
|
||||
|
||||
/// (Windows) .manifest file to embed in the compilation
|
||||
/// Set via options; intended to be read-only after that.
|
||||
|
||||
@ -377,6 +377,19 @@ pub const Subsystem = enum {
|
||||
pub const EfiRuntimeDriver: Subsystem = .efi_runtime_driver;
|
||||
};
|
||||
|
||||
pub const CompressDebugSections = enum { none, zlib, zstd };
|
||||
|
||||
pub const RcIncludes = enum {
|
||||
/// Use MSVC if available, fall back to MinGW.
|
||||
any,
|
||||
/// Use MSVC include paths (MSVC install + Windows SDK, must be present on the system).
|
||||
msvc,
|
||||
/// Use MinGW include paths (distributed with Zig).
|
||||
gnu,
|
||||
/// Do not use any autodetected include paths.
|
||||
none,
|
||||
};
|
||||
|
||||
/// Renders a `std.Target.Cpu` value into a textual representation that can be parsed
|
||||
/// via the `-mcpu` flag passed to the Zig compiler.
|
||||
/// Appends the result to `buffer`.
|
||||
|
||||
@ -195,7 +195,7 @@ self_exe_path: ?[]const u8,
|
||||
dirs: Directories,
|
||||
libc_include_dir_list: []const []const u8,
|
||||
libc_framework_dir_list: []const []const u8,
|
||||
rc_includes: RcIncludes,
|
||||
rc_includes: std.zig.RcIncludes,
|
||||
mingw_unicode_entry_point: bool,
|
||||
thread_pool: *ThreadPool,
|
||||
|
||||
@ -954,17 +954,6 @@ pub const RcSourceFile = struct {
|
||||
extra_flags: []const []const u8 = &.{},
|
||||
};
|
||||
|
||||
pub const RcIncludes = enum {
|
||||
/// Use MSVC if available, fall back to MinGW.
|
||||
any,
|
||||
/// Use MSVC include paths (MSVC install + Windows SDK, must be present on the system).
|
||||
msvc,
|
||||
/// Use MinGW include paths (distributed with Zig).
|
||||
gnu,
|
||||
/// Do not use any autodetected include paths.
|
||||
none,
|
||||
};
|
||||
|
||||
const Job = union(enum) {
|
||||
/// Given the generated AIR for a function, put it onto the code generation queue.
|
||||
/// This `Job` exists (instead of the `link.ZcuTask` being directly queued) to ensure that
|
||||
@ -1680,7 +1669,7 @@ pub const CreateOptions = struct {
|
||||
c_source_files: []const CSourceFile = &.{},
|
||||
rc_source_files: []const RcSourceFile = &.{},
|
||||
manifest_file: ?[]const u8 = null,
|
||||
rc_includes: RcIncludes = .any,
|
||||
rc_includes: std.zig.RcIncludes = .any,
|
||||
link_inputs: []const link.Input = &.{},
|
||||
framework_dirs: []const []const u8 = &[0][]const u8{},
|
||||
frameworks: []const Framework = &.{},
|
||||
@ -1730,7 +1719,7 @@ pub const CreateOptions = struct {
|
||||
linker_tsaware: bool = false,
|
||||
linker_nxcompat: bool = false,
|
||||
linker_dynamicbase: bool = true,
|
||||
linker_compress_debug_sections: ?link.File.Lld.Elf.CompressDebugSections = null,
|
||||
linker_compress_debug_sections: ?std.zig.CompressDebugSections = null,
|
||||
linker_module_definition_file: ?[]const u8 = null,
|
||||
linker_sort_section: ?link.File.Lld.Elf.SortSection = null,
|
||||
major_subsystem_version: ?u16 = null,
|
||||
|
||||
@ -428,7 +428,7 @@ pub const File = struct {
|
||||
tsaware: bool,
|
||||
nxcompat: bool,
|
||||
dynamicbase: bool,
|
||||
compress_debug_sections: Lld.Elf.CompressDebugSections,
|
||||
compress_debug_sections: std.zig.CompressDebugSections,
|
||||
bind_global_refs_locally: bool,
|
||||
import_symbols: bool,
|
||||
import_table: bool,
|
||||
|
||||
@ -95,11 +95,12 @@ pub const Elf = struct {
|
||||
soname: ?[]const u8,
|
||||
allow_undefined_version: bool,
|
||||
enable_new_dtags: ?bool,
|
||||
compress_debug_sections: CompressDebugSections,
|
||||
compress_debug_sections: std.zig.CompressDebugSections,
|
||||
bind_global_refs_locally: bool,
|
||||
pub const HashStyle = enum { sysv, gnu, both };
|
||||
pub const SortSection = enum { name, alignment };
|
||||
pub const CompressDebugSections = enum { none, zlib, zstd };
|
||||
/// Deprecated; use 'std.zig.CompressDebugSections' instead. To be removed after 0.16.0 is tagged.
|
||||
pub const CompressDebugSections = std.zig.CompressDebugSections;
|
||||
|
||||
fn init(comp: *Compilation, options: link.File.OpenOptions) !Elf {
|
||||
const PtrWidth = enum { p32, p64 };
|
||||
|
||||
16
src/main.zig
16
src/main.zig
@ -850,7 +850,7 @@ fn buildOutputType(
|
||||
var disable_c_depfile = false;
|
||||
var linker_sort_section: ?link.File.Lld.Elf.SortSection = null;
|
||||
var linker_gc_sections: ?bool = null;
|
||||
var linker_compress_debug_sections: ?link.File.Lld.Elf.CompressDebugSections = null;
|
||||
var linker_compress_debug_sections: ?std.zig.CompressDebugSections = null;
|
||||
var linker_allow_shlib_undefined: ?bool = null;
|
||||
var allow_so_scripts: bool = false;
|
||||
var linker_bind_global_refs_locally: ?bool = null;
|
||||
@ -918,7 +918,7 @@ fn buildOutputType(
|
||||
var extra_cflags: std.ArrayListUnmanaged([]const u8) = .empty;
|
||||
var extra_rcflags: std.ArrayListUnmanaged([]const u8) = .empty;
|
||||
var symbol_wrap_set: std.StringArrayHashMapUnmanaged(void) = .empty;
|
||||
var rc_includes: Compilation.RcIncludes = .any;
|
||||
var rc_includes: std.zig.RcIncludes = .any;
|
||||
var manifest_file: ?[]const u8 = null;
|
||||
var linker_export_symbol_names: std.ArrayListUnmanaged([]const u8) = .empty;
|
||||
|
||||
@ -1167,11 +1167,11 @@ fn buildOutputType(
|
||||
} else if (mem.eql(u8, arg, "-install_name")) {
|
||||
install_name = args_iter.nextOrFatal();
|
||||
} else if (mem.cutPrefix(u8, arg, "--compress-debug-sections=")) |param| {
|
||||
linker_compress_debug_sections = std.meta.stringToEnum(link.File.Lld.Elf.CompressDebugSections, param) orelse {
|
||||
linker_compress_debug_sections = std.meta.stringToEnum(std.zig.CompressDebugSections, param) orelse {
|
||||
fatal("expected --compress-debug-sections=[none|zlib|zstd], found '{s}'", .{param});
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--compress-debug-sections")) {
|
||||
linker_compress_debug_sections = link.File.Lld.Elf.CompressDebugSections.zlib;
|
||||
linker_compress_debug_sections = .zlib;
|
||||
} else if (mem.eql(u8, arg, "-pagezero_size")) {
|
||||
const next_arg = args_iter.nextOrFatal();
|
||||
pagezero_size = std.fmt.parseUnsigned(u64, eatIntPrefix(next_arg, 16), 16) catch |err| {
|
||||
@ -2335,7 +2335,7 @@ fn buildOutputType(
|
||||
if (it.only_arg.len == 0) {
|
||||
linker_compress_debug_sections = .zlib;
|
||||
} else {
|
||||
linker_compress_debug_sections = std.meta.stringToEnum(link.File.Lld.Elf.CompressDebugSections, it.only_arg) orelse {
|
||||
linker_compress_debug_sections = std.meta.stringToEnum(std.zig.CompressDebugSections, it.only_arg) orelse {
|
||||
fatal("expected [none|zlib|zstd] after --compress-debug-sections, found '{s}'", .{it.only_arg});
|
||||
};
|
||||
}
|
||||
@ -2523,7 +2523,7 @@ fn buildOutputType(
|
||||
try linker_export_symbol_names.append(arena, linker_args_it.nextOrFatal());
|
||||
} else if (mem.eql(u8, arg, "--compress-debug-sections")) {
|
||||
const arg1 = linker_args_it.nextOrFatal();
|
||||
linker_compress_debug_sections = std.meta.stringToEnum(link.File.Lld.Elf.CompressDebugSections, arg1) orelse {
|
||||
linker_compress_debug_sections = std.meta.stringToEnum(std.zig.CompressDebugSections, arg1) orelse {
|
||||
fatal("expected [none|zlib|zstd] after --compress-debug-sections, found '{s}'", .{arg1});
|
||||
};
|
||||
} else if (mem.cutPrefix(u8, arg, "-z")) |z_rest| {
|
||||
@ -6787,8 +6787,8 @@ fn accessFrameworkPath(
|
||||
return false;
|
||||
}
|
||||
|
||||
fn parseRcIncludes(arg: []const u8) Compilation.RcIncludes {
|
||||
return std.meta.stringToEnum(Compilation.RcIncludes, arg) orelse
|
||||
fn parseRcIncludes(arg: []const u8) std.zig.RcIncludes {
|
||||
return std.meta.stringToEnum(std.zig.RcIncludes, arg) orelse
|
||||
fatal("unsupported rc includes type: '{s}'", .{arg});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user