Diff glibc-2.34-r14 with a glibc-2.35-r11

/usr/portage/sys-libs/glibc/glibc-2.35-r11.ebuild 2024-12-25 14:59:52.815270184 +0300
20 20
EMULTILIB_PKG="true"
21 21

  
22 22
# Gentoo patchset (ignored for live ebuilds)
23
PATCH_VER=17
23
PATCH_VER=12
24 24
PATCH_DEV=dilfridge
25 25

  
26 26
if [[ ${PV} == 9999* ]]; then
27 27
	inherit git-r3
28 28
else
29
	KEYWORDS="~alpha amd64 arm arm64 hppa ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
29
	KEYWORDS="~alpha amd64 arm arm64 hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
30 30
	SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
31 31
	SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz"
32
	SRC_URI+=" experimental-loong? ( https://dev.gentoo.org/~xen0n/distfiles/glibc-2.35-loongarch-patches-20220522.tar.xz )"
32 33
fi
33 34

  
34 35
RELEASE_VER=${PV}
......
43 44
SRC_URI+=" multilib-bootstrap? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )"
44 45
SRC_URI+=" systemd? ( https://gitweb.gentoo.org/proj/toolchain/glibc-systemd.git/snapshot/glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz )"
45 46

  
46
IUSE="audit caps cet +clone3 compile-locales +crypt custom-cflags doc gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp +static-libs static-pie suid systemd systemtap test vanilla"
47
IUSE="audit caps cet +clone3 compile-locales +crypt custom-cflags doc experimental-loong gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp stack-realign +static-libs suid systemd systemtap test vanilla"
47 48

  
48 49
# Minimum kernel version that glibc requires
49 50
MIN_KERN_VER="3.2.0"
......
144 145
if [[ ${CATEGORY} == cross-* ]] ; then
145 146
	BDEPEND+=" !headers-only? (
146 147
		>=${CATEGORY}/binutils-2.27
147
		>=${CATEGORY}/gcc-6
148
		>=${CATEGORY}/gcc-6.2
148 149
	)"
149 150
	[[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
150 151
else
151 152
	BDEPEND+="
152 153
		>=sys-devel/binutils-2.27
153
		>=sys-devel/gcc-6
154
		>=sys-devel/gcc-6.2
154 155
	"
155 156
	DEPEND+=" virtual/os-headers "
156 157
	RDEPEND+="
......
182 183
# Small helper functions
183 184
#
184 185

  
186
dump_build_environment() {
187
	einfo ==== glibc build environment ========================================================
188
	local v
189
	for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX CPP LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO NM AR AS STRIP RANLIB OBJCOPY STRINGS OBJDUMP READELF; do
190
		einfo " $(printf '%15s' ${v}:)   ${!v}"
191
	done
192
	einfo =====================================================================================
193
}
194

  
185 195
is_crosscompile() {
186 196
	[[ ${CHOST} != ${CTARGET} ]]
187 197
}
......
248 258
	rm -f glibc-test*
249 259
	printf '%b' "$*" > glibc-test.c
250 260

  
251
	# Most of the time CC is already set, but not in early sanity checks.
252
	nonfatal emake glibc-test CC="${CC-$(tc-getCC ${CTARGET})}"
261
	# We assume CC is already set up.
262
	nonfatal emake glibc-test
253 263
	ret=$?
254 264

  
255 265
	popd >/dev/null
......
304 314
				export CFLAGS="-march=${t} ${CFLAGS}"
305 315
				einfo "Auto adding -march=${t} to CFLAGS #185404"
306 316
			fi
317
			# For compatibility with older binaries at slight performance cost.
318
			use stack-realign && export CFLAGS+=" -mstackrealign"
307 319
		;;
308 320
		amd64)
309 321
			# -march needed for #185404 #199334
310 322
			# TODO: See cross-compile issues listed above for x86.
311
			[[ ${ABI} == x86 ]] &&
312
			if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n'; then
313
				local t=${CTARGET_OPT:-${CTARGET}}
314
				t=${t%%-*}
315
				# Normally the target is x86_64-xxx, so turn that into the -march that
316
				# gcc actually accepts. #528708
317
				[[ ${t} == "x86_64" ]] && t="x86-64"
318
				filter-flags '-march=*'
319
				# ugly, ugly, ugly.  ugly.
320
				CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
321
				export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
322
				einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})"
