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 {
|
pub const ObjectFormat = enum {
|
||||||
coff,
|
coff,
|
||||||
pe,
|
|
||||||
elf,
|
elf,
|
||||||
macho,
|
macho,
|
||||||
wasm,
|
wasm,
|
||||||
|
@ -109,7 +109,7 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro
|
|||||||
const root_name = options.root_name;
|
const root_name = options.root_name;
|
||||||
const target = options.target;
|
const target = options.target;
|
||||||
switch (options.object_format orelse target.getObjectFormat()) {
|
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() }),
|
.Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, target.exeFileExt() }),
|
||||||
.Lib => {
|
.Lib => {
|
||||||
const suffix = switch (options.link_mode orelse .Static) {
|
const suffix = switch (options.link_mode orelse .Static) {
|
||||||
|
@ -3023,7 +3023,7 @@ pub fn addCCArgs(
|
|||||||
if (!comp.bin_file.options.strip) {
|
if (!comp.bin_file.options.strip) {
|
||||||
try argv.append("-g");
|
try argv.append("-g");
|
||||||
switch (comp.bin_file.options.object_format) {
|
switch (comp.bin_file.options.object_format) {
|
||||||
.coff, .pe => try argv.append("-gcodeview"),
|
.coff => try argv.append("-gcodeview"),
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ pub const File = struct {
|
|||||||
const use_stage1 = build_options.is_stage1 and options.use_stage1;
|
const use_stage1 = build_options.is_stage1 and options.use_stage1;
|
||||||
if (use_stage1 or options.emit == null) {
|
if (use_stage1 or options.emit == null) {
|
||||||
return switch (options.object_format) {
|
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,
|
.elf => &(try Elf.createEmpty(allocator, options)).base,
|
||||||
.macho => &(try MachO.createEmpty(allocator, options)).base,
|
.macho => &(try MachO.createEmpty(allocator, options)).base,
|
||||||
.wasm => &(try Wasm.createEmpty(allocator, options)).base,
|
.wasm => &(try Wasm.createEmpty(allocator, options)).base,
|
||||||
@ -208,7 +208,7 @@ pub const File = struct {
|
|||||||
if (options.module == null) {
|
if (options.module == null) {
|
||||||
// No point in opening a file, we would not write anything to it. Initialize with empty.
|
// No point in opening a file, we would not write anything to it. Initialize with empty.
|
||||||
return switch (options.object_format) {
|
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,
|
.elf => &(try Elf.createEmpty(allocator, options)).base,
|
||||||
.macho => &(try MachO.createEmpty(allocator, options)).base,
|
.macho => &(try MachO.createEmpty(allocator, options)).base,
|
||||||
.plan9 => &(try Plan9.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);
|
errdefer if (use_lld) allocator.free(sub_path);
|
||||||
|
|
||||||
const file: *File = switch (options.object_format) {
|
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,
|
.elf => &(try Elf.openPath(allocator, sub_path, options)).base,
|
||||||
.macho => &(try MachO.openPath(allocator, sub_path, options)).base,
|
.macho => &(try MachO.openPath(allocator, sub_path, options)).base,
|
||||||
.plan9 => &(try Plan9.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 {
|
pub fn updateFunc(self: *Coff, module: *Module, func: *Module.Fn, air: Air, liveness: Liveness) !void {
|
||||||
if (build_options.skip_non_native and
|
if (build_options.skip_non_native and builtin.object_format != .coff) {
|
||||||
builtin.object_format != .coff and
|
|
||||||
builtin.object_format != .pe)
|
|
||||||
{
|
|
||||||
@panic("Attempted to compile for object format that was disabled by build configuration");
|
@panic("Attempted to compile for object format that was disabled by build configuration");
|
||||||
}
|
}
|
||||||
if (build_options.have_llvm) {
|
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 {
|
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");
|
@panic("Attempted to compile for object format that was disabled by build configuration");
|
||||||
}
|
}
|
||||||
if (build_options.have_llvm) {
|
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 Target-specific assembly source code
|
||||||
\\ .S Assembly with C preprocessor (requires LLVM extensions)
|
\\ .S Assembly with C preprocessor (requires LLVM extensions)
|
||||||
\\ .c C source code (requires LLVM extensions)
|
\\ .c C source code (requires LLVM extensions)
|
||||||
\\ .cpp C++ source code (requires LLVM extensions)
|
\\ .cxx .cc .C .cpp C++ source code (requires LLVM extensions)
|
||||||
\\ Other C++ extensions: .C .cc .cxx
|
|
||||||
\\ .m Objective-C source code (requires LLVM extensions)
|
\\ .m Objective-C source code (requires LLVM extensions)
|
||||||
|
\\ .bc LLVM IR Module (requires LLVM extensions)
|
||||||
\\
|
\\
|
||||||
\\General Options:
|
\\General Options:
|
||||||
\\ -h, --help Print this help and exit
|
\\ -h, --help Print this help and exit
|
||||||
@ -361,13 +361,12 @@ const usage_build_generic =
|
|||||||
\\ elf Executable and Linking Format
|
\\ elf Executable and Linking Format
|
||||||
\\ c Compile to C source code
|
\\ c Compile to C source code
|
||||||
\\ wasm WebAssembly
|
\\ wasm WebAssembly
|
||||||
\\ pe Portable Executable (Windows)
|
|
||||||
\\ coff Common Object File Format (Windows)
|
\\ coff Common Object File Format (Windows)
|
||||||
\\ macho macOS relocatables
|
\\ macho macOS relocatables
|
||||||
\\ spirv Standard, Portable Intermediate Representation V (SPIR-V)
|
\\ spirv Standard, Portable Intermediate Representation V (SPIR-V)
|
||||||
\\ plan9 Plan 9 from Bell Labs object format
|
\\ plan9 Plan 9 from Bell Labs object format
|
||||||
\\ hex (planned) Intel IHEX
|
\\ hex (planned feature) Intel IHEX
|
||||||
\\ raw (planned) Dump machine code directly
|
\\ raw (planned feature) Dump machine code directly
|
||||||
\\ -dirafter [dir] Add directory to AFTER include search path
|
\\ -dirafter [dir] Add directory to AFTER include search path
|
||||||
\\ -isystem [dir] Add directory to SYSTEM include search path
|
\\ -isystem [dir] Add directory to SYSTEM include search path
|
||||||
\\ -I[dir] Add directory to include search path
|
\\ -I[dir] Add directory to include search path
|
||||||
@ -1708,8 +1707,6 @@ fn buildOutputType(
|
|||||||
break :blk .c;
|
break :blk .c;
|
||||||
} else if (mem.eql(u8, ofmt, "coff")) {
|
} else if (mem.eql(u8, ofmt, "coff")) {
|
||||||
break :blk .coff;
|
break :blk .coff;
|
||||||
} else if (mem.eql(u8, ofmt, "pe")) {
|
|
||||||
break :blk .pe;
|
|
||||||
} else if (mem.eql(u8, ofmt, "macho")) {
|
} else if (mem.eql(u8, ofmt, "macho")) {
|
||||||
break :blk .macho;
|
break :blk .macho;
|
||||||
} else if (mem.eql(u8, ofmt, "wasm")) {
|
} else if (mem.eql(u8, ofmt, "wasm")) {
|
||||||
@ -1753,7 +1750,7 @@ fn buildOutputType(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const a_out_basename = switch (object_format) {
|
const a_out_basename = switch (object_format) {
|
||||||
.pe, .coff => "a.exe",
|
.coff => "a.exe",
|
||||||
else => "a.out",
|
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
|
// If a .pdb file is part of the expected output, we must also copy
|
||||||
// it into place here.
|
// it into place here.
|
||||||
const coff_or_pe = switch (comp.bin_file.options.object_format) {
|
const is_coff = comp.bin_file.options.object_format == .coff;
|
||||||
.coff, .pe => true,
|
const have_pdb = is_coff and !comp.bin_file.options.strip;
|
||||||
else => false,
|
|
||||||
};
|
|
||||||
const have_pdb = coff_or_pe and !comp.bin_file.options.strip;
|
|
||||||
if (have_pdb) {
|
if (have_pdb) {
|
||||||
// Replace `.out` or `.exe` with `.pdb` on both the source and destination
|
// Replace `.out` or `.exe` with `.pdb` on both the source and destination
|
||||||
const src_bin_ext = fs.path.extension(bin_sub_path);
|
const src_bin_ext = fs.path.extension(bin_sub_path);
|
||||||
|
Loading…
Reference in New Issue
Block a user