summaryrefslogtreecommitdiff
path: root/eclass/toolchain.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-03-23 19:01:15 +0000
committerV3n3RiX <venerix@koprulu.sector>2024-03-23 19:01:15 +0000
commit36fc50e36ed1a4686bb7202aeaff3170b2206124 (patch)
tree7b5feb28a3ad8ba78d57f64c93cc796cff95cd53 /eclass/toolchain.eclass
parentacc2dacf2ee9a5b03df96da670153f2e3a24d80c (diff)
gentoo auto-resync : 23:03:2024 - 19:01:14
Diffstat (limited to 'eclass/toolchain.eclass')
-rw-r--r--eclass/toolchain.eclass241
1 files changed, 165 insertions, 76 deletions
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index e962c8181693..cd63712b1f24 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -22,7 +22,7 @@ _TOOLCHAIN_ECLASS=1
DESCRIPTION="The GNU Compiler Collection"
HOMEPAGE="https://gcc.gnu.org/"
-inherit edo flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
+inherit edo flag-o-matic gnuconfig libtool multilib pax-utils python-any-r1 toolchain-funcs prefix
tc_is_live() {
[[ ${PV} == *9999* ]]
@@ -84,6 +84,11 @@ tc_version_is_between() {
# Used to override GCC version. Useful for e.g. live ebuilds or snapshots.
# Defaults to ${PV}.
+# @ECLASS_VARIABLE: TOOLCHAIN_GCC_VALIDATE_FAILURES_VERSION
+# @DESCRIPTION:
+# Version of test comparison script (validate_fails.py) to use.
+: "${GCC_VALIDATE_FAILURES_VERSION:=7bbfb01a32b73842f8908de028703510a0e12057}"
+
# @ECLASS_VARIABLE: TOOLCHAIN_USE_GIT_PATCHES
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -93,6 +98,39 @@ tc_version_is_between() {
# for 13.0, we don't want to create new patchsets for every single 13.0 snapshot,
# so just grab patches from git each time if this variable is set).
+# @ECLASS_VARIABLE: GCC_TESTS_COMPARISON_DIR
+# @USER_VARIABLE
+# @DESCRIPTION:
+# Source of previous GCC test results and location to store new results.
+: "${GCC_TESTS_COMPARISON_DIR:=${BROOT}/var/cache/gcc/testresults/${CHOST}}"
+
+# @ECLASS_VARIABLE: GCC_TESTS_COMPARISON_SLOT
+# @USER_VARIABLE
+# @DESCRIPTION:
+# Slot to compare test results with. Defaults to current slot.
+: "${GCC_TESTS_COMPARISON_SLOT:=${SLOT}}"
+
+# @ECLASS_VARIABLE: GCC_TESTS_IGNORE_NO_BASELINE
+# @DEFAULT_UNSET
+# @USER_VARIABLE
+# @DESCRIPTION:
+# Ignore missing baseline/reference data and create new baseline.
+: "${GCC_TESTS_IGNORE_NO_BASELINE:=}"
+
+# @ECLASS_VARIABLE: GCC_TESTS_CHECK_TARGET
+# @USER_VARIABLE
+# @DESCRIPTION:
+# Defaults to 'check'. Allows choosing a different test target, e.g.
+# 'test-gcc' (https://gcc.gnu.org/install/test.html).
+: "${GCC_TESTS_CHECK_TARGET:=check}"
+
+# @ECLASS_VARIABLE: GCC_TESTS_RUNTESTFLAGS
+# @DEFAULT_UNSET
+# @USER_VARIABLE
+# @DESCRIPTION:
+# Extra options to pass to DejaGnu as RUNTESTFLAGS.
+: "${GCC_TESTS_RUNTESTFLAGS:=}"
+
# @ECLASS_VARIABLE: TOOLCHAIN_PATCH_DEV
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -311,6 +349,7 @@ BDEPEND="
>=sys-devel/flex-2.5.4
nls? ( sys-devel/gettext )
test? (
+ ${PYTHON_DEPS}
>=dev-util/dejagnu-1.4.4
>=sys-devel/autogen-5.5.4
)
@@ -320,7 +359,7 @@ DEPEND="${RDEPEND}"
if [[ ${PN} == gcc && ${PV} == *_p* ]] ; then
# Snapshots don't contain info pages.
# If they start to, adjust gcc_cv_prog_makeinfo_modern logic in toolchain_src_configure.
- # Needed unless/until https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106899 is fixed
+ # Needed unless/until https://gcc.gnu.org/PR106899 is fixed
BDEPEND+=" sys-apps/texinfo"
fi
@@ -484,6 +523,8 @@ get_gcc_src_uri() {
[[ -n ${MUSL_VER} ]] && \
GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})"
+ GCC_SRC_URI+=" test? ( https://gitweb.gentoo.org/proj/gcc-patches.git/plain/scripts/testsuite-management/validate_failures.py?id=${GCC_VALIDATE_FAILURES_VERSION} -> ${PN}-validate-failures-${GCC_VALIDATE_FAILURES_VERSION}.py )"
+
echo "${GCC_SRC_URI}"
}
@@ -513,6 +554,8 @@ toolchain_pkg_setup() {
# Avoid really confusing logs from subconfigure spam, makes logs far
# more legible.
MAKEOPTS="--output-sync=line ${MAKEOPTS}"
+
+ use test && python-any-r1_pkg_setup
}
#---->> src_unpack <<----
@@ -576,6 +619,11 @@ toolchain_src_prepare() {
tc_enable_hardened_gcc
fi
+ if use test ; then
+ cp "${DISTDIR}"/${PN}-validate-failures-${GCC_VALIDATE_FAILURES_VERSION}.py "${T}"/validate_failures.py || die
+ chmod +x "${T}"/validate_failures.py || die
+ fi
+
# Make sure the pkg-config files install into multilib dirs.
# Since we configure with just one --libdir, we can't use that
# (as gcc itself takes care of building multilibs). bug #435728
@@ -595,16 +643,6 @@ toolchain_src_prepare() {
gnuconfig_update
- # Update configure files
- local f
- einfo "Fixing misc issues in configure files"
- for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
- ebegin " Updating ${f/${S}\/} [LANG]"
- patch "${f}" "${FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
- || eerror "Please file a bug about this"
- eend $?
- done
-
if ! use prefix-guest && [[ -n ${EPREFIX} ]] ; then
einfo "Prefixifying dynamic linkers..."
for f in gcc/config/*/*linux*.h ; do
@@ -765,7 +803,7 @@ toolchain_src_configure() {
gcc_do_filter_flags
if ! tc_version_is_at_least 11 && [[ $(gcc-major-version) -ge 12 ]] ; then
- # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105695
+ # https://gcc.gnu.org/PR105695
# bug #849359
export ac_cv_std_swap_in_utility=no
fi
@@ -1006,7 +1044,7 @@ toolchain_src_configure() {
fi
confgcc+=(
- # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100289
+ # https://gcc.gnu.org/PR100289
# TOOD: Find a way to disable this just for stage1 cross?
--disable-gcov
@@ -1336,7 +1374,7 @@ toolchain_src_configure() {
# TODO: Ignore RCs here (but TOOLCHAIN_IS_RC isn't yet an eclass var)
if [[ ${PV} == *_p* && -f "${S}"/gcc/doc/gcc.info ]] ; then
- # Safeguard against https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106899 being fixed
+ # Safeguard against https://gcc.gnu.org/PR106899 being fixed
# without corresponding ebuild changes.
eqawarn "Snapshot release with pre-generated info pages found!"
eqawarn "The BDEPEND in the ebuild should be updated to drop texinfo."
@@ -1567,6 +1605,24 @@ gcc_do_filter_flags() {
fi
fi
+ declare -A l1_cache_sizes=()
+ # Workaround for inconsistent cache sizes on hybrid P/E cores
+ # See PR111768 (and bug #904426, bug #908523, and bug #915389)
+ if [[ ${CBUILD} == @(x86_64|i?86)* ]] && [[ ${CFLAGS} == *-march=native* ]] && tc-is-gcc ; then
+ local x
+ local l1_cache_size
+ # Iterate over all cores and find their L1 cache size
+ for x in $(seq 0 $(($(nproc)-1))) ; do
+ [[ -z ${x} || ${x} -gt 64 ]] && break
+ l1_cache_size=$(taskset --cpu-list ${x} $(tc-getCC) -Q --help=params -O2 -march=native \
+ | awk '{ if ($1 ~ /^.*param.*l1-cache-size/) print $2; }' || die)
+ l1_cache_sizes[${l1_cache_size}]=1
+ done
+ # If any of them are different, just pick the first one.
+ if [[ ${#l1_cache_sizes} != 1 ]] ; then
+ append-flags --param=l1-cache-size=${l1_cache_size}
+ fi
+ fi
if ver_test -lt 13.6 ; then
# These aren't supported by the just-built compiler either.
@@ -1799,7 +1855,7 @@ gcc_do_make() {
emake doc-man-doxygen
# Clean bogus manpages. bug #113902
- find -name '*_build_*' -delete
+ find -name '*_build_*' -delete || die
# Blow away generated directory references. Newer versions of gcc
# have gotten better at this, but not perfect. This is easier than
@@ -1817,48 +1873,68 @@ gcc_do_make() {
#---->> src_test <<----
toolchain_src_test() {
- cd "${WORKDIR}"/build || die
+ # GCC's testsuite is a special case.
+ #
+ # * Generally, people work off comparisons rather than a full set of
+ # passing tests.
+ #
+ # * The guality (sic) tests are for debug info quality and are especially
+ # unreliable.
+ #
+ # * The execute torture tests are hopefully a good way for us to smoketest
+ # and find critical regresions.
- # From opensuse's spec file:
- # "asan needs a whole shadow address space"
+ # From opensuse's spec file: "asan needs a whole shadow address space"
ulimit -v unlimited
# 'asan' wants to be preloaded first, so does 'sandbox'.
- # To make asan tests work disable sandbox for all of test suite.
- # 'backtrace' tests also does not like 'libsandbox.so' presence.
- #
- # Nonfatal here as we die if compare_tests failed
- SANDBOX_ON=0 LD_PRELOAD= nonfatal emake -k check
- local success_tests=$?
+ # To make asan tests work, we disable sandbox for all of test suite.
+ # The 'backtrace' tests also do not like the presence of 'libsandbox.so'.
+ local -x SANDBOX_ON=0
+ local -x LD_PRELOAD=
+
+ # Controls running expensive tests in e.g. the torture testsuite.
+ local -x GCC_TEST_RUN_EXPENSIVE=1
+
+ # nonfatal here as we die if the comparison below fails. Also, note that
+ # the exit code of targets other than 'check' may be unreliable.
+ nonfatal emake -C "${WORKDIR}"/build -k "${GCC_TESTS_CHECK_TARGET}" RUNTESTFLAGS="${GCC_TESTS_RUNTESTFLAGS}"
+
+ if [[ -z ${GCC_TESTS_IGNORE_NO_BASELINE} && -f "${GCC_TESTS_COMPARISON_DIR}/${GCC_TESTS_COMPARISON_SLOT}/${CHOST}.xfail" ]] ; then
+ # TODO: Distribute some baseline results in e.g. gcc-patches.git?
+ # validate_failures.py manifest files support include directives.
+ einfo "Comparing with previous cached results at GCC_TESTS_COMPARISON_DIR=${GCC_TESTS_COMPARISON_DIR}/${GCC_TESTS_COMPARISON_SLOT}/${CHOST}.xfail"
+
+ edo "${T}"/validate_failures.py \
+ --srcpath="${S}" \
+ --build_dir="${WORKDIR}"/build \
+ --manifest="${GCC_TESTS_COMPARISON_DIR}/${GCC_TESTS_COMPARISON_SLOT}/${CHOST}.xfail"
+ else
+ # nonfatal first because we want to run again with comparison data if available.
+ nonfatal edo "${T}"/validate_failures.py \
+ --srcpath="${S}" \
+ --build_dir="${WORKDIR}"/build
+ ret=$?
- if [[ ! -d "${BROOT}"/var/cache/gcc/${SLOT} ]] && ! [[ ${success_tests} -eq 0 ]] ; then
# We have no reference data saved from a previous run to know if
# the failures are tolerable or not, so we bail out.
- eerror "Reference test data does NOT exist at ${BROOT}/var/cache/gcc/${SLOT}"
- eerror "Tests failed and nothing to compare with, so this is a fatal error."
- eerror "(Set GCC_TESTS_IGNORE_NO_BASELINE=1 to make this non-fatal for initial run.)"
+ eerror "No reference test data at GCC_TESTS_COMPARISON_DIR=${GCC_TESTS_COMPARISON_DIR}/${GCC_TESTS_COMPARISON_SLOT}/${CHOST}.xfail!"
+ eerror "GCC's tests require a baseline to compare with for any reasonable interpretation of results."
- if [[ -z ${GCC_TESTS_IGNORE_NO_BASELINE} ]] ; then
+ if [[ -n ${GCC_TESTS_IGNORE_NO_BASELINE} ]] ; then
+ eerror "GCC_TESTS_IGNORE_NO_BASELINE is set, creating new baseline manifest..."
+ elif [[ ${ret} != 0 ]]; then
+ eerror "(Set GCC_TESTS_IGNORE_NO_BASELINE=1 to make this non-fatal for initial run.)"
die "Tests failed (failures occurred with no reference data)"
fi
fi
- einfo "Testing complete! Review the following output to check for success or failure."
- einfo "Please ignore any 'mail' lines in the summary output below (no mail is sent)."
- einfo "Summary:"
- "${S}"/contrib/test_summary
-
- # If previous results exist on the system, compare with it
- # TODO: Distribute some baseline results in e.g. gcc-patches.git?
- if [[ -d "${BROOT}"/var/cache/gcc/${SLOT} ]] ; then
- einfo "Comparing with previous cached results at ${BROOT}/var/cache/gcc/${SLOT}"
-
- # Exit with the following values:
- # 0 if there is nothing of interest
- # 1 if there are errors when comparing single test case files
- # N for the number of errors found when comparing directories
- "${S}"/contrib/compare_tests "${BROOT}"/var/cache/gcc/${SLOT}/ . || die "Comparison for tests results failed, error code: $?"
- fi
+ # Produce an updated set of expected results
+ edo "${T}"/validate_failures.py \
+ --srcpath="${S}" \
+ --build_dir="${WORKDIR}"/build \
+ --manifest="${T}"/${CHOST}.xfail \
+ --produce_manifest &> /dev/null
}
#---->> src_install <<----
@@ -1886,7 +1962,7 @@ toolchain_src_install() {
# See https://gcc.gnu.org/onlinedocs/gcc-11.3.0/jit/internals/index.html#packaging-notes
# and bug #843341.
#
- # Both of the non-JIT and JIT builds are configured to install to $(DESTDIR)
+ # Both of the non-JIT and JIT builds are configured to install to $(DESTDIR)
# Install the configuration with --enable-host-shared first
# *then* the one without, so that the faster build
# of "cc1" et al overwrites the slower build.
@@ -1896,9 +1972,9 @@ toolchain_src_install() {
S="${WORKDIR}"/build-jit emake DESTDIR="${D}" -j1 install
# Punt some tools which are really only useful while building gcc
- find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
+ find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \; || die
# This one comes with binutils
- find "${ED}" -name libiberty.a -delete
+ find "${ED}" -name libiberty.a -delete || die
# Move the libraries to the proper location
gcc_movelibs
@@ -1913,16 +1989,16 @@ toolchain_src_install() {
# with it. Several reported bugs exist where the resulting image
# was wrong, rather than a simple compile/install failure:
# - bug #906155
- # - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42980
- # - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51814
- # - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103656
- # - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109898
+ # - https://gcc.gnu.org/PR42980
+ # - https://gcc.gnu.org/PR51814
+ # - https://gcc.gnu.org/PR103656
+ # - https://gcc.gnu.org/PR109898
S="${WORKDIR}"/build emake DESTDIR="${D}" -j1 install
# Punt some tools which are really only useful while building gcc
- find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
+ find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \; || die
# This one comes with binutils
- find "${ED}" -name libiberty.a -delete
+ find "${ED}" -name libiberty.a -delete || die
# Move the libraries to the proper location
gcc_movelibs
@@ -1998,9 +2074,9 @@ toolchain_src_install() {
rm -rf "${ED}"/usr/share/{man,info}
rm -rf "${D}"${DATAPATH}/{man,info}
else
- local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
+ local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man || die)
if [[ -d ${cxx_mandir} ]] ; then
- cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
+ cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/ || die
fi
fi
@@ -2014,7 +2090,7 @@ toolchain_src_install() {
docompress "${DATAPATH}"/{info,man}
# Prune empty dirs left behind
- find "${ED}" -depth -type d -delete 2>/dev/null
+ find "${ED}" -depth -type d -delete 2>/dev/null || die
# libstdc++.la: Delete as it doesn't add anything useful: g++ itself
# handles linkage correctly in the dynamic & static case. It also just
@@ -2051,17 +2127,17 @@ toolchain_src_install() {
-name libitm.la -o \
-name libvtv.la -o \
-name 'lib*san.la' \
- ')' -type f -delete
+ ')' -type f -delete || die
# Use gid of 0 because some stupid ports don't have
# the group 'root' set to gid 0. Send to /dev/null
# for people who are testing as non-root.
- chown -R 0:0 "${D}${LIBPATH}" 2>/dev/null
+ chown -R 0:0 "${D}${LIBPATH}" 2>/dev/null || die
# Installing gdb pretty-printers into gdb-specific location.
local py gdbdir=/usr/share/gdb/auto-load${LIBPATH}
- pushd "${D}${LIBPATH}" >/dev/null
- for py in $(find . -name '*-gdb.py') ; do
+ pushd "${D}${LIBPATH}" >/dev/null || die
+ for py in $(find . -name '*-gdb.py' || die) ; do
local multidir=${py%/*}
insinto "${gdbdir}/${multidir}"
@@ -2071,7 +2147,7 @@ toolchain_src_install() {
rm "${py}" || die
done
- popd >/dev/null
+ popd >/dev/null || die
# Don't scan .gox files for executable stacks - false positives
export QA_EXECSTACK="usr/lib*/go/*/*.gox"
@@ -2082,16 +2158,9 @@ toolchain_src_install() {
pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
if use test ; then
- # TODO: In future, install orphaned to allow comparison across
- # more versions even after unmerged? Also would be useful for
- # historical records and tracking down regressions a while
- # after they first appeared, but were only just reported.
- einfo "Copying test results to ${EPREFIX}/var/cache/gcc/${SLOT} for future comparison"
- (
- dodir /var/cache/gcc/${SLOT}
- cd "${WORKDIR}"/build || die
- find . -name \*.sum -exec cp --parents -v {} "${ED}"/var/cache/gcc/${SLOT} \;
- )
+ mkdir "${T}"/test-results || die
+ cd "${WORKDIR}"/build || die
+ find . -name \*.sum -exec cp --parents -v {} "${T}"/test-results \; || die
fi
}
@@ -2138,7 +2207,7 @@ gcc_movelibs() {
removedirs="${removedirs} ${FROMDIR}"
FROMDIR=${D}${FROMDIR}
if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
- local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
+ local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null || die)
if [[ -n ${files} ]] ; then
mv ${files} "${TODIR}" || die
fi
@@ -2154,7 +2223,7 @@ gcc_movelibs() {
for FROMDIR in ${removedirs} ; do
rmdir "${D}"${FROMDIR} >& /dev/null
done
-
+ # XXX: Intentionally no die, here to remove empty dirs
find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null
}
@@ -2244,6 +2313,26 @@ create_revdep_rebuild_entry() {
EOF
}
+#---->> pkg_pre* <<----
+
+toolchain_pkg_preinst() {
+ if use test ; then
+ # Install as orphaned to allow comparison across more versions even
+ # after unmerged. Also useful for historical records and tracking
+ # down regressions a while after they first appeared, but were only
+ # just reported.
+ einfo "Copying test results to ${GCC_TESTS_COMPARISON_DIR}/${SLOT}/${CHOST}.xfail for future comparison"
+ (
+ mkdir -p "${GCC_TESTS_COMPARISON_DIR}/${SLOT}" || die
+ cd "${T}"/test-results || die
+ # May not exist with test-fail-continue
+ if [[ -f "${T}"/${CHOST}.xfail ]] ; then
+ cp -v "${T}"/${CHOST}.xfail "${GCC_TESTS_COMPARISON_DIR}/${SLOT}" || die
+ fi
+ )
+ fi
+}
+
#---->> pkg_post* <<----
toolchain_pkg_postinst() {
@@ -2497,4 +2586,4 @@ fi
# enabled-by-default state:
# econf $(usex foo '' --disable-foo)
-EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_postinst pkg_postrm
+EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm