about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/sbcl
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/sbcl')
-rw-r--r--nixpkgs/pkgs/development/compilers/sbcl/bootstrap.nix79
-rw-r--r--nixpkgs/pkgs/development/compilers/sbcl/default.nix112
2 files changed, 191 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/compilers/sbcl/bootstrap.nix b/nixpkgs/pkgs/development/compilers/sbcl/bootstrap.nix
new file mode 100644
index 000000000000..056ad7454600
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/sbcl/bootstrap.nix
@@ -0,0 +1,79 @@
+{ stdenv, fetchurl, makeWrapper }:
+
+let
+  options = rec {
+    x86_64-darwin = rec {
+      version = "1.2.11";
+      system = "x86-64-darwin";
+      sha256 = "0lh4gpvi8hl6g6b9321g5pwh8sk3218i7h4lx7p3vd9z0cf3lz85";
+    };
+    x86_64-linux = rec {
+      version = "1.3.16";
+      system = "x86-64-linux";
+      sha256 = "0sq2dylwwyqfwkbdvcgqwz3vay9v895zpb0fyzsiwy31d1x9pr2s";
+    };
+    i686-linux = rec {
+      version = "1.2.7";
+      system = "x86-linux";
+      sha256 = "07f3bz4br280qvn85i088vpzj9wcz8wmwrf665ypqx181pz2ai3j";
+    };
+    aarch64-linux = rec {
+      version = "1.3.16";
+      system = "arm64-linux";
+      sha256 = "0q1brz9c49xgdljzfx8rpxxnlwhadxkcy5kg0mcd9wnxygind1cl";
+    };
+    armv7l-linux = rec {
+      version = "1.2.14";
+      system = "armhf-linux";
+      sha256 = "0sp5445rbvms6qvzhld0kwwvydw51vq5iaf4kdqsf2d9jvaz3yx5";
+    };
+    armv6l-linux = armv7l-linux;
+    x86_64-freebsd = rec {
+      version = "1.2.7";
+      system = "x86-64-freebsd";
+      sha256 = "14k42xiqd2rrim4pd5k5pjcrpkac09qnpynha8j1v4jngrvmw7y6";
+    };
+    x86_64-solaris = rec {
+      version = "1.2.7";
+      system = "x86-64-solaris";
+      sha256 = "05c12fmac4ha72k1ckl6i780rckd7jh4g5s5hiic7fjxnf1kx8d0";
+    };
+  };
+  cfg = options.${stdenv.hostPlatform.system};
+in
+assert builtins.hasAttr stdenv.hostPlatform.system options;
+stdenv.mkDerivation rec {
+  name    = "sbcl-bootstrap-${version}";
+  version = cfg.version;
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/sbcl/sbcl/${version}/sbcl-${version}-${cfg.system}-binary.tar.bz2";
+    sha256 = cfg.sha256;
+  };
+
+  buildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -p src/runtime/sbcl $out/bin
+
+    mkdir -p $out/share/sbcl
+    cp -p src/runtime/sbcl $out/share/sbcl
+    cp -p output/sbcl.core $out/share/sbcl
+    mkdir -p $out/bin
+    makeWrapper $out/share/sbcl/sbcl $out/bin/sbcl \
+      --add-flags "--core $out/share/sbcl/sbcl.core"
+  '';
+
+  postFixup = stdenv.lib.optionalString (!stdenv.isAarch32 && stdenv.isLinux) ''
+    patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $out/share/sbcl/sbcl
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Lisp compiler";
+    homepage = http://www.sbcl.org;
+    license = licenses.publicDomain; # and FreeBSD
+    maintainers = [maintainers.raskin maintainers.tohl];
+    platforms = attrNames options;
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/sbcl/default.nix b/nixpkgs/pkgs/development/compilers/sbcl/default.nix
new file mode 100644
index 000000000000..469d7847409f
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/sbcl/default.nix
@@ -0,0 +1,112 @@
+{ stdenv, fetchurl, writeText, sbclBootstrap
+, sbclBootstrapHost ? "${sbclBootstrap}/bin/sbcl --disable-debugger --no-userinit --no-sysinit"
+, threadSupport ? (stdenv.isi686 || stdenv.isx86_64 || "aarch64-linux" == stdenv.hostPlatform.system)
+  # Meant for sbcl used for creating binaries portable to non-NixOS via save-lisp-and-die.
+  # Note that the created binaries still need `patchelf --set-interpreter ...`
+  # to get rid of ${glibc} dependency.
+, purgeNixReferences ? false
+, texinfo
+}:
+
+stdenv.mkDerivation rec {
+  name    = "sbcl-${version}";
+  version = "1.5.1";
+
+  src = fetchurl {
+    url    = "mirror://sourceforge/project/sbcl/sbcl/${version}/${name}-source.tar.bz2";
+    sha256 = "08z62qba0kmm15k93s2rq7ipi769895g8iwigcp20qjh6amwnwph";
+  };
+
+  buildInputs = [texinfo];
+
+  patchPhase = ''
+    echo '"${version}.nixos"' > version.lisp-expr
+    echo "
+    (lambda (features)
+      (flet ((enable (x)
+               (pushnew x features))
+             (disable (x)
+               (setf features (remove x features))))
+    ''
+    + (if threadSupport then "(enable :sb-thread)" else "(disable :sb-thread)")
+    + stdenv.lib.optionalString stdenv.isAarch32 "(enable :arm)"
+    + ''
+      )) " > customize-target-features.lisp
+
+    pwd
+
+    # SBCL checks whether files are up-to-date in many places..
+    # Unfortunately, same timestamp is not good enough
+    sed -e 's@> x y@>= x y@' -i contrib/sb-aclrepl/repl.lisp
+    #sed -e '/(date)/i((= date 2208988801) 2208988800)' -i contrib/asdf/asdf.lisp
+    sed -i src/cold/slam.lisp -e \
+      '/file-write-date input/a)'
+    sed -i src/cold/slam.lisp -e \
+      '/file-write-date output/i(or (and (= 2208988801 (file-write-date output)) (= 2208988801 (file-write-date input)))'
+    sed -i src/code/target-load.lisp -e \
+      '/date defaulted-fasl/a)'
+    sed -i src/code/target-load.lisp -e \
+      '/date defaulted-source/i(or (and (= 2208988801 (file-write-date defaulted-source-truename)) (= 2208988801 (file-write-date defaulted-fasl-truename)))'
+
+    # Fix the tests
+    sed -e '5,$d' -i contrib/sb-bsd-sockets/tests.lisp
+    sed -e '5,$d' -i contrib/sb-simple-streams/*test*.lisp
+
+    # Use whatever `cc` the stdenv provides
+    substituteInPlace src/runtime/Config.x86-64-darwin --replace gcc cc
+
+    substituteInPlace src/runtime/Config.x86-64-darwin \
+      --replace mmacosx-version-min=10.4 mmacosx-version-min=10.5
+  ''
+  + (if purgeNixReferences
+    then
+      # This is the default location to look for the core; by default in $out/lib/sbcl
+      ''
+        sed 's@^\(#define SBCL_HOME\) .*$@\1 "/no-such-path"@' \
+          -i src/runtime/runtime.c
+      ''
+    else
+      # Fix software version retrieval
+      ''
+        sed -e "s@/bin/uname@$(command -v uname)@g" -i src/code/*-os.lisp \
+          src/code/run-program.lisp
+      ''
+    );
+
+
+  preBuild = ''
+    export INSTALL_ROOT=$out
+    mkdir -p test-home
+    export HOME=$PWD/test-home
+  '';
+
+  buildPhase = ''
+    sh make.sh --prefix=$out --xc-host="${sbclBootstrapHost}"
+    (cd doc/manual ; make info)
+  '';
+
+  installPhase = ''
+    INSTALL_ROOT=$out sh install.sh
+  ''
+  + stdenv.lib.optionalString (!purgeNixReferences) ''
+    cp -r src $out/lib/sbcl
+    cp -r contrib $out/lib/sbcl
+    cat >$out/lib/sbcl/sbclrc <<EOF
+     (setf (logical-pathname-translations "SYS")
+       '(("SYS:SRC;**;*.*.*" #P"$out/lib/sbcl/src/**/*.*")
+         ("SYS:CONTRIB;**;*.*.*" #P"$out/lib/sbcl/contrib/**/*.*")))
+    EOF
+  '';
+
+  setupHook = stdenv.lib.optional purgeNixReferences (writeText "setupHook.sh" ''
+    addEnvHooks "$targetOffset" _setSbclHome
+    _setSbclHome() {
+      export SBCL_HOME='@out@/lib/sbcl/'
+    }
+  '');
+
+  meta = sbclBootstrap.meta // {
+    inherit version;
+    updateWalker = true;
+  };
+}