Skip to content
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

Support Zig as backend C compiler #2741

Open
jimkring opened this issue Mar 4, 2024 · 2 comments
Open

Support Zig as backend C compiler #2741

jimkring opened this issue Mar 4, 2024 · 2 comments
Assignees
Labels
enhancement An improvement rather than a bug

Comments

@jimkring
Copy link
Contributor

jimkring commented Mar 4, 2024

zig is a nice language and toolchain.

The zig compiler supports C and C++ compilation (by building clang into zig) — the zig cc command is the C compiler and zig c++ is the C++ compiler.

it’s a single download with no dependencies.

It is currently possible to “fool” Nuitka into using zig by creating a shell script named “zig-clang-cc.sh” that passes all command line arguments to zig cc and setting CC=“/path/to/zig-clang-cc.sh”. Note, it is also necessary to pass the --clang option to nuitka.

I set up a simple project with GitHub action build to test this approach.

initial testing quickly found a bug in zig’s handling of some linker flags.

it would be nice to add support to nuitka for officially detecting when zig is configured as the compiler — when CC is set to zig cc.

Note that full support will probably not work right away, or soon, but it would be good to try to keep improving integration and share bug reports with the zig project, because there are many long-term benefits for using zig.

@kayhayen
Copy link
Member

kayhayen commented Mar 4, 2024

I agree, adding that will make it much easier to track the progress on zig side. Notice however that due to ziglang/zig#11415 this may be a very long time away actually.

For older than 3.11, I think we might make it work with using C++03 workaround. Unfortunately, no way to compile for 3.11 without the C11 support there. But ever since MSVC can do C11 now, maybe it's gaining more traction, as e.g. seen in Python.

@kayhayen kayhayen added the enhancement An improvement rather than a bug label Mar 4, 2024
@kayhayen kayhayen self-assigned this Mar 4, 2024
@jimkring
Copy link
Contributor Author

jimkring commented Mar 4, 2024

I have created this tracking issue for communicating our Zig issue priorities to their team: #2742

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement rather than a bug
Projects
None yet
Development

No branches or pull requests

2 participants