-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zig cc
, zig c++
, zig translate-c
and other subcommands without a clang/llvm dependency in the compiler binary
#20875
Comments
Potentially crazy/silly idea: What if, when invoking Some advantages I see:
One downside is the potential for people to misunderstand such a 'plugin command' as being part of Zig proper. (Anecdotally, though, I have not seen this to be the case in the .NET world, where |
i feel that has no benefit given edit: it also steals that namespace away from the official zig binary making it harder for ZSF to add proper subcommands in the future |
I can already see myself mistyping
Is there any evidence that name squatting has actually been a problem in these ecosystems? Also, note that we would probably not have a
I don't think this would be a real problem. You'd have to manually install the plugin command, making it quite obvious that it has nothing to do with ZSF. My experience in .NET world is also that this confusion doesn't exist there, even with
.NET as well (just edited my post to note that).
This I'll concede is a valid concern, though. My best suggestion off the top of my head would be that we should culturally encourage people to not pick too generic names for their plugin commands unless it's actually warranted. Zig could also reserve some command names that we reasonably expect it to gain in the future. |
does this issue affect the ability of If so, how's the plan with mixed-code modules? They are currently such a killer feature and i'd cry if they go away. Ashet OS uses them extensively to compile and link larger C libraries like lwIP and it's really nice to build modular mixed-code projects I was considering making SDL.zig use the same methods, so people just need to link a sdl2 module and get a ready-to-compile system. |
How does this idea of a separate I was thinking of something more modular, but maybe you already thought about that and discarded the idea for a reason:
This would mean that I could just add this Does that make sense? PS: as a side-effect of such an endavour I'm hoping that this would also provide a blueprint for better integration of the Emscripten SDK and the above mentioned WASI SDK into the Zig build system by 3rd-parties (since those SDKs are just slightly differently specialized Clang toolchains). |
@floooh I understand this to mean that the solution proposed in #16270 (comment) is still the way forward. The zig build system includes the zig package manager, which will provide a way to provide C features via a clang/LLVM (or other C compiler integration) package. To me option 2. in your comment reads like it describes the same approach. |
Yeah somehow my brain skipped this part:
...tbh though, if a self-contained cross-platform Clang toolchain (with bundled cross-compilation headers and libraries) exists as 'base', I wonder how useful an additional |
Take |
It doesn't sound like this would work even today, and quite intentionally so on the part of the V8 developers? It was also never a goal of |
There should be many scenarios that need specific exact version of Clang, right? Or say, how to promise the features set supporting between versions of |
Hopefully not, otherwise your code is horribly broken beyond repair |
There are quite a few reasons to pin the toolchain to a specific version, especially in bigger projects and projects which need deterministic builds (I think the pinning to any version is the important part for projects like V8 - so that the same version of V8 is always built with the same version of Clang, what specific Clang version that is should mostly be irrelevant). But I don't see a reason why this pinning shouldn't be possible with a Clang wrapper toolchain or a Zig package which wraps a Clang toolchain (FWIW, the Zig package manager doesn't even have a 'non-pinning mode'). |
Yeah, true, i forgot about deterministic and reproducible builds. But it doesn't mean the code requires a specific version of clang/llvm/compiler to be compiled correctly, but as you said, it needs any fixed/hermetic to create reproducible build results |
This solves the last remaining blocker for #16270, which was proving tricky to find a satisfactory solution to.
What users experience right now is these subcommands being provided via a single binary distribution available from ziglang.org/dowload, as a zip or tarball.
Without a compiled version of LLVM and Clang inside the same executable as Zig, the equation shifts. Some proposed solutions are:
We can imagine combinations of these approaches as well, such as supporting prefetched packages in the zig installation directory and providing downloads that contain clang already prefetched in it.
The fundamental conflict comes down to:
Having typed this out, I think the solution is clear: both!
A separately maintained project should depend on Zig, Clang, and LLVM, and implement the extra utility on top of those dependencies. ziglang.org will continue to post only zig binaries; those binaries will no longer link against Clang and LLVM. This separate project which may or may not have its own website will post binaries whose invocations will look like
zig-extras cc
,zig-extras c++
,zig-extras translate-c
. The project could provide a strict superset of subcommands, making it a drop-in replacement for zig that supports those extra commands. I'm sure at least two dozen geniuses will suggest to name this project "zag".Meanwhile, serious people will be 100% fine with the zig binary that does not depend on LLVM and Clang because they will have full access to these features via the all-powerful build system, and they already know that
zig cc
is a silly gimmick that is completely unnecessary for real world projects. Even so, those subcommands will work with this LLVM-less build of zig, because they will use the build system to fetch and cache the package that provides the necessary functionality.The text was updated successfully, but these errors were encountered: