Diff clang-14.0.6-r4 with a clang-15.0.7-r1

/usr/portage/sys-devel/clang/clang-15.0.7-r1.ebuild 2023-10-09 14:52:35.480368501 +0300
3 3

  
4 4
EAPI=8
5 5

  
6
PYTHON_COMPAT=( python3_{9..10} )
6
PYTHON_COMPAT=( python3_{9..11} )
7 7
inherit cmake llvm llvm.org multilib multilib-minimal \
8
	prefix python-single-r1 toolchain-funcs
8
	prefix python-single-r1 toolchain-funcs flag-o-matic
9 9

  
10 10
DESCRIPTION="C language family frontend for LLVM"
11 11
HOMEPAGE="https://llvm.org/"
......
14 14
# sorttable.js: MIT
15 15

  
16 16
LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA MIT"
17
SLOT="$(ver_cut 1)"
18
KEYWORDS="amd64 arm arm64 ~ppc ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x64-macos"
19
IUSE="
20
	debug default-compiler-rt default-libcxx default-lld doc
21
	llvm-libunwind +pie +static-analyzer test xml
22
"
17
SLOT="${LLVM_MAJOR}/${LLVM_SOABI}g1"
18
KEYWORDS="amd64 arm arm64 ppc ppc64 ~riscv sparc x86 ~amd64-linux ~x64-macos"
19
IUSE="debug doc +extra ieee-long-double +pie +static-analyzer test xml"
23 20
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
24 21
RESTRICT="!test? ( test )"
25 22

  
26 23
DEPEND="
27
	~sys-devel/llvm-${PV}:${SLOT}=[debug=,${MULTILIB_USEDEP}]
24
	~sys-devel/llvm-${PV}:${LLVM_MAJOR}=[debug=,${MULTILIB_USEDEP}]
28 25
	static-analyzer? ( dev-lang/perl:* )
29 26
	xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] )
30 27
"
......
32 29
RDEPEND="
33 30
	${PYTHON_DEPS}
34 31
	${DEPEND}
32
	>=sys-devel/clang-common-${PV}
35 33
"
36 34
BDEPEND="
37 35
	${PYTHON_DEPS}
......
43 41
	xml? ( virtual/pkgconfig )
44 42
"
45 43
PDEPEND="
46
	sys-devel/clang-common
44
	sys-devel/clang-toolchain-symlinks:${LLVM_MAJOR}
47 45
	~sys-devel/clang-runtime-${PV}
48
	default-compiler-rt? (
49
		=sys-libs/compiler-rt-${PV%_*}*
50
		llvm-libunwind? ( sys-libs/llvm-libunwind )
51
		!llvm-libunwind? ( sys-libs/libunwind )
52
	)
53
	default-libcxx? ( >=sys-libs/libcxx-${PV} )
54
	default-lld? ( sys-devel/lld )
55 46
"
56 47

  
57 48
LLVM_COMPONENTS=(
......
64 55
	llvm/utils/{lit,llvm-lit,unittest}
65 56
	llvm/utils/{UpdateTestChecks,update_cc_test_checks.py}
66 57
)
67
LLVM_PATCHSET=${PV}-r4
58
LLVM_PATCHSET=${PV/_/-}
68 59
LLVM_USE_TARGETS=llvm
69 60
llvm.org_set_globals
70 61

  
......
80 71
# multilib clang* libraries (not runtime, not wrappers).
81 72

  
82 73
pkg_setup() {
83
	LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
74
	LLVM_MAX_SLOT=${LLVM_MAJOR} llvm_pkg_setup
84 75
	python-single-r1_pkg_setup
85 76
}
86 77

  
......
168 159
		clang-resource-headers
169 160
		libclang-headers
170 161

  
162
		aarch64-resource-headers
163
		arm-common-resource-headers
164
		arm-resource-headers
165
		core-resource-headers
166
		cuda-resource-headers
167
		hexagon-resource-headers
168
		hip-resource-headers
169
		hlsl-resource-headers
170
		mips-resource-headers
171
		opencl-resource-headers
172
		openmp-resource-headers
173
		ppc-htm-resource-headers
174
		ppc-resource-headers
175
		riscv-resource-headers
176
		systemz-resource-headers
177
		utility-resource-headers
178
		ve-resource-headers
179
		webassembly-resource-headers
180
		windows-resource-headers
181
		x86-resource-headers
182

  
171 183
		# libs
172 184
		clang-cpp
173 185
		libclang
......
184 196
			clang
185 197
			clang-format
186 198
			clang-offload-bundler
199
			clang-offload-packager
187 200
			clang-offload-wrapper
188 201
			clang-refactor
189 202
			clang-repl
......
192 205
			diagtool
193 206
			hmaptool
194 207

  
195
			# extra tools
196
			clang-apply-replacements
197
			clang-change-namespace
198
			clang-doc
199
			clang-include-fixer
200
			clang-move
201
			clang-query
202
			clang-reorder-fields
203
			clang-tidy
204
			clang-tidy-headers
205
			clangd
206
			find-all-symbols
207
			modularize
208
			pp-trace
208
			# needed for cross-compiling Clang
209
			clang-tblgen
209 210
		)
210 211

  
211
		if llvm_are_manpages_built; then
212
		if use extra; then
212 213
			out+=(
213
				# manpages
214
				docs-clang-man
215
				docs-clang-tools-man
214
				# extra tools
215
				clang-apply-replacements
216
				clang-change-namespace
217
				clang-doc
218
				clang-include-fixer
219
				clang-move
220
				clang-pseudo
221
				clang-query
222
				clang-reorder-fields
223
				clang-tidy
224
				clang-tidy-headers
225
				clangd
226
				find-all-symbols
227
				modularize
228
				pp-trace
216 229
			)
217 230
		fi
218 231

  
219
		use doc && out+=(
220
			docs-clang-html
221
			docs-clang-tools-html
222
		)
232
		if llvm_are_manpages_built; then
233
			out+=( docs-clang-man )
234
			use extra && out+=( docs-clang-tools-man )
235
		fi
236

  
237
		if use doc; then
238
			out+=( docs-clang-html )
239
			use extra && out+=( docs-clang-tools-html )
240
		fi
223 241

  
224 242
		use static-analyzer && out+=(
225 243
			clang-check
......
234 252
}
235 253

  
236 254
multilib_src_configure() {
237
	local llvm_version=$(llvm-config --version) || die
238
	local clang_version=$(ver_cut 1-3 "${llvm_version}")
255
	tc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
239 256

  
240 257
	local mycmakeargs=(
241 258
		-DDEFAULT_SYSROOT=$(usex prefix-guest "" "${EPREFIX}")
242
		-DLLVM_CMAKE_PATH="${EPREFIX}/usr/lib/llvm/${SLOT}/$(get_libdir)/cmake/llvm"
243
		-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}"
244
		-DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${SLOT}/share/man"
259
		-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}"
260
		-DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/share/man"
261
		-DCLANG_CONFIG_FILE_SYSTEM_DIR="${EPREFIX}/etc/clang"
245 262
		# relative to bindir
246
		-DCLANG_RESOURCE_DIR="../../../../lib/clang/${clang_version}"
263
		-DCLANG_RESOURCE_DIR="../../../../lib/clang/${LLVM_VERSION}"
247 264

  
248 265
		-DBUILD_SHARED_LIBS=OFF
249 266
		-DCLANG_LINK_CLANG_DYLIB=ON
......
264 281
		# disable using CUDA to autodetect GPU, just build for all
265 282
		-DCMAKE_DISABLE_FIND_PACKAGE_CUDA=ON
266 283

  
267
		# override default stdlib and rtlib
268
		-DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "")
269
		-DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "")
270
		-DCLANG_DEFAULT_LINKER=$(usex default-lld lld "")
271 284
		-DCLANG_DEFAULT_PIE_ON_LINUX=$(usex pie)
272
		-DCLANG_DEFAULT_UNWINDLIB=$(usex default-compiler-rt libunwind "")
273 285

  
274 286
		-DCLANG_ENABLE_ARCMT=$(usex static-analyzer)
275 287
		-DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer)
276 288

  
277 289
		-DPython3_EXECUTABLE="${PYTHON}"
278 290
	)
291

  
292
	if ! use elibc_musl; then
293
		mycmakeargs+=(
294
			-DPPC_LINUX_DEFAULT_IEEELONGDOUBLE=$(usex ieee-long-double)
295
		)
296
	fi
297

  
279 298
	use test && mycmakeargs+=(
280 299
		-DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm"
281 300
		-DLLVM_EXTERNAL_LIT="${BUILD_DIR}/bin/llvm-lit"
......
290 309
				-DLLVM_BUILD_DOCS=ON
291 310
				-DLLVM_ENABLE_SPHINX=ON
292 311
				-DCLANG_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html"
293
				-DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra"
294 312
				-DSPHINX_WARNINGS_AS_ERRORS=OFF
295 313
			)
314
			if use extra; then
315
				mycmakeargs+=(
316
					-DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra"
317
				)
318
			fi
296 319
		fi
297 320
		mycmakeargs+=(
298
			-DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR="${WORKDIR}"/clang-tools-extra
299 321
			-DCLANG_INCLUDE_DOCS=${build_docs}
322
		)
323
	fi
324
	if multilib_native_use extra; then
325
		mycmakeargs+=(
326
			-DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR="${WORKDIR}"/clang-tools-extra
300 327
			-DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=${build_docs}
301 328
		)
302 329
	else
......
312 339
	fi
313 340

  
314 341
	if tc-is-cross-compiler; then
315
		[[ -x "/usr/bin/clang-tblgen" ]] \
316
			|| die "/usr/bin/clang-tblgen not found or usable"
342
		has_version -b sys-devel/clang:${LLVM_MAJOR} ||
343
			die "sys-devel/clang:${LLVM_MAJOR} is required on the build host."
344
		local tools_bin=${BROOT}/usr/lib/llvm/${LLVM_MAJOR}/bin
317 345
		mycmakeargs+=(
318
			-DCMAKE_CROSSCOMPILING=ON
319
			-DCLANG_TABLEGEN=/usr/bin/clang-tblgen
346
			-DLLVM_TOOLS_BINARY_DIR="${tools_bin}"
347
			-DCLANG_TABLEGEN="${tools_bin}"/clang-tblgen
320 348
		)
321 349
	fi
