diff --git a/CodeCoverage.patch b/CodeCoverage.patch new file mode 100644 index 0000000..53e9475 --- /dev/null +++ b/CodeCoverage.patch @@ -0,0 +1,107 @@ +From e5a2eb99f653ae03c67e536df1d55d265a0a1605 Mon Sep 17 00:00:00 2001 +From: Evan Welsh +Date: Mon, 10 Aug 2020 13:17:36 -0500 +Subject: [PATCH] Bug 1654696 - Implement code coverage JSAPI. + r=nbp,ptomato,jwalden + +--- + js/public/experimental/CodeCoverage.h | 25 +++++++++++++++++++++++++ + js/src/jsfriendapi.cpp | 3 +++ + js/src/moz.build | 1 + + js/src/shell/js.cpp | 11 ++++++----- + 4 files changed, 35 insertions(+), 5 deletions(-) + create mode 100644 js/public/experimental/CodeCoverage.h + +diff --git a/js/public/experimental/CodeCoverage.h b/js/public/experimental/CodeCoverage.h +new file mode 100644 +index 000000000..06cc0c9ca +--- /dev/null ++++ b/js/public/experimental/CodeCoverage.h +@@ -0,0 +1,25 @@ ++/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- ++ * vim: set ts=8 sts=2 et sw=2 tw=80: ++ * This Source Code Form is subject to the terms of the Mozilla Public ++ * License, v. 2.0. If a copy of the MPL was not distributed with this ++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ ++ ++#ifndef js_experimental_CodeCoverage_h ++#define js_experimental_CodeCoverage_h ++ ++#include "jstypes.h" // JS_FRIEND_API ++ ++struct JS_PUBLIC_API JSContext; ++ ++namespace js { ++ ++/** ++ * Enable the collection of lcov code coverage metrics. ++ * Must be called before a runtime is created and before any calls to ++ * GetCodeCoverageSummary. ++ */ ++extern JS_FRIEND_API void EnableCodeCoverage(); ++ ++} // namespace js ++ ++#endif // js_experimental_CodeCoverage_h +diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp +index af7a03bd4..5f20c6576 100644 +--- a/js/src/jsfriendapi.cpp ++++ b/js/src/jsfriendapi.cpp +@@ -20,6 +20,7 @@ + #include "gc/PublicIterators.h" + #include "gc/WeakMap.h" + #include "js/CharacterEncoding.h" ++#include "js/experimental/CodeCoverage.h" // js::EnableCodeCoverage + #include "js/Printf.h" + #include "js/Proxy.h" + #include "js/Wrapper.h" +@@ -1465,6 +1466,8 @@ JS_FRIEND_API void js::EnableAccessValidation(JSContext* cx, bool enabled) { + cx->enableAccessValidation = enabled; + } + ++JS_FRIEND_API void js::EnableCodeCoverage() { js::coverage::EnableLCov(); } ++ + JS_FRIEND_API void js::SetRealmValidAccessPtr(JSContext* cx, + JS::HandleObject global, + bool* accessp) { +diff --git a/js/src/moz.build b/js/src/moz.build +index deb15d83a..b4e9e2b02 100755 +--- a/js/src/moz.build ++++ b/js/src/moz.build +@@ -210,6 +210,7 @@ EXPORTS.js += [ + ] + + EXPORTS.js.experimental += [ ++ '../public/experimental/CodeCoverage.h', + '../public/experimental/SourceHook.h', + ] + +diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp +index 4b3f545e6..252dd24f0 100644 +--- a/js/src/shell/js.cpp ++++ b/js/src/shell/js.cpp +@@ -104,10 +104,11 @@ + #include "js/CompileOptions.h" + #include "js/ContextOptions.h" // JS::ContextOptions{,Ref} + #include "js/Debug.h" +-#include "js/Equality.h" // JS::SameValue +-#include "js/ErrorReport.h" // JS::PrintError +-#include "js/Exception.h" // JS::StealPendingExceptionStack +-#include "js/experimental/SourceHook.h" // js::{Set,Forget,}SourceHook ++#include "js/Equality.h" // JS::SameValue ++#include "js/ErrorReport.h" // JS::PrintError ++#include "js/Exception.h" // JS::StealPendingExceptionStack ++#include "js/experimental/CodeCoverage.h" // js::EnableCodeCoverage ++#include "js/experimental/SourceHook.h" // js::{Set,Forget,}SourceHook + #include "js/GCVector.h" + #include "js/Initialization.h" + #include "js/JSON.h" +@@ -11416,7 +11417,7 @@ int main(int argc, char** argv, char** envp) { + + enableCodeCoverage = op.getBoolOption("code-coverage"); + if (enableCodeCoverage) { +- coverage::EnableLCov(); ++ js::EnableCodeCoverage(); + } + + #ifdef JS_WITHOUT_NSPR diff --git a/mozjs78.spec b/mozjs78.spec index 5a29282..5c8620d 100644 --- a/mozjs78.spec +++ b/mozjs78.spec @@ -7,7 +7,7 @@ %global require_tests 1 %if 0%{?build_with_lto} -# LTO is default since F33 +# LTO is default since F33 and F32 package is backported as is, so no LTO there %else %define _lto_cflags %{nil} %endif @@ -24,7 +24,7 @@ Name: mozjs%{major} Version: 78.1.0 -Release: 1%{?dist} +Release: 2%{?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 @@ -46,6 +46,9 @@ 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 +# Backport fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1654696 +Patch16: CodeCoverage.patch + # armv7 fixes Patch17: armv7_disable_WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS.patch @@ -67,6 +70,7 @@ BuildRequires: perl-devel BuildRequires: pkgconfig(libffi) BuildRequires: pkgconfig(zlib) BuildRequires: python3-devel +BuildRequires: python3-setuptools BuildRequires: python3-six BuildRequires: readline-devel BuildRequires: zip @@ -102,6 +106,8 @@ pushd ../.. %patch14 -p1 %patch15 -p1 +%patch16 -p1 + %ifarch armv7hl # Disable WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS as it causes the compilation to fail # https://bugzilla.mozilla.org/show_bug.cgi?id=1526653 @@ -123,7 +129,7 @@ popd rm -rf ../../modules/zlib %build -# Prefer GCC, because clang doesn't support -fstack-clash-protection yet +# Prefer GCC for now export CC=gcc export CXX=g++ @@ -133,6 +139,11 @@ export CXX=g++ # https://github.com/japaric/cargo-call-stack/issues/25 export RUSTFLAGS="-C embed-bitcode" +%if 0%{?build_with_lto} +# https://github.com/ptomato/mozjs/commit/36bb7982b41e0ef9a65f7174252ab996cd6777bd +export CARGO_PROFILE_RELEASE_LTO=true +%endif + export CFLAGS="%{optflags}" export CXXFLAGS="$CFLAGS" export LINKFLAGS="%{?__global_ldflags}" @@ -243,5 +254,10 @@ PYTHONPATH=tests/lib %{__python3} jit-test/jit_test.py -s -t 1800 --no-progress %{_includedir}/mozjs-%{major}/ %changelog +* Mon Aug 17 2020 Frantisek Zatloukal - 78.1.0-2 +- Add BR: python3-setuptools +- Backport fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1654696 +- Set CARGO_PROFILE_RELEASE_LTO=true + * Tue Jul 28 2020 Frantisek Zatloukal - 78.1.0-1 - Initial mozjs78 package based on mozjs68