Open jayschwa opened 4 years ago
I think we can add this as a DOS OS. That should be a pretty straightforward modification. Then you could use -target i386-dos
as your target.
Another option here is something like:
// main.zig
pub const debug_info_type = .COFF; // or .ELF, .Auto
pub fn main() void {}
If it's possible, add support for allowing arbitrary overrides of the output format for the user. The linker could output PE, COFF, ECOFF, ELF, flat binaries, ihex, ....
This would allow something like x86_64-windows-elf
or aarch64-linux-coff
.
This is especially interesting for freestanding targets if you write plugins/modules for custom/embedded systems.
Same as #2826 (but add COFF?)
My original use-case for this issue has been obsoleted. I am now using a linker script to produce a MZ executable that subsequently loads and runs an ELF executable. That said, making output format configurable is probably still desirable.
After some investigation, I've found LLVM will never output COFF objects unless the target triple is *-windows-msvc
.
This seems to leave three options: (1) change LLVM's behavior, (2) add a separate freestanding-coff
OS target that tells LLVM to target *-windows-msvc
(in a similar way to the UEFI target), or (3) add a special case for *-freestanding-msvc
that does the same as (2).
I am experimenting with linking Zig libraries into DOS executables using the Open Watcom toolchain. The Watcom linker seems to require COFF because it does not understand ELF. When building the Zig library, I cannot figure out how to target freestanding and get COFF output. For now, I am using
i386-uefi-none
as my target.