Diff clang-common-14.0.6 with a clang-common-15.0.7-r5

/usr/portage/sys-devel/clang-common/clang-common-15.0.7-r5.ebuild 2023-10-09 14:52:35.480368501 +0300
1
# Copyright 1999-2022 Gentoo Authors
1
# Copyright 1999-2023 Gentoo Authors
2 2
# Distributed under the terms of the GNU General Public License v2
3 3

  
4 4
EAPI=8
......
10 10

  
11 11
LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA"
12 12
SLOT="0"
13
KEYWORDS="amd64 arm arm64 ~ppc ppc64 ~riscv sparc x86 ~amd64-linux ~ppc-macos ~x64-macos"
13
KEYWORDS="amd64 arm arm64 ppc ppc64 ~riscv sparc x86 ~amd64-linux ~ppc-macos ~x64-macos"
14
IUSE="
15
	default-compiler-rt default-libcxx default-lld llvm-libunwind
16
	hardened stricter
17
"
14 18

  
15 19
PDEPEND="
16 20
	sys-devel/clang:*
21
	default-compiler-rt? (
22
		sys-devel/clang-runtime[compiler-rt]
23
		llvm-libunwind? ( sys-libs/llvm-libunwind[static-libs] )
24
		!llvm-libunwind? ( sys-libs/libunwind[static-libs] )
25
	)
26
	!default-compiler-rt? ( sys-devel/gcc )
27
	default-libcxx? ( >=sys-libs/libcxx-${PV} )
28
	!default-libcxx? ( sys-devel/gcc )
29
	default-lld? ( sys-devel/lld )
30
	!default-lld? ( sys-devel/binutils )
31
"
32
IDEPEND="
33
	!default-compiler-rt? ( sys-devel/gcc-config )
34
	!default-libcxx? ( sys-devel/gcc-config )
17 35
"
18 36

  
19 37
LLVM_COMPONENTS=( clang/utils )
20 38
llvm.org_set_globals
21 39

  
40
pkg_pretend() {
41
	[[ ${CLANG_IGNORE_DEFAULT_RUNTIMES} ]] && return
42

  
43
	local flag missing_flags=()
44
	for flag in default-{compiler-rt,libcxx,lld}; do
45
		if ! use "${flag}" && has_version "sys-devel/clang[${flag}]"; then
46
			missing_flags+=( "${flag}" )
47
		fi
48
	done
49

  
50
	if [[ ${missing_flags[@]} ]]; then
51
		eerror "It seems that you have the following flags set on sys-devel/clang:"
52
		eerror
53
		eerror "  ${missing_flags[*]}"
54
		eerror
55
		eerror "The default runtimes are now set via flags on sys-devel/clang-common."
56
		eerror "The build is being aborted to prevent breakage.  Please either set"
57
		eerror "the respective flags on this ebuild, e.g.:"
58
		eerror
59
		eerror "  sys-devel/clang-common ${missing_flags[*]}"
60
		eerror
61
		eerror "or build with CLANG_IGNORE_DEFAULT_RUNTIMES=1."
62
		die "Mismatched defaults detected between sys-devel/clang and sys-devel/clang-common"
63
	fi
64
}
65

  
22 66
src_install() {
23 67
	newbashcomp bash-autocomplete.sh clang
68

  
69
	insinto /etc/clang
70
	newins - gentoo-runtimes.cfg <<-EOF
71
		# This file is initially generated by sys-devel/clang-runtime.
72
		# It is used to control the default runtimes using by clang.
73

  
74
		--rtlib=$(usex default-compiler-rt compiler-rt libgcc)
75
		--unwindlib=$(usex default-compiler-rt libunwind libgcc)
76
		--stdlib=$(usex default-libcxx libc++ libstdc++)
77
		-fuse-ld=$(usex default-lld lld bfd)
78
	EOF
79

  
80
	newins - gentoo-gcc-install.cfg <<-EOF
81
		# This file is maintained by gcc-config.
82
		# It is used to specify the selected GCC installation.
83
	EOF
84

  
85
	newins - gentoo-common.cfg <<-EOF
86
		# This file contains flags common to clang, clang++ and clang-cpp.
87
		@gentoo-runtimes.cfg
88
		@gentoo-gcc-install.cfg
89
		@gentoo-hardened.cfg
90
	EOF
91

  
92
	# Baseline hardening (bug #851111)
93
	# (-fstack-clash-protection is omitted because of a possible Clang bug,
94
	# see bug #892537 and bug #865339.)
95
	newins - gentoo-hardened.cfg <<-EOF
96
		# Some of these options are added unconditionally, regardless of
97
		# USE=hardened, for parity with sys-devel/gcc.
98
		-fstack-protector-strong
99
		-fPIE
100
		-include "${EPREFIX}/usr/include/gentoo/fortify.h"
101
	EOF
102

  
103
	dodir /usr/include/gentoo
104

  
105
	local fortify_level=$(usex hardened 3 2)
106
	# We have to do this because glibc's headers warn if F_S is set
107
	# without optimization and that would at the very least be very noisy
108
	# during builds and at worst trigger many -Werror builds.
109
	cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die
110
	#ifdef __clang__
111
	# pragma clang system_header
112
	#endif
113
	#ifndef _FORTIFY_SOURCE
114
	# if defined(__has_feature)
115
	#  define __GENTOO_HAS_FEATURE(x) __has_feature(x)
116
	# else
117
	#  define __GENTOO_HAS_FEATURE(x) 0
118
	# endif
119
	#
120
	# if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
121
	#  if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer)
122
	#   define _FORTIFY_SOURCE ${fortify_level}
123
	#  endif
124
	# endif
125
	# undef __GENTOO_HAS_FEATURE
126
	#endif
127
	EOF
128

  
129
	if use hardened ; then
130
		cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die
131
			# Options below are conditional on USE=hardened.
132
			-D_GLIBCXX_ASSERTIONS
133

  
134
			# Analogue to GLIBCXX_ASSERTIONS
135
			# https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode
136
			-D_LIBCPP_ENABLE_ASSERTIONS=1
137
		EOF
138
	fi
139

  
140
	if use stricter; then
141
		newins - gentoo-stricter.cfg <<-EOF
142
			# This file increases the strictness of older clang versions
143
			# to match the newest upstream version.
144

  
145
			# clang-16 defaults
146
			-Werror=implicit-function-declaration
147
			-Werror=implicit-int
148
			-Werror=incompatible-function-pointer-types
149
		EOF
150

  
151
		cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die
152
			@gentoo-stricter.cfg
153
		EOF
154
	fi
155

  
156
	local tool
157
	for tool in clang{,++,-cpp}; do
158
		newins - "${tool}.cfg" <<-EOF
159
			# This configuration file is used by ${tool} driver.
160
			@gentoo-common.cfg
161
		EOF
162
	done
163
}
164

  
165
pkg_preinst() {
166
	if has_version -b sys-devel/gcc-config && has_version sys-devel/gcc
167
	then
168
		local gcc_path=$(gcc-config --get-lib-path 2>/dev/null)
169
		if [[ -n ${gcc_path} ]]; then
170
			cat >> "${ED}/etc/clang/gentoo-gcc-install.cfg" <<-EOF
171
				--gcc-install-dir="${gcc_path%%:*}"
172
			EOF
173
		fi
174
	fi
24 175
}
Thank you!