2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv
|
2018-12-19 11:16:06 +00:00
|
|
|
, fetchurl
|
|
|
|
, bash
|
|
|
|
, unzip
|
|
|
|
, glibc
|
|
|
|
, openssl
|
|
|
|
, libgit2
|
2019-11-10 16:44:34 +00:00
|
|
|
, libGLU, libGL
|
2018-12-19 11:16:06 +00:00
|
|
|
, freetype
|
|
|
|
, xorg
|
2021-06-10 03:57:09 +01:00
|
|
|
, alsa-lib
|
2018-12-19 11:16:06 +00:00
|
|
|
, cairo
|
|
|
|
, libuuid
|
|
|
|
, autoreconfHook
|
|
|
|
, gcc48
|
2019-02-26 11:45:54 +00:00
|
|
|
, runtimeShell
|
2018-12-19 11:16:06 +00:00
|
|
|
, ... }:
|
2016-01-14 10:33:59 +00:00
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
{ name, src, version, source-date, source-url, ... }:
|
2016-01-14 10:33:59 +00:00
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
# Build the Pharo VM
|
2016-01-14 10:33:59 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2017-04-17 18:00:23 +01:00
|
|
|
inherit name src;
|
2016-01-14 10:33:59 +00:00
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
# Command line invocation name.
|
|
|
|
# Distinct name for 64-bit builds because they only work with 64-bit images.
|
|
|
|
cmd = if stdenv.is64bit then "pharo-spur64" else "pharo-spur";
|
2016-01-14 10:33:59 +00:00
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
# Choose desired VM sources. Separate for 32-bit and 64-bit VM.
|
|
|
|
# (Could extent to building more VM variants e.g. SpurV3, Sista, etc.)
|
|
|
|
vm = if stdenv.is64bit then "spur64src" else "spursrc";
|
2016-01-16 15:28:12 +00:00
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
# Choose target platform name in the format used by the vm.
|
|
|
|
flavor =
|
|
|
|
if stdenv.isLinux && stdenv.isi686 then "linux32x86"
|
|
|
|
else if stdenv.isLinux && stdenv.isx86_64 then "linux64x64"
|
|
|
|
else if stdenv.isDarwin && stdenv.isi686 then "macos32x86"
|
|
|
|
else if stdenv.isDarwin && stdenv.isx86_64 then "macos64x64"
|
2018-01-02 18:19:37 +00:00
|
|
|
else throw "Unsupported platform: only Linux/Darwin x86/x64 are supported.";
|
2016-01-14 10:33:59 +00:00
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
# Shared data (for the sources file)
|
2021-01-23 17:15:07 +00:00
|
|
|
pharo-share = import ./share.nix { inherit lib stdenv fetchurl unzip; };
|
2016-03-03 19:01:21 +00:00
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
# Note: -fPIC causes the VM to segfault.
|
2017-07-10 04:49:29 +01:00
|
|
|
hardeningDisable = [ "format" "pic"
|
|
|
|
# while the VM depends on <= gcc48:
|
|
|
|
"stackprotector" ];
|
2016-03-03 19:01:21 +00:00
|
|
|
|
2020-10-26 00:41:28 +00:00
|
|
|
# gcc 4.8 used for the build:
|
|
|
|
#
|
|
|
|
# gcc5 crashes during compilation; gcc >= 4.9 produces a
|
|
|
|
# binary that crashes when forking a child process. See:
|
|
|
|
# http://forum.world.st/OSProcess-fork-issue-with-Debian-built-VM-td4947326.html
|
|
|
|
#
|
|
|
|
# (stack protection is disabled above for gcc 4.8 compatibility.)
|
2021-03-05 18:11:00 +00:00
|
|
|
nativeBuildInputs = [ autoreconfHook unzip ];
|
2020-10-26 00:41:28 +00:00
|
|
|
buildInputs = [
|
|
|
|
bash
|
|
|
|
glibc
|
|
|
|
openssl
|
|
|
|
gcc48
|
|
|
|
libGLU libGL
|
|
|
|
freetype
|
|
|
|
xorg.libX11
|
|
|
|
xorg.libICE
|
|
|
|
xorg.libSM
|
2021-06-10 03:57:09 +01:00
|
|
|
alsa-lib
|
2020-10-26 00:41:28 +00:00
|
|
|
cairo
|
|
|
|
pharo-share
|
|
|
|
libuuid
|
|
|
|
];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
# Regenerate the configure script.
|
|
|
|
# Unnecessary? But the build breaks without this.
|
|
|
|
autoreconfPhase = ''
|
2017-06-30 08:50:06 +01:00
|
|
|
pushd platforms/unix/config
|
2017-06-29 19:09:06 +01:00
|
|
|
make
|
|
|
|
popd
|
2016-01-14 10:33:59 +00:00
|
|
|
'';
|
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
# Configure with options modeled on the 'mvm' build script from the vm.
|
|
|
|
configureScript = "platforms/unix/config/configure";
|
|
|
|
configureFlags = [ "--without-npsqueak"
|
|
|
|
"--with-vmversion=5.0"
|
|
|
|
"--with-src=${vm}" ];
|
2022-05-28 20:57:22 +01:00
|
|
|
|
|
|
|
# -fcommon is a workaround build failure on -fno-common toolchains like upstream
|
|
|
|
# gcc-10. Otherwise build fails as:
|
|
|
|
# ld: vm/vm.a(cogit.o):/build/source/spur64src/vm/cointerp.h:358: multiple definition of `checkAllocFiller';
|
|
|
|
# vm/vm.a(gcc3x-cointerp.o):/build/source/spur64src/vm/cointerp.h:358: first defined here
|
|
|
|
NIX_CFLAGS_COMPILE = "-fcommon";
|
|
|
|
|
2017-07-05 05:54:50 +01:00
|
|
|
CFLAGS = "-DPharoVM -DIMMUTABILITY=1 -msse2 -D_GNU_SOURCE -DCOGMTVM=0 -g -O2 -DNDEBUG -DDEBUGVM=0";
|
2017-04-17 18:00:23 +01:00
|
|
|
LDFLAGS = "-Wl,-z,now";
|
|
|
|
|
|
|
|
# VM sources require some patching before build.
|
|
|
|
prePatch = ''
|
2017-06-30 08:50:06 +01:00
|
|
|
patchShebangs build.${flavor}
|
2017-04-17 18:00:23 +01:00
|
|
|
# Fix hard-coded path to /bin/rm in a script
|
2017-06-30 08:50:06 +01:00
|
|
|
sed -i -e 's:/bin/rm:rm:' platforms/unix/config/mkmf
|
2017-04-17 18:00:23 +01:00
|
|
|
# Fill in mandatory metadata about the VM source version
|
|
|
|
sed -i -e 's!\$Date\$!$Date: ${source-date} $!' \
|
|
|
|
-e 's!\$Rev\$!$Rev: ${version} $!' \
|
|
|
|
-e 's!\$URL\$!$URL: ${source-url} $!' \
|
2017-06-30 08:50:06 +01:00
|
|
|
platforms/Cross/vm/sqSCCSVersion.h
|
2017-04-17 18:00:23 +01:00
|
|
|
'';
|
2016-01-14 10:33:59 +00:00
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
# Note: --with-vmcfg configure option is broken so copy plugin specs to ./
|
|
|
|
preConfigure = ''
|
2017-06-30 08:24:09 +01:00
|
|
|
cp build."${flavor}"/pharo.cog.spur/plugins.{ext,int} .
|
2017-04-17 18:00:23 +01:00
|
|
|
'';
|
2016-01-14 10:33:59 +00:00
|
|
|
|
2017-04-17 18:00:23 +01:00
|
|
|
# (No special build phase.)
|
2016-01-14 10:33:59 +00:00
|
|
|
|
2018-12-19 11:16:06 +00:00
|
|
|
installPhase = let
|
|
|
|
libs = [
|
|
|
|
cairo
|
|
|
|
libgit2
|
2019-11-10 16:44:34 +00:00
|
|
|
libGLU libGL
|
2018-12-19 11:16:06 +00:00
|
|
|
freetype
|
|
|
|
openssl
|
|
|
|
libuuid
|
2021-06-10 03:57:09 +01:00
|
|
|
alsa-lib
|
2018-12-19 11:16:06 +00:00
|
|
|
xorg.libICE
|
|
|
|
xorg.libSM
|
|
|
|
];
|
|
|
|
in ''
|
2017-04-17 18:00:23 +01:00
|
|
|
# Install in working directory and then copy
|
|
|
|
make install-squeak install-plugins prefix=$(pwd)/products
|
|
|
|
|
|
|
|
# Copy binaries & rename from 'squeak' to 'pharo'
|
2017-06-29 19:09:06 +01:00
|
|
|
mkdir -p "$out"
|
|
|
|
cp products/lib/squeak/5.0-*/squeak "$out/pharo"
|
|
|
|
cp -r products/lib/squeak/5.0-*/*.so "$out"
|
|
|
|
ln -s "${pharo-share}/lib/"*.sources "$out"
|
2017-04-17 18:00:23 +01:00
|
|
|
|
|
|
|
# Create a shell script to run the VM in the proper environment.
|
2017-06-29 19:09:06 +01:00
|
|
|
#
|
2017-04-17 18:00:23 +01:00
|
|
|
# These wrapper puts all relevant libraries into the
|
|
|
|
# LD_LIBRARY_PATH. This is important because various C code in the VM
|
|
|
|
# and Smalltalk code in the image will search for them there.
|
2017-06-29 19:09:06 +01:00
|
|
|
mkdir -p "$out/bin"
|
2017-04-17 18:00:23 +01:00
|
|
|
|
|
|
|
# Note: include ELF rpath in LD_LIBRARY_PATH for finding libc.
|
2021-01-23 17:15:07 +00:00
|
|
|
libs=$out:$(patchelf --print-rpath "$out/pharo"):${lib.makeLibraryPath libs}
|
2017-04-17 18:00:23 +01:00
|
|
|
|
|
|
|
# Create the script
|
2017-06-29 19:09:06 +01:00
|
|
|
cat > "$out/bin/${cmd}" <<EOF
|
2019-02-26 11:45:54 +00:00
|
|
|
#!${runtimeShell}
|
2016-01-14 10:33:59 +00:00
|
|
|
set -f
|
2020-01-02 00:29:34 +00:00
|
|
|
LD_LIBRARY_PATH="\$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$libs" exec $out/pharo "\$@"
|
2016-01-14 10:33:59 +00:00
|
|
|
EOF
|
2017-06-29 19:09:06 +01:00
|
|
|
chmod +x "$out/bin/${cmd}"
|
2018-12-19 11:16:06 +00:00
|
|
|
ln -s ${libgit2}/lib/libgit2.so* "$out/"
|
2016-01-14 10:33:59 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2016-01-14 10:33:59 +00:00
|
|
|
description = "Clean and innovative Smalltalk-inspired environment";
|
2020-10-26 00:41:28 +00:00
|
|
|
homepage = "https://pharo.org";
|
2016-01-14 10:33:59 +00:00
|
|
|
longDescription = ''
|
|
|
|
Pharo's goal is to deliver a clean, innovative, free open-source
|
|
|
|
Smalltalk-inspired environment. By providing a stable and small core
|
|
|
|
system, excellent dev tools, and maintained releases, Pharo is an
|
|
|
|
attractive platform to build and deploy mission critical applications.
|
|
|
|
|
|
|
|
This package provides the executable VM. You should probably not care
|
|
|
|
about this package (which represents a packaging detail) and have a
|
|
|
|
look at the pharo-vm-core package instead.
|
|
|
|
|
|
|
|
Please fill bug reports on http://bugs.pharo.org under the 'Ubuntu
|
|
|
|
packaging (ppa:pharo/stable)' project.
|
|
|
|
'';
|
2018-01-02 18:19:37 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = [ maintainers.lukego ];
|
|
|
|
platforms = [ "i686-linux" "x86_64-linux" ];
|
2016-01-14 10:33:59 +00:00
|
|
|
};
|
|
|
|
}
|