Merge pull request #125896 from Fundament-Software/terra

This commit is contained in:
Sandro 2021-06-18 20:16:32 +02:00 committed by GitHub
commit 75f70a36ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 57 deletions

View file

@ -764,7 +764,7 @@
keys = [{
longkeyid = "rsa4096/0xAAA50652F0479205";
fingerprint = "BF8B F725 DA30 E53E 7F11 4ED8 AAA5 0652 F047 9205";
}];
}];
};
ar1a = {
email = "aria@ar1as.space";
@ -5331,7 +5331,7 @@
github = "kho-dialga";
githubId = 55767703;
name = "Iván Brito";
};
};
khumba = {
email = "bog@khumba.net";
github = "khumba";
@ -6026,8 +6026,8 @@
githubId = 7243783;
name = "Bernardo Meurer";
keys = [{
longkeyid = "rsa4096/0xF4C0D53B8D14C246";
fingerprint = "F193 7596 57D5 6DA4 CCD4 786B F4C0 D53B 8D14 C246";
longkeyid = "rsa4096/0xF4C0D53B8D14C246";
fingerprint = "F193 7596 57D5 6DA4 CCD4 786B F4C0 D53B 8D14 C246";
}];
};
lowfatcomputing = {
@ -8247,12 +8247,10 @@
github = "poscat0x04";
githubId = 53291983;
name = "Poscat Tarski";
keys = [
{
longkeyid = "rsa4096/2D2595A00D08ACE0";
fingerprint = "48AD DE10 F27B AFB4 7BB0 CCAF 2D25 95A0 0D08 ACE0";
}
];
keys = [{
longkeyid = "rsa4096/2D2595A00D08ACE0";
fingerprint = "48AD DE10 F27B AFB4 7BB0 CCAF 2D25 95A0 0D08 ACE0";
}];
};
pradeepchhetri = {
email = "pradeep.chhetri89@gmail.com";
@ -9344,6 +9342,16 @@
fingerprint = "A317 37B3 693C 921B 480C C629 4A2A AAA3 82F8 294C";
}];
};
seylerius = {
name = "Sable Seyler";
email = "sable@seyleri.us";
github = "seylerius";
githubId = 1145981;
keys = [{
longkeyid = "rsa4096/0xDC26B921A9E9DBDE";
fingerprint = "7246 B6E1 ABB9 9A48 4395 FD11 DC26 B921 A9E9 DBDE";
}];
};
sfrijters = {
email = "sfrijters@gmail.com";
github = "sfrijters";
@ -9869,10 +9877,10 @@
name = "Felix Bühler";
};
stupremee = {
email = "jutus.k@protonmail.com";
github = "Stupremee";
githubId = 39732259;
name = "Justus K";
email = "jutus.k@protonmail.com";
github = "Stupremee";
githubId = 39732259;
name = "Justus K";
};
SubhrajyotiSen = {
email = "subhrajyoti12@gmail.com";

View file

@ -1,27 +1,53 @@
{ lib, stdenv, fetchurl, fetchFromGitHub
, llvmPackages, ncurses, lua
}:
{ lib, stdenv, fetchFromGitHub, llvmPackages, ncurses, cmake, libxml2
, symlinkJoin, breakpointHook, cudaPackages, enableCUDA ? false }:
let
luajitArchive = "LuaJIT-2.0.5.tar.gz";
luajitSrc = fetchurl {
url = "http://luajit.org/download/${luajitArchive}";
sha256 = "0yg9q4q6v028bgh85317ykc9whgxgysp76qzaqgq55y6jy11yjw7";
luajitRev = "9143e86498436892cb4316550be4d45b68a61224";
luajitBase = "LuaJIT-${luajitRev}";
luajitArchive = "${luajitBase}.tar.gz";
luajitSrc = fetchFromGitHub {
owner = "LuaJIT";
repo = "LuaJIT";
rev = luajitRev;
sha256 = "1zw1yr0375d6jr5x20zvkvk76hkaqamjynbswpl604w6r6id070b";
};
in
stdenv.mkDerivation rec {
llvmMerged = symlinkJoin {
name = "llvmClangMerged";
paths = with llvmPackages; [
llvm.out
llvm.dev
llvm.lib
clang-unwrapped.out
clang-unwrapped.dev
clang-unwrapped.lib
];
};
cuda = cudaPackages.cudatoolkit_11;
clangVersion = llvmPackages.clang-unwrapped.version;
in stdenv.mkDerivation rec {
pname = "terra";
version = "1.0.0pre1175_${builtins.substring 0 7 src.rev}";
version = "1.0.0-beta3_${builtins.substring 0 7 src.rev}";
src = fetchFromGitHub {
owner = "zdevito";
repo = "terra";
rev = "ef6a75ffee15a30f3c74f4e6943851cfbc0fec3d";
sha256 = "0aky17vbv3d9zng34hp17p9zb00dbzwhvzsdjzrrqvk9lmyvix0s";
owner = "terralang";
repo = "terra";
rev = "99ff93f8c60c89bbe2dc7c63eab9bfe2f4c4833e";
sha256 = "0ww54xjvv6p8jwsh6hml3v527zgnv2gj58gpb818bbg4k1jwa5fl";
};
nativeBuildInputs = [ lua ];
buildInputs = with llvmPackages; [ llvm clang-unwrapped ncurses ];
nativeBuildInputs = [ cmake ];
buildInputs = [ llvmMerged ncurses libxml2 ] ++ lib.optional enableCUDA cuda;
cmakeFlags = [
"-DHAS_TERRA_VERSION=0"
"-DTERRA_VERSION=${version}"
"-DTERRA_LUA=luajit"
"-DCLANG_RESOURCE_DIR=${llvmMerged}/lib/clang/${clangVersion}"
] ++ lib.optional enableCUDA "-DTERRA_ENABLE_CUDA=ON";
doCheck = true;
enableParallelBuilding = true;
@ -29,40 +55,36 @@ stdenv.mkDerivation rec {
outputs = [ "bin" "dev" "out" "static" ];
patches = [ ./nix-cflags.patch ];
postPatch = ''
substituteInPlace Makefile \
--replace '-lcurses' '-lncurses'
sed -i '/file(DOWNLOAD "''${LUAJIT_URL}" "''${LUAJIT_TAR}")/d' \
cmake/Modules/GetLuaJIT.cmake
substituteInPlace src/terralib.lua \
--subst-var-by NIX_LIBC_INCLUDE ${lib.getDev stdenv.cc.libc}/include
'';
preBuild = ''
cat >Makefile.inc<<EOF
CLANG = ${lib.getBin llvmPackages.clang-unwrapped}/bin/clang
LLVM_CONFIG = ${lib.getBin llvmPackages.llvm}/bin/llvm-config
EOF
preConfigure = ''
mkdir -p build
cp ${luajitSrc} build/${luajitArchive}
ln -s ${luajitSrc} build/${luajitBase}
tar --mode="a+rwX" -chzf build/${luajitArchive} -C build ${luajitBase}
rm build/${luajitBase}
'';
checkPhase = "(cd tests && ../terra run)";
installPhase = ''
install -Dm755 -t $bin/bin release/bin/terra
install -Dm755 -t $out/lib release/lib/terra${stdenv.hostPlatform.extensions.sharedLibrary}
install -Dm644 -t $static/lib release/lib/libterra.a
install -Dm755 -t $bin/bin bin/terra
install -Dm755 -t $out/lib lib/terra${stdenv.hostPlatform.extensions.sharedLibrary}
install -Dm644 -t $static/lib lib/libterra_s.a
mkdir -pv $dev/include
cp -rv release/include/terra $dev/include
cp -rv include/terra $dev/include
'';
meta = with lib; {
description = "A low-level counterpart to Lua";
homepage = "http://terralang.org/";
platforms = platforms.x86_64;
maintainers = with maintainers; [ jb55 thoughtpolice ];
license = licenses.mit;
homepage = "http://terralang.org/";
platforms = platforms.x86_64;
maintainers = with maintainers; [ jb55 seylerius thoughtpolice ];
license = licenses.mit;
};
}

View file

@ -1,12 +1,11 @@
diff --git a/src/terralib.lua b/src/terralib.lua
index 351238d..e638c90 100644
index 532ed18..2c265dc 100644
--- a/src/terralib.lua
+++ b/src/terralib.lua
@@ -3395,6 +3395,17 @@ function terra.includecstring(code,cargs,target)
@@ -3426,6 +3426,16 @@ function terra.includecstring(code,cargs,target)
args:insert("-internal-isystem")
args:insert(path)
end
+
+ -- NOTE(aseipp): include relevant Nix header files
+ args:insert("-isystem")
+ args:insert("@NIX_LIBC_INCLUDE@")
@ -17,6 +16,6 @@ index 351238d..e638c90 100644
+ args:insert(w)
+ end
+ end
if cargs then
args:insertall(cargs)
-- Obey the SDKROOT variable on macOS to match Clang behavior.
local sdkroot = os.getenv("SDKROOT")
if sdkroot then

View file

@ -12043,8 +12043,7 @@ in
tbb = callPackage ../development/libraries/tbb { };
terra = callPackage ../development/compilers/terra {
llvmPackages = llvmPackages_6;
lua = lua5_1;
llvmPackages = llvmPackages_10;
};
teyjus = callPackage ../development/compilers/teyjus (