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

zig: init at 0.1.1 #30598

Merged
merged 1 commit into from Oct 21, 2017
Merged

zig: init at 0.1.1 #30598

merged 1 commit into from Oct 21, 2017

Conversation

andrewrk
Copy link
Member

Motivation for this change

Add zig compiler to NixOS

Things done

tested compiling something

cc @dtzWill

@joachifm
Copy link
Contributor

The ci job fails with

error: while querying the derivation named ‘zig-0.1.1’:
while evaluating the attribute ‘cmakeFlags’ of the derivation ‘zig-0.1.1’ at /tmp/nix-build-nixpkgs-tarball-18.03pre1234.abcdef.drv-0/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:98:11:
while evaluating the attribute ‘cc.libc.dev’ at /tmp/nix-build-nixpkgs-tarball-18.03pre1234.abcdef.drv-0/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:100:12:
attribute ‘dev’ missing, at /tmp/nix-build-nixpkgs-tarball-18.03pre1234.abcdef.drv-0/nixpkgs/pkgs/development/compilers/zig/default.nix:17:31

@andrewrk
Copy link
Member Author

do you know why that error happened? it worked for me when I tested it. do you have a suggestion for how to fix? I just need the path to libc include directory.

@joachifm
Copy link
Contributor

It only happens when evaling the tarball for darwin, so I guess cc.libc is not uniform across all the archs. You can try using getDev stdenv.cc.libc or stdenv.cc.libc_dev (the same thing), they should be more robust than accessing .dev directly.

@dtzWill
Copy link
Member

dtzWill commented Oct 20, 2017

LGTM!

When trying to build Tetris it's not obvious how to tell zig where to find libraries and such.

Would it make sense / be reasonable to (only in Nix-built zig, perhaps) patch Zig to understand NIX_CFLAGS_COMPILE and similar?

(I see it takes clang-like arguments such as -isystem and -dirafter, maybe a wrapper like cc-wrapper would be better?)

Just a thought and is less about packaging Zig (this PR) and more about packaging things written in Zig :).

EDIT:
After poking at this some more

a) Wrapper might be difficult for projects with build.zig; we could 'wrap' zig build-exe but I'm not sure to what end

b) Adding appropriate -isystem, -L, and --library for tetris dependencies.... I'm able to build and run it?! 😁

EDIT2:
@andrewrk helped me on IRC and turns out things already magically work with zig build!!
For example, this dummy Nix expression (save as shell.nix) makes tetris work out-of-the-box after nix-shell'ing. Glorious!

@andrewrk
Copy link
Member Author

@joachifm I changed it to stdenv.cc.libc_dev. It evaluates to the same expression on NixOS.

@joachifm joachifm merged commit b591b5c into NixOS:master Oct 21, 2017
@andrewrk
Copy link
Member Author

From the macos build log:

In file included from /tmp/nix-build-zig-0.1.1.drv-0/zig-0.1.1-src/deps/lld/COFF/Config.h:13:
In file included from /nix/store/pqwvpnqhskx1h1mkwcbf3713rdnzgg7f-llvm-5.0.0/include/llvm/ADT/StringRef.h:13:
/nix/store/pqwvpnqhskx1h1mkwcbf3713rdnzgg7f-llvm-5.0.0/include/llvm/ADT/STLExtras.h:20:10: fatal error: 'algorithm' file not found
#include <algorithm> // for std::all_of
 ^~~~~~~~~~~

Do we need to manually pass in libstdc++ or something? (the other platforms built successfully)

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.

None yet

3 participants