Hi guys,
is it currently possible to compile Zig for the ESP8266/ESP32? According to this forum post it seems like LLVM supports it as a target. I would love to help with this feat, but I'm not really sure where to start. The most helpful thing I could find is this fork.
If someone could provide me a little kickstart from which I can dive into this matter I would be very thankful :)
Currently zig is compiled against LLVM10 that is not yet supported for extensa. Compiling extensa extension against LLVM10 is not straight forward yet as it is not in the main stream.
You have a boostrap for compiling zig, with llvm here, it might help if you want to have a deep dive on it : https://github.com/ziglang/zig-bootstrap
So I have to install an LLVM-Version with extensa-support and then build zig with that?
Yes, exactly.
Actually, there's more work you would need to get XTensa even to what we would consider a tier IV target: you'd probably need to teach Zig's stage1 compiler how to tell LLVM to target XTensa.
I noticed that I accidentally entered an invalid URL for the forum post. If any of you want to have a look – it's fixed now.
Seems expressif is near to release the expressif llvm10 , so it will be compatible (with the pixeldev modifications to do on architecture declaration in zig) https://github.com/espressif/llvm-project/issues/18
I see this is now part of the 0.8.0 milestone, but that's not due for release till next summer. Looking upstream at the expresif repo it appears they have merged in the bits. Would it be possible for me to build their llvm from source and then bootstrap zig using that or are there still major parts missing?
Looking upstream at the expresif repo it appears they have merged in the bits.
Indeed it looks like just 7 days ago they published their LLVM 11 branch (hooray!) https://github.com/espressif/llvm-project/pull/42
For zig itself to rely on it, we would it to be merged into upstream LLVM. However:
Would it be possible for me to build their llvm from source and then bootstrap zig using that or are there still major parts missing?
you could definitely start work now on zig support for xtensa on top of their LLVM fork.
What about the linker? I don't think these patches include patches for the linker right? So you would still have to use the GCC linker that Xtensa provides :(
What about the linker? I don't think these patches include patches for the linker right? So you would still have to use the GCC linker that Xtensa provides :(
I believe that is true. To start with you can get zig build-obj working though. I believe a few people have made progress here before
Thanks. I'm afraid this is still a bit too involved than I'm able to work with at the moment. I'm glad it's getting closer though!
I'm really excited for the day I can write esp32 firmware using zig.
Most helpful comment
Seems expressif is near to release the expressif llvm10 , so it will be compatible (with the pixeldev modifications to do on architecture declaration in zig) https://github.com/espressif/llvm-project/issues/18