diff --git a/lang/gcc7/Portfile b/lang/gcc7/Portfile
index e8d81c7..1a3707e 100644
--- a/lang/gcc7/Portfile
+++ b/lang/gcc7/Portfile
@@ -3,13 +3,27 @@
 PortSystem 1.0
 PortGroup select 1.0
 PortGroup compiler_blacklist_versions 1.0
+PortGroup active_variants 1.1
 
 name                gcc7
-subport             libgcc {}
+
+# are we the port that currently provides libgcc?
+set provides_libgcc 1
 
 epoch               2
 version             7.2.0
 
+set major           [lindex [split ${version} .-] 0]
+set ver3char        [join [split ${version} '.'] ""]
+
+if {${provides_libgcc}} {
+    set libgcc_port libgcc
+} else {
+    set libgcc_port libgcc${major}
+}
+
+subport             ${libgcc_port} {}
+
 platforms           darwin
 categories          lang
 maintainers         nomaintainer
@@ -32,6 +46,8 @@ use_xz              yes
 checksums           rmd160  fa8eed36c78cf135f9cc88e60845996b5cfaba52 \
                     sha256  1cf7adf8ff4b5aa49041c8734bbcf1ad18cc4c94d0029aae0f4e48841088479a
 
+installs_libs       yes
+
 depends_lib         port:cctools \
                     port:gmp \
                     path:lib/pkgconfig/isl.pc:isl \
@@ -44,20 +60,34 @@ depends_lib         port:cctools \
 depends_skip_archcheck-append gcc_select ld64 cctools
 license_noconflict  gmp mpfr ppl libmpc
 
-set major           [lindex [split ${version} .-] 0]
-
 platform darwin {
     configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
 
     # see https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00672.html
-    patchfiles-append         patch-float128.diff
+    patchfiles-append patch-float128.diff
+    # cause `as` to be invoked with the -q option so that it
+    # invokes the clang integrated assembler (instead of the obsolete GNU as)
+    # `man as` claims that this is the default but clearly that is not true everywhere.
+    patchfiles-append patch-default-clang-assembler.diff
 }
 
 configure.dir       ${workpath}/build
 configure.cmd       ${worksrcpath}/configure
+
+# where to install the headers, should be unversioned for the GCC version that
+# provides port:libgcc and versioned for all other ports
+if {${provides_libgcc}} {
+    set gcc_headerdir ${prefix}/include/gcc
+} else {
+    set gcc_headerdir ${prefix}/include/${name}
+}
+
+# the runtime libraries are built for installation to lib/gcc${ver3char} (e.g. lib/gcc720)
+# but will ultimately still be installed into lib/libgcc .
+# The change is only because lib/libgcc and lib/gcc720 have the same length.
 configure.args      --enable-languages=c,c++,objc,obj-c++,lto,fortran \
-                    --libdir=${prefix}/lib/${name} \
-                    --includedir=${prefix}/include/${name} \
+                    --libdir=${prefix}/lib/gcc${ver3char} \
+                    --includedir=${gcc_headerdir} \
                     --infodir=${prefix}/share/info \
                     --mandir=${prefix}/share/man \
                     --datarootdir=${prefix}/share/gcc-${major} \
@@ -65,7 +95,7 @@ configure.args      --enable-languages=c,c++,objc,obj-c++,lto,fortran \
                     --with-system-zlib \
                     --disable-nls \
                     --program-suffix=-mp-${major} \
-                    --with-gxx-include-dir=${prefix}/include/${name}/c++/ \
+                    --with-gxx-include-dir=${gcc_headerdir}/c++/ \
                     --with-gmp=${prefix} \
                     --with-mpfr=${prefix} \
                     --with-mpc=${prefix} \
@@ -75,11 +105,35 @@ configure.args      --enable-languages=c,c++,objc,obj-c++,lto,fortran \
                     --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
 