323
			fi
323
			if [[ ${ABI} == x86 ]]; then
324
				if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n'; then
325
					local t=${CTARGET_OPT:-${CTARGET}}
326
					t=${t%%-*}
327
					# Normally the target is x86_64-xxx, so turn that into the -march that
328
					# gcc actually accepts. #528708
329
					[[ ${t} == "x86_64" ]] && t="x86-64"
330
					filter-flags '-march=*'
331
					# ugly, ugly, ugly.  ugly.
332
					CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
333
					export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
334
					einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})"
335
				fi
336
				# For compatibility with older binaries at slight performance cost.
337
				use stack-realign && export CFLAGS_x86+=" -mstackrealign"
324 338

  
325
			# Workaround for https://bugs.gentoo.org/823780. This really should
326
			# be removed when the upstream bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103275
327
			# is fixed in our tree, either via 11.3 or an 11.2p2 patch set.
328
			if [[ ${ABI} == x86 ]] && tc-is-gcc && (($(gcc-major-version) == 11)) && (($(gcc-minor-version) <= 2)) && (($(gcc-micro-version) == 0)); then
329
				export CFLAGS_x86="${CFLAGS_x86} -mno-avx512f"
330
				einfo "Auto adding -mno-avx512f to CFLAGS_x86 (bug #823780) (ABI=${ABI})"
339
				# Workaround for bug #823780.
340
				if tc-is-gcc && (($(gcc-major-version) == 11)) && (($(gcc-minor-version) <= 2)) && (($(gcc-micro-version) == 0)) ; then
341
					export CFLAGS_x86="${CFLAGS_x86} -mno-avx512f"
342
					einfo "Auto adding -mno-avx512f to CFLAGS_x86 for buggy GCC version (bug #823780) (ABI=${ABI})"
343
				fi
331 344
			fi
332 345
		;;
333 346
		mips)
......
524 537
	export __ORIG_CXX=${CXX}
525 538

  
526 539
	if tc-is-clang && ! use custom-cflags && ! is_crosscompile ; then
540
		export glibc__force_gcc=yes
541
		# once this is toggled on, it needs to stay on, since with CPP manipulated
542
		# tc-is-clang does not work correctly anymore...
543
	fi
527 544

  
545
	if [[ ${glibc__force_gcc} == "yes" ]] ; then
528 546
		# If we are running in an otherwise clang/llvm environment, we need to
529 547
		# recover the proper gcc and binutils settings here, at least until glibc
530 548
		# is finally building with clang. So let's override everything that is
......
541 559
		einfo "Overriding clang configuration, since it won't work here"
542 560

  
543 561
		export CC="${current_gcc_path}/gcc"
562
		export CPP="${current_gcc_path}/cpp"
544 563
		export CXX="${current_gcc_path}/g++"
545 564
		export LD="${current_binutils_path}/ld.bfd"
546 565
		export AR="${current_binutils_path}/ar"
......
752 771
			ebegin "Checking if the system can execute 32-bit binaries"
753 772
			echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c"
754 773
			local STAT
755
			if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then
774
			if ${CC-${CHOST}-gcc} ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then
756 775
				"${T}/check-ia32-emulation.elf32"
757 776
				STAT=$?
758 777
			else
