Blob Blame History Raw
%global major 78

# LTO - Enable in Release builds, but consider disabling for development as it increases compile time
%global build_with_lto    1

# Require tests to pass?
%global require_tests     1

%if 0%{?build_with_lto}
# LTO is default since F33 and F32 package is backported as is, so no LTO there
%define _lto_cflags %{nil}

# Require libatomic for ppc
%ifarch ppc
%global system_libatomic 1

# Big endian platforms
%ifarch ppc ppc64 s390 s390x
%global big_endian 1

Name:           mozjs%{major}
Version:        78.8.0
Release:        1%{?dist}
Summary:        SpiderMonkey JavaScript library

License:        MPLv2.0 and MPLv1.1 and BSD and GPLv2+ and GPLv3+ and LGPLv2+ and AFL and ASL 2.0

# Patches from mozjs68, rebased for mozjs78:
Patch01:        fix-soname.patch
Patch02:        copy-headers.patch
Patch03:        tests-increase-timeout.patch
Patch10:        icu_sources_data-Write-command-output-to-our-stderr.patch

# Build fixes -
Patch12:        emitter.patch

# Build fixes
Patch14:        init_patch.patch
# TODO: Check with mozilla for cause of these fails and re-enable spidermonkey compile time checks if needed
Patch15:        spidermonkey_checks_disable.patch

# armv7 fixes
Patch17:        armv7_disable_WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS.patch

# s390x/ppc64 fixes, TODO: file bug report upstream?
Patch18:        spidermonkey_style_check_disable_s390x.patch
Patch19:        0001-Skip-failing-tests-on-ppc64-and-s390x.patch

# Fix for ( SharedArrayRawBufferRefs is not exported )
Patch30:        FixSharedArray.diff

BuildRequires:  make
BuildRequires:  autoconf213
BuildRequires:  cargo
BuildRequires:  clang-devel
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  nasm
BuildRequires:  llvm
BuildRequires:  llvm-devel
BuildRequires:  rust
BuildRequires:  perl-devel
BuildRequires:  pkgconfig(libffi)
BuildRequires:  pkgconfig(zlib)
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-six
BuildRequires:  readline-devel
BuildRequires:  zip

%if 0%{?big_endian}
BuildRequires:  icu

%if 0%{?system_libatomic}
BuildRequires:  libatomic

SpiderMonkey is the code-name for Mozilla Firefox's C++ implementation of
JavaScript. It is intended to be embedded in other applications
that provide host environments for JavaScript.

%package        devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%setup -q -n firefox-%{version}/js/src

pushd ../..
%patch01 -p1
%patch02 -p1
%patch03 -p1
%patch09 -p1
%patch10 -p1

%patch12 -p1

%patch14 -p1
%patch15 -p1

%ifarch armv7hl
# Disable WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS as it causes the compilation to fail
%patch17 -p1

%ifarch s390x
%patch18 -p1

# Fixes for ppc64 and s390x, there is no need to keep it in ifarch here since mozilla tests support ifarch conditions
%patch19 -p1

# Export SharedArrayRawBufferRefs
%patch30 -p1

# Copy out the LICENSE file
cp LICENSE js/src/

# Remove zlib directory (to be sure using system version)
rm -rf ../../modules/zlib

# Prefer GCC for now
export CC=gcc
export CXX=g++

# Workaround
# error: options `-C embed-bitcode=no` and `-C lto` are incompatible
# error: could not compile `jsrust`.
export RUSTFLAGS="-C embed-bitcode"

%if 0%{?build_with_lto}

export CFLAGS="%{optflags}"
export LINKFLAGS="%{?__global_ldflags}"
export PYTHON="%{__python3}"

%configure \
  --without-system-icu \
  --with-system-zlib \
  --disable-tests \
  --disable-strip \
  --with-intl-api \
  --enable-readline \
  --enable-shared-js \
  --enable-optimize \
  --disable-debug \
  --enable-pie \

%if 0%{?big_endian}
echo "Generate big endian version of config/external/icu/data/icud67l.dat"
pushd ../..
  icupkg -tb config/external/icu/data/icudt67l.dat config/external/icu/data/icudt67b.dat
  rm -f config/external/icu/data/icudt*l.dat



# Fix permissions
chmod -x %{buildroot}%{_libdir}/pkgconfig/*.pc

# Avoid multilib conflicts
case `uname -i` in
  i386 | ppc | s390 | sparc )
  x86_64 | ppc64 | s390x | sparc64 )

if test -n "$wordsize"
  mv %{buildroot}%{_includedir}/mozjs-%{major}/js-config.h \

  cat >%{buildroot}%{_includedir}/mozjs-%{major}/js-config.h <<EOF

#include <bits/wordsize.h>

#if __WORDSIZE == 32
# include "js-config-32.h"
#elif __WORDSIZE == 64
# include "js-config-64.h"
# error "unexpected value for __WORDSIZE macro"



# Remove unneeded files
rm %{buildroot}%{_bindir}/js%{major}-config
rm %{buildroot}%{_libdir}/libjs_static.ajs

# Rename library and create symlinks, following fix-soname.patch
mv %{buildroot}%{_libdir}/libmozjs-%{major}.so \
ln -s libmozjs-%{major}.so.0.0.0 %{buildroot}%{_libdir}/libmozjs-%{major}.so.0
ln -s libmozjs-%{major}.so.0 %{buildroot}%{_libdir}/libmozjs-%{major}.so

# Run SpiderMonkey tests
%if 0%{?require_tests}
PYTHONPATH=tests/lib %{__python3} tests/ -d -s -t 1800 --no-progress --wpt=disabled ../../js/src/dist/bin/js%{major}
PYTHONPATH=tests/lib %{__python3} tests/ -d -s -t 1800 --no-progress --wpt=disabled ../../js/src/dist/bin/js%{major} || :

# Run basic JIT tests
%if 0%{?require_tests}
PYTHONPATH=tests/lib %{__python3} jit-test/ -s -t 1800 --no-progress ../../js/src/dist/bin/js%{major} basic
PYTHONPATH=tests/lib %{__python3} jit-test/ -s -t 1800 --no-progress ../../js/src/dist/bin/js%{major} basic || :


%doc README.html
%license LICENSE

%files devel

* Tue Feb 23 2021 Frantisek Zatloukal <> - 78.8.0-1
- Update to 78.8.0
- Add fix for MOZBZ#1644600

* Tue Jan 26 2021 Frantisek Zatloukal <> - 78.7.0-1
- Update to 78.7.0

* Tue Dec 15 2020 Frantisek Zatloukal <> - 78.6.0-1
- Update to 78.6.0

* Tue Nov 17 2020 Frantisek Zatloukal <> - 78.5.0-1
- Update to 78.5.0
- Build with: --enable-optimize, --disable-debug

* Mon Oct 19 2020 Frantisek Zatloukal <> - 78.4.0-1
- Update to 78.4.0

* Tue Sep 22 2020 Frantisek Zatloukal <> - 78.3.0-1
- Update to 78.3.0

* Mon Aug 24 2020 Frantisek Zatloukal <> - 78.2.0-1
- Update to 78.2.0

* Mon Aug 17 2020 Frantisek Zatloukal <> - 78.1.0-2
- Add BR: python3-setuptools
- Backport fix for

* Tue Jul 28 2020 Frantisek Zatloukal <> - 78.1.0-1
- Initial mozjs78 package based on mozjs68