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 ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
|
|
29 |
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~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)
|
... | ... | |
517 |
530 |
export __ORIG_CXX=${CXX}
|
518 |
531 |
|
519 |
532 |
if tc-is-clang && ! use custom-cflags && ! is_crosscompile ; then
|
|
533 |
export glibc__force_gcc=yes
|
|
534 |
# once this is toggled on, it needs to stay on, since with CPP manipulated
|
|
535 |
# tc-is-clang does not work correctly anymore...
|
|
536 |
fi
|
520 |
537 |
|
|
538 |
if [[ ${glibc__force_gcc} == "yes" ]] ; then
|
521 |
539 |
# If we are running in an otherwise clang/llvm environment, we need to
|
522 |
540 |
# recover the proper gcc and binutils settings here, at least until glibc
|
523 |
541 |
# is finally building with clang. So let's override everything that is
|
... | ... | |
534 |
552 |
einfo "Overriding clang configuration, since it won't work here"
|
535 |
553 |
|
536 |
554 |
export CC="${current_gcc_path}/gcc"
|
|
555 |
export CPP="${current_gcc_path}/cpp"
|
537 |
556 |
export CXX="${current_gcc_path}/g++"
|
538 |
557 |
export LD="${current_binutils_path}/ld.bfd"
|
539 |
558 |
export AR="${current_binutils_path}/ar"
|
... | ... | |
745 |
764 |
ebegin "Checking that IA32 emulation is enabled in the running kernel"
|
746 |
765 |
echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c"
|
747 |
766 |
local STAT
|
748 |
|
if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then
|
|
767 |
if ${CC-${CHOST}-gcc} ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then
|
749 |
768 |
"${T}/check-ia32-emulation.elf32"
|
750 |
769 |
STAT=$?
|
751 |
770 |
else
|
... | ... | |
820 |
839 |
# pkg_pretend
|
821 |
840 |
|
822 |
841 |
pkg_pretend() {
|
823 |
|
# All the checks...
|
824 |
|
einfo "Checking general environment sanity."
|
825 |
|
sanity_prechecks
|
826 |
842 |
upgrade_warning
|
827 |
843 |
}
|
828 |
844 |
|
... | ... | |
834 |
850 |
# src_unpack
|
835 |
851 |
|
836 |
852 |
src_unpack() {
|
837 |
|
# Consistency is not guaranteed between pkg_ and src_ ...
|
|
853 |
setup_env
|
|
854 |
|
|
855 |
einfo "Checking general environment sanity."
|
838 |
856 |
sanity_prechecks
|
839 |
857 |
|
840 |
858 |
use multilib-bootstrap && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz
|
841 |
859 |
|
842 |
|
setup_env
|
843 |
|
|
844 |
860 |
if [[ ${PV} == 9999* ]] ; then
|
845 |
861 |
EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/toolchain/glibc-patches.git"
|
846 |
862 |
EGIT_CHECKOUT_DIR=${WORKDIR}/patches-git
|
... | ... | |
855 |
871 |
|
856 |
872 |
cd "${WORKDIR}" || die
|
857 |
873 |
unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz
|
|
874 |
use experimental-loong && unpack glibc-2.35-loongarch-patches-20220522.tar.xz
|
858 |
875 |
fi
|
859 |
876 |
|
860 |
877 |
cd "${WORKDIR}" || die
|
... | ... | |
873 |
890 |
einfo "Applying Gentoo Glibc Patchset ${patchsetname}"
|
874 |
891 |
eapply "${WORKDIR}"/patches
|
875 |
892 |
einfo "Done."
|
|
893 |
|
|
894 |
if use experimental-loong ; then
|
|
895 |
einfo "Applying experimental LoongArch patchset"
|
|
896 |
eapply "${WORKDIR}"/loongarch-2.35
|
|
897 |
einfo "Done."
|
|
898 |
fi
|
876 |
899 |
fi
|
877 |
900 |
|
|
901 |
eapply "${FILESDIR}"/2.35/glibc-2.35-make-4.4-MAKEFLAGS.patch
|
|
902 |
|
878 |
903 |
if use clone3 ; then
|
879 |
904 |
append-cppflags -DGENTOO_USE_CLONE3
|
880 |
905 |
else
|
... | ... | |
903 |
928 |
}
|
904 |
929 |
|
905 |
930 |
glibc_do_configure() {
|
|
931 |
dump_build_environment
|
906 |
932 |
|
907 |
|
local v
|
908 |
|
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
|
909 |
|
einfo " $(printf '%15s' ${v}:) ${!v}"
|
910 |
|
done
|
911 |
|
|
912 |
|
echo
|
913 |
933 |
local myconf=()
|
914 |
934 |
|
915 |
|
case ${CTARGET} in
|
916 |
|
m68k*)
|
917 |
|
# setjmp() is not compatible with stack protection:
|
918 |
|
# https://sourceware.org/PR24202
|
919 |
|
myconf+=( --enable-stack-protector=no )
|
920 |
|
;;
|
921 |
|
*)
|
922 |
|
# Use '=strong' instead of '=all' to protect only functions
|
923 |
|
# worth protecting from stack smashes.
|
924 |
|
# '=all' is also known to have a problem in IFUNC resolution
|
925 |
|
# tests: https://sourceware.org/PR25680, bug #712356.
|
926 |
|
myconf+=( --enable-stack-protector=$(usex ssp strong no) )
|
927 |
|
;;
|
928 |
|
esac
|
929 |
|
myconf+=( --enable-stackguard-randomization )
|
|
935 |
# Use '=strong' instead of '=all' to protect only functions
|
|
936 |
# worth protecting from stack smashes.
|
|
937 |
myconf+=( --enable-stack-protector=$(usex ssp strong no) )
|
930 |
938 |
|
931 |
939 |
# Keep a whitelist of targets supporing IFUNC. glibc's ./configure
|
932 |
940 |
# is not robust enough to detect proper support:
|
... | ... | |
976 |
984 |
fi
|
977 |
985 |
|
978 |
986 |
myconf+=(
|
979 |
|
--without-cvs
|
980 |
987 |
--disable-werror
|
981 |
988 |
--enable-bind-now
|
982 |
989 |
--build=${CBUILD_OPT:-${CBUILD}}
|
... | ... | |
995 |
1002 |
--with-pkgversion="$(glibc_banner)"
|
996 |
1003 |
$(use_enable crypt)
|
997 |
1004 |
$(use_multiarch || echo --disable-multi-arch)
|
998 |
|
$(use_enable static-pie)
|
999 |
1005 |
$(use_enable systemtap)
|
1000 |
1006 |
$(use_enable nscd)
|
1001 |
1007 |
|
... | ... | |
1143 |
1149 |
myconf+=(
|
1144 |
1150 |
--disable-sanity-checks
|
1145 |
1151 |
--enable-hacker-mode
|
1146 |
|
--without-cvs
|
1147 |
1152 |
--disable-werror
|
1148 |
1153 |
--enable-bind-now
|
1149 |
1154 |
--build=${CBUILD_OPT:-${CBUILD}}
|
... | ... | |
1211 |
1216 |
# sandbox does not understand unshare() and prevents
|
1212 |
1217 |
# writes to /proc/, which makes many tests fail
|
1213 |
1218 |
|
1214 |
|
SANDBOX_ON=0 LD_PRELOAD= emake ${myxfailparams} check
|
|
1219 |
# we give the tests a bit more time to avoid spurious
|
|
1220 |
# bug reports on slow arches
|
|
1221 |
|
|
1222 |
SANDBOX_ON=0 LD_PRELOAD= TIMEOUTFACTOR=16 emake ${myxfailparams} check
|
1215 |
1223 |
}
|
1216 |
1224 |
|
1217 |
1225 |
do_src_test() {
|