ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
35.24k stars 2.57k forks source link

stop invoking lld when building one object file #8940

Open mattnite opened 3 years ago

mattnite commented 3 years ago

I have the following zig code:

export fn foo() c_int {
    return 0;
}

If I try to build it with zig build-obj probe.zig -target bpfel-freestanding -OReleaseFast I get:

error(link): /home/mknight/zig/0.8.0-dev.2707+322215bf0/files/zig terminated with stderr:

error: LLDCrashed
mattnite commented 3 years ago

I'm sorry for the lack of info on this one, I gave up trying to build LLVM12 locally and I've just been waiting for it to be released on arch before working on the compiler again, so I don't know how to debug this.

LemonBoy commented 3 years ago

lld is getting support for BPF as we speak. The real problem here is that Zig should really stop invoking lld when building object files.

andrewrk commented 3 years ago

Keeping the issue open to track these TODOs:

https://github.com/ziglang/zig/blob/a2c546fea30de2caf1efb454d327e70270c07338/src/link/Elf.zig#L1385-L1391

andrewrk commented 3 years ago

Also as @LemonBoy pointed out in https://github.com/ziglang/zig/pull/10117#issuecomment-962662345 the zig cc case needs to be solved as well.