+if {${os.major} >= 13} {
+    # use the system assembler by default; now that we use `as -q` that is the
+    # only way that doesn't oblige users to install a port:clang-xy in addition
+    # to port:gccN. This can change when the `as` command from port:cctools takes
+    # a --clang argument to use a specific clang.
+    configure.args-append \
+                    --with-as=/usr/bin/as
+    configure.env-append \
+                    AS_FOR_TARGET=/usr/bin/as
+} else {
+    # older Xcode versions aren't compatible and oblige selecting a clang port
+    # via the `port select clang` mechanism.
+    pre-fetch {
+        if {![file exists ${prefix}/bin/clang]} {
+            ui_error "You need to run `port select --set clang mp-clang-${cdv}`"
+            return -code error "port:${name} needs ${prefix}/bin/clang"
+        }
+    }
+    depends_skip_archcheck-append llvm_select
+    configure.args-append \
+                    --with-as=${prefix}/bin/as
+    configure.env-append \
+                    AS_FOR_TARGET=${prefix}/bin/as
+}
+
 # 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
@@ -88,7 +142,6 @@ configure.args-append \
 
 configure.env-append \
                     AR_FOR_TARGET=${prefix}/bin/ar \
-                    AS_FOR_TARGET=${prefix}/bin/as \
                     LD_FOR_TARGET=${prefix}/bin/ld \
                     NM_FOR_TARGET=${prefix}/bin/nm \
                     OBJDUMP_FOR_TARGET=${prefix}/bin/objdump \
@@ -134,13 +187,28 @@ compiler.blacklist-append {clang < 300}
 configure.cxx_stdlib
 
 build.dir           ${configure.dir}
-build.target        bootstrap-lean
 use_parallel_build  yes
 
 destroot.target     install install-info-host
 