......
831 850
# pkg_pretend
832 851

  
833 852
pkg_pretend() {
834
	# All the checks...
835
	einfo "Checking general environment sanity."
836
	sanity_prechecks
837 853
	upgrade_warning
838 854
}
839 855

  
......
845 861
# src_unpack
846 862

  
847 863
src_unpack() {
848
	# Consistency is not guaranteed between pkg_ and src_ ...
864
	setup_env
865

  
866
	einfo "Checking general environment sanity."
849 867
	sanity_prechecks
850 868

  
851 869
	use multilib-bootstrap && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz
852 870

  
853
	setup_env
854

  
855 871
	if [[ ${PV} == 9999* ]] ; then
856 872
		EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/toolchain/glibc-patches.git"
857 873
		EGIT_CHECKOUT_DIR=${WORKDIR}/patches-git
......
866 882

  
867 883
		cd "${WORKDIR}" || die
868 884
		unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz
885
		use experimental-loong && unpack glibc-2.35-loongarch-patches-20220522.tar.xz
869 886
	fi
870 887

  
871 888
	cd "${WORKDIR}" || die
......
884 901
		einfo "Applying Gentoo Glibc Patchset ${patchsetname}"
885 902
		eapply "${WORKDIR}"/patches
886 903
		einfo "Done."
904

  
905
		if use experimental-loong ; then
906
			einfo "Applying experimental LoongArch patchset"
907
			eapply "${WORKDIR}"/loongarch-2.35
908
			einfo "Done."
909
		fi
887 910
	fi
888 911

  
912
	eapply "${FILESDIR}"/2.35/glibc-2.35-make-4.4-MAKEFLAGS.patch
913

  
889 914
	if use clone3 ; then
890 915
		append-cppflags -DGENTOO_USE_CLONE3
891 916
	else
......
914 939
}
915 940

  
916 941
glibc_do_configure() {
942
	dump_build_environment
917 943

  
918
	local v
919
	for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO NM AR AS STRIP RANLIB OBJCOPY STRINGS OBJDUMP READELF; do
920
		einfo " $(printf '%15s' ${v}:)   ${!v}"
921
	done
922

  
923
	echo
924 944
	local myconf=()
925 945

  
926
	case ${CTARGET} in
927
		m68k*)
928
			# setjmp() is not compatible with stack protection:
929
			# https://sourceware.org/PR24202
930
			myconf+=( --enable-stack-protector=no )
931
			;;
932
		*)
933
			# Use '=strong' instead of '=all' to protect only functions
934
			# worth protecting from stack smashes.
935
			# '=all' is also known to have a problem in IFUNC resolution
936
			# tests: https://sourceware.org/PR25680, bug #712356.
937
			myconf+=( --enable-stack-protector=$(usex ssp strong no) )
938
			;;
939
	esac
940
	myconf+=( --enable-stackguard-randomization )
946
	# Use '=strong' instead of '=all' to protect only functions
947
	# worth protecting from stack smashes.
948
	myconf+=( --enable-stack-protector=$(usex ssp strong no) )
941 949

  
942 950
	# Keep a whitelist of targets supporing IFUNC. glibc's ./configure
943 951
	# is not robust enough to detect proper support:
......
987 995
	fi
988 996

  
989 997
	myconf+=(
990
		--without-cvs
991 998
		--disable-werror
992 999
		--enable-bind-now
993 1000
		--build=${CBUILD_OPT:-${CBUILD}}
......
1006 1013
		--with-pkgversion="$(glibc_banner)"
1007 1014
		$(use_enable crypt)
1008 1015
		$(use_multiarch || echo --disable-multi-arch)
1009
		$(use_enable static-pie)
1010 1016
		$(use_enable systemtap)
1011 1017
		$(use_enable nscd)
1012 1018

  
......
1154 1160
	myconf+=(
1155 1161
		--disable-sanity-checks
1156 1162
		--enable-hacker-mode
1157
		--without-cvs
1158 1163
		--disable-werror
1159 1164
		--enable-bind-now
1160 1165
		--build=${CBUILD_OPT:-${CBUILD}}
......
1222 1227
	# sandbox does not understand unshare() and prevents
1223 1228
	# writes to /proc/, which makes many tests fail
1224 1229

  
1225
	SANDBOX_ON=0 LD_PRELOAD= emake ${myxfailparams} check
1230
	# we give the tests a bit more time to avoid spurious
1231
	# bug reports on slow arches
1232

  
1233
	SANDBOX_ON=0 LD_PRELOAD= TIMEOUTFACTOR=16 emake ${myxfailparams} check
1226 1234
}
1227 1235

  
1228 1236
do_src_test() {
Thank you!