about summary refs log tree commit diff
path: root/pkgs/development/compilers/gerbil
diff options
context:
space:
mode:
authorFrancois-Rene Rideau2023-08-09 20:17:42 -0400
committerFrancois-Rene Rideau2023-10-15 19:00:21 -0400
commit2fdfcc5352965870ada423cc8cfbe5c4dbfeacbb (patch)
tree7a5e04867fa338df819d59cee2afb3383291ee27 /pkgs/development/compilers/gerbil
parentbca2b0c9fa1cd46aa4952fcbeaab302e014d694b (diff)
gerbil: 0.17 -> 0.18
Diffstat (limited to 'pkgs/development/compilers/gerbil')
-rw-r--r--pkgs/development/compilers/gerbil/build.nix83
-rw-r--r--pkgs/development/compilers/gerbil/default.nix18
-rw-r--r--pkgs/development/compilers/gerbil/gerbil-support.nix53
-rw-r--r--pkgs/development/compilers/gerbil/gerbil-utils.nix8
4 files changed, 105 insertions, 57 deletions
diff --git a/pkgs/development/compilers/gerbil/build.nix b/pkgs/development/compilers/gerbil/build.nix
index 227f11b7c584..9ce26d0b21b2 100644
--- a/pkgs/development/compilers/gerbil/build.nix
+++ b/pkgs/development/compilers/gerbil/build.nix
@@ -1,8 +1,11 @@
 { pkgs, gccStdenv, lib, coreutils,
-  openssl, zlib, sqlite, libxml2, libyaml, libmysqlclient, lmdb, leveldb, postgresql,
-  version, git-version,
+  openssl, zlib, sqlite,
+  version, git-version, src,
   gambit-support,
-  gambit ? pkgs.gambit, gambit-params ? pkgs.gambit-support.stable-params, src }:
+  gambit-git-version,
+  gambit-stampYmd,
+  gambit-stampHms,
+  gambit-params }:
 
 # We use Gambit, that works 10x better with GCC than Clang. See ../gambit/build.nix
 let stdenv = gccStdenv; in
@@ -12,16 +15,13 @@ stdenv.mkDerivation rec {
   inherit version;
   inherit src;
 
-  buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml libmysqlclient lmdb leveldb postgresql ];
+  buildInputs_libraries = [ openssl zlib sqlite ];
 
   # TODO: either fix all of Gerbil's dependencies to provide static libraries,
   # or give up and delete all tentative support for static libraries.
   #buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
 
-  buildInputs = [ gambit ]
-    ++ buildInputs_libraries; # ++ buildInputs_staticLibraries;
-
-  env.NIX_CFLAGS_COMPILE = "-I${libmysqlclient}/include/mysql -L${libmysqlclient}/lib/mysql";
+  buildInputs = buildInputs_libraries;
 
   postPatch = ''
     echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm ;
@@ -29,6 +29,17 @@ stdenv.mkDerivation rec {
     grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do
       substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' ;
     done ;
+    substituteInPlace ./configure --replace 'set -e' 'set -e ; git () { echo "v${git-version}" ;}' ;
+    substituteInPlace ./src/build/build-version.scm --replace "with-exception-catcher" '(lambda _ "v${git-version}")' ;
+    #rmdir src/gambit
+    #cp -a ${pkgs.gambit-unstable.src} ./src/gambit
+    chmod -R u+w ./src/gambit
+    ( cd src/gambit ; ${gambit-params.fixStamp gambit-git-version gambit-stampYmd gambit-stampHms} )
+    for f in src/bootstrap/gerbil/compiler/driver__0.scm \
+             src/build/build-libgerbil.ss \
+             src/gerbil/compiler/driver.ss ; do
+      substituteInPlace "$f" --replace '"gcc"' '"${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc"' ;
+    done
   '';
 
 ## TODO: make static compilation work.
@@ -40,26 +51,42 @@ stdenv.mkDerivation rec {
 # OPENSSL_LIBSSL=${makeStaticLibraries openssl}/lib/libssl.a # MISSING!
 # ZLIB=${makeStaticLibraries zlib}/lib/libz.a
 # SQLITE=${makeStaticLibraries sqlite}/lib/sqlite.a # MISSING!
-# LIBXML2=${makeStaticLibraries libxml2}/lib/libxml2.a # MISSING!
-# YAML=${makeStaticLibraries libyaml}/lib/libyaml.a # MISSING!
-# MYSQL=${makeStaticLibraries libmysqlclient}/lib/mariadb/libmariadb.a
-# LMDB=${makeStaticLibraries lmdb}/lib/mysql/libmysqlclient_r.a # MISSING!
-# LEVELDB=${makeStaticLibraries leveldb}/lib/libleveldb.a
 # EOF
 
+  configureFlags = [
+    "--prefix=$out/gerbil"
+    "--enable-zlib"
+    "--enable-sqlite"
+    "--enable-shared"
+    "--disable-deprecated"
+    "--enable-march=" # Avoid non-portable invalid instructions
+  ];
+
   configurePhase = ''
-    (cd src && ./configure \
-      --prefix=$out/gerbil \
-      --with-gambit=${gambit}/gambit \
-      --enable-libxml \
-      --enable-libyaml \
-      --enable-zlib \
-      --enable-sqlite \
-      --enable-mysql \
-      --enable-lmdb \
-      --enable-leveldb)
+    export CC=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc \
+           CXX=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}g++ \
+           CPP=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}cpp \
+           CXXCPP=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}cpp \
+           LD=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}ld \
+           XMKMF=${coreutils}/bin/false
+    unset CFLAGS LDFLAGS LIBS CPPFLAGS CXXFLAGS
+    (cd src/gambit ; ${gambit-params.fixStamp gambit-git-version gambit-stampYmd gambit-stampHms})
+    ./configure ${builtins.concatStringsSep " " configureFlags}
+    (cd src/gambit ;
+    substituteInPlace config.status \
+      ${lib.optionalString (gccStdenv.isDarwin && !gambit-params.stable)
+         ''--replace "/usr/local/opt/openssl@1.1" "${lib.getLib openssl}"''} \
+        --replace "/usr/local/opt/openssl" "${lib.getLib openssl}"
+    ./config.status
+    )
   '';
 
+  extraLdOptions = [
+      "-L${zlib}/lib"
+      "-L${openssl.out}/lib"
+      "-L${sqlite.out}/lib"
+    ];
+
   buildPhase = ''
     runHook preBuild
 
