2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv
|
2020-10-07 09:15:18 +00:00
|
|
|
, fetchurl
|
2021-06-28 23:13:55 +00:00
|
|
|
, fetchpatch
|
2020-10-07 09:15:18 +00:00
|
|
|
, autoconf213
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config
|
2020-10-07 09:15:18 +00:00
|
|
|
, perl
|
|
|
|
, python3
|
|
|
|
, zip
|
|
|
|
, buildPackages
|
|
|
|
, which
|
|
|
|
, readline
|
|
|
|
, zlib
|
|
|
|
, icu67
|
|
|
|
, cargo
|
|
|
|
, rustc
|
|
|
|
, rust-cbindgen
|
|
|
|
, yasm
|
2021-12-06 16:07:01 +00:00
|
|
|
, llvmPackages_12
|
2020-10-07 09:15:18 +00:00
|
|
|
, nspr
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "spidermonkey";
|
2021-12-06 16:07:01 +00:00
|
|
|
version = "78.15.0";
|
2020-10-07 09:15:18 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://mozilla/firefox/releases/${version}esr/source/firefox-${version}esr.source.tar.xz";
|
2021-12-06 16:07:01 +00:00
|
|
|
sha256 = "0l91cxdc5v9fps79ckb1kid4gw6v5qng1jd9zvaacwaiv628shx4";
|
2020-10-07 09:15:18 +00:00
|
|
|
};
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
patches = [
|
|
|
|
# Fix build failure on armv7l using Debian patch
|
|
|
|
# Upstream bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1526653
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://salsa.debian.org/mozilla-team/firefox/commit/fd6847c9416f9eebde636e21d794d25d1be8791d.patch";
|
|
|
|
sha256 = "02b7zwm6vxmk61aj79a6m32s1k5sr0hwm3q1j4v6np9jfyd10g1j";
|
|
|
|
})
|
2022-01-26 04:04:25 +00:00
|
|
|
|
|
|
|
# Remove this when updating to 79 - The patches are already applied upstream
|
|
|
|
# https://bugzilla.mozilla.org/show_bug.cgi?id=1318905
|
|
|
|
|
|
|
|
# Combination of 3 changesets, modified to apply on 78:
|
|
|
|
# - https://hg.mozilla.org/mozilla-central/rev/06d7e1b6b7e7
|
|
|
|
# - https://hg.mozilla.org/mozilla-central/rev/ec48f15d085c
|
|
|
|
# - https://hg.mozilla.org/mozilla-central/rev/6803dda74d33
|
|
|
|
./add-riscv64-support.patch
|
2021-06-28 23:13:55 +00:00
|
|
|
];
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
setOutputFlags = false; # Configure script only understands --includedir
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
autoconf213
|
|
|
|
cargo
|
2021-12-06 16:07:01 +00:00
|
|
|
llvmPackages_12.llvm # for llvm-objdump
|
2020-10-07 09:15:18 +00:00
|
|
|
perl
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config
|
2020-10-07 09:15:18 +00:00
|
|
|
python3
|
|
|
|
rust-cbindgen
|
|
|
|
rustc
|
|
|
|
which
|
|
|
|
yasm # to buid icu? seems weird
|
|
|
|
zip
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
icu67
|
|
|
|
nspr
|
|
|
|
readline
|
|
|
|
zlib
|
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
export CXXFLAGS="-fpermissive"
|
|
|
|
export LIBXUL_DIST=$out
|
|
|
|
export PYTHON="${buildPackages.python3.interpreter}"
|
|
|
|
|
|
|
|
# We can't build in js/src/, so create a build dir
|
|
|
|
mkdir obj
|
|
|
|
cd obj/
|
|
|
|
configureScript=../js/src/configure
|
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--with-system-zlib"
|
|
|
|
"--with-system-nspr"
|
|
|
|
"--with-system-icu"
|
|
|
|
"--with-intl-api"
|
|
|
|
"--enable-readline"
|
|
|
|
"--enable-shared-js"
|
|
|
|
"--disable-jemalloc"
|
|
|
|
# Fedora and Arch disable optimize, but it doesn't seme to be necessary
|
|
|
|
# It turns on -O3 which some gcc version had a problem with:
|
|
|
|
# https://src.fedoraproject.org/rpms/mozjs38/c/761399aba092bcb1299bb4fccfd60f370ab4216e
|
|
|
|
"--enable-optimize"
|
|
|
|
"--enable-release"
|
2021-02-05 17:12:51 +00:00
|
|
|
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
2020-10-07 09:15:18 +00:00
|
|
|
# Spidermonkey seems to use different host/build terminology for cross
|
|
|
|
# compilation here.
|
|
|
|
"--host=${stdenv.buildPlatform.config}"
|
|
|
|
"--target=${stdenv.hostPlatform.config}"
|
|
|
|
];
|
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
# mkDerivation by default appends --build/--host to configureFlags when cross compiling
|
|
|
|
# These defaults are bogus for Spidermonkey - avoid passing them by providing an empty list
|
2020-10-07 09:15:18 +00:00
|
|
|
configurePlatforms = [ ];
|
|
|
|
|
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
|
|
|
2022-01-26 04:04:25 +00:00
|
|
|
# cc-rs insists on using -mabi=lp64 (soft-float) for riscv64,
|
|
|
|
# while we have a double-float toolchain
|
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString (with stdenv.hostPlatform; isRiscV && is64bit) "-mabi=lp64d";
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
# Remove unnecessary static lib
|
|
|
|
preFixup = ''
|
2020-11-06 00:33:48 +00:00
|
|
|
moveToOutput bin/js78-config "$dev"
|
2020-10-07 09:15:18 +00:00
|
|
|
rm $out/lib/libjs_static.ajs
|
2020-11-06 00:33:48 +00:00
|
|
|
ln -s $out/bin/js78 $out/bin/js
|
2020-10-07 09:15:18 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-03-19 17:17:44 +00:00
|
|
|
postPatch = ''
|
|
|
|
# This patch is a manually applied fix of
|
|
|
|
# https://bugzilla.mozilla.org/show_bug.cgi?id=1644600
|
|
|
|
# Once that bug is fixed, this can be removed.
|
|
|
|
# This is needed in, for example, `zeroad`.
|
|
|
|
substituteInPlace js/public/StructuredClone.h \
|
|
|
|
--replace "class SharedArrayRawBufferRefs {" \
|
|
|
|
"class JS_PUBLIC_API SharedArrayRawBufferRefs {"
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-10-07 09:15:18 +00:00
|
|
|
description = "Mozilla's JavaScript engine written in C/C++";
|
2021-03-19 17:17:44 +00:00
|
|
|
homepage = "https://spidermonkey.dev/";
|
2020-10-07 09:15:18 +00:00
|
|
|
license = licenses.gpl2; # TODO: MPL/GPL/LGPL tri-license.
|
2020-11-06 00:33:48 +00:00
|
|
|
maintainers = with maintainers; [ abbradar lostnet ];
|
2020-10-07 09:15:18 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|