# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4 PortSystem 1.0 PortGroup select 1.0 PortGroup compiler_blacklist_versions 1.0 PortGroup active_variants 1.1 PortGroup conflicts_build 1.0 epoch 2 name gcc11 version 11.4.0 revision 1 platforms {darwin >= 10 < 22} categories lang maintainers nomaintainer # an exception in the license allows dependents to not be GPL license {GPL-3+ Permissive} description The GNU compiler collection long_description The GNU compiler collection, including front ends for \ C, C++, Objective-C, Objective-C++ and Fortran. homepage https://gcc.gnu.org/ # Primary releases master_sites https://ftpmirror.gnu.org/gcc/gcc-${version}/ \ https://mirror.its.dal.ca/gnu/gcc/gcc-${version}/ \ https://mirrors.kernel.org/gnu/gcc/gcc-${version}/ \ https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-${version}/ \ https://ftp-stud.hs-esslingen.de/pub/Mirrors/ftp.gnu.org/gcc/gcc-${version}/ \ https://mirror.yongbok.net/gnu/gcc/gcc-${version}/ \ http://mirror.koddos.net/gcc/releases/gcc-${version}/ \ ftp://ftp.gwdg.de/pub/linux/gcc/releases/gcc-${version}/ \ ftp://gcc.ftp.nluug.nl/mirror/languages/gcc/releases/gcc-${version}/ \ ftp://gcc.gnu.org/pub/gcc/releases/gcc-${version}/ \ gnu:gcc/gcc-${version} distname gcc-${version} use_xz yes checksums rmd160 a43fd21a3887af24daa550c4b52fb634e33b633c \ sha256 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9 \ size 79837032 set libgccname lib${name} subport ${libgccname} { revision [ expr ${revision} + 0 ] } set libcxxname ${name}-libcxx if { ${os.platform} eq "darwin" } { # Patch generated from https://github.com/iains/gcc-11-branch # git diff --no-prefix releases/gcc-11.3.0 gcc-11.3-darwin-r2 patchfiles-append patch-darwin-gcc-${version}.diff } if { ${os.platform} eq "darwin" && ${os.major} >= 17 } { # On macOS 10.13 and later, compilation is extremely slow if SIP is # disabled; e.g. from ~30m with SIP enabled, to ~6 hours if disabled. # # This is caused by gcc's build system setting DYLD_LIBRARY_PATH to ensure # that the toolchain picks up newly built library versions, which seems to # trigger a pathologically slow path in dyld's library resolution. # # Since dyld ignores DYLD_LIBRARY_PATH when SIP is enabled, the issue is # avoided entirely, but at the cost of potentially falling back to incorrect # system library paths. The correct, SIP-compatible solution would be gcc # adopting @rpath. # # However, given that SIP is enabled by default in macOS, including on our # build bots, we already have to assume that ignoring DYLD_LIBRARY_PATH will # still produce a valid toolchain. # # Given that, we go ahead and disable DYLD_LIBRARY_PATH explicitly, avoiding # otherwise unworkably long build-times for hosts with SIP disabled. # # See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84257 patchfiles-append patch-disable-dyld_library_path.diff } # Since GCC 7.4.0, during configure, it detects features supported by target-as. # On the other hand, MacPorts cctools contain a proxy for 'as' that runs system # 'as' or one of the supported MacPorts clang's 'as' if it is installed. Here, # we may encounter a misconfiguration when GCC builds on a system with some # MacPorts clang, and 'as' is using it. However, on a clean system, it uses # system 'as' if no MacPorts clang is installed, which may behave differently. # This can make GCC broken until MacPorts clang is installed. To avoid a stealth # dependency on the used clang, I enforce building with system 'as'. # See: # - https://trac.macports.org/ticket/68683 # - https://github.com/gcc-mirror/gcc/commit/b410cf1dc056aab195c5408871ffca932df8a78a patchfiles-append patch-gcc10-disable-macports-cctools-as-changes.diff configure.env-append \ DISABLE_MACPORTS_AS_CLANG_SEARCH=1 \ DISABLE_XCODE_AS_CLANG_SEARCH=1 build.env-append DISABLE_MACPORTS_AS_CLANG_SEARCH=1 \ DISABLE_XCODE_AS_CLANG_SEARCH=1 depends_build-append \ port:texinfo depends_lib-append port:cctools \ port:gmp \ path:lib/pkgconfig/isl.pc:isl \ port:ld64 \ port:libiconv \ port:libmpc \ port:mpfr \ port:zlib \ port:zstd depends_run-append port:gcc_select \ port:libgcc11 depends_skip_archcheck-append gcc_select ld64 cctools license_noconflict gmp mpfr ppl libmpc zlib set major [lindex [split ${version} .-] 0] platform darwin { configure.pre_args-append --build=${build_arch}-apple-darwin${os.major} } set gcc_configure_langs {c c++ objc obj-c++ lto fortran} if {${subport} eq ${name} && ${build_arch} ne "i386"} { # jit compiler is not building on i386 systems # https://trac.macports.org/ticket/61130 lappend gcc_configure_langs jit } set gcc_as ${prefix}/bin/as set gcc_ld ${prefix}/bin/ld set gcc_ar ${prefix}/bin/ar set gcc_nm ${prefix}/bin/nm set mp_extra_rpath ${prefix}/lib/libgcc configure.dir ${workpath}/build configure.cmd ${worksrcpath}/configure configure.args --enable-languages=[join ${gcc_configure_langs} ","] \ --libdir=${prefix}/lib/${name} \ --includedir=${prefix}/include/${name} \ --infodir=${prefix}/share/info \ --mandir=${prefix}/share/man \ --datarootdir=${prefix}/share/gcc-${major} \ --with-local-prefix=${prefix} \ --with-system-zlib \ --disable-nls \ --program-suffix=-mp-${major} \ --with-gxx-include-dir=${prefix}/include/${name}/c++/ \ --with-gmp=${prefix} \ --with-mpfr=${prefix} \ --with-mpc=${prefix} \ --with-isl=${prefix} \ --with-zstd=${prefix} \ --enable-checking=release \ --disable-multilib \ --enable-lto \ --enable-libstdcxx-time \ --with-build-config=bootstrap-debug \ --with-as=${prefix}/bin/as \ --with-ld=${prefix}/bin/ld \ --with-ar=${prefix}/bin/ar \ --with-bugurl=https://trac.macports.org/newticket \ --enable-host-shared \ --with-darwin-extra-rpath=${mp_extra_rpath} # see https://lists.macports.org/pipermail/macports-dev/2017-August/036209.html # --disable-tls does not limit functionality # it only determines how std::call_once works configure.args-append \ --disable-tls # Disable ccache configure.ccache no if { ${subport} ne ${libcxxname} && ${os.platform} eq "darwin" } { # gcc has build issues on macOS 11.3 with the use of Xcode 12.5 clang via cctools for ld # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100340 # https://trac.macports.org/ticket/62775 # Bootstrap comparison fails on 10.6, so disable for that case too # https://trac.macports.org/ticket/65149 # ... also now fails mysteriously on 10.7 # https://github.com/macports/macports-ports/commit/21bcf9d4ae1feade8f4c53c7608febf8d249cea8#commitcomment-78674560 if { ([vercmp ${xcodeversion} >= 12.5] && [vercmp ${xcodeversion} < 13]) || \ ([vercmp ${xcodecltversion} >= 12.5] && [vercmp ${xcodecltversion} < 13]) || \ (${os.major} <= 11) } \ { # Skip bootstrap comparison entirely post-patch { reinplace {s|^do-compare =|do-compare = /usr/bin/true|g} \ ${worksrcpath}/Makefile.in \ ${worksrcpath}/config/bootstrap-debug.mk \ ${worksrcpath}/config/bootstrap-debug-lean.mk \ ${worksrcpath}/config/bootstrap-debug-lib.mk } } } configure.args-append \ --with-as=${gcc_as} \ --with-ld=${gcc_ld} \ --with-ar=${gcc_ar} \ configure.env-append \ AR_FOR_TARGET=${gcc_ar} \ AS_FOR_TARGET=${gcc_as} \ LD_FOR_TARGET=${gcc_ld} \ NM_FOR_TARGET=${gcc_nm} \ OBJDUMP_FOR_TARGET=${prefix}/bin/objdump \ RANLIB_FOR_TARGET=${prefix}/bin/ranlib \ STRIP_FOR_TARGET=${prefix}/bin/strip \ OTOOL=${prefix}/bin/otool \ OTOOL64=${prefix}/bin/otool if {${os.platform} eq "darwin" && ${os.major} >= 22} { if { [vercmp ${xcodeversion} >= 15.0] || [vercmp ${xcodecltversion} >= 15.0] } { # On macOS13 and newer ensure the 'legacy' linker is used as GCC currently has problems # with the new default linker in Xcode 15. See e.g. # https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking # https://discussions.apple.com/thread/255137447 # https://developer.apple.com/forums/thread/737707 # https://github.com/Homebrew/homebrew-core/issues/145991 configure.args-replace --with-ld=${prefix}/bin/ld --with-ld=${prefix}/bin/ld-classic # Ensure ld64 is installed with the correct variant need for ld-classic require_active_variants ld64 ld64_xcode } } pre-configure { # Set package info configure.args-append --with-pkgversion="MacPorts ${name} ${version}_${revision}${portvariants}" if {${configure.sdkroot} ne ""} { # We should be using --with-build-sysroot here. Using --with-sysroot # changes the behavior of the installed gcc to look in that sysroot # by default instead of /. Using --with-build-sysroot is supposed # to be used during the build but not impact the installed product. # Unfortunately, the build fails because the value doesn't get # plumbed everywhere it is supposed to. # # https://trac.macports.org/ticket/53726 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79885 # if the sdkroot is one of the current, rapidly changing SDKS, use the generic one configure.args-append --with-sysroot="[regsub {MacOSX1[1-9]\.[0-9]+\.sdk} ${configure.sdkroot} {MacOSX.sdk}]" } } set libcxx_incpath ${prefix}/libexec/${name}/libc++/include/c++/v1 subport ${libcxxname} { PortGroup compilers 1.0 compilers.choose cxx compilers.setup -gcc -fortran -clangdevel -clang34 -clang35 -clang36 \ -clang37 -clang50 -clang60 -clang70 -clang80 -clang90 if { ![clang_variant_isset] } { if { ${os.platform} eq "darwin" && ${os.major} < 11 } { default_variants-append +clang11 } else { default_variants-append +clang14 } } revision [ expr ${revision} + 0 ] description libc++ header implementation to be used by ${name} long_description {*}${description} homepage https://llvm.org/ license NCSA depends_build depends_extract depends_run depends_lib distfiles patchfiles use_configure no supported_archs noarch platforms any # Find clang/llvm version to use from active variant proc getClangVersion {} { if { [regexp {clang(.*)} [clang_variant_name] -> clang_v] } { return ${clang_v} } return "" } set mp_clang_ver [getClangVersion] build { # Copy headers from clang-N during build file mkdir ${worksrcpath}/headers file copy ${prefix}/libexec/llvm-${mp_clang_ver}/include/c++/v1 ${worksrcpath}/headers/ } destroot { set base_dir [file dirname ${libcxx_incpath}] file mkdir ${destroot}${base_dir} file copy ${worksrcpath}/headers/v1 ${destroot}${base_dir} } } if { ${subport} ne ${libcxxname} } { variant stdlib_flag description {Enable stdlib command line flag to select c++ runtime} { # Enables support for specifying the c++ runtime via `-stdlib=` in a similar # way to clang. For more details see the later comments in # https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg257385.html # Note : This 'bakes' the libc++ include directory into gcc, # which is then used as the default search location when `-stdlib=libc++` # is given. Therefore to have consistency across various OS versions, and to enable # modern c++ standards, use a recent macports clang port to provide this. if {${subport} eq ${name}} { depends_run-append port:${libcxxname} } configure.args-append --with-gxx-libcxx-include-dir="${libcxx_incpath}" } # libcxx is unavailable on PPC if {${build_arch} ni [list ppc ppc64]} { default_variants-append +stdlib_flag } } # https://trac.macports.org/ticket/29067 # https://trac.macports.org/ticket/29104 # https://trac.macports.org/ticket/47996 # https://trac.macports.org/ticket/58493 compiler.blacklist-append {clang < 800} gcc-4.0 *gcc-4.2 {llvm-gcc-4.2 < 2336.1} {macports-clang-3.[4-7]} # https://build.macports.org/builders/ports-10.13_x86_64-builder/builds/105513/steps/install-port/logs/stdio # c++/v1/functional:1408:2: error: no member named 'fancy_abort' in namespace 'std::__1'; did you mean simply 'fancy_abort'? compiler.blacklist-append {clang < 1000} # "-stdlib" would be passed on to the bootstrap compiler if present configure.cxx_stdlib build.dir ${configure.dir} build.target bootstrap-lean use_parallel_build yes destroot.target install install-info-host # gcc cannot build if libunwind-headers is active conflicts_build-append libunwind-headers binutils # List of dylibs to be installed # Note that we really don't want to include libgcc_ext.10.[45].dylib here, but install_name_tool # doesn't know how to change the id of stubs, and it's easier than recreating them for each # gcc port. set all_dylibs {libgcc_ext.10.4.dylib libgcc_ext.10.5.dylib libgcc_s.1.dylib libgcc_s.1.1.dylib \ libgcc_s.2.dylib libgfortran.5.dylib libquadmath.0.dylib libstdc++.6.dylib \ libobjc-gnu.4.dylib libgomp.1.dylib libitm.1.dylib libssp.0.dylib libasan.6.dylib \ libubsan.1.dylib libatomic.1.dylib libgcc_ehs.1.1.dylib} set install_dylibs {libasan.6.dylib} if {${subport} eq ${libgccname}} { # Activate hack for new libgcc # https://trac.macports.org/wiki/PortfileRecipes#deactivatehack pre-activate { if {![catch {set installed [lindex [registry_active libgcc8] 0]}]} { # Extract the epoch of the installed libgcc8 set _epoch [lindex $installed 5] # If < 5 need to deactivate if {[vercmp $_epoch < 5]} { registry_deactivate_composite libgcc8 "" [list ports_nodepcheck 1] } } if {![catch {set installed [lindex [registry_active libgcc10] 0]}]} { # Extract the epoch of the installed libgcc10 set _epoch [lindex $installed 5] # If < 6 need to deactivate if {[vercmp $_epoch < 6]} { registry_deactivate_composite libgcc10 "" [list ports_nodepcheck 1] } } if {![catch {set installed [lindex [registry_active libgcc-devel] 0]}]} { # Extract the epoch of the installed libgcc-devel set _epoch [lindex $installed 5] # If < 5 need to deactivate if {[vercmp $_epoch < 5]} { registry_deactivate_composite libgcc-devel "" [list ports_nodepcheck 1] } } } # http://trac.macports.org/ticket/35770 # http://trac.macports.org/ticket/38814 # While there can be multiple versions of these runtimes in a single # process, it is not possible to pass objects between different versions, # so we simplify this by having the libgcc port provide the newest version # of these runtimes for all versions of gcc to use. # # If there is a binary incompatible change to the runtime in a future # version of gcc, then the latest version of gcc to provide a given ABI # version should continue to provide a subport for that and older gcc # versions. depends_run port:libgcc12 depends_build-append {*}${depends_lib} depends_lib # On arm or Darwin 11 and older nothing is installed so skip build entirely if { ${os.arch} eq "arm" || ${os.major} < 12 } { fetch.type none build { } use_configure no patchfiles destroot { set doc_dir ${destroot}${prefix}/share/doc/${subport} xinstall -m 755 -d ${doc_dir} system "echo ${subport} provides no runtime > ${doc_dir}/README" } } else { configure.args-replace \ --libdir=${prefix}/lib/${name} \ --libdir=${prefix}/lib/libgcc # see https://trac.macports.org/ticket/54766 configure.args-replace \ --includedir=${prefix}/include/${name} \ --includedir=${prefix}/include/gcc configure.args-replace \ --with-gxx-include-dir=${prefix}/include/${name}/c++/ \ --with-gxx-include-dir=${prefix}/include/gcc/c++/ post-destroot { # Temporary working dir for dylibs file mkdir ${destroot}${prefix}/lib/libgcc.merged # loop over libs to install foreach dylib ${install_dylibs} { # Different OS versions (e.g. Leopard) or architectures (e.g. PPC) don't produce all the dylibs # https://trac.macports.org/ticket/40098 # https://trac.macports.org/ticket/40100 if {![file exists ${destroot}${prefix}/lib/libgcc/${dylib}]} { continue } # Move dylib to temp area move ${destroot}${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/libgcc.merged # Universal support if {[variant_exists universal] && [variant_isset universal]} { foreach archdir [glob ${destroot}${prefix}/lib/libgcc/*/] { set archdir_nodestroot [string map "${destroot}/ /" ${archdir}] if {[file exists ${archdir}/${dylib}]} { system "install_name_tool -id ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}" foreach link [glob -tails -directory ${archdir} *.dylib] { system "install_name_tool -change ${archdir_nodestroot}${link} ${prefix}/lib/libgcc/${link} ${archdir}/${dylib}" } system "lipo -create -output ${destroot}${prefix}/lib/libgcc.merged/${dylib}~ ${destroot}${prefix}/lib/libgcc.merged/${dylib} ${archdir}/${dylib} && mv ${destroot}${prefix}/lib/libgcc.merged/${dylib}~ ${destroot}${prefix}/lib/libgcc.merged/${dylib}" } } } # strip debug symbols to supress debugger warnings: # http://trac.macports.org/attachment/ticket/34831 if {! [string match *libgcc_ext* ${dylib}]} { system "strip -x ${destroot}${prefix}/lib/libgcc.merged/${dylib}" } } # Remove stuff not provided by libgccX ports file delete -force ${destroot}${prefix}/bin file delete -force ${destroot}${prefix}/share file delete -force ${destroot}${prefix}/lib/libgcc file delete -force ${destroot}${prefix}/libexec # Move temporary lib dir back in place move ${destroot}${prefix}/lib/libgcc.merged ${destroot}${prefix}/lib/libgcc # Remove includes. Provided by newer libgcc. file delete -force ${destroot}${prefix}/include set doc_dir ${destroot}${prefix}/share/doc/${subport} xinstall -m 755 -d ${doc_dir} system "echo ${subport} provides additional runtime > ${doc_dir}/README" } } } if {${subport} eq ${name}} { post-destroot { file delete ${destroot}${prefix}/share/info/dir foreach file [glob ${destroot}${prefix}/share/{info,man/man7}/*] { set extension [file extension ${file}] set newfile [regsub "${extension}$" ${file} "-mp-${major}${extension}"] file rename ${file} ${newfile} } # loop over libs to install foreach dylib ${all_dylibs} { # Different OS versions (e.g. Leopard) or architectures (e.g. PPC) don't produce all the dylibs # https://trac.macports.org/ticket/40098 # https://trac.macports.org/ticket/40100 if {[file exists ${destroot}${prefix}/lib/${name}/${dylib}]} { delete ${destroot}${prefix}/lib/${name}/${dylib} ln -s ${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/${name}/${dylib} } if {[variant_exists universal] && [variant_isset universal]} { foreach archdir [glob ${destroot}${prefix}/lib/${name}/*/] { if {[file exists ${archdir}/${dylib}]} { delete ${archdir}/${dylib} ln -s ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib} } } } } } select.group gcc select.file ${filespath}/mp-${name} } if { ${subport} ne ${libcxxname} } { post-destroot { # Ensure all dylibs in destroot have our extra rpath added .. # https://trac.macports.org/ticket/65503 foreach dlib [ exec find ${destroot}${prefix} -type f -and -name "*.dylib" ] { ui_debug "Ensuring DYLIB '${dlib}' has RPATH '${mp_extra_rpath}'" # Note install_name_tool returns a failure if the dylib already has the entry # We don't want that here so force final status to be true... system "install_name_tool -add_rpath ${mp_extra_rpath} ${dlib} > /dev/null 2>&1 ; true" } } if {${os.platform} eq "darwin" && ${os.major} <= 18} { switch -- $build_arch { i386 - x86_64 { configure.universal_archs i386 x86_64 } ppc - ppc64 { configure.universal_archs ppc ppc64 } } variant universal { configure.args-delete --disable-multilib } } else { universal_variant no } # the generated compiler doesn't accept -arch configure.env-append \ "CPP=${configure.cc} -E" \ "CPP_FOR_BUILD=${configure.cc} -E" \ "CXXCPP=${configure.cxx} -E" build.env-append \ "CPP=${configure.cc} -E" \ "CPP_FOR_BUILD=${configure.cc} -E" \ "CXXCPP=${configure.cxx} -E" configure.cc-append [get_canonical_archflags] configure.cc_archflags configure.cxx-append ${configure.cxx_archflags} configure.cxx_archflags configure.objc_archflags configure.ld_archflags configure.universal_cflags configure.universal_cxxflags configure.universal_ldflags configure.universal_args } livecheck.type regex #livecheck.url https://ftp.gnu.org/gnu/gcc/ livecheck.url http://mirror.koddos.net/gcc/releases/ livecheck.regex gcc-(${major}\\.\[0-9.\]+)/