322 350

  
......
344 372
multilib_src_test() {
345 373
	# respect TMPDIR!
346 374
	local -x LIT_PRESERVES_TMP=1
347
	cmake_build check-clang
348
	multilib_is_native_abi &&
349
		cmake_build check-clang-tools check-clangd
375
	local test_targets=( check-clang )
376
	if multilib_native_use extra; then
377
		test_targets+=(
378
			check-clang-tools
379
			check-clangd
380
		)
381
	fi
382
	cmake_build "${test_targets[@]}"
350 383
}
351 384

  
352 385
src_install() {
......
359 392
	# Move runtime headers to /usr/lib/clang, where they belong
360 393
	mv "${ED}"/usr/include/clangrt "${ED}"/usr/lib/clang || die
361 394
	# move (remaining) wrapped headers back
362
	mv "${T}"/clang-tidy "${ED}"/usr/include/ || die
363
	mv "${ED}"/usr/include "${ED}"/usr/lib/llvm/${SLOT}/include || die
395
	if use extra; then
396
		mv "${T}"/clang-tidy "${ED}"/usr/include/ || die
397
	fi
398
	mv "${ED}"/usr/include "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/include || die
364 399

  
365 400
	# Apply CHOST and version suffix to clang tools
366
	# note: we use two version components here (vs 3 in runtime path)
367
	local llvm_version=$(llvm-config --version) || die
368
	local clang_version=$(ver_cut 1 "${llvm_version}")
369
	local clang_full_version=$(ver_cut 1-3 "${llvm_version}")
370 401
	local clang_tools=( clang clang++ clang-cl clang-cpp )
371 402
	local abi i
372 403

  
......
380 411
	# - clang, clang++, clang-cl, clang-cpp -> clang*-X
381 412
	# also in CHOST variant
382 413
	for i in "${clang_tools[@]:1}"; do
383
		rm "${ED}/usr/lib/llvm/${SLOT}/bin/${i}" || die
384
		dosym "clang-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}-${clang_version}"
385
		dosym "${i}-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}"
414
		rm "${ED}/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}" || die
415
		dosym "clang-${LLVM_MAJOR}" "/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}-${LLVM_MAJOR}"
416
		dosym "${i}-${LLVM_MAJOR}" "/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}"
386 417
	done
387 418

  
388 419
	# now create target symlinks for all supported ABIs
389 420
	for abi in $(get_all_abis); do
390 421
		local abi_chost=$(get_abi_CHOST "${abi}")
391 422
		for i in "${clang_tools[@]}"; do
392
			dosym "${i}-${clang_version}" \
393
				"/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}-${clang_version}"
394
			dosym "${abi_chost}-${i}-${clang_version}" \
395
				"/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}"
423
			dosym "${i}-${LLVM_MAJOR}" \
424
				"/usr/lib/llvm/${LLVM_MAJOR}/bin/${abi_chost}-${i}-${LLVM_MAJOR}"
425
			dosym "${abi_chost}-${i}-${LLVM_MAJOR}" \
426
				"/usr/lib/llvm/${LLVM_MAJOR}/bin/${abi_chost}-${i}"
396 427
		done
397 428
	done
398 429
}
......
400 431
multilib_src_install() {
401 432
	DESTDIR=${D} cmake_build install-distribution
402 433

  
434
	if multilib_is_native_abi; then
435
		# install clang-*-wrapper tools
436
		# https://bugs.gentoo.org/904143
437
		exeinto "/usr/lib/llvm/${LLVM_MAJOR}/bin"
438
		doexe "${BUILD_DIR}"/bin/clang-{linker,nvlink}-wrapper
439
	fi
440

  
403 441
	# move headers to /usr/include for wrapping & ABI mismatch checks
404 442
	# (also drop the version suffix from runtime headers)
405 443
	rm -rf "${ED}"/usr/include || die
406
	mv "${ED}"/usr/lib/llvm/${SLOT}/include "${ED}"/usr/include || die
407
	mv "${ED}"/usr/lib/llvm/${SLOT}/$(get_libdir)/clang "${ED}"/usr/include/clangrt || die
408
	if multilib_is_native_abi; then
444
	mv "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/include "${ED}"/usr/include || die
445
	mv "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/$(get_libdir)/clang "${ED}"/usr/include/clangrt || die
446
	if multilib_native_use extra; then
409 447
		# don't wrap clang-tidy headers, the list is too long
410 448
		# (they're fine for non-native ABI but enabling the targets is problematic)
411 449
		mv "${ED}"/usr/include/clang-tidy "${T}/" || die
......
415 453
multilib_src_install_all() {
416 454
	python_fix_shebang "${ED}"
417 455
	if use static-analyzer; then
418
		python_optimize "${ED}"/usr/lib/llvm/${SLOT}/share/scan-view
456
		python_optimize "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/share/scan-view
419 457
	fi
420 458

  
421
	docompress "/usr/lib/llvm/${SLOT}/share/man"
459
	docompress "/usr/lib/llvm/${LLVM_MAJOR}/share/man"
422 460
	llvm_install_manpages
423 461
	# match 'html' non-compression
424 462
	use doc && docompress -x "/usr/share/doc/${PF}/tools-extra"
425 463
	# +x for some reason; TODO: investigate
426
	use static-analyzer && fperms a-x "/usr/lib/llvm/${SLOT}/share/man/man1/scan-build.1"
464
	use static-analyzer && fperms a-x "/usr/lib/llvm/${LLVM_MAJOR}/share/man/man1/scan-build.1"
427 465
}
428 466

  
429 467
pkg_postinst() {
......
432 470
	fi
433 471

  
434 472
	elog "You can find additional utility scripts in:"
435
	elog "  ${EROOT}/usr/lib/llvm/${SLOT}/share/clang"
436
	elog "Some of them are vim integration scripts (with instructions inside)."
437
	elog "The run-clang-tidy.py script requires the following additional package:"
438
	elog "  dev-python/pyyaml"
473
	elog "  ${EROOT}/usr/lib/llvm/${LLVM_MAJOR}/share/clang"
474
	if use extra; then
475
		elog "Some of them are vim integration scripts (with instructions inside)."
476
		elog "The run-clang-tidy.py script requires the following additional package:"
477
		elog "  dev-python/pyyaml"
478
	fi
439 479
}
440 480

  
441 481
pkg_postrm() {
Thank you!