zig
zig copied to clipboard
COFF and ELF: move to-and-from CPU arch logic
- Before, std.Target.Cpu.Arch.toCoffMachine was not used anywhere. Instead, std.coff.fromTargetCpuArch was used. After this commit this is still the case but toCoffMachine is removed and merged into std.coff.fromTargetCpuArch, making it more complete, too.
- After this commit std.elf.toTargetCpuArch and std.coff.toTargetCpuArch are still not used anywhere and weren't before this commit either. Can we remove them? @kubkon
- toCoffMachine and toElfMachine are removed and their logic is moved to std.coff and std.elf, respectively. I thought they belong there more than in std.Target.
I am not using std.elf.toTargetCpuArch
anywhere in zld either. I am using toElfMachine
to flag up errors to the users though, but those calls can be replaced with std.elf.EM.fromTargetCpuArch
. Next step would be to either flag up use of toElfMachine
as a compile error with deprecation message, or re-implement it as inlined call to std.elf.EM.fromTargetCpuArch
.
https://github.com/search?q=toTargetCpuArch+language%3AZig&type=code&l=Zig
I can't see any real-world usage of toTargetCpuArch (except in zld but you said you don't use that anymore so I assume that's just outdated). Do you think we can remove both of those toTargetCpuArch functions then (and still deprecate those too probably)? Or else we can just leave them here for now.
Alright, I added two deprecation declarations for toElfMachine and toCoffMachine.
Oh so this thing is causing the problem here:
test {
std.testing.refAllDecls(Target.Cpu.Arch);
}
Fixed that now hopefully.
Sorry are you suggesting that the current std.Target.Cpu.Arch.toElfMachine
and std.Target.Cpu.Arch.toCoffMachine
were good and instead I could just remove std.coff.MachineType.fromTargetCpuArch
and merge the logic into std.Target.Cpu.Arch.toCoffMachine
? I think that'd be good too but just want to make sure I'm understanding it right.
I'm sorry, I don't see the purpose of this patch. Closing.