about summary refs log tree commit diff
path: root/pkgs/development/compilers
diff options
context:
space:
mode:
authorVladimír Čunát <v@cunat.cz>2019-09-24 08:14:34 +0200
committerVladimír Čunát <v@cunat.cz>2019-09-24 08:14:34 +0200
commiteab41878ac16a80b1189d5e4aeec5e037f6571db (patch)
tree8bd9dcfadee430fc3f853bfacdd6220bc4e35152 /pkgs/development/compilers
parent11c2b06dd2cf9ea86920ff9bb3939a3f5eb41a27 (diff)
parentafd04a49ed4d03923adf51352ce2bce1fa72455d (diff)
downloadnixlib-eab41878ac16a80b1189d5e4aeec5e037f6571db.tar
nixlib-eab41878ac16a80b1189d5e4aeec5e037f6571db.tar.gz
nixlib-eab41878ac16a80b1189d5e4aeec5e037f6571db.tar.bz2
nixlib-eab41878ac16a80b1189d5e4aeec5e037f6571db.tar.lz
nixlib-eab41878ac16a80b1189d5e4aeec5e037f6571db.tar.xz
nixlib-eab41878ac16a80b1189d5e4aeec5e037f6571db.tar.zst
nixlib-eab41878ac16a80b1189d5e4aeec5e037f6571db.zip
Merge branch 'master' into staging-next
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r--pkgs/development/compilers/jetbrains-jdk/default.nix13
-rw-r--r--pkgs/development/compilers/mozart/default.nix89
-rw-r--r--pkgs/development/compilers/terra/default.nix45
-rw-r--r--pkgs/development/compilers/terra/nix-cflags.patch22
4 files changed, 148 insertions, 21 deletions
diff --git a/pkgs/development/compilers/jetbrains-jdk/default.nix b/pkgs/development/compilers/jetbrains-jdk/default.nix
index 1349b7f0dddc..a6e3dfff4e03 100644
--- a/pkgs/development/compilers/jetbrains-jdk/default.nix
+++ b/pkgs/development/compilers/jetbrains-jdk/default.nix
@@ -14,6 +14,11 @@ let drv = stdenv.mkDerivation rec {
       url = "https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_2-linux-x64-b${version}.tar.gz";
       sha256 = "121yzgvkfx7lq0k9s8wjnhz09a564br5y7zlkxgh191sbm2i7zdi";
     }
+  else if stdenv.hostPlatform.system == "x86_64-darwin" then
+    fetchurl {
+      url = "https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_2-osx-x64-b${version}.tar.gz";
+      sha256 = "1ly6kf59knvzbr2pjkc9fqyzfs28pdvnqg5pfffr8zp14xm44zmd";
+    }
   else
     throw "unsupported system: ${stdenv.hostPlatform.system}";
 
@@ -28,20 +33,20 @@ let drv = stdenv.mkDerivation rec {
     jrePath=$out/jre
   '';
 
-  postFixup = ''
+  postFixup = lib.optionalString (!stdenv.isDarwin) ''
     find $out -type f -perm -0100 \
         -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
         --set-rpath "$rpath" {} \;
     find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \;
   '';
 
-  rpath = lib.makeLibraryPath ([
+  rpath = lib.optionalString (!stdenv.isDarwin) (lib.makeLibraryPath ([
     stdenv.cc.cc stdenv.cc.libc glib libxml2 libav_0_8 ffmpeg libxslt libGL
     alsaLib fontconfig freetype pango gtk2 cairo gdk-pixbuf atk zlib
     (placeholder "out")
   ] ++ (with xorg; [
     libX11 libXext libXtst libXi libXp libXt libXrender libXxf86vm
-  ])) + ":${placeholder "out"}/lib/jli";
+  ])) + ":${placeholder "out"}/lib/jli");
 
   passthru.home = drv;
 
@@ -61,6 +66,6 @@ let drv = stdenv.mkDerivation rec {
     homepage = "https://bintray.com/jetbrains/intellij-jdk/";
     license = licenses.gpl2;
     maintainers = with maintainers; [ edwtjo ];
-    platforms = with platforms; [ "x86_64-linux" ];
+    platforms = with platforms; [ "x86_64-linux" "x86_64-darwin" ];
   };
 }; in drv
diff --git a/pkgs/development/compilers/mozart/default.nix b/pkgs/development/compilers/mozart/default.nix
new file mode 100644
index 000000000000..97634bca8ef7
--- /dev/null
+++ b/pkgs/development/compilers/mozart/default.nix
@@ -0,0 +1,89 @@
+{ lib
+, fetchFromGitHub
+, fetchurl
+, cmake
+, unzip
+, makeWrapper
+, boost
+, llvmPackages
+, llvmPackages_4
+, gmp
+, emacs
+, emacs25-nox
+, jre_headless
+, tcl
+, tk
+}:
+
+let stdenv = llvmPackages.stdenv;
+
+in stdenv.mkDerivation rec {
+  pname = "mozart2";
+  version = "2.0.1";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/mozart/mozart2/releases/download/v${version}/${name}-Source.zip";
+    sha256 = "1mad9z5yzzix87cdb05lmif3960vngh180s2mb66cj5gwh5h9dll";
+  };
+
+  # This is a workaround to avoid using sbt.
+  # I guess it is acceptable to fetch the bootstrapping compiler in binary form.
+  bootcompiler = fetchurl {
+    url = "https://github.com/layus/mozart2/releases/download/v2.0.0-beta.1/bootcompiler.jar";
+    sha256 = "1hgh1a8hgzgr6781as4c4rc52m2wbazdlw3646s57c719g5xphjz";
+  };
+
+  postConfigure = ''
+    cp ${bootcompiler} bootcompiler/bootcompiler.jar
+  '';
+
+  nativeBuildInputs = [ cmake makeWrapper unzip ];
+
+  # We cannot compile with both gcc and clang, but we need clang during the
+  # process, so we compile everything with clang.
+  # BUT, we need clang4 for parsing, and a more recent clang for compiling.
+  cmakeFlags = [
+    "-DCMAKE_CXX_COMPILER=${llvmPackages.clang}/bin/clang++"
+    "-DCMAKE_C_COMPILER=${llvmPackages.clang}/bin/clang"
+    "-DBoost_USE_STATIC_LIBS=OFF"
+    "-DMOZART_BOOST_USE_STATIC_LIBS=OFF"
+    "-DCMAKE_PROGRAM_PATH=${llvmPackages_4.clang}/bin"
+    # Rationale: Nix's cc-wrapper needs to see a compile flag (like -c) to
+    # infer that it is not a linking call, and stop trashing the command line
+    # with linker flags.
+    # As it does not recognise -emit-ast, we pass -c immediately overridden
+    # by -emit-ast.
+    # The remaining is just the default flags that we cannot reuse and need
+    # to repeat here.
+    "-DMOZART_GENERATOR_FLAGS='-c;-emit-ast;--std=c++0x;-Wno-invalid-noreturn;-Wno-return-type;-Wno-braced-scalar-init'"
+    # We are building with clang, as nix does not support having clang and
+    # gcc together as compilers and we need clang for the sources generation.
+    # However, clang emits tons of warnings about gcc's atomic-base library.
+    "-DCMAKE_CXX_FLAGS=-Wno-braced-scalar-init"
+  ] ++ lib.optional stdenv.isDarwin "-DCMAKE_FIND_FRAMEWORK=LAST";
+
+  fixupPhase = ''
+    wrapProgram $out/bin/oz --set OZEMACS ${emacs}/bin/emacs
+  '';
+
+  buildInputs = [
+    boost
+    llvmPackages_4.llvm
+    llvmPackages_4.clang
+    llvmPackages_4.clang-unwrapped
+    gmp
+    emacs25-nox
+    jre_headless
+    tcl
+    tk
+  ];
+
+  meta = {
+    description = "An open source implementation of Oz 3.";
+    maintainers = [ lib.maintainers.layus ];
+    license = lib.licenses.bsd2;
+    homepage = "https://mozart.github.io";
+  };
+
+}
diff --git a/pkgs/development/compilers/terra/default.nix b/pkgs/development/compilers/terra/default.nix
index dea6df1b7aa4..6d87d4bbd496 100644
--- a/pkgs/development/compilers/terra/default.nix
+++ b/pkgs/development/compilers/terra/default.nix
@@ -1,29 +1,40 @@
-{ stdenv, fetchFromGitHub, fetchurl, llvmPackages, ncurses, lua }:
+{ stdenv, fetchurl, fetchFromGitHub
+, llvmPackages, ncurses, lua
+}:
 
 let
   luajitArchive = "LuaJIT-2.0.5.tar.gz";
   luajitSrc = fetchurl {
-    url = "http://luajit.org/download/${luajitArchive}";
+    url    = "http://luajit.org/download/${luajitArchive}";
     sha256 = "0yg9q4q6v028bgh85317ykc9whgxgysp76qzaqgq55y6jy11yjw7";
   };
 in
-
 stdenv.mkDerivation rec {
-  pname = "terra-git";
-  version = "1.0.0-beta1";
+  pname = "terra";
+  version = "1.0.0pre1175_${builtins.substring 0 7 src.rev}";
 
   src = fetchFromGitHub {
-    owner = "zdevito";
-    repo = "terra";
-    rev = "release-${version}";
-    sha256 = "1blv3mbmlwb6fxkck6487ck4qq67cbwq6s1zlp86hy2wckgf8q2c";
+    owner  = "zdevito";
+    repo   = "terra";
+    rev    = "ef6a75ffee15a30f3c74f4e6943851cfbc0fec3d";
+    sha256 = "0aky17vbv3d9zng34hp17p9zb00dbzwhvzsdjzrrqvk9lmyvix0s";
   };
 
+  nativeBuildInputs = [ lua ];
+  buildInputs = with llvmPackages; [ llvm clang-unwrapped ncurses ];
+
+  doCheck = true;
+  enableParallelBuilding = true;
+  hardeningDisable = [ "fortify" ];
   outputs = [ "bin" "dev" "out" "static" ];
 
+  patches = [ ./nix-cflags.patch ];
   postPatch = ''
-    substituteInPlace Makefile --replace \
-      '-lcurses' '-lncurses'
+    substituteInPlace Makefile \
+      --replace '-lcurses' '-lncurses'
+
+    substituteInPlace src/terralib.lua \
+      --subst-var-by NIX_LIBC_INCLUDE ${stdenv.cc.libc.dev}/include
   '';
 
   preBuild = ''
@@ -36,6 +47,8 @@ stdenv.mkDerivation rec {
     cp ${luajitSrc} build/${luajitArchive}
   '';
 
+  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}
@@ -45,13 +58,11 @@ stdenv.mkDerivation rec {
     cp -rv release/include/terra $dev/include
   '';
 
-  buildInputs = with llvmPackages; [ lua llvm clang-unwrapped ncurses ];
-
   meta = with stdenv.lib; {
     description = "A low-level counterpart to Lua";
-    homepage = http://terralang.org/;
-    platforms = platforms.x86_64;
-    maintainers = with maintainers; [ jb55 ];
-    license = licenses.mit;
+    homepage    = http://terralang.org/;
+    platforms   = platforms.x86_64;
+    maintainers = with maintainers; [ jb55 thoughtpolice ];
+    license     = licenses.mit;
   };
 }
diff --git a/pkgs/development/compilers/terra/nix-cflags.patch b/pkgs/development/compilers/terra/nix-cflags.patch
new file mode 100644
index 000000000000..339ae23cef65
--- /dev/null
+++ b/pkgs/development/compilers/terra/nix-cflags.patch
@@ -0,0 +1,22 @@
+diff --git a/src/terralib.lua b/src/terralib.lua
+index 351238d..e638c90 100644
+--- a/src/terralib.lua
++++ b/src/terralib.lua
+@@ -3395,6 +3395,17 @@ 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@")
++
++    local nix_cflags = os.getenv('NIX_CFLAGS_COMPILE')
++    if nix_cflags ~= nil then
++        for w in nix_cflags:gmatch("%S+") do
++          args:insert(w)
++        end
++    end
+     
+     if cargs then
+         args:insertall(cargs)