Gentoo Archives: gentoo-commits

From: Joonas Niilola <juippis@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: www-client/firefox/
Date: Sun, 29 Jan 2023 08:50:29
Message-Id: 1674982221.c38056ecf68cd7c730d41fcf131829175a7793ab.juippis@gentoo
1 commit: c38056ecf68cd7c730d41fcf131829175a7793ab
2 Author: Joonas Niilola <juippis <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jan 29 08:48:30 2023 +0000
4 Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org>
5 CommitDate: Sun Jan 29 08:50:21 2023 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c38056ec
7
8 www-client/firefox: support mold linker in 109.0
9
10 Closes: https://github.com/gentoo/gentoo/pull/28366
11 Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>
12
13 www-client/firefox/firefox-109.0.ebuild | 74 ++++++++++++++++++++++++++++-----
14 1 file changed, 64 insertions(+), 10 deletions(-)
15
16 diff --git a/www-client/firefox/firefox-109.0.ebuild b/www-client/firefox/firefox-109.0.ebuild
17 index c2e92bead6a2..e6d4ce7a40de 100644
18 --- a/www-client/firefox/firefox-109.0.ebuild
19 +++ b/www-client/firefox/firefox-109.0.ebuild
20 @@ -88,7 +88,10 @@ BDEPEND="${PYTHON_DEPS}
21 sys-devel/clang:15
22 sys-devel/llvm:15
23 clang? (
24 - sys-devel/lld:15
25 + || (
26 + sys-devel/lld:15
27 + sys-devel/mold
28 + )
29 virtual/rust:0/llvm-15
30 pgo? ( =sys-libs/compiler-rt-sanitizers-15*[profile] )
31 )
32 @@ -97,7 +100,10 @@ BDEPEND="${PYTHON_DEPS}
33 sys-devel/clang:14
34 sys-devel/llvm:14
35 clang? (
36 - sys-devel/lld:14
37 + || (
38 + sys-devel/lld:14
39 + sys-devel/mold
40 + )
41 virtual/rust:0/llvm-14
42 pgo? ( =sys-libs/compiler-rt-sanitizers-14*[profile] )
43 )
44 @@ -227,7 +233,7 @@ llvm_check_deps() {
45 return 1
46 fi
47
48 - if use clang ; then
49 + if use clang && tc-ld-is-lld ; then
50 if ! has_version -b "sys-devel/lld:${LLVM_SLOT}" ; then
51 einfo "sys-devel/lld:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
52 return 1
53 @@ -427,6 +433,40 @@ mozconfig_use_with() {
54 mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}"
55 }
56
57 +# This is a straight copypaste from toolchain-funcs.eclass's 'tc-ld-is-lld', and is temporarily
58 +# placed here until toolchain-funcs.eclass gets an official support for mold linker.
59 +# Please see:
60 +# https://github.com/gentoo/gentoo/pull/28366 ||
61 +# https://github.com/gentoo/gentoo/pull/28355
62 +tc-ld-is-mold() {
63 + local out
64 +
65 + # Ensure ld output is in English.
66 + local -x LC_ALL=C
67 +
68 + # First check the linker directly.
69 + out=$($(tc-getLD "$@") --version 2>&1)
70 + if [[ ${out} == *"mold"* ]] ; then
71 + return 0
72 + fi
73 +
74 + # Then see if they're selecting mold via compiler flags.
75 + # Note: We're assuming they're using LDFLAGS to hold the
76 + # options and not CFLAGS/CXXFLAGS.
77 + local base="${T}/test-tc-linker"
78 + cat <<-EOF > "${base}.c"
79 + int main() { return 0; }
80 + EOF
81 + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
82 + rm -f "${base}"*
83 + if [[ ${out} == *"mold"* ]] ; then
84 + return 0
85 + fi
86 +
87 + # No mold here!
88 + return 1
89 +}
90 +
91 virtwl() {
92 debug-print-function ${FUNCNAME} "$@"
93
94 @@ -486,7 +526,7 @@ pkg_setup() {
95
96 llvm_pkg_setup
97
98 - if use clang && use lto ; then
99 + if use clang && use lto && tc-ld-is-lld ; then
100 local version_lld=$(ld.lld --version 2>/dev/null | awk '{ print $2 }')
101 [[ -n ${version_lld} ]] && version_lld=$(ver_cut 1 "${version_lld}")
102 [[ -z ${version_lld} ]] && die "Failed to read ld.lld version!"
103 @@ -856,13 +896,18 @@ src_configure() {
104
105 if use lto ; then
106 if use clang ; then
107 - # Upstream only supports lld when using clang
108 - mozconfig_add_options_ac "forcing ld=lld due to USE=clang and USE=lto" --enable-linker=lld
109 + # Upstream only supports lld or mold when using clang.
110 + if tc-ld-is-mold ; then
111 + mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold
112 + else
113 + mozconfig_add_options_ac "forcing ld=lld due to USE=clang and USE=lto" --enable-linker=lld
114 + fi
115
116 mozconfig_add_options_ac '+lto' --enable-lto=cross
117
118 else
119 - # ThinLTO is currently broken, see bmo#1644409
120 + # ThinLTO is currently broken, see bmo#1644409.
121 + # mold does not support gcc+lto combination.
122 mozconfig_add_options_ac '+lto' --enable-lto=full
123 mozconfig_add_options_ac "linker is set to bfd" --enable-linker=bfd
124 fi
125 @@ -878,10 +923,19 @@ src_configure() {
126 else
127 # Avoid auto-magic on linker
128 if use clang ; then
129 - # This is upstream's default
130 - mozconfig_add_options_ac "forcing ld=lld due to USE=clang" --enable-linker=lld
131 + # lld is upstream's default
132 + if tc-ld-is-mold ; then
133 + mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold
134 + else
135 + mozconfig_add_options_ac "forcing ld=lld due to USE=clang" --enable-linker=lld
136 + fi
137 +
138 else
139 - mozconfig_add_options_ac "linker is set to bfd" --enable-linker=bfd
140 + if tc-ld-is-mold ; then
141 + mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold
142 + else
143 + mozconfig_add_options_ac "linker is set to bfd due to USE=-clang" --enable-linker=bfd
144 + fi
145 fi
146 fi