-if {${subport} eq "libgcc"} {
+# moved upwards from the "dylibs" variable in the port:libgcc post-destroot;
+# these are the libraries that are potential dependencies for other ports
+# and that are either installed by that port and not the
+# main port, or by the main port and as symlinks by port:libgcc.
+set standardLibs    {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}
+
+if {${subport} eq "${libgcc_port}"} {
+
     conflicts       libgcc-devel
+    long_description-append \
+                    This port installs the standard runtime libraries, including libstdc++. \
+                    Users building from source can install port:${name}+with_libgcc \
+                    and port:${subport}+stub to avoid building everything twice.
+
+    variant stub conflicts universal description "Don't touch, used automatically when the main port:${name} is installed +with_libgcc" {}
 
     # http://trac.macports.org/ticket/35770
     # http://trac.macports.org/ticket/38814
@@ -154,70 +222,193 @@ if {${subport} eq "libgcc"} {
     # version should continue to provide a subport for that and older gcc
     # versions.
 
-    depends_lib-delete path:lib/libgcc/libgcc_s.1.dylib:libgcc
-
-    configure.args-delete --libdir=${prefix}/lib/${name}
-    configure.args-append --libdir=${prefix}/lib/libgcc
-
-    # TODO: Possibly disable bootstrap with appropriate configure flags.
-    #       the problem is that libstdc++'s configure script tests for tls support
-    #       using the running compiler (not gcc for which libstdc++ is being built).
-    #       Thus when we build with clang, we get a mismatch
-    # http://trac.macports.org/ticket/36116
-    #compiler.blacklist-append {clang < 425}
-    #configure.args-append --disable-bootstrap
-    #build.target        all
+    if {![catch {set result [active_variants ${name} with_libgcc {}]}]} {
+        if {${result}} {
+            default_variants-append +stub
+        }
+    }
+    if {[variant_isset stub]} {
+        # reset the depspecs
+        depends_lib
+        require_active_variants ${name} with_libgcc
+
+        use_configure   no
+        installs_libs   no
+        supported_archs noarch
+        fetch           {}
+        extract         {}
+        patch           {}
+        build           {}
+        destroot {
+            # install something relevant into $prefix/lib/libgcc
+            xinstall -m 755 -d ${destroot}${prefix}/lib/libgcc
+            system "echo ${version} > ${destroot}${prefix}/lib/libgcc/libgcc_version.txt"
+            # there should be no need to install anything related to headers
+            # For binary compatibility with binaries that linked against the old libstdcxx port
+            ln -s libgcc/libstdc++.6.dylib ${destroot}${prefix}/lib/libstdc++.6.dylib
+        }
+    } else {
+        depends_lib-delete path:lib/libgcc/libgcc_s.1.dylib:libgcc
+        require_active_variants ${name} "" with_libgcc
+
+        # port:libgcc builds the runtime libraries for installation in lib/libgcc
+        configure.args-replace  --libdir=${prefix}/lib/gcc${ver3char} \
+                                --libdir=${prefix}/lib/libgcc
+
+        # bootstrap-less building is a *lot* faster, see:
+        # http://trac.macports.org/ticket/36116
+        # and
+        # https://trac.macports.org/changeset/103047
+        if {${os.major} >= 12} {
+            compiler.blacklist-append {clang < 425}
+            configure.args-append --disable-bootstrap
+            build.target        all
+        } else {
+            configure.cc_archflags
+            configure.cxx_archflags
+            configure.objc_archflags
+            configure.ld_archflags
+            configure.universal_cflags
+            configure.universal_cxxflags
+            configure.universal_ldflags
+            configure.universal_args
+            build.target        bootstrap-lean
+        }
 
-    post-destroot {
-        file mkdir ${destroot}${prefix}/lib/libgcc.merged
+        post-destroot {
+            file mkdir ${destroot}${prefix}/lib/libgcc.merged
 
-        # 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 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}
+            # 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.
 
-        foreach dylib ${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
-            }
+            foreach dylib ${standardLibs} {
+                # Different OS versions (eg: Leopard) or architectures (eg: 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 ${destroot}${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/libgcc.merged
-            if {[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 ${dylibs} {
-                            system "install_name_tool -change ${archdir_nodestroot}${link} ${prefix}/lib/libgcc/${link} ${archdir}/${dylib}"
+                move ${destroot}${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/libgcc.merged
+                if {[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 ${dylibs} {
+                                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}"
                         }
-                        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}"
+                if {${os.major} < 13} {
+                    # strip debug symbols to suppress debugger warnings:
+                    # http://trac.macports.org/attachment/ticket/34831
+                    # This isn't required for lldb
+                    if {! [string match *libgcc_ext* ${dylib}]} {
+                        system "strip -x ${destroot}${prefix}/lib/libgcc.merged/${dylib}"
+                    }
+                }
             }
-        }
 
-        file delete -force ${destroot}${prefix}/bin
-        file delete -force ${destroot}${prefix}/share
-        file delete -force ${destroot}${prefix}/include
-        file delete -force ${destroot}${prefix}/lib/libgcc
-        file delete -force ${destroot}${prefix}/libexec
+            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 ${destroot}${prefix}/lib/libgcc.merged ${destroot}${prefix}/lib/libgcc
+            move ${destroot}${prefix}/lib/libgcc.merged ${destroot}${prefix}/lib/libgcc
 
-        # For binary compatibility with binaries that linked against the old libstdcxx port
-        ln -s libgcc/libstdc++.6.dylib ${destroot}${prefix}/lib/libstdc++.6.dylib
+            # For binary compatibility with binaries that linked against the old libstdcxx port
+            ln -s libgcc/libstdc++.6.dylib ${destroot}${prefix}/lib/libstdc++.6.dylib
+        }
     }
+
+} else {
+### Main port
+
+variant with_libgcc conflicts universal description "Include the standard libraries instead of getting them from port:libgcc. For if you install from source." {}
+# the quick variant simplifies gcc patch development but also decreases the build time by a factor > 4
+variant quick description "Build ${name} without the usual 3-stage bootstrap.\
+    Probably safest with configure.compiler=macports-gcc-${major} but not when that compiler uses libc++!" {}
+
+depends_run-append          port:gcc_select
+
+if {${os.major} >= 13} {
+    # OS X 10.9 and up support the system clang toolchain from Xcode and
+    # MacPorts clang compilers (starting arbitrarily at 3.9) for building
+    # against the libc++ runtime instead of libstdc++. A feature under
+    # testing which hopefully can be included into GCC one day under control
+    # of a -stdlib=libc++ compiler argument.
+    # Even when that happens it will use a hardcoded clang version determined
+    # during the GCC build, i.e. these variants will remain.
+    set libcxx_versions     {{} 3.9 4.0 5.0}
 } else {
-depends_run-append         port:gcc_select
+    # don't support the system clang toolchain before OS X 10.9
+    set libcxx_versions     {3.9 4.0 5.0}
+}
+
+foreach cdv ${libcxx_versions} {
+    set cv [join [split ${cdv} "."] ""]
+    if {${cdv} eq {}} {
+        variant libcxx description "Build to use libc++ and the corresponding headers from Xcode (experimental for Xcode <= 6)" {}
+    } else {
+        variant libcxx${cv} description "Build to use libc++ and the corresponding headers from port:clang-${cdv}" {}
+    }
+    if {[variant_isset libcxx${cv}]} {
+        if {${cdv} ne {}} {
+            depends_run-append  port:clang-${cdv}
+            set libcxx_headers  "${prefix}/libexec/llvm-${cdv}/include/c++/v1"
+            set clang_mp        "${prefix}/bin/clang-mp-${cdv}"
+            if {${os.major} >= 13} {
+                pre-fetch {
+                    if {![file exists ${prefix}/bin/clang]} {
+                        ui_error "You need to run `port select --set clang mp-clang-${cdv}`"
+                        return -code error "port:${name} needs ${prefix}/bin/clang"
+                    }
+                }
+                depends_skip_archcheck-append llvm_select
+                # we need a clang installation anyway, use it for the compiler too
+                # (if the user used port select to that extent).
+                configure.args-replace \
+                                --with-as=/usr/bin/as \
+                                --with-as=${prefix}/bin/as
+                configure.env-replace \
+                                AS_FOR_TARGET=/usr/bin/as \
+                                AS_FOR_TARGET=${prefix}/bin/as
+            }
+        } else {
+            set libcxx_headers  "[file dir [exec xcrun --find clang]]/../include/c++/v1"
+            set clang_mp        "[exec xcrun --find clang]"
+        }
+        patchfiles-append   patch-use-libcxx.diff
+        post-patch {
+            reinplace "s|@LLVMHEADERPATH@|${libcxx_headers}|g" ${worksrcpath}/gcc/incpath.c
+#             # this will apply when as -q takes a --clang argument.
+#             reinplace "s|@CLANG@|${clang_mp}|g" ${worksrcpath}/gcc/config/darwin.h
+        }
+
+        # the reason for the change proposed in https://lists.macports.org/pipermail/macports-dev/2017-August/036209.html
+        # is moot when using libc++ ; reenable TLS
+        configure.args-delete   --disable-tls
+
+        # GCC_IS_BUILDING_ITSELF: causes g++ to add a static libstdc++ just like it does when building with/for libstdc++
+        # GCC_FORCE_LIBSTDCPP: forces the use of libstdc++ for the current build and ignores the default clang C++ header location
+        # LIBCPP_INCLUDE_PATH: redefines the location of the clang C++ headers; empty means don't use them at all
+        # The combination below means: build GCC "as usual" itself
+        configure.env-append    GCC_IS_BUILDING_ITSELF=1 GCC_FORCE_LIBSTDCPP=1
+        build.env-append        GCC_IS_BUILDING_ITSELF=1 GCC_FORCE_LIBSTDCPP=1
+        destroot.env-append     GCC_IS_BUILDING_ITSELF=1 GCC_FORCE_LIBSTDCPP=1
+    }
+}
+# post-patch {
+#     # use the system clang as assembler if no libcxx variant is set
+#     # and `as -q` accepts a --clang argument.
+#     set clang_mp "[exec xcrun --find clang]"
+#     reinplace "s|@CLANG@|${clang_mp}|g" ${worksrcpath}/gcc/config/darwin.h
+# }
 
 post-destroot {
     file delete ${destroot}${prefix}/share/info/dir
@@ -229,29 +420,120 @@ post-destroot {
         file rename ${file} ${newfile}
     }
 
-    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} {
-        # 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_isset with_libgcc]} {
+        foreach dylib ${standardLibs} {
+            # 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_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}
+                    }
+                }
+            }
         }
+        # The C++ headerfiles are installed by port:libgcc too
+        delete -force ${destroot}${gcc_headerdir}/c++
+    } else {
+        file mkdir ${destroot}${prefix}/lib/libgcc
+        foreach dylib ${standardLibs} {
+            # This is a modified "inversed" version of what port:libgcc does when not in stub mode
+            # the difference is that here we're moving the ${standardLibs} from lib/gcc${ver3char} ($prefix/lib/gcc7)
+            # into the unversioned $prefix/lib/libgcc and need to adapt their ID and link info accordingly.
+            if {! [file exists ${destroot}${prefix}/lib/gcc${ver3char}/${dylib}]} {
+                continue
+            }
+
+            move ${destroot}${prefix}/lib/gcc${ver3char}/${dylib} ${destroot}${prefix}/lib/libgcc
+            # put an appropriate symlink in the versioned location
+            ln -s ${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/gcc${ver3char}/${dylib}
 
-        if {[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}
+            # update ${dylib}'s ID and all of its dependents to match the new location
+            if {[variant_isset universal]} {
+                # this case is untested and should never be executed because of the with_libgcc/universal conflict
+                # Keeping it around for the "just in case".
+                foreach archdir [glob ${destroot}${prefix}/lib/gcc${ver3char}/*/] {
+                    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 ${dylibs} {
+                            system "install_name_tool -change ${archdir_nodestroot}${link} ${prefix}/lib/libgcc/${link} ${archdir}/${dylib}"
+                        }
+                        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}"
+                    }
+                }
+            } else {
+                if {[string match *libgcc_ext* ${dylib}]} {
+                    # libgcc_ext is a stub library which install_name_tool cannot handle.
+                    # Instead, we do a binary-file search-and-replace, which is possible before the
+                    # original and desired target rpaths have the same length.
+                    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}"
+                } else {
+                    system "install_name_tool -id ${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/libgcc/${dylib}"
+                    foreach dep [glob ${destroot}${prefix}/lib/gcc${ver3char}/*.dylib ${destroot}${prefix}/lib/libgcc/*.dylib] {
+                        if {[file type ${dep}] eq "file" && ![string match *libgcc_ext* ${dep}]} { 
+                            # ${dylib} has been moved, so update all of its dependents
+                            set old ${prefix}/lib/gcc${ver3char}/${dylib}
+                            set new ${prefix}/lib/libgcc/${dylib}
+                            system "install_name_tool -change ${old} ${new} ${dep}"
+                        }
+                    }
                 }
             }
+
+            if {${os.major} < 13} {
+                # strip debug symbols to suppress debugger warnings:
+                # http://trac.macports.org/attachment/ticket/34831
+                if {! [string match *libgcc_ext* ${dylib}]} {
+                    system "strip -x ${destroot}${prefix}/lib/libgcc/${dylib}"
+                }
+            }
+        }
+    }
+    foreach cdv ${libcxx_versions} {
+        set cv [join [split ${cdv} "."] ""]
+        if {[variant_isset libcxx${cv}] && [file exists ${destroot}${gcc_headerdir}/c++]} {
+            # move the stdc++ headers out of the way because g++ shouldn't find them.
+            # FIXME: needs to go when gcc supports -stdlib=libc++ !
+            xinstall -m 755 -d ${destroot}${prefix}/include/${name}-stdinc
+            file rename ${destroot}${gcc_headerdir}/c++ ${destroot}${prefix}/include/${name}-stdinc/c++
         }
     }
+
+    # make the library directory available via the old path too, in case anyone expects it there.
+    ln -s gcc${ver3char} ${destroot}${prefix}/lib/${name}
+
 }
 
 select.group        gcc
 select.file         ${filespath}/mp-${name}
 
+if {[variant_exists quick] && [variant_isset quick]} {
+    # quick (and hopefully not too dirty) build: don't bootstrap
+    # and leave the configure environment mostly intact.
+    configure.args-replace \
+                    --with-build-config=bootstrap-debug \
+                    --disable-bootstrap
+} else {
+    configure.cc_archflags
+    configure.cxx_archflags
+    configure.objc_archflags
+    configure.ld_archflags
+    configure.universal_cflags
+    configure.universal_cxxflags
+    configure.universal_ldflags
+    configure.universal_args
+    build.target    bootstrap-lean
+}
+
+### End main port
 }
 
 platform powerpc {
@@ -265,21 +547,13 @@ variant universal {
 }
 # the generated compiler doesn't accept -arch
 configure.env-append \
-    CPP="${configure.cc} -E" \
-    CXXCPP="${configure.cxx} -E"
-build.env-append \
-    CPP="${configure.cc} -E" \
-    CXXCPP="${configure.cxx} -E"
+                    CPP="${configure.cc} -E" \
+                    CXXCPP="${configure.cxx} -E"
+build.env-append    CPP="${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       http://ftp.gnu.org/gnu/gcc/
