Gentoo Archives: gentoo-commits

From: Marek Szuba <marecki@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-libs/nodejs/, net-libs/nodejs/files/
Date: Thu, 22 Apr 2021 15:27:35
Message-Id: 1619105232.5b43e0081fcb5059fc9e68a0aa7d2993a8805643.marecki@gentoo
1 commit: 5b43e0081fcb5059fc9e68a0aa7d2993a8805643
2 Author: Marek Szuba <marecki <AT> gentoo <DOT> org>
3 AuthorDate: Thu Apr 22 13:47:11 2021 +0000
4 Commit: Marek Szuba <marecki <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 22 15:27:12 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5b43e008
7
8 net-libs/nodejs-16.0.0: implement IUSE=lto
9
10 Note that the upstream patch which for the time being is required to
11 make LTO work only has an effect if the aforementioned USE flag is set.
12
13 Closes: https://bugs.gentoo.org/784995
14 Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>
15
16 net-libs/nodejs/files/nodejs-16.0.0-v8_lto.patch | 39 ++++++++++++++++++++++
17 net-libs/nodejs/metadata.xml | 1 +
18 ...odejs-16.0.0.ebuild => nodejs-16.0.0-r1.ebuild} | 12 +++++--
19 3 files changed, 50 insertions(+), 2 deletions(-)
20
21 diff --git a/net-libs/nodejs/files/nodejs-16.0.0-v8_lto.patch b/net-libs/nodejs/files/nodejs-16.0.0-v8_lto.patch
22 new file mode 100644
23 index 00000000000..a3e4acb02c3
24 --- /dev/null
25 +++ b/net-libs/nodejs/files/nodejs-16.0.0-v8_lto.patch
26 @@ -0,0 +1,39 @@
27 +From ea694e2b138d2f991989e09fc0e964fec3587b5f Mon Sep 17 00:00:00 2001
28 +From: Jesse Chan <jc@×××××.com>
29 +Date: Thu, 22 Apr 2021 19:41:09 +0800
30 +Subject: [PATCH] tools: disable LTO for "v8_cppgc_shared" target
31 +
32 +"PushAllRegistersAndIterateStack" is implemented in assembly and
33 +called from "stack.cc" via 'extern "C"'. [1]
34 +
35 +However, LTO does not work well with symbol usage from assembly. [2]
36 +
37 +This change workarounds the issue by disabling LTO for the target.
38 +
39 +With GCC 10 and "./configure --enable-lto", compilation succeeds
40 +after this change.
41 +
42 +[1] v8/v8@c10863153
43 +[2] https://gcc.gnu.org/wiki/LinkTimeOptimizationFAQ#Symbol_usage_from_assembly_language
44 +
45 +Refs: #35957
46 +Refs: #38335
47 +Signed-off-by: Jesse Chan <jc@×××××.com>
48 +---
49 + tools/v8_gypfiles/v8.gyp | 3 +++
50 + 1 file changed, 3 insertions(+)
51 +
52 +diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp
53 +index ccb5984f47d..377e12d1fdc 100644
54 +--- a/tools/v8_gypfiles/v8.gyp
55 ++++ b/tools/v8_gypfiles/v8.gyp
56 +@@ -1378,6 +1378,9 @@
57 + '<(V8_ROOT)/src/heap/base/worklist.h',
58 + ],
59 + 'conditions': [
60 ++ ['enable_lto=="true"', {
61 ++ 'cflags_cc': [ '-fno-lto' ],
62 ++ }],
63 + ['clang or OS!="win"', {
64 + 'conditions': [
65 + ['_toolset == "host" and host_arch == "x64" or _toolset == "target" and target_arch=="x64"', {
66
67 diff --git a/net-libs/nodejs/metadata.xml b/net-libs/nodejs/metadata.xml
68 index db1b9aefa8e..15befbfa251 100644
69 --- a/net-libs/nodejs/metadata.xml
70 +++ b/net-libs/nodejs/metadata.xml
71 @@ -12,6 +12,7 @@
72 </maintainer>
73 <use>
74 <flag name="inspector">Enable V8 inspector</flag>
75 + <flag name="lto">Build with link-time optimisation</flag>
76 <flag name="npm">Enable NPM package manager</flag>
77 <flag name="pax_kernel">Enable building under a PaX enabled kernel</flag>
78 <flag name="snapshot">Enable snapshot creation for faster startup</flag>
79
80 diff --git a/net-libs/nodejs/nodejs-16.0.0.ebuild b/net-libs/nodejs/nodejs-16.0.0-r1.ebuild
81 similarity index 93%
82 rename from net-libs/nodejs/nodejs-16.0.0.ebuild
83 rename to net-libs/nodejs/nodejs-16.0.0-r1.ebuild
84 index 3b317ab08c9..612a576994a 100644
85 --- a/net-libs/nodejs/nodejs-16.0.0.ebuild
86 +++ b/net-libs/nodejs/nodejs-16.0.0-r1.ebuild
87 @@ -6,7 +6,7 @@ EAPI=7
88 PYTHON_COMPAT=( python3_{7..9} )
89 PYTHON_REQ_USE="threads(+)"
90
91 -inherit bash-completion-r1 flag-o-matic pax-utils python-any-r1 toolchain-funcs xdg-utils
92 +inherit bash-completion-r1 pax-utils python-any-r1 toolchain-funcs xdg-utils
93
94 DESCRIPTION="A JavaScript runtime built on Chrome's V8 JavaScript engine"
95 HOMEPAGE="https://nodejs.org/"
96 @@ -16,7 +16,7 @@ LICENSE="Apache-1.1 Apache-2.0 BSD BSD-2 MIT"
97 SLOT="0/$(ver_cut 1)"
98 KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86 ~amd64-linux ~x64-macos"
99
100 -IUSE="cpu_flags_x86_sse2 debug doc +icu inspector +npm pax_kernel +snapshot +ssl system-icu +system-ssl systemtap test"
101 +IUSE="cpu_flags_x86_sse2 debug doc +icu inspector lto +npm pax_kernel +snapshot +ssl system-icu +system-ssl systemtap test"
102 REQUIRED_USE="inspector? ( icu ssl )
103 npm? ( ssl )
104 system-icu? ( icu )
105 @@ -42,6 +42,7 @@ DEPEND="${RDEPEND}"
106
107 PATCHES=(
108 "${FILESDIR}"/${PN}-15.2.0-global-npm-config.patch
109 + "${FILESDIR}"/${PN}-16.0.0-v8_lto.patch
110 )
111
112 S="${WORKDIR}/node-v${PV}"
113 @@ -49,6 +50,12 @@ S="${WORKDIR}/node-v${PV}"
114 pkg_pretend() {
115 (use x86 && ! use cpu_flags_x86_sse2) && \
116 die "Your CPU doesn't support the required SSE2 instruction."
117 +
118 + if [[ ${MERGE_TYPE} != "binary" ]]; then
119 + if use lto; then
120 + tc-is-gcc || die "${PN} only supports LTO for gcc"
121 + fi
122 + fi
123 }
124
125 src_prepare() {
126 @@ -103,6 +110,7 @@ src_configure() {
127 --shared-zlib
128 )
129 use debug && myconf+=( --debug )
130 + use lto && myconf+=( --enable-lto )
131 if use system-icu; then
132 myconf+=( --with-intl=system-icu )
133 elif use icu; then