@@ -68,7 +95,7 @@ stdenv.mkDerivation rec {
     export GERBIL_BUILD_CORES=$NIX_BUILD_CORES
     export GERBIL_GXC=$PWD/bin/gxc
     export GERBIL_BASE=$PWD
-    export GERBIL_HOME=$PWD
+    export GERBIL_PREFIX=$PWD
     export GERBIL_PATH=$PWD/lib
     export PATH=$PWD/bin:$PATH
     ${gambit-support.export-gambopt gambit-params}
@@ -76,13 +103,17 @@ stdenv.mkDerivation rec {
     # Build, replacing make by build.sh
     ( cd src && sh build.sh )
 
+    f=build/lib/libgerbil.so.ldd ; [ -f $f ] && :
+    substituteInPlace "$f" --replace '(' \
+      '(${lib.strings.concatStrings (map (x: "\"${x}\" " ) extraLdOptions)}'
+
     runHook postBuild
   '';
 
   installPhase = ''
     runHook preInstall
     mkdir -p $out/gerbil $out/bin
-    (cd src; ./install)
+    ./install.sh
     (cd $out/bin ; ln -s ../gerbil/bin/* .)
     runHook postInstall
   '';
@@ -98,4 +129,6 @@ stdenv.mkDerivation rec {
     platforms   = lib.platforms.unix;
     maintainers = with lib.maintainers; [ fare ];
   };
+
+  outputsToInstall = [ "out" ];
 }
diff --git a/pkgs/development/compilers/gerbil/default.nix b/pkgs/development/compilers/gerbil/default.nix
index eeafde520de9..29e6d3575088 100644
--- a/pkgs/development/compilers/gerbil/default.nix
+++ b/pkgs/development/compilers/gerbil/default.nix
@@ -1,12 +1,18 @@
-{ callPackage, fetchFromGitHub }:
+{ callPackage, fetchFromGitHub, gambit-unstable, gambit-support, pkgs, gccStdenv }:
 
 callPackage ./build.nix rec {
-  version = "0.17";
-  git-version = version;
+  version = "0.18";
+  git-version = "0.18";
   src = fetchFromGitHub {
-    owner = "vyzo";
+    owner = "mighty-gerbils";
     repo = "gerbil";
-    rev = "v${version}";
-    sha256 = "0xzi9mhrmzcajhlz5qcnz4yjlljvbkbm9426iifgjn47ac0965zw";
+    rev = "8ca36a928bc9345f9d28e5f2dfcb55ca558e85f9";
+    sha256 = "sha256-EMiYgQM/Gl+dh6AxLYRZ0BKZ+VKFd+Lkyy9Pw11ivE8=";
+    fetchSubmodules = true;
   };
+  inherit gambit-support;
+  gambit-params = gambit-support.unstable-params;
+  gambit-git-version = "4.9.5-40-g24201248"; # pkgs.gambit-unstable.passthru.git-version
+  gambit-stampYmd = "20230917"; # pkgs.gambit-unstable.passthru.git-stampYmd
+  gambit-stampHms = "182043"; # pkgs.gambit-unstable.passthru.git-stampHms
 }
diff --git a/pkgs/development/compilers/gerbil/gerbil-support.nix b/pkgs/development/compilers/gerbil/gerbil-support.nix
index 3d57e2a73c52..f7a8e81e5071 100644
--- a/pkgs/development/compilers/gerbil/gerbil-support.nix
+++ b/pkgs/development/compilers/gerbil/gerbil-support.nix
@@ -1,15 +1,22 @@
 { pkgs, lib, callPackage, ... }:
 
-  with pkgs.gerbil-support; {
+with pkgs.gerbil-support; {
+
+  pppToName = ppp: lib.removeSuffix ".nix" (baseNameOf ppp); # from pre-package path to name
+  callPpp = ppp: callPackage ppp prePackage-defaults; # from pre-package path to pre-package
+  pppToKV = ppp: { name = pppToName ppp; value = callPpp ppp; }; # from pre-package path to name
+  ppplToPpa = ppps: builtins.listToAttrs (map pppToKV ppps); # from pre-package path list to name/pre-package attr
 
   prePackages-unstable =
-    let pks = [ ./gerbil-libp2p.nix ./smug-gerbil.nix ./ftw.nix
-                ./gerbil-utils.nix ./gerbil-crypto.nix ./gerbil-poo.nix
-                ./gerbil-persist.nix ./gerbil-ethereum.nix ./glow-lang.nix ];
-        call = pkg: callPackage pkg prePackage-defaults;
-        pkgName = pkg: lib.removeSuffix ".nix" (baseNameOf pkg);
-        f = pkg: { name = pkgName pkg; value = call pkg; }; in
-    builtins.listToAttrs (map f pks);
+    ppplToPpa
+      [ ./gerbil-leveldb.nix ./gerbil-lmdb.nix ./gerbil-mysql.nix
+        ./gerbil-libxml.nix ./gerbil-libyaml.nix
+        ./smug-gerbil.nix ./ftw.nix
+        ./gerbil-utils.nix ./gerbil-crypto.nix ./gerbil-poo.nix
+        ./gerbil-persist.nix ./gerbil-ethereum.nix
+        # ./gerbil-libp2p.nix
+        # ./glow-lang.nix
+      ];
 
   prePackage-defaults = {
     gerbil = pkgs.gerbil-unstable;
@@ -25,24 +32,23 @@
     softwareName = "";
   };
 
-  gerbilPackages-unstable =
-    builtins.mapAttrs (_: gerbilPackage) prePackages-unstable;
+  ppaToPl = builtins.mapAttrs (_: gerbilPackage);
+  gerbilPackages-unstable = ppaToPl prePackages-unstable;
 
   resolve-pre-src = pre-src: pre-src.fun (removeAttrs pre-src ["fun"]);
 
-  gerbilVersionFromGit = pkg:
-    let version-path = "${pkg.passthru.pre-pkg.version-path}.ss"; in
-    if builtins.pathExists version-path then
+  gerbilVersionFromGit = srcDir: version-path:
+    let version-file = "${srcDir}/${version-path}.ss"; in
+    if builtins.pathExists version-file then
       let m =
         builtins.match "\\(import :clan/versioning.*\\)\n\\(register-software \"([-_.A-Za-z0-9]+)\" \"([-_.A-Za-z0-9]+)\"\\) ;; ([-0-9]+)\n"
-          (builtins.readFile version-path); in
-          { version = builtins.elemAt m 2; git-version = builtins.elemAt m 1; }
-     else { version = "0.0";
-            git-version = let gitpath = "${toString pkg.src}/.git"; in
+          (builtins.readFile version-file); in
+          { version = "${builtins.elemAt m 2}-git"; git-version = builtins.elemAt m 1; }
+     else { version = "0.0-git";
+            git-version = let gitpath = "${srcDir}/.git"; in
               if builtins.pathExists gitpath then lib.commitIdFromGitRepo gitpath else "0"; };
 
-  gerbilSkippableFiles = [".git" ".build" ".build_outputs" "run" "result" "dep" "BLAH"
-                          "version.ss" "tmp.nix"];
+  gerbilSkippableFiles = [".git" ".build" ".build_outputs" "run" "result" "dep" "BLAH" "tmp.nix"];
 
   gerbilSourceFilter = path: type:
     let baseName = baseNameOf path; in
@@ -66,9 +72,12 @@
     if old-sha256 == new-sha256 then {} else
     view "Overriding ${name} old-sha256: ${old-sha256} new-sha256: ${new-sha256}"
     { ${name} = super.${name} // {
-        pre-src = new-pre-src;
-        version = "override";
-        git-version = if new-pre-src ? rev then lib.substring 0 7 new-pre-src.rev else "unknown";};};
+                       pre-src = new-pre-src;
+                       version = "override";
+                       git-version = if new-pre-src ? rev
+                                     then lib.substring 0 7 new-pre-src.rev
+                                     else "unknown";};
+                     };
 
   pkgsOverrideGerbilPackageSrc = name: pre-src: pkgs: super: {
     gerbil-support = (super-support:
diff --git a/pkgs/development/compilers/gerbil/gerbil-utils.nix b/pkgs/development/compilers/gerbil/gerbil-utils.nix
index 4e7042fe4f3c..a0419d71e47b 100644
--- a/pkgs/development/compilers/gerbil/gerbil-utils.nix
+++ b/pkgs/development/compilers/gerbil/gerbil-utils.nix
@@ -2,8 +2,8 @@
 
 {
   pname = "gerbil-utils";
-  version = "unstable-2023-07-22";
-  git-version = "0.2-198-g2fb01ce";
+  version = "unstable-2023-09-18";
+  git-version = "0.2-199-ga604965";
   softwareName = "Gerbil-utils";
   gerbil-package = "clan";
   version-path = "version";
@@ -12,8 +12,8 @@
     fun = fetchFromGitHub;
     owner = "fare";
     repo = "gerbil-utils";
-    rev = "2fb01ce0b302f232f5c4daf4987457b6357d609d";
-    sha256 = "127q98gk1x6y1nlkkpnbnkz989ybpszy7aiy43hzai2q6xn4nv72";
+    rev = "a6049651d163a23bb4a876b9745dd572f1eaf536";
+    sha256 = "1k4g4qdzrx72bb14y5cb045bwkfzvmlsaxlga1j7w1vm6ann5lp2";
   };
 
   meta = with lib; {