Ticket #54773: gcc7-libgcc+libcxx.diff

File gcc7-libgcc+libcxx.diff, 27.3 KB (added by RJVB (René Bertin), 7 years ago)
  • lang/gcc7/Portfile

    diff --git a/lang/gcc7/Portfile b/lang/gcc7/Portfile
    index e8d81c7..1a3707e 100644
    a b  
    33PortSystem 1.0
    44PortGroup select 1.0
    55PortGroup compiler_blacklist_versions 1.0
     6PortGroup active_variants 1.1
    67
    78name                gcc7
    8 subport             libgcc {}
     9
     10# are we the port that currently provides libgcc?
     11set provides_libgcc 1
    912
    1013epoch               2
    1114version             7.2.0
    1215
     16set major           [lindex [split ${version} .-] 0]
     17set ver3char        [join [split ${version} '.'] ""]
     18
     19if {${provides_libgcc}} {
     20    set libgcc_port libgcc
     21} else {
     22    set libgcc_port libgcc${major}
     23}
     24
     25subport             ${libgcc_port} {}
     26
    1327platforms           darwin
    1428categories          lang
    1529maintainers         nomaintainer
    use_xz yes 
    3246checksums           rmd160  fa8eed36c78cf135f9cc88e60845996b5cfaba52 \
    3347                    sha256  1cf7adf8ff4b5aa49041c8734bbcf1ad18cc4c94d0029aae0f4e48841088479a
    3448
     49installs_libs       yes
     50
    3551depends_lib         port:cctools \
    3652                    port:gmp \
    3753                    path:lib/pkgconfig/isl.pc:isl \
    depends_lib port:cctools \ 
    4460depends_skip_archcheck-append gcc_select ld64 cctools
    4561license_noconflict  gmp mpfr ppl libmpc
    4662
    47 set major           [lindex [split ${version} .-] 0]
    48 
    4963platform darwin {
    5064    configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
    5165
    5266    # see https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00672.html
    53     patchfiles-append         patch-float128.diff
     67    patchfiles-append patch-float128.diff
     68    # cause `as` to be invoked with the -q option so that it
     69    # invokes the clang integrated assembler (instead of the obsolete GNU as)
     70    # `man as` claims that this is the default but clearly that is not true everywhere.
     71    patchfiles-append patch-default-clang-assembler.diff
    5472}
    5573
    5674configure.dir       ${workpath}/build
    5775configure.cmd       ${worksrcpath}/configure
     76
     77# where to install the headers, should be unversioned for the GCC version that
     78# provides port:libgcc and versioned for all other ports
     79if {${provides_libgcc}} {
     80    set gcc_headerdir ${prefix}/include/gcc
     81} else {
     82    set gcc_headerdir ${prefix}/include/${name}
     83}
     84
     85# the runtime libraries are built for installation to lib/gcc${ver3char} (e.g. lib/gcc720)
     86# but will ultimately still be installed into lib/libgcc .
     87# The change is only because lib/libgcc and lib/gcc720 have the same length.
    5888configure.args      --enable-languages=c,c++,objc,obj-c++,lto,fortran \
    59                     --libdir=${prefix}/lib/${name} \
    60                     --includedir=${prefix}/include/${name} \
     89                    --libdir=${prefix}/lib/gcc${ver3char} \
     90                    --includedir=${gcc_headerdir} \
    6191                    --infodir=${prefix}/share/info \
    6292                    --mandir=${prefix}/share/man \
    6393                    --datarootdir=${prefix}/share/gcc-${major} \
    configure.args --enable-languages=c,c++,objc,obj-c++,lto,fortran \ 
    6595                    --with-system-zlib \
    6696                    --disable-nls \
    6797                    --program-suffix=-mp-${major} \
    68                     --with-gxx-include-dir=${prefix}/include/${name}/c++/ \
     98                    --with-gxx-include-dir=${gcc_headerdir}/c++/ \
    6999                    --with-gmp=${prefix} \
    70100                    --with-mpfr=${prefix} \
    71101                    --with-mpc=${prefix} \
    configure.args --enable-languages=c,c++,objc,obj-c++,lto,fortran \ 
    75105                    --enable-lto \
    76106                    --enable-libstdcxx-time \
    77107                    --with-build-config=bootstrap-debug \
    78                     --with-as=${prefix}/bin/as \
    79108                    --with-ld=${prefix}/bin/ld \
    80109                    --with-ar=${prefix}/bin/ar \
    81110                    --with-bugurl=https://trac.macports.org/newticket
    82111
     112if {${os.major} >= 13} {
     113    # use the system assembler by default; now that we use `as -q` that is the
     114    # only way that doesn't oblige users to install a port:clang-xy in addition
     115    # to port:gccN. This can change when the `as` command from port:cctools takes
     116    # a --clang argument to use a specific clang.
     117    configure.args-append \
     118                    --with-as=/usr/bin/as
     119    configure.env-append \
     120                    AS_FOR_TARGET=/usr/bin/as
     121} else {
     122    # older Xcode versions aren't compatible and oblige selecting a clang port
     123    # via the `port select clang` mechanism.
     124    pre-fetch {
     125        if {![file exists ${prefix}/bin/clang]} {
     126            ui_error "You need to run `port select --set clang mp-clang-${cdv}`"
     127            return -code error "port:${name} needs ${prefix}/bin/clang"
     128        }
     129    }
     130    depends_skip_archcheck-append llvm_select
     131    configure.args-append \
     132                    --with-as=${prefix}/bin/as
     133    configure.env-append \
     134                    AS_FOR_TARGET=${prefix}/bin/as
     135}
     136
    83137# see https://lists.macports.org/pipermail/macports-dev/2017-August/036209.html
    84138# --disable-tls does not limit functionality
    85139# it only determines how std::call_once works
    configure.args-append \ 
    88142
    89143configure.env-append \
    90144                    AR_FOR_TARGET=${prefix}/bin/ar \
    91                     AS_FOR_TARGET=${prefix}/bin/as \
    92145                    LD_FOR_TARGET=${prefix}/bin/ld \
    93146                    NM_FOR_TARGET=${prefix}/bin/nm \
    94147                    OBJDUMP_FOR_TARGET=${prefix}/bin/objdump \
    compiler.blacklist-append {clang < 300} 
    134187configure.cxx_stdlib
    135188
    136189build.dir           ${configure.dir}
    137 build.target        bootstrap-lean
    138190use_parallel_build  yes
    139191
    140192destroot.target     install install-info-host
    141193
    142 if {${subport} eq "libgcc"} {
     194# moved upwards from the "dylibs" variable in the port:libgcc post-destroot;
     195# these are the libraries that are potential dependencies for other ports
     196# and that are either installed by that port and not the
     197# main port, or by the main port and as symlinks by port:libgcc.
     198set standardLibs    {libgcc_ext.10.4.dylib libgcc_ext.10.5.dylib \
     199    libgcc_s.1.dylib libgfortran.4.dylib libquadmath.0.dylib \
     200    libstdc++.6.dylib libobjc-gnu.4.dylib libgomp.1.dylib \
     201    libitm.1.dylib libssp.0.dylib libasan.0.dylib libatomic.1.dylib}
     202
     203if {${subport} eq "${libgcc_port}"} {
     204
    143205    conflicts       libgcc-devel
     206    long_description-append \
     207                    This port installs the standard runtime libraries, including libstdc++. \
     208                    Users building from source can install port:${name}+with_libgcc \
     209                    and port:${subport}+stub to avoid building everything twice.
     210
     211    variant stub conflicts universal description "Don't touch, used automatically when the main port:${name} is installed +with_libgcc" {}
    144212
    145213    # http://trac.macports.org/ticket/35770
    146214    # http://trac.macports.org/ticket/38814
    if {${subport} eq "libgcc"} { 
    154222    # version should continue to provide a subport for that and older gcc
    155223    # versions.
    156224
    157     depends_lib-delete path:lib/libgcc/libgcc_s.1.dylib:libgcc
    158 
    159     configure.args-delete --libdir=${prefix}/lib/${name}
    160     configure.args-append --libdir=${prefix}/lib/libgcc
    161 
    162     # TODO: Possibly disable bootstrap with appropriate configure flags.
    163     #       the problem is that libstdc++'s configure script tests for tls support
    164     #       using the running compiler (not gcc for which libstdc++ is being built).
    165     #       Thus when we build with clang, we get a mismatch
    166     # http://trac.macports.org/ticket/36116
    167     #compiler.blacklist-append {clang < 425}
    168     #configure.args-append --disable-bootstrap
    169     #build.target        all
     225    if {![catch {set result [active_variants ${name} with_libgcc {}]}]} {
     226        if {${result}} {
     227            default_variants-append +stub
     228        }
     229    }
     230    if {[variant_isset stub]} {
     231        # reset the depspecs
     232        depends_lib
     233        require_active_variants ${name} with_libgcc
     234
     235        use_configure   no
     236        installs_libs   no
     237        supported_archs noarch
     238        fetch           {}
     239        extract         {}
     240        patch           {}
     241        build           {}
     242        destroot {
     243            # install something relevant into $prefix/lib/libgcc
     244            xinstall -m 755 -d ${destroot}${prefix}/lib/libgcc
     245            system "echo ${version} > ${destroot}${prefix}/lib/libgcc/libgcc_version.txt"
     246            # there should be no need to install anything related to headers
     247            # For binary compatibility with binaries that linked against the old libstdcxx port
     248            ln -s libgcc/libstdc++.6.dylib ${destroot}${prefix}/lib/libstdc++.6.dylib
     249        }
     250    } else {
     251        depends_lib-delete path:lib/libgcc/libgcc_s.1.dylib:libgcc
     252        require_active_variants ${name} "" with_libgcc
     253
     254        # port:libgcc builds the runtime libraries for installation in lib/libgcc
     255        configure.args-replace  --libdir=${prefix}/lib/gcc${ver3char} \
     256                                --libdir=${prefix}/lib/libgcc
     257
     258        # bootstrap-less building is a *lot* faster, see:
     259        # http://trac.macports.org/ticket/36116
     260        # and
     261        # https://trac.macports.org/changeset/103047
     262        if {${os.major} >= 12} {
     263            compiler.blacklist-append {clang < 425}
     264            configure.args-append --disable-bootstrap
     265            build.target        all
     266        } else {
     267            configure.cc_archflags
     268            configure.cxx_archflags
     269            configure.objc_archflags
     270            configure.ld_archflags
     271            configure.universal_cflags
     272            configure.universal_cxxflags
     273            configure.universal_ldflags
     274            configure.universal_args
     275            build.target        bootstrap-lean
     276        }
    170277
    171     post-destroot {
    172         file mkdir ${destroot}${prefix}/lib/libgcc.merged
     278        post-destroot {
     279            file mkdir ${destroot}${prefix}/lib/libgcc.merged
    173280
    174         # Note that we really don't want to include libgcc_ext.10.[45].dylib here, but install_name_tool
    175         # doesn't know how to change the id of stubs, and it's easier than recreating them for each
    176         # gcc port.
    177         set dylibs {libgcc_ext.10.4.dylib libgcc_ext.10.5.dylib libgcc_s.1.dylib libgfortran.4.dylib libquadmath.0.dylib libstdc++.6.dylib libobjc-gnu.4.dylib libgomp.1.dylib libitm.1.dylib libssp.0.dylib libasan.0.dylib libatomic.1.dylib}
     281            # Note that we really don't want to include libgcc_ext.10.[45].dylib here, but install_name_tool
     282            # doesn't know how to change the id of stubs, and it's easier than recreating them for each
     283            # gcc port.
    178284
    179         foreach dylib ${dylibs} {
    180             # Different OS versions (e.g. Leopard) or architectures (e.g. PPC) don't produce all the dylibs
    181             # https://trac.macports.org/ticket/40098
    182             # https://trac.macports.org/ticket/40100
    183             if {! [file exists ${destroot}${prefix}/lib/libgcc/${dylib}]} {
    184                 continue
    185             }
     285            foreach dylib ${standardLibs} {
     286                # Different OS versions (eg: Leopard) or architectures (eg: PPC) don't produce all the dylibs
     287                # https://trac.macports.org/ticket/40098
     288                # https://trac.macports.org/ticket/40100
     289                if {! [file exists ${destroot}${prefix}/lib/libgcc/${dylib}]} {
     290                    continue
     291                }
    186292
    187             move ${destroot}${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/libgcc.merged
    188             if {[variant_isset universal]} {
    189                 foreach archdir [glob ${destroot}${prefix}/lib/libgcc/*/] {
    190                     set archdir_nodestroot [string map "${destroot}/ /" ${archdir}]
    191                     if {[file exists ${archdir}/${dylib}]} {
    192                         system "install_name_tool -id ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}"
    193                         foreach link ${dylibs} {
    194                             system "install_name_tool -change ${archdir_nodestroot}${link} ${prefix}/lib/libgcc/${link} ${archdir}/${dylib}"
     293                move ${destroot}${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/libgcc.merged
     294                if {[variant_isset universal]} {
     295                    foreach archdir [glob ${destroot}${prefix}/lib/libgcc/*/] {
     296                        set archdir_nodestroot [string map "${destroot}/ /" ${archdir}]
     297                        if {[file exists ${archdir}/${dylib}]} {
     298                            system "install_name_tool -id ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}"
     299                            foreach link ${dylibs} {
     300                                system "install_name_tool -change ${archdir_nodestroot}${link} ${prefix}/lib/libgcc/${link} ${archdir}/${dylib}"
     301                            }
     302                            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}"
    195303                        }
    196                         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}"
    197304                    }
    198305                }
    199             }
    200306
    201             # strip debug symbols to supress debugger warnings:
    202             # http://trac.macports.org/attachment/ticket/34831
    203             if {! [string match *libgcc_ext* ${dylib}]} {
    204                 system "strip -x ${destroot}${prefix}/lib/libgcc.merged/${dylib}"
     307                if {${os.major} < 13} {
     308                    # strip debug symbols to suppress debugger warnings:
     309                    # http://trac.macports.org/attachment/ticket/34831
     310                    # This isn't required for lldb
     311                    if {! [string match *libgcc_ext* ${dylib}]} {
     312                        system "strip -x ${destroot}${prefix}/lib/libgcc.merged/${dylib}"
     313                    }
     314                }
    205315            }
    206         }
    207316
    208         file delete -force ${destroot}${prefix}/bin
    209         file delete -force ${destroot}${prefix}/share
    210         file delete -force ${destroot}${prefix}/include
    211         file delete -force ${destroot}${prefix}/lib/libgcc
    212         file delete -force ${destroot}${prefix}/libexec
     317            file delete -force ${destroot}${prefix}/bin
     318            file delete -force ${destroot}${prefix}/share
     319            file delete -force ${destroot}${prefix}/lib/libgcc
     320            file delete -force ${destroot}${prefix}/libexec
    213321
    214         move ${destroot}${prefix}/lib/libgcc.merged ${destroot}${prefix}/lib/libgcc
     322            move ${destroot}${prefix}/lib/libgcc.merged ${destroot}${prefix}/lib/libgcc
    215323
    216         # For binary compatibility with binaries that linked against the old libstdcxx port
    217         ln -s libgcc/libstdc++.6.dylib ${destroot}${prefix}/lib/libstdc++.6.dylib
     324            # For binary compatibility with binaries that linked against the old libstdcxx port
     325            ln -s libgcc/libstdc++.6.dylib ${destroot}${prefix}/lib/libstdc++.6.dylib
     326        }
    218327    }
     328
     329} else {
     330### Main port
     331
     332variant with_libgcc conflicts universal description "Include the standard libraries instead of getting them from port:libgcc. For if you install from source." {}
     333# the quick variant simplifies gcc patch development but also decreases the build time by a factor > 4
     334variant quick description "Build ${name} without the usual 3-stage bootstrap.\
     335    Probably safest with configure.compiler=macports-gcc-${major} but not when that compiler uses libc++!" {}
     336
     337depends_run-append          port:gcc_select
     338
     339if {${os.major} >= 13} {
     340    # OS X 10.9 and up support the system clang toolchain from Xcode and
     341    # MacPorts clang compilers (starting arbitrarily at 3.9) for building
     342    # against the libc++ runtime instead of libstdc++. A feature under
     343    # testing which hopefully can be included into GCC one day under control
     344    # of a -stdlib=libc++ compiler argument.
     345    # Even when that happens it will use a hardcoded clang version determined
     346    # during the GCC build, i.e. these variants will remain.
     347    set libcxx_versions     {{} 3.9 4.0 5.0}
    219348} else {
    220 depends_run-append         port:gcc_select
     349    # don't support the system clang toolchain before OS X 10.9
     350    set libcxx_versions     {3.9 4.0 5.0}
     351}
     352
     353foreach cdv ${libcxx_versions} {
     354    set cv [join [split ${cdv} "."] ""]
     355    if {${cdv} eq {}} {
     356        variant libcxx description "Build to use libc++ and the corresponding headers from Xcode (experimental for Xcode <= 6)" {}
     357    } else {
     358        variant libcxx${cv} description "Build to use libc++ and the corresponding headers from port:clang-${cdv}" {}
     359    }
     360    if {[variant_isset libcxx${cv}]} {
     361        if {${cdv} ne {}} {
     362            depends_run-append  port:clang-${cdv}
     363            set libcxx_headers  "${prefix}/libexec/llvm-${cdv}/include/c++/v1"
     364            set clang_mp        "${prefix}/bin/clang-mp-${cdv}"
     365            if {${os.major} >= 13} {
     366                pre-fetch {
     367                    if {![file exists ${prefix}/bin/clang]} {
     368                        ui_error "You need to run `port select --set clang mp-clang-${cdv}`"
     369                        return -code error "port:${name} needs ${prefix}/bin/clang"
     370                    }
     371                }
     372                depends_skip_archcheck-append llvm_select
     373                # we need a clang installation anyway, use it for the compiler too
     374                # (if the user used port select to that extent).
     375                configure.args-replace \
     376                                --with-as=/usr/bin/as \
     377                                --with-as=${prefix}/bin/as
     378                configure.env-replace \
     379                                AS_FOR_TARGET=/usr/bin/as \
     380                                AS_FOR_TARGET=${prefix}/bin/as
     381            }
     382        } else {
     383            set libcxx_headers  "[file dir [exec xcrun --find clang]]/../include/c++/v1"
     384            set clang_mp        "[exec xcrun --find clang]"
     385        }
     386        patchfiles-append   patch-use-libcxx.diff
     387        post-patch {
     388            reinplace "s|@LLVMHEADERPATH@|${libcxx_headers}|g" ${worksrcpath}/gcc/incpath.c
     389#             # this will apply when as -q takes a --clang argument.
     390#             reinplace "s|@CLANG@|${clang_mp}|g" ${worksrcpath}/gcc/config/darwin.h
     391        }
     392
     393        # the reason for the change proposed in https://lists.macports.org/pipermail/macports-dev/2017-August/036209.html
     394        # is moot when using libc++ ; reenable TLS
     395        configure.args-delete   --disable-tls
     396
     397        # GCC_IS_BUILDING_ITSELF: causes g++ to add a static libstdc++ just like it does when building with/for libstdc++
     398        # GCC_FORCE_LIBSTDCPP: forces the use of libstdc++ for the current build and ignores the default clang C++ header location
     399        # LIBCPP_INCLUDE_PATH: redefines the location of the clang C++ headers; empty means don't use them at all
     400        # The combination below means: build GCC "as usual" itself
     401        configure.env-append    GCC_IS_BUILDING_ITSELF=1 GCC_FORCE_LIBSTDCPP=1
     402        build.env-append        GCC_IS_BUILDING_ITSELF=1 GCC_FORCE_LIBSTDCPP=1
     403        destroot.env-append     GCC_IS_BUILDING_ITSELF=1 GCC_FORCE_LIBSTDCPP=1
     404    }
     405}
     406# post-patch {
     407#     # use the system clang as assembler if no libcxx variant is set
     408#     # and `as -q` accepts a --clang argument.
     409#     set clang_mp "[exec xcrun --find clang]"
     410#     reinplace "s|@CLANG@|${clang_mp}|g" ${worksrcpath}/gcc/config/darwin.h
     411# }
    221412
    222413post-destroot {
    223414    file delete ${destroot}${prefix}/share/info/dir
    post-destroot { 
    229420        file rename ${file} ${newfile}
    230421    }
    231422
    232     foreach dylib {libgcc_ext.10.4.dylib libgcc_ext.10.5.dylib libgcc_s.1.dylib libgfortran.4.dylib libquadmath.0.dylib libstdc++.6.dylib libobjc-gnu.4.dylib libgomp.1.dylib libitm.1.dylib libssp.0.dylib libasan.0.dylib libatomic.1.dylib} {
    233         # Different OS versions (e.g. Leopard) or architectures (e.g. PPC) don't produce all the dylibs
    234         # https://trac.macports.org/ticket/40098
    235         # https://trac.macports.org/ticket/40100
    236         if {[file exists ${destroot}${prefix}/lib/${name}/${dylib}]} {
    237             delete ${destroot}${prefix}/lib/${name}/${dylib}
    238             ln -s ${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/${name}/${dylib}
     423    if {![variant_isset with_libgcc]} {
     424        foreach dylib ${standardLibs} {
     425            # Different OS versions (e.g. Leopard) or architectures (e.g. PPC) don't produce all the dylibs
     426            # https://trac.macports.org/ticket/40098
     427            # https://trac.macports.org/ticket/40100
     428            if {[file exists ${destroot}${prefix}/lib/${name}/${dylib}]} {
     429                delete ${destroot}${prefix}/lib/${name}/${dylib}
     430                ln -s ${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/${name}/${dylib}
     431            }
     432
     433            if {[variant_isset universal]} {
     434                foreach archdir [glob ${destroot}${prefix}/lib/${name}/*/] {
     435                    if {[file exists ${archdir}/${dylib}]} {
     436                        delete ${archdir}/${dylib}
     437                        ln -s ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}
     438                    }
     439                }
     440            }
    239441        }
     442        # The C++ headerfiles are installed by port:libgcc too
     443        delete -force ${destroot}${gcc_headerdir}/c++
     444    } else {
     445        file mkdir ${destroot}${prefix}/lib/libgcc
     446        foreach dylib ${standardLibs} {
     447            # This is a modified "inversed" version of what port:libgcc does when not in stub mode
     448            # the difference is that here we're moving the ${standardLibs} from lib/gcc${ver3char} ($prefix/lib/gcc7)
     449            # into the unversioned $prefix/lib/libgcc and need to adapt their ID and link info accordingly.
     450            if {! [file exists ${destroot}${prefix}/lib/gcc${ver3char}/${dylib}]} {
     451                continue
     452            }
     453
     454            move ${destroot}${prefix}/lib/gcc${ver3char}/${dylib} ${destroot}${prefix}/lib/libgcc
     455            # put an appropriate symlink in the versioned location
     456            ln -s ${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/gcc${ver3char}/${dylib}
    240457
    241         if {[variant_isset universal]} {
    242             foreach archdir [glob ${destroot}${prefix}/lib/${name}/*/] {
    243                 if {[file exists ${archdir}/${dylib}]} {
    244                     delete ${archdir}/${dylib}
    245                     ln -s ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}
     458            # update ${dylib}'s ID and all of its dependents to match the new location
     459            if {[variant_isset universal]} {
     460                # this case is untested and should never be executed because of the with_libgcc/universal conflict
     461                # Keeping it around for the "just in case".
     462                foreach archdir [glob ${destroot}${prefix}/lib/gcc${ver3char}/*/] {
     463                    set archdir_nodestroot [string map "${destroot}/ /" ${archdir}]
     464                    if {[file exists ${archdir}/${dylib}]} {
     465                        system "install_name_tool -id ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}"
     466                        foreach link ${dylibs} {
     467                            system "install_name_tool -change ${archdir_nodestroot}${link} ${prefix}/lib/libgcc/${link} ${archdir}/${dylib}"
     468                        }
     469                        system "lipo -create -output ${destroot}${prefix}/lib/libgcc/${dylib}~ ${destroot}${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib} && mv ${destroot}${prefix}/lib/libgcc/${dylib}~ ${destroot}${prefix}/lib/libgcc/${dylib}"
     470                    }
     471                }
     472            } else {
     473                if {[string match *libgcc_ext* ${dylib}]} {
     474                    # libgcc_ext is a stub library which install_name_tool cannot handle.
     475                    # Instead, we do a binary-file search-and-replace, which is possible before the
     476                    # original and desired target rpaths have the same length.
     477                    system "/usr/bin/ex -b +:1s,${prefix}/lib/gcc${ver3char}/libgcc_s.1.dylib,${prefix}/lib/libgcc/libgcc_s.1.dylib,g +:wq ${destroot}${prefix}/lib/libgcc/${dylib}"
     478                } else {
     479                    system "install_name_tool -id ${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/libgcc/${dylib}"
     480                    foreach dep [glob ${destroot}${prefix}/lib/gcc${ver3char}/*.dylib ${destroot}${prefix}/lib/libgcc/*.dylib] {
     481                        if {[file type ${dep}] eq "file" && ![string match *libgcc_ext* ${dep}]} {
     482                            # ${dylib} has been moved, so update all of its dependents
     483                            set old ${prefix}/lib/gcc${ver3char}/${dylib}
     484                            set new ${prefix}/lib/libgcc/${dylib}
     485                            system "install_name_tool -change ${old} ${new} ${dep}"
     486                        }
     487                    }
    246488                }
    247489            }
     490
     491            if {${os.major} < 13} {
     492                # strip debug symbols to suppress debugger warnings:
     493                # http://trac.macports.org/attachment/ticket/34831
     494                if {! [string match *libgcc_ext* ${dylib}]} {
     495                    system "strip -x ${destroot}${prefix}/lib/libgcc/${dylib}"
     496                }
     497            }
     498        }
     499    }
     500    foreach cdv ${libcxx_versions} {
     501        set cv [join [split ${cdv} "."] ""]
     502        if {[variant_isset libcxx${cv}] && [file exists ${destroot}${gcc_headerdir}/c++]} {
     503            # move the stdc++ headers out of the way because g++ shouldn't find them.
     504            # FIXME: needs to go when gcc supports -stdlib=libc++ !
     505            xinstall -m 755 -d ${destroot}${prefix}/include/${name}-stdinc
     506            file rename ${destroot}${gcc_headerdir}/c++ ${destroot}${prefix}/include/${name}-stdinc/c++
    248507        }
    249508    }
     509
     510    # make the library directory available via the old path too, in case anyone expects it there.
     511    ln -s gcc${ver3char} ${destroot}${prefix}/lib/${name}
     512
    250513}
    251514
    252515select.group        gcc
    253516select.file         ${filespath}/mp-${name}
    254517
     518if {[variant_exists quick] && [variant_isset quick]} {
     519    # quick (and hopefully not too dirty) build: don't bootstrap
     520    # and leave the configure environment mostly intact.
     521    configure.args-replace \
     522                    --with-build-config=bootstrap-debug \
     523                    --disable-bootstrap
     524} else {
     525    configure.cc_archflags
     526    configure.cxx_archflags
     527    configure.objc_archflags
     528    configure.ld_archflags
     529    configure.universal_cflags
     530    configure.universal_cxxflags
     531    configure.universal_ldflags
     532    configure.universal_args
     533    build.target    bootstrap-lean
     534}
     535
     536### End main port
    255537}
    256538
    257539platform powerpc {
    variant universal { 
    265547}
    266548# the generated compiler doesn't accept -arch
    267549configure.env-append \
    268     CPP="${configure.cc} -E" \
    269     CXXCPP="${configure.cxx} -E"
    270 build.env-append \
    271     CPP="${configure.cc} -E" \
    272     CXXCPP="${configure.cxx} -E"
     550                    CPP="${configure.cc} -E" \
     551                    CXXCPP="${configure.cxx} -E"
     552build.env-append    CPP="${configure.cc} -E" \
     553                    CXXCPP="${configure.cxx} -E"
     554
    273555configure.cc-append [get_canonical_archflags]
    274 configure.cc_archflags
    275556configure.cxx-append ${configure.cxx_archflags}
    276 configure.cxx_archflags
    277 configure.objc_archflags
    278 configure.ld_archflags
    279 configure.universal_cflags
    280 configure.universal_cxxflags
    281 configure.universal_ldflags
    282 configure.universal_args
    283557
    284558livecheck.type      regex
    285559livecheck.url       http://ftp.gnu.org/gnu/gcc/