|
| 1 | +# Copyright 1999-2024 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | + |
| 6 | +TOOLCHAIN_PATCH_DEV="sam" |
| 7 | +PATCH_GCC_VER="14.1.0" |
| 8 | +PATCH_VER="3" |
| 9 | +MUSL_VER="1" |
| 10 | +MUSL_GCC_VER="14.1.0" |
| 11 | +PYTHON_COMPAT=( python3_{10..12} ) |
| 12 | + |
| 13 | +if [[ -n ${TOOLCHAIN_GCC_RC} ]] ; then |
| 14 | + # Cheesy hack for RCs |
| 15 | + MY_PV=$(ver_cut 1).$((($(ver_cut 2) + 1))).$((($(ver_cut 3) - 1)))-RC-$(ver_cut 5) |
| 16 | + MY_P=${PN}-${MY_PV} |
| 17 | + GCC_TARBALL_SRC_URI="mirror://gcc/snapshots/${MY_PV}/${MY_P}.tar.xz" |
| 18 | + TOOLCHAIN_SET_S=no |
| 19 | + S="${WORKDIR}"/${MY_P} |
| 20 | +fi |
| 21 | + |
| 22 | +inherit toolchain |
| 23 | + |
| 24 | +if tc_is_live ; then |
| 25 | + # Needs to be after inherit (for now?), bug #830908 |
| 26 | + EGIT_BRANCH=releases/gcc-$(ver_cut 1) |
| 27 | +elif [[ -z ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then |
| 28 | + # Don't keyword live ebuilds |
| 29 | + KEYWORDS="~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris" |
| 30 | +fi |
| 31 | + |
| 32 | +# use alternate source for Apple M1 (also works for x86_64) |
| 33 | +SRC_URI+=" elibc_Darwin? ( https://raw.githubusercontent.com/Homebrew/formula-patches/82b5c1cd38826ab67ac7fc498a8fe74376a40f4a/gcc/gcc-14.1.0.diff -> gcc-14.1.0-arm64-darwin.patch https://github.com/iains/gcc-14-branch/commit/75ff8c390327ac693f6a1c40510bc0d35d7a1e22.patch?full_index=1 -> gcc-14.1.0-macos-SDK-availability.patch )" |
| 34 | +IUSE+=" bootstrap" |
| 35 | + |
| 36 | +if [[ ${CATEGORY} != cross-* ]] ; then |
| 37 | + # Technically only if USE=hardened *too* right now, but no point in complicating it further. |
| 38 | + # If GCC is enabling CET by default, we need glibc to be built with support for it. |
| 39 | + # bug #830454 |
| 40 | + RDEPEND="!prefix-guest? ( elibc_glibc? ( sys-libs/glibc[cet(-)?] ) )" |
| 41 | + DEPEND="${RDEPEND}" |
| 42 | +fi |
| 43 | + |
| 44 | +src_prepare() { |
| 45 | + # apply big arm64-darwin patch first thing |
| 46 | + use elibc_Darwin && eapply \ |
| 47 | + "${DISTDIR}"/gcc-14.1.0-arm64-darwin.patch \ |
| 48 | + "${DISTDIR}"/gcc-14.1.0-macos-SDK-availability.patch |
| 49 | + |
| 50 | + # make sure 64-bits native targets don't screw up the linker paths |
| 51 | + eapply "${FILESDIR}"/gcc-12-no-libs-for-startfile.patch |
| 52 | + |
| 53 | + local p upstreamed_patches=( |
| 54 | + # add them here |
| 55 | + ) |
| 56 | + for p in "${upstreamed_patches[@]}"; do |
| 57 | + rm -v "${WORKDIR}/patch/${p}" || die |
| 58 | + done |
| 59 | + |
| 60 | + toolchain_src_prepare |
| 61 | + # |
| 62 | + # make it have correct install_names on Darwin |
| 63 | + eapply -p1 "${FILESDIR}"/4.3.3/darwin-libgcc_s-installname.patch |
| 64 | + |
| 65 | + if [[ ${CHOST} == powerpc*-darwin* ]] ; then |
| 66 | + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44107 |
| 67 | + sed -i -e 's|^ifeq (/usr/lib,|ifneq (/usr/lib,|' \ |
| 68 | + libgcc/config/t-slibgcc-darwin || die |
| 69 | + fi |
| 70 | + |
| 71 | + if [[ ${CHOST} == *-solaris* ]] ; then |
| 72 | + # madvise is not available in the compatibility mode GCC uses, |
| 73 | + # posix_madvise however, is |
| 74 | + sed -i -e 's/madvise/posix_madvise/' gcc/cp/module.cc || die |
| 75 | + fi |
| 76 | + |
| 77 | + if [[ ${CHOST} == *-darwin* ]] ; then |
| 78 | + use bootstrap && eapply "${FILESDIR}"/${PN}-13-darwin14-bootstrap.patch |
| 79 | + |
| 80 | + # our ld64 is a slight bit different, so tweak expression to not |
| 81 | + # get confused and break the build |
| 82 | + sed -i -e "s/EGREP 'ld64|dyld'/& | head -n1/" \ |
| 83 | + gcc/configure{.ac,} || die |
| 84 | + |
| 85 | + # rip out specific macos version min |
| 86 | + sed -i -e 's/-mmacosx-version-min=11.0//' \ |
| 87 | + libgcc/config/aarch64/t-darwin \ |
| 88 | + libgcc/config/aarch64/t-heap-trampoline \ |
| 89 | + || die |
| 90 | + fi |
| 91 | + |
| 92 | + eapply "${FILESDIR}"/${PN}-13-fix-cross-fixincludes.patch |
| 93 | + eapply_user |
| 94 | +} |
0 commit comments