- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
acceptedThis proposal is planned.This proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Description
This issue is to fully eliminate LLVM, Clang, and LLD libraries from the Zig project. The remaining ties to these projects are as follows:
- To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
- LLVM
- C backend - 1742/1792 tests passing (97%) (@jacobly0 et al.)
- wasm backend - 1611/1765 tests passing (91%) (@Luukdegram)
optimization passesnot actually a prerequisite for this proposal. The clang package mentioned below will be
able to provide LLVM optimizations as well.
To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. - Clang
upstream Aro and use it for translate-c instead of clang #16268not actually a prerequisite for this proposalWhen the compiler is built without LLVM, use Aro to compile C code instead of Clang #16269not actually a prerequisite for this proposal- C++ source files in zig's repository are built by clang when bootstrappingTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Compiling C++, Objective-C, Objective-C++, etc. files.Solve with a clang package that can be depended on via the zig build system.
To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
To pick up a draggable item, press the space bar.
While dragging, use the arrow keys to move the item.
Press space again to drop the item in its new position, or press escape to cancel.
Note that there would still be an LLVM backend for outputting .bc
files (#13265), but the Zig compiler would lack the capability to compile .bc files into object files. LLVM or Clang would need to be installed and invoked separately for that use case.
In exchange, Zig gains these benefits:
- All our bugs are belong to us.
- The compiler becomes trivial to build from source and to bootstrap with only a C compiler on the host system.
- We stop dealing with annoying problems introduced by Linux distributions and package managers such as Homebrew related to LLVM, Clang, and LLD. There have been and continue to be many.
- The Zig compiler binary goes from about 150 MiB to 5 MiB.
- Compilation speed is increased by orders of magnitude.
- We can implement our own optimization passes that push the state of the art of computing forward.
- We can attract research projects such as alive2
- We can attract direct contributions from Intel, ARM, RISC-V chip manufacturers, etc., who have a vested interest in making our machine code better on their CPUs.
Please read my other comments in this issue before replying:
InKryption, alichraghi, Beyley, Mindgibber, jtriley2p and 914 moreMPLew-is, ringoz, musi-musi, loic-sharma, zexa and 161 morejvyden, 0x08088405, andrewschaaf, lin72h, aelzeiny and 74 morelin72h, pietmichal, den-mentiei, imarko, unreal-skif and 74 morescheibo, Jarred-Sumner, pdeva, Phalangers, zekexiao and 65 moremlugg, alichraghi, theoparis, Beyley, ianprime0509 and 151 moremlugg, travisstaloch, alichraghi, lodinukal, achille-roussel and 147 morerodrimati1992, Congee, 190n, chiumichael, aelzeiny and 131 more
Metadata
Metadata
Assignees
Labels
acceptedThis proposal is planned.This proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.
Type
Projects
Status
Ditch LLVM
Milestone
Relationships
Development
Select code repository
Activity
xdBronch commentedon Jun 30, 2023
I see the 1.0.0 milestone for this, is it meant to be a blocker for 1.0? or simply the goal
andrewrk commentedon Jun 30, 2023
The milestone, on an issue labeled "proposal", means that a decision must be made to accept or reject that proposal before tagging the release corresponding to that milestone.
For an issue labeled "accepted", the milestone means that it must be implemented by then. So, if this proposal is accepted, then I will evaluate at that time which milestone to move it to.
Jarred-Sumner commentedon Jun 30, 2023
IMO, this is the biggest question. One of the most compelling reasons to use Zig is runtime performance of software written in Zig. Without LLVM's optimization passes, what will that look like?
nektro commentedon Jun 30, 2023
Zig will continue to implement optimization passes of its own over time and get faster.
mlarouche commentedon Jun 30, 2023
So here the projects that depend on the ability to compile C++ that I currently developing:
zgui
for my game editor in the future.And also some NDA game platform that have C++ only API that will require some C++-to-C glue code to be compiled, but obviously not implemented.
To me, the ability to seamlessly build any C, C++ and Obj-C is a big selling point of the Zig toolchain even if it is behind a optional flag to enable LLVM and Clang when compiling Zig. A part of the hype momentum around Zig is due to that fact.
If this happens, I think I will remove my donation to the Zig Software Foundation.
TL;DR: Lots of libraries in the game development world (closed or open source) require the ability to compile C++.
ikskuh commentedon Jun 30, 2023
I think this proposal would hurt the Zig ecosystem more than it would help it, due to several reasons:
Imho, this proposal strongly violates the
idea, as the current direction we're heading is a really good unified native build environment based on a single static executable that can serve projects in arbitrar, sizes, shipping compilers for several major languages, a huge ass support for targets and a build system, making work in systems programming fun, even if one doesnt use Zig as a language.
We are on a good way to replace a huge list of tools with a single executable, making contributions to projects build on Zig fun, easy and platform independent.
When this proposal is accepted, in addition to Zig one will need to have the following tools installed:
We can potentially replace all of those tools wit a single, equally powerful executable, making the live easier for all native devs out there
personal projects that would be affected:
foxnne commentedon Jun 30, 2023
I'm still a beginner I believe, but if it is at all worth it for me to give my point of view, Zig's ability to replace all of the build tools mentioned above is a big reason I was interested in Zig in the first place. I struggled a lot with all the different build systems and Zig is a really refreshing breath of fresh air.
I have two personal projects that use zgui heavily and I had planned on continuing.
emidoots commentedon Jun 30, 2023
With Mach engine we have two dependencies that would be very, very painful to remove (would set us back years):
It will be a long time before Zig's SPIRV backend is capable enough to generate non-GPGPU shaders for graphics APIs (if ever, since it would likely require major language changes) - so I don't see a way for us to escape these aside from replicating what these two projects -- LLVM forks -- do on our side.
Every other C++ dependency I believe we could safely escape from.
emidoots commentedon Jun 30, 2023
A positive long-term effect of this change is that it would push us as a community away from wrapping C++ code and towards more pure-Zig solutions.
Many of the comments in this thread are about people using zgui, wwise, zig-gamedev, assimp, and other C++ libraries wrapped with Zig. It gives you a leg up in the short term, but I worry in the long-term that people's gamedev experiences coming to Zig will be 'initially I saw a nice language... then I encountered the guts of the libraries I was told to use were large, clunky C++ codebases'
GeffDev commentedon Jun 30, 2023
Also a beginner, but I think being able to use Zig as a C++ build system (which is what I use for all my private C++ projects) is an invaluable feature to me and I believe many other people. The simplicity of Zig, having a compiler and a build system contained within a single executable (with the added bonus of being easily cross platform), is really cool, and it would be kinda unfortunate to see that feature be removed as an effect of removing clang and friends. However, if this does go through, the ability to fallback to generating
.bc
files and invoking clang is nice.ghost commentedon Jun 30, 2023
One of my friends pointed out that nothing stops you from invoking clang in a build.zig to compile C++ dependencies, even if Zig stops including clang. I wonder how much of a problem that would really be for these projects?
xdBronch commentedon Jun 30, 2023
doing that would be an additional dependency without the ease of zigs cross compilation
ghost commentedon Jun 30, 2023
Hmm, the more I think about this proposal the less I like it. I'm feeling it would be better to make the LLVM backend non-default (that is, switch
-fno-LLVM
for-fLLVM
or something) but not remove it. It seems like this would solve most of the issues: the existence of many bugs that are LLVM's fault, and the slow compile speed, aren't strong reasons to remove the LLVM backend so much as make it non-default. It wouldn't solve the issues of the binary size of the zig compiler or difficulties with building it, of course.238 remaining items
zig cc
#23115agl-alexglopez commentedon Mar 21, 2025
I am baffled by the initial trend I saw in this thread, even if you never dropped the excellent clarification. You shouldn't hamstring the potential of Zig as a programming language, especially before v1.0.0. Many are focused on the supplementary benefits.
What drew me to the project was its righting the wrongs of past languages and bringing independence and innovation to domains dominated by C, C++, Clang/LLVM, and GCC with the potential of Zig as the better tool, period. Software has been successfully built and distributed for many years before Zig came along so I don't share the obsession with this component. I'm on board for the big picture Vision. However, I am not a FinTech/Game Studio/Founderโข with funding potential to pull--just a user--so don't forget the grain of salt when reading this :). Good luck!
anyon17 commentedon May 21, 2025
is this really happening ? I was planning to pick up Zig for my next project (after writing Rust for 4 years) and seeing this I might want to ask if this is still going to happen ? and will WASM would still be seamlessly supported ?
mlugg commentedon May 21, 2025
Yes, this is planned; no, it won't meaningfully affect you or your use case. Please read the comments linked in the main issue post. This proposal is about how the Zig compiler works with LLVM, not whether it does.
anyon17 commentedon May 21, 2025
thanks @mlugg . In that case, will start my zig journey ! I believe with this, there won't be anything visible to end user of the language right ?
mlugg commentedon May 21, 2025
When this proposal is implemented, it will probably require users to make small tweaks to their build scripts, but that's all. Nothing will stop being possible, and nothing will change very fundamentally; you'll only have to change your code around as much as you do anyway on a typical Zig upgrade.
heheda123123 commentedon Jul 14, 2025
Does this mean that Zig will lose its default ability to cross-compile C/C++ source code?
Paul-Dempsey commentedon Jul 14, 2025
No, absolutely not. Read the whole issue and linked items.