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

terra updates #69072

Merged
merged 4 commits into from Sep 24, 2019
Merged

terra updates #69072

merged 4 commits into from Sep 24, 2019

Conversation

thoughtpolice
Copy link
Member

@thoughtpolice thoughtpolice commented Sep 19, 2019

Motivation

Updates to the latest Terra to fix a few bugs, and also includes a patch to automatically search NIX_CFLAGS_COMPILE for C compiler options. This means the following Terra program works out of the box (whereas you had to fix it before):

#! /usr/bin/env nix-shell
--[[
#! nix-shell -i terra -p terra glibc
--]]

C = terralib.includec("stdio.h")

-- The keyword 'terra' introduces a new Terra function.
terra hello(argc : int, argv : &rawstring)
  -- Here we call a C function from Terra
  C.printf("Hello, Terra!\n")
  return 0
end

hello:compile()
hello:printpretty(false)
hello:disas()
hello(0, nil)
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
Notify maintainers

cc @jb55

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Terra heavily depends on its ability to interface with C APIs, but
without scanning NIX_CFLAGS_COMPILE, it's awkward and annoying to set up
imports correctly (by scanning and adding the flags yourself) in every
single project.

Luckily most of the Clang initialization is hidden away, but the Lua
code for the Terra library handles all the high-level stuff, so we patch
it in there.

This allows simple examples like:

    C = terralib.includec("zlib.h")

to work instantly, provided `zlib` is a Nix dependency.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Signed-off-by: Austin Seipp <aseipp@pobox.com>
@thoughtpolice
Copy link
Member Author

@GrahamcOfBorg build terra

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Copy link
Contributor

@jb55 jb55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this up. I vaguely remember running into these issues when I packaged this originally. Made terra hard to work with.

Commits looks ok but they could be fixup/squashed a bit nicer.

nix-review pr 69072 ✔️

@thoughtpolice
Copy link
Member Author

The evaluator seems to explode on this right now but I can't tell why. Have to ask Graham or something I suppose...

@Mic92
Copy link
Member

Mic92 commented Sep 24, 2019

@GrahamcOfBorg eval

@Mic92 Mic92 merged commit 8025787 into NixOS:master Sep 24, 2019
@Mic92
Copy link
Member

Mic92 commented Sep 24, 2019

Looks like this should be backported to 19.09 as well? Without NIX_CFLAGS_COMPILE support this seems to be not so useful.

@ivan
Copy link
Member

ivan commented Sep 24, 2019

8025787#diff-7dd944a54541412ed4394ad3f33de9faR37 is causing a grahamcofborg-eval failure in #69388

@Mic92
Copy link
Member

Mic92 commented Sep 25, 2019

This was fixed in aad639d

@thoughtpolice thoughtpolice deleted the nixpkgs/terra-updates branch September 25, 2019 22:28
veprbl added a commit to veprbl/nixpkgs that referenced this pull request Sep 25, 2019
Fixes eval after NixOS#69072

Resolved conflict in pkgs/tools/security/thc-hydra/default.nix
Basically had to revert a1c0e10 which
adapts NixOS#69210 to master that doesn't yet have
329a88e
veprbl added a commit that referenced this pull request Sep 25, 2019
Fixes eval on darwin after #69072

Resolved conflict in pkgs/tools/security/thc-hydra/default.nix
Basically had to revert a1c0e10 which
adapts #69210 to master that doesn't yet have
329a88e

Tested using maintainers/scripts/eval-release.sh before and after to see
that the fix works
veprbl added a commit that referenced this pull request Sep 25, 2019
Fixes eval on darwin after #69072

Tested using maintainers/scripts/eval-release.sh before and after to see
that the fix works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants