mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 08:33:06 +00:00
remove 'pe' object format
Portable Executable is an executable format, not an object format. Everywhere in the entire zig codebase, we treated coff and pe as if they were the same. Remove confusion by not including pe in the std.Target.ObjectFormat enum.
This commit is contained in:
parent
26984852bd
commit
36295d712f
@ -550,7 +550,6 @@ pub const Target = struct {
|
||||
|
||||
pub const ObjectFormat = enum {
|
||||
coff,
|
||||
pe,
|
||||
elf,
|
||||
macho,
|
||||
wasm,
|
||||
|
@ -109,7 +109,7 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro
|
||||
const root_name = options.root_name;
|
||||
const target = options.target;
|
||||
switch (options.object_format orelse target.getObjectFormat()) {
|
||||
.coff, .pe => switch (options.output_mode) {
|
||||
.coff => switch (options.output_mode) {
|
||||
.Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, target.exeFileExt() }),
|
||||
.Lib => {
|
||||
const suffix = switch (options.link_mode orelse .Static) {
|
||||
|
@ -3023,7 +3023,7 @@ pub fn addCCArgs(
|
||||
if (!comp.bin_file.options.strip) {
|
||||
try argv.append("-g");
|
||||
switch (comp.bin_file.options.object_format) {
|
||||
.coff, .pe => try argv.append("-gcodeview"),
|
||||
.coff => try argv.append("-gcodeview"),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ pub const File = struct {
|
||||
const use_stage1 = build_options.is_stage1 and options.use_stage1;
|
||||
if (use_stage1 or options.emit == null) {
|
||||
return switch (options.object_format) {
|
||||
.coff, .pe => &(try Coff.createEmpty(allocator, options)).base,
|
||||
.coff => &(try Coff.createEmpty(allocator, options)).base,
|
||||
.elf => &(try Elf.createEmpty(allocator, options)).base,
|
||||
.macho => &(try MachO.createEmpty(allocator, options)).base,
|
||||
.wasm => &(try Wasm.createEmpty(allocator, options)).base,
|
||||
@ -208,7 +208,7 @@ pub const File = struct {
|
||||
if (options.module == null) {
|
||||
// No point in opening a file, we would not write anything to it. Initialize with empty.
|
||||
return switch (options.object_format) {
|
||||
.coff, .pe => &(try Coff.createEmpty(allocator, options)).base,
|
||||
.coff => &(try Coff.createEmpty(allocator, options)).base,
|
||||
.elf => &(try Elf.createEmpty(allocator, options)).base,
|
||||
.macho => &(try MachO.createEmpty(allocator, options)).base,
|
||||
.plan9 => &(try Plan9.createEmpty(allocator, options)).base,
|
||||
@ -225,7 +225,7 @@ pub const File = struct {
|
||||
errdefer if (use_lld) allocator.free(sub_path);
|
||||
|
||||
const file: *File = switch (options.object_format) {
|
||||
.coff, .pe => &(try Coff.openPath(allocator, sub_path, options)).base,
|
||||
.coff => &(try Coff.openPath(allocator, sub_path, options)).base,
|
||||
.elf => &(try Elf.openPath(allocator, sub_path, options)).base,
|
||||
.macho => &(try MachO.openPath(allocator, sub_path, options)).base,
|
||||
.plan9 => &(try Plan9.openPath(allocator, sub_path, options)).base,
|
||||
|
@ -657,10 +657,7 @@ fn writeOffsetTableEntry(self: *Coff, index: usize) !void {
|
||||
}
|
||||
|
||||
pub fn updateFunc(self: *Coff, module: *Module, func: *Module.Fn, air: Air, liveness: Liveness) !void {
|
||||
if (build_options.skip_non_native and
|
||||
builtin.object_format != .coff and
|
||||
builtin.object_format != .pe)
|
||||
{
|
||||
if (build_options.skip_non_native and builtin.object_format != .coff) {
|
||||
@panic("Attempted to compile for object format that was disabled by build configuration");
|
||||
}
|
||||
if (build_options.have_llvm) {
|
||||
@ -697,7 +694,7 @@ pub fn updateFunc(self: *Coff, module: *Module, func: *Module.Fn, air: Air, live
|
||||
}
|
||||
|
||||
pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void {
|
||||
if (build_options.skip_non_native and builtin.object_format != .coff and builtin.object_format != .pe) {
|
||||
if (build_options.skip_non_native and builtin.object_format != .coff) {
|
||||
@panic("Attempted to compile for object format that was disabled by build configuration");
|
||||
}
|
||||
if (build_options.have_llvm) {
|
||||
|
20
src/main.zig
20
src/main.zig
@ -287,9 +287,9 @@ const usage_build_generic =
|
||||
\\ .s Target-specific assembly source code
|
||||
\\ .S Assembly with C preprocessor (requires LLVM extensions)
|
||||
\\ .c C source code (requires LLVM extensions)
|
||||
\\ .cpp C++ source code (requires LLVM extensions)
|
||||
\\ Other C++ extensions: .C .cc .cxx
|
||||
\\ .cxx .cc .C .cpp C++ source code (requires LLVM extensions)
|
||||
\\ .m Objective-C source code (requires LLVM extensions)
|
||||
\\ .bc LLVM IR Module (requires LLVM extensions)
|
||||
\\
|
||||
\\General Options:
|
||||
\\ -h, --help Print this help and exit
|
||||
@ -361,13 +361,12 @@ const usage_build_generic =
|
||||
\\ elf Executable and Linking Format
|
||||
\\ c Compile to C source code
|
||||
\\ wasm WebAssembly
|
||||
\\ pe Portable Executable (Windows)
|
||||
\\ coff Common Object File Format (Windows)
|
||||
\\ macho macOS relocatables
|
||||
\\ spirv Standard, Portable Intermediate Representation V (SPIR-V)
|
||||
\\ plan9 Plan 9 from Bell Labs object format
|
||||
\\ hex (planned) Intel IHEX
|
||||
\\ raw (planned) Dump machine code directly
|
||||
\\ hex (planned feature) Intel IHEX
|
||||
\\ raw (planned feature) Dump machine code directly
|
||||
\\ -dirafter [dir] Add directory to AFTER include search path
|
||||
\\ -isystem [dir] Add directory to SYSTEM include search path
|
||||
\\ -I[dir] Add directory to include search path
|
||||
@ -1708,8 +1707,6 @@ fn buildOutputType(
|
||||
break :blk .c;
|
||||
} else if (mem.eql(u8, ofmt, "coff")) {
|
||||
break :blk .coff;
|
||||
} else if (mem.eql(u8, ofmt, "pe")) {
|
||||
break :blk .pe;
|
||||
} else if (mem.eql(u8, ofmt, "macho")) {
|
||||
break :blk .macho;
|
||||
} else if (mem.eql(u8, ofmt, "wasm")) {
|
||||
@ -1753,7 +1750,7 @@ fn buildOutputType(
|
||||
};
|
||||
|
||||
const a_out_basename = switch (object_format) {
|
||||
.pe, .coff => "a.exe",
|
||||
.coff => "a.exe",
|
||||
else => "a.out",
|
||||
};
|
||||
|
||||
@ -2396,11 +2393,8 @@ fn updateModule(gpa: *Allocator, comp: *Compilation, hook: AfterUpdateHook) !voi
|
||||
|
||||
// If a .pdb file is part of the expected output, we must also copy
|
||||
// it into place here.
|
||||
const coff_or_pe = switch (comp.bin_file.options.object_format) {
|
||||
.coff, .pe => true,
|
||||
else => false,
|
||||
};
|
||||
const have_pdb = coff_or_pe and !comp.bin_file.options.strip;
|
||||
const is_coff = comp.bin_file.options.object_format == .coff;
|
||||
const have_pdb = is_coff and !comp.bin_file.options.strip;
|
||||
if (have_pdb) {
|
||||
// Replace `.out` or `.exe` with `.pdb` on both the source and destination
|
||||
const src_bin_ext = fs.path.extension(bin_sub_path);
|
||||
|
Loading…
Reference in New Issue
Block a user