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

add Zig build system #4516

Closed
wants to merge 10 commits into from
Closed

add Zig build system #4516

wants to merge 10 commits into from

Conversation

kassane
Copy link

@kassane kassane commented Feb 20, 2023

Notably, no bindings are added to the main project, only the introduction an alternative build-system.

Whats is zon file?
See: ziglang/zig#14290

Steps

Note: This contribution is not intended to rewrite or deconstruct the main project. It only seeks to expand the working tooling for better use and build alternative.

@bluca
Copy link
Member

bluca commented Feb 20, 2023

There are already multiple systems supported, why is another one needed?

@kassane
Copy link
Author

kassane commented Feb 20, 2023

There are already multiple systems supported, why is another one needed?

@bluca,

The library will now link to zig binding (czmq) under the same condition on a single build. But it will not be restricted to the binding. One important difference about zig binding (czmq) is that libzmq is c++ and implies dual C++ABI support.
https://github.com/ziglang/zig/wiki/Troubleshooting-Build-Issues#dual-abi-linking

Zig C++ (stdc++ vs libc++)
e.g.: https://gist.github.com/kassane/7e9a2da137e13eb6e1dbab726693bdb7?permalink_comment_id=4475986#gistcomment-4475986

On linux for example, the other builds will use the system standard (gnu toolchain) or conventional (optional) clang linking to glibc + libstdc++ (GNU).
The zig being pure LLVM toolchain, will replace libstdc++ with libc++. For shared libraries, no problem but static will result in linking conflict. It is intended that libzmq and zig-czmq will be linked statically. Although it is the code citing sharedlib.

@bluca
Copy link
Member

bluca commented Feb 20, 2023

You can link it with whatever you want, by passing the appropriate parameters, there's no need for yet another build system to do that

@kassane
Copy link
Author

kassane commented Feb 20, 2023

It is intended that libzmq and zig-czmq will be linked statically.

Yes it can be inconvenient for C/C++ Developer. Having to install dependency by dependency until reaching completion.

Now if another build system is unnecessary, then what I can try to do is simply call the process with cmake (and detect if it is installed) and build the binding as shared (on Windows it will be difficult to use zig in cmake).
If czmq used git submodule it would just pull the files from libzmq and link statically.

@kassane
Copy link
Author

kassane commented Feb 28, 2023

Hi again @bluca,

Would there be any problem in adding the zig to the CI? If you want I can do that.

An important question regarding the library license, I am not a lawyer. But would it be a problem to statically link libzmq into libczmq?
Currently in zig PR, the libzmq build by default is static and libczmq is shared.

From libzmq's side I won't need to add anything else, just test and fix any failures continuously.

On your question about: "why a new build-system?"

For most C and C++ developers it will seem useless until it is unknown to many.
Unfortunately zig cannot build other build-systems directly without performing some hacks or external scripting.

It may happen that don't merge this PR, but I will continue to support each change in the mainline project. This does not interfere with czmq-zig binding as it would continue to bind build optionally.
I suggest trying to read czmq-zig's b.dependency on build.zig. Which decides to use system library or package manager.

@bluca
Copy link
Member

bluca commented Feb 28, 2023

As I already said, I don't want to have yet another build system, there's already too many. This is all completely pointless anyway, just use the library provided by the distribution.

@kassane kassane closed this Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants