diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index 2dc3ca61a41..33fd9a52472 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -82,7 +82,7 @@ for block in diff_blocks: if content: with open(file_path, 'w') as file: file.writelines(content) - path = 'html/' + doc + path = doc hunks = ' '.join(f'#{i + 1}' for i in range(count)) out_blocks.append(f'

{doc} ' + hunks + ' 

' + '\n
'
diff --git a/.ci/retrofit-worktree.sh b/.ci/retrofit-worktree.sh
index b9c880a839f..5dcb6e2b88f 100755
--- a/.ci/retrofit-worktree.sh
+++ b/.ci/retrofit-worktree.sh
@@ -12,11 +12,13 @@ export GIT_AUTHOR_EMAIL="ci-sage@example.com"
 export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
 export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
 
+set -e
+
 # Set globally for other parts of the workflow
 git config --global user.name "$GIT_AUTHOR_NAME"
 git config --global user.email "$GIT_AUTHOR_EMAIL"
 
-set -ex
+set -x
 
 # If actions/checkout downloaded our source tree using the GitHub REST API
 # instead of with git (because do not have git installed in our image),
@@ -36,6 +38,10 @@ git tag -f new
 # The changed files now show up as uncommitted changes.
 # The final "git add -N" makes sure that files that were added in "new" do not show
 # as untracked files, which would be removed by "git clean -fx".
+if [ -L $WORKTREE_NAME ]; then
+    rm -f $WORKTREE_NAME
+    git worktree prune --verbose
+fi
 git worktree add --detach $WORKTREE_NAME
 rm -rf $WORKTREE_DIRECTORY/.git && mv $WORKTREE_NAME/.git $WORKTREE_DIRECTORY/
 rm -rf $WORKTREE_NAME && ln -s $WORKTREE_DIRECTORY $WORKTREE_NAME
diff --git a/.ci/write-dockerfile.sh b/.ci/write-dockerfile.sh
index 0aa53414553..578680d76f2 100755
--- a/.ci/write-dockerfile.sh
+++ b/.ci/write-dockerfile.sh
@@ -1,20 +1,41 @@
 #! /usr/bin/env bash
-## Write a Dockerfile to stdout that tests that the packages listed in the debian.txt/fedora.txt files of standard spkg exist
-## and satisfy the requirements tested by spkg-configure.m4
-## This is called by $SAGE_ROOT/tox.ini
 set -e
-SYSTEM="${1:-debian}"
 shopt -s extglob
+##
+## Write a Dockerfile for portability testing to stdout.
+##
+## This script needs to be run from SAGE_ROOT (root of the Sage repository).
+## It is called by $SAGE_ROOT/tox.ini for all environments 'tox -e docker-...'
+##
+## Positional arguments:
+##
+SYSTEM="${1:-debian}"
 SAGE_PACKAGE_LIST_ARGS="${2:-:standard:}"
 WITH_SYSTEM_SPKG="${3:-yes}"
 IGNORE_MISSING_SYSTEM_PACKAGES="${4:-no}"
 EXTRA_SAGE_PACKAGES="${5:-_bootstrap}"
-#
+##
+## Environment variables that take influence:
+##
+## - BOOTSTRAP
+## - CONFIGURE_ARGS
+## - DEVTOOLSET
+## - DIST_UPGRADE
+## - DOCKER_BUILDKIT
+## - EXTRA_PATH
+## - EXTRA_REPOSITORIES
+## - EXTRA_SYSTEM_PACKAGES
+## - FULL_BASE_IMAGE_AND_TAG
+## - SKIP_SYSTEM_PKG_INSTALL
+## - USE_CONDARC
+## - __CHOWN
+## - __SUDO
+##
 STRIP_COMMENTS="sed s/#.*//;"
 SAGE_ROOT=.
 export PATH="$SAGE_ROOT"/build/bin:$PATH
 SYSTEM_PACKAGES=$EXTRA_SYSTEM_PACKAGES
-CONFIGURE_ARGS="--enable-option-checking "
+SYSTEM_CONFIGURE_ARGS="--enable-option-checking "
 for SPKG in $(sage-package list --has-file=spkg-configure.m4 $SAGE_PACKAGE_LIST_ARGS) $EXTRA_SAGE_PACKAGES; do
     SYSTEM_PACKAGE=$(sage-get-system-packages $SYSTEM $SPKG)
     if [ -n "${SYSTEM_PACKAGE}" ]; then
@@ -24,7 +45,7 @@ for SPKG in $(sage-package list --has-file=spkg-configure.m4 $SAGE_PACKAGE_LIST_
             # shell-quote package if necessary
             SYSTEM_PACKAGES+=$(printf " %q" "$a")
         done
-        CONFIGURE_ARGS+="--with-system-${SPKG}=${WITH_SYSTEM_SPKG} "
+        SYSTEM_CONFIGURE_ARGS+="--with-system-${SPKG}=${WITH_SYSTEM_SPKG} "
     fi
 done
 echo "# Automatically generated by SAGE_ROOT/.ci/write-dockerfile.sh"
@@ -247,7 +268,7 @@ $ADD Makefile VERSION.txt COPYING.txt condarc.yml README.md bootstrap bootstrap-
 $ADD config/config.rpath /new/config/config.rpath
 $ADD src/doc/bootstrap /new/src/doc/bootstrap
 $ADD src/bin /new/src/bin
-$ADD src/Pipfile.m4 src/pyproject.toml.m4 src/requirements.txt.m4 src/setup.cfg.m4 src/VERSION.txt /new/src/
+$ADD src/Pipfile.m4 src/pyproject.toml src/requirements.txt.m4 src/setup.cfg.m4 src/VERSION.txt /new/src/
 $ADD m4 /new/m4
 $ADD pkgs /new/pkgs
 $ADD build /new/build
@@ -255,11 +276,9 @@ $ADD .ci /new/.ci
 $ADD .upstream.d /new/.upstream.d
 RUN if [ -d /sage ]; then                                               \
         echo "### Incremental build from \$(cat /sage/VERSION.txt)" &&  \
-        if command -v git; then                                         \
-            (cd /new &&                                                 \
-             echo /src >> .gitignore &&                                 \
-             ./.ci/retrofit-worktree.sh worktree-image /sage);          \
-        else                                                            \
+        printf '/src\n!/src/doc/bootstrap\n!/src/bin\n!/src/*.m4\n!/src/*.toml\n!/src/VERSION.txt\n' >> /sage/.gitignore && \
+        printf '/src\n!/src/doc/bootstrap\n!/src/bin\n!/src/*.m4\n!/src/*.toml\n!/src/VERSION.txt\n' >> /new/.gitignore && \
+        if ! (cd /new && ./.ci/retrofit-worktree.sh worktree-image /sage); then \
             for a in local logs; do                                     \
                 if [ -d /sage/\$a ]; then mv /sage/\$a /new/; fi;       \
             done;                                                       \
@@ -271,21 +290,21 @@ RUN if [ -d /sage ]; then                                               \
     fi
 WORKDIR /sage
 
-ARG BOOTSTRAP=${BOOTSTRAP-./bootstrap}
+ARG BOOTSTRAP="${BOOTSTRAP-./bootstrap}"
 $RUN sh -x -c "\${BOOTSTRAP}" $ENDRUN $THEN_SAVE_STATUS
 
 FROM bootstrapped as configured
 #:configuring:
 RUN $CHECK_STATUS_THEN mkdir -p logs/pkgs; rm -f config.log; ln -s logs/pkgs/config.log config.log
-ARG EXTRA_CONFIGURE_ARGS="${CONFIGURE_ARGS}"
+ARG CONFIGURE_ARGS="${CONFIGURE_ARGS:---enable-build-as-root}"
 EOF
 if [ ${WITH_SYSTEM_SPKG} = "force" ]; then
     cat <=3.9, <3.12"
+      CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9, <3.13"
       # Environment during wheel build
-      CIBW_ENVIRONMENT: "PATH=$(pwd)/local/bin:$PATH CPATH=$(pwd)/local/include:$CPATH LIBRARY_PATH=$(pwd)/local/lib:$LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/local/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal"
+      CIBW_ENVIRONMENT: "PATH=$(pwd)/prefix/bin:$PATH CPATH=$(pwd)/prefix/include:$CPATH LIBRARY_PATH=$(pwd)/prefix/lib:$LIBRARY_PATH LD_LIBRARY_PATH=$(pwd)/prefix/lib:$LD_LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/prefix/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal PIP_CONSTRAINT=$(pwd)/constraints.txt"
       # Use 'build', not 'pip wheel'
       CIBW_BUILD_FRONTEND: build
     steps:
@@ -203,6 +203,12 @@ jobs:
           python-version: "3.8 - 3.12"
           update-environment: false
 
+      - name: Bootstrap
+        run: |
+          export PATH=$(pwd)/build/bin:$PATH
+          eval $(sage-print-system-package-command auto --sudo --yes --no-install-recommends --spkg install _bootstrap)
+          ./bootstrap
+
       - name: Build platform wheels
         # We build the wheels from the sdists so that MANIFEST filtering becomes effective.
         # But we must run cibuildwheel with the unpacked source directory, not a tarball,
@@ -210,16 +216,23 @@ jobs:
         #
         # In the CIBW_BEFORE_ALL phase, we install libraries using the Sage distribution.
         # https://cibuildwheel.readthedocs.io/en/stable/options/#before-all
-        # This is unfortunately repeated for each of the packages that we build wheels for
+        # For Linux, this is repeated for each of the packages that we build wheels for
         # because CIBW starts with a fresh container on each invocation.
+        # Therefore we cache it in a directory mounted from the host: /host
+        # https://cibuildwheel.pypa.io/en/stable/faq/#linux-builds-in-containers
+        #
+        # omit sagemath-{meataxe,sirocco} for now -- needs sagemath-modules
         run: |
           "${{ steps.python.outputs.python-path }}" -m pip install pipx
           export PATH=build/bin:$PATH
-          export CIBW_BEFORE_ALL="( $(sage-print-system-package-command debian --yes --no-install-recommends install $(sage-get-system-packages debian $SPKGS)) || $(sage-print-system-package-command fedora --yes --no-install-recommends install $(sage-get-system-packages fedora $SPKGS | sed s/pkg-config/pkgconfig/)) || ( $(sage-print-system-package-command homebrew --yes --no-install-recommends install $(sage-get-system-packages homebrew $SPKGS)) || echo error ignored) ) && ./bootstrap && ./configure --enable-build-as-root && make -j4 V=0 $TARGETS_PRE"
+          export CIBW_BEFORE_ALL="( $(sage-print-system-package-command debian --yes --no-install-recommends install $(sage-get-system-packages debian $SPKGS)) || $(sage-print-system-package-command fedora --yes --no-install-recommends install $(sage-get-system-packages fedora $SPKGS | sed s/pkg-config/pkgconfig/)) || ( $(sage-print-system-package-command homebrew --yes --no-install-recommends install $(sage-get-system-packages homebrew $SPKGS)) || echo error ignored) ) && if cp /host/sage-\$AUDITWHEEL_PLAT/config.status . 2>/dev/null; then chmod +x config.status; fi && if [ -x ./config.status ]; then ./config.status; else ./configure --enable-build-as-root ${{ startsWith(matrix.os, 'ubuntu') && '--prefix=/host/sage-\$AUDITWHEEL_PLAT' || '' }} && cp config.status prefix/; fi && MAKE=\"make -j6\" make V=0 $TARGETS_PRE && (echo \"sage_conf @ file://\$(pwd)/pkgs/sage-conf\" && echo \"sage_setup @ file://\$(pwd)/pkgs/sage-setup\") > constraints.txt"
           mkdir -p unpacked
-          for pkg in sagemath-objects sagemath-categories; do
+          for pkg in sagemath*objects sagemath*categories sagemath*bliss sagemath*coxeter3 sagemath*mcqd sagemath*tdlib; do
+              case "$pkg:${{ matrix.arch }}" in
+                  sagemath*tdlib:i686) continue;;  # broken - boost-related
+              esac
               (cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz
-              "${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.17.0 unpacked/$pkg*
+              "${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.18.0 unpacked/$pkg*
           done
 
       - uses: actions/upload-artifact@v4
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 52288013188..544971c5cd5 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -25,7 +25,6 @@ on:
            "ubuntu-lunar",
            "ubuntu-mantic",
            "ubuntu-noble",
-           "debian-buster-gcc_spkg",
            "debian-bullseye",
            "debian-bookworm",
            "debian-trixie",
diff --git a/.github/workflows/docker_hub.yml b/.github/workflows/docker_hub.yml
index b1c5f42b77d..bb5b5232284 100644
--- a/.github/workflows/docker_hub.yml
+++ b/.github/workflows/docker_hub.yml
@@ -10,6 +10,9 @@ on:
         default: make-build
         type: string
 
+env:
+  CAN_LOGIN: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}
+
 jobs:
   build-and-push:
     name: Build Docker image and push to DockerHub
@@ -71,11 +74,12 @@ jobs:
         if: env.JOB_DONE == 'false'
 
       - name: Login to Docker Hub
+        id: login
         uses: docker/login-action@v3
         with:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
-        if: env.JOB_DONE == 'false'
+        if: env.JOB_DONE == 'false' && env.CAN_LOGIN == 'true'
 
       - name: Build and push make-build
         uses: docker/build-push-action@v5
@@ -85,8 +89,9 @@ jobs:
           target: ${{ inputs.dockerfile_target }}
           build-args: |
             MAKE_BUILD=${{ env.BASE }}
-          push: true
+          push: ${{ steps.login.outcome == 'success' }}
           tags: ${{ env.TAG_LIST }}
           cache-from: type=gha
           cache-to: type=gha,mode=max
-        if: env.JOB_DONE == 'false'
+        # run even if there are no push credentials (just don't push)
+        if: (success() || failure()) && env.JOB_DONE == 'false'
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 7c108f7eb2c..dcc9ecb3cec 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -37,7 +37,14 @@ jobs:
       id: deps
       run: pip install tox
 
-    - name: Code style check with pycodestyle
+    - name: Code style check with ruff-minimal
+      if: (success() || failure()) && steps.deps.outcome == 'success'
+      run: tox -e ruff-minimal
+      env:
+        # https://github.com/ChartBoost/ruff-action/issues/7#issuecomment-1887780308
+        RUFF_OUTPUT_FORMAT: github
+
+    - name: Code style check with pycodestyle-minimal
       if: (success() || failure()) && steps.deps.outcome == 'success'
       run: tox -e pycodestyle-minimal
 
diff --git a/.gitignore b/.gitignore
index 7c6e7b55356..1d7eacdf9e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -204,6 +204,8 @@ build/pkgs/wheel/version_requirements.txt
 /pkgs/*/MANIFEST
 /pkgs/*/*.egg-info
 /pkgs/*/.tox
+/pkgs/*/venv*
+/pkgs/*/.venv*
 
 /pkgs/sage-conf_pypi/sage_root/config.log
 /pkgs/sage-conf_pypi/sage_root/config.status
diff --git a/CITATION.cff b/CITATION.cff
index ed836e58f83..ca02cd9367c 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -4,8 +4,8 @@ title: SageMath
 abstract: SageMath is a free open-source mathematics software system.
 authors:
 - name: "The SageMath Developers"
-version: 10.4.beta6
+version: 10.4.beta7
 doi: 10.5281/zenodo.8042260
-date-released: 2024-05-12
+date-released: 2024-05-25
 repository-code: "https://github.com/sagemath/sage"
 url: "https://www.sagemath.org/"
diff --git a/Makefile b/Makefile
index 8c9a4504b49..00989597a11 100644
--- a/Makefile
+++ b/Makefile
@@ -351,6 +351,7 @@ ptestoptionallong-nodoc:
 # CONFIGURE_DEPENDENCIES is the list of files that influence the generation of 'configure'.
 CONFIGURE_DEPENDENCIES =							\
 	configure.ac src/bin/sage-version.sh m4/*.m4				\
+	src/pyproject.toml							\
 	build/pkgs/*/spkg-configure.m4						\
 	build/pkgs/*/type build/pkgs/*/SPKG.rst					\
 	build/pkgs/*/checksums.ini build/pkgs/*/requirements.txt		\
diff --git a/VERSION.txt b/VERSION.txt
index 356733d937f..8b6596bde75 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-SageMath version 10.4.beta6, Release Date: 2024-05-12
+SageMath version 10.4.beta7, Release Date: 2024-05-25
diff --git a/build/bin/sage-logger b/build/bin/sage-logger
index 1661e52f5f8..6508516036c 100755
--- a/build/bin/sage-logger
+++ b/build/bin/sage-logger
@@ -63,21 +63,19 @@ fi
 
 timefile="$logdir/$logname.time"
 rm -f "$timefile"
-if /usr/bin/time -h -o /dev/null true 2>/dev/null; then
-    TIME="/usr/bin/time -h -o $timefile"
-else
-    TIME=""
-fi
+time_cmd() {
+    local max=$(($SECONDS+10))
+    exec 3>&1 4>&2
+    local out
+    TIME_OUTPUT=$((time 1>&3 2>&4 sh -c "$1") 2>&1)
+    local retstat=$?
+    [ "$SECONDS" -lt "$max" ] || echo "$TIME_OUTPUT" > "$timefile"
+    return $retstat
+}
 
 report_time ()
 {
-    time=$(echo $(cat $timefile 2>/dev/null))
-    case "$time" in
-        *m*real*|*h*real*|*[1-9][0-9].*real*|*[1-9][0-9],*real*)
-            # at least 10 seconds wall time
-            echo "$time"
-            ;;
-    esac
+    [ -r "$timefile" ] && echo $(< $timefile)
 }
 
 mkdir -p "$logdir"
@@ -94,8 +92,7 @@ if [ -n "$SAGE_SILENT_BUILD" -a ${use_prefix} = true ]; then
     # Silent build.
     # Similar to https://www.gnu.org/software/automake/manual/html_node/Automake-Silent-Rules.html#Automake-Silent-Rules
     echo "[$logname] installing. Log file: $logfile"
-    ( exec>> $logfile 2>&1 ; $TIME sh -c "$cmd"; status=$?;
-      [ -r $timefile ] && cat $timefile; exit $status )
+    ( exec>> $logfile 2>&1; time_cmd "$cmd"; status=$?; report_time; exit $status )
     status=$?
     if [[ $status != 0 ]]; then
         echo "  [$logname] error installing, exit status $status. End of log file:"
@@ -115,9 +112,7 @@ else
     # We trap SIGINT such that SIGINT interrupts the main process being
     # run, not the logging.
 
-    ( exec 2>&1;
-      $TIME sh -c "$cmd"; status=$?; report_time;
-      exit $status ) | \
+    ( exec 2>&1; time_cmd "$cmd"; status=$?; report_time; exit $status ) | \
         ( trap '' SIGINT; if [ -n "$GITHUB_ACTIONS" -a -n "$prefix" ]; then echo "::group::${logname}"; fi; tee -a "$logfile" | $SED; if [ -n "$GITHUB_ACTIONS" -a -n "$prefix" ]; then echo "::endgroup::"; fi )
 
     pipestatus=(${PIPESTATUS[*]})
diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg
index 8a4f3e4734f..2b84856ed5c 100755
--- a/build/bin/sage-spkg
+++ b/build/bin/sage-spkg
@@ -363,32 +363,10 @@ WRAPPED_SCRIPTS="build install preinst pipinst postinst $INSTALLED_SCRIPTS"
 warning_for_experimental_packages() { ############################
 if [ x`cat "$PKG_SCRIPTS/type"` = x"experimental" ]; then
     if [ $YES != 1 -a -n "$PKG_NAME_UPSTREAM" ]; then
-        # We use /dev/tty here because our output may be redirected
-        # to a logfile, or line-buffered.
-        write_to_tty < /dev/tty 2>&1
-        else
-            answer=n
-        fi
-        case "$answer" in
-            n*|N*) exit 1;;
-        esac
-        # Confirm the user's input.  (This gives important
-        # feedback to the user when output is redirected to a logfile.)
-        echo > /dev/tty "OK, installing $PKG_NAME now..."
+        echo "Error: The package $PKG_NAME is marked as experimental."
+        echo "Use 'sage -i -y $PKG_BASE' to force installation of this package"
+        echo "or use the configure option --enable-experimental-packages"
+        exit 1
     fi
 fi
 } ############################## warning_for_experimental_packages
diff --git a/build/make/Makefile.in b/build/make/Makefile.in
index 49c0cc4ebcf..7a13e5a9e23 100644
--- a/build/make/Makefile.in
+++ b/build/make/Makefile.in
@@ -17,6 +17,7 @@
 # Always use bash for make rules
 SHELL = @SHELL@
 
+ifndef DEBUG_RULES
 # Check a variable that is only set in build/make/install, but not in sage-env, for example
 ifndef SAGE_PKGCONFIG
 # Set by build/bin/sage-sdist, which invokes the Makefile directly in
@@ -25,6 +26,7 @@ ifndef SAGE_SPKG_COPY_UPSTREAM
 $(error This Makefile needs to be invoked by build/make/install)
 endif
 endif
+endif
 
 # Directory to keep track of which packages are installed - relative to installation prefix
 SPKG_INST_RELDIR = var/lib/sage/installed
diff --git a/build/pkgs/4ti2/checksums.ini b/build/pkgs/4ti2/checksums.ini
index 047f39ece1d..a53ea5b8f04 100644
--- a/build/pkgs/4ti2/checksums.ini
+++ b/build/pkgs/4ti2/checksums.ini
@@ -1,5 +1,4 @@
 tarball=4ti2-${VERSION}.tar.gz
 sha1=3d41f30ea3ef94c293eae30c087494269fc1a6b9
-md5=1215872325ddfc561865ecb22b2bccb2
-cksum=2439180289
+sha256=f7c191beb14246b643e4fd5b18b53d9966693b9e6d3a569441a0e3ca14b1a86b
 upstream_url=https://github.com/4ti2/4ti2/releases/download/Release_${VERSION_MAJOR}_${VERSION_MINOR}_${VERSION_MICRO}/4ti2-${VERSION}.tar.gz
diff --git a/build/pkgs/alabaster/checksums.ini b/build/pkgs/alabaster/checksums.ini
index 8e79c9a28b3..a58c93e8f4a 100644
--- a/build/pkgs/alabaster/checksums.ini
+++ b/build/pkgs/alabaster/checksums.ini
@@ -1,5 +1,4 @@
 tarball=alabaster-VERSION-py3-none-any.whl
 sha1=6c86446396c69236a1542e09771e8d7b8487dcfa
-md5=a1c5ddb246633ac0567beef4a1dcffd7
-cksum=2188566230
+sha256=b46733c07dce03ae4e150330b975c75737fa60f0a7c591b6c8bf4928a28e2c92
 upstream_url=https://pypi.io/packages/py3/a/alabaster/alabaster-VERSION-py3-none-any.whl
diff --git a/build/pkgs/anyio/checksums.ini b/build/pkgs/anyio/checksums.ini
index 4dcafcb69da..edc3a769889 100644
--- a/build/pkgs/anyio/checksums.ini
+++ b/build/pkgs/anyio/checksums.ini
@@ -1,5 +1,4 @@
 tarball=anyio-VERSION-py3-none-any.whl
 sha1=bb08368bb19e1aff2f4190e39300e43fee52103e
-md5=420d85e19168705cdf0223621b18831a
-cksum=627181302
+sha256=cfdb2b588b9fc25ede96d8db56ed50848b0b649dca3dd1df0b11f683bb9e0b5f
 upstream_url=https://pypi.io/packages/py3/a/anyio/anyio-VERSION-py3-none-any.whl
diff --git a/build/pkgs/appdirs/checksums.ini b/build/pkgs/appdirs/checksums.ini
index 3e83a68f3a0..0d44544631d 100644
--- a/build/pkgs/appdirs/checksums.ini
+++ b/build/pkgs/appdirs/checksums.ini
@@ -1,5 +1,4 @@
 tarball=appdirs-VERSION-py2.py3-none-any.whl
 sha1=fc74022712122436427f8282a47bfa430ec2db56
-md5=1d638a5913a8d8ed8e7c7d789ece149c
-cksum=3594208532
+sha256=a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128
 upstream_url=https://pypi.io/packages/py2.py3/a/appdirs/appdirs-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/appnope/checksums.ini b/build/pkgs/appnope/checksums.ini
index f29070a251b..e9ee40864d3 100644
--- a/build/pkgs/appnope/checksums.ini
+++ b/build/pkgs/appnope/checksums.ini
@@ -1,5 +1,4 @@
 tarball=appnope-VERSION.tar.gz
 sha1=dd705054af5f6c80d0ce9e1b444428c7b1b07daa
-md5=ca8ec0b1628061ce922dbf1ceee25bca
-cksum=3863274580
+sha256=02bd91c4de869fbb1e1c50aafc4098827a7a54ab2f39d9dcba6c9547ed920e24
 upstream_url=https://pypi.io/packages/source/a/appnope/appnope-VERSION.tar.gz
diff --git a/build/pkgs/argon2_cffi/checksums.ini b/build/pkgs/argon2_cffi/checksums.ini
index fa87877c2e6..acfeee93d3a 100644
--- a/build/pkgs/argon2_cffi/checksums.ini
+++ b/build/pkgs/argon2_cffi/checksums.ini
@@ -1,5 +1,4 @@
 tarball=argon2-cffi-VERSION.tar.gz
 sha1=c16c1506de0211bdfa23d4d51e780fb4aaff5222
-md5=b7843e8690c790f8e743d37bb75c25a8
-cksum=3700408796
+sha256=d384164d944190a7dd7ef22c6aa3ff197da12962bd04b17f64d4e93d934dba5b
 upstream_url=https://pypi.io/packages/source/a/argon2_cffi/argon2-cffi-VERSION.tar.gz
diff --git a/build/pkgs/argon2_cffi_bindings/checksums.ini b/build/pkgs/argon2_cffi_bindings/checksums.ini
index fe2e878a74d..b0e7ade0b5a 100644
--- a/build/pkgs/argon2_cffi_bindings/checksums.ini
+++ b/build/pkgs/argon2_cffi_bindings/checksums.ini
@@ -1,5 +1,4 @@
 tarball=argon2-cffi-bindings-VERSION.tar.gz
 sha1=5a9b8906d9ca73c53c2bf0a2f0a8127fda69e965
-md5=f1591e1af7dea9ef3e5b982e2c196c1d
-cksum=2420586823
+sha256=bb89ceffa6c791807d1305ceb77dbfacc5aa499891d2c55661c6459651fc39e3
 upstream_url=https://pypi.io/packages/source/a/argon2_cffi_bindings/argon2-cffi-bindings-VERSION.tar.gz
diff --git a/build/pkgs/arrow/checksums.ini b/build/pkgs/arrow/checksums.ini
index 8823edda27e..5ac9740854e 100644
--- a/build/pkgs/arrow/checksums.ini
+++ b/build/pkgs/arrow/checksums.ini
@@ -1,5 +1,4 @@
 tarball=arrow-VERSION-py3-none-any.whl
 sha1=fd9376ef4788dc2b1c981e6b5beb9048e046c556
-md5=71d18bb3d882ae242b5b1a397313bb12
-cksum=244356435
+sha256=c728b120ebc00eb84e01882a6f5e7927a53960aa990ce7dd2b10f39005a67f80
 upstream_url=https://pypi.io/packages/py3/a/arrow/arrow-VERSION-py3-none-any.whl
diff --git a/build/pkgs/asttokens/checksums.ini b/build/pkgs/asttokens/checksums.ini
index 44d0ca1b500..9c5d57c3a17 100644
--- a/build/pkgs/asttokens/checksums.ini
+++ b/build/pkgs/asttokens/checksums.ini
@@ -1,5 +1,4 @@
 tarball=asttokens-VERSION.tar.gz
 sha1=d522a139240293953c99d32ca62c41542babb963
-md5=c353679585a40f43c24ca60fca33bbf6
-cksum=1117135252
+sha256=b03869718ba9a6eb027e134bfdf69f38a236d681c83c160d510768af11254ba0
 upstream_url=https://pypi.io/packages/source/a/asttokens/asttokens-VERSION.tar.gz
diff --git a/build/pkgs/async_lru/checksums.ini b/build/pkgs/async_lru/checksums.ini
index 1a289cb63c3..f1b60406ec1 100644
--- a/build/pkgs/async_lru/checksums.ini
+++ b/build/pkgs/async_lru/checksums.ini
@@ -1,5 +1,4 @@
 tarball=async_lru-VERSION-py3-none-any.whl
 sha1=99b2ea5d551cbad28e08e45f0d0b00827f9ff73d
-md5=de1e9e7559810690de8b7084b372d9a2
-cksum=3326301475
+sha256=ff02944ce3c288c5be660c42dbcca0742b32c3b279d6dceda655190240b99224
 upstream_url=https://pypi.io/packages/py3/a/async_lru/async_lru-VERSION-py3-none-any.whl
diff --git a/build/pkgs/attrs/checksums.ini b/build/pkgs/attrs/checksums.ini
index 74904048262..01a3de82ed3 100644
--- a/build/pkgs/attrs/checksums.ini
+++ b/build/pkgs/attrs/checksums.ini
@@ -1,5 +1,4 @@
 tarball=attrs-VERSION-py3-none-any.whl
 sha1=d916b1ecad441ce7f07d86034085475f6c231830
-md5=5aecf1f8857233a04c1926ea68e8f860
-cksum=1934687514
+sha256=1f28b4522cdc2fb4256ac1a020c78acf9cba2c6b461ccd2c126f3aa8e8335d04
 upstream_url=https://pypi.io/packages/py3/a/attrs/attrs-VERSION-py3-none-any.whl
diff --git a/build/pkgs/awali/checksums.ini b/build/pkgs/awali/checksums.ini
index 60138d29e19..ccc3c7e3862 100644
--- a/build/pkgs/awali/checksums.ini
+++ b/build/pkgs/awali/checksums.ini
@@ -1,4 +1,3 @@
 tarball=awali-all-vVERSION.tgz
 sha1=9098aaefde031df58374bab0c1fc38109eecd4e3
-md5=d4216d8cbe21f83ae3a816a2f994f85e
-cksum=3149228485
+sha256=85a2de222f93554d2959e16f64d8e7549b25446dcb0564ed1cb57196fc35f108
diff --git a/build/pkgs/babel/checksums.ini b/build/pkgs/babel/checksums.ini
index e97dabc2292..84e9171f829 100644
--- a/build/pkgs/babel/checksums.ini
+++ b/build/pkgs/babel/checksums.ini
@@ -1,5 +1,4 @@
 tarball=Babel-VERSION-py3-none-any.whl
 sha1=7f8671a725d0bbf28618841c441af8bd7709d527
-md5=36702a42728c34366bf2ba612b9077cc
-cksum=2476971038
+sha256=efb1a25b7118e67ce3a259bed20545c29cb68be8ad2c784c83689981b7a57287
 upstream_url=https://pypi.io/packages/py3/b/babel/Babel-VERSION-py3-none-any.whl
diff --git a/build/pkgs/barvinok/checksums.ini b/build/pkgs/barvinok/checksums.ini
index fce4148ce81..84ffc3e212b 100644
--- a/build/pkgs/barvinok/checksums.ini
+++ b/build/pkgs/barvinok/checksums.ini
@@ -1,5 +1,4 @@
 tarball=barvinok-VERSION.tar.xz
 sha1=1e17e72732f7e96017d9ae0c3394c3c77c185f2e
-md5=57066c5aa5628b89345c16ed95f93d7e
-cksum=2863920036
+sha256=049a2e0ac061668c2cb6d9832e42c3800c09b5095aef57abd8421ea727df58a3
 upstream_url=https://sourceforge.net/projects/barvinok/files/barvinok-VERSION.tar.xz
diff --git a/build/pkgs/beautifulsoup4/checksums.ini b/build/pkgs/beautifulsoup4/checksums.ini
index 0fd063dd71c..01abdd62940 100644
--- a/build/pkgs/beautifulsoup4/checksums.ini
+++ b/build/pkgs/beautifulsoup4/checksums.ini
@@ -1,5 +1,4 @@
 tarball=beautifulsoup4-VERSION.tar.gz
 sha1=d9cd72f81e7710692b8ff0a42e69bf93375b5fd3
-md5=b49a6696a762e946c2be97c36a5adaa8
-cksum=839566236
+sha256=492bbc69dca35d12daac71c4db1bfff0c876c00ef4a2ffacce226d4638eb72da
 upstream_url=https://pypi.io/packages/source/b/beautifulsoup4/beautifulsoup4-VERSION.tar.gz
diff --git a/build/pkgs/beniget/checksums.ini b/build/pkgs/beniget/checksums.ini
index 731aafbe3f0..b7b3d25085b 100644
--- a/build/pkgs/beniget/checksums.ini
+++ b/build/pkgs/beniget/checksums.ini
@@ -1,5 +1,4 @@
 tarball=beniget-VERSION.tar.gz
 sha1=0167f16d17fbd61b91e620bca07e4ec7054ce51d
-md5=a2bbe7f17f10f9c127d8ef00692ddc55
-cksum=2287567629
+sha256=75554b3b8ad0553ce2f607627dad3d95c60c441189875b98e097528f8e23ac0c
 upstream_url=https://pypi.io/packages/source/b/beniget/beniget-VERSION.tar.gz
diff --git a/build/pkgs/benzene/checksums.ini b/build/pkgs/benzene/checksums.ini
index 1df7cd9dcf0..6982671a3c8 100644
--- a/build/pkgs/benzene/checksums.ini
+++ b/build/pkgs/benzene/checksums.ini
@@ -1,4 +1,3 @@
 tarball=benzene-VERSION.tar.bz2
 sha1=7618f1e21e91459a8b050b948698a75b042d6d80
-md5=ac592d6af7495b51b382b8828ee84323
-cksum=1973449623
+sha256=63e8662672a007f5b2a727df0ab0e38825c65229fd1060fbf5b5d87b3301e9c6
diff --git a/build/pkgs/bleach/checksums.ini b/build/pkgs/bleach/checksums.ini
index 33843727cd9..575b1452888 100644
--- a/build/pkgs/bleach/checksums.ini
+++ b/build/pkgs/bleach/checksums.ini
@@ -1,5 +1,4 @@
 tarball=bleach-VERSION-py3-none-any.whl
 sha1=7ba81a446171fb840d3083afadd0c87f0b599305
-md5=ec9e860103ffbc3e6e9963485464bfbc
-cksum=1174632300
+sha256=3225f354cfc436b9789c66c4ee030194bee0568fbf9cbdad3bc8b5c26c5f12b6
 upstream_url=https://pypi.io/packages/py3/b/bleach/bleach-VERSION-py3-none-any.whl
diff --git a/build/pkgs/bliss/checksums.ini b/build/pkgs/bliss/checksums.ini
index 0c1ebf647bc..88e6065ba17 100644
--- a/build/pkgs/bliss/checksums.ini
+++ b/build/pkgs/bliss/checksums.ini
@@ -1,5 +1,4 @@
 tarball=bliss-VERSION.zip
 sha1=c91c9dcbc11d66ffbcf6415e09ebe793df37be2a
-md5=5707cbfd9fd00980571c64ab3584c505
-cksum=1626493724
+sha256=acc8b98034f30fad24c897f365abd866c13d9f1bb207e398d0caf136875972a4
 upstream_url=https://users.aalto.fi/~tjunttil/bliss/downloads/bliss-VERSION.zip
diff --git a/build/pkgs/bliss/spkg-install.in b/build/pkgs/bliss/spkg-install.in
index 4124a2338e5..b988d6262ce 100644
--- a/build/pkgs/bliss/spkg-install.in
+++ b/build/pkgs/bliss/spkg-install.in
@@ -1,3 +1,7 @@
+if [ "$UNAME" = "Darwin" ]; then
+    LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib"
+    export LDFLAGS
+fi
 cd src
 sdh_cmake -DUSE_GMP=OFF -DCMAKE_VERBOSE_MAKEFILE=ON
 sdh_make
diff --git a/build/pkgs/boost_cropped/checksums.ini b/build/pkgs/boost_cropped/checksums.ini
index 245f90d6c85..3ebb8041d98 100644
--- a/build/pkgs/boost_cropped/checksums.ini
+++ b/build/pkgs/boost_cropped/checksums.ini
@@ -1,4 +1,3 @@
 tarball=boost_cropped-VERSION.tar.bz2
 sha1=a00ffbbcaeefa2efd80fc6fc6ef1a295c165acd9
-md5=43b1d77344682e229ca8c702e42572b8
-cksum=2257236793
+sha256=f008c70cb82a30fd63f42f6a850fdfe344731b95e35e8a38d5a886cdf8efc921
diff --git a/build/pkgs/brial/checksums.ini b/build/pkgs/brial/checksums.ini
index 2f3607207f7..80efcb38591 100644
--- a/build/pkgs/brial/checksums.ini
+++ b/build/pkgs/brial/checksums.ini
@@ -1,5 +1,4 @@
 tarball=brial-VERSION.tar.bz2
 sha1=ea69faff56fb7068536723f3fb5b3583b8467831
-md5=d6c6a01d4fc80062550e02d9185bfbff
-cksum=318826732
+sha256=deb95fc1a99b6f9324f1278fcb676a605b77d59f24683d6af87f573cb46d0a4f
 upstream_url=https://github.com/BRiAl/BRiAl/releases/download/VERSION/brial-VERSION.tar.bz2
diff --git a/build/pkgs/buckygen/checksums.ini b/build/pkgs/buckygen/checksums.ini
index a27ce23059d..3e2e6843ce0 100644
--- a/build/pkgs/buckygen/checksums.ini
+++ b/build/pkgs/buckygen/checksums.ini
@@ -1,4 +1,3 @@
 tarball=buckygen-VERSION.zip
 sha1=a106afecbd55ece18cd75b2e3be6720f5c599d79
-md5=ce46e081eaa23c1cb1004eafe24de831
-cksum=1392809973
+sha256=c151b33078913bed7f72977821d246c6dda5e01b64a53d963b5f95b65852e634
diff --git a/build/pkgs/bzip2/checksums.ini b/build/pkgs/bzip2/checksums.ini
index 54dcf0c02ac..206d87ff1e3 100644
--- a/build/pkgs/bzip2/checksums.ini
+++ b/build/pkgs/bzip2/checksums.ini
@@ -1,4 +1,3 @@
 tarball=bzip2-VERSION.tar.gz
 sha1=ddccd26b2f94700ade5906b0648095b0ddac525c
-md5=80c416073bee97c9ae56f5c5efd29065
-cksum=383440329
+sha256=296b7d4f9bccd58ebbb14d3317e9e97fdd0d7ff13e42cd32285faa626c75455f
diff --git a/build/pkgs/cachetools/checksums.ini b/build/pkgs/cachetools/checksums.ini
index 0ffe70b3b2f..9c2aa8528b0 100644
--- a/build/pkgs/cachetools/checksums.ini
+++ b/build/pkgs/cachetools/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cachetools-VERSION-py3-none-any.whl
 sha1=f7deaa4b10ae6d8955c83b0573e5b80f84e5d87a
-md5=7375eb8031ea2c95b91d2406c29e9379
-cksum=3631496040
+sha256=95ef631eeaea14ba2e36f06437f36463aac3a096799e876ee55e5cdccb102590
 upstream_url=https://pypi.io/packages/py3/c/cachetools/cachetools-VERSION-py3-none-any.whl
diff --git a/build/pkgs/calver/checksums.ini b/build/pkgs/calver/checksums.ini
index 358cbc4cf7b..8c23449b03d 100644
--- a/build/pkgs/calver/checksums.ini
+++ b/build/pkgs/calver/checksums.ini
@@ -1,5 +1,4 @@
 tarball=calver-VERSION-py3-none-any.whl
 sha1=4553e3fbfc58908f3be2dd529e5991986f6a46b5
-md5=3c34037d7bd217efd99b738aa1a7744b
-cksum=3667684754
+sha256=a1d7fcdd67797afc52ee36ffb8c8adf6643173864306547bfd1380cbce6310a0
 upstream_url=https://pypi.io/packages/py3/c/calver/calver-VERSION-py3-none-any.whl
diff --git a/build/pkgs/cbc/checksums.ini b/build/pkgs/cbc/checksums.ini
index 063d4b0c1df..3f49dd0da0b 100644
--- a/build/pkgs/cbc/checksums.ini
+++ b/build/pkgs/cbc/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cbc-VERSION.tar.gz
 sha1=d937d6af1ee8838d44659ebd4cf7bbb1b20372ce
-md5=2134576233cc95cdfedc63991a4944ec
-cksum=1215468781
+sha256=e39acffdac115e6b9c0d6f1afaf4f890f037007061d7ad4e0a47b95ec18db752
 upstream_url=https://github.com/coin-or/Cbc/archive/refs/tags/releases/VERSION.tar.gz
diff --git a/build/pkgs/ccache/checksums.ini b/build/pkgs/ccache/checksums.ini
index 97ad12917d0..2b4b1895243 100644
--- a/build/pkgs/ccache/checksums.ini
+++ b/build/pkgs/ccache/checksums.ini
@@ -1,4 +1,3 @@
 tarball=ccache-VERSION.tar.bz2
 sha1=3653e0765f01697c449f7026c479fbd9526323a7
-md5=1f6ab79c60660f90c88f47708803605e
-cksum=1428047259
+sha256=fa9d7f38367431bc86b19ad107d709ca7ecf1574fdacca01698bdf0a47cd8567
diff --git a/build/pkgs/cddlib/checksums.ini b/build/pkgs/cddlib/checksums.ini
index 3da743b66b8..974373cf670 100644
--- a/build/pkgs/cddlib/checksums.ini
+++ b/build/pkgs/cddlib/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cddlib-VERSION.tar.gz
 sha1=8f38597a0479a191a62346dab89794e888c478b6
-md5=ec7f35912e34232b5306a643f99b6311
-cksum=2420656558
+sha256=70dffdb3369b8704dc75428a1b3c42ab9047b81ce039f12f427e2eb2b1b0dee2
 upstream_url=https://github.com/cddlib/cddlib/releases/download/VERSION/cddlib-VERSION.tar.gz
diff --git a/build/pkgs/certifi/checksums.ini b/build/pkgs/certifi/checksums.ini
index aaa80e4d577..1a07649c990 100644
--- a/build/pkgs/certifi/checksums.ini
+++ b/build/pkgs/certifi/checksums.ini
@@ -1,5 +1,4 @@
 tarball=certifi-VERSION-py3-none-any.whl
 sha1=9e99fff8d517d9c5b8d8fe6fe66bc31fa55b0fec
-md5=c97d3905f6f805c9ccf70af93c7f0ace
-cksum=3858731419
+sha256=e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474
 upstream_url=https://pypi.io/packages/py3/c/certifi/certifi-VERSION-py3-none-any.whl
diff --git a/build/pkgs/cffi/checksums.ini b/build/pkgs/cffi/checksums.ini
index 5e9ebc003f4..6b22c299649 100644
--- a/build/pkgs/cffi/checksums.ini
+++ b/build/pkgs/cffi/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cffi-VERSION.tar.gz
 sha1=c42a46cd11f6153f299cf10e9c236e8b2a143c21
-md5=f493860a6e98cd0c4178149568a6b4f6
-cksum=585894851
+sha256=d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9
 upstream_url=https://pypi.io/packages/source/c/cffi/cffi-VERSION.tar.gz
diff --git a/build/pkgs/chardet/checksums.ini b/build/pkgs/chardet/checksums.ini
index 9911b1d139e..8bce7750395 100644
--- a/build/pkgs/chardet/checksums.ini
+++ b/build/pkgs/chardet/checksums.ini
@@ -1,5 +1,4 @@
 tarball=chardet-VERSION-py3-none-any.whl
 sha1=2facc0387556aa8a2956ef682d49fc3eae56d30a
-md5=b9eda7cd7d1582e269bd8eb7ffc4fcad
-cksum=1563594607
+sha256=e1cf59446890a00105fe7b7912492ea04b6e6f06d4b742b2c788469e34c82970
 upstream_url=https://pypi.io/packages/py3/c/chardet/chardet-VERSION-py3-none-any.whl
diff --git a/build/pkgs/charset_normalizer/checksums.ini b/build/pkgs/charset_normalizer/checksums.ini
index 1d99f3fb73c..0530b566631 100644
--- a/build/pkgs/charset_normalizer/checksums.ini
+++ b/build/pkgs/charset_normalizer/checksums.ini
@@ -1,5 +1,4 @@
 tarball=charset_normalizer-VERSION-py3-none-any.whl
 sha1=1aa12424059bec1d95d9dda38b4ff6d062dededf
-md5=ea733f7299c80a232262a7f71a4fc698
-cksum=984483622
+sha256=3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc
 upstream_url=https://pypi.io/packages/py3/c/charset_normalizer/charset_normalizer-VERSION-py3-none-any.whl
diff --git a/build/pkgs/cliquer/checksums.ini b/build/pkgs/cliquer/checksums.ini
index 112891b0960..ae0300270b2 100644
--- a/build/pkgs/cliquer/checksums.ini
+++ b/build/pkgs/cliquer/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cliquer-VERSION.tar.gz
 sha1=2973abfcf84f9d098e8abbf4f0ac4b776c7f6105
-md5=f37da2689c4f867407a9030a5cfc39e6
-cksum=1511776397
+sha256=6ff79e1e9983ebabbca3dd276a8a310cbdeb48c7adf95f37abd83129b566340e
 upstream_url=https://github.com/dimpase/autocliquer/releases/download/vVERSION/cliquer-VERSION.tar.gz
diff --git a/build/pkgs/cmake/checksums.ini b/build/pkgs/cmake/checksums.ini
index 312edba61ff..477a967711a 100644
--- a/build/pkgs/cmake/checksums.ini
+++ b/build/pkgs/cmake/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cmake-VERSION.tar.gz
 sha1=05de9ac807fefeb2a36ed5e8fcea376a00dd3d57
-md5=df0e65607c9280a8df68b2c93eac4437
-cksum=3851971657
+sha256=fece24563f697870fbb982ea8bf17482c9d5f855d8c9bf0b82463d76c9e8d0cc
 upstream_url=https://github.com/Kitware/CMake/releases/download/vVERSION/cmake-VERSION.tar.gz
diff --git a/build/pkgs/cocoalib/checksums.ini b/build/pkgs/cocoalib/checksums.ini
index be2e5a19ad1..bc38adaecfe 100644
--- a/build/pkgs/cocoalib/checksums.ini
+++ b/build/pkgs/cocoalib/checksums.ini
@@ -1,4 +1,3 @@
 tarball=CoCoALib-VERSION.tgz
 sha1=087b7fa3d905c47a6ff70e4e4cc2fbc031227631
-md5=1cfc3b6ff549ea01e1bffaf3bc9600a8
-cksum=2933468620
+sha256=c7d3d69b44eefd316a456720aee4cf1fdf74ad9940f527646533fe1540add4ba
diff --git a/build/pkgs/colorama/checksums.ini b/build/pkgs/colorama/checksums.ini
index e625d548a68..3332565f156 100644
--- a/build/pkgs/colorama/checksums.ini
+++ b/build/pkgs/colorama/checksums.ini
@@ -1,5 +1,4 @@
 tarball=colorama-VERSION-py2.py3-none-any.whl
 sha1=d6ab1608850fecfc0e1cf50bf93d743695c04027
-md5=3fc7a89530d68d7ea231ebe779c0db9c
-cksum=3297334831
+sha256=4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
 upstream_url=https://pypi.io/packages/py2.py3/c/colorama/colorama-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/combinatorial_designs/checksums.ini b/build/pkgs/combinatorial_designs/checksums.ini
index 9a1b121fce8..7fc2ef9b3a8 100644
--- a/build/pkgs/combinatorial_designs/checksums.ini
+++ b/build/pkgs/combinatorial_designs/checksums.ini
@@ -1,4 +1,3 @@
 tarball=combinatorial_designs-VERSION.tar.bz2
 sha1=353ba24217f9b7920890a784fd75dc59175f7196
-md5=f345a6918b1bcf34fcd71c2f26d10de0
-cksum=131472289
+sha256=c9486c6d7ec71da338589a6e301723be4e55e02dcfc41f8dba11a682e3b3482e
diff --git a/build/pkgs/comm/checksums.ini b/build/pkgs/comm/checksums.ini
index a3c7481f090..34f21ec0087 100644
--- a/build/pkgs/comm/checksums.ini
+++ b/build/pkgs/comm/checksums.ini
@@ -1,5 +1,4 @@
 tarball=comm-VERSION-py3-none-any.whl
 sha1=e7e20f9c1524a9fe059c0b6df90a68e1cd2115a9
-md5=165e29c257c70498b61c7a31916727f2
-cksum=2011044045
+sha256=6d52794cba11b36ed9860999cd10fd02d6b2eac177068fdd585e1e2f8a96e67a
 upstream_url=https://pypi.io/packages/py3/c/comm/comm-VERSION-py3-none-any.whl
diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini
index 3222e604fa8..11ac0586818 100644
--- a/build/pkgs/configure/checksums.ini
+++ b/build/pkgs/configure/checksums.ini
@@ -1,4 +1,3 @@
 tarball=configure-VERSION.tar.gz
-sha1=dca19f73642b76f1f96b860bb6603499f586380d
-md5=cdfc81ecaa40045a7827959e9f52e226
-cksum=1337053183
+sha1=471d1f0b2d196f53d0f2642f23dec8e306d19e9d
+sha256=f5e990564bfce379ec01675351e47d1be2aff8a2f9433c8dcdb722257ff314ad
diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt
index 8da0a664f61..4ae97e23c06 100644
--- a/build/pkgs/configure/package-version.txt
+++ b/build/pkgs/configure/package-version.txt
@@ -1 +1 @@
-f5e78840b108412e1e26382910af993f874c6933
+7e761162d6ebd9c81d5feb1007530bcdd408dadc
diff --git a/build/pkgs/contourpy/checksums.ini b/build/pkgs/contourpy/checksums.ini
index f4751b4da06..2823ef85c08 100644
--- a/build/pkgs/contourpy/checksums.ini
+++ b/build/pkgs/contourpy/checksums.ini
@@ -1,5 +1,4 @@
 tarball=contourpy-VERSION.tar.gz
 sha1=eb8520cb7172aa8b957d8ba2d09e8f6d9a068d2a
-md5=dd89f11007f39baec1e858ad1f464ea9
-cksum=239770832
+sha256=96ba37c2e24b7212a77da85004c38e7c4d155d3e72a45eeaf22c1f03f607e8ab
 upstream_url=https://pypi.io/packages/source/c/contourpy/contourpy-VERSION.tar.gz
diff --git a/build/pkgs/conway_polynomials/checksums.ini b/build/pkgs/conway_polynomials/checksums.ini
index eeb24706c7d..ad748205e1a 100644
--- a/build/pkgs/conway_polynomials/checksums.ini
+++ b/build/pkgs/conway_polynomials/checksums.ini
@@ -1,5 +1,4 @@
 tarball=conway-polynomials-VERSION.tar.gz
 sha1=cf0904c184d7f947eaae0de1b0e2e47411e9cfda
-md5=ddc0e82da67120efc353a6ec29c4cca2
-cksum=2976854063
+sha256=67ddcd7c0fa7a569fddd9ba70621423e638fd03646c1d4a375c8301f6b1100cb
 upstream_url=https://files.pythonhosted.org/packages/source/c/conway-polynomials/conway-polynomials-VERSION.tar.gz
diff --git a/build/pkgs/coxeter3/checksums.ini b/build/pkgs/coxeter3/checksums.ini
index 906a9a3b784..ae16064a597 100644
--- a/build/pkgs/coxeter3/checksums.ini
+++ b/build/pkgs/coxeter3/checksums.ini
@@ -1,4 +1,3 @@
 tarball=coxeter-VERSION.tar.bz2
 sha1=2f9ba814043c39ab4063ed31f384d908072cae4e
-md5=46318ee161fd18b8a0c438b8a4f6c411
-cksum=440369702
+sha256=659e13317716148a70fee53c8555e494931b7820f41a1627f735c4c753ac1268
diff --git a/build/pkgs/cppy/checksums.ini b/build/pkgs/cppy/checksums.ini
index 613b3b3f5b8..8c1171ff28d 100644
--- a/build/pkgs/cppy/checksums.ini
+++ b/build/pkgs/cppy/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cppy-VERSION.tar.gz
 sha1=c82ee7a4f38e302bfe4de2a695d2bdfefb69951f
-md5=7c1f825c43dd66454440932a35b9969c
-cksum=1879136901
+sha256=83b43bf17b1085ac15c5debdb42154f138b928234b21447358981f69d0d6fe1b
 upstream_url=https://files.pythonhosted.org/packages/source/c/cppy/cppy-VERSION.tar.gz
diff --git a/build/pkgs/cryptominisat/checksums.ini b/build/pkgs/cryptominisat/checksums.ini
index a3f569b739b..f3838f6618c 100644
--- a/build/pkgs/cryptominisat/checksums.ini
+++ b/build/pkgs/cryptominisat/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cryptominisat-VERSION.tar.gz
 sha1=f79dfa1ffc6c9c75b3a33f76d3a89a3df2b3f4c2
-md5=05bdde77aa78c983849437e93b39bd6a
-cksum=462131608
+sha256=50153025c8503ef32f32fff847ee24871bb0fc1f0b13e17fe01aa762923f6d94
 upstream_url=https://github.com/msoos/cryptominisat/archive/refs/tags/VERSION.tar.gz
diff --git a/build/pkgs/csdp/checksums.ini b/build/pkgs/csdp/checksums.ini
index 90e65b23177..8367332b77a 100644
--- a/build/pkgs/csdp/checksums.ini
+++ b/build/pkgs/csdp/checksums.ini
@@ -1,4 +1,3 @@
 tarball=csdp-VERSION.tar.gz
 sha1=017cbf067f190a2491692be6796f9b6af29c903e
-md5=520497cf33c3049a22b03681a5d717d8
-cksum=127128634
+sha256=4bc8d09eec34557c4f483b8fda6bb1ff9d00c659c91ca71fc8b4a77a14346be0
diff --git a/build/pkgs/cunningham_tables/checksums.ini b/build/pkgs/cunningham_tables/checksums.ini
index 360d9b647b7..47cb1afb35b 100644
--- a/build/pkgs/cunningham_tables/checksums.ini
+++ b/build/pkgs/cunningham_tables/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cunningham_tables-VERSION.tar.gz
 sha1=8bea1a113d85bb9c37d8f213dd19525d9d026f22
-md5=e71b32f12e9a46c1c86e275e8441a06b
-cksum=1990403877
+sha256=ef39ab25bef5b1813071c9bd96abe3a9e683d5595c9654a3ffde5b07b7fe52b0
 upstream_url=http://users.ox.ac.uk/~coml0531/sage/cunningham_tables-VERSION.tar.gz
diff --git a/build/pkgs/curl/checksums.ini b/build/pkgs/curl/checksums.ini
index 4dd30b4fc57..6edbac68445 100644
--- a/build/pkgs/curl/checksums.ini
+++ b/build/pkgs/curl/checksums.ini
@@ -1,5 +1,4 @@
 tarball=curl-VERSION.tar.bz2
 sha1=0113fe762aed27d58c4e53ce2be7a98bc7f74957
-md5=35fca80437f32dd7ef6c2e30b4916f06
-cksum=1239842454
+sha256=702fb26e73190a3bd77071aa146f507b9817cc4dfce218d2ab87f00cd3bc059d
 upstream_url=https://curl.se/download/curl-VERSION.tar.bz2
diff --git a/build/pkgs/cvxopt/checksums.ini b/build/pkgs/cvxopt/checksums.ini
index a09000f2476..ca2f4711f5d 100644
--- a/build/pkgs/cvxopt/checksums.ini
+++ b/build/pkgs/cvxopt/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cvxopt-VERSION.tar.gz
 sha1=f9c3c3fb61e87d27f05b3b66bc10734d5e6284e6
-md5=ced06e7d92d8a10c84db94589e7f8162
-cksum=2059529268
+sha256=3461fa42c1b2240ba4da1d985ca73503914157fc4c77417327ed6d7d85acdbe6
 upstream_url=https://pypi.io/packages/source/c/cvxopt/cvxopt-VERSION.tar.gz
diff --git a/build/pkgs/cvxpy/checksums.ini b/build/pkgs/cvxpy/checksums.ini
index 3f76d4a6228..025278a9b01 100644
--- a/build/pkgs/cvxpy/checksums.ini
+++ b/build/pkgs/cvxpy/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cvxpy-VERSION.tar.gz
 sha1=1ca24d9e2ee5add13b33724ab9a11e747fe4ed99
-md5=da9fa9feb9634d3562057484b9822889
-cksum=1557666297
+sha256=7a9ef34e3c57ff8c844d86f0a3834fb5575af19233947639de0ba577c6122e3e
 upstream_url=https://pypi.io/packages/source/c/cvxpy/cvxpy-VERSION.tar.gz
diff --git a/build/pkgs/cycler/checksums.ini b/build/pkgs/cycler/checksums.ini
index b9f7e51759f..c187b6b4cba 100644
--- a/build/pkgs/cycler/checksums.ini
+++ b/build/pkgs/cycler/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cycler-VERSION.tar.gz
 sha1=576c8605d33a8f70eccabf321ecc9e2fbdb9fb72
-md5=4d0c25f418956e91c47163179682e0ef
-cksum=2916957464
+sha256=9c87405839a19696e837b3b818fed3f5f69f16f1eec1a1ad77e043dcea9c772f
 upstream_url=https://files.pythonhosted.org/packages/source/c/cycler/cycler-VERSION.tar.gz
diff --git a/build/pkgs/cylp/checksums.ini b/build/pkgs/cylp/checksums.ini
index 570be6d38a8..d4f3ea9867b 100644
--- a/build/pkgs/cylp/checksums.ini
+++ b/build/pkgs/cylp/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cylp-VERSION.tar.gz
 sha1=22398052ca88123b77e691a0045806a030c9b259
-md5=ac00f775af15afcee1b7932144441ec0
-cksum=2746382211
+sha256=a7ee226caa274e190338da3d24314647df7e06599ab38cdd26c005d8b8258b16
 upstream_url=https://pypi.io/packages/source/c/cylp/cylp-VERSION.tar.gz
diff --git a/build/pkgs/cypari/checksums.ini b/build/pkgs/cypari/checksums.ini
index 27a680da968..8bedd4cf52d 100644
--- a/build/pkgs/cypari/checksums.ini
+++ b/build/pkgs/cypari/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cypari2-VERSION.tar.gz
 sha1=4cb5fc43899852b7fc0c0175e610318c38f0caac
-md5=e9940034c6707a3faeb416f207444e81
-cksum=361739172
+sha256=1a25865c34f20b1dc95830798e34ab6436e278b8e0c80dc7bf0ab34c5db03ab8
 upstream_url=https://pypi.io/packages/source/c/cypari2/cypari2-VERSION.tar.gz
diff --git a/build/pkgs/cysignals/checksums.ini b/build/pkgs/cysignals/checksums.ini
index 5c925fcc9ec..6bf5ec53eaa 100644
--- a/build/pkgs/cysignals/checksums.ini
+++ b/build/pkgs/cysignals/checksums.ini
@@ -1,5 +1,4 @@
 tarball=cysignals-VERSION.tar.gz
 sha1=76db7aa59d55e867c83b329c017382555253af43
-md5=1837370e1d7f0b0acf1b97c3b7323b7d
-cksum=4114189395
+sha256=0f1e321e55a07f901c86a36a1e4497f6ff9dfe700681d0130a38c36e4eb238c3
 upstream_url=https://pypi.io/packages/source/c/cysignals/cysignals-VERSION.tar.gz
diff --git a/build/pkgs/cython/checksums.ini b/build/pkgs/cython/checksums.ini
index 6fcab0bf060..9393fe60b7f 100644
--- a/build/pkgs/cython/checksums.ini
+++ b/build/pkgs/cython/checksums.ini
@@ -1,5 +1,4 @@
 tarball=Cython-VERSION.tar.gz
 sha1=83d6428e3bb7869f44f92ed75d7dff867c2a38ce
-md5=0110d7adac5ebb6ae65d8b71a72b664e
-cksum=1043698601
+sha256=dcc96739331fb854dcf503f94607576cfe8488066c61ca50dfd55836f132de99
 upstream_url=https://pypi.io/packages/source/C/Cython/Cython-VERSION.tar.gz
diff --git a/build/pkgs/d3js/checksums.ini b/build/pkgs/d3js/checksums.ini
index 5cfe0dd2274..5d155588954 100644
--- a/build/pkgs/d3js/checksums.ini
+++ b/build/pkgs/d3js/checksums.ini
@@ -1,4 +1,3 @@
 tarball=d3js-VERSION.tar.gz
 sha1=2fd4da34ca9e645cf81bf914d289c21c7bb8c166
-md5=d859a120f1eaebb8b563f4598868c564
-cksum=527881311
+sha256=9c0120e72ac623fd8e0e9f9bec3f5998a523e822a26c86d4460c08172120c490
diff --git a/build/pkgs/database_cremona_ellcurve/checksums.ini b/build/pkgs/database_cremona_ellcurve/checksums.ini
index 9bb6711f674..8be593bb368 100644
--- a/build/pkgs/database_cremona_ellcurve/checksums.ini
+++ b/build/pkgs/database_cremona_ellcurve/checksums.ini
@@ -1,4 +1,3 @@
 tarball=database_cremona_ellcurve-20190911.tar.bz2
 sha1=db8f87a70cc4103d617e0989e393f1343cacae6d
-md5=9399e69983c44d801f2d5bd2f3769d98
-cksum=767500587
+sha256=5d1d6aa35a95f9df123c87c1894791580d067444e1145bbd6ec20b4840f22053
diff --git a/build/pkgs/database_cubic_hecke/checksums.ini b/build/pkgs/database_cubic_hecke/checksums.ini
index b2119998ee2..347eac4060a 100644
--- a/build/pkgs/database_cubic_hecke/checksums.ini
+++ b/build/pkgs/database_cubic_hecke/checksums.ini
@@ -1,5 +1,4 @@
 tarball=database_cubic_hecke-VERSION.tar.gz
 sha1=f78ae31202fe077177f2c5059c028f9d40c20a46
-md5=4f83516e155515f17ebd88c56bc0f31b
-cksum=3948466130
+sha256=1c45ea30431698b0604924172e7e934e65d7db7e381f4173197704030b0c3bce
 upstream_url=https://pypi.io/packages/source/d/database_cubic_hecke/database_cubic_hecke-VERSION.tar.gz
diff --git a/build/pkgs/database_jones_numfield/checksums.ini b/build/pkgs/database_jones_numfield/checksums.ini
index 69db10a25a8..a64642fb00d 100644
--- a/build/pkgs/database_jones_numfield/checksums.ini
+++ b/build/pkgs/database_jones_numfield/checksums.ini
@@ -1,4 +1,3 @@
 tarball=database_jones_numfield-VERSION.tar.gz
 sha1=f7b1c4c330ff6be47ade4ec7fc14df9cebe8e2a8
-md5=a8da4f207235a1de980a23a06e1e6d76
-cksum=1843797635
+sha256=704d70101bc504bbdd2d7ac5847cb3bbc43e017c0ee163a9b4ab3ed2e572a001
diff --git a/build/pkgs/database_knotinfo/checksums.ini b/build/pkgs/database_knotinfo/checksums.ini
index 6f174a26738..9bcedf63dfa 100644
--- a/build/pkgs/database_knotinfo/checksums.ini
+++ b/build/pkgs/database_knotinfo/checksums.ini
@@ -1,5 +1,4 @@
 tarball=database_knotinfo-VERSION.tar.gz
 sha1=d32a5640c59c25d49ee72770aedfc6daac7c3d0e
-md5=2d4104feee05547b542b1d86dd0f7675
-cksum=2620016485
+sha256=146506d11752ba10bdd2cc3d6fedb35f913ce44ccaca64c0ca17f5c2ede38ba1
 upstream_url=https://pypi.io/packages/source/d/database_knotinfo/database_knotinfo-VERSION.tar.gz
diff --git a/build/pkgs/database_kohel/checksums.ini b/build/pkgs/database_kohel/checksums.ini
index cd7679266e5..32d2321ad8b 100644
--- a/build/pkgs/database_kohel/checksums.ini
+++ b/build/pkgs/database_kohel/checksums.ini
@@ -1,4 +1,3 @@
 tarball=database_kohel-VERSION.tar.gz
 sha1=ace5bed1eab66b4b0e9e74717cfcd8eb94c59d3f
-md5=5253b28e0a82f1fb88dc5cabb95ae578
-cksum=1736717427
+sha256=0e05b6ee5306862cffddd61b5b8635841307b8fee8787b69c29a0d55b0650860
diff --git a/build/pkgs/database_mutation_class/checksums.ini b/build/pkgs/database_mutation_class/checksums.ini
index cc4443b0928..96c903b6ccd 100644
--- a/build/pkgs/database_mutation_class/checksums.ini
+++ b/build/pkgs/database_mutation_class/checksums.ini
@@ -1,4 +1,3 @@
 tarball=database_mutation_class-VERSION.tar.gz
 sha1=0e7eb2e89e1d4a612cb60e3d6be14d42f3e55678
-md5=8186b8f75eae76825399f3a9e6378c7b
-cksum=364985299
+sha256=5105eed820e469bc0645788e23a47ff19420d3e398f5866df1424a05c67ee067
diff --git a/build/pkgs/database_odlyzko_zeta/checksums.ini b/build/pkgs/database_odlyzko_zeta/checksums.ini
index 3c5cc103711..ce22051cf58 100644
--- a/build/pkgs/database_odlyzko_zeta/checksums.ini
+++ b/build/pkgs/database_odlyzko_zeta/checksums.ini
@@ -1,4 +1,3 @@
 tarball=database_odlyzko_zeta-VERSION.tar.bz2
 sha1=97f586307d2f67a0a8594bd010602e2c4d5e0b4d
-md5=c93f63760540d5a787728a7a89ca2d9c
-cksum=3293740202
+sha256=8919f01992718b9bf5c0602dbf16dd9d6f58b141b25f67f5cfd59f6cd0f9a0d4
diff --git a/build/pkgs/database_stein_watkins/checksums.ini b/build/pkgs/database_stein_watkins/checksums.ini
index 9192816cc06..2d5044b8097 100644
--- a/build/pkgs/database_stein_watkins/checksums.ini
+++ b/build/pkgs/database_stein_watkins/checksums.ini
@@ -1,4 +1,3 @@
 tarball=database_stein_watkins-VERSION.tar.gz
 sha1=eecfb07fe2693e4baf301a0759d018a8842aba4d
-md5=e2ac1794dfaa0fdd9e7d12132c894c66
-cksum=1440891220
+sha256=00fd8610d6343968f853cfb49c4ed75fb2347a2953ea8d6d0fa0aa2a98d43f6f
diff --git a/build/pkgs/database_stein_watkins_mini/checksums.ini b/build/pkgs/database_stein_watkins_mini/checksums.ini
index b88d9ff7a8a..0b8179140a0 100644
--- a/build/pkgs/database_stein_watkins_mini/checksums.ini
+++ b/build/pkgs/database_stein_watkins_mini/checksums.ini
@@ -1,4 +1,3 @@
 tarball=database_stein_watkins_mini-VERSION.tar.bz2
 sha1=4979191668e7cc8490eda75044435519faab0f9c
-md5=24b2741b9e78449071624f79b7dd48b0
-cksum=3178425274
+sha256=adacd565277629238a14fd7d52f35a7516dfcd1d8875cb0c480cb56bd2cbb875
diff --git a/build/pkgs/database_symbolic_data/checksums.ini b/build/pkgs/database_symbolic_data/checksums.ini
index 36fc20b99aa..f4c13ac4cd1 100644
--- a/build/pkgs/database_symbolic_data/checksums.ini
+++ b/build/pkgs/database_symbolic_data/checksums.ini
@@ -1,4 +1,3 @@
 tarball=database_symbolic_data-VERSION.tar.bz2
 sha1=5f8532dacae12f36813ea609c6f511016955d1ee
-md5=4b0162e2efe22c942970cf2deaa38700
-cksum=884432759
+sha256=97eb42d007296c9a41bce65ada5ebf84c9341eaeda0b35a060e2d327042eb7fe
diff --git a/build/pkgs/dateutil/checksums.ini b/build/pkgs/dateutil/checksums.ini
index 20fbeb61d10..1c7783ac8fd 100644
--- a/build/pkgs/dateutil/checksums.ini
+++ b/build/pkgs/dateutil/checksums.ini
@@ -1,5 +1,4 @@
 tarball=python-dateutil-VERSION.tar.gz
 sha1=c2ba10c775b7a52a4b57cac4d4110a0c0f812a82
-md5=5970010bb72452344df3d76a10281b65
-cksum=3093929984
+sha256=0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86
 upstream_url=https://files.pythonhosted.org/packages/source/p/python-dateutil/python-dateutil-VERSION.tar.gz
diff --git a/build/pkgs/debugpy/checksums.ini b/build/pkgs/debugpy/checksums.ini
index 43f1c2c84a5..9ffea011e6e 100644
--- a/build/pkgs/debugpy/checksums.ini
+++ b/build/pkgs/debugpy/checksums.ini
@@ -1,5 +1,4 @@
 tarball=debugpy-VERSION.zip
 sha1=af611dc5c401424196c27363379fc483814efe26
-md5=b4a6173035b58a0ad61561a4c5017885
-cksum=57995549
+sha256=12af2c55b419521e33d5fb21bd022df0b5eb267c3e178f1d374a63a2a6bdccd0
 upstream_url=https://pypi.io/packages/source/d/debugpy/debugpy-VERSION.zip
diff --git a/build/pkgs/decorator/checksums.ini b/build/pkgs/decorator/checksums.ini
index 47bd53771d0..daaa14c6732 100644
--- a/build/pkgs/decorator/checksums.ini
+++ b/build/pkgs/decorator/checksums.ini
@@ -1,5 +1,4 @@
 tarball=decorator-VERSION.tar.gz
 sha1=929f42916ac8a4aa973599d558768b8f1728db46
-md5=a6b34700dcac8a4bb04efd55e99626c1
-cksum=4154678061
+sha256=637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330
 upstream_url=https://pypi.io/packages/source/d/decorator/decorator-VERSION.tar.gz
diff --git a/build/pkgs/deformation/checksums.ini b/build/pkgs/deformation/checksums.ini
index a0996128077..4c3b5eefad3 100644
--- a/build/pkgs/deformation/checksums.ini
+++ b/build/pkgs/deformation/checksums.ini
@@ -1,5 +1,4 @@
 tarball=deformation-VERSION.tar.bz2
 sha1=0f5fd78a91da207d06b5be59bf466f16c2614eda
-md5=e2c365e20778117d402fb664fc145d72
-cksum=3789646827
+sha256=100dc7a28638b0a06227d07d2c1d1f872c65f9828e451e34e947aed109abbfcb
 upstream_url=https://github.com/sagemath/deformation/archive/refs/tags/VERSION.tar.gz
diff --git a/build/pkgs/defusedxml/checksums.ini b/build/pkgs/defusedxml/checksums.ini
index c2cf328d5b2..a6da3a2e278 100644
--- a/build/pkgs/defusedxml/checksums.ini
+++ b/build/pkgs/defusedxml/checksums.ini
@@ -1,5 +1,4 @@
 tarball=defusedxml-VERSION.tar.gz
 sha1=37667af1dc1357eb96b005c4f408ad5292d77b9f
-md5=a50e7f21aa60a741efe6b1b658dfb3f8
-cksum=3442371004
+sha256=1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69
 upstream_url=https://pypi.io/packages/source/d/defusedxml/defusedxml-VERSION.tar.gz
diff --git a/build/pkgs/distlib/checksums.ini b/build/pkgs/distlib/checksums.ini
index b1a05ffc295..bd456ec2028 100644
--- a/build/pkgs/distlib/checksums.ini
+++ b/build/pkgs/distlib/checksums.ini
@@ -1,5 +1,4 @@
 tarball=distlib-VERSION-py2.py3-none-any.whl
 sha1=97ea3bb71040f0348eaea272ec17fefea5806e87
-md5=cf336842ba81996e554ae4eb2cd76d5d
-cksum=3779817199
+sha256=034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784
 upstream_url=https://pypi.io/packages/py2.py3/d/distlib/distlib-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/docutils/checksums.ini b/build/pkgs/docutils/checksums.ini
index 784aac76419..ebcc15cc5a1 100644
--- a/build/pkgs/docutils/checksums.ini
+++ b/build/pkgs/docutils/checksums.ini
@@ -1,5 +1,4 @@
 tarball=docutils-VERSION-py3-none-any.whl
 sha1=2bac2b2e9f4cc6d832588457c5f69bac79d80239
-md5=1d4506ff10777551614a128872523dfb
-cksum=2147344904
+sha256=96f387a2c5562db4476f09f13bbab2192e764cac08ebbf3a34a95d9b1e4a59d6
 upstream_url=https://pypi.io/packages/py3/d/docutils/docutils-VERSION-py3-none-any.whl
diff --git a/build/pkgs/dot2tex/checksums.ini b/build/pkgs/dot2tex/checksums.ini
index 2409245334f..c13d6f3489c 100644
--- a/build/pkgs/dot2tex/checksums.ini
+++ b/build/pkgs/dot2tex/checksums.ini
@@ -1,4 +1,3 @@
 tarball=dot2tex-VERSION.tar.gz
 sha1=5149c76e817b0592ea4dfd03f899495a394b8e90
-md5=b9ae1b7939409df221209098aaf11c97
-cksum=557736523
+sha256=e7205ed17edf7e8a7a816f13da5c74fd8b88e1ad42cc3975a6943a32f59ad55b
diff --git a/build/pkgs/dsdp/checksums.ini b/build/pkgs/dsdp/checksums.ini
index a82f4f651a8..da43d10edb8 100644
--- a/build/pkgs/dsdp/checksums.ini
+++ b/build/pkgs/dsdp/checksums.ini
@@ -1,5 +1,4 @@
 tarball=dsdp_VERSION.orig.tar.gz
 sha1=d80b072acf5396561809266ff1c93e7927697aeb
-md5=7f49a35f3fe7b5802d29ee2435fdb67e
-cksum=955095458
+sha256=de82af5e2daec70c8bf653ea4872108850bebea25238a799e78289ff88f88e06
 upstream_url=http://deb.debian.org/debian/pool/main/d/dsdp/dsdp_VERSION.orig.tar.gz
diff --git a/build/pkgs/e_antic/checksums.ini b/build/pkgs/e_antic/checksums.ini
index fe7fa852b76..f0afbce6ac8 100644
--- a/build/pkgs/e_antic/checksums.ini
+++ b/build/pkgs/e_antic/checksums.ini
@@ -1,5 +1,4 @@
 tarball=e-antic-VERSION.tar.gz
 sha1=587052e189f9a7a145ac3144e6b7f11fca54b1ff
-md5=0b54042461b28c4b45239480af062546
-cksum=589498373
+sha256=a38d2ab62c1b00fa2ee78f39039cc4d9d8e83de5fa5e2a18529ad34ab8976fe1
 upstream_url=https://github.com/flatsurf/e-antic/releases/download/VERSION/e-antic-VERSION.tar.gz
diff --git a/build/pkgs/ecl/checksums.ini b/build/pkgs/ecl/checksums.ini
index 1afa214fd26..169baeb6d6b 100644
--- a/build/pkgs/ecl/checksums.ini
+++ b/build/pkgs/ecl/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ecl-VERSION.tgz
 sha1=612f61f87eedb271025095306eca78d19f3991db
-md5=16bcfd2ce9730691f88e74edaab790af
-cksum=1542706373
+sha256=c51bdab4ca6c1173dd3fe9cfe9727bcefb97bb0a3d6434b627ca6bdaeb33f880
 upstream_url=https://common-lisp.net/project/ecl/static/files/release/ecl-VERSION.tgz
diff --git a/build/pkgs/eclib/checksums.ini b/build/pkgs/eclib/checksums.ini
index b6a7efd95aa..fde4faaee15 100644
--- a/build/pkgs/eclib/checksums.ini
+++ b/build/pkgs/eclib/checksums.ini
@@ -1,5 +1,4 @@
 tarball=eclib-VERSION.tar.bz2
 sha1=3028ac95e1b76699f5f9e871ac706cda363ab842
-md5=c96e1bb39a50552aeac6675b907709b8
-cksum=2027019032
+sha256=32d116a3e359b0de4f6486c2bb6188bb8b553c8b833f618cc2596484e8b6145a
 upstream_url=https://github.com/JohnCremona/eclib/releases/download/vVERSION/eclib-VERSION.tar.bz2
diff --git a/build/pkgs/ecm/checksums.ini b/build/pkgs/ecm/checksums.ini
index 20289bd49ec..f2221539308 100644
--- a/build/pkgs/ecm/checksums.ini
+++ b/build/pkgs/ecm/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ecm-VERSION.tar.gz
 sha1=f35d225d1d44f9b8ad420bf9b50a92582f681337
-md5=cfbb789d76cf538fc4dbb99d8e6e4b81
-cksum=2195620014
+sha256=c721dd22e557c4a5dac9ac7e156a400cd2298812dd1f9b56e89966de01471ba8
 upstream_url=https://gitlab.inria.fr/zimmerma/ecm/uploads/89f6f0d65d3e980cef33dc922004e4b2/ecm-VERSION.tar.gz
diff --git a/build/pkgs/ecos_python/checksums.ini b/build/pkgs/ecos_python/checksums.ini
index dc6d7b9a6f1..1b5791948e7 100644
--- a/build/pkgs/ecos_python/checksums.ini
+++ b/build/pkgs/ecos_python/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ecos-VERSION.tar.gz
 sha1=7afce63aec44522052e05fa2e1c82e12fe20fd45
-md5=a76939695aa07f8ab2f01a532732f348
-cksum=2810151369
+sha256=f48816d73b87ae325556ea537b7c8743187311403c80e3832035224156337c4e
 upstream_url=https://pypi.io/packages/source/e/ecos/ecos-VERSION.tar.gz
diff --git a/build/pkgs/editables/checksums.ini b/build/pkgs/editables/checksums.ini
index a3628c1c005..6470e5fd5d2 100644
--- a/build/pkgs/editables/checksums.ini
+++ b/build/pkgs/editables/checksums.ini
@@ -1,5 +1,4 @@
 tarball=editables-VERSION-py3-none-any.whl
 sha1=7aa90de86b05d6dc1a04c219b01ca7eab09de113
-md5=5de129d3a039b26b7f6798a4002acdf6
-cksum=24000838
+sha256=61e5ffa82629e0d8bfe09bc44a07db3c1ab8ed1ce78a6980732870f19b5e7d4c
 upstream_url=https://pypi.io/packages/py3/e/editables/editables-VERSION-py3-none-any.whl
diff --git a/build/pkgs/elliptic_curves/checksums.ini b/build/pkgs/elliptic_curves/checksums.ini
index 8af491ec7d4..687b7ae0e04 100644
--- a/build/pkgs/elliptic_curves/checksums.ini
+++ b/build/pkgs/elliptic_curves/checksums.ini
@@ -1,4 +1,3 @@
 tarball=elliptic_curves-VERSION.tar.bz2
 sha1=1eb0d332be1d05aaee70cd03cce7299a1df95953
-md5=315564f43d9272a2659f91355e6b1d16
-cksum=3923089644
+sha256=5fba5470d9d91f06282ed5edfc45bf0ea1c5f7c8d4837c46234b17be1481fd50
diff --git a/build/pkgs/entrypoints/checksums.ini b/build/pkgs/entrypoints/checksums.ini
index 88c67871e54..60bb1387477 100644
--- a/build/pkgs/entrypoints/checksums.ini
+++ b/build/pkgs/entrypoints/checksums.ini
@@ -1,5 +1,4 @@
 tarball=entrypoints-VERSION.tar.gz
 sha1=ca5c5976781db7ec6e8faece06af31ff32960529
-md5=3acd8b72119a8fb1eac7030c24ac6b49
-cksum=3193499805
+sha256=b706eddaa9218a19ebcd67b56818f05bb27589b1ca9e8d797b74affad4ccacd4
 upstream_url=https://pypi.io/packages/source/e/entrypoints/entrypoints-VERSION.tar.gz
diff --git a/build/pkgs/exceptiongroup/checksums.ini b/build/pkgs/exceptiongroup/checksums.ini
index 1ca0c50d46d..ef04b565062 100644
--- a/build/pkgs/exceptiongroup/checksums.ini
+++ b/build/pkgs/exceptiongroup/checksums.ini
@@ -1,5 +1,4 @@
 tarball=exceptiongroup-VERSION-py3-none-any.whl
 sha1=e69c438e6d15111c4f7cc18224b31a42a58663da
-md5=d252c64173c449dc34654e7be8211744
-cksum=527795480
+sha256=4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14
 upstream_url=https://pypi.io/packages/py3/e/exceptiongroup/exceptiongroup-VERSION-py3-none-any.whl
diff --git a/build/pkgs/executing/checksums.ini b/build/pkgs/executing/checksums.ini
index 71e107aafbe..5add559f690 100644
--- a/build/pkgs/executing/checksums.ini
+++ b/build/pkgs/executing/checksums.ini
@@ -1,5 +1,4 @@
 tarball=executing-VERSION.tar.gz
 sha1=ac9b0cbedd1166bce7a3b9f8542f8d1fafdd8c73
-md5=e6fa9a6abf00555ccc8a6b3524729238
-cksum=1761713270
+sha256=19da64c18d2d851112f09c287f8d3dbbdf725ab0e569077efb6cdcbd3497c107
 upstream_url=https://pypi.io/packages/source/e/executing/executing-VERSION.tar.gz
diff --git a/build/pkgs/fastjsonschema/checksums.ini b/build/pkgs/fastjsonschema/checksums.ini
index 3df871d077a..ae58c4c8577 100644
--- a/build/pkgs/fastjsonschema/checksums.ini
+++ b/build/pkgs/fastjsonschema/checksums.ini
@@ -1,5 +1,4 @@
 tarball=fastjsonschema-VERSION.tar.gz
 sha1=eab76262783dd81303e2b1da0914a1d5a7f388aa
-md5=4dd3d7946af566fc32e30f0768cddae3
-cksum=2794560071
+sha256=e820349dd16f806e4bd1467a138dced9def4bc7d6213a34295272a6cac95b5bd
 upstream_url=https://pypi.io/packages/source/f/fastjsonschema/fastjsonschema-VERSION.tar.gz
diff --git a/build/pkgs/fflas_ffpack/checksums.ini b/build/pkgs/fflas_ffpack/checksums.ini
index 1a5cdcee74b..21dfdb5bcf9 100644
--- a/build/pkgs/fflas_ffpack/checksums.ini
+++ b/build/pkgs/fflas_ffpack/checksums.ini
@@ -1,5 +1,4 @@
-tarball=fflas_ffpack-VERSION.tar.bz2
-sha1=7c5faa81abc2b88ec24cec373b5e44cbaa7844dd
-md5=d8b7c113951a2a3f498a3aaadbe5620f
-cksum=3321469120
-upstream_url=https://github.com/linbox-team/fflas-ffpack/releases/download/vVERSION/fflas_ffpack-VERSION.tar.bz2
\ No newline at end of file
+tarball=fflas_ffpack-VERSION.tar.gz
+sha1=0beadd30b01dc5c890679aff73818a681513e82e
+sha256=12f79262c0971ee7ca93134785b610b128dc855c0bb840471d9eea57dd1778b3
+upstream_url=https://github.com/mkoeppe/fflas-ffpack/releases/download/v2.5.0%2Bsage-2024-05-18b/fflas-ffpack-2.5.0.tar.gz
diff --git a/build/pkgs/fflas_ffpack/package-version.txt b/build/pkgs/fflas_ffpack/package-version.txt
index 437459cd94c..2d33e69f32b 100644
--- a/build/pkgs/fflas_ffpack/package-version.txt
+++ b/build/pkgs/fflas_ffpack/package-version.txt
@@ -1 +1 @@
-2.5.0
+2.5.0+sage-2024-05-18b
diff --git a/build/pkgs/filelock/checksums.ini b/build/pkgs/filelock/checksums.ini
index 6c597d2d7aa..330f4d53a36 100644
--- a/build/pkgs/filelock/checksums.ini
+++ b/build/pkgs/filelock/checksums.ini
@@ -1,5 +1,4 @@
 tarball=filelock-VERSION-py3-none-any.whl
 sha1=f1fa92751023660a10b248f8559d09f3c461403f
-md5=d0af0f1a2ee56c24f630ece278cb062f
-cksum=3749691502
+sha256=57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c
 upstream_url=https://pypi.io/packages/py3/f/filelock/filelock-VERSION-py3-none-any.whl
diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
index ab836606657..804f58da22a 100644
--- a/build/pkgs/flint/checksums.ini
+++ b/build/pkgs/flint/checksums.ini
@@ -1,5 +1,4 @@
 tarball=flint-VERSION.tar.gz
-sha1=65be9297c06edd7e24f20874b7bd6130cee56723
-md5=5189f67b0ec12e4a54d6782851642b81
-cksum=172350473
+sha1=35af6e2de8765a841952438f3c915d0505b983b6
+sha256=3259e5ecbb07ea3bebeff025f846a494087be92b0aaf0636d6e36128963cadda
 upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
index cb2b00e4f7a..ff365e06b95 100644
--- a/build/pkgs/flint/package-version.txt
+++ b/build/pkgs/flint/package-version.txt
@@ -1 +1 @@
-3.0.1
+3.1.3
diff --git a/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
deleted file mode 100644
index 48a32f5d894..00000000000
--- a/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-From 54277f054f13254898c9a57c2c7eb869877e1252 Mon Sep 17 00:00:00 2001
-From: Marc Mezzarobba 
-Date: Mon, 13 Nov 2023 10:23:54 +0100
-Subject: [PATCH] Makefile.in: fix handling of $DESTDIR
-
----
- Makefile.in | 54 ++++++++++++++++++++++++++---------------------------
- 1 file changed, 27 insertions(+), 27 deletions(-)
-
-diff --git a/Makefile.in b/Makefile.in
-index 08db6837c..2827b9da1 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -34,9 +34,9 @@ FLINT_SOLIB:=@FLINT_SOLIB@
- prefix:=@prefix@
- exec_prefix:=@exec_prefix@
- 
--INCLUDEDIR:=$(DESTDIR)@includedir@
--LIBDIR:=$(DESTDIR)@libdir@
--BINDIR:=$(DESTDIR)@bindir@
-+INCLUDEDIR:=@includedir@
-+LIBDIR:=@libdir@
-+BINDIR:=@bindir@
- PKGCONFIGDIR:=$(LIBDIR)/pkgconfig
- 
- HOST_OS:=@host_os@
-@@ -202,10 +202,10 @@ BUILD_DIRS +=                                                               \
- endif
- 
- INSTALL_DIRS :=                                                             \
--        $(LIBDIR)                       $(INCLUDEDIR)/flint                 \
--        $(PKGCONFIGDIR)
-+        $(DESTDIR)$(LIBDIR)             $(DESTDIR)$(INCLUDEDIR)/flint       \
-+        $(DESTDIR)$(PKGCONFIGDIR)
- ifneq ($(FLINT_DLLLIB),0)
--INSTALL_DIRS += $(BINDIR)
-+INSTALL_DIRS += $(DESTDIR)$(BINDIR)
- endif
- 
- ################################################################################
-@@ -722,41 +722,41 @@ distclean: clean
- ################################################################################
- 
- install: library | $(INSTALL_DIRS)
--	$(CP) flint.pc $(PKGCONFIGDIR)/flint.pc
-+	$(CP) flint.pc $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
- ifneq ($(SHARED), 0)
- ifneq ($(FLINT_DLLLIB),0)
--	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(BINDIR)
--	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(BINDIR)
--	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BINDIR)
--	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(LIBDIR)
-+	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(BINDIR)
-+	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(BINDIR)
-+	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(BINDIR)
-+	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(DESTDIR)$(LIBDIR)
- else
--	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(LIBDIR)
--	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(LIBDIR)
--	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(LIBDIR)
-+	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(LIBDIR)
-+	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(LIBDIR)
-+	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)
- endif
- ifneq ($(FLINT_DYLIB),0)
--	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(LIBDIR)/$(FLINT_LIB)
-+	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
- endif
- endif
- ifneq ($(STATIC), 0)
--	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(LIBDIR)
-+	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(DESTDIR)$(LIBDIR)
- endif
--	$(CP) $(HEADERS) $(INCLUDEDIR)/flint
-+	$(CP) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/flint
- 
- uninstall:
--	$(RM_F) $(PKGCONFIGDIR)/flint.pc
-+	$(RM_F) $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
- ifneq ($(FLINT_DLLLIB),0)
--	$(RM_F) $(BINDIR)/$(FLINT_LIB)
--	$(RM_F) $(BINDIR)/$(FLINT_LIB_MAJOR)
--	$(RM_F) $(BINDIR)/$(FLINT_LIB_FULL)
--	$(RM_F) $(LIBDIR)/$(FLINT_IMPLIB)
-+	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB)
-+	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_MAJOR)
-+	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_FULL)
-+	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_IMPLIB)
- else
--	$(RM_F) $(LIBDIR)/$(FLINT_LIB)
--	$(RM_F) $(LIBDIR)/$(FLINT_LIB_MAJOR)
--	$(RM_F) $(LIBDIR)/$(FLINT_LIB_FULL)
-+	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
-+	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_MAJOR)
-+	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_FULL)
- endif
--	$(RM_F) $(LIBDIR)/$(FLINT_LIB_STATIC)
--	$(RM_RF) $(INCLUDEDIR)/flint
-+	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_STATIC)
-+	$(RM_RF) $(DESTDIR)$(INCLUDEDIR)/flint
- 
- ################################################################################
- # maintainer stuff
--- 
-2.42.0
-
diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
index 4c1a347152d..98350eb483d 100644
--- a/build/pkgs/flint/spkg-configure.m4
+++ b/build/pkgs/flint/spkg-configure.m4
@@ -1,6 +1,6 @@
 SAGE_SPKG_CONFIGURE([flint], [
     SAGE_SPKG_DEPCHECK([mpfr], [
-        AC_CHECK_HEADER(flint/flint.h, [dnl
+        AC_CHECK_HEADERS([flint/flint.h flint/padic.h], [dnl
           dnl gr_get_fexpr appears in Flint 3.0
           AC_SEARCH_LIBS([gr_get_fexpr], [flint], [dnl
             dnl Assume Flint 3.2 is too new
diff --git a/build/pkgs/flit_core/checksums.ini b/build/pkgs/flit_core/checksums.ini
index b93e9200816..0a40b9891b2 100644
--- a/build/pkgs/flit_core/checksums.ini
+++ b/build/pkgs/flit_core/checksums.ini
@@ -1,5 +1,4 @@
 tarball=flit_core-VERSION-py3-none-any.whl
 sha1=cf044db53e986d0735ad708cce9eba0b71684168
-md5=c817750ae741d8f720b173a30f7b2085
-cksum=1810686358
+sha256=7aada352fb0c7f5538c4fafeddf314d3a6a92ee8e2b1de70482329e42de70301
 upstream_url=https://pypi.io/packages/py3/f/flit_core/flit_core-VERSION-py3-none-any.whl
diff --git a/build/pkgs/fonttools/checksums.ini b/build/pkgs/fonttools/checksums.ini
index b0aa6d12927..7cb3b54ce86 100644
--- a/build/pkgs/fonttools/checksums.ini
+++ b/build/pkgs/fonttools/checksums.ini
@@ -1,5 +1,4 @@
 tarball=fonttools-VERSION.tar.gz
 sha1=5432f0273040b044e8d6465947e3a4c00097bdbf
-md5=039956b85e9b84ba53373b0df644f5ad
-cksum=3441365368
+sha256=c391cd5af88aacaf41dd7cfb96eeedfad297b5899a39e12f4c2c3706d0a3329d
 upstream_url=https://pypi.io/packages/source/f/fonttools/fonttools-VERSION.tar.gz
diff --git a/build/pkgs/fplll/checksums.ini b/build/pkgs/fplll/checksums.ini
index 5f9ec9753be..7ad5ac91a3b 100644
--- a/build/pkgs/fplll/checksums.ini
+++ b/build/pkgs/fplll/checksums.ini
@@ -1,5 +1,4 @@
 tarball=fplll-VERSION.tar.gz
 sha1=607f5922109d93ddd5a05419682511e26579f9d6
-md5=fa4e1f24994c0345a9530397a3369b27
-cksum=4174005926
+sha256=76d3778f0326597ed7505bab19493a9bf6b73a5c5ca614e8fb82f42105c57d00
 upstream_url=https://github.com/fplll/fplll/releases/download/VERSION/fplll-VERSION.tar.gz
diff --git a/build/pkgs/fpylll/checksums.ini b/build/pkgs/fpylll/checksums.ini
index 156fc587670..5cbc7e3bc08 100644
--- a/build/pkgs/fpylll/checksums.ini
+++ b/build/pkgs/fpylll/checksums.ini
@@ -1,5 +1,4 @@
 tarball=fpylll-VERSION.tar.gz
 sha1=f23835208fc048028c849bb5b566f2fe631df7f4
-md5=c81a1af8ecf57ae740366a110dfbbbaf
-cksum=398170701
+sha256=623b4619b6da9fed9ba26b1ac7e8d8e620a06d2a5f7095ee67985c7160d3c3a4
 upstream_url=https://pypi.io/packages/source/f/fpylll/fpylll-VERSION.tar.gz
diff --git a/build/pkgs/fqdn/checksums.ini b/build/pkgs/fqdn/checksums.ini
index 423dc55e68f..2e3cdea93c6 100644
--- a/build/pkgs/fqdn/checksums.ini
+++ b/build/pkgs/fqdn/checksums.ini
@@ -1,5 +1,4 @@
 tarball=fqdn-VERSION-py3-none-any.whl
 sha1=85a7ac7d7f45d2e0b64c4b7653ab277ceec91ecf
-md5=376c19af0cd5029cd8b36d1042a1490e
-cksum=4276482151
+sha256=3a179af3761e4df6eb2e026ff9e1a3033d3587bf980a0b1b2e1e5d08d7358014
 upstream_url=https://pypi.io/packages/py3/f/fqdn/fqdn-VERSION-py3-none-any.whl
diff --git a/build/pkgs/freetype/checksums.ini b/build/pkgs/freetype/checksums.ini
index 704e1b370d5..150769930c2 100644
--- a/build/pkgs/freetype/checksums.ini
+++ b/build/pkgs/freetype/checksums.ini
@@ -1,5 +1,4 @@
 tarball=freetype-VERSION.tar.bz2
 sha1=040d6a4be23708132c85ef9df837eb3f8a04c4ab
-md5=4934a8b61b636920bcce58e7c7f3e1a2
-cksum=2814275332
+sha256=5eab795ebb23ac77001cfb68b7d4d50b5d6c7469247b0b01b2c953269f658dac
 upstream_url=https://download.savannah.gnu.org/releases/freetype/freetype-VERSION.tar.gz
diff --git a/build/pkgs/fricas/checksums.ini b/build/pkgs/fricas/checksums.ini
index a06136db04e..1790c649eb3 100644
--- a/build/pkgs/fricas/checksums.ini
+++ b/build/pkgs/fricas/checksums.ini
@@ -1,5 +1,4 @@
 tarball=fricas-VERSION-full.tar.bz2
 sha1=2f1e1bbbad7e04a7114ffbd93eeedadc5db32272
-md5=d2ecd6f8c45cfc41c407b7d5f6eaae07
-cksum=1256005675
+sha256=fc2112ad45ba7b45ac423165f32bd5b244622107a1e4e1d56b9136f96746f2a0
 upstream_url=https://github.com/fricas/fricas/releases/download/VERSION/fricas-VERSION-full.tar.bz2
diff --git a/build/pkgs/frobby/checksums.ini b/build/pkgs/frobby/checksums.ini
index 8d2575db5d2..ebdefdefd9c 100644
--- a/build/pkgs/frobby/checksums.ini
+++ b/build/pkgs/frobby/checksums.ini
@@ -1,4 +1,3 @@
 tarball=frobby_v0.9.0.tar.gz
 sha1=513b6e2ef8e8670c0518d168c2e554df1f8d79b4
-md5=2204f340dad8fb7be156f9f7c403c4a0
-cksum=2889611419
+sha256=af092383e6dc849c86f4e79747ae0e5cd309a690747230e10aa38d60640062df
diff --git a/build/pkgs/furo/checksums.ini b/build/pkgs/furo/checksums.ini
index e9219c0b481..b6feae79dad 100644
--- a/build/pkgs/furo/checksums.ini
+++ b/build/pkgs/furo/checksums.ini
@@ -1,5 +1,4 @@
 tarball=furo-VERSION-py3-none-any.whl
 sha1=21afca1ac0f309541bfd5b89e61097a1bd4b681e
-md5=a7c552d8bc7b504b528414043f91671b
-cksum=2089555908
+sha256=513092538537dc5c596691da06e3c370714ec99bc438680edc1debffb73e5bfc
 upstream_url=https://pypi.io/packages/py3/f/furo/furo-VERSION-py3-none-any.whl
diff --git a/build/pkgs/gap/checksums.ini b/build/pkgs/gap/checksums.ini
index b0ea8ba8818..2b1170e52d9 100644
--- a/build/pkgs/gap/checksums.ini
+++ b/build/pkgs/gap/checksums.ini
@@ -1,5 +1,4 @@
 tarball=gap-VERSION.tar.gz
 sha1=a6e36f3f874a2c46f51561402634497eab705cca
-md5=c5cd9f272f2703d7a3649ad7193b2d90
-cksum=2760477284
+sha256=672308745eb78a222494ee8dd6786edd5bc331456fcc6456ac064bdb28d587a8
 upstream_url=https://github.com/gap-system/gap/releases/download/vVERSION/gap-VERSION.tar.gz
diff --git a/build/pkgs/gap3/checksums.ini b/build/pkgs/gap3/checksums.ini
index 93a6920959a..1d5e624ad83 100644
--- a/build/pkgs/gap3/checksums.ini
+++ b/build/pkgs/gap3/checksums.ini
@@ -1,4 +1,3 @@
 tarball=gap3-VERSION.tar.gz
 sha1=c730fb20e850fc5d4ac98569d717d20967e88086
-md5=edc04e9080e4b020400deb5d90e5a528
-cksum=3976232974
+sha256=07d90b63f504c67bb463fad470544d18619e25539fec7cfb74343a1a982d3b75
diff --git a/build/pkgs/gap_jupyter/checksums.ini b/build/pkgs/gap_jupyter/checksums.ini
index fcea05efa44..e873f263973 100644
--- a/build/pkgs/gap_jupyter/checksums.ini
+++ b/build/pkgs/gap_jupyter/checksums.ini
@@ -1,4 +1,3 @@
 tarball=jupyter-kernel-gap-VERSION.tar.gz
 sha1=9536aa352c6dee815ae5179e3971bfb9216f8eda
-md5=f5853cc8cd62ce495be8d3c8bdb2500f
-cksum=3578940226
+sha256=8c62f3c290ac6eea94e4f1d35067b74261eea67c400b0aaa8d1f9451df0e963f
diff --git a/build/pkgs/gast/checksums.ini b/build/pkgs/gast/checksums.ini
index 57bc0736a13..6035bc7c22d 100644
--- a/build/pkgs/gast/checksums.ini
+++ b/build/pkgs/gast/checksums.ini
@@ -1,5 +1,4 @@
 tarball=gast-VERSION.tar.gz
 sha1=6c113cf8d33cc654d33210335103485ab41d3dbb
-md5=907c689e3fdbc7a48cc010e665195baa
-cksum=218846575
+sha256=9c270fe5f4b130969b54174de7db4e764b09b4f7f67ccfc32480e29f78348d97
 upstream_url=https://pypi.io/packages/source/g/gast/gast-VERSION.tar.gz
diff --git a/build/pkgs/gc/checksums.ini b/build/pkgs/gc/checksums.ini
index 81825b73703..ede35b376a2 100644
--- a/build/pkgs/gc/checksums.ini
+++ b/build/pkgs/gc/checksums.ini
@@ -1,5 +1,4 @@
 tarball=gc-VERSION.tar.gz
 sha1=3f543532c47e592a8f5ea6f7a529c8ed7465a5c7
-md5=fc5351214bc2e854070ee3319181a467
-cksum=2567761321
+sha256=b9183fe49d4c44c7327992f626f8eaa1d8b14de140f243edb1c9dcff7719a7fc
 upstream_url=https://github.com/ivmai/bdwgc/releases/download/vVERSION/gc-VERSION.tar.gz
diff --git a/build/pkgs/gcc/checksums.ini b/build/pkgs/gcc/checksums.ini
index 996f8360f45..272d516f07d 100644
--- a/build/pkgs/gcc/checksums.ini
+++ b/build/pkgs/gcc/checksums.ini
@@ -1,5 +1,4 @@
 tarball=gcc-VERSION.tar.xz
-sha1=5dce6dc0091b8049b530d1587513a07201691760
-md5=73bafd0af874439dcdb9fc063b6fb069
-cksum=2807184004
+sha1=5f95b6d042fb37d45c6cbebfc91decfbc4fb493c
+sha256=e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da
 upstream_url=https://mirrors.kernel.org/gnu/gcc/gcc-VERSION/gcc-VERSION.tar.xz
diff --git a/build/pkgs/gcc/package-version.txt b/build/pkgs/gcc/package-version.txt
index 685332623b2..67aee23940e 100644
--- a/build/pkgs/gcc/package-version.txt
+++ b/build/pkgs/gcc/package-version.txt
@@ -1 +1 @@
-12.2.0
+13.2.0
diff --git a/build/pkgs/gcc/patches/68057560ff1fc0fb2df38c2f9627a20c9a8da5c5.patch b/build/pkgs/gcc/patches/68057560ff1fc0fb2df38c2f9627a20c9a8da5c5.patch
new file mode 100644
index 00000000000..0672eb2936e
--- /dev/null
+++ b/build/pkgs/gcc/patches/68057560ff1fc0fb2df38c2f9627a20c9a8da5c5.patch
@@ -0,0 +1,138 @@
+From: Francois-Xavier Coudert 
+Date: Thu, 7 Mar 2024 13:36:03 +0000 (+0100)
+Subject: Include safe-ctype.h after C++ standard headers, to avoid over-poisoning
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=68057560ff1fc0fb2df38c2f9627a20c9a8da5c5
+
+Include safe-ctype.h after C++ standard headers, to avoid over-poisoning
+
+When building gcc's C++ sources against recent libc++, the poisoning of
+the ctype macros due to including safe-ctype.h before including C++
+standard headers such as , , etc, causes many compilation
+errors, similar to:
+
+  In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23:
+  In file included from /home/dim/src/gcc/master/gcc/system.h:233:
+  In file included from /usr/include/c++/v1/vector:321:
+  In file included from
+  /usr/include/c++/v1/__format/formatter_bool.h:20:
+  In file included from
+  /usr/include/c++/v1/__format/formatter_integral.h:32:
+  In file included from /usr/include/c++/v1/locale:202:
+  /usr/include/c++/v1/__locale:546:5: error: '__abi_tag__' attribute
+  only applies to structs, variables, functions, and namespaces
+    546 |     _LIBCPP_INLINE_VISIBILITY
+        |     ^
+  /usr/include/c++/v1/__config:813:37: note: expanded from macro
+  '_LIBCPP_INLINE_VISIBILITY'
+    813 | #  define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
+        |                                     ^
+  /usr/include/c++/v1/__config:792:26: note: expanded from macro
+  '_LIBCPP_HIDE_FROM_ABI'
+    792 |
+    __attribute__((__abi_tag__(_LIBCPP_TOSTRING(
+  _LIBCPP_VERSIONED_IDENTIFIER))))
+        |                          ^
+  In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23:
+  In file included from /home/dim/src/gcc/master/gcc/system.h:233:
+  In file included from /usr/include/c++/v1/vector:321:
+  In file included from
+  /usr/include/c++/v1/__format/formatter_bool.h:20:
+  In file included from
+  /usr/include/c++/v1/__format/formatter_integral.h:32:
+  In file included from /usr/include/c++/v1/locale:202:
+  /usr/include/c++/v1/__locale:547:37: error: expected ';' at end of
+  declaration list
+    547 |     char_type toupper(char_type __c) const
+        |                                     ^
+  /usr/include/c++/v1/__locale:553:48: error: too many arguments
+  provided to function-like macro invocation
+    553 |     const char_type* toupper(char_type* __low, const
+    char_type* __high) const
+        |                                                ^
+  /home/dim/src/gcc/master/gcc/../include/safe-ctype.h:146:9: note:
+  macro 'toupper' defined here
+    146 | #define toupper(c) do_not_use_toupper_with_safe_ctype
+        |         ^
+
+This is because libc++ uses different transitive includes than
+libstdc++, and some of those transitive includes pull in various ctype
+declarations (typically via ).
+
+There was already a special case for including  before
+safe-ctype.h, so move the rest of the C++ standard header includes to
+the same location, to fix the problem.
+
+	PR middle-end/111632
+
+gcc/ChangeLog:
+
+	* system.h: Include safe-ctype.h after C++ standard headers.
+
+Signed-off-by: Dimitry Andric 
+(cherry picked from commit 9970b576b7e4ae337af1268395ff221348c4b34a)
+---
+
+diff --git a/gcc/system.h b/gcc/system.h
+index 33e9d4211150..03ab33ac960f 100644
+--- a/gcc/system.h
++++ b/gcc/system.h
+@@ -194,27 +194,8 @@ extern int fprintf_unlocked (FILE *, const char *, ...);
+ #undef fread_unlocked
+ #undef fwrite_unlocked
+ 
+-/* Include  before "safe-ctype.h" to avoid GCC poisoning
+-   the ctype macros through safe-ctype.h */
+-
+-#ifdef __cplusplus
+-#ifdef INCLUDE_STRING
+-# include 
+-#endif
+-#endif
+-
+-/* There are an extraordinary number of issues with .
+-   The last straw is that it varies with the locale.  Use libiberty's
+-   replacement instead.  */
+-#include "safe-ctype.h"
+-
+-#include 
+-
+-#include 
+-
+-#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
+-extern int errno;
+-#endif
++/* Include C++ standard headers before "safe-ctype.h" to avoid GCC
++   poisoning the ctype macros through safe-ctype.h */
+ 
+ #ifdef __cplusplus
+ #if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY)
+@@ -229,6 +210,9 @@ extern int errno;
+ #ifdef INCLUDE_SET
+ # include 
+ #endif
++#ifdef INCLUDE_STRING
++# include 
++#endif
+ #ifdef INCLUDE_VECTOR
+ # include 
+ #endif
+@@ -245,6 +229,19 @@ extern int errno;
+ # include 
+ #endif
+ 
++/* There are an extraordinary number of issues with .
++   The last straw is that it varies with the locale.  Use libiberty's
++   replacement instead.  */
++#include "safe-ctype.h"
++
++#include 
++
++#include 
++
++#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
++extern int errno;
++#endif
++
+ /* Some of glibc's string inlines cause warnings.  Plus we'd rather
+    rely on (and therefore test) GCC's string builtins.  */
+ #define __NO_STRING_INLINES
diff --git a/build/pkgs/gcc/patches/e95ab9e60ce1d9aa7751d79291133fd5af9209d7.patch b/build/pkgs/gcc/patches/e95ab9e60ce1d9aa7751d79291133fd5af9209d7.patch
new file mode 100644
index 00000000000..6fb61b58ed2
--- /dev/null
+++ b/build/pkgs/gcc/patches/e95ab9e60ce1d9aa7751d79291133fd5af9209d7.patch
@@ -0,0 +1,64 @@
+From: Francois-Xavier Coudert 
+Date: Sat, 16 Mar 2024 08:50:00 +0000 (+0100)
+Subject: libcc1: fix  include
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=e95ab9e60ce1d9aa7751d79291133fd5af9209d7
+
+libcc1: fix  include
+
+Use INCLUDE_VECTOR before including system.h, instead of directly
+including , to avoid running into poisoned identifiers.
+
+Signed-off-by: Dimitry Andric 
+
+	PR middle-end/111632
+
+libcc1/ChangeLog:
+
+	* libcc1plugin.cc: Fix include.
+	* libcp1plugin.cc: Fix include.
+
+(cherry picked from commit 5213047b1d50af63dfabb5e5649821a6cb157e33)
+---
+
+diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc
+index 7e0fecae1456..44bcf56698ee 100644
+--- a/libcc1/libcc1plugin.cc
++++ b/libcc1/libcc1plugin.cc
+@@ -32,6 +32,7 @@
+ #undef PACKAGE_VERSION
+ 
+ #define INCLUDE_MEMORY
++#define INCLUDE_VECTOR
+ #include "gcc-plugin.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -69,8 +70,6 @@
+ #include "gcc-c-interface.h"
+ #include "context.hh"
+ 
+-#include 
+-
+ using namespace cc1_plugin;
+ 
+ 
+diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc
+index 8d394c0cfdb8..9586a2afdb47 100644
+--- a/libcc1/libcp1plugin.cc
++++ b/libcc1/libcp1plugin.cc
+@@ -33,6 +33,7 @@
+ #undef PACKAGE_VERSION
+ 
+ #define INCLUDE_MEMORY
++#define INCLUDE_VECTOR
+ #include "gcc-plugin.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -71,8 +72,6 @@
+ #include "rpc.hh"
+ #include "context.hh"
+ 
+-#include 
+-
+ using namespace cc1_plugin;
+ 
+ 
diff --git a/build/pkgs/gcc/patches/gcc-13-homebrew.patch b/build/pkgs/gcc/patches/gcc-13-homebrew.patch
new file mode 100644
index 00000000000..8cedce8bc46
--- /dev/null
+++ b/build/pkgs/gcc/patches/gcc-13-homebrew.patch
@@ -0,0 +1,71 @@
+Patch included in https://github.com/Homebrew/homebrew-core/blob/50d9d78a4a09b42807b0a8f74f1f2f8933051a7b/Formula/g/gcc@13.rb
+
+diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
+index 416d2c2e3a4..e52f11d8460 100644
+--- a/fixincludes/fixincl.x
++++ b/fixincludes/fixincl.x
+@@ -2,11 +2,11 @@
+  *
+  * DO NOT EDIT THIS FILE   (fixincl.x)
+  *
+- * It has been AutoGen-ed  January 22, 2023 at 09:03:29 PM by AutoGen 5.18.12
++ * It has been AutoGen-ed  August 17, 2023 at 10:16:38 AM by AutoGen 5.18.12
+  * From the definitions    inclhack.def
+  * and the template file   fixincl
+  */
+-/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Jan 22 21:03:29 CET 2023
++/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Aug 17 10:16:38 CEST 2023
+  *
+  * You must regenerate it.  Use the ./genfixes script.
+  *
+@@ -3674,7 +3674,7 @@ tSCC* apzDarwin_Flt_Eval_MethodMachs[] = {
+  *  content selection pattern - do fix if pattern found
+  */
+ tSCC zDarwin_Flt_Eval_MethodSelect0[] =
+-       "^#if __FLT_EVAL_METHOD__ == 0$";
++       "^#if __FLT_EVAL_METHOD__ == 0( \\|\\| __FLT_EVAL_METHOD__ == -1)?$";
+ 
+ #define    DARWIN_FLT_EVAL_METHOD_TEST_CT  1
+ static tTestDesc aDarwin_Flt_Eval_MethodTests[] = {
+@@ -3685,7 +3685,7 @@ static tTestDesc aDarwin_Flt_Eval_MethodTests[] = {
+  */
+ static const char* apzDarwin_Flt_Eval_MethodPatch[] = {
+     "format",
+-    "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16",
++    "%0 || __FLT_EVAL_METHOD__ == 16",
+     (char*)NULL };
+ 
+ /* * * * * * * * * * * * * * * * * * * * * * * * * *
+diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
+index 45e0cbc0c10..19e0ea2df66 100644
+--- a/fixincludes/inclhack.def
++++ b/fixincludes/inclhack.def
+@@ -1819,10 +1819,11 @@ fix = {
+     hackname  = darwin_flt_eval_method;
+     mach      = "*-*-darwin*";
+     files     = math.h;
+-    select    = "^#if __FLT_EVAL_METHOD__ == 0$";
++    select    = "^#if __FLT_EVAL_METHOD__ == 0( \\|\\| __FLT_EVAL_METHOD__ == -1)?$";
+     c_fix     = format;
+-    c_fix_arg = "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16";
+-    test_text = "#if __FLT_EVAL_METHOD__ == 0";
++    c_fix_arg = "%0 || __FLT_EVAL_METHOD__ == 16";
++    test_text = "#if __FLT_EVAL_METHOD__ == 0\n"
++		"#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1";
+ };
+ 
+ /*
+diff --git a/fixincludes/tests/base/math.h b/fixincludes/tests/base/math.h
+index 29b67579748..7b92f29a409 100644
+--- a/fixincludes/tests/base/math.h
++++ b/fixincludes/tests/base/math.h
+@@ -32,6 +32,7 @@
+ 
+ #if defined( DARWIN_FLT_EVAL_METHOD_CHECK )
+ #if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16
++#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1 || __FLT_EVAL_METHOD__ == 16
+ #endif  /* DARWIN_FLT_EVAL_METHOD_CHECK */
+ 
+ 
+-- 
+2.39.3
diff --git a/build/pkgs/gcc/patches/gcc-12.2.0-arm.patch b/build/pkgs/gcc/patches/gcc-13.2.0-arm.patch
similarity index 52%
rename from build/pkgs/gcc/patches/gcc-12.2.0-arm.patch
rename to build/pkgs/gcc/patches/gcc-13.2.0-arm.patch
index bcaade28c15..0a3688f7d90 100644
--- a/build/pkgs/gcc/patches/gcc-12.2.0-arm.patch
+++ b/build/pkgs/gcc/patches/gcc-13.2.0-arm.patch
@@ -1,5 +1,5 @@
 diff --git a/Makefile.def b/Makefile.def
-index 72d58549645..25b8563a808 100644
+index 35e994eb77e..9b4a8a2bf7a 100644
 --- a/Makefile.def
 +++ b/Makefile.def
 @@ -47,7 +47,8 @@ host_modules= { module= fixincludes; bootstrap=true;
@@ -8,181 +8,256 @@ index 72d58549645..25b8563a808 100644
  host_modules= { module= gcc; bootstrap=true; 
 -		extra_make_flags="$(EXTRA_GCC_FLAGS)"; };
 +		extra_make_flags="$(EXTRA_GCC_FLAGS)";
-+		extra_configure_flags='--enable-pie-tools=@enable_pie_tools@'; };
++		extra_configure_flags='@gcc_host_pie@'; };
  host_modules= { module= gmp; lib_path=.libs; bootstrap=true;
  		// Work around in-tree gmp configure bug with missing flex.
- 		extra_configure_flags='--disable-shared LEX="touch lex.yy.c"';
+ 		extra_configure_flags='--disable-shared LEX="touch lex.yy.c" @host_libs_picflag@';
 diff --git a/Makefile.in b/Makefile.in
-index 593495e1650..807c5947895 100644
+index 06a9398e172..0973ec3a71d 100644
 --- a/Makefile.in
 +++ b/Makefile.in
-@@ -112,6 +112,9 @@ GCC_SHLIB_SUBDIR = @GCC_SHLIB_SUBDIR@
- # If the build should make suitable code for shared host resources.
- host_shared = @host_shared@
- 
-+# If we should build compilers and supporting tools as PIE.
-+enable_pie_tools = @enable_pie_tools@
-+
- # Build programs are put under this directory.
- BUILD_SUBDIR = @build_subdir@
- # This is set by the configure script to the arguments to use when configuring
-@@ -12012,7 +12015,7 @@ configure-gcc:
+@@ -12016,7 +12016,7 @@ configure-gcc:
  	  $$s/$$module_srcdir/configure \
  	  --srcdir=$${topdir}/$$module_srcdir \
  	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
 -	  --target=${target_alias}  \
-+	  --target=${target_alias} --enable-pie-tools=@enable_pie_tools@ \
++	  --target=${target_alias} @gcc_host_pie@ \
  	  || exit 1
  @endif gcc
  
-@@ -12047,7 +12050,8 @@ configure-stage1-gcc:
+@@ -12051,7 +12051,8 @@ configure-stage1-gcc:
  	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
  	  --target=${target_alias} \
  	   \
 -	  $(STAGE1_CONFIGURE_FLAGS)
 +	  $(STAGE1_CONFIGURE_FLAGS) \
-+	  --enable-pie-tools=@enable_pie_tools@
++	  @gcc_host_pie@
  @endif gcc-bootstrap
  
  .PHONY: configure-stage2-gcc maybe-configure-stage2-gcc
-@@ -12080,7 +12084,8 @@ configure-stage2-gcc:
+@@ -12084,7 +12085,8 @@ configure-stage2-gcc:
  	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
  	  --target=${target_alias} \
  	  --with-build-libsubdir=$(HOST_SUBDIR) \
 -	  $(STAGE2_CONFIGURE_FLAGS)
 +	  $(STAGE2_CONFIGURE_FLAGS) \
-+	  --enable-pie-tools=@enable_pie_tools@
++	  @gcc_host_pie@
  @endif gcc-bootstrap
  
  .PHONY: configure-stage3-gcc maybe-configure-stage3-gcc
-@@ -12113,7 +12118,8 @@ configure-stage3-gcc:
+@@ -12117,7 +12119,8 @@ configure-stage3-gcc:
  	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
  	  --target=${target_alias} \
  	  --with-build-libsubdir=$(HOST_SUBDIR) \
 -	  $(STAGE3_CONFIGURE_FLAGS)
 +	  $(STAGE3_CONFIGURE_FLAGS) \
-+	  --enable-pie-tools=@enable_pie_tools@
++	  @gcc_host_pie@
  @endif gcc-bootstrap
  
  .PHONY: configure-stage4-gcc maybe-configure-stage4-gcc
-@@ -12146,7 +12152,8 @@ configure-stage4-gcc:
+@@ -12150,7 +12153,8 @@ configure-stage4-gcc:
  	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
  	  --target=${target_alias} \
  	  --with-build-libsubdir=$(HOST_SUBDIR) \
 -	  $(STAGE4_CONFIGURE_FLAGS)
 +	  $(STAGE4_CONFIGURE_FLAGS) \
-+	  --enable-pie-tools=@enable_pie_tools@
++	  @gcc_host_pie@
  @endif gcc-bootstrap
  
  .PHONY: configure-stageprofile-gcc maybe-configure-stageprofile-gcc
-@@ -12179,7 +12186,8 @@ configure-stageprofile-gcc:
+@@ -12183,7 +12187,8 @@ configure-stageprofile-gcc:
  	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
  	  --target=${target_alias} \
  	  --with-build-libsubdir=$(HOST_SUBDIR) \
 -	  $(STAGEprofile_CONFIGURE_FLAGS)
 +	  $(STAGEprofile_CONFIGURE_FLAGS) \
-+	  --enable-pie-tools=@enable_pie_tools@
++	  @gcc_host_pie@
  @endif gcc-bootstrap
  
  .PHONY: configure-stagetrain-gcc maybe-configure-stagetrain-gcc
-@@ -12212,7 +12220,8 @@ configure-stagetrain-gcc:
+@@ -12216,7 +12221,8 @@ configure-stagetrain-gcc:
  	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
  	  --target=${target_alias} \
  	  --with-build-libsubdir=$(HOST_SUBDIR) \
 -	  $(STAGEtrain_CONFIGURE_FLAGS)
 +	  $(STAGEtrain_CONFIGURE_FLAGS) \
-+	  --enable-pie-tools=@enable_pie_tools@
++	  @gcc_host_pie@
  @endif gcc-bootstrap
  
  .PHONY: configure-stagefeedback-gcc maybe-configure-stagefeedback-gcc
-@@ -12245,7 +12254,8 @@ configure-stagefeedback-gcc:
+@@ -12249,7 +12255,8 @@ configure-stagefeedback-gcc:
  	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
  	  --target=${target_alias} \
  	  --with-build-libsubdir=$(HOST_SUBDIR) \
 -	  $(STAGEfeedback_CONFIGURE_FLAGS)
 +	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-+	  --enable-pie-tools=@enable_pie_tools@
++	  @gcc_host_pie@
  @endif gcc-bootstrap
  
  .PHONY: configure-stageautoprofile-gcc maybe-configure-stageautoprofile-gcc
-@@ -12278,7 +12288,8 @@ configure-stageautoprofile-gcc:
+@@ -12282,7 +12289,8 @@ configure-stageautoprofile-gcc:
  	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
  	  --target=${target_alias} \
  	  --with-build-libsubdir=$(HOST_SUBDIR) \
 -	  $(STAGEautoprofile_CONFIGURE_FLAGS)
 +	  $(STAGEautoprofile_CONFIGURE_FLAGS) \
-+	  --enable-pie-tools=@enable_pie_tools@
++	  @gcc_host_pie@
  @endif gcc-bootstrap
  
  .PHONY: configure-stageautofeedback-gcc maybe-configure-stageautofeedback-gcc
-@@ -12311,7 +12322,8 @@ configure-stageautofeedback-gcc:
+@@ -12315,7 +12323,8 @@ configure-stageautofeedback-gcc:
  	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
  	  --target=${target_alias} \
  	  --with-build-libsubdir=$(HOST_SUBDIR) \
 -	  $(STAGEautofeedback_CONFIGURE_FLAGS)
 +	  $(STAGEautofeedback_CONFIGURE_FLAGS) \
-+	  --enable-pie-tools=@enable_pie_tools@
++	  @gcc_host_pie@
  @endif gcc-bootstrap
  
  
-diff --git a/Makefile.tpl b/Makefile.tpl
-index ef58fac2b9a..925da105c18 100644
---- a/Makefile.tpl
-+++ b/Makefile.tpl
-@@ -115,6 +115,9 @@ GCC_SHLIB_SUBDIR = @GCC_SHLIB_SUBDIR@
- # If the build should make suitable code for shared host resources.
- host_shared = @host_shared@
- 
-+# If we should build compilers and supporting tools as PIE.
-+enable_pie_tools = @enable_pie_tools@
-+
- # Build programs are put under this directory.
- BUILD_SUBDIR = @build_subdir@
- # This is set by the configure script to the arguments to use when configuring
-diff --git a/config/mh-darwin b/config/mh-darwin
-index b72835ae953..bb4112773c9 100644
---- a/config/mh-darwin
-+++ b/config/mh-darwin
-@@ -11,7 +11,8 @@
- # non-bootstrapped compiler), later stages will be built by GCC which supports
- # the required flags.
- 
--# We cannot use mdynamic-no-pic when building shared host resources.
-+# We cannot use mdynamic-no-pic when building shared host resources, or for PIE
-+# tool executables, which also enables host-shared.
- 
- ifeq (${host_shared},no)
- BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC := $(shell \
+diff --git a/aclocal.m4 b/aclocal.m4
+new file mode 100644
+index 00000000000..e69de29bb2d
+diff --git a/c++tools/Makefile.in b/c++tools/Makefile.in
+index 77bda3d56dc..dcb1029e064 100644
+--- a/c++tools/Makefile.in
++++ b/c++tools/Makefile.in
+@@ -29,8 +29,9 @@ AUTOCONF := @AUTOCONF@
+ AUTOHEADER := @AUTOHEADER@
+ CXX := @CXX@
+ CXXFLAGS := @CXXFLAGS@
+-PIEFLAG := @PIEFLAG@
+-CXXOPTS := $(CXXFLAGS) $(PIEFLAG) -fno-exceptions -fno-rtti
++PICFLAG := @PICFLAG@
++LD_PICFLAG := @LD_PICFLAG@
++CXXOPTS := $(CXXFLAGS) $(PICFLAG) -fno-exceptions -fno-rtti
+ LDFLAGS := @LDFLAGS@
+ exeext := @EXEEXT@
+ LIBIBERTY := ../libiberty/libiberty.a
+@@ -90,11 +91,15 @@ ifeq (@CXX_AUX_TOOLS@,yes)
+ 
+ all::g++-mapper-server$(exeext)
+ 
++ifneq ($(PICFLAG),)
++override LIBIBERTY := ../libiberty/pic/libiberty.a
++endif
++
+ MAPPER.O := server.o resolver.o
+ CODYLIB = ../libcody/libcody.a
+ CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I. -I../gcc
+ g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB)
+-	+$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
++	+$(CXX) $(LDFLAGS) $(PICFLAG) $(LD_PICFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
+ 
+ # copy to gcc dir so tests there can run
+ all::../gcc/g++-mapper-server$(exeext)
+diff --git a/c++tools/configure b/c++tools/configure
+index 742816e4253..88087009383 100755
+--- a/c++tools/configure
++++ b/c++tools/configure
+@@ -627,7 +627,8 @@ get_gcc_base_ver
+ EGREP
+ GREP
+ CXXCPP
+-PIEFLAG
++LD_PICFLAG
++PICFLAG
+ MAINTAINER
+ CXX_AUX_TOOLS
+ AUTOHEADER
+@@ -700,6 +701,7 @@ enable_c___tools
+ enable_maintainer_mode
+ enable_checking
+ enable_default_pie
++enable_host_pie
+ with_gcc_major_version_only
+ '
+       ac_precious_vars='build_alias
+@@ -1333,6 +1335,7 @@ Optional Features:
+                           only specific categories of checks. Categories are:
+                           yes,no,all,none,release.
+   --enable-default-pie    enable Position Independent Executable as default
++  --enable-host-pie       build host code as PIE
+ 
+ Optional Packages:
+   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+@@ -2990,12 +2993,20 @@ fi
+ # Check whether --enable-default-pie was given.
+ # Check whether --enable-default-pie was given.
+ if test "${enable_default_pie+set}" = set; then :
+-  enableval=$enable_default_pie; PIEFLAG=-fPIE
++  enableval=$enable_default_pie; PICFLAG=-fPIE
+ else
+-  PIEFLAG=
++  PICFLAG=
+ fi
+ 
+ 
++# Enable --enable-host-pie
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
++fi
++
++
++
+ 
+ # Check if O_CLOEXEC is defined by fcntl
+ 
+diff --git a/c++tools/configure.ac b/c++tools/configure.ac
+index 23e98c8e721..44dfaccbbfa 100644
+--- a/c++tools/configure.ac
++++ b/c++tools/configure.ac
+@@ -102,8 +102,15 @@ fi
+ AC_ARG_ENABLE(default-pie,
+ [AS_HELP_STRING([--enable-default-pie],
+ 		  [enable Position Independent Executable as default])],
+-[PIEFLAG=-fPIE], [PIEFLAG=])
+-AC_SUBST([PIEFLAG])
++[PICFLAG=-fPIE], [PICFLAG=])
++
++# Enable --enable-host-pie
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])],
++[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
++AC_SUBST(PICFLAG)
++AC_SUBST(LD_PICFLAG)
+ 
+ # Check if O_CLOEXEC is defined by fcntl
+ AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
 diff --git a/configure b/configure
-index 5dcaab14ae9..c690bbec82b 100755
+index 117a7ef23f2..ee9dd18d2a3 100755
 --- a/configure
 +++ b/configure
-@@ -685,6 +685,7 @@ get_gcc_base_ver
- extra_host_zlib_configure_flags
+@@ -687,7 +687,10 @@ extra_host_zlib_configure_flags
  extra_host_libiberty_configure_flags
  stage1_languages
-+enable_pie_tools
+ host_libs_picflag
++PICFLAG
  host_shared
++gcc_host_pie
++host_pie
  extra_linker_plugin_flags
  extra_linker_plugin_configure_flags
-@@ -830,6 +831,7 @@ enable_lto
+ islinc
+@@ -830,6 +833,7 @@ enable_isl_version_check
+ enable_lto
  enable_linker_plugin_configure_flags
  enable_linker_plugin_flags
++enable_host_pie
  enable_host_shared
-+enable_pie_tools
  enable_stage1_languages
  enable_objc_gc
- with_target_bdw_gc
-@@ -1558,6 +1560,8 @@ Optional Features:
+@@ -1558,6 +1562,7 @@ Optional Features:
+   --enable-linker-plugin-flags=FLAGS
                            additional flags for configuring and building linker
                            plugins [none]
++  --enable-host-pie       build position independent host executables
    --enable-host-shared    build host code as shared libraries
-+  --enable-pie-tools      build Position Independent Executables for the
-+                          compilers and other tools
    --enable-stage1-languages[=all]
                            choose additional languages to build during stage1.
-                           Mostly useful for compiler development
-@@ -8410,6 +8414,20 @@ else
+@@ -8414,6 +8419,20 @@ else
   fi
  fi
  
@@ -203,54 +278,112 @@ index 5dcaab14ae9..c690bbec82b 100755
  
  
  # GCC GRAPHITE dependency isl.
-@@ -8663,6 +8681,42 @@ else
- fi
- 
- 
-+# Check whether --enable-pie-tools was given.
-+# Checked early because it can affect host make fragments.
-+# Check whether --enable-pie-tools was given.
-+if test "${enable_pie_tools+set}" = set; then :
-+  enableval=$enable_pie_tools; enable_pie_tools=$enableval
-+ case $target in
-+   aarch64-*-darwin1[1-9]*)
-+     if test x$enable_pie_tools != xyes ; then
-+       echo configure.ac: warning: aarch64-darwin must use PIE, pie-tools setting ignored. 1>&2
-+       enable_pie_tools=yes
-+       host_shared=yes
+@@ -8645,6 +8664,39 @@ fi
+ 
+ 
+ 
++# Handle --enable-host-pie
++# If host PIE executables are the default (or must be forced on) for some host,
++# we must pass that configuration to the gcc directory.
++gcc_host_pie=
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie; host_pie=$enableval
++ case $host in
++   *-*-darwin2*)
++     if test x$host_pie != xyes ; then
++       # for Darwin20+ this is required.
++       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: PIE executables are required for the configured host, host-pie setting ignored." >&5
++$as_echo "$as_me: WARNING: PIE executables are required for the configured host, host-pie setting ignored." >&2;}
++       host_pie=yes
++       gcc_host_pie=--enable-host-pie
 +     fi ;;
-+    *) ;;
++  *) ;;
 + esac
 +else
-+  case $target in
-+  # PIE is the default for macOS 10.7+ so reflect that in the configure.
-+  # However, we build 32b toolchains mdynamic-no-pic by default which is
-+  # not compatible with PIE.
-+  x86_64-*-darwin1[1-9]* | *-*-darwin2*) enable_pie_tools=yes ;;
-+  *) enable_pie_tools=no ;;
++  case $host in
++  *-*-darwin2*)
++    # Default to PIE (mandatory for aarch64).
++    host_pie=yes
++    gcc_host_pie=--enable-host-pie
++    ;;
++  *) host_pie=no ;;
 + esac
 +fi
 +
 +
-+case $target in
-+  *-*-darwin*)
-+    if test x$enable_pie_tools = xyes && test x$host_shared != xyes ; then
-+      echo configure.ac: warning: for Darwin PIE requires PIC code, switching host-shared on 1>&2
-+      host_shared=yes
-+    fi ;;
-+  *) ;;
-+esac
 +
 +
 +
+ # Enable --enable-host-shared.
+ # Checked early to determine whether jit is an 'all' language
+ # Check whether --enable-host-shared was given.
+@@ -8654,26 +8706,57 @@ if test "${enable_host_shared+set}" = set; then :
+    x86_64-*-darwin* | aarch64-*-darwin*)
+      if test x$host_shared != xyes ; then
+        # PIC is the default, and actually cannot be switched off.
+-       echo configure.ac: warning: PIC code is required for the configured target, host-shared setting ignored. 1>&2
++       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: PIC code is required for the configured host; host-shared setting ignored." >&5
++$as_echo "$as_me: WARNING: PIC code is required for the configured host; host-shared setting ignored." >&2;}
++       host_shared=yes
++     fi ;;
++   *-*-darwin*)
++     if test x$host_pie = xyes -a x$host_shared != xyes ; then
++       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: PIC code is required for PIE host executables host-shared setting ignored." >&5
++$as_echo "$as_me: WARNING: PIC code is required for PIE host executables host-shared setting ignored." >&2;}
+        host_shared=yes
+      fi ;;
+   *) ;;
+  esac
+ else
+   case $host in
++  # 64B x86_64 and Aarch64 Darwin default to PIC.
+   x86_64-*-darwin* | aarch64-*-darwin*) host_shared=yes ;;
+-  *) host_shared=no ;;
++  # 32B and powerpc64 Darwin must use PIC to link PIE exes.
++  *-*-darwin*) host_shared=$host_pie ;;
++  *) host_shared=no;;
+  esac
+ fi
+ 
+ 
+ 
+ 
++if test x$host_shared = xyes; then
++  case $host in
++    *-*-darwin*)
++      # Since host shared is the default for 64b Darwin, and also enabled for
++      # host_pie, ensure that we present the PIE flag when host_pie is active.
++      if test x$host_pie = xyes; then
++        PICFLAG=-fPIE
++      fi
++      ;;
++    *)
++      PICFLAG=-fPIC
++      ;;
++  esac
++elif test x$host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
++
++
++
+ # If we are building PIC/PIE host executables, and we are building dependent
+ # libs (e.g. GMP) in-tree those libs need to be configured to generate PIC
+ # code.
+ host_libs_picflag=
+-if test "$host_shared" = "yes";then
++if test "$host_shared" = "yes" -o "$host_pie" = "yes"; then
+ host_libs_picflag='--with-pic'
+ fi
  
- # By default, C and C++ are the only stage 1 languages.
- stage1_languages=,c,
 diff --git a/configure.ac b/configure.ac
-index 85977482aee..72bd20fda66 100644
+index b3e9bbd2aa5..4d390f86c7e 100644
 --- a/configure.ac
 +++ b/configure.ac
-@@ -1827,6 +1827,20 @@ AC_ARG_WITH(boot-ldflags,
+@@ -1806,6 +1806,20 @@ AC_ARG_WITH(boot-ldflags,
   if test "$poststage1_libs" = ""; then
     poststage1_ldflags="-static-libstdc++ -static-libgcc"
   fi])
@@ -271,120 +404,304 @@ index 85977482aee..72bd20fda66 100644
  AC_SUBST(poststage1_ldflags)
  
  # GCC GRAPHITE dependency isl.
-@@ -1931,7 +1945,41 @@ AC_ARG_ENABLE(host-shared,
-   x86_64-*-darwin* | aarch64-*-darwin*) host_shared=yes ;;
-   *) host_shared=no ;;
-  esac])
-+
-+# Check whether --enable-pie-tools was given.
-+# Checked early because it can affect host make fragments.
-+AC_ARG_ENABLE(pie-tools,
-+[AS_HELP_STRING([--enable-pie-tools],
-+  [build Position Independent Executables for the compilers and other tools])],
-+[enable_pie_tools=$enableval
-+ case $target in
-+   aarch64-*-darwin1[[1-9]]*)
-+     if test x$enable_pie_tools != xyes ; then
-+       echo configure.ac: warning: aarch64-darwin must use PIE, pie-tools setting ignored. 1>&2
-+       enable_pie_tools=yes
-+       host_shared=yes
+@@ -1891,6 +1905,36 @@ AC_ARG_ENABLE(linker-plugin-flags,
+   extra_linker_plugin_flags=)
+ AC_SUBST(extra_linker_plugin_flags)
+ 
++# Handle --enable-host-pie
++# If host PIE executables are the default (or must be forced on) for some host,
++# we must pass that configuration to the gcc directory.
++gcc_host_pie=
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build position independent host executables])],
++[host_pie=$enableval
++ case $host in
++   *-*-darwin2*)
++     if test x$host_pie != xyes ; then
++       # for Darwin20+ this is required.
++       AC_MSG_WARN([PIE executables are required for the configured host, host-pie setting ignored.])
++       host_pie=yes
++       gcc_host_pie=--enable-host-pie
 +     fi ;;
-+    *) ;;
++  *) ;;
 + esac],
-+[case $target in
-+  # PIE is the default for macOS 10.7+ so reflect that in the configure.
-+  # However, we build 32b toolchains mdynamic-no-pic by default which is
-+  # not compatible with PIE.
-+  x86_64-*-darwin1[[1-9]]* | *-*-darwin2*) enable_pie_tools=yes ;;
-+  *) enable_pie_tools=no ;;
++[case $host in
++  *-*-darwin2*)
++    # Default to PIE (mandatory for aarch64).
++    host_pie=yes
++    gcc_host_pie=--enable-host-pie
++    ;;
++  *) host_pie=no ;;
 + esac])
 +
-+case $target in
-+  *-*-darwin*)
-+    if test x$enable_pie_tools = xyes && test x$host_shared != xyes ; then
-+      echo configure.ac: warning: for Darwin PIE requires PIC code, switching host-shared on 1>&2
-+      host_shared=yes
-+    fi ;;
-+  *) ;;
-+esac
-+
++AC_SUBST(host_pie)
++AC_SUBST(gcc_host_pie)
++
+ # Enable --enable-host-shared.
+ # Checked early to determine whether jit is an 'all' language
+ AC_ARG_ENABLE(host-shared,
+@@ -1901,23 +1945,52 @@ AC_ARG_ENABLE(host-shared,
+    x86_64-*-darwin* | aarch64-*-darwin*)
+      if test x$host_shared != xyes ; then
+        # PIC is the default, and actually cannot be switched off.
+-       echo configure.ac: warning: PIC code is required for the configured target, host-shared setting ignored. 1>&2
++       AC_MSG_WARN([PIC code is required for the configured host; host-shared setting ignored.])
++       host_shared=yes
++     fi ;;
++   *-*-darwin*)
++     if test x$host_pie = xyes -a x$host_shared != xyes ; then
++       AC_MSG_WARN([PIC code is required for PIE host executables host-shared setting ignored.])
+        host_shared=yes
+      fi ;;
+   *) ;;
+  esac],
+ [case $host in
++  # 64B x86_64 and Aarch64 Darwin default to PIC.
+   x86_64-*-darwin* | aarch64-*-darwin*) host_shared=yes ;;
+-  *) host_shared=no ;;
++  # 32B and powerpc64 Darwin must use PIC to link PIE exes.
++  *-*-darwin*) host_shared=$host_pie ;;
++  *) host_shared=no;;
+  esac])
+ 
  AC_SUBST(host_shared)
-+AC_SUBST([enable_pie_tools])
- 
- # By default, C and C++ are the only stage 1 languages.
- stage1_languages=,c,
-diff --git a/contrib/compare-debug b/contrib/compare-debug
-index cf80ae32695..678a897c931 100755
---- a/contrib/compare-debug
-+++ b/contrib/compare-debug
-@@ -60,9 +60,19 @@ trap 'rm -f "$1.$suf1" "$2.$suf2"' 0 1 2 15
- case `uname -s` in
- Darwin)
-   # The strip command on darwin does not remove all debug info.
--  # Fortunately, we can use ld to do it instead.
--  ld -S -r -no_uuid "$1" -o "$1.$suf1"
--  ld -S -r -no_uuid "$2" -o "$2.$suf2"
-+  # Fortunately, we can use ld to do it instead, but even ld on earlier
-+  # system versions can be fussy about what it finds - make sure we use
-+  # a ld that understands coalesced sections.
-+  case `uname -r` in
-+  8*)
-+    ld64 -S -r -no_uuid "$1" -o "$1.$suf1"
-+    ld64 -S -r -no_uuid "$2" -o "$2.$suf2"
-+    ;;
-+  *)
-+    ld -S -r -no_uuid "$1" -o "$1.$suf1"
-+    ld -S -r -no_uuid "$2" -o "$2.$suf2"
-+    ;;
+ 
++if test x$host_shared = xyes; then
++  case $host in
++    *-*-darwin*)
++      # Since host shared is the default for 64b Darwin, and also enabled for
++      # host_pie, ensure that we present the PIE flag when host_pie is active.
++      if test x$host_pie = xyes; then
++        PICFLAG=-fPIE
++      fi
++      ;;
++    *)
++      PICFLAG=-fPIC
++      ;;
 +  esac
-   ;;
- *)
-   cp "$1" "$1.$suf1"
++elif test x$host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
++
++AC_SUBST(PICFLAG)
++
+ # If we are building PIC/PIE host executables, and we are building dependent
+ # libs (e.g. GMP) in-tree those libs need to be configured to generate PIC
+ # code.
+ host_libs_picflag=
+-if test "$host_shared" = "yes";then
++if test "$host_shared" = "yes" -o "$host_pie" = "yes"; then
+ host_libs_picflag='--with-pic'
+ fi
+ AC_SUBST(host_libs_picflag)
+diff --git a/fixincludes/Makefile.in b/fixincludes/Makefile.in
+index 1937dcaa32d..e6ce41dba39 100644
+--- a/fixincludes/Makefile.in
++++ b/fixincludes/Makefile.in
+@@ -73,7 +73,7 @@ default : all
+ # Now figure out from those variables how to compile and link.
+ 
+ .c.o:
+-	$(CC) -c $(CFLAGS) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
++	$(CC) -c $(CFLAGS) $(PICFLAG) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
+ 
+ # The only suffixes we want for implicit rules are .c and .o.
+ .SUFFIXES:
+@@ -87,7 +87,11 @@ default : all
+ ##
+ ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+ 
++ifeq ($(PICFLAG),)
+ LIBIBERTY=../libiberty/libiberty.a
++else
++LIBIBERTY=../libiberty/pic/libiberty.a
++endif
+ 
+ ALLOBJ = fixincl.o fixtests.o fixfixes.o server.o procopen.o \
+       fixlib.o fixopts.o
+@@ -107,15 +111,15 @@ oneprocess : full-stamp
+ twoprocess : test-stamp $(AF)
+ 
+ full-stamp : $(ALLOBJ) $(LIBIBERTY)
+-	$(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
++	$(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
+ 	$(STAMP) $@
+ 
+ test-stamp : $(TESTOBJ) $(LIBIBERTY)
+-	$(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
++	$(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
+ 	$(STAMP) $@
+ 
+ $(AF): $(FIXOBJ) $(LIBIBERTY)
+-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(FIXOBJ) $(LIBIBERTY)
++	$(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $@ $(FIXOBJ) $(LIBIBERTY)
+ 
+ $(ALLOBJ)   : $(HDR)
+ fixincl.o   : fixincl.c  $(srcdir)/fixincl.x
 diff --git a/fixincludes/configure b/fixincludes/configure
-index 6e2d67b655b..b3bca666a4d 100755
+index bdcc41f6ddc..a5e995f5316 100755
 --- a/fixincludes/configure
 +++ b/fixincludes/configure
-@@ -2644,7 +2644,7 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+@@ -623,6 +623,8 @@ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
+ get_gcc_base_ver
+ MAINT
++LD_PICFLAG
++PICFLAG
+ TARGET
+ target_noncanonical
+ WERROR
+@@ -695,6 +697,7 @@ enable_option_checking
+ enable_werror_always
+ with_local_prefix
+ enable_twoprocess
++enable_host_pie
+ enable_maintainer_mode
+ with_gcc_major_version_only
+ '
+@@ -1323,6 +1326,7 @@ Optional Features:
+   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+   --enable-werror-always  enable -Werror despite compiler version
+   --enable-twoprocess       Use a separate process to apply the fixes
++  --enable-host-pie       build host code as PIE
+   --enable-maintainer-mode enable make rules and dependencies not useful
+                           (and sometimes confusing) to the casual installer
+ 
+@@ -3022,6 +3026,7 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+ # ---------------------------
+ # _LT_COMPILER_PIC
+ 
++enable_darwin_at_rpath_$1=no
+ 
+ # _LT_LINKER_SHLIBS([TAGNAME])
+ # ----------------------------
+@@ -3044,7 +3049,6 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+ # the compiler configuration to `libtool'.
+ # _LT_LANG_CXX_CONFIG
+ 
+-
+ # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
+ # ---------------------------------
+ # Figure out "hidden" library dependencies from verbose
+@@ -4835,6 +4839,15 @@ $as_echo "#define SEPARATE_FIX_PROC 1" >>confdefs.h
+ 
+ fi
  
- # _LT_DARWIN_LINKER_FEATURES
- # --------------------------
--# Checks for linker and compiler features on darwin
-+# Checks for linker and compiler features on Darwin / macOS / iOS
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
++fi
++
++
++
++
+ case $host in
+ 	vax-dec-bsd* )
  
+diff --git a/fixincludes/configure.ac b/fixincludes/configure.ac
+index ef2227e3c93..4e78511d20f 100644
+--- a/fixincludes/configure.ac
++++ b/fixincludes/configure.ac
+@@ -68,6 +68,14 @@ if test $TARGET = twoprocess; then
+ 		  [Define if testing and fixing are done by separate process])
+ fi
  
- # _LT_SYS_MODULE_PATH_AIX
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++       [build host code as PIE])],
++[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
++AC_SUBST(PICFLAG)
++AC_SUBST(LD_PICFLAG)
++
+ case $host in
+ 	vax-dec-bsd* )
+ 		AC_DEFINE(exit, xexit, [Define to xexit if the host system does not support atexit])
 diff --git a/gcc/Makefile.in b/gcc/Makefile.in
-index 31ff95500c9..255a10c2ce8 100644
+index 775aaa1b3c4..2b0d8f9cd01 100644
 --- a/gcc/Makefile.in
 +++ b/gcc/Makefile.in
-@@ -270,11 +270,15 @@ COMPILER += $(CET_HOST_FLAGS)
- NO_PIE_CFLAGS = @NO_PIE_CFLAGS@
- NO_PIE_FLAG = @NO_PIE_FLAG@
+@@ -158,6 +158,9 @@ LDFLAGS = @LDFLAGS@
+ # Should we build position-independent host code?
+ PICFLAG = @PICFLAG@
+ 
++# The linker flag for the above.
++LD_PICFLAG = @LD_PICFLAG@
++
+ # Flags to determine code coverage. When coverage is disabled, this will
+ # contain the optimization flags, as you normally want code coverage
+ # without optimization.
+@@ -266,19 +269,19 @@ LINKER = $(CC)
+ LINKER_FLAGS = $(CFLAGS)
+ endif
+ 
++enable_host_pie = @enable_host_pie@
++
+ # Enable Intel CET on Intel CET enabled host if needed.
+ CET_HOST_FLAGS = @CET_HOST_FLAGS@
+ COMPILER += $(CET_HOST_FLAGS)
+ 
+-NO_PIE_CFLAGS = @NO_PIE_CFLAGS@
+-NO_PIE_FLAG = @NO_PIE_FLAG@
+ DO_LINK_MUTEX = @DO_LINK_MUTEX@
  
 -# We don't want to compile the compilers with -fPIE, it make PCH fail.
-+ifneq (@enable_pie_tools@,yes)
-+# Build and link the compilers and tools without PIE.
- COMPILER += $(NO_PIE_CFLAGS)
--
+-COMPILER += $(NO_PIE_CFLAGS)
++# Maybe compile the compilers with -fPIE or -fPIC.
++COMPILER += $(PICFLAG)
+ 
 -# Link with -no-pie since we compile the compiler with -fno-PIE.
- LINKER += $(NO_PIE_FLAG)
-+else
-+# FIXME these need to be configured.
-+COMPILER += -fPIE
-+LINKER += -pie
-+endif
+-LINKER += $(NO_PIE_FLAG)
++# Link with -pie, or -no-pie, depending on the above.
++LINKER += $(LD_PICFLAG)
  
  # Like LINKER, but use a mutex for serializing front end links.
  ifeq (@DO_LINK_MUTEX@,true)
-@@ -407,6 +411,7 @@ ifeq ($(enable_plugin),yes)
+@@ -1050,7 +1053,7 @@ RTL_SSA_H = $(PRETTY_PRINT_H) insn-config.h splay-tree-utils.h \
+ # programs built during a bootstrap.
+ # autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a
+ # cross compiler which does not use the native headers and libraries.
+-INTERNAL_CFLAGS = -DIN_GCC $(PICFLAG) @CROSS@
++INTERNAL_CFLAGS = -DIN_GCC @CROSS@
+ 
+ # This is the variable actually used when we compile. If you change this,
+ # you probably want to update BUILD_CFLAGS in configure.ac
+@@ -1068,21 +1071,24 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS) $(INTERNAL_CFLAGS) \
+ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
+ 
+ # This is the variable to use when using $(COMPILER).
+-ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
++ALL_COMPILERFLAGS = $(ALL_CXXFLAGS) $(PICFLAG)
+ 
+ # This is the variable to use when using $(LINKER).
+-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
++ALL_LINKERFLAGS = $(ALL_CXXFLAGS) $(LD_PICFLAG)
+ 
+ # Build and host support libraries.
+ 
+-# Use the "pic" build of libiberty if --enable-host-shared, unless we are
+-# building for mingw.
++# Use the "pic" build of libiberty if --enable-host-shared or --enable-host-pie,
++# unless we are building for mingw.
+ LIBIBERTY_PICDIR=$(if $(findstring mingw,$(target)),,pic)
+-ifeq ($(enable_host_shared),yes)
++ifneq ($(enable_host_shared)$(enable_host_pie),)
+ LIBIBERTY = ../libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
+-BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
+ else
+ LIBIBERTY = ../libiberty/libiberty.a
++endif
++ifeq ($(enable_host_shared),yes)
++BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
++else
+ BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
  endif
  
- enable_host_shared = @enable_host_shared@
-+enable_default_pie = @enable_default_pie@
- 
- enable_as_accelerator = @enable_as_accelerator@
- 
-@@ -1153,6 +1158,8 @@ LANG_MAKEFRAGS = @all_lang_makefrags@
+@@ -1167,6 +1173,8 @@ LANG_MAKEFRAGS = @all_lang_makefrags@
  # Used by gcc/jit/Make-lang.in
  LD_VERSION_SCRIPT_OPTION = @ld_version_script_option@
  LD_SONAME_OPTION = @ld_soname_option@
@@ -393,7 +710,7 @@ index 31ff95500c9..255a10c2ce8 100644
  
  # Flags to pass to recursive makes.
  # CC is set by configure.
-@@ -1942,9 +1949,12 @@ cs-tconfig.h: Makefile
+@@ -1973,9 +1981,12 @@ cs-tconfig.h: Makefile
  	$(SHELL) $(srcdir)/mkconfig.sh tconfig.h
  
  cs-tm.h: Makefile
@@ -409,7 +726,7 @@ index 31ff95500c9..255a10c2ce8 100644
  
  cs-tm_p.h: Makefile
  	TARGET_CPU_DEFAULT="" \
-@@ -4116,6 +4126,9 @@ site.exp: ./config.status Makefile
+@@ -4141,6 +4152,9 @@ site.exp: ./config.status Makefile
  	  echo "set COMPAT_OPTIONS \"$(COMPAT_OPTIONS)\"" >> ./site.tmp; \
  	else true; \
  	fi
@@ -480,62 +797,94 @@ index 6be36df5190..126e09bbcd1 100644
  m4_include([../libtool.m4])
  m4_include([../ltoptions.m4])
  m4_include([../ltsugar.m4])
-diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
-index aaf853e3a2a..b20218310f3 100644
---- a/gcc/ada/Makefile.rtl
-+++ b/gcc/ada/Makefile.rtl
-@@ -2822,6 +2822,15 @@ ifeq ($(strip $(filter-out darwin%,$(target_os))),)
-   TOOLS_TARGET_PAIRS = indepsw.adbaapcs_vfp_rmode,
  						  nregs, NULL, pcum->silent_p);
  }
@@ -1063,21 +1388,22 @@ index 5c9e7791a12..91258c925a8 100644
  
  /* Given MODE and TYPE of a function argument, return the alignment in
     bits.  The idea is to suppress any stronger alignment requested by
-@@ -7343,6 +7371,13 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
-     return;
+@@ -7641,6 +7669,14 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
+      Both behaviors were wrong, but in different cases.  */
  
    pcum->aapcs_arg_processed = true;
 +  if (TARGET_MACHO)
 +    {
 +      /* Set suitable defaults for queries.  */
 +      pcum->darwinpcs_arg_boundary
-+	= aarch64_function_arg_alignment (mode, type, &abi_break);
++	= aarch64_function_arg_alignment (mode, type, &abi_break,
++					  &abi_break_packed);
 +      pcum->darwinpcs_arg_padding = BITS_PER_UNIT;
 +    }
  
    pure_scalable_type_info pst_info;
    if (type && pst_info.analyze_registers (type))
-@@ -7399,13 +7434,29 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
+@@ -7700,13 +7736,29 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
      /* No frontends can create types with variable-sized modes, so we
         shouldn't be asked to pass or return them.  */
      size = GET_MODE_SIZE (mode).to_constant ();
@@ -1085,7 +1411,7 @@ index 5c9e7791a12..91258c925a8 100644
 +  if (TARGET_MACHO)
 +    /* Since we can pack things on the stack, we need the unrounded size.  */
 +    pcum->darwinpcs_stack_bytes = size;
-+ 
++
    size = ROUND_UP (size, UNITS_PER_WORD);
  
    allocate_ncrn = (type) ? !(FLOAT_TYPE_P (type)) : !FLOAT_MODE_P (mode);
@@ -1100,14 +1426,14 @@ index 5c9e7791a12..91258c925a8 100644
 +     so use this call directly.  */
 +  allocate_nvrn
 +    = aarch64_vfp_is_call_or_return_candidate (mode, type,
-+					       &pcum->aapcs_vfp_rmode,
-+					       &nregs, &is_ha,
-+					       pcum->silent_p);
++						&pcum->aapcs_vfp_rmode,
++						&nregs, &is_ha,
++						pcum->silent_p);
 +#endif
    gcc_assert (!sve_p || !allocate_nvrn);
  
-   /* allocate_ncrn may be false-positive, but allocate_nvrn is quite reliable.
-@@ -7420,7 +7471,13 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
+   unsigned int alignment
+@@ -7727,7 +7779,13 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
        if (!pcum->silent_p && !TARGET_FLOAT)
  	aarch64_err_no_fpadvsimd (mode);
  
@@ -1122,7 +1448,7 @@ index 5c9e7791a12..91258c925a8 100644
  	{
  	  pcum->aapcs_nextnvrn = nvrn + nregs;
  	  if (!aarch64_composite_type_p (type, mode))
-@@ -7450,6 +7507,7 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
+@@ -7757,6 +7815,7 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
  		}
  	      pcum->aapcs_reg = par;
  	    }
@@ -1130,7 +1456,7 @@ index 5c9e7791a12..91258c925a8 100644
  	  return;
  	}
        else
-@@ -7466,10 +7524,18 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
+@@ -7773,14 +7832,24 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
    /* C6 - C9.  though the sign and zero extension semantics are
       handled elsewhere.  This is the case where the argument fits
       entirely general registers.  */
@@ -1149,18 +1475,14 @@ index 5c9e7791a12..91258c925a8 100644
        /* C.8 if the argument has an alignment of 16 then the NGRN is
  	 rounded up to the next even number.  */
        if (nregs == 2
-@@ -7479,7 +7545,9 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
- 	     alignment nregs should be > 2 and therefore it should be
- 	     passed by reference rather than value.  */
- 	  && (aarch64_function_arg_alignment (mode, type, &abi_break)
--	      == 16 * BITS_PER_UNIT))
-+	      == 16 * BITS_PER_UNIT)
+-	  && ncrn % 2)
++	  && ncrn % 2
 +	  /* Darwin PCS deletes rule C.8.  */
 +	  && !TARGET_MACHO)
  	{
- 	  if (abi_break && warn_psabi && currently_expanding_gimple_stmt)
- 	    inform (input_location, "parameter passing for argument of type "
-@@ -7525,8 +7593,8 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
+ 	  /* Emit a warning if the alignment changed when taking the
+ 	     'packed' attribute into account.  */
+@@ -7842,8 +7911,8 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
  	    }
  	  pcum->aapcs_reg = par;
  	}
@@ -1170,16 +1492,18 @@ index 5c9e7791a12..91258c925a8 100644
        return;
      }
  
-@@ -7536,10 +7604,87 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
+@@ -7853,7 +7922,6 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
    /* The argument is passed on stack; record the needed number of words for
       this argument and align the total size if necessary.  */
  on_stack:
 -  pcum->aapcs_stack_words = size / UNITS_PER_WORD;
  
--  if (aarch64_function_arg_alignment (mode, type, &abi_break)
--      == 16 * BITS_PER_UNIT)
-+  unsigned int align = aarch64_function_arg_alignment (mode, type, &abi_break);
-+
+   if (warn_pcs_change
+       && abi_break_packed
+@@ -7862,6 +7930,83 @@ on_stack:
+     inform (input_location, "parameter passing for argument of type "
+ 	    "%qT changed in GCC 13.1", type);
+ 
 +  if (TARGET_MACHO)
 +    {
 +      /* Darwin does not round up the allocation for smaller entities to 8
@@ -1209,7 +1533,7 @@ index 5c9e7791a12..91258c925a8 100644
 +	  pcum->aapcs_stack_words = size / UNITS_PER_WORD;
 +	  pcum->darwinpcs_sub_word_offset = 0;
 +	  pcum->darwinpcs_sub_word_pos = 0;
-+	  pcum->darwinpcs_arg_boundary = MAX (align, PARM_BOUNDARY);
++	  pcum->darwinpcs_arg_boundary = MAX (alignment, PARM_BOUNDARY);
 +	  if (!pcum->named_p)
 +	    pcum->darwinpcs_arg_padding = PARM_BOUNDARY;
 +	  return;
@@ -1220,7 +1544,7 @@ index 5c9e7791a12..91258c925a8 100644
 +	 existing object(s) in the same stack slot.  In that case, we do not
 +	 need to add any more stack space for it.  */
 +      int new_off
-+	= ROUND_UP (pcum->darwinpcs_sub_word_pos, align / BITS_PER_UNIT);
++	= ROUND_UP (pcum->darwinpcs_sub_word_pos, alignment / BITS_PER_UNIT);
 +
 +      if (new_off >= UNITS_PER_WORD)
 +	{
@@ -1241,7 +1565,7 @@ index 5c9e7791a12..91258c925a8 100644
 +	   not add any stack space.  */
 +	pcum->darwinpcs_sub_word_offset = new_off;
 +      pcum->darwinpcs_sub_word_pos = new_pos;
-+      pcum->darwinpcs_arg_boundary = align;
++      pcum->darwinpcs_arg_boundary = alignment ;
 +      if (pcum->last_named_p && new_pos > 0)
 +	{
 +	  /* Round the last named arg to the start of the next stack slot.  */
@@ -1257,11 +1581,10 @@ index 5c9e7791a12..91258c925a8 100644
 +
 +  /* size was already rounded up to PARM_BOUNDARY.  */
 +  pcum->aapcs_stack_words = size / UNITS_PER_WORD;
-+  if (align == 16 * BITS_PER_UNIT)
+   if (alignment == 16 * BITS_PER_UNIT)
      {
        int new_size = ROUND_UP (pcum->aapcs_stack_size, 16 / UNITS_PER_WORD);
-       if (pcum->aapcs_stack_size != new_size)
-@@ -7592,7 +7737,28 @@ aarch64_init_cumulative_args (CUMULATIVE_ARGS *pcum,
+@@ -7915,7 +8060,28 @@ aarch64_init_cumulative_args (CUMULATIVE_ARGS *pcum,
    pcum->aapcs_arg_processed = false;
    pcum->aapcs_stack_words = 0;
    pcum->aapcs_stack_size = 0;
@@ -1290,7 +1613,7 @@ index 5c9e7791a12..91258c925a8 100644
  
    if (!silent_p
        && !TARGET_FLOAT
-@@ -7631,8 +7797,10 @@ aarch64_function_arg_advance (cumulative_args_t pcum_v,
+@@ -7954,8 +8120,10 @@ aarch64_function_arg_advance (cumulative_args_t pcum_v,
        || pcum->pcs_variant == ARM_PCS_SVE)
      {
        aarch64_layout_arg (pcum_v, arg);
@@ -1303,21 +1626,21 @@ index 5c9e7791a12..91258c925a8 100644
        pcum->aapcs_arg_processed = false;
        pcum->aapcs_ncrn = pcum->aapcs_nextncrn;
        pcum->aapcs_nvrn = pcum->aapcs_nextnvrn;
-@@ -7640,6 +7808,12 @@ aarch64_function_arg_advance (cumulative_args_t pcum_v,
+@@ -7963,6 +8131,12 @@ aarch64_function_arg_advance (cumulative_args_t pcum_v,
        pcum->aapcs_stack_size += pcum->aapcs_stack_words;
        pcum->aapcs_stack_words = 0;
        pcum->aapcs_reg = NULL_RTX;
 +      pcum->darwinpcs_arg_boundary = BITS_PER_UNIT;
 +      pcum->darwinpcs_arg_padding = BITS_PER_UNIT;
 +      pcum->named_p
-+        = pcum->darwinpcs_n_args_processed < pcum->darwinpcs_n_named;
++	= pcum->darwinpcs_n_args_processed < pcum->darwinpcs_n_named;
 +      pcum->last_named_p
-+        = pcum->darwinpcs_n_args_processed + 1 == pcum->darwinpcs_n_named;
++	= pcum->darwinpcs_n_args_processed + 1 == pcum->darwinpcs_n_named;
      }
  }
  
-@@ -7650,12 +7824,15 @@ aarch64_function_arg_regno_p (unsigned regno)
- 	  || (FP_REGNUM_P (regno) && regno < V0_REGNUM + NUM_FP_ARG_REGS));
+@@ -7974,12 +8148,15 @@ aarch64_function_arg_regno_p (unsigned regno)
+ 	  || (PR_REGNUM_P (regno) && regno < P0_REGNUM + NUM_PR_ARG_REGS));
  }
  
 -/* Implement FUNCTION_ARG_BOUNDARY.  Every parameter gets at least
@@ -1327,8 +1650,8 @@ index 5c9e7791a12..91258c925a8 100644
 -   Stacked Argument Address (NSAA) will have a minimum alignment of
 -   8 bytes.  */
 +/* Implement FUNCTION_ARG_BOUNDARY.
-+   For AAPCS64, Every parameter gets at least PARM_BOUNDARY bits of 
-+   alignment, but will be given anything up to STACK_BOUNDARY bits 
++   For AAPCS64, Every parameter gets at least PARM_BOUNDARY bits of
++   alignment, but will be given anything up to STACK_BOUNDARY bits
 +   if the type requires it.  This makes sure that both before and after
 +   the layout of each argument, the Next Stacked Argument Address (NSAA)
 +   will have a minimum alignment of 8 bytes.
@@ -1338,10 +1661,10 @@ index 5c9e7791a12..91258c925a8 100644
  
  static unsigned int
  aarch64_function_arg_boundary (machine_mode mode, const_tree type)
-@@ -7663,6 +7840,71 @@ aarch64_function_arg_boundary (machine_mode mode, const_tree type)
-   unsigned int abi_break;
-   unsigned int alignment = aarch64_function_arg_alignment (mode, type,
- 							   &abi_break);
+@@ -7991,8 +8168,107 @@ aarch64_function_arg_boundary (machine_mode mode, const_tree type)
+ 							   &abi_break_packed);
+   /* We rely on aarch64_layout_arg and aarch64_gimplify_va_arg_expr
+      to emit warnings about ABI incompatibility.  */
 +#if TARGET_MACHO
 +  /* This can only work for unnamed args.  */
 +  machine_mode comp_mode = VOIDmode;
@@ -1357,14 +1680,6 @@ index 5c9e7791a12..91258c925a8 100644
 +  return MIN (alignment, STACK_BOUNDARY);
 +#else
 +  alignment = MIN (MAX (alignment, PARM_BOUNDARY), STACK_BOUNDARY);
-+  if (abi_break & warn_psabi)
-+    {
-+      abi_break = MIN (MAX (abi_break, PARM_BOUNDARY), STACK_BOUNDARY);
-+      if (alignment != abi_break && !TARGET_MACHO)
-+	inform (input_location, "parameter passing for argument of type "
-+		"%qT changed in GCC 9.1", type);
-+    }
-+
 +  return alignment;
 +#endif
 +}
@@ -1379,8 +1694,12 @@ index 5c9e7791a12..91258c925a8 100644
 +				  cumulative_args_t ca ATTRIBUTE_UNUSED)
 +{
 +  unsigned int abi_break;
++  unsigned int abi_break_packed;
 +  unsigned int alignment = aarch64_function_arg_alignment (mode, type,
-+							   &abi_break);
++							   &abi_break,
++							   &abi_break_packed);
++  /* We rely on aarch64_layout_arg and aarch64_gimplify_va_arg_expr
++     to emit warnings about ABI incompatibility.  */
 +#if TARGET_MACHO
 +  CUMULATIVE_ARGS *pcum = get_cumulative_args (ca);
 +gcc_checking_assert (pcum->aapcs_arg_processed);
@@ -1408,11 +1727,6 @@ index 5c9e7791a12..91258c925a8 100644
 +
 +#else
    alignment = MIN (MAX (alignment, PARM_BOUNDARY), STACK_BOUNDARY);
-   if (abi_break & warn_psabi)
-     {
-@@ -7673,6 +7915,44 @@ aarch64_function_arg_boundary (machine_mode mode, const_tree type)
-     }
- 
    return alignment;
 +#endif
 +}
@@ -1455,7 +1769,7 @@ index 5c9e7791a12..91258c925a8 100644
  }
  
  /* Implement TARGET_GET_RAW_RESULT_MODE and TARGET_GET_RAW_ARG_MODE.  */
-@@ -10848,6 +11128,7 @@ aarch64_classify_address (struct aarch64_address_info *info,
+@@ -11030,6 +11306,7 @@ aarch64_classify_address (struct aarch64_address_info *info,
        /* load literal: pc-relative constant pool entry.  Only supported
           for SI mode or larger.  */
        info->type = ADDRESS_SYMBOLIC;
@@ -1463,7 +1777,7 @@ index 5c9e7791a12..91258c925a8 100644
  
        if (!load_store_pair_p
  	  && GET_MODE_SIZE (mode).is_constant (&const_size)
-@@ -10855,6 +11136,7 @@ aarch64_classify_address (struct aarch64_address_info *info,
+@@ -11037,6 +11314,7 @@ aarch64_classify_address (struct aarch64_address_info *info,
  	{
  	  poly_int64 offset;
  	  rtx sym = strip_offset_and_salt (x, &offset);
@@ -1471,7 +1785,7 @@ index 5c9e7791a12..91258c925a8 100644
  	  return ((LABEL_REF_P (sym)
  		   || (SYMBOL_REF_P (sym)
  		       && CONSTANT_POOL_ADDRESS_P (sym)
-@@ -10872,10 +11154,13 @@ aarch64_classify_address (struct aarch64_address_info *info,
+@@ -11054,10 +11332,13 @@ aarch64_classify_address (struct aarch64_address_info *info,
  	  poly_int64 offset;
  	  HOST_WIDE_INT const_offset;
  	  rtx sym = strip_offset_and_salt (info->offset, &offset);
@@ -1486,7 +1800,7 @@ index 5c9e7791a12..91258c925a8 100644
  	    {
  	      /* The symbol and offset must be aligned to the access size.  */
  	      unsigned int align;
-@@ -10925,6 +11210,55 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p)
+@@ -11107,6 +11388,55 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p)
    if (!res)
      return false;
  
@@ -1542,7 +1856,7 @@ index 5c9e7791a12..91258c925a8 100644
    /* ... except writeback forms.  */
    return addr.type != ADDRESS_REG_WB;
  }
-@@ -11609,6 +11943,144 @@ sizetochar (int size)
+@@ -11820,6 +12150,144 @@ sizetochar (int size)
      }
  }
  
@@ -1687,7 +2001,7 @@ index 5c9e7791a12..91258c925a8 100644
  /* Print operand X to file F in a target specific manner according to CODE.
     The acceptable formatting commands given by CODE are:
       'c':		An integer or symbol address without a preceding #
-@@ -11677,6 +12149,12 @@ aarch64_print_operand (FILE *f, rtx x, int code)
+@@ -11888,6 +12356,12 @@ aarch64_print_operand (FILE *f, rtx x, int code)
  	}
        break;
  
@@ -1700,7 +2014,7 @@ index 5c9e7791a12..91258c925a8 100644
      case 'e':
        {
  	x = unwrap_const_vec_duplicate (x);
-@@ -12000,7 +12478,7 @@ aarch64_print_operand (FILE *f, rtx x, int code)
+@@ -12211,7 +12685,7 @@ aarch64_print_operand (FILE *f, rtx x, int code)
      case 'A':
        if (GET_CODE (x) == HIGH)
  	x = XEXP (x, 0);
@@ -1709,7 +2023,7 @@ index 5c9e7791a12..91258c925a8 100644
        switch (aarch64_classify_symbolic_expression (x))
  	{
  	case SYMBOL_SMALL_GOT_4G:
-@@ -12031,9 +12509,29 @@ aarch64_print_operand (FILE *f, rtx x, int code)
+@@ -12242,9 +12716,29 @@ aarch64_print_operand (FILE *f, rtx x, int code)
  	  break;
  	}
        output_addr_const (asm_out_file, x);
@@ -1739,7 +2053,7 @@ index 5c9e7791a12..91258c925a8 100644
        switch (aarch64_classify_symbolic_expression (x))
  	{
  	case SYMBOL_SMALL_GOT_4G:
-@@ -12071,10 +12569,12 @@ aarch64_print_operand (FILE *f, rtx x, int code)
+@@ -12282,10 +12776,12 @@ aarch64_print_operand (FILE *f, rtx x, int code)
  	default:
  	  break;
  	}
@@ -1752,7 +2066,7 @@ index 5c9e7791a12..91258c925a8 100644
        switch (aarch64_classify_symbolic_expression (x))
  	{
  	case SYMBOL_TLSLE24:
-@@ -12083,6 +12583,7 @@ aarch64_print_operand (FILE *f, rtx x, int code)
+@@ -12294,6 +12790,7 @@ aarch64_print_operand (FILE *f, rtx x, int code)
  	default:
  	  break;
  	}
@@ -1760,7 +2074,7 @@ index 5c9e7791a12..91258c925a8 100644
        output_addr_const (asm_out_file, x);
        break;
  
-@@ -12232,8 +12733,14 @@ aarch64_print_address_internal (FILE *f, machine_mode mode, rtx x,
+@@ -12443,8 +12940,14 @@ aarch64_print_address_internal (FILE *f, machine_mode mode, rtx x,
  	break;
  
        case ADDRESS_LO_SUM:
@@ -1775,7 +2089,7 @@ index 5c9e7791a12..91258c925a8 100644
  	asm_fprintf (f, "]");
  	return true;
  
-@@ -12703,6 +13210,8 @@ aarch64_asm_output_labelref (FILE* f, const char *name)
+@@ -12942,6 +13445,8 @@ aarch64_asm_output_labelref (FILE* f, const char *name)
    asm_fprintf (f, "%U%s", name);
  }
  
@@ -1784,7 +2098,7 @@ index 5c9e7791a12..91258c925a8 100644
  static void
  aarch64_elf_asm_constructor (rtx symbol, int priority)
  {
-@@ -12742,6 +13251,7 @@ aarch64_elf_asm_destructor (rtx symbol, int priority)
+@@ -12981,6 +13486,7 @@ aarch64_elf_asm_destructor (rtx symbol, int priority)
        assemble_aligned_integer (POINTER_BYTES, symbol);
      }
  }
@@ -1792,7 +2106,19 @@ index 5c9e7791a12..91258c925a8 100644
  
  const char*
  aarch64_output_casesi (rtx *operands)
-@@ -15048,15 +15558,17 @@ aarch64_init_builtins ()
+@@ -13084,7 +13590,11 @@ aarch64_select_rtx_section (machine_mode mode,
+   if (aarch64_can_use_per_function_literal_pools_p ())
+     return function_section (current_function_decl);
+ 
++#ifdef TARGET_MACHO
++  return machopic_select_rtx_section (mode, x, align);
++#else
+   return default_elf_select_rtx_section (mode, x, align);
++#endif
+ }
+ 
+ /* Implement ASM_OUTPUT_POOL_EPILOGUE.  */
+@@ -15308,15 +15818,17 @@ aarch64_init_builtins ()
  {
    aarch64_general_init_builtins ();
    aarch64_sve::init_builtins ();
@@ -1813,7 +2139,7 @@ index 5c9e7791a12..91258c925a8 100644
    unsigned int code = DECL_MD_FUNCTION_CODE (fndecl);
    unsigned int subcode = code >> AARCH64_BUILTIN_SHIFT;
    tree type = TREE_TYPE (TREE_TYPE (fndecl));
-@@ -18326,10 +18838,14 @@ initialize_aarch64_code_model (struct gcc_options *opts)
+@@ -18500,10 +19012,14 @@ initialize_aarch64_code_model (struct gcc_options *opts)
  	}
        break;
      case AARCH64_CMODEL_LARGE:
@@ -1830,7 +2156,7 @@ index 5c9e7791a12..91258c925a8 100644
  	sorry ("code model %qs not supported in ilp32 mode", "large");
        break;
      case AARCH64_CMODEL_TINY_PIC:
-@@ -19252,7 +19768,9 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset)
+@@ -19389,7 +19905,9 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset)
  	case AARCH64_CMODEL_SMALL_SPIC:
  	case AARCH64_CMODEL_SMALL_PIC:
  	case AARCH64_CMODEL_SMALL:
@@ -1841,7 +2167,7 @@ index 5c9e7791a12..91258c925a8 100644
  
  	default:
  	  gcc_unreachable ();
-@@ -19288,10 +19806,22 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset)
+@@ -19425,10 +19943,22 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset)
  
  	  return SYMBOL_TINY_ABSOLUTE;
  
@@ -1865,7 +2191,7 @@ index 5c9e7791a12..91258c925a8 100644
  	  if ((flag_pic || SYMBOL_REF_WEAK (x))
  	      && !aarch64_symbol_binds_local_p (x))
  	    return aarch64_cmodel == AARCH64_CMODEL_SMALL_SPIC
-@@ -19303,7 +19833,8 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset)
+@@ -19440,7 +19970,8 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset)
  		|| offset_within_block_p (x, offset)))
  	    return SYMBOL_FORCE_TO_MEM;
  
@@ -1875,7 +2201,7 @@ index 5c9e7791a12..91258c925a8 100644
  
  	case AARCH64_CMODEL_LARGE:
  	  /* This is alright even in PIC code as the constant
-@@ -19433,7 +19964,10 @@ static GTY(()) tree va_list_type;
+@@ -19570,7 +20101,10 @@ static GTY(()) tree va_list_type;
       void *__vr_top;
       int   __gr_offs;
       int   __vr_offs;
@@ -1887,7 +2213,7 @@ index 5c9e7791a12..91258c925a8 100644
  
  static tree
  aarch64_build_builtin_va_list (void)
-@@ -19441,6 +19975,13 @@ aarch64_build_builtin_va_list (void)
+@@ -19578,6 +20112,13 @@ aarch64_build_builtin_va_list (void)
    tree va_list_name;
    tree f_stack, f_grtop, f_vrtop, f_groff, f_vroff;
  
@@ -1901,7 +2227,7 @@ index 5c9e7791a12..91258c925a8 100644
    /* Create the type.  */
    va_list_type = lang_hooks.types.make_type (RECORD_TYPE);
    /* Give it the required name.  */
-@@ -19512,6 +20053,13 @@ aarch64_expand_builtin_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED)
+@@ -19649,6 +20190,13 @@ aarch64_expand_builtin_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED)
    int vr_save_area_size = cfun->va_list_fpr_size;
    int vr_offset;
  
@@ -1915,7 +2241,7 @@ index 5c9e7791a12..91258c925a8 100644
    cum = &crtl->args.info;
    if (cfun->va_list_gpr_size)
      gr_save_area_size = MIN ((NUM_ARG_REGS - cum->aapcs_ncrn) * UNITS_PER_WORD,
-@@ -19602,6 +20150,9 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
+@@ -19739,6 +20287,9 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
    HOST_WIDE_INT size, rsize, adjust, align;
    tree t, u, cond1, cond2;
  
@@ -1925,7 +2251,7 @@ index 5c9e7791a12..91258c925a8 100644
    indirect_p = pass_va_arg_by_reference (type);
    if (indirect_p)
      type = build_pointer_type (type);
-@@ -19786,8 +20337,18 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
+@@ -19929,8 +20480,18 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
  	  field_ptr_t = double_ptr_type_node;
  	  break;
  	case E_TFmode:
@@ -1944,9 +2270,9 @@ index 5c9e7791a12..91258c925a8 100644
 +	      field_ptr_t = long_double_ptr_type_node;
 +	    }
  	  break;
- 	case E_HFmode:
- 	  field_t = aarch64_fp16_type_node;
-@@ -19858,6 +20419,9 @@ aarch64_setup_incoming_varargs (cumulative_args_t cum_v,
+ 	case E_SDmode:
+ 	  field_t = dfloat32_type_node;
+@@ -20013,6 +20574,9 @@ aarch64_setup_incoming_varargs (cumulative_args_t cum_v,
    int gr_saved = cfun->va_list_gpr_size;
    int vr_saved = cfun->va_list_fpr_size;
  
@@ -1956,7 +2282,7 @@ index 5c9e7791a12..91258c925a8 100644
    /* The caller has advanced CUM up to, but not beyond, the last named
       argument.  Advance a local copy of CUM past the last "real" named
       argument, to find out how many registers are left over.  */
-@@ -20685,6 +21249,12 @@ aarch64_autovectorize_vector_modes (vector_modes *modes, bool)
+@@ -20845,6 +21409,12 @@ aarch64_autovectorize_vector_modes (vector_modes *modes, bool)
  static const char *
  aarch64_mangle_type (const_tree type)
  {
@@ -1969,18 +2295,18 @@ index 5c9e7791a12..91258c925a8 100644
    /* The AArch64 ABI documents say that "__va_list" has to be
       mangled as if it is in the "std" namespace.  */
    if (lang_hooks.types_compatible_p (CONST_CAST_TREE (type), va_list_type))
-@@ -20699,6 +21269,10 @@ aarch64_mangle_type (const_tree type)
+@@ -20861,6 +21431,10 @@ aarch64_mangle_type (const_tree type)
  	return "Dh";
      }
  
-+  /* TFmode is __float128 for Darwin. */
-+  if (TARGET_MACHO && TYPE_MODE (type) == TFmode)
++  /* __float128 */
++  if (TYPE_MODE (type) == TFmode)
 +    return "g";
 +
    /* Mangle AArch64-specific internal types.  TYPE_NAME is non-NULL_TREE for
       builtin types.  */
    if (TYPE_NAME (type) != NULL)
-@@ -21389,7 +21963,8 @@ aarch64_mov_operand_p (rtx x, machine_mode mode)
+@@ -21554,7 +22128,8 @@ aarch64_mov_operand_p (rtx x, machine_mode mode)
  
    /* GOT accesses are valid moves.  */
    if (SYMBOL_REF_P (x)
@@ -1990,7 +2316,7 @@ index 5c9e7791a12..91258c925a8 100644
      return true;
  
    if (SYMBOL_REF_P (x) && mode == DImode && CONSTANT_ADDRESS_P (x))
-@@ -22549,7 +23124,9 @@ aarch64_declare_function_name (FILE *stream, const char* name,
+@@ -22746,7 +23321,9 @@ aarch64_declare_function_name (FILE *stream, const char* name,
    aarch64_asm_output_variant_pcs (stream, fndecl, name);
  
    /* Don't forget the type directive for ELF.  */
@@ -2000,7 +2326,7 @@ index 5c9e7791a12..91258c925a8 100644
    ASM_OUTPUT_LABEL (stream, name);
  
    cfun->machine->label_is_assembled = true;
-@@ -22584,12 +23161,17 @@ aarch64_print_patchable_function_entry (FILE *file,
+@@ -22807,12 +23384,17 @@ aarch64_output_patchable_area (unsigned int patch_area_size, bool record_p)
  /* Implement ASM_OUTPUT_DEF_FROM_DECLS.  Output .variant_pcs for aliases.  */
  
  void
@@ -2019,7 +2345,7 @@ index 5c9e7791a12..91258c925a8 100644
  }
  
  /* Implement ASM_OUTPUT_EXTERNAL.  Output .variant_pcs for undefined
-@@ -23213,6 +23795,16 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width,
+@@ -23436,6 +24018,16 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width,
      }
  
    gcc_assert (CONST_INT_P (info.u.mov.value));
@@ -2036,7 +2362,7 @@ index 5c9e7791a12..91258c925a8 100644
  
    if (which == AARCH64_CHECK_MOV)
      {
-@@ -23221,16 +23813,16 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width,
+@@ -23444,16 +24036,16 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width,
  		  ? "msl" : "lsl");
        if (lane_count == 1)
  	snprintf (templ, sizeof (templ), "%s\t%%d0, " HOST_WIDE_INT_PRINT_HEX,
@@ -2056,7 +2382,7 @@ index 5c9e7791a12..91258c925a8 100644
      }
    else
      {
-@@ -23239,12 +23831,12 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width,
+@@ -23462,12 +24054,12 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width,
        if (info.u.mov.shift)
  	snprintf (templ, sizeof (templ), "%s\t%%0.%d%c, #"
  		  HOST_WIDE_INT_PRINT_DEC ", %s #%d", mnemonic, lane_count,
@@ -2071,22 +2397,26 @@ index 5c9e7791a12..91258c925a8 100644
      }
    return templ;
  }
-@@ -26355,12 +26947,12 @@ aarch64_libgcc_floating_mode_supported_p (scalar_float_mode mode)
+@@ -26664,7 +27256,8 @@ aarch64_libgcc_floating_mode_supported_p (scalar_float_mode mode)
  }
  
  /* Implement TARGET_SCALAR_MODE_SUPPORTED_P - return TRUE
--   if MODE is HFmode, and punt to the generic implementation otherwise.  */
-+   if MODE is HFmode, or TFmode on Mach-O, and punt to the generic implementation otherwise.  */
+-   if MODE is [BH]Fmode, and punt to the generic implementation otherwise.  */
++   if MODE is [BH]Fmode, or TFmode on Mach-O, and punt to the generic
++   implementation otherwise.  */
  
  static bool
  aarch64_scalar_mode_supported_p (scalar_mode mode)
- {
--  return (mode == HFmode
-+  return (mode == HFmode || (mode == TFmode && TARGET_MACHO)
+@@ -26672,7 +27265,7 @@ aarch64_scalar_mode_supported_p (scalar_mode mode)
+   if (DECIMAL_FLOAT_MODE_P (mode))
+     return default_decimal_float_supported_p ();
+ 
+-  return ((mode == HFmode || mode == BFmode)
++  return ((mode == HFmode || mode == BFmode || (mode == TFmode && TARGET_MACHO))
  	  ? true
  	  : default_scalar_mode_supported_p (mode));
  }
-@@ -27118,19 +27710,37 @@ aarch64_sls_emit_shared_blr_thunks (FILE *out_file)
+@@ -27402,19 +27995,37 @@ aarch64_sls_emit_shared_blr_thunks (FILE *out_file)
  	continue;
  
        const char *name = indirect_symbol_names[regnum];
@@ -2127,7 +2457,7 @@ index 5c9e7791a12..91258c925a8 100644
      }
  }
  
-@@ -27323,6 +27933,15 @@ aarch64_run_selftests (void)
+@@ -27607,6 +28218,15 @@ aarch64_run_selftests (void)
  #undef TARGET_ASM_ALIGNED_SI_OP
  #define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
  
@@ -2143,7 +2473,7 @@ index 5c9e7791a12..91258c925a8 100644
  #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
  #define TARGET_ASM_CAN_OUTPUT_MI_THUNK \
    hook_bool_const_tree_hwi_hwi_const_tree_true
-@@ -27409,6 +28028,12 @@ aarch64_run_selftests (void)
+@@ -27693,6 +28313,12 @@ aarch64_run_selftests (void)
  #undef TARGET_FUNCTION_ARG_BOUNDARY
  #define TARGET_FUNCTION_ARG_BOUNDARY aarch64_function_arg_boundary
  
@@ -2156,7 +2486,7 @@ index 5c9e7791a12..91258c925a8 100644
  #undef TARGET_FUNCTION_ARG_PADDING
  #define TARGET_FUNCTION_ARG_PADDING aarch64_function_arg_padding
  
-@@ -27736,7 +28361,7 @@ aarch64_libgcc_floating_mode_supported_p
+@@ -28017,7 +28643,7 @@ aarch64_libgcc_floating_mode_supported_p
  
  /* The architecture reserves bits 0 and 1 so use bit 2 for descriptors.  */
  #undef TARGET_CUSTOM_FUNCTION_DESCRIPTORS
@@ -2166,12 +2496,12 @@ index 5c9e7791a12..91258c925a8 100644
  #undef TARGET_HARD_REGNO_NREGS
  #define TARGET_HARD_REGNO_NREGS aarch64_hard_regno_nregs
 diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
-index 359b6e8561f..db5fe441b36 100644
+index 73b09e20508..d11c0ba21b4 100644
 --- a/gcc/config/aarch64/aarch64.h
 +++ b/gcc/config/aarch64/aarch64.h
-@@ -58,6 +58,10 @@
- #define TARGET_SIMD (!TARGET_GENERAL_REGS_ONLY && AARCH64_ISA_SIMD)
- #define TARGET_FLOAT (!TARGET_GENERAL_REGS_ONLY && AARCH64_ISA_FP)
+@@ -65,6 +65,10 @@
+ #define TARGET_SIMD (AARCH64_ISA_SIMD)
+ #define TARGET_FLOAT (AARCH64_ISA_FP)
  
 +/* If this is non-zero then generated code of the object format, ABI and
 +   assembler syntax used by Darwin (Mach-O) platforms.  */
@@ -2180,7 +2510,7 @@ index 359b6e8561f..db5fe441b36 100644
  #define UNITS_PER_WORD		8
  
  #define UNITS_PER_VREG		16
-@@ -135,6 +139,12 @@
+@@ -142,6 +146,12 @@
  /* Heap alignment (same as BIGGEST_ALIGNMENT and STACK_BOUNDARY).  */
  #define MALLOC_ABI_ALIGNMENT  128
  
@@ -2193,7 +2523,7 @@ index 359b6e8561f..db5fe441b36 100644
  /* Defined by the ABI */
  #define WCHAR_TYPE "unsigned int"
  #define WCHAR_TYPE_SIZE			32
-@@ -1025,6 +1035,24 @@ typedef struct
+@@ -934,6 +944,24 @@ typedef struct
  				   aapcs_reg == NULL_RTX.  */
    int aapcs_stack_size;		/* The total size (in words, per 8 byte) of the
  				   stack arg area so far.  */
@@ -2218,7 +2548,7 @@ index 359b6e8561f..db5fe441b36 100644
    bool silent_p;		/* True if we should act silently, rather than
  				   raise an error for invalid calls.  */
  } CUMULATIVE_ARGS;
-@@ -1309,8 +1337,13 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
+@@ -1232,8 +1260,13 @@ extern const char *aarch64_rewrite_mcpu (int argc, const char **argv);
  #define ASM_CPU_SPEC \
     MCPU_TO_MARCH_SPEC
  
@@ -2233,8 +2563,8 @@ index 359b6e8561f..db5fe441b36 100644
  
  #define ASM_OUTPUT_POOL_EPILOGUE  aarch64_asm_output_pool_epilogue
  
-@@ -1324,6 +1357,10 @@ extern GTY(()) tree aarch64_fp16_ptr_type_node;
- extern GTY(()) tree aarch64_bf16_type_node;
+@@ -1246,6 +1279,10 @@ extern GTY(()) tree aarch64_fp16_ptr_type_node;
+    bfloat16_type_node.  Defined in aarch64-builtins.cc.  */
  extern GTY(()) tree aarch64_bf16_ptr_type_node;
  
 +/* A pointer to the user-visible __float128 (on Mach-O).  Defined in
@@ -2245,18 +2575,18 @@ index 359b6e8561f..db5fe441b36 100644
     So in order to unwind a function using a frame pointer, the very first
     function that is unwound must save the frame pointer.  That way the frame
 diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
-index 34b8059b45b..c356d3048b5 100644
+index 36d0bb3f718..454c0fc1a8e 100644
 --- a/gcc/config/aarch64/aarch64.md
 +++ b/gcc/config/aarch64/aarch64.md
-@@ -303,6 +303,7 @@
-     UNSPEC_TAG_SPACE		; Translate address to MTE tag address space.
+@@ -304,6 +304,7 @@
      UNSPEC_LD1RO
      UNSPEC_SALT_ADDR
+     UNSPECV_PATCHABLE_AREA
 +    UNSPEC_MACHOPIC_OFFSET
  ])
  
  (define_c_enum "unspecv" [
-@@ -849,6 +850,37 @@
+@@ -850,6 +851,37 @@
    [(set_attr "type" "load_4")]
  )
  
@@ -2294,7 +2624,7 @@ index 34b8059b45b..c356d3048b5 100644
  (define_insn "trap"
    [(trap_if (const_int 1) (const_int 8))]
    ""
-@@ -1286,7 +1318,7 @@
+@@ -1304,7 +1336,7 @@
     ldr\\t%s0, %1
     str\\t%w1, %0
     str\\t%s1, %0
@@ -2303,7 +2633,7 @@ index 34b8059b45b..c356d3048b5 100644
     adr\\t%x0, %c1
     adrp\\t%x0, %A1
     fmov\\t%s0, %w1
-@@ -1325,7 +1357,7 @@
+@@ -1342,7 +1374,7 @@
     ldr\\t%d0, %1
     str\\t%x1, %0
     str\\t%d1, %0
@@ -2312,7 +2642,7 @@ index 34b8059b45b..c356d3048b5 100644
     adr\\t%x0, %c1
     adrp\\t%x0, %A1
     fmov\\t%d0, %x1
-@@ -6857,7 +6889,10 @@
+@@ -7019,7 +7051,10 @@
  	(lo_sum:P (match_operand:P 1 "register_operand" "r")
  		  (match_operand 2 "aarch64_valid_symref" "S")))]
    ""
@@ -2325,10 +2655,10 @@ index 34b8059b45b..c356d3048b5 100644
  )
  
 diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
-index 92220b26ee2..15ec719ca2d 100644
+index 1d7967db9c0..cc97d7263ba 100644
 --- a/gcc/config/aarch64/aarch64.opt
 +++ b/gcc/config/aarch64/aarch64.opt
-@@ -152,6 +152,13 @@ Enum(aarch64_abi) String(ilp32) Value(AARCH64_ABI_ILP32)
+@@ -158,6 +158,13 @@ Enum(aarch64_abi) String(ilp32) Value(AARCH64_ABI_ILP32)
  EnumValue
  Enum(aarch64_abi) String(lp64) Value(AARCH64_ABI_LP64)
  
@@ -2343,10 +2673,10 @@ index 92220b26ee2..15ec719ca2d 100644
  Target Save Var(pcrelative_literal_loads) Init(2) Save
  PC relative literal loads.
 diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md
-index ee7587cca16..cb73a2daae8 100644
+index 5b20abc27e5..9c6a631c6fb 100644
 --- a/gcc/config/aarch64/constraints.md
 +++ b/gcc/config/aarch64/constraints.md
-@@ -158,7 +158,9 @@
+@@ -168,7 +168,9 @@
     A constraint that matches a small GOT access."
    (and (match_code "const,symbol_ref")
         (match_test "aarch64_classify_symbolic_expression (op)
@@ -2357,7 +2687,7 @@ index ee7587cca16..cb73a2daae8 100644
  
  (define_constraint "Uss"
    "@internal
-@@ -490,6 +492,11 @@
+@@ -505,6 +507,11 @@
   An address valid for a prefetch instruction."
   (match_test "aarch64_address_valid_for_prefetch_p (op, true)"))
  
@@ -2371,10 +2701,10 @@ index ee7587cca16..cb73a2daae8 100644
     A constraint that matches an immediate offset valid for SVE LD1B
 diff --git a/gcc/config/aarch64/darwin.h b/gcc/config/aarch64/darwin.h
 new file mode 100644
-index 00000000000..2a855c11efa
+index 00000000000..5609c569dc1
 --- /dev/null
 +++ b/gcc/config/aarch64/darwin.h
-@@ -0,0 +1,280 @@
+@@ -0,0 +1,279 @@
 +/* Target definitions for Arm64/Aarch64 running on macOS/iOS.
 +
 +Copyright The GNU Toolchain Authors.
@@ -2589,7 +2919,7 @@ index 00000000000..2a855c11efa
 +/* Darwin has experimental support for section anchors on aarch64*; it is
 +   not enabled by default (the -fsection-anchors is required).  */
 +
-+#undef TARGET_ASM_OUTPUT_ANCHOR 
++#undef TARGET_ASM_OUTPUT_ANCHOR
 +#define TARGET_ASM_OUTPUT_ANCHOR darwin_asm_output_anchor
 +
 +#undef TARGET_USE_ANCHORS_FOR_SYMBOL_P
@@ -2654,9 +2984,8 @@ index 00000000000..2a855c11efa
 +#define CLEAR_INSN_CACHE(beg, end)				\
 +  extern void sys_icache_invalidate(void *start, size_t len);	\
 +  sys_icache_invalidate ((beg), (size_t)((end)-(beg)))
-+
 diff --git a/gcc/config/aarch64/falkor-tag-collision-avoidance.cc b/gcc/config/aarch64/falkor-tag-collision-avoidance.cc
-index 5f198290568..610838049e5 100644
+index 39e3f5c2d1b..78790cd1d15 100644
 --- a/gcc/config/aarch64/falkor-tag-collision-avoidance.cc
 +++ b/gcc/config/aarch64/falkor-tag-collision-avoidance.cc
 @@ -740,7 +740,7 @@ dump_insn_list (const rtx &t, const insn_info_list_t &insn_info,
@@ -2669,10 +2998,10 @@ index 5f198290568..610838049e5 100644
    for (unsigned i = 0; i < insn_info.length (); i++)
      dump_insn_slim (dump_file, insn_info[i]->insn);
 diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md
-index c308015ac2c..cd88f93ca2d 100644
+index 3f5f4df8c46..4c3498dfe2c 100644
 --- a/gcc/config/aarch64/predicates.md
 +++ b/gcc/config/aarch64/predicates.md
-@@ -261,9 +261,24 @@
+@@ -277,9 +277,24 @@
  (define_predicate "aarch64_prefetch_operand"
    (match_test "aarch64_address_valid_for_prefetch_p (op, false)"))
  
@@ -2699,7 +3028,7 @@ index c308015ac2c..cd88f93ca2d 100644
  })
 diff --git a/gcc/config/aarch64/t-aarch64-darwin b/gcc/config/aarch64/t-aarch64-darwin
 new file mode 100644
-index 00000000000..a8bfcffad78
+index 00000000000..9754e87ebcf
 --- /dev/null
 +++ b/gcc/config/aarch64/t-aarch64-darwin
 @@ -0,0 +1,25 @@
@@ -2725,11 +3054,11 @@ index 00000000000..a8bfcffad78
 +LIB1ASMSRC   = aarch64/lib1funcs.asm
 +LIB1ASMFUNCS = _aarch64_sync_cache_range
 +
-+# FIXME - figure out what multilib provisions we should make for 
++# FIXME - figure out what multilib provisions we should make for
 +# a) arm64e
 +# b) arm64_32
 diff --git a/gcc/config/darwin-driver.cc b/gcc/config/darwin-driver.cc
-index 00287f3d5ec..6df85f57bb4 100644
+index 9c1dcc3d794..a4d7cfe7376 100644
 --- a/gcc/config/darwin-driver.cc
 +++ b/gcc/config/darwin-driver.cc
 @@ -268,14 +268,21 @@ darwin_driver_init (unsigned int *decoded_options_count,
@@ -2868,7 +3197,7 @@ index 00287f3d5ec..6df85f57bb4 100644
 +#endif
  }
 diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
-index f065a13d73d..7cd684c6abe 100644
+index ced2f7e40a6..0915548477e 100644
 --- a/gcc/config/darwin.cc
 +++ b/gcc/config/darwin.cc
 @@ -118,7 +118,7 @@ static bool ld_init_term_start_labels = false;
@@ -2896,16 +3225,7 @@ index f065a13d73d..7cd684c6abe 100644
  
  int
  machopic_operand_p (rtx op)
-@@ -1936,6 +1938,8 @@ darwin_label_is_anonymous_local_objc_name (const char *name)
-     }
-   else if (startswith ((const char *)p, "ClassMethods"))
-     return false;
-+  else if (startswith ((const char *)p, "ClassProtocols"))
-+    return false;
-   else if (startswith ((const char *)p, "Instance"))
-     {
-       if (p[8] == 'I' || p[8] == 'M')
-@@ -2238,6 +2242,8 @@ darwin_emit_except_table_label (FILE *file)
+@@ -2240,6 +2242,8 @@ darwin_emit_except_table_label (FILE *file)
  rtx
  darwin_make_eh_symbol_indirect (rtx orig, bool ARG_UNUSED (pubvis))
  {
@@ -2914,7 +3234,7 @@ index f065a13d73d..7cd684c6abe 100644
    if (DARWIN_PPC == 0 && TARGET_64BIT)
      return orig;
  
-@@ -3058,7 +3064,12 @@ darwin_file_end (void)
+@@ -3060,7 +3064,12 @@ darwin_file_end (void)
        fprintf (asm_out_file, "\t.long\t0\n\t.long\t%u\n", flags);
       }
  
@@ -2928,7 +3248,7 @@ index f065a13d73d..7cd684c6abe 100644
      {
        /* These sections are only used for kernel code.  */
 diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
-index 51e257dc698..13ba6e61474 100644
+index 1b538c73593..7fb3ec40755 100644
 --- a/gcc/config/darwin.h
 +++ b/gcc/config/darwin.h
 @@ -42,6 +42,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
@@ -2939,9 +3259,9 @@ index 51e257dc698..13ba6e61474 100644
  
  #define OBJECT_FORMAT_MACHO 1
  
-@@ -296,6 +297,31 @@ extern GTY(()) int darwin_ms_struct;
+@@ -303,6 +304,31 @@ extern GTY(()) int darwin_ms_struct;
  #define DARWIN_CC1_SPEC							\
-   "%= 10.6, the unwinder *still* comes from libSystem and
--   we find the emutls impl from lemutls_w. In either case, the builtins etc.
--   are linked from -lgcc.
--
--   When we have specified shared-libgcc or any case that might require
--   exceptions, we pull the libgcc content (including emulated tls) from
--   -lgcc_s.1 in GCC and the unwinder from /usr/lib/libgcc_s.1 for < 10.6 and
--   libSystem for >= 10.6 respectively.
--   Otherwise, we just link the emutls/builtins from convenience libs.
--
--   If we need exceptions, prior to 10.3.9, then we have to link the static
--   eh lib, since there's no shared version on the system.
--
--   In all cases, libgcc_s.1 will be installed with the compiler, or any app
--   built using it, so we can link the builtins and emutls shared on all.
--
-    We have to work around that DYLD_XXXX are disabled in macOS 10.11+ which
-    means that any bootstrap trying to use a shared libgcc with a bumped SO-
-    name will fail.  This means that we do not accept shared libgcc for these
--   versions.
-+   versions, unless we have embedded run paths enabled, in which case the
-+   compiler will add the appropriate path to find the library.
-+
-+   For -static-libgcc: < 10.6, use the unwinder in libgcc_eh (and find
-+   the emultls impl. there too).
- 
-    For -static-libgcc: >= 10.6, the unwinder *still* comes from libSystem and
-    we find the emutls impl from lemutls_w. In either case, the builtins etc.
-    are linked from -lgcc.
-->
-+
-    Otherwise, we just link the shared version of gcc_s.1.1 and pick up
-    exceptions:
-      * Prior to 10.3.9, then we have to link the static eh lib, since there
-@@ -502,6 +515,10 @@ extern GTY(()) int darwin_ms_struct;
- 
-    In all cases, libgcc_s.1.1 will be installed with the compiler, or any app
-    built using it, so we can link the builtins and emutls shared on all.
-+
-+   On most Darwin systems (other than Arm64) we will also install a legacy
-+   support libgcc_s.1.dylib to support executables linked with libgcc_ext by
-+   earlier GCC versions.
- */
- #undef REAL_LIBGCC_SPEC
- #define REAL_LIBGCC_SPEC \
-@@ -509,8 +526,7 @@ extern GTY(()) int darwin_ms_struct;
+@@ -511,8 +539,7 @@ extern GTY(()) int darwin_ms_struct;
      %:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh)		  \
      %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w);		  \
     shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime:		  \
@@ -3044,7 +3312,7 @@ index 51e257dc698..13ba6e61474 100644
      %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh)		  \
      %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4)   \
      %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5);	  \
-@@ -545,7 +561,8 @@ extern GTY(()) int darwin_ms_struct;
+@@ -547,7 +574,8 @@ extern GTY(()) int darwin_ms_struct;
    { "darwin_crt2", DARWIN_CRT2_SPEC },					\
    { "darwin_crt3", DARWIN_CRT3_SPEC },					\
    { "darwin_dylib1", DARWIN_DYLIB1_SPEC },				\
@@ -3054,7 +3322,7 @@ index 51e257dc698..13ba6e61474 100644
  
  #define DARWIN_CRT1_SPEC						\
    "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o)		\
-@@ -571,6 +588,17 @@ extern GTY(()) int darwin_ms_struct;
+@@ -573,6 +601,17 @@ extern GTY(()) int darwin_ms_struct;
  "%{!static:%:version-compare(< 10.6 mmacosx-version-min= -lbundle1.o)	\
  	   %{fgnu-tm: -lcrttms.o}}"
  
@@ -3073,10 +3341,10 @@ index 51e257dc698..13ba6e61474 100644
  /* Emit macosx version (but only major).  */
  #define ASM_MMACOSX_VERSION_MIN_SPEC \
 diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt
-index cc7d14c2e4d..b1cb8464d57 100644
+index d655aaef2fb..ff624ffd82a 100644
 --- a/gcc/config/darwin.opt
 +++ b/gcc/config/darwin.opt
-@@ -237,6 +237,10 @@ nodefaultexport
+@@ -241,6 +241,10 @@ nodefaultexport
  Driver RejectNegative
  Do not add a default symbol exports to modules or dynamic libraries.
  
@@ -3088,7 +3356,7 @@ index cc7d14c2e4d..b1cb8464d57 100644
  Driver RejectNegative
  (Obsolete after 10.3.9) Set MH_NOPREFIXBINDING, in an executable.
 diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
-index a55f6b2b874..36a32867281 100644
+index 588bd669bdd..b6c9a94c3a0 100644
 --- a/gcc/config/i386/darwin.h
 +++ b/gcc/config/i386/darwin.h
 @@ -308,3 +308,10 @@ along with GCC; see the file COPYING3.  If not see
@@ -3103,10 +3371,10 @@ index a55f6b2b874..36a32867281 100644
 +  (!flag_off_stack_trampolines && !flag_trampolines) ? 1 : 0
 +
 diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
-index 9dd9fa68722..5cd4b5c0592 100644
+index a551b8b9d9b..dd9f22b440f 100644
 --- a/gcc/config/i386/i386.cc
 +++ b/gcc/config/i386/i386.cc
-@@ -24698,7 +24698,7 @@ ix86_libgcc_floating_mode_supported_p
+@@ -25189,7 +25189,7 @@ ix86_libgcc_floating_mode_supported_p
  #define TARGET_HARD_REGNO_SCRATCH_OK ix86_hard_regno_scratch_ok
  
  #undef TARGET_CUSTOM_FUNCTION_DESCRIPTORS
@@ -3116,10 +3384,10 @@ index 9dd9fa68722..5cd4b5c0592 100644
  #undef TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID
  #define TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID ix86_addr_space_zero_address_valid
 diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
-index 363082ba47b..5f56d7abf65 100644
+index 27b9783cae8..f97d3027da3 100644
 --- a/gcc/config/i386/i386.h
 +++ b/gcc/config/i386/i386.h
-@@ -746,6 +746,12 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
+@@ -754,6 +754,12 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
  /* Minimum allocation boundary for the code of a function.  */
  #define FUNCTION_BOUNDARY 8
  
@@ -3133,18 +3401,24 @@ index 363082ba47b..5f56d7abf65 100644
  #define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_pfn
  
 diff --git a/gcc/configure b/gcc/configure
-index 5ce0557719a..dbc127c59cb 100755
+index c7b26d1927d..f4bd9c5d5f1 100755
 --- a/gcc/configure
 +++ b/gcc/configure
-@@ -634,6 +634,7 @@ LIBOBJS
+@@ -632,10 +632,10 @@ ac_includes_default="\
+ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
  CET_HOST_FLAGS
- NO_PIE_FLAG
- NO_PIE_CFLAGS
-+enable_pie_tools
- enable_default_pie
+-NO_PIE_FLAG
+-NO_PIE_CFLAGS
+-enable_default_pie
++LD_PICFLAG
  PICFLAG
++enable_default_pie
++enable_host_pie
  enable_host_shared
-@@ -740,6 +741,8 @@ ORIGINAL_PLUGIN_LD_FOR_TARGET
+ enable_plugin
+ pluginlibs
+@@ -740,6 +740,8 @@ ORIGINAL_PLUGIN_LD_FOR_TARGET
  gcc_cv_ld
  ORIGINAL_AS_FOR_TARGET
  gcc_cv_as
@@ -3153,7 +3427,7 @@ index 5ce0557719a..dbc127c59cb 100755
  enable_fast_install
  objdir
  OTOOL64
-@@ -1000,6 +1003,8 @@ enable_static
+@@ -1003,6 +1005,8 @@ enable_static
  with_pic
  enable_fast_install
  enable_libtool_lock
@@ -3162,15 +3436,15 @@ index 5ce0557719a..dbc127c59cb 100755
  enable_ld
  enable_gold
  with_plugin_ld
-@@ -1030,6 +1035,7 @@ with_linker_hash_style
+@@ -1028,6 +1032,7 @@ enable_link_serialization
+ enable_version_specific_runtime_libs
+ enable_plugin
+ enable_host_shared
++enable_host_pie
+ enable_libquadmath_support
+ with_linker_hash_style
  with_diagnostics_color
- with_diagnostics_urls
- enable_default_pie
-+enable_pie_tools
- enable_cet
- enable_s390_excess_float_precision
- '
-@@ -1733,6 +1739,8 @@ Optional Features:
+@@ -1736,6 +1741,8 @@ Optional Features:
    --enable-fast-install[=PKGS]
                            optimize for fast installation [default=yes]
    --disable-libtool-lock  avoid locking (might break parallel builds)
@@ -3179,16 +3453,15 @@ index 5ce0557719a..dbc127c59cb 100755
    --enable-ld[=ARG]       build ld [ARG={default,yes,no}]
    --enable-gold[=ARG]     build gold [ARG={default,yes,no}]
    --enable-gnu-indirect-function
-@@ -1790,6 +1798,8 @@ Optional Features:
+@@ -1790,6 +1797,7 @@ Optional Features:
+                           in a compiler-specific directory
+   --enable-plugin         enable plugin support
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
    --disable-libquadmath-support
                            disable libquadmath support for Fortran
    --enable-default-pie    enable Position Independent Executable as default
-+  --enable-pie-tools      build Position Independent Executables for the
-+                          compilers and other tools
-   --enable-cet            enable Intel CET in host libraries [default=auto]
-   --enable-s390-excess-float-precision
-                           on s390 targets, evaluate float with double
-@@ -1850,6 +1860,9 @@ Optional Packages:
+@@ -1854,6 +1862,9 @@ Optional Packages:
    --with-pic              try to use only PIC/non-PIC objects [default=use
                            both]
    --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -3198,26 +3471,70 @@ index 5ce0557719a..dbc127c59cb 100755
    --with-plugin-ld=[ARG]  specify the plugin linker
    --with-glibc-version=M.N
                            assume GCC used with glibc version M.N or later
-@@ -3766,15 +3779,24 @@ if test x${gcc_gxx_libcxx_include_dir} != x; then
- $as_echo "#define ENABLE_STDLIB_OPTION 1" >>confdefs.h
+@@ -3753,33 +3764,59 @@ gcc_gxx_libcxx_include_dir=
+ 
+ # Check whether --with-gxx-libcxx-include-dir was given.
+ if test "${with_gxx_libcxx_include_dir+set}" = set; then :
+-  withval=$with_gxx_libcxx_include_dir; case "${withval}" in
+-yes)	as_fn_error $? "bad value ${withval} given for libc++ include directory" "$LINENO" 5 ;;
+-no)	;;
+-*)	gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir ;;
+-esac
++  withval=$with_gxx_libcxx_include_dir; gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir
+ fi
  
- else
--  $as_echo "#define ENABLE_STDLIB_OPTION 0" >>confdefs.h
+ 
++# --with-gxx-libcxx-include-dir controls the enabling of the -stdlib option.
++# if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option.
++# if --with-gxx-libcxx-include-dir is 'yes' we enable the stdlib option and use
++# the default path within the installation.
++# if --with-gxx-libcxx-include-dir is unset we enable the stdlib option
++# based on the platform (to be available on platform versions where it is the
++# default for the system tools). We also use a default path within the compiler
++# install tree.
++# Otherwise, we use the path provided and enable the stdlib option.
+ # If both --with-sysroot and --with-gxx-libcxx-include-dir are passed, we
+ # check to see if the latter starts with the former and, upon success, compute
+ # gcc_gxx_libcxx_include_dir as relative to the sysroot.
+ gcc_gxx_libcxx_include_dir_add_sysroot=0
+-
++gcc_enable_stdlib_opt=0
+ if test x${gcc_gxx_libcxx_include_dir} != x; then
++  if test x${gcc_gxx_libcxx_include_dir} = xno; then
++    # set defaults for the dir, but the option is disabled anyway.
++    gcc_gxx_libcxx_include_dir=
++  elif test x${gcc_gxx_libcxx_include_dir} = xyes; then
++    # set defaults for the dir, and enable.
++    gcc_gxx_libcxx_include_dir=
++    gcc_enable_stdlib_opt=1
++  else
++    gcc_enable_stdlib_opt=1
++  fi
++else
 +  case $target in
 +    *-darwin1[1-9]* | *-darwin2*)
-+       # Default this on for Darwin versions which default to libcxx.
-+       $as_echo "#define ENABLE_STDLIB_OPTION 1" >>confdefs.h
- 
-+       ;;
-+    *)
-+       $as_echo "#define ENABLE_STDLIB_OPTION 0" >>confdefs.h
-+
++       # Default this on for Darwin versions which default to libcxx,
++       # and embed the path in the compiler install so that we get a
++       # self-contained toolchain.
++       gcc_enable_stdlib_opt=1
 +       ;;
++    *) ;;
 +  esac
- fi
++fi
+ 
+-$as_echo "#define ENABLE_STDLIB_OPTION 1" >>confdefs.h
++cat >>confdefs.h <<_ACEOF
++#define ENABLE_STDLIB_OPTION $gcc_enable_stdlib_opt
++_ACEOF
+ 
+-else
+-  $as_echo "#define ENABLE_STDLIB_OPTION 0" >>confdefs.h
+ 
+-fi
 -# ??? This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO.
-+
++# Sysroot behaviour as for gxx-include-dir
  if test x${gcc_gxx_libcxx_include_dir} = x; then
++  # default path,embedded in the compiler tree.
 +  libcxx_incdir='include/c++/v1'
    if test x${enable_version_specific_runtime_libs} = xyes; then
 -    gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1'
@@ -3227,7 +3544,16 @@ index 5ce0557719a..dbc127c59cb 100755
      if test x$host != x$target; then
         libcxx_incdir="$target_alias/$libcxx_incdir"
      fi
-@@ -17867,6 +17889,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -16295,7 +16332,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -18000,6 +18037,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -3244,8 +3570,9 @@ index 5ce0557719a..dbc127c59cb 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -3253,15 +3580,16 @@ index 5ce0557719a..dbc127c59cb 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -3275,49 +3603,41 @@ index 5ce0557719a..dbc127c59cb 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -17884,10 +17947,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -18017,9 +18097,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -19673,7 +19745,7 @@ else
+@@ -19825,7 +19909,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 19676 "configure"
-+#line 19748 "configure"
+-#line 19828 "configure"
++#line 19912 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -19779,7 +19851,7 @@ else
+@@ -19931,7 +20015,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 19782 "configure"
-+#line 19854 "configure"
+-#line 19934 "configure"
++#line 20018 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -20655,6 +20727,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -20807,6 +20891,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
        darwin* | rhapsody*)
  
  
@@ -3334,8 +3654,9 @@ index 5ce0557719a..dbc127c59cb 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -3343,15 +3664,16 @@ index 5ce0557719a..dbc127c59cb 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -3365,38 +3687,31 @@ index 5ce0557719a..dbc127c59cb 100755
    archive_cmds_need_lc_CXX=no
    hardcode_direct_CXX=no
    hardcode_automatic_CXX=yes
-@@ -20672,12 +20785,25 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -20824,12 +20951,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
         if test "$lt_cv_apple_cc_single_mod" != "yes"; then
 -      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++      _lt_install_name='\$rpath/\$soname'
 +      if test "x$enable_darwin_at_rpath" = "xyes"; then
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring${_lt_dsymutil}"
-+      else
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++        _lt_install_name='@rpath/\$soname'
 +      fi
++      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring${_lt_dsymutil}"
        archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
      fi
  
-@@ -23028,6 +23154,35 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+@@ -23200,6 +23335,35 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
  
  
  
@@ -3432,30 +3747,69 @@ index 5ce0557719a..dbc127c59cb 100755
  # Identify the assembler which will work hand-in-glove with the newly
  # built GCC, so that we can examine its features.  This is the assembler
  # which will be driven by the driver program.
-@@ -32429,6 +32584,22 @@ $as_echo "#define ENABLE_DEFAULT_PIE 1" >>confdefs.h
+@@ -32062,13 +32226,17 @@ fi
+ # Enable --enable-host-shared
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
+-else
+-  PICFLAG=
++  enableval=$enable_host_shared;
  fi
  
  
-+# Check whether --enable-pie-tools was given; this is passed automatically
-+# from the top level where it has already been validated.
-+# Check whether --enable-pie-tools was given.
-+if test "${enable_pie_tools+set}" = set; then :
-+  enableval=$enable_pie_tools; enable_pie_tools=$enableval
-+else
-+  enable_pie_tools=no
+ 
++# Enable --enable-host-pie
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
 +fi
 +
-+if test x$enable_pie_tools = xyes ; then
-+
-+$as_echo "#define ENABLE_PIE_TOOLS 1" >>confdefs.h
-+
+ 
+ 
+ # Check whether --enable-libquadmath-support was given.
+@@ -32222,10 +32390,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_c_no_fpie" >&5
+ $as_echo "$gcc_cv_c_no_fpie" >&6; }
+-if test "$gcc_cv_c_no_fpie" = "yes"; then
+-  NO_PIE_CFLAGS="-fno-PIE"
+-fi
+-
+ 
+ # Check if -no-pie works.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5
+@@ -32250,10 +32414,27 @@ rm -f core conftest.err conftest.$ac_objext \
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5
+ $as_echo "$gcc_cv_no_pie" >&6; }
+-if test "$gcc_cv_no_pie" = "yes"; then
+-  NO_PIE_FLAG="-no-pie"
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++elif test x$gcc_cv_c_no_fpie = xyes; then
++  PICFLAG=-fno-PIE
++else
++  PICFLAG=
+ fi
+ 
++if test x$enable_host_pie = xyes; then
++  LD_PICFLAG=-pie
++elif test x$gcc_cv_no_pie = xyes; then
++  LD_PICFLAG=-no-pie
++else
++  LD_PICFLAG=
 +fi
 +
 +
- # Check if -fno-PIE works.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-PIE option" >&5
- $as_echo_n "checking for -fno-PIE option... " >&6; }
-@@ -32966,6 +33137,10 @@ LTLIBOBJS=$ac_ltlibobjs
++
+ 
+ # Enable Intel CET on Intel CET enabled host if jit is enabled.
+  # Check whether --enable-cet was given.
+@@ -32737,6 +32918,10 @@ LTLIBOBJS=$ac_ltlibobjs
  
  
  
@@ -3467,27 +3821,68 @@ index 5ce0557719a..dbc127c59cb 100755
  : "${CONFIG_STATUS=./config.status}"
  ac_write_fail=0
 diff --git a/gcc/configure.ac b/gcc/configure.ac
-index 23bee7010a3..2d9159989e4 100644
+index 09082e8ccae..d181e41154c 100644
 --- a/gcc/configure.ac
 +++ b/gcc/configure.ac
-@@ -249,14 +249,22 @@ if test x${gcc_gxx_libcxx_include_dir} != x; then
-   AC_DEFINE(ENABLE_STDLIB_OPTION, 1,
-             [Define if the -stdlib= option should be enabled.])
+@@ -235,29 +235,54 @@ gcc_gxx_libcxx_include_dir=
+ AC_ARG_WITH(gxx-libcxx-include-dir,
+ [AS_HELP_STRING([--with-gxx-libcxx-include-dir=DIR],
+                 [specifies directory to find libc++ header files])],
+-[case "${withval}" in
+-yes)	AC_MSG_ERROR(bad value ${withval} given for libc++ include directory) ;;
+-no)	;;
+-*)	gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir ;;
+-esac])
+-
++[gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir])
++
++# --with-gxx-libcxx-include-dir controls the enabling of the -stdlib option.
++# if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option.
++# if --with-gxx-libcxx-include-dir is 'yes' we enable the stdlib option and use
++# the default path within the installation.
++# if --with-gxx-libcxx-include-dir is unset we enable the stdlib option
++# based on the platform (to be available on platform versions where it is the
++# default for the system tools). We also use a default path within the compiler
++# install tree.
++# Otherwise, we use the path provided and enable the stdlib option.
+ # If both --with-sysroot and --with-gxx-libcxx-include-dir are passed, we
+ # check to see if the latter starts with the former and, upon success, compute
+ # gcc_gxx_libcxx_include_dir as relative to the sysroot.
+ gcc_gxx_libcxx_include_dir_add_sysroot=0
+-
++gcc_enable_stdlib_opt=0
+ if test x${gcc_gxx_libcxx_include_dir} != x; then
+-  AC_DEFINE(ENABLE_STDLIB_OPTION, 1,
+-            [Define if the -stdlib= option should be enabled.])
++  if test x${gcc_gxx_libcxx_include_dir} = xno; then
++    # set defaults for the dir, but the option is disabled anyway.
++    gcc_gxx_libcxx_include_dir=
++  elif test x${gcc_gxx_libcxx_include_dir} = xyes; then
++    # set defaults for the dir, and enable.
++    gcc_gxx_libcxx_include_dir=
++    gcc_enable_stdlib_opt=1
++  else
++    gcc_enable_stdlib_opt=1
++  fi
  else
 -  AC_DEFINE(ENABLE_STDLIB_OPTION, 0)
 +  case $target in
 +    *-darwin1[[1-9]]* | *-darwin2*)
-+       # Default this on for Darwin versions which default to libcxx.
-+       AC_DEFINE(ENABLE_STDLIB_OPTION, 1)
-+       ;;
-+    *)
-+       AC_DEFINE(ENABLE_STDLIB_OPTION, 0)
++       # Default this on for Darwin versions which default to libcxx,
++       # and embed the path in the compiler install so that we get a
++       # self-contained toolchain.
++       gcc_enable_stdlib_opt=1
 +       ;;
++    *) ;;
 +  esac
  fi
 -# ??? This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO.
++AC_DEFINE_UNQUOTED(ENABLE_STDLIB_OPTION, $gcc_enable_stdlib_opt,
++          [Define if the -stdlib= option should be enabled.])
 +
++# Sysroot behaviour as for gxx-include-dir
  if test x${gcc_gxx_libcxx_include_dir} = x; then
++  # default path,embedded in the compiler tree.
 +  libcxx_incdir='include/c++/v1'
    if test x${enable_version_specific_runtime_libs} = xyes; then
 -    gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1'
@@ -3497,7 +3892,7 @@ index 23bee7010a3..2d9159989e4 100644
      if test x$host != x$target; then
         libcxx_incdir="$target_alias/$libcxx_incdir"
      fi
-@@ -2559,6 +2567,21 @@ AC_PROG_LIBTOOL
+@@ -2586,6 +2611,21 @@ AC_PROG_LIBTOOL
  AC_SUBST(objdir)
  AC_SUBST(enable_fast_install)
  
@@ -3519,31 +3914,71 @@ index 23bee7010a3..2d9159989e4 100644
  # Identify the assembler which will work hand-in-glove with the newly
  # built GCC, so that we can examine its features.  This is the assembler
  # which will be driven by the driver program.
-@@ -7646,6 +7669,19 @@ if test x$enable_default_pie = xyes ; then
+@@ -7400,11 +7440,14 @@ fi
+ # Enable --enable-host-shared
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
++		[build host code as shared libraries])])
+ AC_SUBST(enable_host_shared)
+-AC_SUBST(PICFLAG)
+ 
++# Enable --enable-host-pie
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])])
++AC_SUBST(enable_host_pie)
+ 
+ AC_ARG_ENABLE(libquadmath-support,
+ [AS_HELP_STRING([--disable-libquadmath-support],
+@@ -7526,10 +7569,6 @@ AC_CACHE_CHECK([for -fno-PIE option],
+      [gcc_cv_c_no_fpie=yes],
+      [gcc_cv_c_no_fpie=no])
+    CXXFLAGS="$saved_CXXFLAGS"])
+-if test "$gcc_cv_c_no_fpie" = "yes"; then
+-  NO_PIE_CFLAGS="-fno-PIE"
+-fi
+-AC_SUBST([NO_PIE_CFLAGS])
+ 
+ # Check if -no-pie works.
+ AC_CACHE_CHECK([for -no-pie option],
+@@ -7540,10 +7579,27 @@ AC_CACHE_CHECK([for -no-pie option],
+      [gcc_cv_no_pie=yes],
+      [gcc_cv_no_pie=no])
+    LDFLAGS="$saved_LDFLAGS"])
+-if test "$gcc_cv_no_pie" = "yes"; then
+-  NO_PIE_FLAG="-no-pie"
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++elif test x$gcc_cv_c_no_fpie = xyes; then
++  PICFLAG=-fno-PIE
++else
++  PICFLAG=
  fi
- AC_SUBST([enable_default_pie])
- 
-+# Check whether --enable-pie-tools was given; this is passed automatically
-+# from the top level where it has already been validated.
-+AC_ARG_ENABLE(pie-tools,
-+[AS_HELP_STRING([--enable-pie-tools],
-+  [build Position Independent Executables for the compilers and other tools])],
-+[enable_pie_tools=$enableval],
-+[enable_pie_tools=no])
-+if test x$enable_pie_tools = xyes ; then
-+  AC_DEFINE(ENABLE_PIE_TOOLS, 1,
-+      [Define if you build Position Independent Executables for the compilers and other tools.])
+-AC_SUBST([NO_PIE_FLAG])
++
++if test x$enable_host_pie = xyes; then
++  LD_PICFLAG=-pie
++elif test x$gcc_cv_no_pie = xyes; then
++  LD_PICFLAG=-no-pie
++else
++  LD_PICFLAG=
 +fi
-+AC_SUBST([enable_pie_tools])
 +
- # Check if -fno-PIE works.
- AC_CACHE_CHECK([for -fno-PIE option],
-   [gcc_cv_c_no_fpie],
++AC_SUBST([PICFLAG])
++AC_SUBST([LD_PICFLAG])
+ 
+ # Enable Intel CET on Intel CET enabled host if jit is enabled.
+ GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
 diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
-index d7e9980ff1e..ff2a1f6665f 100644
+index 1dd3c2b13bc..3d75d0099ed 100644
 --- a/gcc/cp/decl2.cc
 +++ b/gcc/cp/decl2.cc
-@@ -3653,9 +3653,8 @@ get_tls_init_fn (tree var)
+@@ -3703,9 +3703,8 @@ get_tls_init_fn (tree var)
    if (!flag_extern_tls_init && DECL_EXTERNAL (var))
      return NULL_TREE;
  
@@ -3555,7 +3990,33 @@ index d7e9980ff1e..ff2a1f6665f 100644
      return get_local_tls_init_fn (DECL_SOURCE_LOCATION (var));
  
    tree sname = mangle_tls_init_fn (var);
-@@ -4801,22 +4800,24 @@ handle_tls_init (void)
+@@ -3868,6 +3867,25 @@ generate_tls_wrapper (tree fn)
+   expand_or_defer_fn (finish_function (/*inline_p=*/false));
+ }
+ 
++/* A dummy init function to act as a weak placeholder for a (possibly non-
++   existent) dynamic init.  */
++static void
++generate_tls_dummy_init (tree fn)
++{
++  tree var = DECL_BEFRIENDING_CLASSES (fn);
++  tree init_fn = get_tls_init_fn (var);
++  /* If have no init fn, or it is non-weak, then we do not need to make a
++     dummy.  */
++  if (!init_fn || !lookup_attribute ("weak", DECL_ATTRIBUTES (init_fn)))
++    return;
++  start_preparsed_function (init_fn, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED);
++  tree body = begin_function_body ();
++  declare_weak (init_fn);
++  finish_return_stmt (NULL_TREE);
++  finish_function_body (body);
++  expand_or_defer_fn (finish_function (/*inline_p=*/false));
++}
++
+ /* Start a global constructor or destructor function.  */
+ 
+ static tree
+@@ -4657,22 +4675,24 @@ handle_tls_init (void)
    finish_expr_stmt (cp_build_modify_expr (loc, guard, NOP_EXPR,
  					  boolean_true_node,
  					  tf_warning_or_error));
@@ -3564,13 +4025,13 @@ index d7e9980ff1e..ff2a1f6665f 100644
      {
        tree var = TREE_VALUE (vars);
        tree init = TREE_PURPOSE (vars);
-       one_static_initialization_or_destruction (var, init, true);
+       one_static_initialization_or_destruction (/*initp=*/true, var, init);
  
 -      /* Output init aliases even with -fno-extern-tls-init.  */
 -      if (TARGET_SUPPORTS_ALIASES && TREE_PUBLIC (var))
 +      /* Output inits even with -fno-extern-tls-init.
-+	 We save the list here and output either an alias or a stub function
-+	 below.  */
++	We save the list here and output either an alias or a stub function
++	below.  */
 +      if (TREE_PUBLIC (var))
  	{
 -          tree single_init_fn = get_tls_init_fn (var);
@@ -3587,7 +4048,7 @@ index d7e9980ff1e..ff2a1f6665f 100644
  	}
      }
  
-@@ -4824,6 +4825,30 @@ handle_tls_init (void)
+@@ -4680,6 +4700,30 @@ handle_tls_init (void)
    finish_if_stmt (if_stmt);
    finish_function_body (body);
    expand_or_defer_fn (finish_function (/*inline_p=*/false));
@@ -3618,23 +4079,22 @@ index d7e9980ff1e..ff2a1f6665f 100644
  }
  
  /* We're at the end of compilation, so generate any mangling aliases that
-diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc
-index 8174d652776..2e1e06e6ac9 100644
---- a/gcc/cp/g++spec.cc
-+++ b/gcc/cp/g++spec.cc
-@@ -222,7 +222,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
- 
- 	case OPT_static_libstdc__:
- 	  library = library >= 0 ? 2 : library;
-+#ifdef HAVE_LD_STATIC_DYNAMIC
-+	  /* Remove -static-libstdc++ from the command only if target supports
-+	     LD_STATIC_DYNAMIC.  When not supported, it is left in so that a
-+	     back-end target can use outfile substitution.  */
- 	  args[i] |= SKIPOPT;
-+#endif
- 	  break;
+@@ -5098,7 +5142,14 @@ c_parse_final_cleanups (void)
+ 	    }
+ 
+ 	  if (!DECL_INITIAL (decl) && decl_tls_wrapper_p (decl))
+-	    generate_tls_wrapper (decl);
++	    {
++	      generate_tls_wrapper (decl);
++	      /* The wrapper might have a weak reference to an init, we provide
++		 a dummy function to satisfy that here.  The linker/dynamic
++		 loader will override this with the actual init, if one is
++		 required.  */
++	      generate_tls_dummy_init (decl);
++	    }
  
- 	case OPT_stdlib_:
+ 	  if (!DECL_SAVED_TREE (decl))
+ 	    continue;
 diff --git a/gcc/cumulative-args.h b/gcc/cumulative-args.h
 new file mode 100644
 index 00000000000..b60928e37f9
@@ -3661,32 +4121,72 @@ index 00000000000..b60928e37f9
 +#endif /* !CHECKING_P */
 +
 +#endif /* GCC_CUMULATIVE_ARGS_H */
+diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
+index 1679fb81097..4fbf2096416 100644
+--- a/gcc/d/Make-lang.in
++++ b/gcc/d/Make-lang.in
+@@ -64,7 +64,7 @@ ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC $(CHECKING_DFLAGS) \
+ 	$(PICFLAG) $(ALIASING_FLAGS) $(NOEXCEPTION_DFLAGS) $(COVERAGE_FLAGS) \
+ 	$(WARN_DFLAGS)
+ 
+-DCOMPILE.base = $(GDC) $(NO_PIE_CFLAGS) -c $(ALL_DFLAGS) -o $@
++DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
+ DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
+ DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
+ DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++
+diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
+index b30d3691fe6..93d5236f7b3 100644
+--- a/gcc/doc/install.texi
++++ b/gcc/doc/install.texi
+@@ -1075,14 +1075,26 @@ code.
+ 
+ @item --enable-host-shared
+ Specify that the @emph{host} code should be built into position-independent
+-machine code (with -fPIC), allowing it to be used within shared libraries,
+-but yielding a slightly slower compiler.
++machine code (with @option{-fPIC}), allowing it to be used within shared
++libraries, but yielding a slightly slower compiler.
+ 
+ This option is required when building the libgccjit.so library.
+ 
+ Contrast with @option{--enable-shared}, which affects @emph{target}
+ libraries.
+ 
++@item --enable-host-pie
++Specify that the @emph{host} executables should be built into
++position-independent executables (with @option{-fPIE} and @option{-pie}),
++yielding a slightly slower compiler (but faster than
++@option{--enable-host-shared}).  Position-independent executables are loaded
++at random addresses each time they are executed, therefore provide additional
++protection against Return Oriented Programming (ROP) attacks.
++
++@option{--enable-host-pie}) may be used with @option{--enable-host-shared}),
++in which case @option{-fPIC} is used when compiling, and @option{-pie} when
++linking.
++
+ @item @anchor{with-gnu-as}--with-gnu-as
+ Specify that the compiler should assume that the
+ assembler it finds is the GNU assembler.  However, this does not modify
 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
-index ff6c338bedb..55c8ba8969f 100644
+index de40f62e219..f735557aed0 100644
 --- a/gcc/doc/invoke.texi
 +++ b/gcc/doc/invoke.texi
-@@ -670,6 +670,7 @@ Objective-C and Objective-C++ Dialects}.
- @gccoptlist{-fcall-saved-@var{reg}  -fcall-used-@var{reg} @gol
- -ffixed-@var{reg}  -fexceptions @gol
- -fnon-call-exceptions  -fdelete-dead-exceptions  -funwind-tables @gol
-+-foff-stack-trampolines @gol
- -fasynchronous-unwind-tables @gol
- -fno-gnu-unique @gol
- -finhibit-size-directive  -fcommon  -fno-ident @gol
-@@ -680,6 +681,7 @@ Objective-C and Objective-C++ Dialects}.
- -fverbose-asm  -fpack-struct[=@var{n}]  @gol
- -fleading-underscore  -ftls-model=@var{model} @gol
- -fstack-reuse=@var{reuse_level} @gol
-+-fstack-use-cumulative-args @gol
- -ftrampolines  -ftrapv  -fwrapv @gol
- -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} @gol
+@@ -707,7 +707,8 @@ Objective-C and Objective-C++ Dialects}.
+ -fverbose-asm  -fpack-struct[=@var{n}]
+ -fleading-underscore  -ftls-model=@var{model}
+ -fstack-reuse=@var{reuse_level}
+--ftrampolines  -ftrapv  -fwrapv
++-fstack-use-cumulative-args
++-ftrampolines -foff-stack-trampolines -ftrapv  -fwrapv
+ -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
  -fstrict-volatile-bitfields  -fsync-libcalls}
-@@ -17071,6 +17073,17 @@ the behavior of older compilers in which temporaries' stack space is
+ 
+@@ -18160,6 +18161,17 @@ the behavior of older compilers in which temporaries' stack space is
  not reused, the aggressive stack reuse can lead to runtime errors. This
  option is used to control the temporary stack reuse optimization.
  
-+@item -fstack-use-cumulative-args
 +@opindex fstack_use_cumulative_args
++@item -fstack-use-cumulative-args
 +This option instructs the compiler to use the
 +@code{cumulative_args_t}-based stack layout target hooks,
 +@code{TARGET_FUNCTION_ARG_BOUNDARY_CA} and
@@ -3696,15 +4196,15 @@ index ff6c338bedb..55c8ba8969f 100644
 +AArch64 Darwin) require using the more advanced @code{_CA}-based
 +hooks: For these targets this option should be enabled by default.
 +
- @item -ftrapv
  @opindex ftrapv
+ @item -ftrapv
  This option generates traps for signed overflow on addition, subtraction,
-@@ -17129,6 +17142,19 @@ instructions.  It does not allow exceptions to be thrown from
+@@ -18218,6 +18230,19 @@ instructions.  It does not allow exceptions to be thrown from
  arbitrary signal handlers such as @code{SIGALRM}.  This enables
  @option{-fexceptions}.
  
-+@item -foff-stack-trampolines
 +@opindex foff-stack-trampolines
++@item -foff-stack-trampolines
 +Certain platforms (such as the Apple M1) do not permit an executable
 +stack. Generate calls to @code{__builtin_nested_func_ptr_created} and
 +@code{__builtin_nested_func_ptr_deleted} in order to allocate and
@@ -3716,14 +4216,14 @@ index ff6c338bedb..55c8ba8969f 100644
 +instantiate nested functions, and then @code{longjmp} back to a state
 +prior to having allocated those nested functions.
 +
- @item -fdelete-dead-exceptions
  @opindex fdelete-dead-exceptions
+ @item -fdelete-dead-exceptions
  Consider that instructions that may throw exceptions but don't otherwise
 diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
-index c5006afc00d..366360612e3 100644
+index a660e33739b..4479f8cbf0e 100644
 --- a/gcc/doc/tm.texi
 +++ b/gcc/doc/tm.texi
-@@ -4322,6 +4322,16 @@ with the specified mode and type.  The default hook returns
+@@ -4354,6 +4354,16 @@ with the specified mode and type.  The default hook returns
  @code{PARM_BOUNDARY} for all arguments.
  @end deftypefn
  
@@ -3740,7 +4240,7 @@ index c5006afc00d..366360612e3 100644
  @deftypefn {Target Hook} {unsigned int} TARGET_FUNCTION_ARG_ROUND_BOUNDARY (machine_mode @var{mode}, const_tree @var{type})
  Normally, the size of an argument is rounded up to @code{PARM_BOUNDARY},
  which is the default value for this hook.  You can define this hook to
-@@ -4329,6 +4339,16 @@ return a different value if an argument size must be rounded to a larger
+@@ -4361,6 +4371,16 @@ return a different value if an argument size must be rounded to a larger
  value.
  @end deftypefn
  
@@ -3758,10 +4258,10 @@ index c5006afc00d..366360612e3 100644
  A C expression that is nonzero if @var{regno} is the number of a hard
  register in which function arguments are sometimes passed.  This does
 diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
-index f869ddd5e5b..2c9f0f0bf14 100644
+index f7ab5d48a63..cf6259c6cf6 100644
 --- a/gcc/doc/tm.texi.in
 +++ b/gcc/doc/tm.texi.in
-@@ -3330,8 +3330,12 @@ required.
+@@ -3341,8 +3341,12 @@ required.
  
  @hook TARGET_FUNCTION_ARG_BOUNDARY
  
@@ -3775,10 +4275,10 @@ index f869ddd5e5b..2c9f0f0bf14 100644
  A C expression that is nonzero if @var{regno} is the number of a hard
  register in which function arguments are sometimes passed.  This does
 diff --git a/gcc/function.cc b/gcc/function.cc
-index ad0096a43ef..e5044a60741 100644
+index edf0b2ec6cf..a8d49aa7613 100644
 --- a/gcc/function.cc
 +++ b/gcc/function.cc
-@@ -2445,7 +2445,10 @@ assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm,
+@@ -2448,7 +2448,10 @@ assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm,
    else if (DECL_CHAIN (parm))
      data->arg.named = 1;  /* Not the last non-variadic parm. */
    else if (targetm.calls.strict_argument_naming (all->args_so_far))
@@ -3790,7 +4290,7 @@ index ad0096a43ef..e5044a60741 100644
    else
      data->arg.named = 0;  /* Treat as variadic.  */
  
-@@ -2502,6 +2505,7 @@ assign_parms_setup_varargs (struct assign_parm_data_all *all,
+@@ -2505,6 +2508,7 @@ assign_parms_setup_varargs (struct assign_parm_data_all *all,
  
    function_arg_info last_named_arg = data->arg;
    last_named_arg.named = true;
@@ -3798,7 +4298,7 @@ index ad0096a43ef..e5044a60741 100644
    targetm.calls.setup_incoming_varargs (all->args_so_far, last_named_arg,
  					&varargs_pretend_bytes, no_rtl);
  
-@@ -2610,7 +2614,9 @@ assign_parm_find_entry_rtl (struct assign_parm_data_all *all,
+@@ -2613,7 +2617,9 @@ assign_parm_find_entry_rtl (struct assign_parm_data_all *all,
  
    locate_and_pad_parm (data->arg.mode, data->arg.type, in_regs,
  		       all->reg_parm_stack_space,
@@ -3809,7 +4309,7 @@ index ad0096a43ef..e5044a60741 100644
  		       &all->stack_args_size, &data->locate);
  
    /* Update parm_stack_boundary if this parameter is passed in the
-@@ -3924,7 +3930,8 @@ gimplify_parameters (gimple_seq *cleanup)
+@@ -3944,7 +3950,8 @@ gimplify_parameters (gimple_seq *cleanup)
        if (data.arg.pass_by_reference)
  	{
  	  tree type = TREE_TYPE (data.arg.type);
@@ -3819,7 +4319,7 @@ index ad0096a43ef..e5044a60741 100644
  	  if (reference_callee_copied (&all.args_so_far_v, orig_arg))
  	    {
  	      tree local, t;
-@@ -4027,6 +4034,7 @@ gimplify_parameters (gimple_seq *cleanup)
+@@ -4047,6 +4054,7 @@ gimplify_parameters (gimple_seq *cleanup)
  void
  locate_and_pad_parm (machine_mode passed_mode, tree type, int in_regs,
  		     int reg_parm_stack_space, int partial,
@@ -3827,7 +4327,7 @@ index ad0096a43ef..e5044a60741 100644
  		     tree fndecl ATTRIBUTE_UNUSED,
  		     struct args_size *initial_offset_ptr,
  		     struct locate_and_pad_arg_data *locate)
-@@ -4064,9 +4072,23 @@ locate_and_pad_parm (machine_mode passed_mode, tree type, int in_regs,
+@@ -4084,9 +4092,23 @@ locate_and_pad_parm (machine_mode passed_mode, tree type, int in_regs,
  	      ? arg_size_in_bytes (type)
  	      : size_int (GET_MODE_SIZE (passed_mode)));
    where_pad = targetm.calls.function_arg_padding (passed_mode, type);
@@ -3855,7 +4355,7 @@ index ad0096a43ef..e5044a60741 100644
  
    /* Alignment can't exceed MAX_SUPPORTED_STACK_ALIGNMENT.  */
 diff --git a/gcc/function.h b/gcc/function.h
-index 098613766be..009a9dc1c44 100644
+index d4ce8a7c6c6..09ab17e66c1 100644
 --- a/gcc/function.h
 +++ b/gcc/function.h
 @@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
@@ -3866,7 +4366,7 @@ index 098613766be..009a9dc1c44 100644
  
  /* Stack of pending (incomplete) sequences saved by `start_sequence'.
     Each element describes one pending sequence.
-@@ -661,6 +662,7 @@ extern int aggregate_value_p (const_tree, const_tree);
+@@ -665,6 +666,7 @@ extern int aggregate_value_p (const_tree, const_tree);
  extern bool use_register_for_decl (const_tree);
  extern gimple_seq gimplify_parameters (gimple_seq *);
  extern void locate_and_pad_parm (machine_mode, tree, int, int, int,
@@ -3875,10 +4375,10 @@ index 098613766be..009a9dc1c44 100644
  				 struct locate_and_pad_arg_data *);
  extern void generate_setjmp_warnings (void);
 diff --git a/gcc/gcc.cc b/gcc/gcc.cc
-index bb07cc244e3..a16c1e4372b 100644
+index 16bb07f2cdc..d0349741d2f 100644
 --- a/gcc/gcc.cc
 +++ b/gcc/gcc.cc
-@@ -572,6 +572,7 @@ or with constant text in a single argument.
+@@ -575,6 +575,7 @@ or with constant text in a single argument.
   %l     process LINK_SPEC as a spec.
   %L     process LIB_SPEC as a spec.
   %M     Output multilib_os_dir.
@@ -3886,7 +4386,7 @@ index bb07cc244e3..a16c1e4372b 100644
   %G     process LIBGCC_SPEC as a spec.
   %R     Output the concatenation of target_system_root and
          target_sysroot_suffix.
-@@ -1191,6 +1192,10 @@ proper position among the other output files.  */
+@@ -1178,6 +1179,10 @@ proper position among the other output files.  */
  # define SYSROOT_HEADERS_SUFFIX_SPEC ""
  #endif
  
@@ -3897,7 +4397,7 @@ index bb07cc244e3..a16c1e4372b 100644
  static const char *asm_debug = ASM_DEBUG_SPEC;
  static const char *asm_debug_option = ASM_DEBUG_OPTION_SPEC;
  static const char *cpp_spec = CPP_SPEC;
-@@ -5895,6 +5900,7 @@ struct spec_path_info {
+@@ -5859,6 +5864,7 @@ struct spec_path_info {
    size_t append_len;
    bool omit_relative;
    bool separate_options;
@@ -3905,7 +4405,7 @@ index bb07cc244e3..a16c1e4372b 100644
  };
  
  static void *
-@@ -5904,6 +5910,16 @@ spec_path (char *path, void *data)
+@@ -5868,6 +5874,16 @@ spec_path (char *path, void *data)
    size_t len = 0;
    char save = 0;
  
@@ -3922,7 +4422,7 @@ index bb07cc244e3..a16c1e4372b 100644
    if (info->omit_relative && !IS_ABSOLUTE_PATH (path))
      return NULL;
  
-@@ -6135,6 +6151,22 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
+@@ -6099,6 +6115,22 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
  	      info.omit_relative = false;
  #endif
  	      info.separate_options = false;
@@ -3945,7 +4445,7 @@ index bb07cc244e3..a16c1e4372b 100644
  
  	      for_each_path (&startfile_prefixes, true, 0, spec_path, &info);
  	    }
-@@ -6461,6 +6493,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
+@@ -6425,6 +6457,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
  	      info.append_len = strlen (info.append);
  	      info.omit_relative = false;
  	      info.separate_options = true;
@@ -3954,10 +4454,10 @@ index bb07cc244e3..a16c1e4372b 100644
  	      for_each_path (&include_prefixes, false, info.append_len,
  			     spec_path, &info);
 diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h
-index 79e296d4a66..a9caa0467ba 100644
+index 12ceef39180..af071079940 100644
 --- a/gcc/ginclude/stddef.h
 +++ b/gcc/ginclude/stddef.h
-@@ -427,9 +427,8 @@ typedef struct {
+@@ -428,9 +428,8 @@ typedef struct {
    /* _Float128 is defined as a basic type, so max_align_t must be
       sufficiently aligned for it.  This code must work in C++, so we
       use __float128 here; that is only available on some
@@ -3970,18 +4470,10 @@ index 79e296d4a66..a9caa0467ba 100644
  #endif
  } max_align_t;
 diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in
-index 6e10abfd0ac..5a39342068d 100644
+index a65f13853ae..3fd564a5932 100644
 --- a/gcc/jit/Make-lang.in
 +++ b/gcc/jit/Make-lang.in
-@@ -43,6 +43,7 @@
- LIBGCCJIT_VERSION_NUM = 0
- LIBGCCJIT_MINOR_NUM = 0
- LIBGCCJIT_RELEASE_NUM = 1
-+COMMA := ,
- 
- ifneq (,$(findstring mingw,$(target)))
- LIBGCCJIT_FILENAME = libgccjit-$(LIBGCCJIT_VERSION_NUM).dll
-@@ -59,22 +60,18 @@ LIBGCCJIT_AGE = 1
+@@ -59,7 +59,7 @@ LIBGCCJIT_AGE = 1
  LIBGCCJIT_BASENAME = libgccjit
  
  LIBGCCJIT_SONAME = \
@@ -3990,72 +4482,180 @@ index 6e10abfd0ac..5a39342068d 100644
  LIBGCCJIT_FILENAME = $(LIBGCCJIT_BASENAME).$(LIBGCCJIT_VERSION_NUM).dylib
  LIBGCCJIT_LINKER_NAME = $(LIBGCCJIT_BASENAME).dylib
  
--# Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and
--# LD_SONAME_OPTION depending if configure found them, using $(if)
--# We have to define a COMMA here, otherwise the commas in the "true"
--# result are treated as separators by the $(if).
--COMMA := ,
--LIBGCCJIT_VERSION_SCRIPT_OPTION = \
--	$(if $(LD_VERSION_SCRIPT_OPTION),\
--	  -Wl$(COMMA)$(LD_VERSION_SCRIPT_OPTION)$(COMMA)$(srcdir)/jit/libgccjit.map)
-+# TODO: translate the libgccjit.map into a form usable by Darwin's linker and
-+# then check for linker support for -exported_symbols_list=.  Omitting this
-+# means that all symbols in the libgccjit library will be visible.
-+LIBGCCJIT_VERSION_SCRIPT_OPTION =
- 
--LIBGCCJIT_SONAME_OPTION = \
--	$(if $(LD_SONAME_OPTION), \
--	     -Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME))
-+# This is a work-around fix for cross-compilation where the target linker
-+# is ld and the host is ld64.
-+LIBGCCJIT_SONAME_OPTION = -Wl,-install_name,$(LIBGCCJIT_SONAME)
- 
- LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_FILENAME)
- LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)
-@@ -98,7 +95,6 @@ LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_SONAME)
- # LD_SONAME_OPTION depending if configure found them, using $(if)
- # We have to define a COMMA here, otherwise the commas in the "true"
- # result are treated as separators by the $(if).
--COMMA := ,
- LIBGCCJIT_VERSION_SCRIPT_OPTION = \
- 	$(if $(LD_VERSION_SCRIPT_OPTION),\
- 	  -Wl$(COMMA)$(LD_VERSION_SCRIPT_OPTION)$(COMMA)$(srcdir)/jit/libgccjit.map)
-diff --git a/gcc/objc/objc-next-runtime-abi-02.cc b/gcc/objc/objc-next-runtime-abi-02.cc
-index e50ca6e89f5..9ea63b189c7 100644
---- a/gcc/objc/objc-next-runtime-abi-02.cc
-+++ b/gcc/objc/objc-next-runtime-abi-02.cc
-@@ -1033,6 +1033,7 @@ next_runtime_abi_02_protocol_decl (tree p)
-   else
-     decl = start_var_decl (objc_v2_protocol_template, buf);
-   OBJCMETA (decl, objc_meta, meta_protocol);
-+  DECL_PRESERVE_P (decl) = 1;
-   return decl;
- }
- 
-@@ -2115,8 +2116,8 @@ build_v2_classrefs_table (void)
- 	  expr = convert (objc_class_type, build_fold_addr_expr (expr));
- 	}
-       /* The runtime wants this, even if it appears unused, so we must force the
--	 output.
--      DECL_PRESERVE_P (decl) = 1; */
-+	 output.  */
-+      DECL_PRESERVE_P (decl) = 1;
-       finish_var_decl (decl, expr);
-     }
- }
-@@ -2318,6 +2319,7 @@ build_v2_protocol_list_address_table (void)
-       expr = convert (objc_protocol_type, build_fold_addr_expr (ref->refdecl));
-       OBJCMETA (decl, objc_meta, meta_label_protocollist);
-       finish_var_decl (decl, expr);
-+      DECL_PRESERVE_P (decl) = 1;
-     }
- 
-     /* TODO: delete the vec.  */
+diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
+index b34db0d9156..e6ad91ee168 100644
+--- a/gcc/m2/Make-lang.in
++++ b/gcc/m2/Make-lang.in
+@@ -478,6 +478,11 @@ GM2_MIN_FLAGS=$(GM2_G) $(GM2_OS) \
+  -Wpedantic-cast -Wpedantic-param-names -fno-exceptions \
+  -ffunction-sections -fdata-sections $(GM2_CPP)
+ 
++# ALL_LINKERFLAGS may include -pie (when GCC is configured with
++# --enable-host-pie), so use -fPIE if needed.  (It would not be
++# a good idea to override CFLAGS.)
++GM2_PICFLAGS = $(PICFLAG)
++
+ O2=-O2 -g
+ SO_O2=-O2 -g -fPIC
+ SO=-O0 -g -fPIC
+@@ -1354,23 +1359,23 @@ m2/boot-bin/mc$(exeext): $(BUILD-MC-BOOT-O) $(BUILD-MC-INTERFACE-O) \
+ 
+ m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) $(CXXFLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@
++	$(CXX) $(CXXFLAGS) $(GM2_PICFLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@
+ 
+ m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
++	$(CXX) $(CXXFLAGS) $(GM2_PICFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
+ 
+ m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
++	$(CXX) $(CXXFLAGS) $(GM2_PICFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
+ 
+ m2/mc-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+ 	unset CC ; $(M2LINK) -s --langc++ --exit --name m2/mc-boot/main.cc $(srcdir)/m2/init/mcinit
+-	$(CXX) $(CXXFLAGS) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.cc -o $@
++	$(CXX) $(CXXFLAGS) $(GM2_PICFLAGS) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.cc -o $@
+ 
+ mcflex.o: mcflex.c m2/gm2-libs/gm2-libs-host.h
+-	$(CC) $(CFLAGS) -I$(srcdir)/m2/mc -g -c $< -o $@   # remember that mcReserved.h is copied into m2/mc
++	$(CC) $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2/mc -g -c $< -o $@   # remember that mcReserved.h is copied into m2/mc
+ 
+ mcflex.c: $(srcdir)/m2/mc/mc.flex
+ 	flex -t $< > $@
+@@ -1378,17 +1383,17 @@ mcflex.c: $(srcdir)/m2/mc/mc.flex
+ m2/gm2-libs-boot/M2RTS.o: $(srcdir)/m2/gm2-libs/M2RTS.mod $(MCDEPS) $(BUILD-BOOT-H)
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+ 	$(MC) --suppress-noreturn -o=m2/gm2-libs-boot/M2RTS.c $(srcdir)/m2/gm2-libs/M2RTS.mod
+-	$(COMPILER) -c -DIN_GCC $(CFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/M2RTS.c -o $@
++	$(COMPILER) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/M2RTS.c -o $@
+ 
+ m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+ 	$(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs-boot/$*.mod
+-	$(COMPILER) -c -DIN_GCC $(CFLAGS) $(MCINCLUDES) m2/gm2-libs-boot/$*.c -o $@
++	$(COMPILER) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) $(MCINCLUDES) m2/gm2-libs-boot/$*.c -o $@
+ 
+ m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+ 	$(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs/$*.mod
+-	$(COMPILER) -c -DIN_GCC $(CFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/$*.c -o $@
++	$(COMPILER) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/$*.c -o $@
+ 
+ m2/gm2-libs-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+@@ -1396,49 +1401,49 @@ m2/gm2-libs-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
+ 
+ m2/gm2-libs-boot/RTcodummy.o: $(srcdir)/m2/gm2-libs-ch/RTcodummy.c m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/RTintdummy.o: $(srcdir)/m2/gm2-libs-ch/RTintdummy.c m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SRC_PREFIX)wrapc.h m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
++	$(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@
++	$(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/errno.o: $(srcdir)/m2/gm2-libs-ch/errno.c m2/gm2-libs-boot/$(SRC_PREFIX)errno.h m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/dtoa.o: $(srcdir)/m2/gm2-libs-ch/dtoa.cc m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/ldtoa.o: $(srcdir)/m2/gm2-libs-ch/ldtoa.cc m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/termios.o: $(srcdir)/m2/gm2-libs-ch/termios.c $(BUILD-LIBS-BOOT-H) m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/SysExceptions.o: $(srcdir)/m2/gm2-libs-ch/SysExceptions.c \
+                                   m2/gm2-libs-boot/$(SRC_PREFIX)SysExceptions.h m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/SysStorage.o: $(srcdir)/m2/gm2-libs/SysStorage.mod $(MCDEPS) $(BUILD-BOOT-H)
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+ 	$(MC) -o=m2/gm2-libs-boot/SysStorage.c $(srcdir)/m2/gm2-libs/SysStorage.mod
+-	$(COMPILER) -DIN_GCC -c $(CFLAGS) \
++	$(COMPILER) -DIN_GCC -c $(CFLAGS) $(GM2_PICFLAGS) \
+           -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) \
+           m2/gm2-libs-boot/SysStorage.c -o m2/gm2-libs-boot/SysStorage.o
+ 
+@@ -1511,7 +1516,7 @@ m2/gm2-compiler/%.o: m2/gm2-compiler/%.mod
+ 
+ m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.c m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -DBUILD_GM2_LIBS_TARGET -DBUILD_GM2_LIBS -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -DBUILD_GM2_LIBS_TARGET -DBUILD_GM2_LIBS -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.mod
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+@@ -1613,15 +1618,15 @@ m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+ 
+ m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs-ch/%.c m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -DBUILD_GM2_LIBS -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -DBUILD_GM2_LIBS -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs-ch/%.cc m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
++	$(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@
++	$(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@
+ 
+ m2/gm2-libs-boot/libgm2.a: m2/boot-bin/mc$(exeext) $(BUILD-LIBS-BOOT)
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+@@ -1722,11 +1727,11 @@ include m2/Make-maintainer
+ else
+ m2/pge-boot/%.o: m2/pge-boot/%.c m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) $(CFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
++	$(CXX) $(CFLAGS) $(GM2_PICFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
+ 
+ m2/pge-boot/%.o: m2/pge-boot/%.cc m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
+ 	-test -d $(@D) || $(mkinstalldirs) $(@D)
+-	$(CXX) $(CXXFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
++	$(CXX) $(CXXFLAGS) $(GM2_PICFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
+ 
+ $(PGE): $(BUILD-PGE-O)
+ 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PGE-O) -lm
 diff --git a/gcc/target.def b/gcc/target.def
-index d85adf36a39..5eb1fdce24e 100644
+index 171bbd1caf1..ba2c342d40f 100644
 --- a/gcc/target.def
 +++ b/gcc/target.def
-@@ -4967,6 +4967,18 @@ with the specified mode and type.  The default hook returns\n\
+@@ -4992,6 +4992,18 @@ with the specified mode and type.  The default hook returns\n\
   unsigned int, (machine_mode mode, const_tree type),
   default_function_arg_boundary)
  
@@ -4074,7 +4674,7 @@ index d85adf36a39..5eb1fdce24e 100644
  DEFHOOK
  (function_arg_round_boundary,
   "Normally, the size of an argument is rounded up to @code{PARM_BOUNDARY},\n\
-@@ -4976,6 +4988,18 @@ value.",
+@@ -5001,6 +5013,18 @@ value.",
   unsigned int, (machine_mode mode, const_tree type),
   default_function_arg_round_boundary)
  
@@ -4094,10 +4694,10 @@ index d85adf36a39..5eb1fdce24e 100644
     is not allowed for this 'val' argument; NULL otherwise. */
  DEFHOOK
 diff --git a/gcc/target.h b/gcc/target.h
-index d6fa6931499..40c3da87656 100644
+index cd448e4b7ab..064523f2a2e 100644
 --- a/gcc/target.h
 +++ b/gcc/target.h
-@@ -51,22 +51,7 @@
+@@ -51,22 +51,8 @@
  #include "insn-codes.h"
  #include "tm.h"
  #include "hard-reg-set.h"
@@ -4117,15 +4717,16 @@ index d6fa6931499..40c3da87656 100644
 -union cumulative_args_t { void *p; };
 -
 -#endif /* !CHECKING_P */
++#include "tree-core.h"
 +#include "cumulative-args.h"
  
  /* Types of memory operation understood by the "by_pieces" infrastructure.
     Used by the TARGET_USE_BY_PIECES_INFRASTRUCTURE_P target hook and
 diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc
-index 399d6f874dc..9d554adcb45 100644
+index 51bf3fb7a82..421aacd829d 100644
 --- a/gcc/targhooks.cc
 +++ b/gcc/targhooks.cc
-@@ -850,6 +850,14 @@ default_function_arg_boundary (machine_mode mode ATTRIBUTE_UNUSED,
+@@ -856,6 +856,14 @@ default_function_arg_boundary (machine_mode mode ATTRIBUTE_UNUSED,
    return PARM_BOUNDARY;
  }
  
@@ -4140,7 +4741,7 @@ index 399d6f874dc..9d554adcb45 100644
  unsigned int
  default_function_arg_round_boundary (machine_mode mode ATTRIBUTE_UNUSED,
  				     const_tree type ATTRIBUTE_UNUSED)
-@@ -857,6 +865,14 @@ default_function_arg_round_boundary (machine_mode mode ATTRIBUTE_UNUSED,
+@@ -863,6 +871,14 @@ default_function_arg_round_boundary (machine_mode mode ATTRIBUTE_UNUSED,
    return PARM_BOUNDARY;
  }
  
@@ -4156,10 +4757,10 @@ index 399d6f874dc..9d554adcb45 100644
  hook_void_bitmap (bitmap regs ATTRIBUTE_UNUSED)
  {
 diff --git a/gcc/targhooks.h b/gcc/targhooks.h
-index ecce55ebe79..ba110ade58b 100644
+index cf3d3107a0d..cd3c6a8d18a 100644
 --- a/gcc/targhooks.h
 +++ b/gcc/targhooks.h
-@@ -154,6 +154,12 @@ extern unsigned int default_function_arg_boundary (machine_mode,
+@@ -158,6 +158,12 @@ extern unsigned int default_function_arg_boundary (machine_mode,
  						   const_tree);
  extern unsigned int default_function_arg_round_boundary (machine_mode,
  							 const_tree);
@@ -4172,3542 +4773,1425 @@ index ecce55ebe79..ba110ade58b 100644
  extern bool hook_bool_const_rtx_commutative_p (const_rtx, int);
  extern rtx default_function_value (const_tree, const_tree, bool);
  extern HARD_REG_SET default_zero_call_used_regs (HARD_REG_SET);
-diff --git a/gcc/testsuite/g++.dg/abi/aarch64_guard1.C b/gcc/testsuite/g++.dg/abi/aarch64_guard1.C
-index e2669a89fbf..52be32decc6 100644
---- a/gcc/testsuite/g++.dg/abi/aarch64_guard1.C
-+++ b/gcc/testsuite/g++.dg/abi/aarch64_guard1.C
-@@ -12,5 +12,6 @@ int *foo ()
-   return &x;
- }
+diff --git a/gcc/testsuite/gfortran.dg/coarray/caf.exp b/gcc/testsuite/gfortran.dg/coarray/caf.exp
+index d232be2fa90..fb233e3d082 100644
+--- a/gcc/testsuite/gfortran.dg/coarray/caf.exp
++++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp
+@@ -28,6 +28,7 @@
  
--// { dg-final { scan-assembler _ZGVZ3foovE1x,8,8 } }
-+// { dg-final { scan-assembler _ZGVZ3foovE1x,8,8 { target { ! *-*-darwin* } } } }
-+// { dg-final { scan-assembler __DATA,__bss,__ZGVZ3foovE1x,8,3 { target *-*-darwin* } } }
- // { dg-final { scan-tree-dump "& 1" "original" } }
-diff --git a/gcc/testsuite/g++.dg/abi/arm_va_list.C b/gcc/testsuite/g++.dg/abi/arm_va_list.C
-index 4f6f3a46da4..ff9fd8bcf0d 100644
---- a/gcc/testsuite/g++.dg/abi/arm_va_list.C
-+++ b/gcc/testsuite/g++.dg/abi/arm_va_list.C
-@@ -8,8 +8,10 @@
- // #include 
- typedef __builtin_va_list va_list;
- 
--// { dg-final { scan-assembler "\n_Z1fPSt9__va_list:" } }
-+// { dg-final { scan-assembler "\n_Z1fPSt9__va_list:" { target { ! *-*-darwin* } } } }
-+// { dg-final { scan-assembler "\n__Z1fPPc:" { target *-*-darwin* } } }
- void f(va_list*) {}
- 
--// { dg-final { scan-assembler "\n_Z1gSt9__va_listS_:" } }
-+// { dg-final { scan-assembler "\n_Z1gSt9__va_listS_:" { target { ! *-*-darwin* } } } }
-+// { dg-final { scan-assembler "\n__Z1gPcS_:" { target *-*-darwin* } } }
- void g(va_list, va_list) {}
-diff --git a/gcc/testsuite/g++.dg/cpp0x/pr106435-b.cc b/gcc/testsuite/g++.dg/cpp0x/pr106435-b.cc
-new file mode 100644
-index 00000000000..4f581694177
---- /dev/null
-+++ b/gcc/testsuite/g++.dg/cpp0x/pr106435-b.cc
-@@ -0,0 +1,17 @@
-+// PR c++/106435
-+#include "pr106435.h"
-+
-+//#include 
-+
-+Foo::Foo() {
-+  ++num_calls;
-+//  std::cout << "Foo::Foo(this=" << this << ")\n";
-+}
-+
-+int Foo::func() {
-+//  std::cout << "Foo::func(this=" << this << ")\n";
-+  return num_calls;
-+}
-+
-+thread_local Foo Bar::foo;
-+thread_local Foo Bar::baz;
-diff --git a/gcc/testsuite/g++.dg/cpp0x/pr106435.C b/gcc/testsuite/g++.dg/cpp0x/pr106435.C
-new file mode 100644
-index 00000000000..d600976f9f9
---- /dev/null
-+++ b/gcc/testsuite/g++.dg/cpp0x/pr106435.C
-@@ -0,0 +1,20 @@
-+// PR c++/106435
-+// { dg-do run { target c++11 } }
-+// { dg-additional-sources "pr106435-b.cc" }
-+
-+#include "pr106435.h"
-+
-+int num_calls = 0;
-+
-+extern "C" __attribute__((__noreturn__)) void abort();
-+
-+thread_local Foo Bar::bat;
-+
-+int main() {
-+  int v = Bar::foo.func();
-+  if (v != 2)
-+    abort();
-+  v = Bar::bat.func();
-+  if (v != 3)
-+    abort();
-+}
-diff --git a/gcc/testsuite/g++.dg/cpp0x/pr106435.h b/gcc/testsuite/g++.dg/cpp0x/pr106435.h
-new file mode 100644
-index 00000000000..240de1ee9a9
---- /dev/null
-+++ b/gcc/testsuite/g++.dg/cpp0x/pr106435.h
-@@ -0,0 +1,14 @@
-+// PR c++/106435
-+#pragma once
-+
-+extern int num_calls;
-+struct Foo {
-+  Foo();
-+  int func();
-+};
+ # Load procedures from common libraries. 
+ load_lib gfortran-dg.exp
++load_lib atomic-dg.exp
+ 
+ # If a testcase doesn't have special options, use these.
+ global DEFAULT_FFLAGS
+@@ -47,6 +48,7 @@ global gfortran_test_path
+ global gfortran_aux_module_flags
+ set gfortran_test_path $srcdir/$subdir
+ set gfortran_aux_module_flags $DEFAULT_FFLAGS
 +
-+struct Bar {
-+  thread_local static Foo foo;
-+  thread_local static Foo baz;
-+  thread_local static Foo bat;
-+};
-diff --git a/gcc/testsuite/g++.dg/ext/arm-bf16/bf16-mangle-aarch64-1.C b/gcc/testsuite/g++.dg/ext/arm-bf16/bf16-mangle-aarch64-1.C
-index 5426a1814b8..a017ce8ce5f 100644
---- a/gcc/testsuite/g++.dg/ext/arm-bf16/bf16-mangle-aarch64-1.C
-+++ b/gcc/testsuite/g++.dg/ext/arm-bf16/bf16-mangle-aarch64-1.C
-@@ -2,12 +2,12 @@
- 
- /* Test mangling */
- 
--/* { dg-final { scan-assembler "\t.global\t_Z1fPu6__bf16" } } */
-+/* { dg-final { scan-assembler {\t.globa?l[ \t]_?_Z1fPu6__bf16} } } */
- void f (__bf16 *x) { }
- 
--/* { dg-final { scan-assembler "\t.global\t_Z1gPu6__bf16S_" } } */
-+/* { dg-final { scan-assembler {\t.globa?l[ \t]_?_Z1gPu6__bf16S_} } } */
- void g (__bf16 *x, __bf16 *y) { }
- 
--/* { dg-final { scan-assembler "\t.global\t_ZN1SIu6__bf16u6__bf16E1iE" } } */
-+/* { dg-final { scan-assembler {\t.globa?l[ \t]_?_ZN1SIu6__bf16u6__bf16E1iE} } } */
- template  struct S { static int i; };
- template <> int S<__bf16, __bf16>::i = 3;
-diff --git a/gcc/testsuite/g++.dg/torture/darwin-cfstring-3.C b/gcc/testsuite/g++.dg/torture/darwin-cfstring-3.C
-index ee4b385b17f..eabb3b517a4 100644
---- a/gcc/testsuite/g++.dg/torture/darwin-cfstring-3.C
-+++ b/gcc/testsuite/g++.dg/torture/darwin-cfstring-3.C
-@@ -26,5 +26,5 @@ void foo(void) {
- 
- /* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+\[lL\]C.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" { target { *-*-darwin* && { ! lp64 } } } } } */
- /* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+\[lL\]C.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" { target { *-*-darwin* && { ! lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t4\n" { target { *-*-darwin* && {  lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t10\n" { target { *-*-darwin* && {  lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t___CFConstantStringClassReference\n\t.(long|word)\t1992\n\t.space 4\n\t.(quad|xword)\t.*\n\t.(quad|xword)\t4\n} { target { *-*-darwin* && {  lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t___CFConstantStringClassReference\n\t.(long|word)\t1992\n\t.space 4\n\t.(quad|xword)\t.*\n\t.(quad|xword)\t10\n} { target { *-*-darwin* && {  lp64 } } } } } */
-diff --git a/gcc/testsuite/g++.target/aarch64/no_unique_address_1.C b/gcc/testsuite/g++.target/aarch64/no_unique_address_1.C
-index 5fc68ea5d6d..5faf915fa54 100644
---- a/gcc/testsuite/g++.target/aarch64/no_unique_address_1.C
-+++ b/gcc/testsuite/g++.target/aarch64/no_unique_address_1.C
-@@ -1,5 +1,5 @@
- /* { dg-options "-std=c++11 -O -foptimize-sibling-calls -fpeephole2" } */
--/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */
-+/* { dg-final { check-function-bodies "**" "" "" { target { lp64 && { ! aarch64*-*-darwin* } } } } } */
- 
- struct X { };
- struct Y { int : 0; };
-diff --git a/gcc/testsuite/g++.target/aarch64/no_unique_address_2.C b/gcc/testsuite/g++.target/aarch64/no_unique_address_2.C
-index f0717133ccd..322ec127c79 100644
---- a/gcc/testsuite/g++.target/aarch64/no_unique_address_2.C
-+++ b/gcc/testsuite/g++.target/aarch64/no_unique_address_2.C
-@@ -1,5 +1,5 @@
- /* { dg-options "-std=c++17 -O -foptimize-sibling-calls -fpeephole2" } */
--/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */
-+/* { dg-final { check-function-bodies "**" "" "" { target { lp64 && { ! aarch64*-*-darwin* } } } } } */
- 
- struct X { };
- struct Y { int : 0; };
-diff --git a/gcc/testsuite/g++.target/aarch64/sve/aarch64-sve.exp b/gcc/testsuite/g++.target/aarch64/sve/aarch64-sve.exp
-index 03a6537a53e..d4c2052dc59 100644
---- a/gcc/testsuite/g++.target/aarch64/sve/aarch64-sve.exp
-+++ b/gcc/testsuite/g++.target/aarch64/sve/aarch64-sve.exp
-@@ -25,6 +25,11 @@ if {![istarget aarch64*-*-*] } then {
-   return
+ proc dg-compile-aux-modules { args } {
+     global gfortran_test_path
+     global gfortran_aux_module_flags
+@@ -71,7 +73,16 @@ proc dg-compile-aux-modules { args } {
+ # Add -latomic only where supported.  Assume built-in support elsewhere.
+ set maybe_atomic_lib ""
+ if [check_effective_target_libatomic_available] {
+-    set maybe_atomic_lib "-latomic"
++    #set maybe_atomic_lib "-latomic"
++    if ![is_remote host] {
++	if [info exists TOOL_OPTIONS] {
++	    set maybe_atomic_lib "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]"
++	} else {
++	    set maybe_atomic_lib "[atomic_link_flags [get_multilibs]]"
++	}
++    }
++  set t [get_multilibs]
++  puts "maybe al $maybe_atomic_lib ml $t"
  }
  
-+# Darwin doesn't support sve
-+if { [istarget *-*-darwin*] } then {
-+  return
-+}
-+
- # Load support procs.
- load_lib g++-dg.exp
- 
-diff --git a/gcc/testsuite/g++.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp b/gcc/testsuite/g++.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp
-index 38140413a97..559e1f37c68 100644
---- a/gcc/testsuite/g++.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp
-+++ b/gcc/testsuite/g++.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp
-@@ -24,6 +24,11 @@ if { ![istarget aarch64*-*-*] } {
-     return
+ # Main loop.
+@@ -97,14 +108,14 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ]]
+     foreach flags $option_list {
+ 	verbose "Testing $nshort (single), $flags" 1
+         set gfortran_aux_module_flags "-fcoarray=single $flags"
+-	dg-test $test "-fcoarray=single $flags $maybe_atomic_lib" "" 
++	dg-test $test "-fcoarray=single $flags" $maybe_atomic_lib 
+ 	cleanup-modules ""
+     }
+ 
+     foreach flags $option_list {
+ 	verbose "Testing $nshort (libcaf_single), $flags" 1
+         set gfortran_aux_module_flags "-fcoarray=lib $flags -lcaf_single"
+-	dg-test $test "-fcoarray=lib $flags -lcaf_single $maybe_atomic_lib" ""
++	dg-test $test "-fcoarray=lib $flags -lcaf_single" $maybe_atomic_lib
+ 	cleanup-modules ""
+     }
  }
+diff --git a/gcc/testsuite/gfortran.dg/dg.exp b/gcc/testsuite/gfortran.dg/dg.exp
+index ee2760327dc..73541ea7301 100644
+--- a/gcc/testsuite/gfortran.dg/dg.exp
++++ b/gcc/testsuite/gfortran.dg/dg.exp
+@@ -18,6 +18,7 @@
  
-+# Darwin doesn't support sve
-+if { [istarget *-*-darwin*] } then {
-+  return
-+}
-+
  # Load support procs.
- load_lib g++-dg.exp
- 
-diff --git a/gcc/testsuite/g++.target/aarch64/sve/acle/aarch64-sve-acle.exp b/gcc/testsuite/g++.target/aarch64/sve/acle/aarch64-sve-acle.exp
-index d1887eb8087..c9fee945c52 100644
---- a/gcc/testsuite/g++.target/aarch64/sve/acle/aarch64-sve-acle.exp
-+++ b/gcc/testsuite/g++.target/aarch64/sve/acle/aarch64-sve-acle.exp
-@@ -25,6 +25,11 @@ if {![istarget aarch64*-*-*] } {
-     return
+ load_lib gfortran-dg.exp
++load_lib atomic-dg.exp
+ 
+ # If a testcase doesn't have special options, use these.
+ global DEFAULT_FFLAGS
+@@ -53,13 +54,38 @@ proc dg-compile-aux-modules { args } {
+     }
  }
  
-+# Darwin doesn't support sve
-+if { [istarget *-*-darwin*] } then {
-+  return
++# coarray tests might need libatomic.  Assume that it is either not needed or
++# provided by builtins if it's not available.
++set maybe_atomic_lib ""
++if [check_effective_target_libatomic_available] {
++    if ![is_remote host] {
++	if [info exists TOOL_OPTIONS] {
++	    set maybe_atomic_lib "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]"
++	} else {
++	    set maybe_atomic_lib "[atomic_link_flags [get_multilibs]]"
++	}
++    } else {
++        set maybe_atomic_lib ""
++    }
++  set t [get_multilibs]
++  puts "dg set al $maybe_atomic_lib ml $t"
 +}
 +
- # Load support procs.
- load_lib g++-dg.exp
- 
-diff --git a/gcc/testsuite/g++.target/aarch64/sve2/acle/aarch64-sve2-acle-asm.exp b/gcc/testsuite/g++.target/aarch64/sve2/acle/aarch64-sve2-acle-asm.exp
-index 78e8ecae729..e22ef5f0876 100644
---- a/gcc/testsuite/g++.target/aarch64/sve2/acle/aarch64-sve2-acle-asm.exp
-+++ b/gcc/testsuite/g++.target/aarch64/sve2/acle/aarch64-sve2-acle-asm.exp
-@@ -24,6 +24,11 @@ if { ![istarget aarch64*-*-*] } {
-     return
- }
- 
-+# Darwin doesn't support sve
-+if { [istarget *-*-darwin*] } then {
-+  return
++set all_flags $DEFAULT_FFLAGS
++if { $maybe_atomic_lib != "" } {
++   foreach f $maybe_atomic_lib {
++     lappend all_flags $f
++   }
 +}
 +
- # Load support procs.
- load_lib g++-dg.exp
- 
-diff --git a/gcc/testsuite/gcc.dg/builtin-apply2.c b/gcc/testsuite/gcc.dg/builtin-apply2.c
-index 0f350f4ac16..d1e70b3a3e5 100644
---- a/gcc/testsuite/gcc.dg/builtin-apply2.c
-+++ b/gcc/testsuite/gcc.dg/builtin-apply2.c
-@@ -1,7 +1,7 @@
- /* { dg-do run } */
- /* { dg-require-effective-target untyped_assembly } */
- /* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args in registers." { "avr-*-* nds32*-*-* amdgcn-*-*" } } */
--/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs." { "csky*-*-* riscv*-*-* or1k*-*-* msp430-*-* pru-*-* loongarch*-*-*" } } */
-+/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs." { "csky*-*-* riscv*-*-* or1k*-*-* msp430-*-* pru-*-* loongarch*-*-* aarch64-apple-darwin*" } } */
- /* { dg-skip-if "Variadic funcs use Base AAPCS.  Normal funcs use VFP variant." { arm*-*-* && arm_hf_eabi } } */
- 
- /* PR target/12503 */
-diff --git a/gcc/testsuite/gcc.dg/cwsc1.c b/gcc/testsuite/gcc.dg/cwsc1.c
-index e793e26116a..7d8b472bdf6 100644
---- a/gcc/testsuite/gcc.dg/cwsc1.c
-+++ b/gcc/testsuite/gcc.dg/cwsc1.c
-@@ -6,7 +6,11 @@
- #elif defined(__i386__)
- # define CHAIN  "%ecx"
- #elif defined(__aarch64__)
--# define CHAIN  "x18"
-+# if defined(__APPLE__)
-+#  define CHAIN  "x16"
-+# else
-+#  define CHAIN  "x18"
-+# endif
- #elif defined(__alpha__)
- # define CHAIN  "$1"
- #elif defined(__arm__)
-diff --git a/gcc/testsuite/gcc.dg/darwin-segaddr.c b/gcc/testsuite/gcc.dg/darwin-segaddr.c
-index 526db77bd9c..fcc324b3031 100644
---- a/gcc/testsuite/gcc.dg/darwin-segaddr.c
-+++ b/gcc/testsuite/gcc.dg/darwin-segaddr.c
-@@ -1,7 +1,8 @@
- /* Check that -segaddr gets through and works.  */
- /* { dg-do run { target *-*-darwin* } } */
- /* { dg-options "-O0 -segaddr __TEST 0x200000 -fno-pie" { target { *-*-darwin* && { ! lp64 } } } } */
--/* { dg-options "-O0 -segaddr __TEST 0x110000000 -fno-pie" { target { *-*-darwin* && lp64 } } } */
-+/* { dg-options "-O0 -segaddr __TEST 0x110000000 -fno-pie" { target { *-*-darwin[1456789]* && lp64 } } } */
-+/* { dg-options "-O0 -segaddr __TEST 0x110000000 " { target { *-*-darwin2* && lp64 } } } */
- 
- extern void abort ();
- 
-diff --git a/gcc/testsuite/gcc.dg/pr26427.c b/gcc/testsuite/gcc.dg/pr26427.c
-index add13ca209e..2c09f28195d 100644
---- a/gcc/testsuite/gcc.dg/pr26427.c
-+++ b/gcc/testsuite/gcc.dg/pr26427.c
-@@ -1,4 +1,4 @@
--/* { dg-warning "this target does not support" "" {target *86*-*-darwin* } 0 } */
-+/* { dg-warning "this target does not support" "" {target *86*-*-darwin* aarch64-*-darwin* } 0 } */
- /* { dg-do run { target { *-*-darwin* } } } */
- /* { dg-options { -fsection-anchors -O } } */
- /* PR target/26427 */
-diff --git a/gcc/testsuite/gcc.dg/pubtypes-2.c b/gcc/testsuite/gcc.dg/pubtypes-2.c
-index 116e3489bc0..b3d1231ad44 100644
---- a/gcc/testsuite/gcc.dg/pubtypes-2.c
-+++ b/gcc/testsuite/gcc.dg/pubtypes-2.c
-@@ -2,7 +2,8 @@
- /* { dg-options "-O0 -gdwarf-2 -dA" } */
- /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } } */
- /* { dg-final { scan-assembler "__debug_pubtypes" } } */
--/* { dg-final { scan-assembler {long+[ \t]+0x14d+[ \t]+[#;]+[ \t]+Pub Info Length} } } */
-+/* { dg-final { scan-assembler {long+[ \t]+0x14d+[ \t]+[#;]+[ \t]+Pub Info Length} { target { ! aarch64-*-darwin* } } } } */
-+/* { dg-final { scan-assembler {long+[ \t]+0x163+[ \t]+[#;]+[ \t]+Pub Info Length} { target aarch64-*-darwin* } } } */
- /* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
- /* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
- 
-diff --git a/gcc/testsuite/gcc.dg/pubtypes-3.c b/gcc/testsuite/gcc.dg/pubtypes-3.c
-index 3fb3468fb00..950a9ba72fc 100644
---- a/gcc/testsuite/gcc.dg/pubtypes-3.c
-+++ b/gcc/testsuite/gcc.dg/pubtypes-3.c
-@@ -2,7 +2,8 @@
- /* { dg-options "-O0 -gdwarf-2 -dA" } */
- /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } } */
- /* { dg-final { scan-assembler "__debug_pubtypes" } } */
--/* { dg-final { scan-assembler {long+[ \t]+0x14d+[ \t]+[#;]+[ \t]+Pub Info Length} } } */
-+/* { dg-final { scan-assembler {long+[ \t]+0x14d+[ \t]+[#;]+[ \t]+Pub Info Length} { target { ! aarch64-*-darwin* } } } } */
-+/* { dg-final { scan-assembler {long+[ \t]+0x163+[ \t]+[#;]+[ \t]+Pub Info Length} { target aarch64-*-darwin* } } } */
- /* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
- /* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
- /* { dg-final { scan-assembler-not "\"list_name_type\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
-diff --git a/gcc/testsuite/gcc.dg/pubtypes-4.c b/gcc/testsuite/gcc.dg/pubtypes-4.c
-index 83fba8dfabc..7250771587b 100644
---- a/gcc/testsuite/gcc.dg/pubtypes-4.c
-+++ b/gcc/testsuite/gcc.dg/pubtypes-4.c
-@@ -2,7 +2,8 @@
- /* { dg-options "-O0 -gdwarf-2 -dA" } */
- /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } } */
- /* { dg-final { scan-assembler "__debug_pubtypes" } } */
--/* { dg-final { scan-assembler {long+[ \t]+0x184+[ \t]+[#;]+[ \t]+Pub Info Length} } } */
-+/* { dg-final { scan-assembler {long+[ \t]+0x184+[ \t]+[#;]+[ \t]+Pub Info Length} { target { ! aarch64-*-darwin* } } } } */
-+/* { dg-final { scan-assembler {long+[ \t]+0x19a+[ \t]+[#;]+[ \t]+Pub Info Length} { target aarch64-*-darwin* } } } */
- /* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
- /* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
- /* { dg-final { scan-assembler "\"list_name_type\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
-diff --git a/gcc/testsuite/gcc.dg/rtl/aarch64/big-endian-cse-1.c b/gcc/testsuite/gcc.dg/rtl/aarch64/big-endian-cse-1.c
-index 1559a489f25..aa2da0cbca5 100644
---- a/gcc/testsuite/gcc.dg/rtl/aarch64/big-endian-cse-1.c
-+++ b/gcc/testsuite/gcc.dg/rtl/aarch64/big-endian-cse-1.c
-@@ -1,4 +1,5 @@
- /* { dg-do compile { target aarch64*-*-* } } */
-+/* { dg-skip-if "Darwin platforms do not support big-endian arm64" *-*-darwin* } */
- /* { dg-require-effective-target lp64 } */
- /* { dg-options "-O3 -mbig-endian" } */
- 
-diff --git a/gcc/testsuite/gcc.dg/tls/pr78796.c b/gcc/testsuite/gcc.dg/tls/pr78796.c
-index 038e5366e41..31e03dd419c 100644
---- a/gcc/testsuite/gcc.dg/tls/pr78796.c
-+++ b/gcc/testsuite/gcc.dg/tls/pr78796.c
-@@ -1,7 +1,7 @@
- /* PR target/78796 */
- /* { dg-do run } */
- /* { dg-options "-O2" } */
--/* { dg-additional-options "-mcmodel=large" { target aarch64-*-* } } */
-+/* { dg-additional-options "-mcmodel=large" { target { { aarch64-*-* } && { ! aarch64-*-darwin* } } } } */
- /* { dg-require-effective-target tls_runtime } */
- /* { dg-add-options tls } */
- 
-diff --git a/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c b/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
-index ee4b385b17f..eabb3b517a4 100644
---- a/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
-+++ b/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
-@@ -26,5 +26,5 @@ void foo(void) {
- 
- /* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+\[lL\]C.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" { target { *-*-darwin* && { ! lp64 } } } } } */
- /* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+\[lL\]C.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" { target { *-*-darwin* && { ! lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t4\n" { target { *-*-darwin* && {  lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t10\n" { target { *-*-darwin* && {  lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t___CFConstantStringClassReference\n\t.(long|word)\t1992\n\t.space 4\n\t.(quad|xword)\t.*\n\t.(quad|xword)\t4\n} { target { *-*-darwin* && {  lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t___CFConstantStringClassReference\n\t.(long|word)\t1992\n\t.space 4\n\t.(quad|xword)\t.*\n\t.(quad|xword)\t10\n} { target { *-*-darwin* && {  lp64 } } } } } */
-diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
-index 552ca1433f4..16643ceb198 100644
---- a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
-+++ b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
-@@ -9,7 +9,7 @@
- /* arm_hf_eabi: Variadic funcs use Base AAPCS.  Normal funcs use VFP variant.
-    avr: Variadic funcs don't pass arguments in registers, while normal funcs
-         do.  */
--/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs" { arm_hf_eabi || { csky*-*-* avr-*-* riscv*-*-* or1k*-*-* msp430-*-* amdgcn-*-* pru-*-* loongarch*-*-* } } } */
-+/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs" { arm_hf_eabi || { csky*-*-* avr-*-* riscv*-*-* or1k*-*-* msp430-*-* amdgcn-*-* pru-*-* loongarch*-*-*  aarch64-apple-darwin* } } } */
- /* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args in registers." { nds32*-*-* } { v850*-*-* } } */
- /* { dg-require-effective-target untyped_assembly } */
-    
-diff --git a/gcc/testsuite/gcc.dg/tree-ssa/stdarg-2.c b/gcc/testsuite/gcc.dg/tree-ssa/stdarg-2.c
-index 0224997f18a..3684cffdc64 100644
---- a/gcc/testsuite/gcc.dg/tree-ssa/stdarg-2.c
-+++ b/gcc/testsuite/gcc.dg/tree-ssa/stdarg-2.c
-@@ -25,9 +25,9 @@ f1 (int i, ...)
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
- 
- void
-@@ -46,9 +46,9 @@ f2 (int i, ...)
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save \[148\] GPR units and 0 FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 8 GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 1 GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 8 GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 8 GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
- 
- void
-@@ -62,10 +62,10 @@ f3 (int i, ...)
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 0 GPR units and \[1-9\]\[0-9\]* FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 || llp64 } } } } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 0 GPR units and \[1-9\]\[0-9\]* FPR units" "stdarg" { target { powerpc*-*-linux* && { powerpc_fprs && ilp32 } } } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 0 GPR units and 1 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 0 GPR units and 16 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 0 GPR units and 16 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 8 GPR units and 2" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save \[1-9\]\[0-9\]* GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save \[1-9\]\[0-9\]* GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save \[1-9\]\[0-9\]* GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save \[1-9\]\[0-9\]* GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
- 
- void
-@@ -81,9 +81,9 @@ f4 (int i, ...)
- /* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
- 
- void
-@@ -100,9 +100,9 @@ f5 (int i, ...)
- /* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
- 
- void
-@@ -121,9 +121,9 @@ f6 (int i, ...)
- /* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save (3|12|24) GPR units and 0 FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save 24 GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save 3 GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save 24 GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save 24 GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save (3|12|24) GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save (3|12|24) GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save (3|12|24) GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save (3|12|24) GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
- 
- void
-@@ -139,9 +139,9 @@ f7 (int i, ...)
- /* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
- 
- void
-@@ -159,9 +159,9 @@ f8 (int i, ...)
- /* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
++puts "revised FFLAGS $all_flags"
++
+ # Main loop.
+ gfortran-dg-runtest [lsort \
+-       [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $DEFAULT_FFLAGS
++       [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $all_flags
  
- void
-@@ -177,9 +177,9 @@ f9 (int i, ...)
- /* { dg-final { scan-tree-dump "f9: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f9: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f9: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f9: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f9: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f9: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f9: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f9: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f9: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
+ gfortran-dg-runtest [lsort \
+-       [glob -nocomplain $srcdir/$subdir/g77/*.\[fF\] ] ] "" $DEFAULT_FFLAGS
+-
++       [glob -nocomplain $srcdir/$subdir/g77/*.\[fF\] ] ] "" $all_flags
  
- void
-@@ -197,9 +197,9 @@ f10 (int i, ...)
- /* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
+ # All done.
+ dg-finish
+diff --git a/gcc/testsuite/lib/asan-dg.exp b/gcc/testsuite/lib/asan-dg.exp
+index 35e60eaaed5..157b60908d6 100644
+--- a/gcc/testsuite/lib/asan-dg.exp
++++ b/gcc/testsuite/lib/asan-dg.exp
+@@ -78,7 +78,7 @@ proc asan_link_flags_1 { paths lib } {
+ 	   || [file exists "${gccpath}/libsanitizer/${lib}/.libs/lib${lib}.${shlib_ext}"] } {
+ 	  append flags " -B${gccpath}/libsanitizer/ "
+ 	  append flags " -B${gccpath}/libsanitizer/${lib}/ "
+-	  append flags " -L${gccpath}/libsanitizer/${lib}/.libs "
++	  append flags " -B${gccpath}/libsanitizer/${lib}/.libs "
+ 	  append ld_library_path ":${gccpath}/libsanitizer/${lib}/.libs"
+       }
+     } else {
+diff --git a/gcc/testsuite/lib/atomic-dg.exp b/gcc/testsuite/lib/atomic-dg.exp
+index 1589acd8eaf..ce1799cef2d 100644
+--- a/gcc/testsuite/lib/atomic-dg.exp
++++ b/gcc/testsuite/lib/atomic-dg.exp
+@@ -33,7 +33,7 @@ proc atomic_link_flags { paths } {
+       if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"]
+ 	   || [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } {
+ 	  append flags " -B${gccpath}/libatomic/ "
+-	  append flags " -L${gccpath}/libatomic/.libs"
++	  append flags " -B${gccpath}/libatomic/.libs"
+ 	  append ld_library_path ":${gccpath}/libatomic/.libs"
+       }
+     } else {
+diff --git a/gcc/testsuite/lib/target-libpath.exp b/gcc/testsuite/lib/target-libpath.exp
+index 6d530fb4af6..5de039b4fc2 100644
+--- a/gcc/testsuite/lib/target-libpath.exp
++++ b/gcc/testsuite/lib/target-libpath.exp
+@@ -67,6 +67,7 @@ proc set_ld_library_path_env_vars { } {
+   global orig_dyld_library_path
+   global orig_path
+   global orig_gcc_exec_prefix
++  global ENABLE_DARWIN_AT_RPATH
+   global env
  
- void
-@@ -218,9 +218,9 @@ f11 (int i, ...)
- /* { dg-final { scan-tree-dump "f11: va_list escapes 0, needs to save (3|12|24) GPR units and 0 FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f11: va_list escapes 0, needs to save 24 GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f11: va_list escapes 0, needs to save 3 GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f11: va_list escapes 0, needs to save 24 GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f11: va_list escapes 0, needs to save 24 GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f11: va_list escapes 0, needs to save (3|12|24) GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f11: va_list escapes 0, needs to save (3|12|24) GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f11: va_list escapes 0, needs to save (3|12|24) GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f11: va_list escapes 0, needs to save (3|12|24) GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
+   # Save the original GCC_EXEC_PREFIX.
+@@ -133,6 +134,7 @@ proc set_ld_library_path_env_vars { } {
+   #
+   # Doing this is somewhat of a hack as ld_library_path gets repeated in
+   # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
++  if { ![istarget *-*-darwin*] } {
+   if { $orig_ld_library_path_saved } {
+     setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
+   } else {
+@@ -166,11 +168,23 @@ proc set_ld_library_path_env_vars { } {
+   } else {
+     setenv LD_LIBRARY_PATH_64 "$ld_library_path"
+   }
+-  if { $orig_dyld_library_path_saved } {
+-    setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
+-  } else {
+-    setenv DYLD_LIBRARY_PATH "$ld_library_path"
+   }
++  if { [istarget *-*-darwin*] } {
++    if { [info exists ENABLE_DARWIN_AT_RPATH] || [istarget *-*-darwin1\[5-9\]*]
++         || [istarget *-*-darwin20*] } {
++      # Either we are not using DYLD_LIBRARY_PATH or we're on a version of the
++      # OS for which it is not passed through system exes.
++      if [info exists env(DYLD_LIBRARY_PATH)] {
++        unsetenv DYLD_LIBRARY_PATH
++      }
++    } else {
++      if { $orig_dyld_library_path_saved } {
++        setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
++      } else {
++        setenv DYLD_LIBRARY_PATH "$ld_library_path"
++      }
++    }
++  } 
+   if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
+     if { $orig_path_saved } {
+       setenv PATH "$ld_library_path:$orig_path"
+@@ -179,6 +193,7 @@ proc set_ld_library_path_env_vars { } {
+     }
+   }
  
- void
-@@ -239,9 +239,9 @@ f12 (int i, ...)
- /* { dg-final { scan-tree-dump "f12: va_list escapes 0, needs to save 0 GPR units and \[1-9\]\[0-9\]* FPR units" "stdarg" { target { powerpc*-*-linux* && { powerpc_fprs && ilp32 } } } } } */
- /* { dg-final { scan-tree-dump "f12: va_list escapes 0, needs to save 24 GPR units and 2" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f12: va_list escapes 0, needs to save 0 GPR units and 3 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f12: va_list escapes 0, needs to save 0 GPR units and 48 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f12: va_list escapes 0, needs to save 0 GPR units and 48 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f12: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f12: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f12: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f12: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
++  verbose -log "set paths"
+   verbose -log "LD_LIBRARY_PATH=[getenv LD_LIBRARY_PATH]"
+   verbose -log "LD_RUN_PATH=[getenv LD_RUN_PATH]"
+   verbose -log "SHLIB_PATH=[getenv SHLIB_PATH]"
+diff --git a/gcc/tree-nested.cc b/gcc/tree-nested.cc
+index 1418e1f7f56..060072ba76e 100644
+--- a/gcc/tree-nested.cc
++++ b/gcc/tree-nested.cc
+@@ -611,6 +611,14 @@ get_trampoline_type (struct nesting_info *info)
+   if (trampoline_type)
+     return trampoline_type;
  
- void
-@@ -260,9 +260,9 @@ f13 (int i, ...)
- /* { dg-final { scan-tree-dump "f13: va_list escapes 0, needs to save 0 GPR units and \[1-9\]\[0-9\]* FPR units" "stdarg" { target { powerpc*-*-linux* && { powerpc_fprs && ilp32 } } } } } */
- /* { dg-final { scan-tree-dump "f13: va_list escapes 0, needs to save 24 GPR units and 2" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f13: va_list escapes 0, needs to save 0 GPR units and 3 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f13: va_list escapes 0, needs to save 0 GPR units and 48 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f13: va_list escapes 0, needs to save 0 GPR units and 48 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f13: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f13: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f13: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f13: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
++  /* When trampolines are created off-stack then the only thing we need in the
++     local frame is a single pointer.  */
++  if (flag_off_stack_trampolines)
++    {
++      trampoline_type = build_pointer_type (void_type_node);
++      return trampoline_type;
++    }
++
+   align = TRAMPOLINE_ALIGNMENT;
+   size = TRAMPOLINE_SIZE;
  
- void
-@@ -281,9 +281,9 @@ f14 (int i, ...)
- /* { dg-final { scan-tree-dump "f14: va_list escapes 0, needs to save \[148\] GPR units and \[1-9\]\[0-9\]* FPR units" "stdarg" { target { powerpc*-*-linux* && { powerpc_fprs && ilp32 } } } } } */
- /* { dg-final { scan-tree-dump "f14: va_list escapes 0, needs to save 24 GPR units and 3" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f14: va_list escapes 0, needs to save 1 GPR units and 2 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f14: va_list escapes 0, needs to save 8 GPR units and 32 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f14: va_list escapes 0, needs to save 8 GPR units and 32 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f14: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f14: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f14: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f14: va_list escapes 0, needs to save \[1-9]\[0-9\]* GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
- 
- inline void __attribute__((always_inline))
-@@ -305,11 +305,11 @@ f15 (int i, ...)
- /* { dg-final { scan-tree-dump "f15: va_list escapes 0, needs to save \[148\] GPR units and \[1-9\]\[0-9\]* FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 || llp64 } } } } } } */
- /* { dg-final { scan-tree-dump "f15: va_list escapes 0, needs to save \[148\] GPR units and \[1-9\]\[0-9\]* FPR units" "stdarg" { target { powerpc*-*-linux* && { powerpc_fprs && ilp32 } } } } } */
- /* { dg-final { scan-tree-dump "f15: va_list escapes 0, needs to save 1 GPR units and 2 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f15: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f15: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- 
- /* We may be able to improve upon this after fixing PR66010/PR66013.  */
- /* { dg-final { scan-tree-dump "f15: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
- 
- /* { dg-final { scan-tree-dump-not "f15: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump-not "f15: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump-not "f15: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump-not "f15: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
-diff --git a/gcc/testsuite/gcc.dg/tree-ssa/stdarg-4.c b/gcc/testsuite/gcc.dg/tree-ssa/stdarg-4.c
-index 1a637d6efe4..77cdf384df4 100644
---- a/gcc/testsuite/gcc.dg/tree-ssa/stdarg-4.c
-+++ b/gcc/testsuite/gcc.dg/tree-ssa/stdarg-4.c
-@@ -27,9 +27,9 @@ f1 (int i, ...)
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save all GPR units and 0 FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save all GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save all GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save all GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save all GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f1: va_list escapes \[01\], needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f1: va_list escapes \[01\], needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f1: va_list escapes \[01\], needs to save all GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f1: va_list escapes \[01\], needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
+@@ -2788,17 +2796,27 @@ convert_tramp_reference_op (tree *tp, int *walk_subtrees, void *data)
  
- void
-@@ -45,9 +45,9 @@ f2 (int i, ...)
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 0 GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && { powerpc_fprs && ilp32 } } } } } */
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save all GPR units and 2" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 0 GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 0 GPR units and all FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 0 GPR units and all FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f2: va_list escapes \[01\], needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f2: va_list escapes \[01\], needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f2: va_list escapes \[01\], needs to save all GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f2: va_list escapes \[01\], needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
- 
- /* Here va_arg can be executed at most as many times as va_start.
-@@ -69,9 +69,9 @@ f3 (int i, ...)
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save \[148\] GPR units and 0 FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 8 GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 1 GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 8 GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 8 GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
+       /* Compute the address of the field holding the trampoline.  */
+       x = get_frame_field (info, target_context, x, &wi->gsi);
+-      x = build_addr (x);
+-      x = gsi_gimplify_val (info, x, &wi->gsi);
  
- void
-@@ -91,7 +91,7 @@ f4 (int i, ...)
- /* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 0 GPR units and \[1-9\]\[0-9\]* FPR units" "stdarg" { target { powerpc*-*-linux* && { powerpc_fprs && ilp32 } } } } } */
- /* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 8 GPR units and 2" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 0 GPR units and 1 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 0 GPR units and 16 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 0 GPR units and 16 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
- /* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
--/* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target ia64-*-* } } } */
-+/* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target ia64-*-* aarch64-apple-darwin* } } } */
- /* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
-diff --git a/gcc/testsuite/gcc.dg/tree-ssa/stdarg-5.c b/gcc/testsuite/gcc.dg/tree-ssa/stdarg-5.c
-index c8ad4fe320d..b0484f2f053 100644
---- a/gcc/testsuite/gcc.dg/tree-ssa/stdarg-5.c
-+++ b/gcc/testsuite/gcc.dg/tree-ssa/stdarg-5.c
-@@ -25,7 +25,8 @@ f1 (int i, ...)
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 || llp64 } } } } } } */
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save all GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save all GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save all GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save all GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
-+/* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save all GPR units" "stdarg" { target aarch64-apple-darwin* } } } */
- 
- void
- f2 (int i, ...)
-@@ -39,7 +40,8 @@ f2 (int i, ...)
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 || llp64 } } } } } } */
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save all GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save all GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save all GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save all GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
-+/* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save all GPR units" "stdarg" { target aarch64-apple-darwin* } } } */
- 
- /* Here va_arg can be executed at most as many times as va_start.  */
- void
-@@ -58,7 +60,8 @@ f3 (int i, ...)
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 || llp64 } } } } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 32 GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 1 GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 8 GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 8 GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
-+/* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 8 GPR units" "stdarg" { target aarch64-apple-darwin* } } } */
- 
- void
- f4 (int i, ...)
-@@ -77,7 +80,8 @@ f4 (int i, ...)
- /* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 16 GPR units and 16 FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 || llp64 } } } } } } */
- /* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 24 GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 2 GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 24 GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 24 GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
-+/* { dg-final { scan-tree-dump "f4: va_list escapes 0, needs to save 24 GPR units" "stdarg" { target aarch64-apple-darwin* } } } */
- 
- void
- f5 (int i, ...)
-@@ -92,7 +96,8 @@ f5 (int i, ...)
- /* { dg-final { scan-tree-dump "f5: va_list escapes 0, needs to save 16 GPR units and 0 FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 || llp64 } } } } } } */
- /* { dg-final { scan-tree-dump "f5: va_list escapes 0, needs to save 32 GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f5: va_list escapes 0, needs to save (4|2) GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f5: va_list escapes 0, needs to save 16 GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f5: va_list escapes 0, needs to save 16 GPR units and 0 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
-+/* { dg-final { scan-tree-dump "f5: va_list escapes 0, needs to save 16 GPR units" "stdarg" { target aarch64-apple-darwin* } } } */
- 
- void
- f6 (int i, ...)
-@@ -107,7 +112,8 @@ f6 (int i, ...)
- /* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save 8 GPR units and 32 FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 || llp64 } } } } } } */
- /* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save 32 GPR units and 3" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save (3|2) GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save 8 GPR units and 32 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save 8 GPR units and 32 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
-+/* { dg-final { scan-tree-dump "f6: va_list escapes 0, needs to save 24 GPR units" "stdarg" { target aarch64-apple-darwin* } } } */
- 
- void
- f7 (int i, ...)
-@@ -122,4 +128,5 @@ f7 (int i, ...)
- /* { dg-final { scan-tree-dump "f7: va_list escapes 0, needs to save 0 GPR units and 64 FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 || llp64 } } } } } } */
- /* { dg-final { scan-tree-dump "f7: va_list escapes 0, needs to save 32 GPR units and 2" "stdarg" { target alpha*-*-linux* } } } */
- /* { dg-final { scan-tree-dump "f7: va_list escapes 0, needs to save 2 GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
--/* { dg-final { scan-tree-dump "f7: va_list escapes 0, needs to save 0 GPR units and 64 FPR units" "stdarg" { target aarch64*-*-* } } } */
-+/* { dg-final { scan-tree-dump "f7: va_list escapes 0, needs to save 0 GPR units and 64 FPR units" "stdarg" { target { { aarch64*-*-* } && { ! aarch64-apple-darwin* } } } } } */
-+/* { dg-final { scan-tree-dump "f7: va_list escapes 0, needs to save 32 GPR units" "stdarg" { target aarch64-apple-darwin* } } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp b/gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp
-index 3e652c483c7..34907929bda 100644
---- a/gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp
-+++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/aapcs64.exp
-@@ -25,6 +25,11 @@ if { ![istarget aarch64*-*-*] } then {
-   return
- }
- 
-+if { [istarget *-*-darwin*] } then {
-+  # darwinpcs and mach-o will need different test mechanisms.
-+  return
-+}
-+
- torture-init
- set-torture-options $C_TORTURE_OPTIONS
- set additional_flags "-W -Wall -Wno-abi"
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c
-index c42c7acbbe9..76917a6ff5b 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c
-@@ -1,4 +1,5 @@
- /* { dg-do assemble { target { aarch64*-*-* } } } */
-+/* { dg-require-effective-target aarch64_asm_bf16_ok }  */
- /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
- /* { dg-options "-O2" } */
- /* { dg-add-options arm_v8_2a_bf16_neon }  */
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_get.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_get.c
-index 2193753ffbb..d29b222b032 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_get.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_get.c
-@@ -1,4 +1,5 @@
- /* { dg-do assemble { target { aarch64*-*-* } } } */
-+/* { dg-require-effective-target aarch64_asm_bf16_ok }  */
- /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
- /* { dg-add-options arm_v8_2a_bf16_neon } */
- /* { dg-additional-options "-save-temps" } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_reinterpret.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_reinterpret.c
-index f5adf40c648..4e3a3d94416 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_reinterpret.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_reinterpret.c
-@@ -1,4 +1,5 @@
- /* { dg-do assemble { target { aarch64*-*-* } } } */
-+/* { dg-require-effective-target aarch64_asm_bf16_ok }  */
- /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
- /* { dg-add-options arm_v8_2a_bf16_neon }  */
- /* { dg-additional-options "-save-temps" } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvt-compile.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvt-compile.c
-index 47af7c494d9..a2f415f67b7 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvt-compile.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvt-compile.c
-@@ -1,4 +1,5 @@
- /* { dg-do assemble { target { aarch64*-*-* } } } */
-+/* { dg-require-effective-target aarch64_asm_bf16_ok }  */
- /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
- /* { dg-add-options arm_v8_2a_bf16_neon } */
- /* { dg-additional-options "-save-temps" } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvt-nosimd.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvt-nosimd.c
-index a914680937d..c6b2ef3e444 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvt-nosimd.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvt-nosimd.c
-@@ -2,7 +2,7 @@
- /* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } } */
- /* { dg-require-effective-target aarch64_asm_bf16_ok } */
- /* { dg-additional-options "-save-temps -march=armv8.2-a+bf16+nosimd" } */
--/* { dg-final { check-function-bodies "**" "" {-O[^0]} } } */
-+/* { dg-final { check-function-bodies "**" "" {-O[^0]} { target { ! aarch64*-*-darwin* } } } } */
- 
- #include 
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvtnq2-untied.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvtnq2-untied.c
-index 4b730e39d4e..fd2abadb457 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvtnq2-untied.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvtnq2-untied.c
-@@ -1,8 +1,9 @@
- /* { dg-do assemble { target { aarch64*-*-* } } } */
-+/* { dg-require-effective-target aarch64_asm_bf16_ok }  */
- /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
- /* { dg-add-options arm_v8_2a_bf16_neon } */
- /* { dg-additional-options "-save-temps" } */
--/* { dg-final { check-function-bodies "**" "" {-O[^0]} } } */
-+/* { dg-final { check-function-bodies "**" "" {-O[^0]} { target { ! aarch64*-*-darwin* } } } } */
- /* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } } */
- 
- #include 
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfdot-1.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfdot-1.c
-index ad51507731b..e57053d2193 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfdot-1.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfdot-1.c
-@@ -1,8 +1,9 @@
- /* { dg-do assemble { target { aarch64*-*-* } } } */
-+/* { dg-require-effective-target aarch64_asm_bf16_ok }  */
- /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
- /* { dg-add-options arm_v8_2a_bf16_neon }  */
- /* { dg-additional-options "-save-temps" } */
--/* { dg-final { check-function-bodies "**" "" {-O[^0]} } } */
-+/* { dg-final { check-function-bodies "**" "" {-O[^0]} { target { ! aarch64*-*-darwin* } } } } */
- /* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } } */
- 
- #include 
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfdot-2.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfdot-2.c
-index ae0a953f7b4..9f5669a8974 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfdot-2.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfdot-2.c
-@@ -3,7 +3,7 @@
- /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
- /* { dg-add-options arm_v8_2a_bf16_neon }  */
- /* { dg-additional-options "-mbig-endian --save-temps" } */
--/* { dg-final { check-function-bodies "**" "" {-O[^0]} } } */
-+/* { dg-final { check-function-bodies "**" "" {-O[^0]} { target { ! aarch64*-*-darwin* } } } } */
- /* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } } */
- 
- #include 
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfmlalbt-compile.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfmlalbt-compile.c
-index 9810e4ba374..315cabd464b 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfmlalbt-compile.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfmlalbt-compile.c
-@@ -1,8 +1,9 @@
- /* { dg-do assemble { target { aarch64*-*-* } } } */
-+/* { dg-require-effective-target aarch64_asm_bf16_ok }  */
- /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
- /* { dg-add-options arm_v8_2a_bf16_neon } */
- /* { dg-additional-options "-save-temps" } */
--/* { dg-final { check-function-bodies "**" "" "-DCHECK_ASM" } } */
-+/* { dg-final { check-function-bodies "**" "" "-DCHECK_ASM" { target { ! aarch64*-*-darwin* } } } } */
- 
- #include 
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfmmla-compile.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfmmla-compile.c
-index 0aaa69f0037..ddc391b1332 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfmmla-compile.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfmmla-compile.c
-@@ -1,8 +1,9 @@
- /* { dg-do assemble { target { aarch64*-*-* } } } */
-+/* { dg-require-effective-target aarch64_asm_bf16_ok }  */
- /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
- /* { dg-add-options arm_v8_2a_bf16_neon } */
- /* { dg-additional-options "-save-temps" } */
--/* { dg-final { check-function-bodies "**" "" "-DCHECK_ASM" } } */
-+/* { dg-final { check-function-bodies "**" "" "-DCHECK_ASM" { target { ! aarch64*-*-darwin* } } } } */
- 
- #include 
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vdot-3-1.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vdot-3-1.c
-index ac4f821e771..978eac29815 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vdot-3-1.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vdot-3-1.c
-@@ -1,8 +1,9 @@
- /* { dg-do assemble { target { aarch64*-*-* } } } */
-+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw } */
- /* { dg-require-effective-target arm_v8_2a_i8mm_ok } */
- /* { dg-add-options arm_v8_2a_i8mm }  */
- /* { dg-additional-options "-save-temps" } */
--/* { dg-final { check-function-bodies "**" "" {-O[^0]} } } */
-+/* { dg-final { check-function-bodies "**" "" {-O[^0]} { target { ! aarch64*-*-darwin* } } } } */
- /* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } } */
- 
- #include 
-diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vdot-3-2.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vdot-3-2.c
-index 61c7c51f5ec..f84ed68e2f7 100644
---- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vdot-3-2.c
-+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vdot-3-2.c
-@@ -3,7 +3,7 @@
- /* { dg-require-effective-target arm_v8_2a_i8mm_ok } */
- /* { dg-add-options arm_v8_2a_i8mm }  */
- /* { dg-additional-options "-mbig-endian -save-temps" } */
--/* { dg-final { check-function-bodies "**" "" {-O[^0]} } } */
-+/* { dg-final { check-function-bodies "**" "" {-O[^0]} { target { ! aarch64*-*-darwin* } } } } */
- /* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } } */
- 
- #include 
-diff --git a/gcc/testsuite/gcc.target/aarch64/arm_align_max_pwr.c b/gcc/testsuite/gcc.target/aarch64/arm_align_max_pwr.c
-index ffa4d229922..38b9ef01eb7 100644
---- a/gcc/testsuite/gcc.target/aarch64/arm_align_max_pwr.c
-+++ b/gcc/testsuite/gcc.target/aarch64/arm_align_max_pwr.c
-@@ -19,5 +19,7 @@ dummy ()
-   return result;
- }
- 
--/* { dg-final { scan-assembler-times "zero\t4" 2 } } */
--/* { dg-final { scan-assembler "zero\t268435452" } } */
-+/* { dg-final { scan-assembler-times "zero\t4" 2 { target { ! *-*-darwin* } } } } */
-+/* { dg-final { scan-assembler "zero\t268435452" { target { ! *-*-darwin*} }  } } */
-+/* { dg-final { scan-assembler-times ".zerofill __DATA,__bss,_y,4,28" 1 { target { *-*-darwin* } } } } */
-+/* { dg-final { scan-assembler-times ".zerofill __DATA,__bss,_x,4,28" 1 { target { *-*-darwin* } } } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-2.c b/gcc/testsuite/gcc.target/aarch64/auto-init-2.c
-index 375befd325b..3a0387a5952 100644
---- a/gcc/testsuite/gcc.target/aarch64/auto-init-2.c
-+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-2.c
-@@ -12,11 +12,11 @@ enum E {
-   N3
- };
- 
--extern void bar (char, short, int, enum E, long, long long, int *, bool);
-+extern void bar (unsigned char, short, int, enum E, long, long long, int *, bool);
- 
- void foo()
- {
--  char temp1;
-+  unsigned char temp1;
-   short temp2;
-   int temp3;
-   enum E temp4;
-diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-3.c b/gcc/testsuite/gcc.target/aarch64/auto-init-3.c
-index 7008f76b294..85a4e4daeb6 100644
---- a/gcc/testsuite/gcc.target/aarch64/auto-init-3.c
-+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-3.c
-@@ -2,13 +2,19 @@
- /* { dg-do compile } */
- /* { dg-options "-ftrivial-auto-var-init=zero -fdump-rtl-expand" } */
- 
--long double result;
-+#ifdef __APPLE__
-+# define TYPE _Float128
-+#else
-+# define TYPE long double
-+#endif
- 
--long double foo()
-+TYPE result;
+-      /* Do machine-specific ugliness.  Normally this will involve
+-	 computing extra alignment, but it can really be anything.  */
+-      if (descr)
+-	builtin = builtin_decl_implicit (BUILT_IN_ADJUST_DESCRIPTOR);
++      /* APB: We don't need to do the adjustment calls when using off-stack
++	 trampolines, any such adjustment will be done when the off-stack
++	 trampoline is created.  */
++      if (!descr && flag_off_stack_trampolines)
++	x = gsi_gimplify_val (info, x, &wi->gsi);
+       else
+-	builtin = builtin_decl_implicit (BUILT_IN_ADJUST_TRAMPOLINE);
+-      call = gimple_build_call (builtin, 1, x);
+-      x = init_tmp_var_with_call (info, &wi->gsi, call);
++	{
++	  x = build_addr (x);
 +
-+TYPE foo()
- {
-   float temp1;
-   double temp2;
--  long double temp3;
-+  TYPE temp3;
-   
-   result = temp1 + temp2 + temp3;
-   return result;
-diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-4.c b/gcc/testsuite/gcc.target/aarch64/auto-init-4.c
-index 10197045b4c..0c6840ba224 100644
---- a/gcc/testsuite/gcc.target/aarch64/auto-init-4.c
-+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-4.c
-@@ -2,13 +2,19 @@
- /* { dg-do compile } */
- /* { dg-options "-O -ftrivial-auto-var-init=pattern -fdump-rtl-expand" } */
- 
--long double result;
-+#ifdef __APPLE__
-+# define TYPE _Float128
-+#else
-+# define TYPE long double
-+#endif
- 
--long double foo()
-+TYPE result;
++	  x = gsi_gimplify_val (info, x, &wi->gsi);
 +
-+TYPE foo()
- {
-   float temp1;
-   double temp2;
--  long double temp3;
-+  TYPE temp3;
-   
-   result = temp1 + temp2 + temp3;
-   return result;
-diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-5.c b/gcc/testsuite/gcc.target/aarch64/auto-init-5.c
-index ac69ac3df82..0dda3c201d3 100644
---- a/gcc/testsuite/gcc.target/aarch64/auto-init-5.c
-+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-5.c
-@@ -2,14 +2,19 @@
- /* { dg-do compile } */
- /* { dg-options "-ftrivial-auto-var-init=zero" } */
- 
-+#ifdef __APPLE__
-+# define TYPE _Float128
-+#else
-+# define TYPE long double
-+#endif
- 
--_Complex long double result;
-+_Complex TYPE result;
- 
--_Complex long double foo()
-+_Complex TYPE foo()
- {
-   _Complex float temp1;
-   _Complex double temp2;
--  _Complex long double temp3;
-+  _Complex TYPE temp3;
- 
-   result = temp1 + temp2 + temp3;
-   return result;
-diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-6.c b/gcc/testsuite/gcc.target/aarch64/auto-init-6.c
-index 0456c66f496..23323115a11 100644
---- a/gcc/testsuite/gcc.target/aarch64/auto-init-6.c
-+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-6.c
-@@ -2,14 +2,19 @@
- /* { dg-do compile } */
- /* { dg-options "-ftrivial-auto-var-init=pattern" } */
- 
-+#ifdef __APPLE__
-+# define TYPE _Float128
-+#else
-+# define TYPE long double
-+#endif
- 
--_Complex long double result;
-+_Complex TYPE result;
++	  /* Do machine-specific ugliness.  Normally this will involve
++	     computing extra alignment, but it can really be anything.  */
++	  if (descr)
++	    builtin = builtin_decl_implicit (BUILT_IN_ADJUST_DESCRIPTOR);
++	  else
++	    builtin = builtin_decl_implicit (BUILT_IN_ADJUST_TRAMPOLINE);
++	  call = gimple_build_call (builtin, 1, x);
++	  x = init_tmp_var_with_call (info, &wi->gsi, call);
++	}
  
--_Complex long double foo()
-+_Complex TYPE foo()
+       /* Cast back to the proper function type.  */
+       x = build1 (NOP_EXPR, TREE_TYPE (t), x);
+@@ -3377,6 +3395,7 @@ build_init_call_stmt (struct nesting_info *info, tree decl, tree field,
+ static void
+ finalize_nesting_tree_1 (struct nesting_info *root)
  {
-   _Complex float temp1;
-   _Complex double temp2;
--  _Complex long double temp3;
-+  _Complex TYPE temp3;
- 
-   result = temp1 + temp2 + temp3;
-   return result;
-diff --git a/gcc/testsuite/gcc.target/aarch64/c-output-template-2.c b/gcc/testsuite/gcc.target/aarch64/c-output-template-2.c
-index ced96d04542..86e4f5fa82c 100644
---- a/gcc/testsuite/gcc.target/aarch64/c-output-template-2.c
-+++ b/gcc/testsuite/gcc.target/aarch64/c-output-template-2.c
-@@ -6,4 +6,4 @@ test (void)
-     __asm__ ("@ %c0" : : "S" (test));
- }
- 
--/* { dg-final { scan-assembler "@ test" } } */
-+/* { dg-final { scan-assembler "@ _?test" } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/c-output-template-3.c b/gcc/testsuite/gcc.target/aarch64/c-output-template-3.c
-index 8bde4cbeb0c..4531a381518 100644
---- a/gcc/testsuite/gcc.target/aarch64/c-output-template-3.c
-+++ b/gcc/testsuite/gcc.target/aarch64/c-output-template-3.c
-@@ -7,4 +7,4 @@ test (void)
-     __asm__ ("@ %c0" : : "S" (&test + 4));
- }
- 
--/* { dg-final { scan-assembler "@ test\\+4" } } */
-+/* { dg-final { scan-assembler "@ _?test\\+4" } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/c-output-template-4.c b/gcc/testsuite/gcc.target/aarch64/c-output-template-4.c
-index c5a93915af1..800d52bfab8 100644
---- a/gcc/testsuite/gcc.target/aarch64/c-output-template-4.c
-+++ b/gcc/testsuite/gcc.target/aarch64/c-output-template-4.c
-@@ -7,4 +7,4 @@ test (void)
-     __asm__ ("@ %c0" : : "S" (&test + 4));
- }
++  gimple_seq cleanup_list = NULL;
+   gimple_seq stmt_list = NULL;
+   gimple *stmt;
+   tree context = root->context;
+@@ -3508,9 +3527,48 @@ finalize_nesting_tree_1 (struct nesting_info *root)
+ 	  if (!field)
+ 	    continue;
  
--/* { dg-final { scan-assembler "@ test\\+4" } } */
-+/* { dg-final { scan-assembler "@ _?test\\+4" } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/cpymem-size.c b/gcc/testsuite/gcc.target/aarch64/cpymem-size.c
-index 4a6f2495d22..b8ef4745c6d 100644
---- a/gcc/testsuite/gcc.target/aarch64/cpymem-size.c
-+++ b/gcc/testsuite/gcc.target/aarch64/cpymem-size.c
-@@ -6,7 +6,7 @@
- /*
- ** cpy_127:
- **      mov	(w|x)2, 127
--**      b	memcpy
-+**      b	_?memcpy
- */
- void
- cpy_127 (char *out, char *in)
-@@ -17,7 +17,7 @@ cpy_127 (char *out, char *in)
- /*
- ** cpy_128:
- **      mov	(w|x)2, 128
--**      b	memcpy
-+**      b	_?memcpy
- */
- void
- cpy_128 (char *out, char *in)
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/aarch64-darwin.exp b/gcc/testsuite/gcc.target/aarch64/darwin/aarch64-darwin.exp
-new file mode 100644
-index 00000000000..b0b7f49aede
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/aarch64-darwin.exp
-@@ -0,0 +1,46 @@
-+#  Specific tests for the darwinpcs and codegen.
-+#  Copyright (C) GNU Toolchain Authors
-+#  Contributed by Iain Sandoe
-+#
-+#  This file is part of GCC.
-+#
-+#  GCC is free software; you can redistribute it and/or modify it
-+#  under the terms of the GNU General Public License as published by
-+#  the Free Software Foundation; either version 3, or (at your option)
-+#  any later version.
-+#
-+#  GCC is distributed in the hope that it will be useful, but
-+#  WITHOUT ANY WARRANTY; without even the implied warranty of
-+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+#  General Public License for more details.
-+#
-+#  You should have received a copy of the GNU General Public License
-+#  along with GCC; see the file COPYING3.  If not see
-+#  .  */
-+
-+# GCC testsuite that uses the `dg.exp' driver.
-+
-+# Exit immediately if this isn't aarch64-darwin.
-+
-+if { ![istarget aarch64*-*-darwin*] } then {
-+  return
-+}
+-	  x = builtin_decl_implicit (BUILT_IN_INIT_TRAMPOLINE);
+-	  stmt = build_init_call_stmt (root, i->context, field, x);
+-	  gimple_seq_add_stmt (&stmt_list, stmt);
++	  if (flag_off_stack_trampolines)
++	    {
++	      /* We pass a whole bunch of arguments to the builtin function that
++		 creates the off-stack trampoline, these are
++		 1. The nested function chain value (that must be passed to the
++		 nested function so it can find the function arguments).
++		 2. A pointer to the nested function implementation,
++		 3. The address in the local stack frame where we should write
++		 the address of the trampoline.
 +
-+# Load support procs.
-+load_lib gcc-dg.exp
++		 When this code was originally written I just kind of threw
++		 everything at the builtin, figuring I'd work out what was
++		 actually needed later, I think, the stack pointer could
++		 certainly be dropped, arguments #2 and #4 are based off the
++		 stack pointer anyway, so #1 doesn't seem to add much value.  */
++	      tree arg1, arg2, arg3;
 +
-+# If a testcase doesn't have special options, use these.
-+global DEFAULT_CFLAGS
-+if ![info exists DEFAULT_CFLAGS] then {
-+    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
-+}
++	      gcc_assert (DECL_STATIC_CHAIN (i->context));
++	      arg1 = build_addr (root->frame_decl);
++	      arg2 = build_addr (i->context);
 +
-+# Initialize `dg'.
-+dg-init
++	      x = build3 (COMPONENT_REF, TREE_TYPE (field),
++			  root->frame_decl, field, NULL_TREE);
++	      arg3 = build_addr (x);
 +
-+# Main loop.
-+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
-+	"" $DEFAULT_CFLAGS
++	      x = builtin_decl_implicit (BUILT_IN_NESTED_PTR_CREATED);
++	      stmt = gimple_build_call (x, 3, arg1, arg2, arg3);
++	      gimple_seq_add_stmt (&stmt_list, stmt);
 +
-+# All done.
-+dg-finish
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/complex-in-regs.c b/gcc/testsuite/gcc.target/aarch64/darwin/complex-in-regs.c
-new file mode 100644
-index 00000000000..974f02ca2ec
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/complex-in-regs.c
-@@ -0,0 +1,103 @@
-+/* { dg-do compile } */
-+/* we need this for complex and gnu initializers.  */
-+/* { dg-options "-std=gnu99 " } */
-+/* We use the sections anchors to make the code easier to match.  */
-+/* { dg-additional-options " -O -fsection-anchors -fno-schedule-insns -fno-schedule-insns2 " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+
-+__attribute__((__noinline__))
-+_Complex char
-+cc_regs_fun (_Complex char r0, _Complex char r1, 
-+	     _Complex char r2, _Complex char r3,
-+	     _Complex char r4, _Complex char r5,
-+	     _Complex char r6, _Complex char r7);
-+
-+/*
-+**call_cc_regs_fun:
-+**	...
-+**	ldrh	w7, \[x0\]
-+**	ldrh	w6, \[x0, 2\]
-+**	ldrh	w5, \[x0, 4\]
-+**	ldrh	w4, \[x0, 6\]
-+**	ldrh	w3, \[x0, 8\]
-+**	ldrh	w2, \[x0, 10\]
-+**	ldrh	w1, \[x0, 12\]
-+**	ldrh	w0, \[x0, 14]\
-+**	bl	_cc_regs_fun
-+**	...
-+*/
-+
-+_Complex char
-+call_cc_regs_fun (void)
-+{
-+  return cc_regs_fun ((_Complex char) (1 + 1i), (_Complex char) (2 + 2i),
-+		      (_Complex char) (3 + 3i), (_Complex char) (4 + 4i),
-+		      (_Complex char) (5 + 5i), (_Complex char) (6 + 6i),
-+		      (_Complex char) (7 + 7i), (_Complex char) (8 + 8i));
-+}
++	      /* This call to delete the nested function trampoline is added to
++		 the cleanup list, and called when we exit the current scope.  */
++	      x = builtin_decl_implicit (BUILT_IN_NESTED_PTR_DELETED);
++	      stmt = gimple_build_call (x, 0);
++	      gimple_seq_add_stmt (&cleanup_list, stmt);
++	    }
++	  else
++	    {
++	      /* Original code to initialise the on stack trampoline.  */
++	      x = builtin_decl_implicit (BUILT_IN_INIT_TRAMPOLINE);
++	      stmt = build_init_call_stmt (root, i->context, field, x);
++	      gimple_seq_add_stmt (&stmt_list, stmt);
++	    }
+ 	}
+     }
+ 
+@@ -3535,11 +3593,40 @@ finalize_nesting_tree_1 (struct nesting_info *root)
+   /* If we created initialization statements, insert them.  */
+   if (stmt_list)
+     {
+-      gbind *bind;
+-      annotate_all_with_location (stmt_list, DECL_SOURCE_LOCATION (context));
+-      bind = gimple_seq_first_stmt_as_a_bind (gimple_body (context));
+-      gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind));
+-      gimple_bind_set_body (bind, stmt_list);
++      if (flag_off_stack_trampolines)
++	{
++	  /* Handle the new, off stack trampolines.  */
++	  gbind *bind;
++	  annotate_all_with_location (stmt_list, DECL_SOURCE_LOCATION (context));
++	  annotate_all_with_location (cleanup_list, DECL_SOURCE_LOCATION (context));
++	  bind = gimple_seq_first_stmt_as_a_bind (gimple_body (context));
++	  gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind));
 +
++	  gimple_seq xxx_list = NULL;
 +
-+__attribute__((__noinline__))
-+_Complex short
-+cs_regs_fun (_Complex short r0, _Complex short r1,
-+	     _Complex short r2, _Complex short r3,
-+	     _Complex short r4, _Complex short r5,
-+	     _Complex short r6, _Complex short r7);
-+
-+/*
-+**call_cs_regs_fun:
-+**	...
-+**	ldr	w7, \[x0, 16\]
-+**	ldr	w6, \[x0, 20\]
-+**	ldr	w5, \[x0, 24\]
-+**	ldr	w4, \[x0, 28\]
-+**	ldr	w3, \[x0, 32\]
-+**	ldr	w2, \[x0, 36\]
-+**	ldr	w1, \[x0, 40\]
-+**	ldr	w0, \[x0, 44\]
-+**	bl	_cs_regs_fun
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+_Complex short
-+call_cs_regs_fun (void)
-+{
-+  return cs_regs_fun ((_Complex short) (1 + 1i), (_Complex short) (2 + 2i),
-+		      (_Complex short) (3 + 3i), (_Complex short) (4 + 4i),
-+		      (_Complex short) (5 + 5i), (_Complex short) (6 + 6i),
-+		      (_Complex short) (7 + 7i), (_Complex short) (8 + 8i));
-+}
++	  if (cleanup_list != NULL)
++	    {
++	      /* We Maybe shouldn't be creating this try/finally if -fno-exceptions is
++		 in use.  If this is the case, then maybe we should, instead, be
++		 inserting the cleanup code onto every path out of this function?  Not
++		 yet figured out how we would do this.  */
++	      gtry *t = gimple_build_try (stmt_list, cleanup_list, GIMPLE_TRY_FINALLY);
++	      gimple_seq_add_stmt (&xxx_list, t);
++	    }
++	  else
++	    xxx_list = stmt_list;
 +
-+__attribute__((__noinline__))
-+_Complex int
-+ci_regs_fun (_Complex int r0, _Complex int r1,
-+	     _Complex int r2, _Complex int r3,
-+	     _Complex int r4, _Complex int r5,
-+	     _Complex int r6, _Complex int r7);
-+
-+/*
-+**call_ci_regs_fun:
-+**	...
-+**	ldr	x7, \[x0, 48\]
-+**	ldr	x6, \[x0, 56\]
-+**	ldr	x5, \[x0, 64\]
-+**	ldr	x4, \[x0, 72\]
-+**	ldr	x3, \[x0, 80\]
-+**	ldr	x2, \[x0, 88\]
-+**	ldr	x1, \[x0, 96\]
-+**	ldr	x0, \[x0, 104\]
-+**	bl	_ci_regs_fun
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+_Complex int
-+call_ci_regs_fun (void)
-+{
-+  return ci_regs_fun ((_Complex int) (1 + 1i), (_Complex int) (2 + 2i),
-+		      (_Complex int) (3 + 3i), (_Complex int) (4 + 4i),
-+		      (_Complex int) (5 + 5i), (_Complex int) (6 + 6i),
-+		      (_Complex int) (7 + 7i), (_Complex int) (8 + 8i));
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d1.c b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d1.c
-new file mode 100644
-index 00000000000..e2dd574fac7
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d1.c
-@@ -0,0 +1,54 @@
-+/* { dg-do compile } */
-+/* we need this for the empty struct.  */
-+/* { dg-options "-std=gnu99 " } */
-+/* { dg-additional-options "-O -fno-schedule-insns -fno-schedule-insns2 " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+/* Make sure we do no consume any registers in passing zero-sized entities */
-+
-+typedef struct es {} Empty;
-+
-+__attribute__((__noinline__)) void
-+use_no_regs (int a, Empty b, int c, Empty d, Empty e, int f);
-+
-+/*
-+**call_use_no_regs:
-+**	...
-+**	mov	w2, 3
-+**	mov	w1, 2
-+**	mov	w0, 1
-+**	bl	_use_no_regs
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) void
-+call_use_no_regs (void)
-+{
-+  Empty e;
-+  use_no_regs (1, e, 2, e, e, 3);
-+}
++	  gimple_bind_set_body (bind, xxx_list);
++	}
++      else
++	{
++	  /* The traditional, on stack trampolines.  */
++	  gbind *bind;
++	  annotate_all_with_location (stmt_list, DECL_SOURCE_LOCATION (context));
++	  bind = gimple_seq_first_stmt_as_a_bind (gimple_body (context));
++	  gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind));
++	  gimple_bind_set_body (bind, stmt_list);
++	}
+     }
+ 
+   /* If a chain_decl was created, then it needs to be registered with
+diff --git a/gcc/tree.cc b/gcc/tree.cc
+index 207293c48cb..0a4770ec801 100644
+--- a/gcc/tree.cc
++++ b/gcc/tree.cc
+@@ -9852,6 +9852,23 @@ build_common_builtin_nodes (void)
+ 			"__builtin_nonlocal_goto",
+ 			ECF_NORETURN | ECF_NOTHROW);
+ 
++  tree ptr_ptr_type_node = build_pointer_type (ptr_type_node);
 +
-+/* Make sure we consume no stack in passing zero-sized entities. */
++  ftype = build_function_type_list (void_type_node,
++				    ptr_type_node, // void *chain
++				    ptr_type_node, // void *func
++				    ptr_ptr_type_node, // void **dst
++				    NULL_TREE);
++  local_define_builtin ("__builtin_nested_func_ptr_created", ftype,
++			BUILT_IN_NESTED_PTR_CREATED,
++			"__builtin_nested_func_ptr_created", ECF_NOTHROW);
 +
-+/*
-+**call_use_no_stack:
-+**	...
-+**	mov	w[0-9]+, 108
-+**	strb	w[0-9]+, \[sp, 1\]
-+**	mov	w[0-9]+, 106
-+**	strb	w[0-9]+, \[sp\]
-+**	...
-+**	bl	_use_no_stack
-+**	...
-+*/
++  ftype = build_function_type_list (void_type_node,
++				    NULL_TREE);
++  local_define_builtin ("__builtin_nested_func_ptr_deleted", ftype,
++			BUILT_IN_NESTED_PTR_DELETED,
++			"__builtin_nested_func_ptr_deleted", ECF_NOTHROW);
 +
-+__attribute__((__noinline__)) void
-+use_no_stack (int a, int b, int c, int d, int e, int f, int g, int h,
-+	      Empty i, char j, Empty k, char l);
+   ftype = build_function_type_list (void_type_node,
+ 				    ptr_type_node, ptr_type_node, NULL_TREE);
+   local_define_builtin ("__builtin_setjmp_setup", ftype,
+diff --git a/gotools/Makefile.in b/gotools/Makefile.in
+index 2783b91ef4b..9739a79526b 100644
+--- a/gotools/Makefile.in
++++ b/gotools/Makefile.in
+@@ -704,8 +704,8 @@ distclean-generic:
+ maintainer-clean-generic:
+ 	@echo "This command is intended for maintainers to use"
+ 	@echo "it deletes files that may require special tools to rebuild."
+-@NATIVE_FALSE@install-exec-local:
+ @NATIVE_FALSE@uninstall-local:
++@NATIVE_FALSE@install-exec-local:
+ clean: clean-am
+ 
+ clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \
+diff --git a/intl/Makefile.in b/intl/Makefile.in
+index 409d693c48e..5beebdc152c 100644
+--- a/intl/Makefile.in
++++ b/intl/Makefile.in
+@@ -54,7 +54,7 @@ CTAGS = @CTAGS@
+ ETAGS = @ETAGS@
+ MKID = @MKID@
+ 
+-COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(DEFS-$@) $(INCLUDES)
++COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) @PICFLAG@ $(DEFS) $(DEFS-$@) $(INCLUDES)
+ 
+ HEADERS = \
+   gmo.h \
+diff --git a/intl/configure b/intl/configure
+index 03f40487a92..79bb5831a47 100755
+--- a/intl/configure
++++ b/intl/configure
+@@ -623,6 +623,8 @@ ac_header_list=
+ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
+ PICFLAG
++enable_host_pie
++enable_host_shared
+ BISON3_NO
+ BISON3_YES
+ INCINTL
+@@ -731,6 +733,7 @@ with_libintl_prefix
+ with_libintl_type
+ enable_maintainer_mode
+ enable_host_shared
++enable_host_pie
+ '
+       ac_precious_vars='build_alias
+ host_alias
+@@ -1356,6 +1359,7 @@ Optional Features:
+   --disable-rpath         do not hardcode runtime library paths
+   --enable-maintainer-mode enable rules only needed by maintainers
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
+ 
+ Optional Packages:
+   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+@@ -6852,15 +6856,31 @@ fi
+ 
+ 
+ 
++# Enable --enable-host-shared.
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
++  enableval=$enable_host_shared;
++fi
 +
-+void
-+call_use_no_stack (void)
-+{
-+  Empty e;
-+  use_no_stack (0, 1, 2, 3, 4, 5, 6, 7, e, 'j', e, 'l');
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-00.c b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-00.c
-new file mode 100644
-index 00000000000..bd76856308b
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-00.c
-@@ -0,0 +1,126 @@
-+/* { dg-do compile } */
-+/* { dg-additional-options " -O -fno-schedule-insns -fno-schedule-insns2 " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+/* In each case we consume the parm registers with 8 ints, forcing
-+   the test values to be spilled to the stack.  */
-+
-+/* The important thing here is that the chars are assigned to the stack
-+ * with no padding - so that they occupy bytes 0-8. */
-+
-+/*
-+**call_char_packing:
-+**	...
-+**	mov	w[0-9]+, 113
-+**	strb	w[0-9]+, \[sp, 8\]
-+**	mov	w[0-9]+, 112
-+**	strb	w[0-9]+, \[sp, 7\]
-+**	mov	w[0-9]+, 111
-+**	strb	w[0-9]+, \[sp, 6\]
-+**	mov	w[0-9]+, 110
-+**	strb	w[0-9]+, \[sp, 5\]
-+**	mov	w[0-9]+, 109
-+**	strb	w[0-9]+, \[sp, 4\]
-+**	mov	w[0-9]+, 108
-+**	strb	w[0-9]+, \[sp, 3\]
-+**	mov	w[0-9]+, 107
-+**	strb	w[0-9]+, \[sp, 2\]
-+**	mov	w[0-9]+, 106
-+**	strb	w[0-9]+, \[sp, 1\]
-+**	mov	w[0-9]+, 105
-+**	strb	w[0-9]+, \[sp\]
-+**	mov	w7, 7
-+**	mov	w6, 6
-+**	mov	w5, 5
-+**	mov	w4, 4
-+**	mov	w3, 3
-+**	mov	w2, 2
-+**	mov	w1, 1
-+**	mov	w0, 0
-+**	bl	_char_packing
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) void
-+char_packing (int a, int b, int c, int d, int e, int f, int g, int h,
-+	      char i, char j, char k, char l,
-+	      char m, char n, char o, char p,
-+	      char q);
-+
-+void call_char_packing (void)
-+{
-+ char_packing (0, 1, 2, 3, 4, 5, 6, 7,
-+	       'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q');
-+}
 +
-+/* Here we should occupy the first 7 short words on the stack. */
-+
-+/*
-+**call_short_packing:
-+**	...
-+**	mov	w[0-9]+, 12
-+**	strh	w[0-9]+, \[sp, 8\]
-+**	mov	w[0-9]+, 11
-+**	strh	w[0-9]+, \[sp, 6\]
-+**	mov	w[0-9]+, 10
-+**	strh	w[0-9]+, \[sp, 4\]
-+**	mov	w[0-9]+, 9
-+**	strh	w[0-9]+, \[sp, 2\]
-+**	mov	w[0-9]+, 8
-+**	strh	w[0-9]+, \[sp\]
-+**	mov	w7, 7
-+**	mov	w6, 6
-+**	mov	w5, 5
-+**	mov	w4, 4
-+**	mov	w3, 3
-+**	mov	w2, 2
-+**	mov	w1, 1
-+**	mov	w0, 0
-+**	bl	_short_packing
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) void
-+short_packing (int a, int b, int c, int d, int e, int f, int g, int h,
-+		    short i, short j, short k, short l,
-+		    short m);
-+
-+void call_short_packing (void)
-+{
-+ short_packing (0, 1, 2, 3, 4, 5, 6, 7,
-+	        8, 9, 10, 11, 12);
-+}
 +
-+/* Here we should occupy the first 3 ints on the stack. */
-+
-+/*
-+**call_int_packing:
-+**	...
-+**	mov	w[0-9]+, 10
-+**	str	w[0-9]+, \[sp, 8\]
-+**	mov	w[0-9]+, 9
-+**	str	w[0-9]+, \[sp, 4\]
-+**	mov	w[0-9]+, 8
-+**	str	w[0-9]+, \[sp\]
-+**	mov	w7, 7
-+**	mov	w6, 6
-+**	mov	w5, 5
-+**	mov	w4, 4
-+**	mov	w3, 3
-+**	mov	w2, 2
-+**	mov	w1, 1
-+**	mov	w0, 0
-+**	bl	_int_packing
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) void
-+int_packing (int a, int b, int c, int d, int e, int f, int g, int h,
-+	     int i, int j, int k);
-+
-+void call_int_packing (void)
-+{
-+ int_packing (0, 1, 2, 3, 4, 5, 6, 7,
-+	      8, 9, 10);
-+}
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
 +
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-01.c b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-01.c
-new file mode 100644
-index 00000000000..d21fd551b4a
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-01.c
-@@ -0,0 +1,115 @@
-+/* { dg-do compile } */
-+/* { dg-additional-options " -O -fno-schedule-insns -fno-schedule-insns2 " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+/* In each case we consume the parm registers with 8 ints, forcing
-+   the test values to be spilled to the stack.  */
-+
-+/* char short char short - everything on 2byte boundaries */
-+
-+/*
-+**call_c_s_packing:
-+**	...
-+**	mov	w[0-9]+, 109
-+**	strb	w[0-9]+, \[sp, 8\]
-+**	mov	w[0-9]+, 9
-+**	strh	w[0-9]+, \[sp, 6\]
-+**	mov	w[0-9]+, 107
-+**	strb	w[0-9]+, \[sp, 4\]
-+**	mov	w[0-9]+, 8
-+**	strh	w[0-9]+, \[sp, 2\]
-+**	mov	w[0-9]+, 105
-+**	strb	w[0-9]+, \[sp\]
-+**	mov	w7, 7
-+**	mov	w6, 6
-+**	mov	w5, 5
-+**	mov	w4, 4
-+**	mov	w3, 3
-+**	mov	w2, 2
-+**	mov	w1, 1
-+**	mov	w0, 0
-+**	bl	_c_s_packing
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) void
-+c_s_packing (int a, int b, int c, int d, int e, int f, int g, int h,
-+	     char i, short j, char k, short l,
-+	     char m);
-+
-+void call_c_s_packing (void)
-+{
-+ c_s_packing (0, 1, 2, 3, 4, 5, 6, 7,
-+	      'i', 8 , 'k', 9, 'm');
-+}
 +
-+/*
-+**call_s_c_packing:
-+**	...
-+**	mov	w[0-9]+, 109
-+**	strb	w[0-9]+, \[sp, 7\]
-+**	mov	w[0-9]+, 108
-+**	strb	w[0-9]+, \[sp, 6\]
-+**	mov	w[0-9]+, 9
-+**	strh	w[0-9]+, \[sp, 4\]
-+**	mov	w[0-9]+, 106
-+**	strb	w[0-9]+, \[sp, 2\]
-+**	mov	w[0-9]+, 8
-+**	strh	w[0-9]+, \[sp\]
-+**	mov	w7, 7
-+**	mov	w6, 6
-+**	mov	w5, 5
-+**	mov	w4, 4
-+**	mov	w3, 3
-+**	mov	w2, 2
-+**	mov	w1, 1
-+**	mov	w0, 0
-+**	bl	_s_c_packing
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) void
-+s_c_packing (int a, int b, int c, int d, int e, int f, int g, int h,
-+	     short i, char j, short k, char l,
-+	     char m);
-+
-+void call_s_c_packing (void)
-+{
-+ s_c_packing (0, 1, 2, 3, 4, 5, 6, 7,
-+	      8, 'j' , 9, 'l', 'm');
-+}
 +
-+/* 0, 2, 4, 0 */
-+
-+/*
-+**call_csi_packing:
-+**	...
-+**	mov	w[0-9]+, 108
-+**	strb	w[0-9]+, \[sp, 8\]
-+**	mov	w[0-9]+, 9
-+**	str	w[0-9]+, \[sp, 4\]
-+**	mov	w[0-9]+, 8
-+**	strh	w[0-9]+, \[sp, 2\]
-+**	mov	w[0-9]+, 105
-+**	strb	w[0-9]+, \[sp\]
-+**	mov	w7, 7
-+**	mov	w6, 6
-+**	mov	w5, 5
-+**	mov	w4, 4
-+**	mov	w3, 3
-+**	mov	w2, 2
-+**	mov	w1, 1
-+**	mov	w0, 0
-+**	bl	_csi_packing
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) void
-+csi_packing (int a, int b, int c, int d, int e, int f, int g, int h,
-+	     char i, short j, int k, char l);
-+
-+void call_csi_packing (void)
-+{
-+ csi_packing (0, 1, 2, 3, 4, 5, 6, 7,
-+	      'i', 8 , 9, 'l');
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-02.c b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-02.c
-new file mode 100644
-index 00000000000..55e5acdaf41
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-02.c
-@@ -0,0 +1,75 @@
-+/* { dg-do compile } */
-+/* we need this for complex literals.  */
-+/* { dg-options "-std=gnu99 " } */
-+/* { dg-additional-options "-O -fsection-anchors -fno-schedule-insns -fno-schedule-insns2 " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+
-+__attribute__((__noinline__)) void
-+c_cc_packing (int a, int b, int c, int d, int e, int f, int g, int h,
-+	      _Complex char i, _Complex char j);
-+
-+/* We check that these values are not packed on the stack.
-+**call_c_cc_packing:
-+**	...
-+**	ldrh	w[0-9]+, \[x[0-9]+\]
-+**	strh	w[0-9]+, \[sp, 8\]
-+**	ldrh	w[0-9]+, \[x[0-9]+, 2\]
-+**	strh	w[0-9]+, \[sp\]
-+**	...
-+**	bl	_c_cc_packing
-+**	...
-+*/
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
+ else
+   PICFLAG=
+ fi
+ 
+ 
+-
+ ac_config_files="$ac_config_files Makefile config.intl"
+ 
+ cat >confcache <<\_ACEOF
+diff --git a/intl/configure.ac b/intl/configure.ac
+index 16a740aa230..81aa831f59f 100644
+--- a/intl/configure.ac
++++ b/intl/configure.ac
+@@ -83,10 +83,25 @@ fi
+ AC_SUBST(BISON3_YES)
+ AC_SUBST(BISON3_NO)
+ 
++# Enable --enable-host-shared.
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
++       [build host code as shared libraries])])
++AC_SUBST(enable_host_shared)
++
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++       [build host code as PIE])])
++AC_SUBST(enable_host_pie)
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
+ AC_SUBST(PICFLAG)
+ 
+ AC_CONFIG_FILES(Makefile config.intl)
+diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
+index c6c8d81c56a..d18738cd7e6 100644
+--- a/libatomic/Makefile.am
++++ b/libatomic/Makefile.am
+@@ -65,8 +65,13 @@ libatomic_version_script =
+ libatomic_version_dep =
+ endif
+ libatomic_version_info = -version-info $(libtool_VERSION)
++if ENABLE_DARWIN_AT_RPATH
++libatomic_darwin_rpath = -Wc,-nodefaultrpaths
++libatomic_darwin_rpath += -Wl,-rpath,@loader_path
++endif
+ 
+-libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) $(lt_host_flags)
++libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) \
++	$(lt_host_flags) $(libatomic_darwin_rpath) 
+ libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c init.c \
+ 	fenv.c fence.c flag.c
+ 
+diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
+index a0fa3dfc8cc..155c9aa9255 100644
+--- a/libatomic/Makefile.in
++++ b/libatomic/Makefile.in
+@@ -417,7 +417,12 @@ noinst_LTLIBRARIES = libatomic_convenience.la
+ @LIBAT_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libatomic_version_dep = $(top_srcdir)/libatomic.map
+ @LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libatomic_version_dep = libatomic.map-sun
+ libatomic_version_info = -version-info $(libtool_VERSION)
+-libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) $(lt_host_flags)
++@ENABLE_DARWIN_AT_RPATH_TRUE@libatomic_darwin_rpath =  \
++@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wc,-nodefaultrpaths \
++@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
++libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) \
++	$(lt_host_flags) $(libatomic_darwin_rpath) 
 +
-+void
-+call_c_cc_packing (void)
-+{
-+ c_cc_packing (0, 1, 2, 3, 4, 5, 6, 7,
-+	       (_Complex char) (1 + 1i),(_Complex char) (2 + 2i));
-+}
+ libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c \
+ 	init.c fenv.c fence.c flag.c $(am__append_2)
+ SIZEOBJS = load store cas exch fadd fsub fand fior fxor fnand tas
+diff --git a/libatomic/configure b/libatomic/configure
+index e47d2d7fb35..7c687b932e7 100755
+--- a/libatomic/configure
++++ b/libatomic/configure
+@@ -658,6 +658,8 @@ OPT_LDFLAGS
+ SECTION_LDFLAGS
+ enable_aarch64_lse
+ libtool_VERSION
++ENABLE_DARWIN_AT_RPATH_FALSE
++ENABLE_DARWIN_AT_RPATH_TRUE
+ MAINT
+ MAINTAINER_MODE_FALSE
+ MAINTAINER_MODE_TRUE
+@@ -803,6 +805,7 @@ with_pic
+ enable_fast_install
+ with_gnu_ld
+ enable_libtool_lock
++enable_darwin_at_rpath
+ enable_maintainer_mode
+ enable_symvers
+ enable_werror
+@@ -1452,6 +1455,8 @@ Optional Features:
+   --enable-fast-install[=PKGS]
+                           optimize for fast installation [default=yes]
+   --disable-libtool-lock  avoid locking (might break parallel builds)
++  --enable-darwin-at-path install libraries with @rpath/library-name, requires
++                          rpaths to be added to executables
+   --enable-maintainer-mode
+                           enable make rules and dependencies not useful (and
+                           sometimes confusing) to the casual installer
+@@ -7608,7 +7613,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -9581,6 +9586,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+     darwin* | rhapsody*)
+ 
+ 
 +
++  # Publish an arg to allow the user to select that Darwin host (and target)
++  # libraries should be given install-names like @rpath/libfoo.dylib.  This
++  # requires that the user of the library then adds an 'rpath' to the DSO that
++  # needs access.
++  # NOTE: there are defaults below, for systems that support rpaths.  The person
++  # configuring can override the defaults for any system version that supports
++  # them - they are, however, forced off for system versions without support.
++  # Check whether --enable-darwin-at-rpath was given.
++if test "${enable_darwin_at_rpath+set}" = set; then :
++  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
++    # This is not supported before macOS 10.5 / Darwin9.
++    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
++	enable_darwin_at_rpath=no
++      ;;
++    esac
++   fi
++else
++  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
++    # As above, before 10.5 / Darwin9 this does not work.
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++       enable_darwin_at_rpath=no
++       ;;
 +
-+__attribute__((__noinline__)) void
-+c_cs_packing (int a, int b, int c, int d, int e, int f, int g, int h,
-+		   _Complex short i, _Complex short j);
++    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
++    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
++    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
++      enable_darwin_at_rpath=yes
++      ;;
++    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
++    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
 +
-+/*
-+**call_c_cs_packing:
-+**	...
-+**	ldr	w[0-9]+, \[x[0-9]+, 4\]
-+**	str	w[0-9]+, \[sp, 8\]
-+**	ldr	w[0-9]+, \[x[0-9]+, 8\]
-+**	str	w[0-9]+, \[sp\]
-+**	...
-+**	bl	_c_cs_packing
-+**	...
-+*/
++    esac
 +
-+void
-+call_c_cs_packing (void)
-+{
-+ c_cs_packing (0, 1, 2, 3, 4, 5, 6, 7,
-+	       (_Complex short) (1 + 1i),(_Complex short) (2 + 2i));
-+}
++fi
 +
-+void c_ci_packing (int a, int b, int c, int d, int e, int f, int g, int h,
-+		   _Complex int i, _Complex int j);
-+
-+/*
-+**call_c_ci_packing:
-+**	...
-+**	ldr	x[0-9]+, \[x[0-9]+, 12\]
-+**	str	x[0-9]+, \[sp, 8\]
-+**	ldr	x[0-9]+, \[x[0-9]+, 20\]
-+**	str	x[0-9]+, \[sp\]
-+**	...
-+**	bl	_c_ci_packing
-+**	...
-+*/
 +
-+void
-+call_c_ci_packing (void)
-+{
-+ c_ci_packing (0, 1, 2, 3, 4, 5, 6, 7,
-+	       (_Complex int) (1 + 1i),(_Complex int) (2 + 2i));
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-03.c b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-03.c
-new file mode 100644
-index 00000000000..b0d2593dfd7
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-03.c
-@@ -0,0 +1,67 @@
-+/* { dg-do compile } */
-+
-+/* { dg-additional-options "-O -fno-schedule-insns -fno-schedule-insns2 " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+typedef union u { char a; short b; } U;
-+typedef struct sf { float a; float b; float c;} SF;
-+
-+__attribute__((__noinline__)) void
-+u_packing (int a, int b, int c, int d, int e, int f, int g, int h,
-+	   U i, U j);
-+
-+/* We check that these values are not packed on the stack.
-+**call_u_packing:
-+**	...
-+**	strh	w[0-9]+, \[sp, 8\]
-+**	strh	w[0-9]+, \[sp\]
-+**	...
-+**	bl	_u_packing
-+**	...
-+*/
+   archive_cmds_need_lc=no
+   hardcode_direct=no
+   hardcode_automatic=yes
+@@ -9598,9 +9646,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+   esac
+   if test "$_lt_dar_can_shared" = "yes"; then
+     output_verbose_link_cmd=func_echo_all
+-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
++    if test "x$enable_darwin_at_rpath" = "xyes"; then
++      _lt_install_name='@rpath/\$soname'
++    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ 
+   else
+@@ -11406,7 +11458,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11409 "configure"
++#line 11461 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11512,7 +11564,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11515 "configure"
++#line 11567 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11797,6 +11849,15 @@ fi
+ 
+ 
+ 
++ if test x$enable_darwin_at_rpath = xyes; then
++  ENABLE_DARWIN_AT_RPATH_TRUE=
++  ENABLE_DARWIN_AT_RPATH_FALSE='#'
++else
++  ENABLE_DARWIN_AT_RPATH_TRUE='#'
++  ENABLE_DARWIN_AT_RPATH_FALSE=
++fi
 +
-+void
-+call_u_packing (void)
-+{
-+  U x = { 'a' };
-+  u_packing (0, 1, 2, 3, 4, 5, 6, 7, x, x);
-+}
 +
-+/* But a homogeneous float aggregate is treated as if it were the contained
-+   floats.  */
-+
-+__attribute__((__noinline__)) void
-+sf_packing (float a, float b, float c, float d,
-+	    float e, float f, float g, float h,
-+	    SF i, SF j);
-+
-+/* So the stores to sp+12 and 20 pack the floats onto the stack.
-+**call_sf_packing:
-+**	...
-+**	fmov	s1, 1.0e\+0
-+**	str	s1, \[sp, 48\]
-+**	fmov	s2, 2.0e\+0
-+**	str	s2, \[sp, 52\]
-+**	mov	w[0-9]+, 1077936128
-+**	ldr	x[0-9]+, \[sp, 48\]
-+**	str	x[0-9]+, \[sp, 12\]
-+**	str	w[0-9]+, \[sp, 20\]
-+**	str	x[0-9]+, \[sp\]
-+**	str	w[0-9]+, \[sp, 8\]
-+**	fmov	s7, 7.0e\+0
-+**	fmov	s6, 6.0e\+0
-+**	fmov	s5, 5.0e\+0
-+**	fmov	s4, 4.0e\+0
-+**	fmov	s3, 3.0e\+0
-+**	movi	v0.2s, #0
-+**	bl	_sf_packing
-+**	...
-+*/
+ # For libtool versioning info, format is CURRENT:REVISION:AGE
+ libtool_VERSION=3:0:2
+ 
+@@ -15924,6 +15985,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
++  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+ 
+ if test -z "${LIBAT_BUILD_VERSIONED_SHLIB_TRUE}" && test -z "${LIBAT_BUILD_VERSIONED_SHLIB_FALSE}"; then
+   as_fn_error $? "conditional \"LIBAT_BUILD_VERSIONED_SHLIB\" was never defined.
+diff --git a/libatomic/configure.ac b/libatomic/configure.ac
+index 31304685dbd..20981f16f70 100644
+--- a/libatomic/configure.ac
++++ b/libatomic/configure.ac
+@@ -156,6 +156,8 @@ AC_SUBST(enable_shared)
+ AC_SUBST(enable_static)
+ AM_MAINTAINER_MODE
+ 
++AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
 +
-+void
-+call_sf_packing (void)
-+{
-+ SF A = {1.0F, 2.0F, 3.0F};
-+ sf_packing (0.0F, 1.0F, 2.0F, 3.0F, 4.0F, 5.0F, 6.0F, 7.0F,
-+ 	     A, A);
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-04.c b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-04.c
-new file mode 100644
-index 00000000000..33c60c69b78
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d2-04.c
-@@ -0,0 +1,66 @@
-+/* { dg-do compile } */
-+
-+/* { dg-additional-options "-O -fno-schedule-insns -fno-schedule-insns2 " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+typedef short v2hi __attribute__ ((vector_size (4)));
-+typedef int v4si __attribute__ ((vector_size (16)));
-+
-+v4si t;
-+int al = __alignof__ (t);
-+
-+__attribute__((__noinline__)) void
-+v2hi_packing (v2hi a, v2hi b, v2hi c, v2hi d, v2hi e, v2hi f, v2hi g, v2hi h,
-+	      v2hi i, v2hi j);
-+
-+/* We check that v2hi is packed on the stack.
-+**call_v2hi_packing:
-+**	...
-+**	mov	w[0-9]+, 1
-+**	movk	w[0-9]+, 0x2, lsl 16
-+**	str	w[0-9]+, \[sp, 4\]
-+**	str	w[0-9]+, \[sp\]
-+**	mov	w7, w[0-9]+
-+**	mov	w6, w[0-9]+
-+**	mov	w5, w[0-9]+
-+**	mov	w4, w[0-9]+
-+**	mov	w3, w[0-9]+
-+**	mov	w2, w[0-9]+
-+**	mov	w1, w[0-9]+
-+**	bl	_v2hi_packing
-+**	...
-+*/
+ # For libtool versioning info, format is CURRENT:REVISION:AGE
+ libtool_VERSION=3:0:2
+ AC_SUBST(libtool_VERSION)
+diff --git a/libatomic/testsuite/lib/libatomic.exp b/libatomic/testsuite/lib/libatomic.exp
+index 10f38475bc8..c6d645e9ae3 100644
+--- a/libatomic/testsuite/lib/libatomic.exp
++++ b/libatomic/testsuite/lib/libatomic.exp
+@@ -148,11 +148,15 @@ proc libatomic_init { args } {
+     if { $blddir != "" } {
+ 	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
+ 	lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
+-	lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
++        if [istarget *-*-darwin*] {
++            lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
++	} else {
++	    lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
++	}
+     }
+     lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
+ 
+-    if [istarget *-*-darwin*] {
++    if [istarget *-*-darwin\[89\]*] {
+ 	lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
+     }
+ 
+diff --git a/libbacktrace/configure b/libbacktrace/configure
+index 6af2c04c81a..38b54957034 100755
+--- a/libbacktrace/configure
++++ b/libbacktrace/configure
+@@ -681,6 +681,8 @@ PIC_FLAG
+ WARN_FLAGS
+ EXTRA_FLAGS
+ BACKTRACE_FILE
++ENABLE_DARWIN_AT_RPATH_FALSE
++ENABLE_DARWIN_AT_RPATH_TRUE
+ OTOOL64
+ OTOOL
+ LIPO
+@@ -805,6 +807,7 @@ with_pic
+ enable_fast_install
+ with_gnu_ld
+ enable_libtool_lock
++enable_darwin_at_rpath
+ enable_largefile
+ enable_cet
+ enable_werror
+@@ -1453,6 +1456,8 @@ Optional Features:
+   --enable-fast-install[=PKGS]
+                           optimize for fast installation [default=yes]
+   --disable-libtool-lock  avoid locking (might break parallel builds)
++  --enable-darwin-at-path install libraries with @rpath/library-name, requires
++                          rpaths to be added to executables
+   --disable-largefile     omit support for large files
+   --enable-cet            enable Intel CET in target libraries [default=auto]
+   --disable-werror        disable building with -Werror
+@@ -8010,7 +8015,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -9716,6 +9721,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+     darwin* | rhapsody*)
+ 
+ 
 +
-+void
-+call_v2hi_packing (void)
-+{
-+  v2hi x = {1,2};
-+  v2hi_packing (x, x, x, x, x, x, x, x, x, x);
-+}
++  # Publish an arg to allow the user to select that Darwin host (and target)
++  # libraries should be given install-names like @rpath/libfoo.dylib.  This
++  # requires that the user of the library then adds an 'rpath' to the DSO that
++  # needs access.
++  # NOTE: there are defaults below, for systems that support rpaths.  The person
++  # configuring can override the defaults for any system version that supports
++  # them - they are, however, forced off for system versions without support.
++  # Check whether --enable-darwin-at-rpath was given.
++if test "${enable_darwin_at_rpath+set}" = set; then :
++  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
++    # This is not supported before macOS 10.5 / Darwin9.
++    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
++	enable_darwin_at_rpath=no
++      ;;
++    esac
++   fi
++else
++  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
++    # As above, before 10.5 / Darwin9 this does not work.
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++       enable_darwin_at_rpath=no
++       ;;
 +
++    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
++    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
++    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
++      enable_darwin_at_rpath=yes
++      ;;
++    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
++    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
 +
-+__attribute__((__noinline__)) void
-+v4si_packing (int r0, int r1, int r2, int r3, int r4, int r5, int r6, int r7,
-+	      v4si a, v4si b, v4si c, v4si d, v4si e, v4si f, v4si g, v4si h,
-+	      int stack, v4si i, v4si j);
-+
-+/* Test that we align a 16b vector on the stack.
-+**call_v4si_packing:
-+**	...
-+**	adrp	x0, lC0@PAGE
-+**	ldr	q[0-9]+, \[x[0-9]+, #lC0@PAGEOFF\]
-+**	str	q[0-9]+, \[sp, 32\]
-+**	str	q[0-9]+, \[sp, 16\]
-+**	mov	w[0-9]+, 42
-+**	str	w[0-9]+, \[sp\]
-+**	...
-+**	bl	_v4si_packing
-+**	...
-+*/
-+
-+void
-+call_v4si_packing (void)
-+{
-+  v4si x = {3,1,2,4};
-+  v4si_packing (0, 1, 2, 3, 4, 5, 6, 7, x, x, x, x, x, x, x, x, 42, x, x);
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d3.c b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d3.c
-new file mode 100644
-index 00000000000..21c6b696b7c
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d3.c
-@@ -0,0 +1,40 @@
-+/* { dg-do compile } */
-+/* { dg-additional-options "-O " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+/* This will fail, because of issue #74
-+**foo: 
-+**	cmp	w0, w1
-+**	cset	w0, eq
-+**	ret
-+*/
-+
-+__attribute__((__noinline__))
-+int
-+foo (char a, unsigned char b)
-+{
-+  return a == b ? 1 : 0;
-+}
-+
-+__attribute__((__noinline__))
-+int
-+bar (short a, unsigned short b)
-+{
-+  return a == b ? 1 : 0;
-+}
-+
-+void pop (char *, unsigned char *, short *, unsigned short *);
-+
-+int main ()
-+{
-+   char a;
-+   unsigned char b;
-+   short c;
-+   unsigned short d;
-+   int result;
-+   pop (&a, &b, &c, &d);
-+   
-+   result = foo (a, b);
-+   result += bar (c, d);
-+   return result;
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d4.c b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d4.c
-new file mode 100644
-index 00000000000..2aab48260f4
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/darwinpcs-d4.c
-@@ -0,0 +1,62 @@
-+/* { dg-do compile } */
-+/* we need this for __int128.  */
-+/* { dg-options "-std=gnu99 " } */
-+/* { dg-additional-options "-O -fno-schedule-insns -fno-schedule-insns2 " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+/* we should use x0, x1 and x2 - not skip x1.
-+**foo:
-+**	eor	x0, x0, x1
-+**	orr	x0, x0, x2
-+**	cmp	x0, 0
-+**	cset	w0, eq
-+**	ret
-+*/
-+
-+__attribute__((__noinline__))
-+int
-+foo (unsigned long long x,unsigned __int128 y)
-+{
-+  return x == y ? 1 : 0; 
-+}
-+
-+/* we should use x0, x1 and x2.
-+**bar:
-+**	eor	x2, x2, x0
-+**	orr	x2, x2, x1
-+**	cmp	x2, 0
-+**	cset	w0, eq
-+**	ret
-+*/
-+
-+__attribute__((__noinline__))
-+int
-+bar (unsigned __int128 y, unsigned long long x)
-+{
-+  return x == y ? 1 : 0; 
-+}
-+
-+int fooo (unsigned long long x, unsigned __int128 y);
-+int baro (unsigned __int128 y, unsigned long long x);
-+
-+/* we should use x0, x1 and x2 in both calls.
-+**main:
-+**	...
-+**	mov	x1, 25
-+**	mov	x2, 0
-+**	mov	x0, 10
-+**	bl	_fooo
-+**	mov	x2, 10
-+**	mov	x0, 25
-+**	mov	x1, 0
-+**	bl	_baro
-+**	...
-+*/
-+
-+int main ()
-+{
-+  unsigned long long x = 10;
-+  unsigned __int128 y = 25;
-+  int r = fooo (x, y);
-+  r += baro (y, x);
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/float128-00.c b/gcc/testsuite/gcc.target/aarch64/darwin/float128-00.c
-new file mode 100644
-index 00000000000..29aec80fbaa
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/float128-00.c
-@@ -0,0 +1,38 @@
-+
-+/* we need this for _Float128.  */
-+/* { dg-options "-std=gnu99 " } */
-+/* We use the sections anchors to make the code easier to match.  */
-+/* { dg-additional-options " -O2 -fsection-anchors " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+/* we should just pass q0 and q1 through
-+**foo:
-+**	...
-+**	bl	___addtf3
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+_Float128
-+foo (_Float128 a, _Float128 b)
-+{
-+  return a + b;
-+}
-+
-+
-+/* we should just load q0 and q1
-+**call_foo:
-+**	...
-+**	ldr	q1, \[x[0-9]+\]
-+**	...
-+**	ldr	q0, \[x[0-9]+\]
-+**	b	_foo
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+_Float128
-+call_foo (void)
-+{
-+  return foo (1.0, 2.0);
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/homogeneous-aggr.c b/gcc/testsuite/gcc.target/aarch64/darwin/homogeneous-aggr.c
-new file mode 100644
-index 00000000000..bee97557a4d
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/homogeneous-aggr.c
-@@ -0,0 +1,25 @@
-+/* { dg-do compile } */
-+/* { dg-additional-options "-O " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+typedef struct sf { float a; float b; float c;} SF;
-+
-+__attribute__((__noinline__)) void
-+hmg_f (SF a);
-+
-+/* we should use registers for each item
-+**call_hmg_f:
-+**	...
-+**	fmov	s0, 1.0e\+0
-+**	fmov	s1, 2.0e\+0
-+**	fmov	s2, 3.0e\+0
-+**	bl	_hmg_f
-+**	...
-+*/
-+
-+void
-+call_hmg_f (void)
-+{
-+ SF A = { 1.0F, 2.0F, 3.0F };
-+ hmg_f (A);
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/k+r-00.c b/gcc/testsuite/gcc.target/aarch64/darwin/k+r-00.c
-new file mode 100644
-index 00000000000..443fb968811
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/k+r-00.c
-@@ -0,0 +1,28 @@
-+/* { dg-do compile } */
-+
-+/* { dg-options "-std=gnu99 " } */
-+/* { dg-additional-options "-O2 -fsection-anchors" } */
-+
-+
-+/* What we care about here is that we get int loads from sp, sp+4 and sp+8.
-+ * This code will change when we implement darwinpcs d.3 - since the
-+ * promotions will no longer be needed (although they are harmless).
-+**test_k_r00:
-+**	ldrsb	w[0-9]+, \[sp, 4\]
-+**	ldr	x[0-9]+, \[sp, 8\]
-+**	...
-+**	ldrsb	w[0-9]+, \[sp\]
-+**	...
-+*/
-+
-+const char *
-+test_k_r00 (r0, r1, r2, r3, r4, r5, r6, r7, a, b, c)
-+     char r0, r1, r2, r3, r4, r5, r6, r7;
-+     char a;
-+     char b;
-+     const char *c;
-+{
-+  if (a > 10 && b < 100)
-+    return c;
-+  return (char *)0;
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/tu-accesses-0.c b/gcc/testsuite/gcc.target/aarch64/darwin/tu-accesses-0.c
-new file mode 100644
-index 00000000000..ba5cc493bc9
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/tu-accesses-0.c
-@@ -0,0 +1,82 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O -fcommon -mno-pc-relative-literal-loads" } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+/* This checks that we perform the correct accesses for file-scope vars
-+   including GOT indirections.  */
-+
-+double gd = 1.0;
-+
-+__attribute__((__weak__))
-+double wd = 2.0;
-+
-+__attribute__((__visibility__("hidden")))
-+double hd = 3.0;
-+
-+__attribute__((__weak__, __visibility__("hidden")))
-+double whd = 4.0;
-+
-+extern double ed;
-+
-+double cd;
-+
-+static double sd = 5.0;
-+
-+struct {
-+  double a;
-+  double b;
-+} two_dbls = { 1.0, 42.0 };
-+
-+double arr[3] = { 6.0, 7.0, 8.0 };
-+
-+/*
-+**test:
-+**	adrp	x[0-9]+, _gd@PAGE
-+**	ldr	d[0-9]+, \[x[0-9]+, #_gd@PAGEOFF\]
-+**	adrp	x[0-9]+, lC0@PAGE
-+**	ldr	d[0-9]+, \[x[0-9]+, #lC0@PAGEOFF\]
-+**	fadd	d[0-9]+, d[0-9]+, d[0-9]+
-+**	adrp	x[0-9]+, _wd@GOTPAGE
-+**	ldr	x[0-9]+, \[x[0-9]+, _wd@GOTPAGEOFF\]
-+**	ldr	d[0-9]+, \[x[0-9]+\]
-+**	fadd	d[0-9]+, d[0-9]+, d[0-9]+
-+**	adrp	x[0-9]+, _hd@PAGE
-+**	ldr	d[0-9]+, \[x[0-9]+, #_hd@PAGEOFF\]
-+**	fadd	d[0-9]+, d[0-9]+, d[0-9]+
-+**	adrp	x[0-9]+, _whd@PAGE
-+**	ldr	d[0-9]+, \[x[0-9]+, #_whd@PAGEOFF\]
-+**	fadd	d[0-9]+, d[0-9]+, d[0-9]+
-+**	adrp	x[0-9]+, _ed@GOTPAGE
-+**	ldr	x[0-9]+, \[x[0-9]+, _ed@GOTPAGEOFF\]
-+**	ldr	d[0-9]+, \[x[0-9]+\]
-+**	fadd	d[0-9]+, d[0-9]+, d[0-9]+
-+**	adrp	x[0-9]+, _cd@GOTPAGE
-+**	ldr	x[0-9]+, \[x[0-9]+, _cd@GOTPAGEOFF\]
-+**	ldr	d[0-9]+, \[x[0-9]+\]
-+**	fadd	d[0-9]+, d[0-9]+, d[0-9]+
-+**	fmov	d[0-9]+, 5.0e\+0
-+**	fadd	d[0-9]+, d[0-9]+, d[0-9]+
-+**	adrp	x[0-9]+, _two_dbls@PAGE\+8
-+**	ldr	d[0-9]+, \[x[0-9]+, #_two_dbls@PAGEOFF\+8\]
-+**	fadd	d[0-9]+, d[0-9]+, d[0-9]+
-+**	adrp	x[0-9]+, _arr@PAGE\+16
-+**	ldr	d[0-9]+, \[x[0-9]+, #_arr@PAGEOFF\+16\]
-+**	fadd	d[0-9]+, d[0-9]+, d[0-9]+
-+**	ret
-+*/
-+
-+double test (void)
-+{
-+  double x = 123456123456123456.0;
-+  x += gd;
-+  x += wd;
-+  x += hd;
-+  x += whd;
-+  x += ed;
-+  x += cd;
-+  x += sd;
-+  x += two_dbls.b;
-+  x += arr[2];
-+
-+  return x;
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/variadic-00.c b/gcc/testsuite/gcc.target/aarch64/darwin/variadic-00.c
-new file mode 100644
-index 00000000000..6420fca11d5
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/variadic-00.c
-@@ -0,0 +1,91 @@
-+/* { dg-do compile } */
-+
-+/* We use the sections anchors to make the code easier to match.  */
-+/* { dg-additional-options " -O -fsection-anchors -fno-schedule-insns -fno-schedule-insns2 " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+#include 
-+
-+/* What we care about here is that the load of w0 is from the incoming [SP]
-+**fooi:
-+**	sub	sp, sp, #16
-+**	add	x[0-9]+, sp, 24
-+**	str	x[0-9]+, \[sp, 8\]
-+**	ldr	w0, \[sp, 16\]
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) int
-+fooi (int a, ...)
-+{
-+  int x;
-+  va_list ap;
-+  va_start(ap, a);
-+  x = va_arg(ap, int);
-+  va_end(ap);
-+  return x;
-+}
-+
-+__attribute__((__noinline__)) int
-+fooo (char a, ...);
-+
-+/*
-+**call_foo:
-+**	...
-+**	mov	w[0-9]+, 42
-+**	str	w[0-9]+, \[sp\]
-+**	mov	w0, 1
-+**	bl	_fooo
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) int
-+call_foo (void)
-+{
-+  int y = fooo (1, 42);
-+  return y;
-+}
-+
-+/* What we care about here is that the load of w0 is from the incoming [SP+8]
-+**bari:
-+**	sub	sp, sp, #16
-+**	add	x[0-9]+, sp, 32
-+**	str	x[0-9]+, \[sp, 8\]
-+**	ldr	w0, \[sp, 24\]
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) int
-+bari (int a, int b, int c, int d, int e, int f, int g, int h,
-+      int i, ...)
-+{
-+  int x;
-+  va_list ap;
-+  va_start(ap, i);
-+  x = va_arg(ap, int);
-+  va_end(ap);
-+  return x;
-+}
-+
-+/*
-+**call_bar:
-+**	...
-+**	mov	w[0-9]+, 42
-+**	str	w[0-9]+, \[sp, 8\]
-+**	mov	w[0-9]+, 9
-+**	str	w[0-9]+, \[sp\]
-+**	...
-+	bl	_baro
-+**	...
-+*/
-+
-+__attribute__((__noinline__)) int
-+baro (int a, int b, int c, int d, int e, int f, int g, int h,
-+      int i, ...);
-+
-+__attribute__((__noinline__)) int
-+call_bar (void)
-+{
-+  int y = baro (1, 2, 3, 4, 5, 6, 7, 8, 9, 42);
-+  return y;
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/variadic-01.c b/gcc/testsuite/gcc.target/aarch64/darwin/variadic-01.c
-new file mode 100644
-index 00000000000..c055aeae580
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/variadic-01.c
-@@ -0,0 +1,102 @@
-+/* { dg-do compile } */
-+
-+/* we need this for _Float128.  */
-+/* { dg-options "-std=gnu99 " } */
-+/* We use the sections anchors to make the code easier to match.  */
-+/* { dg-additional-options " -O2 -fsection-anchors " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+#include 
-+
-+/* What we care about here is that q0 and q1 are loaded from incoming sp and
-+   sp+16.
-+**foo:
-+**	...
-+**	ldr	q1, \[sp, 32\]
-+**	ldr	q0, \[sp, 48\]
-+**	...
-+**	bl	___addtf3
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+_Float128
-+foo (int n, ...)
-+{
-+  _Float128 a, b;
-+  va_list ap;
-+
-+  va_start(ap, n);
-+  a = va_arg(ap, _Float128);
-+  b = va_arg(ap, _Float128);
-+  va_end(ap); 
-+  return a + b;
-+}
-+
-+/*
-+**call_foo:
-+**	...
-+**	str	q[0-9]+, \[sp, 16\]
-+**	...
-+**	mov	w0, 2
-+**	str	q[0-9]+, \[sp\]
-+**	bl	_foo
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+_Float128
-+call_foo (void)
-+{
-+  return foo (2, (_Float128)1.0, (_Float128)2.0);
-+}
-+
-+/* What we care about here is that q0 and q1 are loaded from incoming sp and
-+   sp+32 (with the int at sp+16).
-+**bar:
-+**	...
-+**	ldr	w[0-9]+, \[x[0-9]+, 16\]
-+**	ldr	q0, \[x[0-9]+\]
-+**	...
-+**	ldr	q1, \[x[0-9]+, 32\]
-+**	bl	___addtf3
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+_Float128
-+bar (int n, ...)
-+{
-+  _Float128 a, b;
-+  va_list ap;
-+
-+  va_start(ap, n);
-+  a = va_arg(ap, _Float128);
-+  n = va_arg(ap, int);
-+  if (n != 42)
-+    __builtin_abort ();
-+  b = va_arg(ap, _Float128);
-+  va_end(ap); 
-+  return a + b;
-+}
-+
-+/*
-+**call_bar:
-+**	...
-+**	str	q[0-9]+, \[sp, 32\]
-+**	...
-+**	mov	w[0-9]+, 42
-+**	str	w[0-9]+, \[sp, 16\]
-+**	mov	w0, 2
-+**	str	q[0-9]+, \[sp\]
-+**	bl	_bar
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+_Float128
-+call_bar (void)
-+{
-+  return bar (2, (_Float128)1.0,
-+	      42, (_Float128)2.0);
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/darwin/variadic-02.c b/gcc/testsuite/gcc.target/aarch64/darwin/variadic-02.c
-new file mode 100644
-index 00000000000..9d796bfc07f
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/aarch64/darwin/variadic-02.c
-@@ -0,0 +1,104 @@
-+/* { dg-do compile } */
-+
-+/* we need this for __int128.  */
-+/* { dg-options "-std=gnu99 " } */
-+/* We use the sections anchors to make the code easier to match.  */
-+/* { dg-additional-options " -O2 -fsection-anchors " } */
-+/* { dg-final { check-function-bodies "**" "" "" { target *-*-darwin* } } } */
-+
-+#include 
-+
-+/* What we care about here is that we load the values from incoming sp and
-+   sp + 16.
-+**foo:
-+**	sub	sp, sp, #16
-+**	...
-+**	ldp	x[0-9]+, x[0-9]+, \[sp, 16\]
-+**	...
-+**	ldr	x[0-9]+, \[sp, 32\]
-+**	ldr	x[0-9]+, \[sp, 40\]
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+__int128
-+foo (int n, ...)
-+{
-+  __int128 a, b;
-+  va_list ap;
-+
-+  va_start(ap, n);
-+  a = va_arg(ap, __int128);
-+  b = va_arg(ap, __int128);
-+  va_end(ap); 
-+  return a + b;
-+}
-+
-+/*
-+**call_foo:
-+**	...
-+**	stp	x[0-9]+, x[0-9]+, \[sp\]
-+**	mov	w0, 2
-+**	stp	x[0-9]+, x[0-9]+, \[sp, 16\]
-+**	bl	_foo
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+__int128
-+call_foo (void)
-+{
-+  return foo (2, (__int128)1, (__int128)2);
-+}
++    esac
 +
++fi
 +
-+/* sp = one int128, sp+16 = int sp + 32 = other int128 
-+**bar:
-+**	...
-+**	sub	sp, sp, #16
-+**	...
-+**	ldp	x[0-9]+, x[0-9]+, \[sp, 16\]
-+**	...
-+**	ldr	x[0-9]+, \[sp, 48\]
-+**	ldr	x[0-9]+, \[sp, 56\]
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+__int128
-+bar (int n, ...)
-+{
-+  __int128 a, b;
-+  va_list ap;
-+
-+  va_start(ap, n);
-+  a = va_arg(ap, __int128);
-+  n = va_arg(ap, int);
-+  b = va_arg(ap, __int128);
-+  va_end(ap); 
-+  return a + b;
-+}
 +
-+__attribute__((__noinline__))
-+__int128
-+baro (int n, ...);
-+
-+/*
-+**call_bar:
-+**	...
-+**	mov	w[0-9]+, 42
-+**	...
-+**	mov	w0, 2
-+**	stp	x[0-9]+, x[0-9]+, \[sp\]
-+**	str	w[0-9]+, \[sp, 16\]
-+**	stp	x[0-9]+, x[0-9]+, \[sp, 32\]
-+**	bl	_baro
-+**	...
-+*/
-+
-+__attribute__((__noinline__))
-+__int128
-+call_bar (void)
-+{
-+  return baro (2, (__int128)1, 42, (__int128)2);
-+}
-diff --git a/gcc/testsuite/gcc.target/aarch64/dbl_mov_immediate_1.c b/gcc/testsuite/gcc.target/aarch64/dbl_mov_immediate_1.c
-index ba6a230457b..cc30dd546f4 100644
---- a/gcc/testsuite/gcc.target/aarch64/dbl_mov_immediate_1.c
-+++ b/gcc/testsuite/gcc.target/aarch64/dbl_mov_immediate_1.c
-@@ -41,8 +41,10 @@ double d4(void)
- 
- /* { dg-final { scan-assembler-times "movi\td\[0-9\]+, #?0"                 1 } } */
- 
--/* { dg-final { scan-assembler-times "adrp\tx\[0-9\]+, \.LC\[0-9\]"         2 } } */
--/* { dg-final { scan-assembler-times "ldr\td\[0-9\]+, \\\[x\[0-9\], #:lo12:\.LC\[0-9\]\\\]" 2 } } */
-+/* { dg-final { scan-assembler-times "adrp\tx\[0-9\]+, \.LC\[0-9\]"         2  { target { ! *-*-darwin* } } } } */
-+/* { dg-final { scan-assembler-times "ldr\td\[0-9\]+, \\\[x\[0-9\], #:lo12:\.LC\[0-9\]\\\]" 2  { target { ! *-*-darwin* } } } } */
-+/* { dg-final { scan-assembler-times "adrp\tx\[0-9\]+, lC\[0-9\]@PAGE" 2  { target *-*-darwin* } } } */
-+/* { dg-final { scan-assembler-times "ldr\td\[0-9\]+, \\\[x\[0-9\], #lC\[0-9\]@PAGEOFF\\\]" 2  { target *-*-darwin* } } } */
- 
- /* { dg-final { scan-assembler-times "fmov\td\[0-9\]+, 1\\\.5e\\\+0"        1 } } */
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/dwarf-cfa-reg.c b/gcc/testsuite/gcc.target/aarch64/dwarf-cfa-reg.c
-index ae5b3797021..8a691add222 100644
---- a/gcc/testsuite/gcc.target/aarch64/dwarf-cfa-reg.c
-+++ b/gcc/testsuite/gcc.target/aarch64/dwarf-cfa-reg.c
-@@ -1,5 +1,6 @@
- /* Verify that CFA register is restored to SP after FP is restored.  */
- /* { dg-do compile } */
-+/* { dg-skip-if "no cfi insn support yet" *-*-darwin* } */
- /* { dg-options "-O0 -gdwarf-2" } */
- /* { dg-final { scan-assembler ".cfi_restore 30" } } */
- /* { dg-final { scan-assembler ".cfi_restore 29" } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/inline-lrint_1.c b/gcc/testsuite/gcc.target/aarch64/inline-lrint_1.c
-index 478875ff874..9a2b2e44893 100644
---- a/gcc/testsuite/gcc.target/aarch64/inline-lrint_1.c
-+++ b/gcc/testsuite/gcc.target/aarch64/inline-lrint_1.c
-@@ -15,4 +15,4 @@ TEST (fllf, float , long long, l)
- 
- /* { dg-final { scan-assembler-times "frintx\t\[d,s\]\[0-9\]+, \[d,s\]\[0-9\]+" 6 } } */
- /* { dg-final { scan-assembler-times "fcvtzs\tx\[0-9\]+, \[d,s\]\[0-9\]+" 6 } } */
--/* { dg-final { scan-assembler-not "bl"    } } */
-+/* { dg-final { scan-assembler-not "bl\t" } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/ldp_stp_13.c b/gcc/testsuite/gcc.target/aarch64/ldp_stp_13.c
-index 9cc3942f153..52c90a92114 100644
---- a/gcc/testsuite/gcc.target/aarch64/ldp_stp_13.c
-+++ b/gcc/testsuite/gcc.target/aarch64/ldp_stp_13.c
-@@ -1,4 +1,5 @@
- /* { dg-do compile } */
-+/* { dg-require-effective-target arm_mabi_ilp32 } */
- /* { dg-options "-O2 -mabi=ilp32" } */
- 
- long long
-diff --git a/gcc/testsuite/gcc.target/aarch64/memset-corner-cases-2.c b/gcc/testsuite/gcc.target/aarch64/memset-corner-cases-2.c
-index 9ee96f33255..dec73f98506 100644
---- a/gcc/testsuite/gcc.target/aarch64/memset-corner-cases-2.c
-+++ b/gcc/testsuite/gcc.target/aarch64/memset-corner-cases-2.c
-@@ -7,7 +7,7 @@
- /* 127 bytes should use libcall for size.
- **set127byte:
- **	mov	x2, 127
--**	b	memset
-+**	b	_?memset
- */
- void __attribute__((__noinline__))
- set127byte (int64_t *src, int c)
-@@ -18,7 +18,7 @@ set127byte (int64_t *src, int c)
- /* 128 bytes should use libcall for size.
- **set128byte:
- **	mov	x2, 128
--**	b	memset
-+**	b	_?memset
- */
- void __attribute__((__noinline__))
- set128byte (int64_t *src, int c)
-diff --git a/gcc/testsuite/gcc.target/aarch64/memset-corner-cases.c b/gcc/testsuite/gcc.target/aarch64/memset-corner-cases.c
-index c43f0199adc..733a11e585a 100644
---- a/gcc/testsuite/gcc.target/aarch64/memset-corner-cases.c
-+++ b/gcc/testsuite/gcc.target/aarch64/memset-corner-cases.c
-@@ -77,7 +77,7 @@ set256byte (int64_t *src, char c)
- **set257byte:
- **	mov	x2, 257
- **	mov	w1, 99
--**	b	memset
-+**	b	_?memset
- */
- void __attribute__((__noinline__))
- set257byte (int64_t *src)
-diff --git a/gcc/testsuite/gcc.target/aarch64/no-inline-lrint_1.c b/gcc/testsuite/gcc.target/aarch64/no-inline-lrint_1.c
-index d5e9200562c..7f504ad687f 100644
---- a/gcc/testsuite/gcc.target/aarch64/no-inline-lrint_1.c
-+++ b/gcc/testsuite/gcc.target/aarch64/no-inline-lrint_1.c
-@@ -14,6 +14,6 @@ TEST (dlld, double, long long, l)
- TEST (fllf, float , long long, l)
- 
- /* { dg-final { scan-assembler-times "frintx\t\[d,s\]\[0-9\]+, \[d,s\]\[0-9\]+" 6 } } */
--/* { dg-final { scan-assembler-times "bl\tlrint"  4 } } */
--/* { dg-final { scan-assembler-times "bl\tllrint" 2 } } */
-+/* { dg-final { scan-assembler-times "bl\t_*lrint"  4 } } */
-+/* { dg-final { scan-assembler-times "bl\t_*llrint" 2 } } */
- /* { dg-final { scan-assembler-not "fcvtzs" } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/pr100518.c b/gcc/testsuite/gcc.target/aarch64/pr100518.c
-index 5ca599f5d2e..4e7d6bc7d90 100644
---- a/gcc/testsuite/gcc.target/aarch64/pr100518.c
-+++ b/gcc/testsuite/gcc.target/aarch64/pr100518.c
-@@ -1,4 +1,5 @@
- /* { dg-do compile } */
-+/* { dg-require-effective-target arm_mabi_ilp32 } */
- /* { dg-options "-mabi=ilp32 -mstrict-align -O2" } */
- 
- int unsigned_range_min, unsigned_range_max, a11___trans_tmp_1;
-diff --git a/gcc/testsuite/gcc.target/aarch64/pr62308.c b/gcc/testsuite/gcc.target/aarch64/pr62308.c
-index 1cf6e212dca..4c1a733e84d 100644
---- a/gcc/testsuite/gcc.target/aarch64/pr62308.c
-+++ b/gcc/testsuite/gcc.target/aarch64/pr62308.c
-@@ -1,4 +1,5 @@
- /* { dg-do compile } */
-+/* { dg-skip-if "Darwin platforms do not support big-endian arm64" *-*-darwin* } */
- /* { dg-options "-mbig-endian" } */
- 
- typedef int __attribute__((vector_size(16))) v4si;
-diff --git a/gcc/testsuite/gcc.target/aarch64/pr78255.c b/gcc/testsuite/gcc.target/aarch64/pr78255.c
-index b078cf3e1c1..fc5d859ee68 100644
---- a/gcc/testsuite/gcc.target/aarch64/pr78255.c
-+++ b/gcc/testsuite/gcc.target/aarch64/pr78255.c
-@@ -1,4 +1,5 @@
- /* { dg-do compile } */
-+/* { dg-skip-if "Darwin platforms do not support tiny" *-*-darwin* } */
- /* { dg-options "-O2 -mcmodel=tiny" } */
- 
- extern int bar (void *);
-diff --git a/gcc/testsuite/gcc.target/aarch64/pr78561.c b/gcc/testsuite/gcc.target/aarch64/pr78561.c
-index 048d2d7969f..635214edde1 100644
---- a/gcc/testsuite/gcc.target/aarch64/pr78561.c
-+++ b/gcc/testsuite/gcc.target/aarch64/pr78561.c
-@@ -1,4 +1,5 @@
- /* { dg-do compile } */
-+/* { dg-skip-if "Darwin platforms do not support tiny" *-*-darwin* } */
- /* { dg-options "-Og -O3 -mcmodel=tiny" } */
+   archive_cmds_need_lc=no
+   hardcode_direct=no
+   hardcode_automatic=yes
+@@ -9733,9 +9781,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+   esac
+   if test "$_lt_dar_can_shared" = "yes"; then
+     output_verbose_link_cmd=func_echo_all
+-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
++    if test "x$enable_darwin_at_rpath" = "xyes"; then
++      _lt_install_name='@rpath/\$soname'
++    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
- int
-diff --git a/gcc/testsuite/gcc.target/aarch64/pr80295.c b/gcc/testsuite/gcc.target/aarch64/pr80295.c
-index b3866d8d6a9..7a7f127b65f 100644
---- a/gcc/testsuite/gcc.target/aarch64/pr80295.c
-+++ b/gcc/testsuite/gcc.target/aarch64/pr80295.c
-@@ -1,4 +1,5 @@
- /* { dg-do compile } */
-+/* { dg-require-effective-target arm_mabi_ilp32 } */
- /* { dg-options "-mabi=ilp32" } */
- 
- void f (void *b) 
-diff --git a/gcc/testsuite/gcc.target/aarch64/pr87305.c b/gcc/testsuite/gcc.target/aarch64/pr87305.c
-index 8beaa9176e0..c3f98e8eaec 100644
---- a/gcc/testsuite/gcc.target/aarch64/pr87305.c
-+++ b/gcc/testsuite/gcc.target/aarch64/pr87305.c
-@@ -1,4 +1,5 @@
- /* { dg-do compile } */
-+/* { dg-skip-if "Darwin platforms do not support big-endian arm64" *-*-darwin* } */
- /* { dg-options "-Ofast -mbig-endian -w" } */
- 
- int cc;
-diff --git a/gcc/testsuite/gcc.target/aarch64/pr92424-1.c b/gcc/testsuite/gcc.target/aarch64/pr92424-1.c
-index c413a2c306e..59f7435dc83 100644
---- a/gcc/testsuite/gcc.target/aarch64/pr92424-1.c
-+++ b/gcc/testsuite/gcc.target/aarch64/pr92424-1.c
-@@ -1,6 +1,7 @@
- /* { dg-do "compile" } */
- /* { dg-options "-O1" } */
- /* { dg-final { check-function-bodies "**" "" } } */
-+/* { dg-skip-if "unimplemented patchable function entry" *-*-darwin* } */
- 
- /* Note: this test only checks the instructions in the function bodies,
-    not the placement of the patch label or nops before the futncion.  */
-diff --git a/gcc/testsuite/gcc.target/aarch64/pr94201.c b/gcc/testsuite/gcc.target/aarch64/pr94201.c
-index 69176169186..051c742e98e 100644
---- a/gcc/testsuite/gcc.target/aarch64/pr94201.c
-+++ b/gcc/testsuite/gcc.target/aarch64/pr94201.c
-@@ -1,4 +1,5 @@
- /* { dg-do compile } */
-+/* { dg-require-effective-target arm_mabi_ilp32 } */
- /* { dg-options "-mcmodel=tiny -mabi=ilp32 -fPIC" } */
- 
- extern int bar (void *);
-diff --git a/gcc/testsuite/gcc.target/aarch64/pr94577.c b/gcc/testsuite/gcc.target/aarch64/pr94577.c
-index 6f2d3612c26..6a52e52dc39 100644
---- a/gcc/testsuite/gcc.target/aarch64/pr94577.c
-+++ b/gcc/testsuite/gcc.target/aarch64/pr94577.c
-@@ -1,4 +1,5 @@
- /* { dg-do compile } */
-+/* { dg-require-effective-target arm_mabi_ilp32 } */
- /* { dg-options "-mcmodel=large -mabi=ilp32" } */
+   else
+@@ -11541,7 +11593,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11544 "configure"
++#line 11596 "configure"
+ #include "confdefs.h"
  
- void
-diff --git a/gcc/testsuite/gcc.target/aarch64/pr97535.c b/gcc/testsuite/gcc.target/aarch64/pr97535.c
-index 7d4db485f1f..6f1ee8035eb 100644
---- a/gcc/testsuite/gcc.target/aarch64/pr97535.c
-+++ b/gcc/testsuite/gcc.target/aarch64/pr97535.c
-@@ -13,4 +13,4 @@ void setRaw(const void *raw)
- 
- /* At any optimization level this should be a function call
-    and not inlined.  */
--/* { dg-final { scan-assembler "bl\tmemcpy" } } */
-+/* { dg-final { scan-assembler "bl\t_*memcpy" } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-2.c b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-2.c
-index 8eec6824f37..193c65717ed 100644
---- a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-2.c
-+++ b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-2.c
-@@ -1,5 +1,6 @@
- /* { dg-do compile } */
- /* { dg-options "-Ofast" } */
-+/* { dg-skip-if "no system variant_pcs support" *-*-darwin* } */
- 
- __attribute__ ((__simd__ ("notinbranch")))
- __attribute__ ((__nothrow__ , __leaf__ , __const__))
-@@ -12,5 +13,5 @@ void bar(double * f, int n)
- 		f[i] = foo(f[i]);
- }
+ #if HAVE_DLFCN_H
+@@ -11647,7 +11699,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11650 "configure"
++#line 11702 "configure"
+ #include "confdefs.h"
  
--/* { dg-final { scan-assembler-not {\.variant_pcs\tfoo} } } */
--/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnN2v_foo} 1 } } */
-+/* { dg-final { scan-assembler-not {\.variant_pcs\t_?foo} } } */
-+/* { dg-final { scan-assembler-times {\.variant_pcs\t_?_ZGVnN2v_foo} 1 } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c
-index 95f6a6803e8..6fd57735b3a 100644
---- a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c
-+++ b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c
-@@ -1,5 +1,6 @@
- /* { dg-do compile } */
- /* { dg-options "-Ofast" } */
-+/* { dg-skip-if "no system variant_pcs support" *-*-darwin* } */
- 
- __attribute__ ((__simd__))
- __attribute__ ((__nothrow__ , __leaf__ , __const__))
-@@ -17,8 +18,8 @@ double foo(double x)
- 	return x * x / 3.0;
- }
+ #if HAVE_DLFCN_H
+@@ -11886,6 +11938,15 @@ CC="$lt_save_CC"
  
--/* { dg-final { scan-assembler-not {\.variant_pcs\tfoo} } } */
--/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnM1v_foo} 1 } } */
--/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnM2v_foo} 1 } } */
--/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnN1v_foo} 1 } } */
--/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnN2v_foo} 1 } } */
-+/* { dg-final { scan-assembler-not {\.variant_pcs\t_?foo} } } */
-+/* { dg-final { scan-assembler-times {\.variant_pcs\t_?_ZGVnM1v_foo} 1 } } */
-+/* { dg-final { scan-assembler-times {\.variant_pcs\t_?_ZGVnM2v_foo} 1 } } */
-+/* { dg-final { scan-assembler-times {\.variant_pcs\t_?_ZGVnN1v_foo} 1 } } */
-+/* { dg-final { scan-assembler-times {\.variant_pcs\t_?_ZGVnN2v_foo} 1 } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute.c b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute.c
-index eddcef3597c..62ee482a892 100644
---- a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute.c
-+++ b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute.c
-@@ -1,5 +1,6 @@
- /* { dg-do compile } */
- /* { dg-options "-Ofast" } */
-+/* { dg-skip-if "no system variant_pcs support" *-*-darwin* } */
- 
- __attribute__ ((__simd__ ("notinbranch")))
- __attribute__ ((__nothrow__ , __leaf__ , __const__))
-@@ -12,5 +13,5 @@ void foo(double *f, int n)
- 		f[i] = log(f[i]);
- }
  
--/* { dg-final { scan-assembler-not {\.variant_pcs\tlog} } } */
--/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnN2v_log} 1 } } */
-+/* { dg-final { scan-assembler-not {\.variant_pcs\t_?log} } } */
-+/* { dg-final { scan-assembler-times {\.variant_pcs\t_?_ZGVnN2v_log} 1 } } */
-diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-1.c b/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-1.c
-index 6885894a97e..ebba23c9d02 100644
---- a/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-1.c
-+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-1.c
-@@ -1,6 +1,7 @@
- /* { dg-do compile } */
- /* { dg-options "-O2 -fstack-clash-protection --param stack-clash-protection-guard-size=16 -funwind-tables" } */
- /* { dg-require-effective-target supports_stack_clash_protection } */
-+/* { dg-skip-if "no cfi insn support yet" *-*-darwin* } */
- 
- #define SIZE 128*1024
- #include "stack-check-prologue.h"
-diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-2.c b/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-2.c
-index 5796a53be06..e15fbd6196c 100644
---- a/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-2.c
-+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-2.c
-@@ -1,6 +1,7 @@
- /* { dg-do compile } */
- /* { dg-options "-O2 -fstack-clash-protection --param stack-clash-protection-guard-size=16 -funwind-tables" } */
- /* { dg-require-effective-target supports_stack_clash_protection } */
-+/* { dg-skip-if "no cfi insn support yet" *-*-darwin* } */
- 
- #define SIZE 1280*1024 + 512
- #include "stack-check-prologue.h"
-diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-3.c b/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-3.c
-index c4b7bb601c4..ccaf2e6f8cf 100644
---- a/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-3.c
-+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-cfa-3.c
-@@ -1,6 +1,7 @@
- /* { dg-do compile } */
- /* { dg-options "-O3 -fopenmp-simd -march=armv8-a+sve -fstack-clash-protection --param stack-clash-protection-guard-size=16 -funwind-tables" } */
- /* { dg-require-effective-target supports_stack_clash_protection } */
-+/* { dg-skip-if "no cfi insn support yet" *-*-darwin* } */
- 
- #include "stack-check-prologue-16.c"
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/sve/aarch64-sve.exp b/gcc/testsuite/gcc.target/aarch64/sve/aarch64-sve.exp
-index 71dd6687c6b..7a62814edbb 100644
---- a/gcc/testsuite/gcc.target/aarch64/sve/aarch64-sve.exp
-+++ b/gcc/testsuite/gcc.target/aarch64/sve/aarch64-sve.exp
-@@ -25,6 +25,11 @@ if {![istarget aarch64*-*-*] } then {
-   return
- }
  
-+# Darwin doesn't support sve
-+if { [istarget *-*-darwin*] } then {
-+  return
-+}
++ if test x$enable_darwin_at_rpath = xyes; then
++  ENABLE_DARWIN_AT_RPATH_TRUE=
++  ENABLE_DARWIN_AT_RPATH_FALSE='#'
++else
++  ENABLE_DARWIN_AT_RPATH_TRUE='#'
++  ENABLE_DARWIN_AT_RPATH_FALSE=
++fi
 +
- # Load support procs.
- load_lib gcc-dg.exp
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp b/gcc/testsuite/gcc.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp
-index a271f1793f4..2da5720d1f3 100644
---- a/gcc/testsuite/gcc.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp
-+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp
-@@ -24,6 +24,11 @@ if {![istarget aarch64*-*-*] } {
-     return
- }
- 
-+# Darwin doesn't support sve
-+if { [istarget *-*-darwin*] } then {
-+  return
-+}
 +
- # Load support procs.
- load_lib gcc-dg.exp
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/aarch64-sve-acle.exp b/gcc/testsuite/gcc.target/aarch64/sve/acle/aarch64-sve-acle.exp
-index ce71c9c1fd4..c7bd136f202 100644
---- a/gcc/testsuite/gcc.target/aarch64/sve/acle/aarch64-sve-acle.exp
-+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/aarch64-sve-acle.exp
-@@ -25,6 +25,11 @@ if {![istarget aarch64*-*-*] } {
-     return
- }
+ # Check whether --enable-largefile was given.
+ if test "${enable_largefile+set}" = set; then :
+   enableval=$enable_largefile;
+@@ -14435,6 +14496,10 @@ if test -z "${HAVE_DWZ_TRUE}" && test -z "${HAVE_DWZ_FALSE}"; then
+   as_fn_error $? "conditional \"HAVE_DWZ\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
++  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+ if test -z "${HAVE_ELF_TRUE}" && test -z "${HAVE_ELF_FALSE}"; then
+   as_fn_error $? "conditional \"HAVE_ELF\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
+index 39e6bf41e35..98b96fcb86f 100644
+--- a/libbacktrace/configure.ac
++++ b/libbacktrace/configure.ac
+@@ -84,6 +84,8 @@ AM_CONDITIONAL(HAVE_DWZ, test "$DWZ" != "")
+ LT_INIT
+ AM_PROG_LIBTOOL
  
-+# Darwin doesn't support sve
-+if { [istarget *-*-darwin*] } then {
-+  return
-+}
++AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
 +
- # Load support procs.
- load_lib gcc-dg.exp
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pcs/aarch64-sve-pcs.exp b/gcc/testsuite/gcc.target/aarch64/sve/pcs/aarch64-sve-pcs.exp
-index 83786733f35..9ab68902def 100644
---- a/gcc/testsuite/gcc.target/aarch64/sve/pcs/aarch64-sve-pcs.exp
-+++ b/gcc/testsuite/gcc.target/aarch64/sve/pcs/aarch64-sve-pcs.exp
-@@ -25,6 +25,10 @@ if {![istarget aarch64*-*-*] } then {
-     return
- }
+ AC_SYS_LARGEFILE
  
-+if { [istarget *-*-darwin*] } then {
-+    return
-+}
-+
- # Load support procs.
- load_lib gcc-dg.exp
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/aarch64-sve2.exp b/gcc/testsuite/gcc.target/aarch64/sve2/aarch64-sve2.exp
-index 60652dbf8fb..010e32132cb 100644
---- a/gcc/testsuite/gcc.target/aarch64/sve2/aarch64-sve2.exp
-+++ b/gcc/testsuite/gcc.target/aarch64/sve2/aarch64-sve2.exp
-@@ -25,6 +25,11 @@ if {![istarget aarch64*-*-*] } then {
-   return
- }
+ backtrace_supported=yes
+diff --git a/libcc1/configure b/libcc1/configure
+index bae3b8712b6..9ee2b785eb1 100755
+--- a/libcc1/configure
++++ b/libcc1/configure
+@@ -787,6 +787,7 @@ with_pic
+ enable_fast_install
+ with_gnu_ld
+ enable_libtool_lock
++enable_darwin_at_rpath
+ enable_cet
+ with_gcc_major_version_only
+ enable_werror_always
+@@ -1439,6 +1440,8 @@ Optional Features:
+   --enable-fast-install[=PKGS]
+                           optimize for fast installation [default=yes]
+   --disable-libtool-lock  avoid locking (might break parallel builds)
++  --enable-darwin-at-path install libraries with @rpath/library-name, requires
++                          rpaths to be added to executables
+   --enable-cet            enable Intel CET in host libraries [default=auto]
+   --enable-werror-always  enable -Werror despite compiler version
+   --enable-plugin         enable plugin support
+@@ -7271,7 +7274,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -8976,6 +8979,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+     darwin* | rhapsody*)
  
-+# Darwin doesn't support sve
-+if { [istarget *-*-darwin*] } then {
-+  return
-+}
-+
- # Load support procs.
- load_lib gcc-dg.exp
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/acle/aarch64-sve2-acle-asm.exp b/gcc/testsuite/gcc.target/aarch64/sve2/acle/aarch64-sve2-acle-asm.exp
-index e08cd612190..a7e5f364770 100644
---- a/gcc/testsuite/gcc.target/aarch64/sve2/acle/aarch64-sve2-acle-asm.exp
-+++ b/gcc/testsuite/gcc.target/aarch64/sve2/acle/aarch64-sve2-acle-asm.exp
-@@ -24,6 +24,11 @@ if {![istarget aarch64*-*-*] } {
-     return
- }
  
-+# Darwin doesn't support sve
-+if { [istarget *-*-darwin*] } then {
-+  return
-+}
 +
- # Load support procs.
- load_lib gcc-dg.exp
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/acle/aarch64-sve2-acle.exp b/gcc/testsuite/gcc.target/aarch64/sve2/acle/aarch64-sve2-acle.exp
-index f0255967c9d..82092e337f6 100644
---- a/gcc/testsuite/gcc.target/aarch64/sve2/acle/aarch64-sve2-acle.exp
-+++ b/gcc/testsuite/gcc.target/aarch64/sve2/acle/aarch64-sve2-acle.exp
-@@ -25,6 +25,11 @@ if {![istarget aarch64*-*-*] } {
-     return
- }
- 
-+# Darwin doesn't support sve
-+if { [istarget *-*-darwin*] } then {
-+  return
-+}
++  # Publish an arg to allow the user to select that Darwin host (and target)
++  # libraries should be given install-names like @rpath/libfoo.dylib.  This
++  # requires that the user of the library then adds an 'rpath' to the DSO that
++  # needs access.
++  # NOTE: there are defaults below, for systems that support rpaths.  The person
++  # configuring can override the defaults for any system version that supports
++  # them - they are, however, forced off for system versions without support.
++  # Check whether --enable-darwin-at-rpath was given.
++if test "${enable_darwin_at_rpath+set}" = set; then :
++  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
++    # This is not supported before macOS 10.5 / Darwin9.
++    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
++	enable_darwin_at_rpath=no
++      ;;
++    esac
++   fi
++else
++  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
++    # As above, before 10.5 / Darwin9 this does not work.
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++       enable_darwin_at_rpath=no
++       ;;
 +
- # Load support procs.
- load_lib gcc-dg.exp
- 
-diff --git a/gcc/testsuite/gcc.target/aarch64/symbol-range-tiny.c b/gcc/testsuite/gcc.target/aarch64/symbol-range-tiny.c
-index fc6a4f3ec78..2d9e94bc625 100644
---- a/gcc/testsuite/gcc.target/aarch64/symbol-range-tiny.c
-+++ b/gcc/testsuite/gcc.target/aarch64/symbol-range-tiny.c
-@@ -1,4 +1,5 @@
- /* { dg-do link } */
-+/* { dg-skip-if "no mcmodel tiny" *-*-darwin* } */
- /* { dg-options "-O3 -save-temps -mcmodel=tiny" } */
- 
- char fixed_regs[0x00080000];
-diff --git a/gcc/testsuite/gcc.target/aarch64/uaddw-3.c b/gcc/testsuite/gcc.target/aarch64/uaddw-3.c
-index 39cbd6b6cc2..b4ed187bd2c 100644
---- a/gcc/testsuite/gcc.target/aarch64/uaddw-3.c
-+++ b/gcc/testsuite/gcc.target/aarch64/uaddw-3.c
-@@ -1,10 +1,11 @@
- /* { dg-do compile } */
- /* { dg-options "-O3" } */
-+/* { dg-additional-options "-fno-signed-char" { target *-*-darwin* } } */
- 
- #pragma GCC target "+nosve"
- 
- int 
--t6(int len, void * dummy, char * __restrict x)
-+t6(int len, void * dummy, unsigned char * __restrict x)
- {
-   len = len & ~31;
-   unsigned short result = 0;
-diff --git a/gcc/testsuite/gcc.target/aarch64/vect-cse-codegen.c b/gcc/testsuite/gcc.target/aarch64/vect-cse-codegen.c
-index d025e989a1e..f218504c719 100644
---- a/gcc/testsuite/gcc.target/aarch64/vect-cse-codegen.c
-+++ b/gcc/testsuite/gcc.target/aarch64/vect-cse-codegen.c
-@@ -6,8 +6,8 @@
- 
- /*
- **test1:
--**	adrp	x[0-9]+, .LC[0-9]+
--**	ldr	q[0-9]+, \[x[0-9]+, #:lo12:.LC[0-9]+\]
-+**	adrp	x[0-9]+, (.LC[0-9]+|lC[0-9]+@PAGE)
-+**	ldr	q[0-9]+, \[x[0-9]+, #(:lo12:.LC[0-9]+|lC[0-9]+@PAGEOFF)\]
- **	add	v[0-9]+.2d, v[0-9]+.2d, v[0-9]+.2d
- **	str	q[0-9]+, \[x[0-9]+\]
- **	fmov	x[0-9]+, d[0-9]+
-@@ -27,13 +27,14 @@ test1 (uint64_t a, uint64x2_t b, uint64x2_t* rt)
- 
- /*
- **test2:
--**	adrp	x[0-9]+, .LC[0-1]+
--**	ldr	q[0-9]+, \[x[0-9]+, #:lo12:.LC[0-9]+\]
-+**	adrp	x[0-9]+, (.LC[0-1]+|lC[0-1]+@PAGE)
-+**	ldr	q[0-9]+, \[x[0-9]+, #(:lo12:.LC[0-9]+|lC[0-9]+@PAGEOFF)\]
- **	add	v[0-9]+.2d, v[0-9]+.2d, v[0-9]+.2d
- **	str	q[0-9]+, \[x[0-9]+\]
- **	fmov	x[0-9]+, d[0-9]+
- **	orr	x[0-9]+, x[0-9]+, x[0-9]+
- **	ret
-+
- */
- 
- uint64_t
-@@ -48,8 +49,8 @@ test2 (uint64_t a, uint64x2_t b, uint64x2_t* rt)
- 
- /*
- **test3:
--**	adrp	x[0-9]+, .LC[0-9]+
--**	ldr	q[0-9]+, \[x[0-9]+, #:lo12:.LC[0-9]+\]
-+**	adrp	x[0-9]+, (.LC[0-9]+|lC[0-9]+@PAGE)
-+**	ldr	q[0-9]+, \[x[0-9]+, #(:lo12:.LC[0-9]+|lC[0-9]+@PAGEOFF)\]
- **	add	v[0-9]+.4s, v[0-9]+.4s, v[0-9]+.4s
- **	str	q[0-9]+, \[x1\]
- **	fmov	w[0-9]+, s[0-9]+
-diff --git a/gcc/testsuite/gfortran.dg/coarray/caf.exp b/gcc/testsuite/gfortran.dg/coarray/caf.exp
-index 8683a2ab435..e76cb69dcd9 100644
---- a/gcc/testsuite/gfortran.dg/coarray/caf.exp
-+++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp
-@@ -28,6 +28,7 @@
++    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
++    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
++    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
++      enable_darwin_at_rpath=yes
++      ;;
++    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
++    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
++
++    esac
++
++fi
++
++
+   archive_cmds_need_lc=no
+   hardcode_direct=no
+   hardcode_automatic=yes
+@@ -8993,9 +9039,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+   esac
+   if test "$_lt_dar_can_shared" = "yes"; then
+     output_verbose_link_cmd=func_echo_all
+-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
++    if test "x$enable_darwin_at_rpath" = "xyes"; then
++      _lt_install_name='@rpath/\$soname'
++    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
- # Load procedures from common libraries. 
- load_lib gfortran-dg.exp
-+load_lib atomic-dg.exp
+   else
+@@ -10801,7 +10851,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 10804 "configure"
++#line 10854 "configure"
+ #include "confdefs.h"
  
- # If a testcase doesn't have special options, use these.
- global DEFAULT_FFLAGS
-@@ -47,6 +48,7 @@ global gfortran_test_path
- global gfortran_aux_module_flags
- set gfortran_test_path $srcdir/$subdir
- set gfortran_aux_module_flags $DEFAULT_FFLAGS
-+
- proc dg-compile-aux-modules { args } {
-     global gfortran_test_path
-     global gfortran_aux_module_flags
-@@ -69,9 +71,21 @@ proc dg-compile-aux-modules { args } {
- }
- 
- # Add -latomic only where supported.  Assume built-in support elsewhere.
--set maybe_atomic_lib ""
- if [check_effective_target_libatomic_available] {
--    set maybe_atomic_lib "-latomic"
-+    #set maybe_atomic_lib "-latomic"
-+    if ![is_remote host] {
-+	if [info exists TOOL_OPTIONS] {
-+	    set maybe_atomic_lib "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]"
-+	} else {
-+	    set maybe_atomic_lib "[atomic_link_flags [get_multilibs]]"
-+	}
-+    } else {
-+        set maybe_atomic_lib ""
-+    }
-+  set t [get_multilibs]
-+  puts "maybe al $maybe_atomic_lib ml $t"
-+} else {
-+    set maybe_atomic_lib ""
- }
- 
- # Main loop.
-diff --git a/gcc/testsuite/gfortran.dg/dg.exp b/gcc/testsuite/gfortran.dg/dg.exp
-index bd7ad95ad0d..36fc2972b2e 100644
---- a/gcc/testsuite/gfortran.dg/dg.exp
-+++ b/gcc/testsuite/gfortran.dg/dg.exp
-@@ -18,6 +18,7 @@
+ #if HAVE_DLFCN_H
+@@ -10907,7 +10957,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 10910 "configure"
++#line 10960 "configure"
+ #include "confdefs.h"
  
- # Load support procs.
- load_lib gfortran-dg.exp
-+load_lib atomic-dg.exp
+ #if HAVE_DLFCN_H
+@@ -12189,6 +12239,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+       darwin* | rhapsody*)
  
- # If a testcase doesn't have special options, use these.
- global DEFAULT_FFLAGS
-@@ -53,12 +54,30 @@ proc dg-compile-aux-modules { args } {
-     }
- }
  
-+# coarray tests might need libatomic.  Assume that it is either not needed or
-+# provided by builtins if it's not available.
-+if [check_effective_target_libatomic_available] {
-+    if ![is_remote host] {
-+	if [info exists TOOL_OPTIONS] {
-+	    set maybe_atomic_lib "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]"
-+	} else {
-+	    set maybe_atomic_lib "[atomic_link_flags [get_multilibs]]"
-+	}
-+    } else {
-+        set maybe_atomic_lib ""
-+    }
-+  set t [get_multilibs]
-+  puts "dg set al $maybe_atomic_lib ml $t"
-+}
 +
-+puts "DEFAULT_FFLAGS $DEFAULT_FFLAGS"
++  # Publish an arg to allow the user to select that Darwin host (and target)
++  # libraries should be given install-names like @rpath/libfoo.dylib.  This
++  # requires that the user of the library then adds an 'rpath' to the DSO that
++  # needs access.
++  # NOTE: there are defaults below, for systems that support rpaths.  The person
++  # configuring can override the defaults for any system version that supports
++  # them - they are, however, forced off for system versions without support.
++  # Check whether --enable-darwin-at-rpath was given.
++if test "${enable_darwin_at_rpath+set}" = set; then :
++  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
++    # This is not supported before macOS 10.5 / Darwin9.
++    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
++	enable_darwin_at_rpath=no
++      ;;
++    esac
++   fi
++else
++  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
++    # As above, before 10.5 / Darwin9 this does not work.
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++       enable_darwin_at_rpath=no
++       ;;
 +
- # Main loop.
- gfortran-dg-runtest [lsort \
--       [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $DEFAULT_FFLAGS
-+       [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] $maybe_atomic_lib $DEFAULT_FFLAGS
- 
- gfortran-dg-runtest [lsort \
--       [glob -nocomplain $srcdir/$subdir/g77/*.\[fF\] ] ] "" $DEFAULT_FFLAGS
-+       [glob -nocomplain $srcdir/$subdir/g77/*.\[fF\] ] ] $maybe_atomic_lib $DEFAULT_FFLAGS
- 
- 
- # All done.
-diff --git a/gcc/testsuite/gfortran.dg/pr95690.f90 b/gcc/testsuite/gfortran.dg/pr95690.f90
-index 47a5df9e894..1afa9d3c467 100644
---- a/gcc/testsuite/gfortran.dg/pr95690.f90
-+++ b/gcc/testsuite/gfortran.dg/pr95690.f90
-@@ -2,8 +2,8 @@
- module m
- contains
-    subroutine s
--      print *, (erfc) ! { dg-error "not a floating constant" "" { target i?86-*-* x86_64-*-* sparc*-*-* cris-*-* } }
--   end ! { dg-error "not a floating constant" "" { target { ! "i?86-*-* x86_64-*-* sparc*-*-* cris-*-*" } } }
-+      print *, (erfc) ! { dg-error "not a floating constant" "" { target i?86-*-* x86_64-*-* sparc*-*-* cris-*-* aarch64-apple-darwin* } }
-+   end ! { dg-error "not a floating constant" "" { target { ! "i?86-*-* x86_64-*-* sparc*-*-* cris-*-* aarch64-apple-darwin*" } } }
-    function erfc()
-    end
- end
-diff --git a/gcc/testsuite/lib/asan-dg.exp b/gcc/testsuite/lib/asan-dg.exp
-index 7e0f85dc9b0..88c6ece8caa 100644
---- a/gcc/testsuite/lib/asan-dg.exp
-+++ b/gcc/testsuite/lib/asan-dg.exp
-@@ -78,7 +78,7 @@ proc asan_link_flags_1 { paths lib } {
- 	   || [file exists "${gccpath}/libsanitizer/${lib}/.libs/lib${lib}.${shlib_ext}"] } {
- 	  append flags " -B${gccpath}/libsanitizer/ "
- 	  append flags " -B${gccpath}/libsanitizer/${lib}/ "
--	  append flags " -L${gccpath}/libsanitizer/${lib}/.libs "
-+	  append flags " -B${gccpath}/libsanitizer/${lib}/.libs "
- 	  append ld_library_path ":${gccpath}/libsanitizer/${lib}/.libs"
-       }
-     } else {
-diff --git a/gcc/testsuite/lib/atomic-dg.exp b/gcc/testsuite/lib/atomic-dg.exp
-index 86dcfa674ea..c9244fb6cac 100644
---- a/gcc/testsuite/lib/atomic-dg.exp
-+++ b/gcc/testsuite/lib/atomic-dg.exp
-@@ -33,7 +33,7 @@ proc atomic_link_flags { paths } {
-       if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"]
- 	   || [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } {
- 	  append flags " -B${gccpath}/libatomic/ "
--	  append flags " -L${gccpath}/libatomic/.libs"
-+	  append flags " -B${gccpath}/libatomic/.libs"
- 	  append ld_library_path ":${gccpath}/libatomic/.libs"
-       }
-     } else {
-diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp
-index a80630bb2a8..195611f1f72 100644
---- a/gcc/testsuite/lib/scanasm.exp
-+++ b/gcc/testsuite/lib/scanasm.exp
-@@ -763,7 +763,7 @@ proc scan-lto-assembler { args } {
- # to function bodies in array RESULT.  FILENAME has already been uploaded
- # locally where necessary and is known to exist.
- 
--proc parse_function_bodies { filename result } {
-+proc parse_ELF_function_bodies { filename result } {
-     upvar $result up_result
- 
-     # Regexp for the start of a function definition (name in \1).
-@@ -793,6 +793,44 @@ proc parse_function_bodies { filename result } {
-     close $fd
- }
- 
-+proc parse_MACHO_function_bodies { filename result } {
-+    upvar $result up_result
-+
-+    # Regexp for the start of a function definition (name in \1).
-+    set label {^(_[a-zA-Z_]\S+):$}
-+    set start {^LFB[0-9]+}
-+
-+    # Regexp for the end of a function definition.
-+    set terminator {^LFE[0-9]+}
-+
-+    # Regexp for lines that aren't interesting.
-+    set fluff {^\s*(?:\.|//|@)}
-+    set fluff3 {^L[0-9ACESV]}
-+
-+    set fd [open $filename r]
-+    set in_function 0
-+    while { [gets $fd line] >= 0 } {
-+	if { !$in_function && [regexp $label $line dummy function_name] } {
-+	    set in_function 1
-+	    set function_body ""
-+	} elseif { $in_function == 1 } {
-+	  if { [regexp $start $line] } {
-+	    set in_function 2
-+	  } else {
-+	    set in_function 0
-+	  }
-+	} elseif { $in_function == 2 } {
-+	    if { [regexp $terminator $line] } {
-+		set up_result($function_name) $function_body
-+		set in_function 0
-+	    } elseif { ![regexp $fluff $line]  && ![regexp $fluff3 $line] } {
-+		append function_body $line "\n"
-+	    }
-+	}
-+    }
-+    close $fd
-+}
++    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
++    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
++    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
++      enable_darwin_at_rpath=yes
++      ;;
++    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
++    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
 +
- # FUNCTIONS is an array that maps function names to function bodies.
- # Return true if it contains a definition of function NAME and if
- # that definition matches BODY_REGEXP.
-@@ -820,6 +858,14 @@ proc check-function-bodies { args } {
- 	error "too many arguments to check-function-bodies"
-     }
- 
-+    set isELF 1
-+    # some targets have a __USER_LABEL_PREFIX__
-+    set needsULP 0
-+    if { [istarget *-*-darwin*] } {
-+      set isELF 0
-+      set needsULP 1
-+    }
++    esac
 +
-     if { [llength $args] >= 3 } {
- 	set required_flags [lindex $args 2]
- 
-@@ -876,7 +922,11 @@ proc check-function-bodies { args } {
- 	remote_upload host "$filename"
-     }
-     if { [file exists $output_filename] } {
--	parse_function_bodies $output_filename functions
-+        if { $isELF } {
-+	    parse_ELF_function_bodies $output_filename functions
-+	} else {
-+	    parse_MACHO_function_bodies $output_filename functions
-+	}
- 	set have_bodies 1
-     } else {
- 	verbose -log "$testcase: output file does not exist"
-@@ -921,6 +971,9 @@ proc check-function-bodies { args } {
- 		if { $xfail_all || [string equal $selector "F"] } {
- 		    setup_xfail "*-*-*"
- 		}
-+		if { $needsULP } {
-+		    set function_name "_$function_name"
-+		}
- 		set testname "$testcase check-function-bodies $function_name"
- 		if { !$have_bodies } {
- 		    unresolved $testname
-diff --git a/gcc/testsuite/lib/target-libpath.exp b/gcc/testsuite/lib/target-libpath.exp
-index d09cd515d20..280ce390845 100644
---- a/gcc/testsuite/lib/target-libpath.exp
-+++ b/gcc/testsuite/lib/target-libpath.exp
-@@ -67,6 +67,7 @@ proc set_ld_library_path_env_vars { } {
-   global orig_dyld_library_path
-   global orig_path
-   global orig_gcc_exec_prefix
-+  global ENABLE_DARWIN_AT_RPATH
-   global env
- 
-   # Save the original GCC_EXEC_PREFIX.
-@@ -133,6 +134,7 @@ proc set_ld_library_path_env_vars { } {
-   #
-   # Doing this is somewhat of a hack as ld_library_path gets repeated in
-   # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
-+  if { ![istarget *-*-darwin*] } {
-   if { $orig_ld_library_path_saved } {
-     setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
-   } else {
-@@ -166,11 +168,23 @@ proc set_ld_library_path_env_vars { } {
-   } else {
-     setenv LD_LIBRARY_PATH_64 "$ld_library_path"
-   }
--  if { $orig_dyld_library_path_saved } {
--    setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
--  } else {
--    setenv DYLD_LIBRARY_PATH "$ld_library_path"
-   }
-+  if { [istarget *-*-darwin*] } {
-+    if { [info exists ENABLE_DARWIN_AT_RPATH] || [istarget *-*-darwin1\[5-9\]*]
-+         || [istarget *-*-darwin2*] } {
-+      # Either we are not using DYLD_LIBRARY_PATH or we're on a version of the
-+      # OS for which it is not passed through system exes.
-+      if [info exists env(DYLD_LIBRARY_PATH)] {
-+        unsetenv DYLD_LIBRARY_PATH
-+      }
-+    } else {
-+      if { $orig_dyld_library_path_saved } {
-+        setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
-+      } else {
-+        setenv DYLD_LIBRARY_PATH "$ld_library_path"
-+      }
-+    }
-+  } 
-   if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
-     if { $orig_path_saved } {
-       setenv PATH "$ld_library_path:$orig_path"
-@@ -179,6 +193,7 @@ proc set_ld_library_path_env_vars { } {
-     }
-   }
- 
-+  verbose -log "set paths"
-   verbose -log "LD_LIBRARY_PATH=[getenv LD_LIBRARY_PATH]"
-   verbose -log "LD_RUN_PATH=[getenv LD_RUN_PATH]"
-   verbose -log "SHLIB_PATH=[getenv SHLIB_PATH]"
-diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
-index 244fe2306f4..75581914d6c 100644
---- a/gcc/testsuite/lib/target-supports.exp
-+++ b/gcc/testsuite/lib/target-supports.exp
-@@ -8485,7 +8485,7 @@ proc check_effective_target_section_anchors { } {
-     return [check_cached_effective_target section_anchors {
-       expr { [istarget powerpc*-*-*]
- 	     || [istarget arm*-*-*]
--	     || [istarget aarch64*-*-*] }}]
-+	     || ([istarget aarch64*-*-*] && ![istarget aarch64*-*-darwin*]) }}]
- }
++fi
++
++
+   archive_cmds_need_lc_CXX=no
+   hardcode_direct_CXX=no
+   hardcode_automatic_CXX=yes
+@@ -12206,12 +12299,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+   esac
+   if test "$_lt_dar_can_shared" = "yes"; then
+     output_verbose_link_cmd=func_echo_all
+-    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
++    if test "x$enable_darwin_at_rpath" = "xyes"; then
++      _lt_install_name='@rpath/\$soname'
++    fi
++    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+        if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+-      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++      _lt_install_name='\$rpath/\$soname'
++      if test "x$enable_darwin_at_rpath" = "xyes"; then
++        _lt_install_name='@rpath/\$soname'
++      fi
++      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring${_lt_dsymutil}"
+       archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+     fi
  
- # Return 1 if the target supports atomic operations on "int_128" values.
-@@ -11526,6 +11526,15 @@ proc check_effective_target_arm_thumb2_ok_no_arm_v8_1_lob { } {
-     return 0
- }
+diff --git a/libcody/Makefile.in b/libcody/Makefile.in
+index bb87468cb9a..cb01b0092d8 100644
+--- a/libcody/Makefile.in
++++ b/libcody/Makefile.in
+@@ -31,7 +31,7 @@ endif
+ CXXOPTS += $(filter-out -DHAVE_CONFIG_H,@DEFS@) -include config.h
+ 
+ # Linker options
+-LDFLAGS := @LDFLAGS@
++LDFLAGS := @LDFLAGS@ @LD_PICFLAG@
+ LIBS := @LIBS@
+ 
+ # Per-source & per-directory compile flags (warning: recursive)
+diff --git a/libcody/configure b/libcody/configure
+index da52a5cfca5..0e536c0ccb0 100755
+--- a/libcody/configure
++++ b/libcody/configure
+@@ -591,7 +591,10 @@ configure_args
+ AR
+ RANLIB
+ EXCEPTIONS
++LD_PICFLAG
+ PICFLAG
++enable_host_pie
++enable_host_shared
+ OBJEXT
+ EXEEXT
+ ac_ct_CXX
+@@ -653,6 +656,7 @@ enable_maintainer_mode
+ with_compiler
+ enable_checking
+ enable_host_shared
++enable_host_pie
+ enable_exceptions
+ '
+       ac_precious_vars='build_alias
+@@ -1286,6 +1290,7 @@ Optional Features:
+                           yes,no,all,none,release. Flags are: misc,valgrind or
+                           other strings
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
+   --enable-exceptions     enable exceptions & rtti
  
-+# Return 1 if this is an ARM target where -mabi=ilp32 can be used.
+ Optional Packages:
+@@ -2635,11 +2640,34 @@ fi
+ # Enable --enable-host-shared.
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
++  enableval=$enable_host_shared;
++fi
 +
-+proc check_effective_target_arm_mabi_ilp32 { } {
-+  return [check_no_compiler_messages_nocache arm_mabi_ilp32 assembly {
-+     int main() { return 0; }
-+  } "-mabi=ilp32"]
-+}
 +
 +
- # Returns 1 if the target is using glibc, 0 otherwise.
- 
- proc check_effective_target_glibc { } {
-diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-class-meta.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-class-meta.mm
-index 92852c3ecea..e0974539ecf 100644
---- a/gcc/testsuite/obj-c++.dg/gnu-api-2-class-meta.mm
-+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-class-meta.mm
-@@ -19,6 +19,7 @@ this behavior may be defined or documented (for example, if class
- 
- /* { dg-do run } */
- /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
-+/* { dg-skip-if "API unsupported" { arm64*-*-darwin* aarch64*-*-darwin* } { "-fnext-runtime" } { "" } } */
- /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
- /* { dg-additional-options "-DOBJC_OLD_DISPATCH_PROTOTYPES" { target { *-*-darwin* } } } */
- // { dg-additional-options "-Wno-objc-root-class" }
-diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm
-index f6e3d8d22e0..a23968a89b5 100644
---- a/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm
-+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm
-@@ -6,6 +6,7 @@
- 
- /* { dg-do run } */
- /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
-+/* { dg-skip-if "API unsupported" { arm64*-*-darwin* aarch64*-*-darwin* } { "-fnext-runtime" } { "" } } */
- /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
- /* { dg-additional-options "-DOBJC_OLD_DISPATCH_PROTOTYPES" { target { *-*-darwin* } } } */
- // { dg-additional-options "-Wno-objc-root-class" }
-diff --git a/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-4.mm b/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-4.mm
-index 1155db5f83f..e0dd8062373 100644
---- a/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-4.mm
-+++ b/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-4.mm
-@@ -18,4 +18,4 @@
- 
- /* { dg-final { scan-assembler ".section __DATA, __cfstring" } } */
- /* { dg-final { scan-assembler ".long\t___CFConstantStringClassReference\n\t.long\t1992\n\t.long\t.*\n\t.long\t19\n" { target { *-*-darwin* && { ! lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t19\n" { target { *-*-darwin* && {  lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t___CFConstantStringClassReference\n\t.(long|word)\t1992\n\t.space 4\n\t.(quad|xword)\t.*\n\t.(quad|xword)\t19\n} { target { *-*-darwin* && {  lp64 } } } } } */
-diff --git a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-10.mm b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-10.mm
-index e1dad124cd6..eb89710d890 100644
---- a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-10.mm
-+++ b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-10.mm
-@@ -33,4 +33,4 @@ @interface NSConstantString : NSSimpleCString
- /* { dg-final { scan-assembler ".section __OBJC, __cstring_object" { target { *-*-darwin* && { ! lp64 } } } } } */
- /* { dg-final { scan-assembler ".section __DATA, __objc_stringobj" { target { *-*-darwin* && { lp64 } } } } } */
- /* { dg-final { scan-assembler ".long\t__NSConstantStringClassReference\n\t.long\t.*\n\t.long\t5\n\t.data" { target { *-*-darwin* && { ! lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t_OBJC_CLASS_._NSConstantString\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t_OBJC_CLASS_._NSConstantString\n\t.(quad|xword)\t.*\n\t.(long|word)\t5\n\t.space} { target { *-*-darwin* && { lp64 } } } } } */
-diff --git a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-11.mm b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-11.mm
-index 30a9228a64e..c1b58dc6cb8 100644
---- a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-11.mm
-+++ b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-11.mm
-@@ -33,4 +33,4 @@ @interface XStr : XString {
- /* { dg-final { scan-assembler ".section __OBJC, __cstring_object" { target { *-*-darwin* && { ! lp64 } } } } } */
- /* { dg-final { scan-assembler ".section __DATA, __objc_stringobj" { target { *-*-darwin* && { lp64 } } } } } */
- /* { dg-final { scan-assembler ".long\t__XStrClassReference\n\t.long\t.*\n\t.long\t5\n\t.data"  { target { *-*-darwin* && { ! lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t_OBJC_CLASS_._XStr\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t_OBJC_CLASS_._XStr\n\t.(quad|xword)\t.*\n\t.(long|word)\t5\n\t.space} { target { *-*-darwin* && { lp64 } } } } } */
-diff --git a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-9.mm b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-9.mm
-index a1a14295e90..8457f46be53 100644
---- a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-9.mm
-+++ b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-9.mm
-@@ -25,4 +25,4 @@ @interface NSConstantString: NSObject {
- /* { dg-final { scan-assembler ".section __OBJC, __cstring_object" { target { *-*-darwin* && { ! lp64 } } } } } */
- /* { dg-final { scan-assembler ".section __DATA, __objc_stringobj" { target { *-*-darwin* && { lp64 } } } } } */
- /* { dg-final { scan-assembler ".long\t__NSConstantStringClassReference\n\t.long\t.*\n\t.long\t5\n\t.data" { target { *-*-darwin* && { ! lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t_OBJC_CLASS_._NSConstantString\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t_OBJC_CLASS_._NSConstantString\n\t.(quad|xword)\t.*\n\t.(long|word)\t5\n\t.space} { target { *-*-darwin* && { lp64 } } } } } */
-diff --git a/gcc/testsuite/objc.dg/gnu-api-2-class-meta.m b/gcc/testsuite/objc.dg/gnu-api-2-class-meta.m
-index 6c1c76a87a3..41a48f9c685 100644
---- a/gcc/testsuite/objc.dg/gnu-api-2-class-meta.m
-+++ b/gcc/testsuite/objc.dg/gnu-api-2-class-meta.m
-@@ -19,6 +19,7 @@ this behavior may be defined or documented (for example, if class
- 
- /* { dg-do run } */
- /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
-+/* { dg-skip-if "API unsupported" { arm64*-*-darwin* aarch64*-*-darwin* } { "-fnext-runtime" } { "" } } */
- /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
- /* { dg-additional-options "-Wno-objc-root-class" } */
- /* { dg-additional-options "-DOBJC_OLD_DISPATCH_PROTOTYPES" { target { *-*-darwin* } } } */
-diff --git a/gcc/testsuite/objc.dg/gnu-api-2-class.m b/gcc/testsuite/objc.dg/gnu-api-2-class.m
-index d11dae0e6dc..1386ebc2f99 100644
---- a/gcc/testsuite/objc.dg/gnu-api-2-class.m
-+++ b/gcc/testsuite/objc.dg/gnu-api-2-class.m
-@@ -6,6 +6,7 @@
- 
- /* { dg-do run } */
- /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
-+/* { dg-skip-if "API unsupported" { arm64*-*-darwin* aarch64*-*-darwin* } { "-fnext-runtime" } { "" } } */
- /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
- /* { dg-additional-options "-Wno-objc-root-class" } */
- /* { dg-additional-options "-DOBJC_OLD_DISPATCH_PROTOTYPES" { target { *-*-darwin* } } } */
-diff --git a/gcc/testsuite/objc.dg/torture/strings/const-cfstring-4.m b/gcc/testsuite/objc.dg/torture/strings/const-cfstring-4.m
-index 1155db5f83f..e0dd8062373 100644
---- a/gcc/testsuite/objc.dg/torture/strings/const-cfstring-4.m
-+++ b/gcc/testsuite/objc.dg/torture/strings/const-cfstring-4.m
-@@ -18,4 +18,4 @@
- 
- /* { dg-final { scan-assembler ".section __DATA, __cfstring" } } */
- /* { dg-final { scan-assembler ".long\t___CFConstantStringClassReference\n\t.long\t1992\n\t.long\t.*\n\t.long\t19\n" { target { *-*-darwin* && { ! lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t19\n" { target { *-*-darwin* && {  lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t___CFConstantStringClassReference\n\t.(long|word)\t1992\n\t.space 4\n\t.(quad|xword)\t.*\n\t.(quad|xword)\t19\n} { target { *-*-darwin* && {  lp64 } } } } } */
-diff --git a/gcc/testsuite/objc.dg/torture/strings/const-str-10.m b/gcc/testsuite/objc.dg/torture/strings/const-str-10.m
-index 6565dc20007..81b0d326c56 100644
---- a/gcc/testsuite/objc.dg/torture/strings/const-str-10.m
-+++ b/gcc/testsuite/objc.dg/torture/strings/const-str-10.m
-@@ -34,4 +34,4 @@ @interface NSConstantString : NSSimpleCString
- /* { dg-final { scan-assembler ".section __OBJC, __cstring_object" { target { *-*-darwin* && { ! lp64 } } } } } */
- /* { dg-final { scan-assembler ".section __DATA, __objc_stringobj" { target { *-*-darwin* && { lp64 } } } } } */
- /* { dg-final { scan-assembler ".long\t__NSConstantStringClassReference\n\t.long\t.*\n\t.long\t5\n\t.data" { target { *-*-darwin* && { ! lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t_OBJC_CLASS_._NSConstantString\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t_OBJC_CLASS_._NSConstantString\n\t.(quad|xword)\t.*\n\t.(long|word)\t5\n\t.space} { target { *-*-darwin* && { lp64 } } } } } */
-diff --git a/gcc/testsuite/objc.dg/torture/strings/const-str-11.m b/gcc/testsuite/objc.dg/torture/strings/const-str-11.m
-index 2bdb1531e1d..b044b0fd8c7 100644
---- a/gcc/testsuite/objc.dg/torture/strings/const-str-11.m
-+++ b/gcc/testsuite/objc.dg/torture/strings/const-str-11.m
-@@ -33,4 +33,4 @@ @interface XStr : XString {
- /* { dg-final { scan-assembler ".section __OBJC, __cstring_object" { target { *-*-darwin* && { ! lp64 } } } } } */
- /* { dg-final { scan-assembler ".section __DATA, __objc_stringobj" { target { *-*-darwin* && { lp64 } } } } } */
- /* { dg-final { scan-assembler ".long\t__XStrClassReference\n\t.long\t.*\n\t.long\t5\n\t.data"  { target { *-*-darwin* && { ! lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t_OBJC_CLASS_._XStr\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t_OBJC_CLASS_._XStr\n\t.(quad|xword)\t.*\n\t.(long|word)\t5\n\t.space} { target { *-*-darwin* && { lp64 } } } } } */
-diff --git a/gcc/testsuite/objc.dg/torture/strings/const-str-9.m b/gcc/testsuite/objc.dg/torture/strings/const-str-9.m
-index 966ea5e498d..d3d2916ed06 100644
---- a/gcc/testsuite/objc.dg/torture/strings/const-str-9.m
-+++ b/gcc/testsuite/objc.dg/torture/strings/const-str-9.m
-@@ -25,4 +25,4 @@ @interface NSConstantString: NSObject {
- /* { dg-final { scan-assembler ".section __OBJC, __cstring_object" { target { *-*-darwin* && { ! lp64 } } } } } */
- /* { dg-final { scan-assembler ".section __DATA, __objc_stringobj" { target { *-*-darwin* && { lp64 } } } } } */
- /* { dg-final { scan-assembler ".long\t__NSConstantStringClassReference\n\t.long\t.*\n\t.long\t5\n\t.data" { target { *-*-darwin* && { ! lp64 } } } } } */
--/* { dg-final { scan-assembler ".quad\t_OBJC_CLASS_._NSConstantString\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */
-+/* { dg-final { scan-assembler {.(quad|xword)\t_OBJC_CLASS_._NSConstantString\n\t.(quad|xword)\t.*\n\t.(long|word)\t5\n\t.space} { target { *-*-darwin* && { lp64 } } } } } */
-diff --git a/gcc/tree-nested.cc b/gcc/tree-nested.cc
-index 078ceab3ca3..0308f558036 100644
---- a/gcc/tree-nested.cc
-+++ b/gcc/tree-nested.cc
-@@ -611,6 +611,14 @@ get_trampoline_type (struct nesting_info *info)
-   if (trampoline_type)
-     return trampoline_type;
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
++
++
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
+ else
+   PICFLAG=
+ fi
  
-+  /* When trampolines are created off-stack then the only thing we need in the
-+     local frame is a single pointer.  */
-+  if (flag_off_stack_trampolines)
-+    {
-+      trampoline_type = build_pointer_type (void_type_node);
-+      return trampoline_type;
-+    }
++if test x$enable_host_pie = xyes; then
++  LD_PICFLAG=-pie
++else
++  LD_PICFLAG=
++fi
++
 +
-   align = TRAMPOLINE_ALIGNMENT;
-   size = TRAMPOLINE_SIZE;
  
-@@ -2786,17 +2794,27 @@ convert_tramp_reference_op (tree *tp, int *walk_subtrees, void *data)
  
-       /* Compute the address of the field holding the trampoline.  */
-       x = get_frame_field (info, target_context, x, &wi->gsi);
--      x = build_addr (x);
--      x = gsi_gimplify_val (info, x, &wi->gsi);
+ # Check whether --enable-exceptions was given.
+diff --git a/libcody/configure.ac b/libcody/configure.ac
+index 960191ecb72..14e8dd4a226 100644
+--- a/libcody/configure.ac
++++ b/libcody/configure.ac
+@@ -63,9 +63,31 @@ fi
+ # Enable --enable-host-shared.
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
++		[build host code as shared libraries])])
++AC_SUBST(enable_host_shared)
++
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])])
++AC_SUBST(enable_host_pie)
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
++
++if test x$enable_host_pie = xyes; then
++  LD_PICFLAG=-pie
++else
++  LD_PICFLAG=
++fi
++
+ AC_SUBST(PICFLAG)
++AC_SUBST(LD_PICFLAG)
  
--      /* Do machine-specific ugliness.  Normally this will involve
--	 computing extra alignment, but it can really be anything.  */
--      if (descr)
--	builtin = builtin_decl_implicit (BUILT_IN_ADJUST_DESCRIPTOR);
-+      /* APB: We don't need to do the adjustment calls when using off-stack
-+	 trampolines, any such adjustment will be done when the off-stack
-+	 trampoline is created.  */
-+      if (!descr && flag_off_stack_trampolines)
-+	x = gsi_gimplify_val (info, x, &wi->gsi);
-       else
--	builtin = builtin_decl_implicit (BUILT_IN_ADJUST_TRAMPOLINE);
--      call = gimple_build_call (builtin, 1, x);
--      x = init_tmp_var_with_call (info, &wi->gsi, call);
-+	{
-+	  x = build_addr (x);
+ NMS_ENABLE_EXCEPTIONS
+ 
+diff --git a/libcpp/configure b/libcpp/configure
+index e9937cde330..1389ddab544 100755
+--- a/libcpp/configure
++++ b/libcpp/configure
+@@ -625,6 +625,8 @@ ac_includes_default="\
+ ac_subst_vars='LTLIBOBJS
+ CET_HOST_FLAGS
+ PICFLAG
++enable_host_pie
++enable_host_shared
+ MAINT
+ USED_CATALOGS
+ PACKAGE
+@@ -738,6 +740,7 @@ enable_maintainer_mode
+ enable_checking
+ enable_canonical_system_headers
+ enable_host_shared
++enable_host_pie
+ enable_cet
+ enable_valgrind_annotations
+ '
+@@ -1379,6 +1382,7 @@ Optional Features:
+   --enable-canonical-system-headers
+                           enable or disable system headers canonicalization
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
+   --enable-cet            enable Intel CET in host libraries [default=auto]
+   --enable-valgrind-annotations
+                           enable valgrind runtime interaction
+@@ -7605,7 +7609,23 @@ esac
+ # Enable --enable-host-shared.
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
++  enableval=$enable_host_shared;
++fi
 +
-+	  x = gsi_gimplify_val (info, x, &wi->gsi);
 +
-+	  /* Do machine-specific ugliness.  Normally this will involve
-+	     computing extra alignment, but it can really be anything.  */
-+	  if (descr)
-+	    builtin = builtin_decl_implicit (BUILT_IN_ADJUST_DESCRIPTOR);
-+	  else
-+	    builtin = builtin_decl_implicit (BUILT_IN_ADJUST_TRAMPOLINE);
-+	  call = gimple_build_call (builtin, 1, x);
-+	  x = init_tmp_var_with_call (info, &wi->gsi, call);
-+	}
- 
-       /* Cast back to the proper function type.  */
-       x = build1 (NOP_EXPR, TREE_TYPE (t), x);
-@@ -3375,6 +3393,7 @@ build_init_call_stmt (struct nesting_info *info, tree decl, tree field,
- static void
- finalize_nesting_tree_1 (struct nesting_info *root)
- {
-+  gimple_seq cleanup_list = NULL;
-   gimple_seq stmt_list = NULL;
-   gimple *stmt;
-   tree context = root->context;
-@@ -3506,9 +3525,48 @@ finalize_nesting_tree_1 (struct nesting_info *root)
- 	  if (!field)
- 	    continue;
- 
--	  x = builtin_decl_implicit (BUILT_IN_INIT_TRAMPOLINE);
--	  stmt = build_init_call_stmt (root, i->context, field, x);
--	  gimple_seq_add_stmt (&stmt_list, stmt);
-+	  if (flag_off_stack_trampolines)
-+	    {
-+	      /* We pass a whole bunch of arguments to the builtin function that
-+		 creates the off-stack trampoline, these are
-+		 1. The nested function chain value (that must be passed to the
-+		 nested function so it can find the function arguments).
-+		 2. A pointer to the nested function implementation,
-+		 3. The address in the local stack frame where we should write
-+		 the address of the trampoline.
 +
-+		 When this code was originally written I just kind of threw
-+		 everything at the builtin, figuring I'd work out what was
-+		 actually needed later, I think, the stack pointer could
-+		 certainly be dropped, arguments #2 and #4 are based off the
-+		 stack pointer anyway, so #1 doesn't seem to add much value.  */
-+	      tree arg1, arg2, arg3;
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
 +
-+	      gcc_assert (DECL_STATIC_CHAIN (i->context));
-+	      arg1 = build_addr (root->frame_decl);
-+	      arg2 = build_addr (i->context);
 +
-+	      x = build3 (COMPONENT_REF, TREE_TYPE (field),
-+			  root->frame_decl, field, NULL_TREE);
-+	      arg3 = build_addr (x);
 +
-+	      x = builtin_decl_implicit (BUILT_IN_NESTED_PTR_CREATED);
-+	      stmt = gimple_build_call (x, 3, arg1, arg2, arg3);
-+	      gimple_seq_add_stmt (&stmt_list, stmt);
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
+ else
+   PICFLAG=
+ fi
+diff --git a/libcpp/configure.ac b/libcpp/configure.ac
+index 89ac99b04bd..b29b4d6acf1 100644
+--- a/libcpp/configure.ac
++++ b/libcpp/configure.ac
+@@ -211,8 +211,23 @@ esac
+ # Enable --enable-host-shared.
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
++		[build host code as shared libraries])])
++AC_SUBST(enable_host_shared)
++
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])])
++AC_SUBST(enable_host_pie)
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
 +
-+	      /* This call to delete the nested function trampoline is added to
-+		 the cleanup list, and called when we exit the current scope.  */
-+	      x = builtin_decl_implicit (BUILT_IN_NESTED_PTR_DELETED);
-+	      stmt = gimple_build_call (x, 0);
-+	      gimple_seq_add_stmt (&cleanup_list, stmt);
-+	    }
-+	  else
-+	    {
-+	      /* Original code to initialise the on stack trampoline.  */
-+	      x = builtin_decl_implicit (BUILT_IN_INIT_TRAMPOLINE);
-+	      stmt = build_init_call_stmt (root, i->context, field, x);
-+	      gimple_seq_add_stmt (&stmt_list, stmt);
-+	    }
- 	}
-     }
+ AC_SUBST(PICFLAG)
  
-@@ -3533,11 +3591,40 @@ finalize_nesting_tree_1 (struct nesting_info *root)
-   /* If we created initialization statements, insert them.  */
-   if (stmt_list)
-     {
--      gbind *bind;
--      annotate_all_with_location (stmt_list, DECL_SOURCE_LOCATION (context));
--      bind = gimple_seq_first_stmt_as_a_bind (gimple_body (context));
--      gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind));
--      gimple_bind_set_body (bind, stmt_list);
-+      if (flag_off_stack_trampolines)
-+	{
-+	  /* Handle the new, off stack trampolines.  */
-+	  gbind *bind;
-+	  annotate_all_with_location (stmt_list, DECL_SOURCE_LOCATION (context));
-+	  annotate_all_with_location (cleanup_list, DECL_SOURCE_LOCATION (context));
-+	  bind = gimple_seq_first_stmt_as_a_bind (gimple_body (context));
-+	  gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind));
+ # Enable Intel CET on Intel CET enabled host if jit is enabled.
+diff --git a/libdecnumber/configure b/libdecnumber/configure
+index fb6db05565a..84bc4ffc767 100755
+--- a/libdecnumber/configure
++++ b/libdecnumber/configure
+@@ -626,6 +626,8 @@ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
+ CET_HOST_FLAGS
+ PICFLAG
++enable_host_pie
++enable_host_shared
+ ADDITIONAL_OBJS
+ enable_decimal_float
+ target_os
+@@ -706,6 +708,7 @@ enable_werror_always
+ enable_maintainer_mode
+ enable_decimal_float
+ enable_host_shared
++enable_host_pie
+ enable_cet
+ '
+       ac_precious_vars='build_alias
+@@ -1338,6 +1341,7 @@ Optional Features:
+ 			or 'dpd' choses which decimal floating point format
+ 			to use
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
+   --enable-cet            enable Intel CET in host libraries [default=auto]
+ 
+ Some influential environment variables:
+@@ -5186,7 +5190,23 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
+ # Enable --enable-host-shared.
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
++  enableval=$enable_host_shared;
++fi
 +
-+	  gimple_seq xxx_list = NULL;
 +
-+	  if (cleanup_list != NULL)
-+	    {
-+	      /* We Maybe shouldn't be creating this try/finally if -fno-exceptions is
-+		 in use.  If this is the case, then maybe we should, instead, be
-+		 inserting the cleanup code onto every path out of this function?  Not
-+		 yet figured out how we would do this.  */
-+	      gtry *t = gimple_build_try (stmt_list, cleanup_list, GIMPLE_TRY_FINALLY);
-+	      gimple_seq_add_stmt (&xxx_list, t);
-+	    }
-+	  else
-+	    xxx_list = stmt_list;
 +
-+	  gimple_bind_set_body (bind, xxx_list);
-+	}
-+      else
-+	{
-+	  /* The traditional, on stack trampolines.  */
-+	  gbind *bind;
-+	  annotate_all_with_location (stmt_list, DECL_SOURCE_LOCATION (context));
-+	  bind = gimple_seq_first_stmt_as_a_bind (gimple_body (context));
-+	  gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind));
-+	  gimple_bind_set_body (bind, stmt_list);
-+	}
-     }
- 
-   /* If a chain_decl was created, then it needs to be registered with
-diff --git a/gcc/tree.cc b/gcc/tree.cc
-index 4cf3785270b..5cba2ab8171 100644
---- a/gcc/tree.cc
-+++ b/gcc/tree.cc
-@@ -9766,6 +9766,23 @@ build_common_builtin_nodes (void)
- 			"__builtin_nonlocal_goto",
- 			ECF_NORETURN | ECF_NOTHROW);
- 
-+  tree ptr_ptr_type_node = build_pointer_type (ptr_type_node);
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
 +
-+  ftype = build_function_type_list (void_type_node,
-+				    ptr_type_node, // void *chain
-+				    ptr_type_node, // void *func
-+				    ptr_ptr_type_node, // void **dst
-+				    NULL_TREE);
-+  local_define_builtin ("__builtin_nested_func_ptr_created", ftype,
-+			BUILT_IN_NESTED_PTR_CREATED,
-+			"__builtin_nested_func_ptr_created", ECF_NOTHROW);
 +
-+  ftype = build_function_type_list (void_type_node,
-+				    NULL_TREE);
-+  local_define_builtin ("__builtin_nested_func_ptr_deleted", ftype,
-+			BUILT_IN_NESTED_PTR_DELETED,
-+			"__builtin_nested_func_ptr_deleted", ECF_NOTHROW);
 +
-   ftype = build_function_type_list (void_type_node,
- 				    ptr_type_node, ptr_type_node, NULL_TREE);
-   local_define_builtin ("__builtin_setjmp_setup", ftype,
-diff --git a/libada/configure b/libada/configure
-index 162d9731f26..9c8b133d817 100755
---- a/libada/configure
-+++ b/libada/configure
-@@ -3212,6 +3212,9 @@ case "${host}" in
- 	# sets the default TLS model and affects inlining.
- 	PICFLAG=-fPIC
- 	;;
-+    loongarch*-*-*)
-+	PICFLAG=-fpic
-+	;;
-     mips-sgi-irix6*)
- 	# PIC is the default.
- 	;;
-diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
-index d88515e4a03..3c921f4a86d 100644
---- a/libatomic/Makefile.am
-+++ b/libatomic/Makefile.am
-@@ -65,8 +65,13 @@ libatomic_version_script =
- libatomic_version_dep =
- endif
- libatomic_version_info = -version-info $(libtool_VERSION)
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
+ else
+   PICFLAG=
+ fi
+diff --git a/libdecnumber/configure.ac b/libdecnumber/configure.ac
+index aafd06f8a64..30a51ca410b 100644
+--- a/libdecnumber/configure.ac
++++ b/libdecnumber/configure.ac
+@@ -100,8 +100,23 @@ AC_C_BIGENDIAN
+ # Enable --enable-host-shared.
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
++		[build host code as shared libraries])])
++AC_SUBST(enable_host_shared)
++
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])])
++AC_SUBST(enable_host_pie)
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
++
+ AC_SUBST(PICFLAG)
+ 
+ # Enable Intel CET on Intel CET enabled host if jit is enabled.
+diff --git a/libffi/Makefile.am b/libffi/Makefile.am
+index c6d6f849c53..d2ae0c04c7b 100644
+--- a/libffi/Makefile.am
++++ b/libffi/Makefile.am
+@@ -214,7 +214,12 @@ libffi.map: $(top_srcdir)/libffi.map.in
+ 	$(COMPILE) -D$(TARGET) -DGENERATE_LIBFFI_MAP \
+ 	 -E -x assembler-with-cpp -o $@ $(top_srcdir)/libffi.map.in
+ 
+-libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS)
 +if ENABLE_DARWIN_AT_RPATH
-+libatomic_darwin_rpath = -Wc,-nodefaultrpaths
-+libatomic_darwin_rpath += -Wl,-rpath,@loader_path
++libffi_darwin_rpath = -Wl,-rpath,@loader_path
 +endif
++libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) \
++	$(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS) \
++	$(libffi_darwin_rpath)
+ libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep)
  
--libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) $(lt_host_flags)
-+libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) \
-+	$(lt_host_flags) $(libatomic_darwin_rpath) 
- libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c init.c \
- 	fenv.c fence.c flag.c
- 
-diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
-index 80d25653dc7..179f9217ad6 100644
---- a/libatomic/Makefile.in
-+++ b/libatomic/Makefile.in
-@@ -403,7 +403,12 @@ noinst_LTLIBRARIES = libatomic_convenience.la
- @LIBAT_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libatomic_version_dep = $(top_srcdir)/libatomic.map
- @LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libatomic_version_dep = libatomic.map-sun
- libatomic_version_info = -version-info $(libtool_VERSION)
--libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) $(lt_host_flags)
-+@ENABLE_DARWIN_AT_RPATH_TRUE@libatomic_darwin_rpath =  \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wc,-nodefaultrpaths \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
-+libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) \
-+	$(lt_host_flags) $(libatomic_darwin_rpath) 
+ AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
+diff --git a/libffi/Makefile.in b/libffi/Makefile.in
+index 5524a6a571e..34e77a45d1a 100644
+--- a/libffi/Makefile.in
++++ b/libffi/Makefile.in
+@@ -597,7 +597,11 @@ AM_CFLAGS = -Wall -g -fexceptions $(CET_FLAGS) $(am__append_2)
+ @LIBFFI_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map
+ @LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map-sun
+ libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
+-libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS)
++@ENABLE_DARWIN_AT_RPATH_TRUE@libffi_darwin_rpath = -Wl,-rpath,@loader_path
++libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) \
++	$(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS) \
++	$(libffi_darwin_rpath)
 +
- libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c init.c \
- 	fenv.c fence.c flag.c
- 
-diff --git a/libatomic/configure b/libatomic/configure
-index 92853dd8a45..935d5559aed 100755
---- a/libatomic/configure
-+++ b/libatomic/configure
-@@ -658,6 +658,8 @@ OPT_LDFLAGS
- SECTION_LDFLAGS
- enable_aarch64_lse
- libtool_VERSION
-+ENABLE_DARWIN_AT_RPATH_FALSE
-+ENABLE_DARWIN_AT_RPATH_TRUE
- MAINT
- MAINTAINER_MODE_FALSE
- MAINTAINER_MODE_TRUE
-@@ -803,6 +805,7 @@ with_pic
- enable_fast_install
+ libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep)
+ AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
+ AM_CCASFLAGS = $(AM_CPPFLAGS) $(CET_FLAGS)
+diff --git a/libffi/configure b/libffi/configure
+index 2bb9f8d83d6..069476bc2e6 100755
+--- a/libffi/configure
++++ b/libffi/configure
+@@ -667,6 +667,8 @@ MAINT
+ MAINTAINER_MODE_FALSE
+ MAINTAINER_MODE_TRUE
+ READELF
++ENABLE_DARWIN_AT_RPATH_FALSE
++ENABLE_DARWIN_AT_RPATH_TRUE
+ CXXCPP
+ CPP
+ OTOOL64
+@@ -810,6 +812,7 @@ with_pic
+ enable_fast_install
  with_gnu_ld
  enable_libtool_lock
 +enable_darwin_at_rpath
  enable_maintainer_mode
- enable_symvers
- enable_werror
-@@ -1452,6 +1455,8 @@ Optional Features:
+ enable_pax_emutramp
+ enable_debug
+@@ -1465,6 +1468,8 @@ Optional Features:
    --enable-fast-install[=PKGS]
                            optimize for fast installation [default=yes]
    --disable-libtool-lock  avoid locking (might break parallel builds)
@@ -7716,7 +6200,16 @@ index 92853dd8a45..935d5559aed 100755
    --enable-maintainer-mode
                            enable make rules and dependencies not useful (and
                            sometimes confusing) to the casual installer
-@@ -9576,6 +9581,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -7797,7 +7802,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -9771,6 +9776,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -7733,8 +6226,9 @@ index 92853dd8a45..935d5559aed 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -7742,15 +6236,16 @@ index 92853dd8a45..935d5559aed 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -7764,175 +6259,42 @@ index 92853dd8a45..935d5559aed 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -9593,10 +9639,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -9788,9 +9836,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -11382,7 +11437,7 @@ else
+@@ -11596,7 +11648,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11385 "configure"
-+#line 11440 "configure"
+-#line 11599 "configure"
++#line 11651 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11488,7 +11543,7 @@ else
+@@ -11702,7 +11754,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11491 "configure"
-+#line 11546 "configure"
+-#line 11705 "configure"
++#line 11757 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11773,6 +11828,15 @@ fi
- 
- 
- 
-+ if test x$enable_darwin_at_rpath = xyes; then
-+  ENABLE_DARWIN_AT_RPATH_TRUE=
-+  ENABLE_DARWIN_AT_RPATH_FALSE='#'
-+else
-+  ENABLE_DARWIN_AT_RPATH_TRUE='#'
-+  ENABLE_DARWIN_AT_RPATH_FALSE=
-+fi
-+
-+
- # For libtool versioning info, format is CURRENT:REVISION:AGE
- libtool_VERSION=3:0:2
- 
-@@ -15900,6 +15964,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
-   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
- Usually this means the macro was only invoked conditionally." "$LINENO" 5
- fi
-+if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
-+  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
-+Usually this means the macro was only invoked conditionally." "$LINENO" 5
-+fi
- 
- if test -z "${LIBAT_BUILD_VERSIONED_SHLIB_TRUE}" && test -z "${LIBAT_BUILD_VERSIONED_SHLIB_FALSE}"; then
-   as_fn_error $? "conditional \"LIBAT_BUILD_VERSIONED_SHLIB\" was never defined.
-diff --git a/libatomic/configure.ac b/libatomic/configure.ac
-index 5563551aaae..6b9d3085806 100644
---- a/libatomic/configure.ac
-+++ b/libatomic/configure.ac
-@@ -156,6 +156,8 @@ AC_SUBST(enable_shared)
- AC_SUBST(enable_static)
- AM_MAINTAINER_MODE
- 
-+AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
-+
- # For libtool versioning info, format is CURRENT:REVISION:AGE
- libtool_VERSION=3:0:2
- AC_SUBST(libtool_VERSION)
-diff --git a/libatomic/testsuite/Makefile.in b/libatomic/testsuite/Makefile.in
-index 333980ec2c1..8bc70562e5b 100644
---- a/libatomic/testsuite/Makefile.in
-+++ b/libatomic/testsuite/Makefile.in
-@@ -262,6 +262,7 @@ target_alias = @target_alias@
- target_cpu = @target_cpu@
- target_os = @target_os@
- target_vendor = @target_vendor@
-+tmake_file = @tmake_file@
- toolexecdir = @toolexecdir@
- toolexeclibdir = @toolexeclibdir@
- top_build_prefix = @top_build_prefix@
-diff --git a/libatomic/testsuite/lib/libatomic.exp b/libatomic/testsuite/lib/libatomic.exp
-index 38f3e5673e2..300e5096f79 100644
---- a/libatomic/testsuite/lib/libatomic.exp
-+++ b/libatomic/testsuite/lib/libatomic.exp
-@@ -152,6 +152,7 @@ proc libatomic_init { args } {
-     lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
- 
-     if [istarget *-*-darwin*] {
-+	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
- 	lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
-     }
- 
-diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
-index 08cdd21fb40..8898251161d 100644
---- a/libbacktrace/Makefile.in
-+++ b/libbacktrace/Makefile.in
-@@ -15,7 +15,7 @@
- @SET_MAKE@
- 
- # Makefile.am -- Backtrace Makefile.
--# Copyright (C) 2012-2021 Free Software Foundation, Inc.
-+# Copyright (C) 2012-2022 Free Software Foundation, Inc.
- 
- # Redistribution and use in source and binary forms, with or without
- # modification, are permitted provided that the following conditions are
-diff --git a/libbacktrace/backtrace.c b/libbacktrace/backtrace.c
-index d28575ec897..cf6491682a7 100644
---- a/libbacktrace/backtrace.c
-+++ b/libbacktrace/backtrace.c
-@@ -70,6 +70,13 @@ unwind (struct _Unwind_Context *context, void *vdata)
-   uintptr_t pc;
-   int ip_before_insn = 0;
- 
-+#ifdef __APPLE__
-+# undef HAVE_GETIPINFO
-+# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
-+#  define HAVE_GETIPINFO 1
-+# endif
-+#endif
-+
- #ifdef HAVE_GETIPINFO
-   pc = _Unwind_GetIPInfo (context, &ip_before_insn);
- #else
-diff --git a/libbacktrace/configure b/libbacktrace/configure
-index 17f470a4bec..957095aaf1b 100755
---- a/libbacktrace/configure
-+++ b/libbacktrace/configure
-@@ -675,6 +675,8 @@ PIC_FLAG
- WARN_FLAGS
- EXTRA_FLAGS
- BACKTRACE_FILE
-+ENABLE_DARWIN_AT_RPATH_FALSE
-+ENABLE_DARWIN_AT_RPATH_TRUE
- OTOOL64
- OTOOL
- LIPO
-@@ -799,6 +801,7 @@ with_pic
- enable_fast_install
- with_gnu_ld
- enable_libtool_lock
-+enable_darwin_at_rpath
- enable_largefile
- enable_cet
- enable_werror
-@@ -1447,6 +1450,8 @@ Optional Features:
-   --enable-fast-install[=PKGS]
-                           optimize for fast installation [default=yes]
-   --disable-libtool-lock  avoid locking (might break parallel builds)
-+  --enable-darwin-at-path install libraries with @rpath/library-name, requires
-+                          rpaths to be added to executables
-   --disable-largefile     omit support for large files
-   --enable-cet            enable Intel CET in target libraries [default=auto]
-   --disable-werror        disable building with -Werror
-@@ -9705,6 +9710,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-     darwin* | rhapsody*)
+@@ -12578,6 +12630,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+       darwin* | rhapsody*)
  
  
 +
@@ -7948,8 +6310,9 @@ index 17f470a4bec..957095aaf1b 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -7957,15 +6320,16 @@ index 17f470a4bec..957095aaf1b 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -7976,53 +6340,35 @@ index 17f470a4bec..957095aaf1b 100755
 +fi
 +
 +
-   archive_cmds_need_lc=no
-   hardcode_direct=no
-   hardcode_automatic=yes
-@@ -9722,10 +9768,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+   archive_cmds_need_lc_CXX=no
+   hardcode_direct_CXX=no
+   hardcode_automatic_CXX=yes
+@@ -12595,12 +12690,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
--    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+-    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+        if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+-      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++      _lt_install_name='\$rpath/\$soname'
++      if test "x$enable_darwin_at_rpath" = "xyes"; then
++        _lt_install_name='@rpath/\$soname'
++      fi
++      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring${_lt_dsymutil}"
+       archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+     fi
  
-   else
-   ld_shlibs=no
-@@ -11511,7 +11566,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 11514 "configure"
-+#line 11569 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -11617,7 +11672,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 11620 "configure"
-+#line 11675 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -11856,6 +11911,15 @@ CC="$lt_save_CC"
- 
+@@ -14970,6 +15073,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ # Only expand once:
  
  
 + if test x$enable_darwin_at_rpath = xyes; then
@@ -8033,647 +6379,63 @@ index 17f470a4bec..957095aaf1b 100755
 +  ENABLE_DARWIN_AT_RPATH_FALSE=
 +fi
 +
-+
- # Check whether --enable-largefile was given.
- if test "${enable_largefile+set}" = set; then :
-   enableval=$enable_largefile;
-@@ -14273,6 +14337,10 @@ if test -z "${HAVE_DWZ_TRUE}" && test -z "${HAVE_DWZ_FALSE}"; then
-   as_fn_error $? "conditional \"HAVE_DWZ\" was never defined.
+ 
+ if test -n "$ac_tool_prefix"; then
+   # Extract the first word of "${ac_tool_prefix}readelf", so it can be a program name with args.
+@@ -17115,6 +17226,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then
+   as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
 +if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
 +  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
 +Usually this means the macro was only invoked conditionally." "$LINENO" 5
 +fi
- if test -z "${HAVE_ELF_TRUE}" && test -z "${HAVE_ELF_FALSE}"; then
-   as_fn_error $? "conditional \"HAVE_ELF\" was never defined.
+ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
-diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
-index 597c9705db8..7f89bf33c6b 100644
---- a/libbacktrace/configure.ac
-+++ b/libbacktrace/configure.ac
-@@ -84,6 +84,8 @@ AM_CONDITIONAL(HAVE_DWZ, test "$DWZ" != "")
- LT_INIT
- AM_PROG_LIBTOOL
- 
+diff --git a/libffi/configure.ac b/libffi/configure.ac
+index 014d89d0423..716f20ae313 100644
+--- a/libffi/configure.ac
++++ b/libffi/configure.ac
+@@ -55,6 +55,7 @@ AC_SUBST(CET_FLAGS)
+ AM_PROG_AS
+ AM_PROG_CC_C_O
+ AC_PROG_LIBTOOL
 +AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
-+
- AC_SYS_LARGEFILE
- 
- backtrace_supported=yes
-diff --git a/libbacktrace/simple.c b/libbacktrace/simple.c
-index 6a1a1c92a12..811255ab6b5 100644
---- a/libbacktrace/simple.c
-+++ b/libbacktrace/simple.c
-@@ -65,6 +65,13 @@ simple_unwind (struct _Unwind_Context *context, void *vdata)
-   uintptr_t pc;
-   int ip_before_insn = 0;
- 
-+#ifdef __APPLE__
-+# undef HAVE_GETIPINFO
-+# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
-+#  define HAVE_GETIPINFO 1
-+# endif
-+#endif
-+
- #ifdef HAVE_GETIPINFO
-   pc = _Unwind_GetIPInfo (context, &ip_before_insn);
- #else
-diff --git a/libcc1/Makefile.am b/libcc1/Makefile.am
-index 6e3a34ff7e2..44d282c7676 100644
---- a/libcc1/Makefile.am
-+++ b/libcc1/Makefile.am
-@@ -55,6 +55,10 @@ marshall_c_source = marshall-c.hh
- marshall_cxx_source = marshall-cp.hh
- 
- libcc1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1plugin.sym
-+if ENABLE_DARWIN_AT_RPATH
-+libcc1plugin_la_LDFLAGS += -Wc,-nodefaultrpaths
-+libcc1plugin_la_LDFLAGS += -Wl,-rpath,@loader_path
-+endif
- libcc1plugin_la_SOURCES = libcc1plugin.cc context.cc context.hh \
- 	$(shared_source) $(marshall_c_source)
- libcc1plugin.lo_CPPFLAGS = $(CPPFLAGS_FOR_C)
-@@ -65,6 +69,10 @@ libcc1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
- 	$(CXXFLAGS) $(libcc1plugin_la_LDFLAGS) $(LTLDFLAGS) -o $@
  
- libcp1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcp1plugin.sym
-+if ENABLE_DARWIN_AT_RPATH
-+libcp1plugin_la_LDFLAGS += -Wc,-nodefaultrpaths
-+libcp1plugin_la_LDFLAGS += -Wl,-rpath,@loader_path
-+endif
- libcp1plugin_la_SOURCES = libcp1plugin.cc context.cc context.hh \
- 	$(shared_source) $(marshall_cxx_source)
- libcp1plugin.lo_CPPFLAGS = $(CPPFLAGS_FOR_CXX)
-@@ -76,6 +84,10 @@ libcp1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ AC_CHECK_TOOL(READELF, readelf)
  
- LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
- libcc1_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1.sym
-+if ENABLE_DARWIN_AT_RPATH
-+libcc1_la_LDFLAGS += -Wc,-nodefaultrpaths
-+libcc1_la_LDFLAGS += -Wl,-rpath,@loader_path
-+endif
- libcc1_la_SOURCES = findcomp.cc libcc1.cc libcp1.cc \
- 		compiler.cc compiler.hh names.cc names.hh $(shared_source) \
- 		$(marshall_c_source) $(marshall_cxx_source)
-diff --git a/libcc1/Makefile.in b/libcc1/Makefile.in
-index f8f590d71e9..440567a47d2 100644
---- a/libcc1/Makefile.in
-+++ b/libcc1/Makefile.in
-@@ -90,6 +90,12 @@ build_triplet = @build@
- host_triplet = @host@
- target_triplet = @target@
- @DARWIN_DYNAMIC_LOOKUP_TRUE@am__append_1 = -Wl,-undefined,dynamic_lookup
-+@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_2 = -Wc,-nodefaultrpaths \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
-+@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_3 = -Wc,-nodefaultrpaths \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
-+@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_4 = -Wc,-nodefaultrpaths \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
- subdir = .
- ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
- am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
-@@ -405,7 +411,8 @@ shared_source = callbacks.cc callbacks.hh connection.cc connection.hh \
- 
- marshall_c_source = marshall-c.hh
- marshall_cxx_source = marshall-cp.hh
--libcc1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1plugin.sym
-+libcc1plugin_la_LDFLAGS = -module -export-symbols \
-+	$(srcdir)/libcc1plugin.sym $(am__append_2)
- libcc1plugin_la_SOURCES = libcc1plugin.cc context.cc context.hh \
- 	$(shared_source) $(marshall_c_source)
- 
-@@ -416,7 +423,8 @@ libcc1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
- 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
- 	$(CXXFLAGS) $(libcc1plugin_la_LDFLAGS) $(LTLDFLAGS) -o $@
- 
--libcp1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcp1plugin.sym
-+libcp1plugin_la_LDFLAGS = -module -export-symbols \
-+	$(srcdir)/libcp1plugin.sym $(am__append_3)
- libcp1plugin_la_SOURCES = libcp1plugin.cc context.cc context.hh \
- 	$(shared_source) $(marshall_cxx_source)
- 
-@@ -428,7 +436,8 @@ libcp1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
- 	$(CXXFLAGS) $(libcp1plugin_la_LDFLAGS) $(LTLDFLAGS) -o $@
- 
- LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
--libcc1_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1.sym
-+libcc1_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1.sym \
-+	$(am__append_4)
- libcc1_la_SOURCES = findcomp.cc libcc1.cc libcp1.cc \
- 		compiler.cc compiler.hh names.cc names.hh $(shared_source) \
- 		$(marshall_c_source) $(marshall_cxx_source)
-diff --git a/libcc1/configure b/libcc1/configure
-index 01cfb2806da..42fb85a4047 100755
---- a/libcc1/configure
-+++ b/libcc1/configure
-@@ -646,6 +646,8 @@ gcc_version
- get_gcc_base_ver
- CET_HOST_FLAGS
- visibility
-+ENABLE_DARWIN_AT_RPATH_FALSE
-+ENABLE_DARWIN_AT_RPATH_TRUE
- CXXCPP
- am__fastdepCXX_FALSE
- am__fastdepCXX_TRUE
-@@ -787,6 +789,7 @@ with_pic
- enable_fast_install
- with_gnu_ld
- enable_libtool_lock
-+enable_darwin_at_rpath
- enable_cet
- with_gcc_major_version_only
- enable_werror_always
-@@ -1439,6 +1442,8 @@ Optional Features:
-   --enable-fast-install[=PKGS]
-                           optimize for fast installation [default=yes]
-   --disable-libtool-lock  avoid locking (might break parallel builds)
-+  --enable-darwin-at-path install libraries with @rpath/library-name, requires
-+                          rpaths to be added to executables
-   --enable-cet            enable Intel CET in host libraries [default=auto]
-   --enable-werror-always  enable -Werror despite compiler version
-   --enable-plugin         enable plugin support
-@@ -8971,6 +8976,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-     darwin* | rhapsody*)
+diff --git a/libffi/testsuite/lib/libffi.exp b/libffi/testsuite/lib/libffi.exp
+index 15d3d5ebd73..611f5177c7a 100644
+--- a/libffi/testsuite/lib/libffi.exp
++++ b/libffi/testsuite/lib/libffi.exp
+@@ -337,8 +337,13 @@ proc libffi-init { args } {
+     verbose "libffi_dir $libffi_dir"
+     if { $libffi_dir != "" } {
+ 	set libffi_dir [file dirname ${libffi_dir}]
+-	set libffi_link_flags "-L${libffi_dir}/.libs"
+-	lappend libffi_link_flags "-L${blddircxx}/src/.libs"
++        if [istarget *-*-darwin*] {
++            set libffi_link_flags "-B${libffi_dir}/.libs"
++	    lappend libffi_link_flags "-B${blddircxx}/src/.libs"
++	} else {
++	    set libffi_link_flags "-L${libffi_dir}/.libs"
++	    lappend libffi_link_flags "-L${blddircxx}/src/.libs"
++	}
+     }
  
+     set_ld_library_path_env_vars
+@@ -382,7 +387,7 @@ proc libffi_target_compile { source dest type options } {
+     # Darwin needs a stack execution allowed flag.
  
-+
-+  # Publish an arg to allow the user to select that Darwin host (and target)
-+  # libraries should be given install-names like @rpath/libfoo.dylib.  This
-+  # requires that the user of the library then adds an 'rpath' to the DSO that
-+  # needs access.
-+  # NOTE: there are defaults below, for systems that support rpaths.  The person
-+  # configuring can override the defaults for any system version that supports
-+  # them - they are, however, forced off for system versions without support.
-+  # Check whether --enable-darwin-at-rpath was given.
-+if test "${enable_darwin_at_rpath+set}" = set; then :
-+  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
-+    # This is not supported before macOS 10.5 / Darwin9.
-+    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
-+	enable_darwin_at_rpath=no
-+      ;;
-+    esac
-+   fi
-+else
-+  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+       enable_darwin_at_rpath=no
-+       ;;
-+
-+    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
-+    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
-+    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
-+      enable_darwin_at_rpath=yes
-+      ;;
-+    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
-+    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
-+
-+    esac
-+
-+fi
-+
-+
-   archive_cmds_need_lc=no
-   hardcode_direct=no
-   hardcode_automatic=yes
-@@ -8988,10 +9034,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-   esac
-   if test "$_lt_dar_can_shared" = "yes"; then
-     output_verbose_link_cmd=func_echo_all
--    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    fi
- 
-   else
-   ld_shlibs=no
-@@ -10777,7 +10832,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 10780 "configure"
-+#line 10835 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -10883,7 +10938,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 10886 "configure"
-+#line 10941 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -12165,6 +12220,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-       darwin* | rhapsody*)
- 
- 
-+
-+  # Publish an arg to allow the user to select that Darwin host (and target)
-+  # libraries should be given install-names like @rpath/libfoo.dylib.  This
-+  # requires that the user of the library then adds an 'rpath' to the DSO that
-+  # needs access.
-+  # NOTE: there are defaults below, for systems that support rpaths.  The person
-+  # configuring can override the defaults for any system version that supports
-+  # them - they are, however, forced off for system versions without support.
-+  # Check whether --enable-darwin-at-rpath was given.
-+if test "${enable_darwin_at_rpath+set}" = set; then :
-+  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
-+    # This is not supported before macOS 10.5 / Darwin9.
-+    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
-+	enable_darwin_at_rpath=no
-+      ;;
-+    esac
-+   fi
-+else
-+  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+       enable_darwin_at_rpath=no
-+       ;;
-+
-+    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
-+    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
-+    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
-+      enable_darwin_at_rpath=yes
-+      ;;
-+    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
-+    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
-+
-+    esac
-+
-+fi
-+
-+
-   archive_cmds_need_lc_CXX=no
-   hardcode_direct_CXX=no
-   hardcode_automatic_CXX=yes
-@@ -12182,12 +12278,25 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-   esac
-   if test "$_lt_dar_can_shared" = "yes"; then
-     output_verbose_link_cmd=func_echo_all
--    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    fi
-        if test "$lt_cv_apple_cc_single_mod" != "yes"; then
--      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-+      if test "x$enable_darwin_at_rpath" = "xyes"; then
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring${_lt_dsymutil}"
-+      else
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-+      fi
-       archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
-     fi
- 
-@@ -14518,6 +14627,14 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
- ac_compiler_gnu=$ac_cv_c_compiler_gnu
- 
- 
-+ if test x$enable_darwin_at_rpath = xyes; then
-+  ENABLE_DARWIN_AT_RPATH_TRUE=
-+  ENABLE_DARWIN_AT_RPATH_FALSE='#'
-+else
-+  ENABLE_DARWIN_AT_RPATH_TRUE='#'
-+  ENABLE_DARWIN_AT_RPATH_FALSE=
-+fi
-+
- 
- visibility=
- if test "$GXX" = yes; then
-@@ -15369,6 +15486,10 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
-   as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
- Usually this means the macro was only invoked conditionally." "$LINENO" 5
- fi
-+if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
-+  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
-+Usually this means the macro was only invoked conditionally." "$LINENO" 5
-+fi
- if test -z "${DARWIN_DYNAMIC_LOOKUP_TRUE}" && test -z "${DARWIN_DYNAMIC_LOOKUP_FALSE}"; then
-   as_fn_error $? "conditional \"DARWIN_DYNAMIC_LOOKUP\" was never defined.
- Usually this means the macro was only invoked conditionally." "$LINENO" 5
-diff --git a/libcc1/configure.ac b/libcc1/configure.ac
-index 36f5a7e09f1..e8d068e0ac4 100644
---- a/libcc1/configure.ac
-+++ b/libcc1/configure.ac
-@@ -38,6 +38,7 @@ AM_MAINTAINER_MODE
- LT_INIT([disable-static])
- AM_PROG_LIBTOOL
- AC_PROG_CXX
-+AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
- 
- visibility=
- if test "$GXX" = yes; then
-diff --git a/libffi/Makefile.am b/libffi/Makefile.am
-index c6d6f849c53..d2ae0c04c7b 100644
---- a/libffi/Makefile.am
-+++ b/libffi/Makefile.am
-@@ -214,7 +214,12 @@ libffi.map: $(top_srcdir)/libffi.map.in
- 	$(COMPILE) -D$(TARGET) -DGENERATE_LIBFFI_MAP \
- 	 -E -x assembler-with-cpp -o $@ $(top_srcdir)/libffi.map.in
- 
--libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS)
-+if ENABLE_DARWIN_AT_RPATH
-+libffi_darwin_rpath = -Wl,-rpath,@loader_path
-+endif
-+libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) \
-+	$(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS) \
-+	$(libffi_darwin_rpath)
- libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep)
- 
- AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
-diff --git a/libffi/Makefile.in b/libffi/Makefile.in
-index 5524a6a571e..34e77a45d1a 100644
---- a/libffi/Makefile.in
-+++ b/libffi/Makefile.in
-@@ -597,7 +597,11 @@ AM_CFLAGS = -Wall -g -fexceptions $(CET_FLAGS) $(am__append_2)
- @LIBFFI_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map
- @LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map-sun
- libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
--libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS)
-+@ENABLE_DARWIN_AT_RPATH_TRUE@libffi_darwin_rpath = -Wl,-rpath,@loader_path
-+libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) \
-+	$(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS) \
-+	$(libffi_darwin_rpath)
-+
- libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep)
- AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
- AM_CCASFLAGS = $(AM_CPPFLAGS) $(CET_FLAGS)
-diff --git a/libffi/configure b/libffi/configure
-index 575641cca1d..002320ca302 100755
---- a/libffi/configure
-+++ b/libffi/configure
-@@ -667,6 +667,8 @@ MAINT
- MAINTAINER_MODE_FALSE
- MAINTAINER_MODE_TRUE
- READELF
-+ENABLE_DARWIN_AT_RPATH_FALSE
-+ENABLE_DARWIN_AT_RPATH_TRUE
- CXXCPP
- CPP
- OTOOL64
-@@ -810,6 +812,7 @@ with_pic
- enable_fast_install
- with_gnu_ld
- enable_libtool_lock
-+enable_darwin_at_rpath
- enable_maintainer_mode
- enable_pax_emutramp
- enable_debug
-@@ -1465,6 +1468,8 @@ Optional Features:
-   --enable-fast-install[=PKGS]
-                           optimize for fast installation [default=yes]
-   --disable-libtool-lock  avoid locking (might break parallel builds)
-+  --enable-darwin-at-path install libraries with @rpath/library-name, requires
-+                          rpaths to be added to executables
-   --enable-maintainer-mode
-                           enable make rules and dependencies not useful (and
-                           sometimes confusing) to the casual installer
-@@ -9766,6 +9771,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-     darwin* | rhapsody*)
- 
- 
-+
-+  # Publish an arg to allow the user to select that Darwin host (and target)
-+  # libraries should be given install-names like @rpath/libfoo.dylib.  This
-+  # requires that the user of the library then adds an 'rpath' to the DSO that
-+  # needs access.
-+  # NOTE: there are defaults below, for systems that support rpaths.  The person
-+  # configuring can override the defaults for any system version that supports
-+  # them - they are, however, forced off for system versions without support.
-+  # Check whether --enable-darwin-at-rpath was given.
-+if test "${enable_darwin_at_rpath+set}" = set; then :
-+  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
-+    # This is not supported before macOS 10.5 / Darwin9.
-+    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
-+	enable_darwin_at_rpath=no
-+      ;;
-+    esac
-+   fi
-+else
-+  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+       enable_darwin_at_rpath=no
-+       ;;
-+
-+    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
-+    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
-+    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
-+      enable_darwin_at_rpath=yes
-+      ;;
-+    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
-+    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
-+
-+    esac
-+
-+fi
-+
-+
-   archive_cmds_need_lc=no
-   hardcode_direct=no
-   hardcode_automatic=yes
-@@ -9783,10 +9829,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-   esac
-   if test "$_lt_dar_can_shared" = "yes"; then
-     output_verbose_link_cmd=func_echo_all
--    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    fi
- 
-   else
-   ld_shlibs=no
-@@ -11572,7 +11627,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 11575 "configure"
-+#line 11630 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -11678,7 +11733,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 11681 "configure"
-+#line 11736 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -12554,6 +12609,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-       darwin* | rhapsody*)
- 
- 
-+
-+  # Publish an arg to allow the user to select that Darwin host (and target)
-+  # libraries should be given install-names like @rpath/libfoo.dylib.  This
-+  # requires that the user of the library then adds an 'rpath' to the DSO that
-+  # needs access.
-+  # NOTE: there are defaults below, for systems that support rpaths.  The person
-+  # configuring can override the defaults for any system version that supports
-+  # them - they are, however, forced off for system versions without support.
-+  # Check whether --enable-darwin-at-rpath was given.
-+if test "${enable_darwin_at_rpath+set}" = set; then :
-+  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
-+    # This is not supported before macOS 10.5 / Darwin9.
-+    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
-+	enable_darwin_at_rpath=no
-+      ;;
-+    esac
-+   fi
-+else
-+  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+       enable_darwin_at_rpath=no
-+       ;;
-+
-+    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
-+    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
-+    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
-+      enable_darwin_at_rpath=yes
-+      ;;
-+    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
-+    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
-+
-+    esac
-+
-+fi
-+
-+
-   archive_cmds_need_lc_CXX=no
-   hardcode_direct_CXX=no
-   hardcode_automatic_CXX=yes
-@@ -12571,12 +12667,25 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-   esac
-   if test "$_lt_dar_can_shared" = "yes"; then
-     output_verbose_link_cmd=func_echo_all
--    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    fi
-        if test "$lt_cv_apple_cc_single_mod" != "yes"; then
--      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-+      if test "x$enable_darwin_at_rpath" = "xyes"; then
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring${_lt_dsymutil}"
-+      else
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-+      fi
-       archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
-     fi
- 
-@@ -14926,6 +15035,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
- # Only expand once:
- 
- 
-+ if test x$enable_darwin_at_rpath = xyes; then
-+  ENABLE_DARWIN_AT_RPATH_TRUE=
-+  ENABLE_DARWIN_AT_RPATH_FALSE='#'
-+else
-+  ENABLE_DARWIN_AT_RPATH_TRUE='#'
-+  ENABLE_DARWIN_AT_RPATH_FALSE=
-+fi
-+
- 
- if test -n "$ac_tool_prefix"; then
-   # Extract the first word of "${ac_tool_prefix}readelf", so it can be a program name with args.
-@@ -17071,6 +17188,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then
-   as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined.
- Usually this means the macro was only invoked conditionally." "$LINENO" 5
- fi
-+if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
-+  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
-+Usually this means the macro was only invoked conditionally." "$LINENO" 5
-+fi
- if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
-   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
- Usually this means the macro was only invoked conditionally." "$LINENO" 5
-diff --git a/libffi/configure.ac b/libffi/configure.ac
-index 014d89d0423..716f20ae313 100644
---- a/libffi/configure.ac
-+++ b/libffi/configure.ac
-@@ -55,6 +55,7 @@ AC_SUBST(CET_FLAGS)
- AM_PROG_AS
- AM_PROG_CC_C_O
- AC_PROG_LIBTOOL
-+AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
- 
- AC_CHECK_TOOL(READELF, readelf)
- 
+     if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"]
+-	 || [istarget "*-*-darwin2*"] } {
++	 || [istarget "x86_64-*-darwin2*"] } {
+ 	lappend options "additional_flags=-Wl,-allow_stack_execute"
+ 	lappend options "additional_flags=-Wl,-search_paths_first"
+     }
 diff --git a/libgcc/config.host b/libgcc/config.host
-index 8c56fcae5d2..48eed32e195 100644
+index 9d7212028d0..018dfe79d82 100644
 --- a/libgcc/config.host
 +++ b/libgcc/config.host
 @@ -82,7 +82,7 @@ m32c*-*-*)
@@ -8685,10 +6447,10 @@ index 8c56fcae5d2..48eed32e195 100644
  	cpu_type=aarch64
  	;;
  alpha*-*-*)
-@@ -241,7 +241,46 @@ case ${host} in
+@@ -251,7 +251,29 @@ case ${host} in
+       echo "Warning: libgcc configured to support macOS 10.5" 1>&2
        ;;
    esac
-   tmake_file="$tmake_file t-slibgcc-darwin"
 -  extra_parts="crt3.o libd10-uwfef.a crttms.o crttme.o libemutls_w.a"
 +  # We are not using libtool to build the libs here, so we need to replicate
 +  # a little of the logic around setting Darwin rpaths.  Setting an explicit
@@ -8712,29 +6474,12 @@ index 8c56fcae5d2..48eed32e195 100644
 +  if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    tmake_file="$tmake_file t-darwin-rpath "
 +  fi
-+  case ${host} in
-+    *-*-darwin2* | *-*-darwin1[89]* | aarch64*-*-darwin*)
-+      tmake_file="t-darwin-min-8 $tmake_file"
-+      ;;
-+    *-*-darwin9* | *-*-darwin1[0-7]*)
-+      tmake_file="t-darwin-min-5 $tmake_file"
-+      ;;
-+    *-*-darwin[4-8]*)
-+      tmake_file="t-darwin-min-1 $tmake_file"
-+      ;;
-+    *)
-+      # Fall back to configuring for the oldest system known to work with
-+      # all archs and the current sources.
-+      tmake_file="t-darwin-min-5 $tmake_file"
-+      echo "Warning: libgcc configured to support macOS 10.5" 1>&2
-+      ;;
-+  esac
-+  extra_parts="crt3.o crttms.o crttme.o libemutls_w.a"
++  extra_parts="crt3.o crttms.o crttme.o libemutls_w.a "
    ;;
  *-*-dragonfly*)
    tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip"
-@@ -384,6 +423,17 @@ aarch64*-*-elf | aarch64*-*-rtems*)
- 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
+@@ -395,6 +417,17 @@ aarch64*-*-elf | aarch64*-*-rtems*)
+ 	tmake_file="${tmake_file} t-dfprules"
  	md_unwind_header=aarch64/aarch64-unwind.h
  	;;
 +aarch64*-*-darwin*)
@@ -8742,7 +6487,7 @@ index 8c56fcae5d2..48eed32e195 100644
 +	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
 +	tmake_file="${tmake_file} ${cpu_type}/t-lse "
 +	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp "
-+	tmake_file="${tmake_file} t-crtfm"
++	tmake_file="${tmake_file} t-crtfm t-dfprules"
 +	md_unwind_header=aarch64/aarch64-unwind.h
 +	if test x$off_stack_trampolines = xyes; then
 +	    tmake_file="${tmake_file} ${cpu_type}/t-heap-trampoline"
@@ -8751,17 +6496,17 @@ index 8c56fcae5d2..48eed32e195 100644
  aarch64*-*-freebsd*)
  	extra_parts="$extra_parts crtfastmath.o"
  	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
-@@ -408,6 +458,9 @@ aarch64*-*-linux*)
- 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+@@ -423,6 +456,9 @@ aarch64*-*-linux*)
  	tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
  	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
+ 	tmake_file="${tmake_file} t-dfprules"
 +	if test x$off_stack_trampolines = xyes; then
 +	    tmake_file="${tmake_file} ${cpu_type}/t-heap-trampoline"
 +	fi
  	;;
  aarch64*-*-vxworks7*)
  	extra_parts="$extra_parts crtfastmath.o"
-@@ -701,12 +754,17 @@ hppa*-*-netbsd*)
+@@ -691,12 +727,17 @@ hppa*-*-netbsd*)
  i[34567]86-*-darwin*)
  	tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi"
  	tm_file="$tm_file i386/darwin-lib.h"
@@ -8779,7 +6524,7 @@ index 8c56fcae5d2..48eed32e195 100644
  	;;
  i[34567]86-*-elfiamcu)
  	tmake_file="$tmake_file i386/t-crtstuff t-softfp-sfdftf i386/32/t-softfp i386/32/t-iamcu i386/t-softfp t-softfp t-dfprules"
-@@ -773,6 +831,9 @@ x86_64-*-linux*)
+@@ -763,6 +804,9 @@ x86_64-*-linux*)
  	tmake_file="${tmake_file} i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules"
  	tm_file="${tm_file} i386/elf-lib.h"
  	md_unwind_header=i386/linux-unwind.h
@@ -8789,7 +6534,7 @@ index 8c56fcae5d2..48eed32e195 100644
  	;;
  x86_64-*-kfreebsd*-gnu)
  	extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
-@@ -1169,12 +1230,14 @@ powerpc-*-darwin*)
+@@ -1171,12 +1215,14 @@ powerpc-*-darwin*)
  	# We build the darwin10 EH shim for Rosetta (running on x86 machines).
  	tm_file="$tm_file i386/darwin-lib.h"
  	tmake_file="$tmake_file rs6000/t-ppc64-fp rs6000/t-ibm-ldouble"
@@ -8983,7 +6728,7 @@ index 00000000000..c8b83681ed7
 +    }
 +}
 diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
-index 9c29cf08b59..97b68c42cc1 100644
+index dde3a28e07b..87ee33bc52a 100644
 --- a/libgcc/config/aarch64/lse.S
 +++ b/libgcc/config/aarch64/lse.S
 @@ -58,7 +58,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
@@ -9037,10 +6782,10 @@ index 9c29cf08b59..97b68c42cc1 100644
  
  STARTFN	NAME(cas)
 diff --git a/libgcc/config/aarch64/sfp-machine.h b/libgcc/config/aarch64/sfp-machine.h
-index be9b42174c4..5dc1827ee3a 100644
+index 97c38a34c86..b35e2c5e29a 100644
 --- a/libgcc/config/aarch64/sfp-machine.h
 +++ b/libgcc/config/aarch64/sfp-machine.h
-@@ -122,6 +122,27 @@ void __sfp_handle_exceptions (int);
+@@ -124,6 +124,27 @@ void __sfp_handle_exceptions (int);
  
  
  /* Define ALIASNAME as a strong alias for NAME.  */
@@ -9210,982 +6955,550 @@ index 00000000000..96e13bf828e
 +
 +  p->trampolines = allocate_trampoline_page ();
 +
-+  if (p->trampolines == MAP_FAILED)
-+    return NULL;
-+
-+  p->prev = parent;
-+  p->free_trampolines = get_trampolines_per_page();
-+
-+  return p;
-+}
-+
-+void
-+__builtin_nested_func_ptr_created (void *chain, void *func, void **dst)
-+{
-+  if (tramp_ctrl_curr == NULL)
-+    {
-+      tramp_ctrl_curr = allocate_tramp_ctrl (NULL);
-+      if (tramp_ctrl_curr == NULL)
-+	abort ();
-+    }
-+
-+  if (tramp_ctrl_curr->free_trampolines == 0)
-+    {
-+      void *tramp_ctrl = allocate_tramp_ctrl (tramp_ctrl_curr);
-+      if (!tramp_ctrl)
-+	abort ();
-+
-+      tramp_ctrl_curr = tramp_ctrl;
-+    }
-+
-+  union ix86_trampoline *trampoline
-+    = &tramp_ctrl_curr->trampolines[get_trampolines_per_page ()
-+				    - tramp_ctrl_curr->free_trampolines];
-+
-+#if __APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101400
-+  /* Disable write protection for the MAP_JIT regions in this thread (see
-+     https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon) */
-+  pthread_jit_write_protect_np (0);
-+#endif
-+
-+  memcpy (trampoline->insns, trampoline_insns,
-+	  sizeof(trampoline_insns));
-+  trampoline->fields.func_ptr = func;
-+  trampoline->fields.chain_ptr = chain;
-+
-+#if __APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101400
-+  /* Re-enable write protection.  */
-+  pthread_jit_write_protect_np (1);
-+#endif
-+
-+  tramp_ctrl_curr->free_trampolines -= 1;
-+
-+  __builtin___clear_cache ((void *)trampoline->insns,
-+			   ((void *)trampoline->insns + sizeof(trampoline->insns)));
-+
-+  *dst = &trampoline->insns;
-+}
-+
-+void
-+__builtin_nested_func_ptr_deleted (void)
-+{
-+  if (tramp_ctrl_curr == NULL)
-+    abort ();
-+
-+  tramp_ctrl_curr->free_trampolines += 1;
-+
-+  if (tramp_ctrl_curr->free_trampolines == get_trampolines_per_page ())
-+    {
-+      if (tramp_ctrl_curr->prev == NULL)
-+	return;
-+
-+      munmap (tramp_ctrl_curr->trampolines, getpagesize());
-+      struct tramp_ctrl_data *prev = tramp_ctrl_curr->prev;
-+      free (tramp_ctrl_curr);
-+      tramp_ctrl_curr = prev;
-+    }
-+}
-diff --git a/libgcc/config/i386/t-heap-trampoline b/libgcc/config/i386/t-heap-trampoline
-new file mode 100644
-index 00000000000..76f438d9529
---- /dev/null
-+++ b/libgcc/config/i386/t-heap-trampoline
-@@ -0,0 +1,20 @@
-+# Copyright The GNU Toolchain Authors.
-+
-+# This file is part of GCC.
-+#
-+# GCC is free software; you can redistribute it and/or modify it
-+# under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3, or (at your option)
-+# any later version.
-+#
-+# GCC is distributed in the hope that it will be useful, but
-+# WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+# General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with GCC; see the file COPYING3.  If not see
-+# .
-+
-+LIB2ADD += $(srcdir)/config/i386/heap-trampoline.c
-+HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=10.8
-diff --git a/libgcc/config/t-darwin b/libgcc/config/t-darwin
-index 299d26c2c96..a708583d965 100644
---- a/libgcc/config/t-darwin
-+++ b/libgcc/config/t-darwin
-@@ -1,15 +1,15 @@
- # Set this as a minimum (unless overriden by arch t-files) since it's a
- # reasonable lowest common denominator that works for all our archs.
--HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=10.4
-+HOST_LIBGCC2_CFLAGS += $(DARWIN_MIN_LIB_VERSION)
- 
- crt3.o: $(srcdir)/config/darwin-crt3.c
--	$(crt_compile) -mmacosx-version-min=10.4 -c $<
-+	$(crt_compile) $(DARWIN_MIN_CRT_VERSION) -c $<
- 
- crttms.o: $(srcdir)/config/darwin-crt-tm.c
--	$(crt_compile) -mmacosx-version-min=10.4 -DSTART -c $<
-+	$(crt_compile) $(DARWIN_MIN_CRT_VERSION) -DSTART -c $<
- 
- crttme.o: $(srcdir)/config/darwin-crt-tm.c
--	$(crt_compile) -mmacosx-version-min=10.4 -DEND -c $<
-+	$(crt_compile) $(DARWIN_MIN_CRT_VERSION) -DEND -c $<
- 
- # Make emutls weak so that we can deal with -static-libgcc, override the
- # hidden visibility when this is present in libgcc_eh.
-@@ -24,7 +24,8 @@ libemutls_w.a: emutls_s.o
- 	$(AR_CREATE_FOR_TARGET) $@ $<
- 	$(RANLIB_FOR_TARGET) $@
- 
--# Patch to __Unwind_Find_Enclosing_Function for Darwin10.
-+# This has to be built for 10.6, even if the toolchain will not target that
-+# version
- d10-uwfef.o: $(srcdir)/config/darwin10-unwind-find-enc-func.c libgcc_tm.h
- 	$(crt_compile) -mmacosx-version-min=10.6 -c $<
- 
-diff --git a/libgcc/config/t-darwin-min-1 b/libgcc/config/t-darwin-min-1
-new file mode 100644
-index 00000000000..8c2cf8acd39
---- /dev/null
-+++ b/libgcc/config/t-darwin-min-1
-@@ -0,0 +1,3 @@
-+# Support building with -mmacosx-version-min back to 10.1.
-+DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.4
-+DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.1
-diff --git a/libgcc/config/t-darwin-min-4 b/libgcc/config/t-darwin-min-4
-new file mode 100644
-index 00000000000..04e980de4d5
---- /dev/null
-+++ b/libgcc/config/t-darwin-min-4
-@@ -0,0 +1,3 @@
-+# Support building with -mmacosx-version-min back to 10.4.
-+DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.4
-+DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.4
-diff --git a/libgcc/config/t-darwin-min-5 b/libgcc/config/t-darwin-min-5
-new file mode 100644
-index 00000000000..138193151e7
---- /dev/null
-+++ b/libgcc/config/t-darwin-min-5
-@@ -0,0 +1,3 @@
-+# Support building with -mmacosx-version-min back to 10.5.
-+DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.5
-+DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.5
-diff --git a/libgcc/config/t-darwin-min-8 b/libgcc/config/t-darwin-min-8
-new file mode 100644
-index 00000000000..9efc9dc0257
---- /dev/null
-+++ b/libgcc/config/t-darwin-min-8
-@@ -0,0 +1,3 @@
-+# Support building with -mmacosx-version-min back to 10.8.
-+DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.8
-+DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.8
-diff --git a/libgcc/config/t-darwin-rpath b/libgcc/config/t-darwin-rpath
-new file mode 100644
-index 00000000000..951539de7aa
---- /dev/null
-+++ b/libgcc/config/t-darwin-rpath
-@@ -0,0 +1,5 @@
-+# Use @rpath and add a search path to exes and dylibs that depend on this.
-+SHLIB_RPATH = @rpath
++  if (p->trampolines == MAP_FAILED)
++    return NULL;
 +
-+# Enable the libgcc_s.1.dylib compatibility lib to find the dependent 1.1.dylib.
-+SHLIB_LOADER_PATH = -Wl,-rpath,@loader_path
-diff --git a/libgcc/config/t-slibgcc-darwin b/libgcc/config/t-slibgcc-darwin
-index a8f69666a82..ee449de32e6 100644
---- a/libgcc/config/t-slibgcc-darwin
-+++ b/libgcc/config/t-slibgcc-darwin
-@@ -1,4 +1,4 @@
--# Build a shared libgcc library with the darwin linker.
-+# Build a shared libgcc library able to use embedded runpaths.
- 
- SHLIB_SOVERSION = 1.1
- SHLIB_SO_MINVERSION = 1
-@@ -6,7 +6,6 @@ SHLIB_VERSTRING = -compatibility_version $(SHLIB_SO_MINVERSION) \
- 		  -current_version $(SHLIB_SOVERSION)
- SHLIB_EXT = .dylib
- SHLIB_LC = -lSystem
--SHLIB_INSTALL_DIR = $(slibdir)
- 
- SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
- SHLIB_MKMAP_OPTS = -v leading_underscore=1
-@@ -23,11 +22,20 @@ SHLIB_SONAME = @shlib_base_name@$(SHLIB_EXT)
- # subdir.  The code under MULTIBUILDTOP combines these into a single FAT
- # library, that is what we eventually install.
- 
-+# When enable_darwin_at_rpath is true, use @rpath instead of $(slibdir) for
-+# this and dylibs that depend on this.  So this def must come first and be
-+# overridden in a make fragment that depends on the rpath setting.
-+SHLIB_RPATH = $(slibdir)
++  p->prev = parent;
++  p->free_trampolines = get_trampolines_per_page();
 +
-+# Likewise, we only want to add an @loader_path to the shared libs when
-+# we have enable_darwin_at_rpath.
-+SHLIB_LOADER_PATH =
++  return p;
++}
 +
- SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
--	-install_name $(SHLIB_INSTALL_DIR)/$(SHLIB_INSTALL_NAME) \
-+	-install_name $(SHLIB_RPATH)/$(SHLIB_INSTALL_NAME) \
- 	-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
- 	-Wl,-exported_symbols_list,$(SHLIB_MAP) \
--	$(SHLIB_VERSTRING) \
-+	$(SHLIB_VERSTRING) -nodefaultrpaths \
- 	@multilib_flags@ @shlib_objs@ $(SHLIB_LC)
- 
- # we do our own thing
-@@ -63,9 +71,9 @@ EHS_INSTNAME = libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
- libgcc_ehs$(SHLIB_EXT): $(LIBEHSOBJS) $(extra-parts)
- 	mkdir -p $(MULTIDIR)
- 	$(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
--	-install_name $(SHLIB_INSTALL_DIR)/$(EHS_INSTNAME) \
-+	-install_name $(SHLIB_RPATH)/$(EHS_INSTNAME) \
- 	-o $(MULTIDIR)/libgcc_ehs$(SHLIB_EXT) $(SHLIB_VERSTRING) \
--	$(LIBEHSOBJS) $(SHLIB_LC)
-+	-nodefaultrpaths $(LIBEHSOBJS) $(SHLIB_LC)
- 
- all: libgcc_ehs$(SHLIB_EXT)
- 
-@@ -121,12 +129,13 @@ libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
- 	  cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT)  \
- 	    ./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
- 	  arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
--	  $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
-+	  $(CC) -arch $${arch} -nodefaultlibs -dynamiclib -nodefaultrpaths \
-+	    $(SHLIB_LOADER_PATH) \
- 	    -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
- 	    -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
- 	    -Wl,-reexport_library,libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
--	    -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
--	    -compatibility_version 1 -current_version 1 ; \
-+	    -install_name $(SHLIB_RPATH)/libgcc_s.1.dylib \
-+	    -compatibility_version 1 -current_version 1.1 ; \
- 	done
- 	$(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
- 	rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
-@@ -140,13 +149,14 @@ libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
- 	  cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT)  \
- 	    ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
- 	  arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
--	  $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
-+	  $(CC) -arch $${arch} -nodefaultlibs -dynamiclib -nodefaultrpaths \
-+	    $(SHLIB_LOADER_PATH) \
- 	    -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
- 	    -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
- 	    -lSystem \
- 	    -Wl,-reexported_symbols_list,$(srcdir)/config/darwin-unwind.ver \
--	    -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
--	    -compatibility_version 1 -current_version 1 ; \
-+	    -install_name $(SHLIB_RPATH)/libgcc_s.1.dylib \
-+	    -compatibility_version 1 -current_version 1.1 ; \
- 	done
- 	$(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
- 	rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
-diff --git a/libgcc/configure b/libgcc/configure
-index 1f9b2ac578b..a5c228bc3a1 100755
---- a/libgcc/configure
-+++ b/libgcc/configure
-@@ -630,7 +630,6 @@ LIPO
- AR
- toolexeclibdir
- toolexecdir
--enable_gcov
- target_subdir
- host_subdir
- build_subdir
-@@ -654,6 +653,8 @@ build_cpu
- build
- with_aix_soname
- enable_vtable_verify
-+enable_gcov
-+off_stack_trampolines
- enable_shared
- libgcc_topdir
- target_alias
-@@ -701,6 +702,8 @@ with_target_subdir
- with_cross_host
- with_ld
- enable_shared
-+enable_off_stack_trampolines
-+enable_gcov
- enable_vtable_verify
- with_aix_soname
- enable_version_specific_runtime_libs
-@@ -708,7 +711,6 @@ with_toolexeclibdir
- with_slibdir
- enable_maintainer_mode
- with_build_libsubdir
--enable_gcov
- enable_largefile
- enable_decimal_float
- with_system_libunwind
-@@ -1342,12 +1344,15 @@ Optional Features:
-   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-   --disable-shared        don't provide a shared libgcc
-+  --enable-off-stack-trampolines
-+                  Specify whether to support generating off-stack trampolines
++void
++__builtin_nested_func_ptr_created (void *chain, void *func, void **dst)
++{
++  if (tramp_ctrl_curr == NULL)
++    {
++      tramp_ctrl_curr = allocate_tramp_ctrl (NULL);
++      if (tramp_ctrl_curr == NULL)
++	abort ();
++    }
 +
-+  --disable-gcov          don't provide libgcov and related host tools
-   --enable-vtable-verify    Enable vtable verification feature
-   --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory
-   --enable-maintainer-mode
-                           enable make rules and dependencies not useful (and
-                           sometimes confusing) to the casual installer
--  --disable-gcov          don't provide libgcov and related host tools
-   --disable-largefile     omit support for large files
-   --enable-decimal-float={no,yes,bid,dpd}
- 			enable decimal float extension to C.  Selecting 'bid'
-@@ -2252,6 +2257,48 @@ fi
- 
- 
- 
-+# Check whether --enable-off-stack-trampolines was given.
-+if test "${enable_off_stack_trampolines+set}" = set; then :
-+  enableval=$enable_off_stack_trampolines;
-+case "$target" in
-+  x86_64-*-linux* | x86_64-*-darwin1[4-9]* | x86_64-*-darwin2*)
-+    off_stack_trampolines=$enableval
-+    ;;
-+  aarch64*-*-linux* )
-+    off_stack_trampolines=$enableval
-+    ;;
-+  aarch64*-*darwin* )
-+    off_stack_trampolines=$enableval
-+    ;;
-+  *)
-+    as_fn_error $? "Configure option --enable-off-stack-trampolines is not supported \
-+for this platform" "$LINENO" 5
-+    off_stack_trampolines=no
-+    ;;
-+esac
-+else
++  if (tramp_ctrl_curr->free_trampolines == 0)
++    {
++      void *tramp_ctrl = allocate_tramp_ctrl (tramp_ctrl_curr);
++      if (!tramp_ctrl)
++	abort ();
 +
-+case "$target" in
-+  *-*-darwin2*)
-+    off_stack_trampolines=yes
-+    ;;
-+  *)
-+    off_stack_trampolines=no
-+    ;;
-+esac
-+fi
++      tramp_ctrl_curr = tramp_ctrl;
++    }
++
++  union ix86_trampoline *trampoline
++    = &tramp_ctrl_curr->trampolines[get_trampolines_per_page ()
++				    - tramp_ctrl_curr->free_trampolines];
++
++#if __APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101400
++  /* Disable write protection for the MAP_JIT regions in this thread (see
++     https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon) */
++  pthread_jit_write_protect_np (0);
++#endif
 +
++  memcpy (trampoline->insns, trampoline_insns,
++	  sizeof(trampoline_insns));
++  trampoline->fields.func_ptr = func;
++  trampoline->fields.chain_ptr = chain;
 +
++#if __APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101400
++  /* Re-enable write protection.  */
++  pthread_jit_write_protect_np (1);
++#endif
 +
-+# Check whether --enable-gcov was given.
-+if test "${enable_gcov+set}" = set; then :
-+  enableval=$enable_gcov;
-+else
-+  enable_gcov=yes
-+fi
++  tramp_ctrl_curr->free_trampolines -= 1;
 +
++  __builtin___clear_cache ((void *)trampoline->insns,
++			   ((void *)trampoline->insns + sizeof(trampoline->insns)));
 +
++  *dst = &trampoline->insns;
++}
 +
- # Check whether --enable-vtable-verify was given.
- if test "${enable_vtable_verify+set}" = set; then :
-   enableval=$enable_vtable_verify; case "$enableval" in
-diff --git a/libgcc/configure.ac b/libgcc/configure.ac
-index 2fc9d5d7c93..7d11bf00142 100644
---- a/libgcc/configure.ac
-+++ b/libgcc/configure.ac
-@@ -68,6 +68,40 @@ AC_ARG_ENABLE(shared,
- ], [enable_shared=yes])
- AC_SUBST(enable_shared)
- 
-+AC_ARG_ENABLE([off-stack-trampolines],
-+  [AS_HELP_STRING([--enable-off-stack-trampolines]
-+                  [Specify whether to support generating off-stack trampolines])],[
-+case "$target" in
-+  x86_64-*-linux* | x86_64-*-darwin1[[4-9]]* | x86_64-*-darwin2*)
-+    off_stack_trampolines=$enableval
-+    ;;
-+  aarch64*-*-linux* )
-+    off_stack_trampolines=$enableval
-+    ;;
-+  aarch64*-*darwin* )
-+    off_stack_trampolines=$enableval
-+    ;;
-+  *)
-+    AC_MSG_ERROR([Configure option --enable-off-stack-trampolines is not supported \
-+for this platform])
-+    off_stack_trampolines=no
-+    ;;
-+esac],[
-+case "$target" in
-+  *-*-darwin2*)
-+    off_stack_trampolines=yes
-+    ;;
-+  *)
-+    off_stack_trampolines=no
-+    ;;
-+esac])
-+AC_SUBST(off_stack_trampolines)
++void
++__builtin_nested_func_ptr_deleted (void)
++{
++  if (tramp_ctrl_curr == NULL)
++    abort ();
 +
-+AC_ARG_ENABLE(gcov,
-+[  --disable-gcov          don't provide libgcov and related host tools],
-+[], [enable_gcov=yes])
-+AC_SUBST(enable_gcov)
++  tramp_ctrl_curr->free_trampolines += 1;
 +
- AC_ARG_ENABLE(vtable-verify,
- [  --enable-vtable-verify    Enable vtable verification feature ],
- [case "$enableval" in
-diff --git a/libgcc/libgcc-std.ver.in b/libgcc/libgcc-std.ver.in
-index 513ddd0bd0d..fc0b4052a3b 100644
---- a/libgcc/libgcc-std.ver.in
-+++ b/libgcc/libgcc-std.ver.in
-@@ -1943,4 +1943,7 @@ GCC_4.8.0 {
- GCC_7.0.0 {
-   __PFX__divmoddi4
-   __PFX__divmodti4
++  if (tramp_ctrl_curr->free_trampolines == get_trampolines_per_page ())
++    {
++      if (tramp_ctrl_curr->prev == NULL)
++	return;
 +
-+  __builtin_nested_func_ptr_created
-+  __builtin_nested_func_ptr_deleted
- }
-diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h
-index fc24ac34502..536e517b62f 100644
---- a/libgcc/libgcc2.h
-+++ b/libgcc/libgcc2.h
-@@ -29,6 +29,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
- #pragma GCC visibility push(default)
- #endif
- 
-+extern void __builtin_nested_func_ptr_created (void *, void *, void **);
-+extern void __builtin_nested_func_ptr_deleted (void);
++      munmap (tramp_ctrl_curr->trampolines, getpagesize());
++      struct tramp_ctrl_data *prev = tramp_ctrl_curr->prev;
++      free (tramp_ctrl_curr);
++      tramp_ctrl_curr = prev;
++    }
++}
+diff --git a/libgcc/config/i386/t-heap-trampoline b/libgcc/config/i386/t-heap-trampoline
+new file mode 100644
+index 00000000000..76f438d9529
+--- /dev/null
++++ b/libgcc/config/i386/t-heap-trampoline
+@@ -0,0 +1,20 @@
++# Copyright The GNU Toolchain Authors.
 +
- extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
- extern void __clear_cache (void *, void *);
- extern void __eprintf (const char *, const char *, unsigned int, const char *)
-diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
-index 5ce0cd7cd05..2073bf6c5ef 100644
---- a/libgfortran/Makefile.am
-+++ b/libgfortran/Makefile.am
-@@ -37,6 +37,11 @@ else
- version_arg =
- version_dep =
- endif
-+extra_darwin_ldflags_libgfortran = @extra_ldflags_libgfortran@
-+if ENABLE_DARWIN_AT_RPATH
-+extra_darwin_ldflags_libgfortran += -Wc,-nodefaultrpaths 
-+extra_darwin_ldflags_libgfortran += -Wl,-rpath,@loader_path
-+endif
- 
- gfor_c_HEADERS = ISO_Fortran_binding.h
- gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
-@@ -50,7 +55,7 @@ libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS)
- libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
- 	$(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \
- 	$(HWCAP_LDFLAGS) \
--	$(LIBM) $(extra_ldflags_libgfortran) \
-+	$(LIBM) $(extra_darwin_ldflags_libgfortran) \
- 	$(version_arg) -Wc,-shared-libgcc
- libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
- 
-diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in
-index 7ac6bfba657..52dd5f1819e 100644
---- a/libgfortran/Makefile.in
-+++ b/libgfortran/Makefile.in
-@@ -91,8 +91,10 @@ POST_UNINSTALL = :
- build_triplet = @build@
- host_triplet = @host@
- target_triplet = @target@
--@LIBGFOR_MINIMAL_TRUE@am__append_1 = -DLIBGFOR_MINIMAL
--@LIBGFOR_MINIMAL_FALSE@am__append_2 = \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -Wc,-nodefaultrpaths \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
-+@LIBGFOR_MINIMAL_TRUE@am__append_2 = -DLIBGFOR_MINIMAL
-+@LIBGFOR_MINIMAL_FALSE@am__append_3 = \
- @LIBGFOR_MINIMAL_FALSE@io/close.c \
- @LIBGFOR_MINIMAL_FALSE@io/file_pos.c \
- @LIBGFOR_MINIMAL_FALSE@io/format.c \
-@@ -110,7 +112,7 @@ target_triplet = @target@
- @LIBGFOR_MINIMAL_FALSE@io/fbuf.c \
- @LIBGFOR_MINIMAL_FALSE@io/async.c
- 
--@LIBGFOR_MINIMAL_FALSE@am__append_3 = \
-+@LIBGFOR_MINIMAL_FALSE@am__append_4 = \
- @LIBGFOR_MINIMAL_FALSE@intrinsics/access.c \
- @LIBGFOR_MINIMAL_FALSE@intrinsics/c99_functions.c \
- @LIBGFOR_MINIMAL_FALSE@intrinsics/chdir.c \
-@@ -143,9 +145,9 @@ target_triplet = @target@
- @LIBGFOR_MINIMAL_FALSE@intrinsics/umask.c \
- @LIBGFOR_MINIMAL_FALSE@intrinsics/unlink.c
- 
--@IEEE_SUPPORT_TRUE@am__append_4 = ieee/ieee_helper.c
--@LIBGFOR_MINIMAL_TRUE@am__append_5 = runtime/minimal.c
--@LIBGFOR_MINIMAL_FALSE@am__append_6 = \
-+@IEEE_SUPPORT_TRUE@am__append_5 = ieee/ieee_helper.c
-+@LIBGFOR_MINIMAL_TRUE@am__append_6 = runtime/minimal.c
-+@LIBGFOR_MINIMAL_FALSE@am__append_7 = \
- @LIBGFOR_MINIMAL_FALSE@runtime/backtrace.c \
- @LIBGFOR_MINIMAL_FALSE@runtime/convert_char.c \
- @LIBGFOR_MINIMAL_FALSE@runtime/environ.c \
-@@ -157,7 +159,7 @@ target_triplet = @target@
- 
- 
- # dummy sources for libtool
--@onestep_TRUE@am__append_7 = libgfortran_c.c libgfortran_f.f90
-+@onestep_TRUE@am__append_8 = libgfortran_c.c libgfortran_f.f90
- subdir = .
- ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
- am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
-@@ -589,7 +591,7 @@ AMTAR = @AMTAR@
++# This file is part of GCC.
++#
++# GCC is free software; you can redistribute it and/or modify it
++# under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3, or (at your option)
++# any later version.
++#
++# GCC is distributed in the hope that it will be useful, but
++# WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++# General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with GCC; see the file COPYING3.  If not see
++# .
++
++LIB2ADD += $(srcdir)/config/i386/heap-trampoline.c
++HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=10.8
+diff --git a/libgcc/config/t-darwin-rpath b/libgcc/config/t-darwin-rpath
+new file mode 100644
+index 00000000000..e73d7f378b0
+--- /dev/null
++++ b/libgcc/config/t-darwin-rpath
+@@ -0,0 +1,2 @@
++# Use @rpath and add a search path to exes and dylibs that depend on this.
++SHLIB_RPATH = @rpath
+diff --git a/libgcc/config/t-slibgcc-darwin b/libgcc/config/t-slibgcc-darwin
+index cb0cbbdb1c5..da4886848e8 100644
+--- a/libgcc/config/t-slibgcc-darwin
++++ b/libgcc/config/t-slibgcc-darwin
+@@ -1,4 +1,4 @@
+-# Build a shared libgcc library with the darwin linker.
++# Build a shared libgcc library able to use embedded runpaths.
  
- # Some targets require additional compiler options for IEEE compatibility.
- AM_CFLAGS = @AM_CFLAGS@ -fcx-fortran-rules $(SECTION_FLAGS) \
--	$(IEEE_FLAGS) $(am__append_1)
-+	$(IEEE_FLAGS) $(am__append_2)
- AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
- AM_FCFLAGS = @AM_FCFLAGS@ $(IEEE_FLAGS)
- AR = @AR@
-@@ -748,6 +750,8 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
- @LIBGFOR_USE_SYMVER_FALSE@version_dep = 
- @LIBGFOR_USE_SYMVER_GNU_TRUE@@LIBGFOR_USE_SYMVER_TRUE@version_dep = gfortran.ver
- @LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@version_dep = gfortran.ver-sun gfortran.ver
-+extra_darwin_ldflags_libgfortran = @extra_ldflags_libgfortran@ \
-+	$(am__append_1)
- gfor_c_HEADERS = ISO_Fortran_binding.h
- gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
- LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
-@@ -759,7 +763,7 @@ libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS)
- libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
- 	$(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \
- 	$(HWCAP_LDFLAGS) \
--	$(LIBM) $(extra_ldflags_libgfortran) \
-+	$(LIBM) $(extra_darwin_ldflags_libgfortran) \
- 	$(version_arg) -Wc,-shared-libgcc
+ SHLIB_SOVERSION = 1.1
+ SHLIB_SO_MINVERSION = 1
+@@ -6,7 +6,6 @@ SHLIB_VERSTRING = -compatibility_version $(SHLIB_SO_MINVERSION) \
+ 		  -current_version $(SHLIB_SOVERSION)
+ SHLIB_EXT = .dylib
+ SHLIB_LC = -lSystem
+-SHLIB_INSTALL_DIR = $(slibdir)
  
- libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
-@@ -780,7 +784,7 @@ AM_CPPFLAGS = -iquote$(srcdir)/io -I$(srcdir)/$(MULTISRCTOP)../gcc \
- 	      -I$(MULTIBUILDTOP)../libbacktrace \
- 	      -I../libbacktrace
+ SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
+ SHLIB_MKMAP_OPTS = -v leading_underscore=1
+@@ -23,11 +22,16 @@ SHLIB_SONAME = @shlib_base_name@$(SHLIB_EXT)
+ # subdir.  The code under MULTIBUILDTOP combines these into a single FAT
+ # library, that is what we eventually install.
  
--gfor_io_src = io/size_from_kind.c $(am__append_2)
-+gfor_io_src = io/size_from_kind.c $(am__append_3)
- gfor_io_headers = \
- io/io.h \
- io/fbuf.h \
-@@ -802,7 +806,7 @@ gfor_helper_src = intrinsics/associated.c intrinsics/abort.c \
- 	intrinsics/selected_int_kind.f90 \
- 	intrinsics/selected_real_kind.f90 intrinsics/trigd.c \
- 	intrinsics/unpack_generic.c runtime/in_pack_generic.c \
--	runtime/in_unpack_generic.c $(am__append_3) $(am__append_4)
-+	runtime/in_unpack_generic.c $(am__append_4) $(am__append_5)
- @IEEE_SUPPORT_TRUE@gfor_ieee_helper_src = ieee/ieee_helper.c
- @IEEE_SUPPORT_FALSE@gfor_ieee_src = 
- @IEEE_SUPPORT_TRUE@gfor_ieee_src = \
-@@ -811,8 +815,8 @@ gfor_helper_src = intrinsics/associated.c intrinsics/abort.c \
- @IEEE_SUPPORT_TRUE@ieee/ieee_features.F90
++# When enable_darwin_at_rpath is true, use @rpath instead of $(slibdir) for
++# this and dylibs that depend on this.  So this def must come first and be
++# overridden in a make fragment that depends on the rpath setting.
++SHLIB_RPATH = $(slibdir)
++
+ SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
+-	-install_name $(SHLIB_INSTALL_DIR)/$(SHLIB_INSTALL_NAME) \
++	-install_name $(SHLIB_RPATH)/$(SHLIB_INSTALL_NAME) \
+ 	-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
+ 	-Wl,-exported_symbols_list,$(SHLIB_MAP) \
+-	$(SHLIB_VERSTRING) \
++	$(SHLIB_VERSTRING) -nodefaultrpaths \
+ 	@multilib_flags@ @shlib_objs@ $(SHLIB_LC)
  
- gfor_src = runtime/bounds.c runtime/compile_options.c runtime/memory.c \
--	runtime/string.c runtime/select.c $(am__append_5) \
--	$(am__append_6)
-+	runtime/string.c runtime/select.c $(am__append_6) \
-+	$(am__append_7)
- i_all_c = \
- $(srcdir)/generated/all_l1.c \
- $(srcdir)/generated/all_l2.c \
-@@ -1652,7 +1656,7 @@ intrinsics/random_init.f90
+ # we do our own thing
+@@ -63,9 +67,9 @@ EHS_INSTNAME = libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
+ libgcc_ehs$(SHLIB_EXT): $(LIBEHSOBJS) $(extra-parts)
+ 	mkdir -p $(MULTIDIR)
+ 	$(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
+-	-install_name $(SHLIB_INSTALL_DIR)/$(EHS_INSTNAME) \
++	-install_name $(SHLIB_RPATH)/$(EHS_INSTNAME) \
+ 	-o $(MULTIDIR)/libgcc_ehs$(SHLIB_EXT) $(SHLIB_VERSTRING) \
+-	$(LIBEHSOBJS) $(SHLIB_LC)
++	-nodefaultrpaths $(LIBEHSOBJS) $(SHLIB_LC)
  
- BUILT_SOURCES = $(gfor_built_src) $(gfor_built_specific_src) \
- 	$(gfor_built_specific2_src) $(gfor_misc_specifics) \
--	$(am__append_7)
-+	$(am__append_8)
- prereq_SRC = $(gfor_src) $(gfor_built_src) $(gfor_io_src) \
- 	$(gfor_helper_src) $(gfor_ieee_src) $(gfor_io_headers) $(gfor_specific_src)
+ all: libgcc_ehs$(SHLIB_EXT)
  
-diff --git a/libgfortran/configure b/libgfortran/configure
-index ae64dca3114..f288af81ff5 100755
---- a/libgfortran/configure
-+++ b/libgfortran/configure
-@@ -655,6 +655,8 @@ extra_ldflags_libgfortran
- ac_ct_FC
- FCFLAGS
- FC
-+ENABLE_DARWIN_AT_RPATH_FALSE
-+ENABLE_DARWIN_AT_RPATH_TRUE
- enable_static
+@@ -122,12 +126,12 @@ libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
+ 	  cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT)  \
+ 	    ./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
+ 	  arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
+-	  $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
++	  $(CC) -arch $${arch} -nodefaultlibs -dynamiclib -nodefaultrpaths \
+ 	    -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
+ 	    -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
+ 	    -Wl,-reexport_library,libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
+-	    -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
+-	    -compatibility_version 1 -current_version 1 ; \
++	    -install_name $(SHLIB_RPATH)/libgcc_s.1.dylib \
++	    -compatibility_version 1 -current_version 1.1 ; \
+ 	done
+ 	$(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
+ 	rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+@@ -141,13 +145,13 @@ libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
+ 	  cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT)  \
+ 	    ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
+ 	  arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
+-	  $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
++	  $(CC) -arch $${arch} -nodefaultlibs -dynamiclib -nodefaultrpaths \
+ 	    -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
+ 	    -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
+ 	    -lSystem \
+ 	    -Wl,-reexported_symbols_list,$(srcdir)/config/darwin-unwind.ver \
+-	    -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
+-	    -compatibility_version 1 -current_version 1 ; \
++	    -install_name $(SHLIB_RPATH)/libgcc_s.1.dylib \
++	    -compatibility_version 1 -current_version 1.1 ; \
+ 	done
+ 	$(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
+ 	rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+diff --git a/libgcc/configure b/libgcc/configure
+index be5d45f1755..85fc0b08c82 100755
+--- a/libgcc/configure
++++ b/libgcc/configure
+@@ -630,7 +630,6 @@ LIPO
+ AR
+ toolexeclibdir
+ toolexecdir
+-enable_gcov
+ target_subdir
+ host_subdir
+ build_subdir
+@@ -654,6 +653,8 @@ build_cpu
+ build
+ with_aix_soname
+ enable_vtable_verify
++enable_gcov
++off_stack_trampolines
  enable_shared
- lt_host_flags
-@@ -824,6 +826,7 @@ enable_static
- with_pic
- enable_fast_install
- enable_libtool_lock
-+enable_darwin_at_rpath
+ libgcc_topdir
+ target_alias
+@@ -701,6 +702,8 @@ with_target_subdir
+ with_cross_host
+ with_ld
+ enable_shared
++enable_off_stack_trampolines
++enable_gcov
+ enable_vtable_verify
+ with_aix_soname
+ enable_version_specific_runtime_libs
+@@ -708,7 +711,6 @@ with_toolexeclibdir
+ with_slibdir
+ enable_maintainer_mode
+ with_build_libsubdir
+-enable_gcov
  enable_largefile
- enable_libquadmath_support
- with_gcc_major_version_only
-@@ -1479,6 +1482,8 @@ Optional Features:
-   --enable-fast-install[=PKGS]
-                           optimize for fast installation [default=yes]
-   --disable-libtool-lock  avoid locking (might break parallel builds)
-+  --enable-darwin-at-path install libraries with @rpath/library-name, requires
-+                          rpaths to be added to executables
+ enable_decimal_float
+ with_system_libunwind
+@@ -1342,12 +1344,15 @@ Optional Features:
+   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+   --disable-shared        don't provide a shared libgcc
++  --enable-off-stack-trampolines
++                  Specify whether to support generating off-stack trampolines
++
++  --disable-gcov          don't provide libgcov and related host tools
+   --enable-vtable-verify    Enable vtable verification feature
+   --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory
+   --enable-maintainer-mode
+                           enable make rules and dependencies not useful (and
+                           sometimes confusing) to the casual installer
+-  --disable-gcov          don't provide libgcov and related host tools
    --disable-largefile     omit support for large files
-   --disable-libquadmath-support
-                           disable libquadmath support for Fortran
-@@ -10939,6 +10944,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-     darwin* | rhapsody*)
+   --enable-decimal-float={no,yes,bid,dpd}
+ 			enable decimal float extension to C.  Selecting 'bid'
+@@ -2252,6 +2257,48 @@ fi
  
  
-+
-+  # Publish an arg to allow the user to select that Darwin host (and target)
-+  # libraries should be given install-names like @rpath/libfoo.dylib.  This
-+  # requires that the user of the library then adds an 'rpath' to the DSO that
-+  # needs access.
-+  # NOTE: there are defaults below, for systems that support rpaths.  The person
-+  # configuring can override the defaults for any system version that supports
-+  # them - they are, however, forced off for system versions without support.
-+  # Check whether --enable-darwin-at-rpath was given.
-+if test "${enable_darwin_at_rpath+set}" = set; then :
-+  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
-+    # This is not supported before macOS 10.5 / Darwin9.
-+    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
-+	enable_darwin_at_rpath=no
-+      ;;
-+    esac
-+   fi
+ 
++# Check whether --enable-off-stack-trampolines was given.
++if test "${enable_off_stack_trampolines+set}" = set; then :
++  enableval=$enable_off_stack_trampolines;
++case "$target" in
++  x86_64-*-linux* | x86_64-*-darwin1[4-9]* | x86_64-*-darwin2*)
++    off_stack_trampolines=$enableval
++    ;;
++  aarch64*-*-linux* )
++    off_stack_trampolines=$enableval
++    ;;
++  aarch64*-*darwin* )
++    off_stack_trampolines=$enableval
++    ;;
++  *)
++    as_fn_error $? "Configure option --enable-off-stack-trampolines is not supported \
++for this platform" "$LINENO" 5
++    off_stack_trampolines=no
++    ;;
++esac
 +else
-+  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+       enable_darwin_at_rpath=no
-+       ;;
-+
-+    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
-+    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
-+    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
-+      enable_darwin_at_rpath=yes
-+      ;;
-+    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
-+    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
-+
-+    esac
 +
++case "$target" in
++  *-*-darwin2*)
++    off_stack_trampolines=yes
++    ;;
++  *)
++    off_stack_trampolines=no
++    ;;
++esac
 +fi
 +
 +
-   archive_cmds_need_lc=no
-   hardcode_direct=no
-   hardcode_automatic=yes
-@@ -10956,10 +11002,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-   esac
-   if test "$_lt_dar_can_shared" = "yes"; then
-     output_verbose_link_cmd=func_echo_all
--    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    fi
- 
-   else
-   ld_shlibs=no
-@@ -12766,7 +12821,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 12769 "configure"
-+#line 12824 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -12872,7 +12927,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 12875 "configure"
-+#line 12930 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -13274,6 +13329,14 @@ esac
- 
- 
- 
-+ if test x$enable_darwin_at_rpath = xyes; then
-+  ENABLE_DARWIN_AT_RPATH_TRUE=
-+  ENABLE_DARWIN_AT_RPATH_FALSE='#'
++
++# Check whether --enable-gcov was given.
++if test "${enable_gcov+set}" = set; then :
++  enableval=$enable_gcov;
 +else
-+  ENABLE_DARWIN_AT_RPATH_TRUE='#'
-+  ENABLE_DARWIN_AT_RPATH_FALSE=
++  enable_gcov=yes
 +fi
 +
- #AC_MSG_NOTICE([====== Finished libtool configuration]) ; sleep 10
- 
- # We need gfortran to compile parts of the library
-@@ -14917,6 +14980,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-     darwin* | rhapsody*)
- 
- 
-+
-+  # Publish an arg to allow the user to select that Darwin host (and target)
-+  # libraries should be given install-names like @rpath/libfoo.dylib.  This
-+  # requires that the user of the library then adds an 'rpath' to the DSO that
-+  # needs access.
-+  # NOTE: there are defaults below, for systems that support rpaths.  The person
-+  # configuring can override the defaults for any system version that supports
-+  # them - they are, however, forced off for system versions without support.
-+  # Check whether --enable-darwin-at-rpath was given.
-+if test "${enable_darwin_at_rpath+set}" = set; then :
-+  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
-+    # This is not supported before macOS 10.5 / Darwin9.
-+    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
-+	enable_darwin_at_rpath=no
-+      ;;
-+    esac
-+   fi
-+else
-+  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+       enable_darwin_at_rpath=no
-+       ;;
 +
-+    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
-+    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
-+    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
-+      enable_darwin_at_rpath=yes
-+      ;;
-+    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
-+    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
 +
-+    esac
+ # Check whether --enable-vtable-verify was given.
+ if test "${enable_vtable_verify+set}" = set; then :
+   enableval=$enable_vtable_verify; case "$enableval" in
+diff --git a/libgcc/configure.ac b/libgcc/configure.ac
+index 2fc9d5d7c93..7d11bf00142 100644
+--- a/libgcc/configure.ac
++++ b/libgcc/configure.ac
+@@ -68,6 +68,40 @@ AC_ARG_ENABLE(shared,
+ ], [enable_shared=yes])
+ AC_SUBST(enable_shared)
+ 
++AC_ARG_ENABLE([off-stack-trampolines],
++  [AS_HELP_STRING([--enable-off-stack-trampolines]
++                  [Specify whether to support generating off-stack trampolines])],[
++case "$target" in
++  x86_64-*-linux* | x86_64-*-darwin1[[4-9]]* | x86_64-*-darwin2*)
++    off_stack_trampolines=$enableval
++    ;;
++  aarch64*-*-linux* )
++    off_stack_trampolines=$enableval
++    ;;
++  aarch64*-*darwin* )
++    off_stack_trampolines=$enableval
++    ;;
++  *)
++    AC_MSG_ERROR([Configure option --enable-off-stack-trampolines is not supported \
++for this platform])
++    off_stack_trampolines=no
++    ;;
++esac],[
++case "$target" in
++  *-*-darwin2*)
++    off_stack_trampolines=yes
++    ;;
++  *)
++    off_stack_trampolines=no
++    ;;
++esac])
++AC_SUBST(off_stack_trampolines)
 +
-+fi
++AC_ARG_ENABLE(gcov,
++[  --disable-gcov          don't provide libgcov and related host tools],
++[], [enable_gcov=yes])
++AC_SUBST(enable_gcov)
 +
+ AC_ARG_ENABLE(vtable-verify,
+ [  --enable-vtable-verify    Enable vtable verification feature ],
+ [case "$enableval" in
+diff --git a/libgcc/libgcc-std.ver.in b/libgcc/libgcc-std.ver.in
+index c4f87a50e70..a48f4899eb6 100644
+--- a/libgcc/libgcc-std.ver.in
++++ b/libgcc/libgcc-std.ver.in
+@@ -1943,4 +1943,7 @@ GCC_4.8.0 {
+ GCC_7.0.0 {
+   __PFX__divmoddi4
+   __PFX__divmodti4
 +
-   archive_cmds_need_lc_FC=no
-   hardcode_direct_FC=no
-   hardcode_automatic_FC=yes
-@@ -14934,10 +15038,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-   esac
-   if test "$_lt_dar_can_shared" = "yes"; then
-     output_verbose_link_cmd=func_echo_all
--    archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    fi
- 
-   else
-   ld_shlibs_FC=no
-@@ -16190,9 +16303,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
- 
- 
- # extra LD Flags which are required for targets
-+extra_ldflags_libgfortran=
- case "${host}" in
--  *-darwin*)
--    # Darwin needs -single_module when linking libgfortran
-+  *-*-darwin[4567]*)
-+    # Earlier Darwin needs -single_module when linking libgfortran
-     extra_ldflags_libgfortran=-Wl,-single_module
-     ;;
- esac
-@@ -28519,6 +28633,10 @@ if test -z "${HAVE_HWCAP_TRUE}" && test -z "${HAVE_HWCAP_FALSE}"; then
-   as_fn_error $? "conditional \"HAVE_HWCAP\" was never defined.
- Usually this means the macro was only invoked conditionally." "$LINENO" 5
- fi
-+if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
-+  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
-+Usually this means the macro was only invoked conditionally." "$LINENO" 5
-+fi
- if test -z "${LIBGFOR_BUILD_QUAD_TRUE}" && test -z "${LIBGFOR_BUILD_QUAD_FALSE}"; then
-   as_fn_error $? "conditional \"LIBGFOR_BUILD_QUAD\" was never defined.
- Usually this means the macro was only invoked conditionally." "$LINENO" 5
-diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
-index 97cc490cb5e..a21f56648a2 100644
---- a/libgfortran/configure.ac
-+++ b/libgfortran/configure.ac
-@@ -282,6 +282,7 @@ LT_LIB_M
- ACX_LT_HOST_FLAGS
- AC_SUBST(enable_shared)
- AC_SUBST(enable_static)
-+AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
- #AC_MSG_NOTICE([====== Finished libtool configuration]) ; sleep 10
++  __builtin_nested_func_ptr_created
++  __builtin_nested_func_ptr_deleted
+ }
+diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h
+index 3ec9bbd8164..ac7eaab4f01 100644
+--- a/libgcc/libgcc2.h
++++ b/libgcc/libgcc2.h
+@@ -29,6 +29,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+ #pragma GCC visibility push(default)
+ #endif
  
- # We need gfortran to compile parts of the library
-@@ -290,9 +291,10 @@ FC="$GFORTRAN"
- AC_PROG_FC(gfortran)
++extern void __builtin_nested_func_ptr_created (void *, void *, void **);
++extern void __builtin_nested_func_ptr_deleted (void);
++
+ extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
+ extern void __clear_cache (void *, void *);
+ extern void __eprintf (const char *, const char *, unsigned int, const char *)
+diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
+index 454ad12e701..2bc2e57919d 100644
+--- a/libgfortran/Makefile.am
++++ b/libgfortran/Makefile.am
+@@ -37,6 +37,11 @@ else
+ version_arg =
+ version_dep =
+ endif
++extra_darwin_ldflags_libgfortran = @extra_ldflags_libgfortran@
++if ENABLE_DARWIN_AT_RPATH
++extra_darwin_ldflags_libgfortran += -Wc,-nodefaultrpaths 
++extra_darwin_ldflags_libgfortran += -Wl,-rpath,@loader_path
++endif
  
- # extra LD Flags which are required for targets
-+extra_ldflags_libgfortran=
- case "${host}" in
--  *-darwin*)
--    # Darwin needs -single_module when linking libgfortran
-+  *-*-darwin[[4567]]*)
-+    # Earlier Darwin needs -single_module when linking libgfortran
-     extra_ldflags_libgfortran=-Wl,-single_module
-     ;;
- esac
-diff --git a/libgo/configure b/libgo/configure
-index ffe17c9be55..de5c1ac9b3d 100755
---- a/libgo/configure
-+++ b/libgo/configure
-@@ -708,6 +708,8 @@ glibgo_toolexecdir
- WERROR
- WARN_FLAGS
- CC_FOR_BUILD
-+ENABLE_DARWIN_AT_RPATH_FALSE
-+ENABLE_DARWIN_AT_RPATH_TRUE
- enable_static
- enable_shared
- CPP
-@@ -11544,7 +11546,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 11547 "configure"
-+#line 11549 "configure"
- #include "confdefs.h"
+ gfor_c_HEADERS = ISO_Fortran_binding.h
+ gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
+@@ -50,7 +55,7 @@ libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS)
+ libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
+ 	$(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \
+ 	$(HWCAP_LDFLAGS) \
+-	$(LIBM) $(extra_ldflags_libgfortran) \
++	$(LIBM) $(extra_darwin_ldflags_libgfortran) \
+ 	$(version_arg) -Wc,-shared-libgcc
+ libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
  
- #if HAVE_DLFCN_H
-@@ -11650,7 +11652,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 11653 "configure"
-+#line 11655 "configure"
- #include "confdefs.h"
+diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in
+index 23df0761096..ed0d05f502a 100644
+--- a/libgfortran/Makefile.in
++++ b/libgfortran/Makefile.in
+@@ -91,8 +91,10 @@ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
+ target_triplet = @target@
+-@LIBGFOR_MINIMAL_TRUE@am__append_1 = -DLIBGFOR_MINIMAL
+-@LIBGFOR_MINIMAL_FALSE@am__append_2 = \
++@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -Wc,-nodefaultrpaths \
++@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
++@LIBGFOR_MINIMAL_TRUE@am__append_2 = -DLIBGFOR_MINIMAL
++@LIBGFOR_MINIMAL_FALSE@am__append_3 = \
+ @LIBGFOR_MINIMAL_FALSE@io/close.c \
+ @LIBGFOR_MINIMAL_FALSE@io/file_pos.c \
+ @LIBGFOR_MINIMAL_FALSE@io/format.c \
+@@ -110,7 +112,7 @@ target_triplet = @target@
+ @LIBGFOR_MINIMAL_FALSE@io/fbuf.c \
+ @LIBGFOR_MINIMAL_FALSE@io/async.c
  
- #if HAVE_DLFCN_H
-@@ -13779,6 +13781,14 @@ CC="$lt_save_CC"
+-@LIBGFOR_MINIMAL_FALSE@am__append_3 = \
++@LIBGFOR_MINIMAL_FALSE@am__append_4 = \
+ @LIBGFOR_MINIMAL_FALSE@intrinsics/access.c \
+ @LIBGFOR_MINIMAL_FALSE@intrinsics/c99_functions.c \
+ @LIBGFOR_MINIMAL_FALSE@intrinsics/chdir.c \
+@@ -143,9 +145,9 @@ target_triplet = @target@
+ @LIBGFOR_MINIMAL_FALSE@intrinsics/umask.c \
+ @LIBGFOR_MINIMAL_FALSE@intrinsics/unlink.c
  
+-@IEEE_SUPPORT_TRUE@am__append_4 = ieee/ieee_helper.c
+-@LIBGFOR_MINIMAL_TRUE@am__append_5 = runtime/minimal.c
+-@LIBGFOR_MINIMAL_FALSE@am__append_6 = \
++@IEEE_SUPPORT_TRUE@am__append_5 = ieee/ieee_helper.c
++@LIBGFOR_MINIMAL_TRUE@am__append_6 = runtime/minimal.c
++@LIBGFOR_MINIMAL_FALSE@am__append_7 = \
+ @LIBGFOR_MINIMAL_FALSE@runtime/backtrace.c \
+ @LIBGFOR_MINIMAL_FALSE@runtime/convert_char.c \
+ @LIBGFOR_MINIMAL_FALSE@runtime/environ.c \
+@@ -157,7 +159,7 @@ target_triplet = @target@
  
  
-+ if test x$enable_darwin_at_rpath = xyes; then
-+  ENABLE_DARWIN_AT_RPATH_TRUE=
-+  ENABLE_DARWIN_AT_RPATH_FALSE='#'
-+else
-+  ENABLE_DARWIN_AT_RPATH_TRUE='#'
-+  ENABLE_DARWIN_AT_RPATH_FALSE=
-+fi
-+
+ # dummy sources for libtool
+-@onestep_TRUE@am__append_7 = libgfortran_c.c libgfortran_f.f90
++@onestep_TRUE@am__append_8 = libgfortran_c.c libgfortran_f.f90
+ subdir = .
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
+@@ -589,7 +591,7 @@ AMTAR = @AMTAR@
  
- CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
+ # Some targets require additional compiler options for IEEE compatibility.
+ AM_CFLAGS = @AM_CFLAGS@ -fcx-fortran-rules $(SECTION_FLAGS) \
+-	$(IEEE_FLAGS) $(am__append_1)
++	$(IEEE_FLAGS) $(am__append_2)
+ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+ AM_FCFLAGS = @AM_FCFLAGS@ $(IEEE_FLAGS)
+ AR = @AR@
+@@ -749,6 +751,8 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+ @LIBGFOR_USE_SYMVER_FALSE@version_dep = 
+ @LIBGFOR_USE_SYMVER_GNU_TRUE@@LIBGFOR_USE_SYMVER_TRUE@version_dep = gfortran.ver
+ @LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@version_dep = gfortran.ver-sun gfortran.ver
++extra_darwin_ldflags_libgfortran = @extra_ldflags_libgfortran@ \
++	$(am__append_1)
+ gfor_c_HEADERS = ISO_Fortran_binding.h
+ gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
+ LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
+@@ -760,7 +764,7 @@ libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS)
+ libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
+ 	$(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \
+ 	$(HWCAP_LDFLAGS) \
+-	$(LIBM) $(extra_ldflags_libgfortran) \
++	$(LIBM) $(extra_darwin_ldflags_libgfortran) \
+ 	$(version_arg) -Wc,-shared-libgcc
  
-@@ -16321,6 +16331,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
-   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
- Usually this means the macro was only invoked conditionally." "$LINENO" 5
- fi
-+if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
-+  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
-+Usually this means the macro was only invoked conditionally." "$LINENO" 5
-+fi
- if test -z "${USE_LIBFFI_TRUE}" && test -z "${USE_LIBFFI_FALSE}"; then
-   as_fn_error $? "conditional \"USE_LIBFFI\" was never defined.
- Usually this means the macro was only invoked conditionally." "$LINENO" 5
-diff --git a/libgo/configure.ac b/libgo/configure.ac
-index 7e2b98ba67c..7b0222bb620 100644
---- a/libgo/configure.ac
-+++ b/libgo/configure.ac
-@@ -53,6 +53,7 @@ AC_LIBTOOL_DLOPEN
- AM_PROG_LIBTOOL
- AC_SUBST(enable_shared)
- AC_SUBST(enable_static)
-+AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
+ libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
+@@ -781,7 +785,7 @@ AM_CPPFLAGS = -iquote$(srcdir)/io -I$(srcdir)/$(MULTISRCTOP)../gcc \
+ 	      -I$(MULTIBUILDTOP)../libbacktrace \
+ 	      -I../libbacktrace
  
- CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
- AC_SUBST(CC_FOR_BUILD)
-diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
-index f8b2a06d63e..81ba6c634fa 100644
---- a/libgomp/Makefile.am
-+++ b/libgomp/Makefile.am
-@@ -53,9 +53,14 @@ else
- libgomp_version_script =
- libgomp_version_dep =
- endif
-+
- libgomp_version_info = -version-info $(libtool_VERSION)
-+if ENABLE_DARWIN_AT_RPATH
-+libgomp_darwin_rpath = -Wc,-nodefaultrpaths
-+libgomp_darwin_rpath += -Wl,-rpath,@loader_path
-+endif
- libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
--        $(lt_host_flags)
-+        $(lt_host_flags) $(libgomp_darwin_rpath)
- libgomp_la_DEPENDENCIES = $(libgomp_version_dep)
- libgomp_la_LINK = $(LINK) $(libgomp_la_LDFLAGS)
+-gfor_io_src = io/size_from_kind.c $(am__append_2)
++gfor_io_src = io/size_from_kind.c $(am__append_3)
+ gfor_io_headers = \
+ io/io.h \
+ io/fbuf.h \
+@@ -803,7 +807,7 @@ gfor_helper_src = intrinsics/associated.c intrinsics/abort.c \
+ 	intrinsics/selected_int_kind.f90 \
+ 	intrinsics/selected_real_kind.f90 intrinsics/trigd.c \
+ 	intrinsics/unpack_generic.c runtime/in_pack_generic.c \
+-	runtime/in_unpack_generic.c $(am__append_3) $(am__append_4)
++	runtime/in_unpack_generic.c $(am__append_4) $(am__append_5)
+ @IEEE_SUPPORT_TRUE@gfor_ieee_helper_src = ieee/ieee_helper.c
+ @IEEE_SUPPORT_FALSE@gfor_ieee_src = 
+ @IEEE_SUPPORT_TRUE@gfor_ieee_src = \
+@@ -812,8 +816,8 @@ gfor_helper_src = intrinsics/associated.c intrinsics/abort.c \
+ @IEEE_SUPPORT_TRUE@ieee/ieee_features.F90
  
-diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
-index 6f0cb716135..5cfb149c2ba 100644
---- a/libgomp/Makefile.in
-+++ b/libgomp/Makefile.in
-@@ -546,8 +546,11 @@ nodist_toolexeclib_HEADERS = libgomp.spec
- @LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_dep = libgomp.ver
- @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_dep = libgomp.ver-sun
- libgomp_version_info = -version-info $(libtool_VERSION)
-+@ENABLE_DARWIN_AT_RPATH_TRUE@libgomp_darwin_rpath =  \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wc,-nodefaultrpaths \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
- libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
--        $(lt_host_flags)
-+        $(lt_host_flags) $(libgomp_darwin_rpath)
+ gfor_src = runtime/bounds.c runtime/compile_options.c runtime/memory.c \
+-	runtime/string.c runtime/select.c $(am__append_5) \
+-	$(am__append_6)
++	runtime/string.c runtime/select.c $(am__append_6) \
++	$(am__append_7)
+ i_all_c = \
+ $(srcdir)/generated/all_l1.c \
+ $(srcdir)/generated/all_l2.c \
+@@ -1653,7 +1657,7 @@ intrinsics/random_init.f90
  
- libgomp_la_DEPENDENCIES = $(libgomp_version_dep)
- libgomp_la_LINK = $(LINK) $(libgomp_la_LDFLAGS)
-diff --git a/libgomp/configure b/libgomp/configure
-index 85fdb4d3f48..71b5987dc9a 100755
---- a/libgomp/configure
-+++ b/libgomp/configure
-@@ -692,6 +692,8 @@ FC
- MAINT
- MAINTAINER_MODE_FALSE
- MAINTAINER_MODE_TRUE
+ BUILT_SOURCES = $(gfor_built_src) $(gfor_built_specific_src) \
+ 	$(gfor_built_specific2_src) $(gfor_misc_specifics) \
+-	$(am__append_7)
++	$(am__append_8)
+ prereq_SRC = $(gfor_src) $(gfor_built_src) $(gfor_io_src) \
+ 	$(gfor_helper_src) $(gfor_ieee_src) $(gfor_io_headers) $(gfor_specific_src)
+ 
+diff --git a/libgfortran/configure b/libgfortran/configure
+index d7c3a5e27a0..57a2c9d4946 100755
+--- a/libgfortran/configure
++++ b/libgfortran/configure
+@@ -654,6 +654,8 @@ extra_ldflags_libgfortran
+ ac_ct_FC
+ FCFLAGS
+ FC
 +ENABLE_DARWIN_AT_RPATH_FALSE
 +ENABLE_DARWIN_AT_RPATH_TRUE
  enable_static
  enable_shared
  lt_host_flags
-@@ -832,6 +834,7 @@ with_pic
+@@ -823,6 +825,7 @@ enable_static
+ with_pic
  enable_fast_install
- with_gnu_ld
  enable_libtool_lock
 +enable_darwin_at_rpath
- enable_maintainer_mode
- with_cuda_driver
- with_cuda_driver_include
-@@ -1493,6 +1496,8 @@ Optional Features:
+ enable_largefile
+ enable_libquadmath_support
+ with_gcc_major_version_only
+@@ -1478,6 +1481,8 @@ Optional Features:
    --enable-fast-install[=PKGS]
                            optimize for fast installation [default=yes]
    --disable-libtool-lock  avoid locking (might break parallel builds)
 +  --enable-darwin-at-path install libraries with @rpath/library-name, requires
 +                          rpaths to be added to executables
-   --enable-maintainer-mode
-                           enable make rules and dependencies not useful (and
-                           sometimes confusing) to the casual installer
-@@ -9625,6 +9630,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+   --disable-largefile     omit support for large files
+   --disable-libquadmath-support
+                           disable libquadmath support for Fortran
+@@ -9235,7 +9240,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -10945,6 +10950,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -10202,8 +7515,9 @@ index 85fdb4d3f48..71b5987dc9a 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -10211,15 +7525,16 @@ index 85fdb4d3f48..71b5987dc9a 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -10233,49 +7548,41 @@ index 85fdb4d3f48..71b5987dc9a 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -9642,10 +9688,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -10962,9 +11010,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -11431,7 +11486,7 @@ else
+@@ -12791,7 +12843,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11434 "configure"
-+#line 11489 "configure"
+-#line 12794 "configure"
++#line 12846 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11537,7 +11592,7 @@ else
+@@ -12897,7 +12949,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11540 "configure"
-+#line 11595 "configure"
+-#line 12900 "configure"
++#line 12952 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11798,6 +11853,14 @@ esac
+@@ -13299,6 +13351,14 @@ esac
  
  
  
@@ -10287,10 +7594,10 @@ index 85fdb4d3f48..71b5987dc9a 100755
 +  ENABLE_DARWIN_AT_RPATH_FALSE=
 +fi
 +
+ #AC_MSG_NOTICE([====== Finished libtool configuration]) ; sleep 10
  
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
-@@ -13473,6 +13536,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+ # We need gfortran to compile parts of the library
+@@ -14942,6 +15002,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -10307,8 +7614,9 @@ index 85fdb4d3f48..71b5987dc9a 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -10316,15 +7624,16 @@ index 85fdb4d3f48..71b5987dc9a 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -10338,332 +7647,181 @@ index 85fdb4d3f48..71b5987dc9a 100755
    archive_cmds_need_lc_FC=no
    hardcode_direct_FC=no
    hardcode_automatic_FC=yes
-@@ -13490,10 +13594,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -14959,9 +15062,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs_FC=no
-@@ -17213,6 +17326,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then
-   as_fn_error $? "conditional \"BUILD_INFO\" was never defined.
+@@ -16234,9 +16341,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ 
+ 
+ # extra LD Flags which are required for targets
++extra_ldflags_libgfortran=
+ case "${host}" in
+-  *-darwin*)
+-    # Darwin needs -single_module when linking libgfortran
++  *-*-darwin[4567]*)
++    # Earlier Darwin needs -single_module when linking libgfortran
+     extra_ldflags_libgfortran=-Wl,-single_module
+     ;;
+ esac
+@@ -31597,6 +31705,10 @@ if test -z "${HAVE_HWCAP_TRUE}" && test -z "${HAVE_HWCAP_FALSE}"; then
+   as_fn_error $? "conditional \"HAVE_HWCAP\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
 +if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
 +  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
 +Usually this means the macro was only invoked conditionally." "$LINENO" 5
 +fi
- if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
-   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
+ if test -z "${IEEE_SUPPORT_TRUE}" && test -z "${IEEE_SUPPORT_FALSE}"; then
+   as_fn_error $? "conditional \"IEEE_SUPPORT\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
-diff --git a/libgomp/configure.ac b/libgomp/configure.ac
-index a9b1f3973f7..654fca1f445 100644
---- a/libgomp/configure.ac
-+++ b/libgomp/configure.ac
-@@ -149,6 +149,7 @@ AM_PROG_LIBTOOL
+diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
+index 07b9a48a19f..4ee63cf723e 100644
+--- a/libgfortran/configure.ac
++++ b/libgfortran/configure.ac
+@@ -282,6 +282,7 @@ LT_LIB_M
  ACX_LT_HOST_FLAGS
  AC_SUBST(enable_shared)
  AC_SUBST(enable_static)
 +AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
+ #AC_MSG_NOTICE([====== Finished libtool configuration]) ; sleep 10
  
- AM_MAINTAINER_MODE
- 
-diff --git a/libiberty/aclocal.m4 b/libiberty/aclocal.m4
-index 3378316dced..1a00b771fe1 100644
---- a/libiberty/aclocal.m4
-+++ b/libiberty/aclocal.m4
-@@ -12,10 +12,61 @@
- # PARTICULAR PURPOSE.
- 
- m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
-+# AM_CONDITIONAL                                            -*- Autoconf -*-
-+
-+# Copyright (C) 1997-2017 Free Software Foundation, Inc.
-+#
-+# This file is free software; the Free Software Foundation
-+# gives unlimited permission to copy and/or distribute it,
-+# with or without modifications, as long as this notice is preserved.
-+
-+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
-+# -------------------------------------
-+# Define a conditional.
-+AC_DEFUN([AM_CONDITIONAL],
-+[AC_PREREQ([2.52])dnl
-+ m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
-+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
-+AC_SUBST([$1_TRUE])dnl
-+AC_SUBST([$1_FALSE])dnl
-+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
-+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
-+m4_define([_AM_COND_VALUE_$1], [$2])dnl
-+if $2; then
-+  $1_TRUE=
-+  $1_FALSE='#'
-+else
-+  $1_TRUE='#'
-+  $1_FALSE=
-+fi
-+AC_CONFIG_COMMANDS_PRE(
-+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
-+  AC_MSG_ERROR([[conditional "$1" was never defined.
-+Usually this means the macro was only invoked conditionally.]])
-+fi])])
-+
-+# Copyright (C) 2006-2017 Free Software Foundation, Inc.
-+#
-+# This file is free software; the Free Software Foundation
-+# gives unlimited permission to copy and/or distribute it,
-+# with or without modifications, as long as this notice is preserved.
-+
-+# _AM_SUBST_NOTMAKE(VARIABLE)
-+# ---------------------------
-+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
-+# This macro is traced by Automake.
-+AC_DEFUN([_AM_SUBST_NOTMAKE])
-+
-+# AM_SUBST_NOTMAKE(VARIABLE)
-+# --------------------------
-+# Public sister of _AM_SUBST_NOTMAKE.
-+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
-+
- m4_include([../config/acx.m4])
- m4_include([../config/cet.m4])
- m4_include([../config/enable.m4])
- m4_include([../config/no-executables.m4])
-+m4_include([../config/override.m4])
- m4_include([../config/picflag.m4])
- m4_include([../config/warnings.m4])
- m4_include([acinclude.m4])
-diff --git a/libiberty/configure b/libiberty/configure
-index 0a797255c70..a346be40cc2 100755
---- a/libiberty/configure
-+++ b/libiberty/configure
-@@ -632,6 +632,8 @@ PICFLAG
- INSTALL_DATA
- INSTALL_SCRIPT
- INSTALL_PROGRAM
-+ENABLE_DARWIN_AT_RPATH_FALSE
-+ENABLE_DARWIN_AT_RPATH_TRUE
- OUTPUT_OPTION
- NO_MINUS_C_MINUS_O
- ac_libiberty_warn_cflags
-@@ -2459,6 +2461,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
- 
- 
- 
-+
-+
-+
- # This works around the fact that libtool configuration may change LD
- # for this particular configuration, but some shells, instead of
- # keeping the changes in LD private, export them just because LD is
-@@ -5046,6 +5051,15 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
- 
- 
- 
-+ if test x$enable_darwin_at_rpath = xyes; then
-+  ENABLE_DARWIN_AT_RPATH_TRUE=
-+  ENABLE_DARWIN_AT_RPATH_FALSE='#'
-+else
-+  ENABLE_DARWIN_AT_RPATH_TRUE='#'
-+  ENABLE_DARWIN_AT_RPATH_FALSE=
-+fi
-+
-+
- ac_config_headers="$ac_config_headers config.h:config.in"
- 
- 
-@@ -5208,6 +5222,9 @@ case "${host}" in
- 	# sets the default TLS model and affects inlining.
- 	PICFLAG=-fPIC
- 	;;
-+    loongarch*-*-*)
-+	PICFLAG=-fpic
-+	;;
-     mips-sgi-irix6*)
- 	# PIC is the default.
- 	;;
-@@ -7837,6 +7854,10 @@ LTLIBOBJS=$ac_ltlibobjs
- 
- 
- 
-+if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
-+  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
-+Usually this means the macro was only invoked conditionally." "$LINENO" 5
-+fi
- 
- : "${CONFIG_STATUS=./config.status}"
- ac_write_fail=0
-diff --git a/libiberty/configure.ac b/libiberty/configure.ac
-index 84a7b378fad..4dad84ea77a 100644
---- a/libiberty/configure.ac
-+++ b/libiberty/configure.ac
-@@ -190,6 +190,8 @@ dnl AM_DISABLE_SHARED
- dnl When we start using libtool:
- dnl AM_PROG_LIBTOOL
- 
-+AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
-+
- dnl When we start using automake:
- dnl AM_CONFIG_HEADER(config.h:config.in)
- AC_CONFIG_HEADER(config.h:config.in)
-diff --git a/libitm/Makefile.am b/libitm/Makefile.am
-index 3f31ad30556..a25317b07fe 100644
---- a/libitm/Makefile.am
-+++ b/libitm/Makefile.am
-@@ -54,7 +54,12 @@ libitm_version_info = -version-info $(libtool_VERSION)
- # want or need libstdc++.
- libitm_la_DEPENDENCIES = $(libitm_version_dep)
- libitm_la_LINK = $(LINK) $(libitm_la_LDFLAGS)
--libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script)
-+if ENABLE_DARWIN_AT_RPATH
-+libitm_darwin_rpath = -Wc,-nodefaultrpaths
-+libitm_darwin_rpath += -Wl,-rpath,@loader_path
-+endif
-+libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script) \
-+  $(libitm_darwin_rpath)
- 
- libitm_la_SOURCES = \
- 	aatree.cc alloc.cc alloc_c.cc alloc_cpp.cc barrier.cc beginend.cc \
-diff --git a/libitm/Makefile.in b/libitm/Makefile.in
-index 7f53ea9b9db..ed28db45057 100644
---- a/libitm/Makefile.in
-+++ b/libitm/Makefile.in
-@@ -481,7 +481,12 @@ libitm_version_info = -version-info $(libtool_VERSION)
- # want or need libstdc++.
- libitm_la_DEPENDENCIES = $(libitm_version_dep)
- libitm_la_LINK = $(LINK) $(libitm_la_LDFLAGS)
--libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script)
-+@ENABLE_DARWIN_AT_RPATH_TRUE@libitm_darwin_rpath =  \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wc,-nodefaultrpaths \
-+@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
-+libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script) \
-+  $(libitm_darwin_rpath)
-+
- libitm_la_SOURCES = aatree.cc alloc.cc alloc_c.cc alloc_cpp.cc \
- 	barrier.cc beginend.cc clone.cc eh_cpp.cc local.cc query.cc \
- 	retry.cc rwlock.cc useraction.cc util.cc sjlj.S tls.cc \
-diff --git a/libitm/config/aarch64/sjlj.S b/libitm/config/aarch64/sjlj.S
-index 296cb683a9f..941e886143e 100644
---- a/libitm/config/aarch64/sjlj.S
-+++ b/libitm/config/aarch64/sjlj.S
-@@ -57,10 +57,19 @@
- 
- 	.text
- 	.align	2
-+#if __ELF__
- 	.global	_ITM_beginTransaction
- 	.type	_ITM_beginTransaction, %function
- 
- _ITM_beginTransaction:
-+
-+#elif __MACH__
-+	.global	__ITM_beginTransaction
-+
-+__ITM_beginTransaction:
-+
-+#endif
-+
- 	cfi_startproc
- 	CFI_PAC_KEY
- 	PAC_AND_BTI
-@@ -84,8 +93,13 @@ _ITM_beginTransaction:
- 
- 	/* Invoke GTM_begin_transaction with the struct we just built.  */
- 	mov	x1, sp
-+#if __ELF__
- 	bl	GTM_begin_transaction
--
-+#elif __MACH__
-+	bl	_GTM_begin_transaction
-+#else
-+#error "unexpected object format"
-+#endif
- 	/* Return; we don't need to restore any of the call-saved regs.  */
- 	ldp	x29, x30, [sp], 11*16
- 	cfi_adjust_cfa_offset(-11*16)
-@@ -95,14 +109,23 @@ _ITM_beginTransaction:
- 	CFI_PAC_TOGGLE
- 	ret
- 	cfi_endproc
-+#if __ELF__
- 	.size	_ITM_beginTransaction, . - _ITM_beginTransaction
-+#endif
+ # We need gfortran to compile parts of the library
+@@ -290,9 +291,10 @@ FC="$GFORTRAN"
+ AC_PROG_FC(gfortran)
  
- 	.align	2
-+#if __ELF__
- 	.global	GTM_longjmp
- 	.hidden	GTM_longjmp
- 	.type	GTM_longjmp, %function
+ # extra LD Flags which are required for targets
++extra_ldflags_libgfortran=
+ case "${host}" in
+-  *-darwin*)
+-    # Darwin needs -single_module when linking libgfortran
++  *-*-darwin[[4567]]*)
++    # Earlier Darwin needs -single_module when linking libgfortran
+     extra_ldflags_libgfortran=-Wl,-single_module
+     ;;
+ esac
+diff --git a/libgm2/Makefile.am b/libgm2/Makefile.am
+index 95df3ed7a30..aa35e747c9a 100644
+--- a/libgm2/Makefile.am
++++ b/libgm2/Makefile.am
+@@ -46,6 +46,12 @@ SUBDIRS = libm2min libm2log libm2cor libm2iso libm2pim
+ GM2_BUILDDIR := $(shell pwd)
+ gm2_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
  
- GTM_longjmp:
-+
-+#elif __MACH__
-+	.private_extern _GTM_longjmp
++if ENABLE_DARWIN_AT_RPATH
++DARWIN_AT_RPATH=yes
++else
++DARWIN_AT_RPATH=yes
++endif
 +
-+_GTM_longjmp:
-+#endif
- 	/* The first parameter becomes the return value (x0).
- 	   The third parameter is ignored for now.  */
- 	cfi_startproc
-@@ -126,7 +149,9 @@ GTM_longjmp:
- 	CFI_PAC_TOGGLE
- 	br	x30
- 	cfi_endproc
-+#if __ELF__
- 	.size	GTM_longjmp, . - GTM_longjmp
-+#endif
+ # Work around what appears to be a GNU make bug handling MAKEFLAGS
+ # values defined in terms of make variables, as is the case for CC and
+ # friends when we are called from the top level Makefile.
+@@ -91,7 +97,8 @@ AM_MAKEFLAGS = \
+ 	"WERROR=$(WERROR)" \
+         "TARGET_LIB_PATH=$(TARGET_LIB_PATH)" \
+         "TARGET_LIB_PATH_libgm2=$(TARGET_LIB_PATH_libgm2)" \
+-	"LIBTOOL=$(GM2_BUILDDIR)/libtool"
++	"LIBTOOL=$(GM2_BUILDDIR)/libtool" \
++	"DARWIN_AT_RPATH=$(DARWIN_AT_RPATH)"
+ 
+ # Subdir rules rely on $(FLAGS_TO_PASS)
+ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
+diff --git a/libgm2/Makefile.in b/libgm2/Makefile.in
+index d9950065de1..f97f6d0812d 100644
+--- a/libgm2/Makefile.in
++++ b/libgm2/Makefile.in
+@@ -344,6 +344,8 @@ GM2_SRC = $(GCC_DIR)/m2
+ SUBDIRS = libm2min libm2log libm2cor libm2iso libm2pim
+ GM2_BUILDDIR := $(shell pwd)
+ gm2_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++@ENABLE_DARWIN_AT_RPATH_FALSE@DARWIN_AT_RPATH = yes
++@ENABLE_DARWIN_AT_RPATH_TRUE@DARWIN_AT_RPATH = yes
  
- /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code.  */
- #define FEATURE_1_AND 0xc0000000
-diff --git a/libitm/configure b/libitm/configure
-index 18fc2d3a10a..5beb48a6b99 100755
---- a/libitm/configure
-+++ b/libitm/configure
-@@ -660,6 +660,8 @@ libtool_VERSION
- MAINT
- MAINTAINER_MODE_FALSE
- MAINTAINER_MODE_TRUE
-+ENABLE_DARWIN_AT_RPATH_FALSE
-+ENABLE_DARWIN_AT_RPATH_TRUE
+ # Work around what appears to be a GNU make bug handling MAKEFLAGS
+ # values defined in terms of make variables, as is the case for CC and
+@@ -390,7 +392,8 @@ AM_MAKEFLAGS = \
+ 	"WERROR=$(WERROR)" \
+         "TARGET_LIB_PATH=$(TARGET_LIB_PATH)" \
+         "TARGET_LIB_PATH_libgm2=$(TARGET_LIB_PATH_libgm2)" \
+-	"LIBTOOL=$(GM2_BUILDDIR)/libtool"
++	"LIBTOOL=$(GM2_BUILDDIR)/libtool" \
++	"DARWIN_AT_RPATH=$(DARWIN_AT_RPATH)"
+ 
+ 
+ # Subdir rules rely on $(FLAGS_TO_PASS)
+diff --git a/libgm2/configure b/libgm2/configure
+index 8eb1bc81c66..d1a056a8a3b 100755
+--- a/libgm2/configure
++++ b/libgm2/configure
+@@ -649,6 +649,8 @@ GM2_FOR_TARGET
+ CC_FOR_BUILD
  enable_static
  enable_shared
++ENABLE_DARWIN_AT_RPATH_FALSE
++ENABLE_DARWIN_AT_RPATH_TRUE
  CXXCPP
-@@ -810,6 +812,7 @@ with_pic
+ OTOOL64
+ OTOOL
+@@ -806,6 +808,7 @@ with_pic
  enable_fast_install
  with_gnu_ld
  enable_libtool_lock
 +enable_darwin_at_rpath
- enable_maintainer_mode
- enable_linux_futex
- enable_tls
-@@ -1462,6 +1465,8 @@ Optional Features:
+ with_gcc_major_version_only
+ '
+       ac_precious_vars='build_alias
+@@ -1456,6 +1459,8 @@ Optional Features:
    --enable-fast-install[=PKGS]
                            optimize for fast installation [default=yes]
    --disable-libtool-lock  avoid locking (might break parallel builds)
 +  --enable-darwin-at-path install libraries with @rpath/library-name, requires
 +                          rpaths to be added to executables
-   --enable-maintainer-mode
-                           enable make rules and dependencies not useful (and
-                           sometimes confusing) to the casual installer
-@@ -10252,6 +10257,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+ 
+ Optional Packages:
+   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+@@ -6575,10 +6580,6 @@ fi
+ 
+ 
+ 
+-enable_dlopen=yes
+-
+-
+-
+ case `pwd` in
+   *\ * | *\	*)
+     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+@@ -9149,7 +9150,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -9197,6 +9198,8 @@ done
+ 
+ 
+ 
++        enable_dlopen=no
++
+ 
+   enable_win32_dll=no
+ 
+@@ -10860,6 +10863,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -10680,8 +7838,9 @@ index 18fc2d3a10a..5beb48a6b99 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -10689,15 +7848,16 @@ index 18fc2d3a10a..5beb48a6b99 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -10711,49 +7871,41 @@ index 18fc2d3a10a..5beb48a6b99 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -10269,10 +10315,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -10877,9 +10923,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -12058,7 +12113,7 @@ else
+@@ -12706,7 +12756,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 12061 "configure"
-+#line 12116 "configure"
+-#line 12709 "configure"
++#line 12759 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -12164,7 +12219,7 @@ else
+@@ -12812,7 +12862,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 12167 "configure"
-+#line 12222 "configure"
+-#line 12815 "configure"
++#line 12865 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -13040,6 +13095,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13694,6 +13744,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
        darwin* | rhapsody*)
  
  
@@ -10770,8 +7922,9 @@ index 18fc2d3a10a..5beb48a6b99 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -10779,15 +7932,16 @@ index 18fc2d3a10a..5beb48a6b99 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -10801,41 +7955,39 @@ index 18fc2d3a10a..5beb48a6b99 100755
    archive_cmds_need_lc_CXX=no
    hardcode_direct_CXX=no
    hardcode_automatic_CXX=yes
-@@ -13057,12 +13153,25 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13711,12 +13804,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
         if test "$lt_cv_apple_cc_single_mod" != "yes"; then
 -      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++      _lt_install_name='\$rpath/\$soname'
 +      if test "x$enable_darwin_at_rpath" = "xyes"; then
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring${_lt_dsymutil}"
-+      else
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++        _lt_install_name='@rpath/\$soname'
 +      fi
++      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring${_lt_dsymutil}"
        archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
      fi
  
-@@ -15414,6 +15523,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+@@ -16090,6 +16191,21 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
  
  
  
++enable_dlopen=yes
++
++
++
++
 + if test x$enable_darwin_at_rpath = xyes; then
 +  ENABLE_DARWIN_AT_RPATH_TRUE=
 +  ENABLE_DARWIN_AT_RPATH_FALSE='#'
@@ -10843,149 +7995,384 @@ index 18fc2d3a10a..5beb48a6b99 100755
 +  ENABLE_DARWIN_AT_RPATH_TRUE='#'
 +  ENABLE_DARWIN_AT_RPATH_FALSE=
 +fi
++
++
 +
  
  
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
-@@ -18172,6 +18289,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then
-   as_fn_error $? "conditional \"BUILD_INFO\" was never defined.
+ if test "${multilib}" = "yes"; then
+@@ -19873,6 +19989,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then
+   as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
 +if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
 +  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
 +Usually this means the macro was only invoked conditionally." "$LINENO" 5
 +fi
- if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
-   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
+ if test -z "${BUILD_PIMLIB_TRUE}" && test -z "${BUILD_PIMLIB_FALSE}"; then
+   as_fn_error $? "conditional \"BUILD_PIMLIB\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
-diff --git a/libitm/configure.ac b/libitm/configure.ac
-index 78a682376d9..209a025a90e 100644
---- a/libitm/configure.ac
-+++ b/libitm/configure.ac
-@@ -157,6 +157,7 @@ AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
+diff --git a/libgm2/configure.ac b/libgm2/configure.ac
+index 3a79d2612b6..e8c7ba711cd 100644
+--- a/libgm2/configure.ac
++++ b/libgm2/configure.ac
+@@ -177,8 +177,12 @@ AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error)
+ AC_PROG_MAKE_SET
+ AC_PROG_INSTALL
+ 
+-AC_LIBTOOL_DLOPEN
  AM_PROG_LIBTOOL
++LT_INIT
++AC_LIBTOOL_DLOPEN
++
++AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
++
  AC_SUBST(enable_shared)
  AC_SUBST(enable_static)
-+AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
  
- AM_MAINTAINER_MODE
+diff --git a/libgm2/libm2cor/Makefile.am b/libgm2/libm2cor/Makefile.am
+index 48de40c22dd..e50c7a2ef55 100644
+--- a/libgm2/libm2cor/Makefile.am
++++ b/libgm2/libm2cor/Makefile.am
+@@ -123,6 +123,10 @@ libm2cor_la_link_flags = -Wl,-undefined,dynamic_lookup
+ else
+ libm2cor_la_link_flags =
+ endif
++if ENABLE_DARWIN_AT_RPATH
++libm2cor_la_link_flags += -nodefaultrpaths -Wl,-rpath,@loader_path/
++endif
++
+ libm2cor_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2cor_la_link_flags)
+ BUILT_SOURCES = SYSTEM.def
+ CLEANFILES = SYSTEM.def
+diff --git a/libgm2/libm2cor/Makefile.in b/libgm2/libm2cor/Makefile.in
+index 9d643d5f8f6..d92c956aae6 100644
+--- a/libgm2/libm2cor/Makefile.in
++++ b/libgm2/libm2cor/Makefile.in
+@@ -105,6 +105,7 @@ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
+ target_triplet = @target@
++@BUILD_CORLIB_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -nodefaultrpaths -Wl,-rpath,@loader_path/
+ subdir = libm2cor
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+@@ -469,8 +470,10 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
+ @BUILD_CORLIB_TRUE@    -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
+ @BUILD_CORLIB_TRUE@    -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2cor
+ 
+-@BUILD_CORLIB_TRUE@@TARGET_DARWIN_FALSE@libm2cor_la_link_flags = 
+-@BUILD_CORLIB_TRUE@@TARGET_DARWIN_TRUE@libm2cor_la_link_flags = -Wl,-undefined,dynamic_lookup
++@BUILD_CORLIB_TRUE@@TARGET_DARWIN_FALSE@libm2cor_la_link_flags =  \
++@BUILD_CORLIB_TRUE@@TARGET_DARWIN_FALSE@	$(am__append_1)
++@BUILD_CORLIB_TRUE@@TARGET_DARWIN_TRUE@libm2cor_la_link_flags = -Wl,-undefined,dynamic_lookup \
++@BUILD_CORLIB_TRUE@@TARGET_DARWIN_TRUE@	$(am__append_1)
+ @BUILD_CORLIB_TRUE@libm2cor_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2cor_la_link_flags)
+ @BUILD_CORLIB_TRUE@BUILT_SOURCES = SYSTEM.def
+ @BUILD_CORLIB_TRUE@CLEANFILES = SYSTEM.def
+diff --git a/libgm2/libm2iso/Makefile.am b/libgm2/libm2iso/Makefile.am
+index d48ef0692ab..b0c4a5f965e 100644
+--- a/libgm2/libm2iso/Makefile.am
++++ b/libgm2/libm2iso/Makefile.am
+@@ -195,6 +195,10 @@ libm2iso_la_link_flags = -Wl,-undefined,dynamic_lookup
+ else
+ libm2iso_la_link_flags =
+ endif
++if ENABLE_DARWIN_AT_RPATH
++libm2iso_la_link_flags += -nodefaultrpaths -Wl,-rpath,@loader_path/
++endif
++
+ libm2iso_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2iso_la_link_flags)
+ CLEANFILES = SYSTEM.def
+ BUILT_SOURCES = SYSTEM.def
+diff --git a/libgm2/libm2iso/Makefile.in b/libgm2/libm2iso/Makefile.in
+index b8936e745fe..7c7e181a01e 100644
+--- a/libgm2/libm2iso/Makefile.in
++++ b/libgm2/libm2iso/Makefile.in
+@@ -105,6 +105,7 @@ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
+ target_triplet = @target@
++@BUILD_ISOLIB_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -nodefaultrpaths -Wl,-rpath,@loader_path/
+ subdir = libm2iso
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+@@ -568,8 +569,10 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
+ @BUILD_ISOLIB_TRUE@  -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
+ @BUILD_ISOLIB_TRUE@  -fiso -fextended-opaque -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2iso
+ 
+-@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_FALSE@libm2iso_la_link_flags = 
+-@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_TRUE@libm2iso_la_link_flags = -Wl,-undefined,dynamic_lookup
++@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_FALSE@libm2iso_la_link_flags =  \
++@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_FALSE@	$(am__append_1)
++@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_TRUE@libm2iso_la_link_flags = -Wl,-undefined,dynamic_lookup \
++@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_TRUE@	$(am__append_1)
+ @BUILD_ISOLIB_TRUE@libm2iso_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2iso_la_link_flags)
+ @BUILD_ISOLIB_TRUE@CLEANFILES = SYSTEM.def
+ @BUILD_ISOLIB_TRUE@BUILT_SOURCES = SYSTEM.def
+diff --git a/libgm2/libm2log/Makefile.am b/libgm2/libm2log/Makefile.am
+index a15747fd245..3b7609ee5c1 100644
+--- a/libgm2/libm2log/Makefile.am
++++ b/libgm2/libm2log/Makefile.am
+@@ -142,6 +142,9 @@ libm2log_la_link_flags = -Wl,-undefined,dynamic_lookup
+ else
+ libm2log_la_link_flags =
+ endif
++if ENABLE_DARWIN_AT_RPATH
++libm2log_la_link_flags += -nodefaultrpaths -Wl,-rpath,@loader_path/
++endif
+ libm2log_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2log_la_link_flags)
+ BUILT_SOURCES = ../libm2pim/SYSTEM.def
+ 
+diff --git a/libgm2/libm2log/Makefile.in b/libgm2/libm2log/Makefile.in
+index fa98b1d8ff1..cf48c2bb74f 100644
+--- a/libgm2/libm2log/Makefile.in
++++ b/libgm2/libm2log/Makefile.in
+@@ -105,6 +105,7 @@ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
+ target_triplet = @target@
++@BUILD_LOGLIB_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -nodefaultrpaths -Wl,-rpath,@loader_path/
+ subdir = libm2log
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+@@ -478,8 +479,10 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
+ @BUILD_LOGLIB_TRUE@ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
+ @BUILD_LOGLIB_TRUE@ -Wreturn-type -fcase -fm2-prefix=m2log
+ 
+-@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_FALSE@libm2log_la_link_flags = 
+-@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_TRUE@libm2log_la_link_flags = -Wl,-undefined,dynamic_lookup
++@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_FALSE@libm2log_la_link_flags =  \
++@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_FALSE@	$(am__append_1)
++@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_TRUE@libm2log_la_link_flags = -Wl,-undefined,dynamic_lookup \
++@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_TRUE@	$(am__append_1)
+ @BUILD_LOGLIB_TRUE@libm2log_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2log_la_link_flags)
+ @BUILD_LOGLIB_TRUE@BUILT_SOURCES = ../libm2pim/SYSTEM.def
+ @BUILD_LOGLIB_TRUE@M2LIBDIR = /m2/m2log/
+diff --git a/libgm2/libm2min/Makefile.am b/libgm2/libm2min/Makefile.am
+index 1ff160028f6..21411769505 100644
+--- a/libgm2/libm2min/Makefile.am
++++ b/libgm2/libm2min/Makefile.am
+@@ -113,6 +113,9 @@ libm2min_la_link_flags = -Wl,-undefined,dynamic_lookup
+ else
+ libm2min_la_link_flags =
+ endif
++if ENABLE_DARWIN_AT_RPATH
++libm2min_la_link_flags += -nodefaultrpaths -Wl,-rpath,@loader_path/
++endif
+ libm2min_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2min_la_link_flags)
+ BUILT_SOURCES = SYSTEM.def
+ CLEANFILES = SYSTEM.def
+diff --git a/libgm2/libm2min/Makefile.in b/libgm2/libm2min/Makefile.in
+index 1c0bebdc304..ed3312deb0f 100644
+--- a/libgm2/libm2min/Makefile.in
++++ b/libgm2/libm2min/Makefile.in
+@@ -105,6 +105,7 @@ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
+ target_triplet = @target@
++@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -nodefaultrpaths -Wl,-rpath,@loader_path/
+ subdir = libm2min
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+@@ -442,8 +443,10 @@ libm2min_la_M2FLAGS = \
+    -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs -fno-exceptions \
+    -fno-m2-plugin -fno-scaffold-dynamic -fno-scaffold-main -fm2-prefix=m2min
+ 
+-@TARGET_DARWIN_FALSE@libm2min_la_link_flags = 
+-@TARGET_DARWIN_TRUE@libm2min_la_link_flags = -Wl,-undefined,dynamic_lookup
++@TARGET_DARWIN_FALSE@libm2min_la_link_flags = $(am__append_1)
++@TARGET_DARWIN_TRUE@libm2min_la_link_flags =  \
++@TARGET_DARWIN_TRUE@	-Wl,-undefined,dynamic_lookup \
++@TARGET_DARWIN_TRUE@	$(am__append_1)
+ libm2min_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2min_la_link_flags)
+ BUILT_SOURCES = SYSTEM.def
+ CLEANFILES = SYSTEM.def
+diff --git a/libgm2/libm2pim/Makefile.am b/libgm2/libm2pim/Makefile.am
+index ebfeba1ac1d..e777a60c077 100644
+--- a/libgm2/libm2pim/Makefile.am
++++ b/libgm2/libm2pim/Makefile.am
+@@ -175,6 +175,9 @@ libm2pim_la_link_flags = -Wl,-undefined,dynamic_lookup
+ else
+ libm2pim_la_link_flags =
+ endif
++if ENABLE_DARWIN_AT_RPATH
++libm2pim_la_link_flags += -nodefaultrpaths -Wl,-rpath,@loader_path/
++endif
+ libm2pim_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2pim_la_link_flags)
+ BUILT_SOURCES = SYSTEM.def
+ CLEANFILES = SYSTEM.def
+diff --git a/libgm2/libm2pim/Makefile.in b/libgm2/libm2pim/Makefile.in
+index e5a97976d93..5e97a02a91d 100644
+--- a/libgm2/libm2pim/Makefile.in
++++ b/libgm2/libm2pim/Makefile.in
+@@ -105,6 +105,7 @@ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
+ target_triplet = @target@
++@BUILD_PIMLIB_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -nodefaultrpaths -Wl,-rpath,@loader_path/
+ subdir = libm2pim
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+@@ -539,8 +540,10 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
+ @BUILD_PIMLIB_TRUE@  -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
+ @BUILD_PIMLIB_TRUE@  -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2pim
+ 
+-@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_FALSE@libm2pim_la_link_flags = 
+-@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_TRUE@libm2pim_la_link_flags = -Wl,-undefined,dynamic_lookup
++@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_FALSE@libm2pim_la_link_flags =  \
++@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_FALSE@	$(am__append_1)
++@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_TRUE@libm2pim_la_link_flags = -Wl,-undefined,dynamic_lookup \
++@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_TRUE@	$(am__append_1)
+ @BUILD_PIMLIB_TRUE@libm2pim_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2pim_la_link_flags)
+ @BUILD_PIMLIB_TRUE@BUILT_SOURCES = SYSTEM.def
+ @BUILD_PIMLIB_TRUE@CLEANFILES = SYSTEM.def
+diff --git a/libgo/configure b/libgo/configure
+index a607dbff68e..72d46c3eec3 100755
+--- a/libgo/configure
++++ b/libgo/configure
+@@ -708,6 +708,8 @@ glibgo_toolexecdir
+ WERROR
+ WARN_FLAGS
+ CC_FOR_BUILD
++ENABLE_DARWIN_AT_RPATH_FALSE
++ENABLE_DARWIN_AT_RPATH_TRUE
+ enable_static
+ enable_shared
+ CPP
+@@ -11544,7 +11546,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11547 "configure"
++#line 11549 "configure"
+ #include "confdefs.h"
  
-diff --git a/libitm/configure.tgt b/libitm/configure.tgt
-index 06e90973ef3..acaf4f85712 100644
---- a/libitm/configure.tgt
-+++ b/libitm/configure.tgt
-@@ -50,7 +50,7 @@ fi
- # Map the target cpu to an ARCH sub-directory.  At the same time,
- # work out any special compilation flags as necessary.
- case "${target_cpu}" in
--  aarch64*)		ARCH=aarch64 ;;
-+  aarch64* | arm64*)	ARCH=aarch64 ;;
-   alpha*)		ARCH=alpha ;;
-   rs6000 | powerpc*)
- 	XCFLAGS="${XCFLAGS} -mhtm"
-diff --git a/libitm/testsuite/lib/libitm.exp b/libitm/testsuite/lib/libitm.exp
-index 6d8e3e71310..906534022eb 100644
---- a/libitm/testsuite/lib/libitm.exp
-+++ b/libitm/testsuite/lib/libitm.exp
-@@ -158,6 +158,7 @@ proc libitm_init { args } {
-     }
+ #if HAVE_DLFCN_H
+@@ -11650,7 +11652,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11653 "configure"
++#line 11655 "configure"
+ #include "confdefs.h"
  
-     if [istarget *-*-darwin*] {
-+	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
- 	lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
-     }
+ #if HAVE_DLFCN_H
+@@ -13779,6 +13781,14 @@ CC="$lt_save_CC"
  
-diff --git a/libitm/testsuite/libitm.c++/c++.exp b/libitm/testsuite/libitm.c++/c++.exp
-index f92aa096104..295c5bd4703 100644
---- a/libitm/testsuite/libitm.c++/c++.exp
-+++ b/libitm/testsuite/libitm.c++/c++.exp
-@@ -56,8 +56,10 @@ if { $lang_test_file_found } {
-     # Gather a list of all tests.
-     set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
  
-+    set stdcxxadder ""
-     if { $blddir != "" } {
- 	set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-+	set stdcxxadder "-B ${blddir}/${lang_library_path}"
-     } else {
- 	set ld_library_path "$always_ld_library_path"
-     }
-@@ -72,7 +74,7 @@ if { $lang_test_file_found } {
-     }
  
-     # Main loop.
--    dg-runtest $tests "" $libstdcxx_includes
-+    dg-runtest $tests $stdcxxadder $libstdcxx_includes
- }
++ if test x$enable_darwin_at_rpath = xyes; then
++  ENABLE_DARWIN_AT_RPATH_TRUE=
++  ENABLE_DARWIN_AT_RPATH_FALSE='#'
++else
++  ENABLE_DARWIN_AT_RPATH_TRUE='#'
++  ENABLE_DARWIN_AT_RPATH_FALSE=
++fi
++
+ 
+ CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
+ 
+@@ -16386,6 +16396,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
++  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+ if test -z "${USE_LIBFFI_TRUE}" && test -z "${USE_LIBFFI_FALSE}"; then
+   as_fn_error $? "conditional \"USE_LIBFFI\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+diff --git a/libgo/configure.ac b/libgo/configure.ac
+index a59aa091d1d..6f1ac32660b 100644
+--- a/libgo/configure.ac
++++ b/libgo/configure.ac
+@@ -53,6 +53,7 @@ AC_LIBTOOL_DLOPEN
+ AM_PROG_LIBTOOL
+ AC_SUBST(enable_shared)
+ AC_SUBST(enable_static)
++AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
+ 
+ CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
+ AC_SUBST(CC_FOR_BUILD)
+diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
+index 428f7a9dab5..ceb8c910abd 100644
+--- a/libgomp/Makefile.am
++++ b/libgomp/Makefile.am
+@@ -53,9 +53,14 @@ else
+ libgomp_version_script =
+ libgomp_version_dep =
+ endif
++
+ libgomp_version_info = -version-info $(libtool_VERSION)
++if ENABLE_DARWIN_AT_RPATH
++libgomp_darwin_rpath = -Wc,-nodefaultrpaths
++libgomp_darwin_rpath += -Wl,-rpath,@loader_path
++endif
+ libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
+-        $(lt_host_flags)
++        $(lt_host_flags) $(libgomp_darwin_rpath)
+ libgomp_la_LIBADD =
+ libgomp_la_DEPENDENCIES = $(libgomp_version_dep)
+ libgomp_la_LINK = $(LINK) $(libgomp_la_LDFLAGS)
+diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
+index f1afb5ef57f..ef97186e68d 100644
+--- a/libgomp/Makefile.in
++++ b/libgomp/Makefile.in
+@@ -535,8 +535,11 @@ nodist_toolexeclib_HEADERS = libgomp.spec
+ @LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_dep = libgomp.ver
+ @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_dep = libgomp.ver-sun
+ libgomp_version_info = -version-info $(libtool_VERSION)
++@ENABLE_DARWIN_AT_RPATH_TRUE@libgomp_darwin_rpath =  \
++@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wc,-nodefaultrpaths \
++@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
+ libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
+-        $(lt_host_flags)
++        $(lt_host_flags) $(libgomp_darwin_rpath)
  
- # All done.
-diff --git a/libobjc/configure b/libobjc/configure
-index 5d1b424a66d..21ac18723c3 100755
---- a/libobjc/configure
-+++ b/libobjc/configure
-@@ -636,6 +636,9 @@ OBJC_BOEHM_GC_LIBS
- OBJC_BOEHM_GC_INCLUDES
- OBJC_BOEHM_GC
- OBJC_GCFLAGS
-+extra_ldflags_libobjc
+ libgomp_la_LIBADD = $(DL_LIBS)
+ libgomp_la_DEPENDENCIES = $(libgomp_version_dep)
+diff --git a/libgomp/configure b/libgomp/configure
+index ed18809ff1c..2d19357d123 100755
+--- a/libgomp/configure
++++ b/libgomp/configure
+@@ -682,6 +682,8 @@ FC
+ MAINT
+ MAINTAINER_MODE_FALSE
+ MAINTAINER_MODE_TRUE
 +ENABLE_DARWIN_AT_RPATH_FALSE
 +ENABLE_DARWIN_AT_RPATH_TRUE
- SET_MAKE
- CPP
- OTOOL64
-@@ -667,7 +670,6 @@ RANLIB
- AR
- AS
- XCFLAGS
--extra_ldflags_libobjc
+ enable_static
+ enable_shared
  lt_host_flags
- OBJEXT
- EXEEXT
-@@ -755,6 +757,7 @@ with_pic
+@@ -822,6 +824,7 @@ with_pic
  enable_fast_install
  with_gnu_ld
  enable_libtool_lock
 +enable_darwin_at_rpath
+ enable_maintainer_mode
+ enable_linux_futex
  enable_tls
- enable_objc_gc
- with_target_bdw_gc
-@@ -1392,6 +1395,8 @@ Optional Features:
+@@ -1477,6 +1480,8 @@ Optional Features:
    --enable-fast-install[=PKGS]
                            optimize for fast installation [default=yes]
    --disable-libtool-lock  avoid locking (might break parallel builds)
 +  --enable-darwin-at-path install libraries with @rpath/library-name, requires
 +                          rpaths to be added to executables
-   --enable-tls            Use thread-local storage [default=yes]
-   --enable-objc-gc        enable use of Boehm's garbage collector with the GNU
-                           Objective-C runtime
-@@ -3430,17 +3435,6 @@ esac
- 
- 
- 
--case "${host}" in
--  *-darwin*)
--    # Darwin needs -single_module when linking libobjc
--    extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
--    ;;
--  *-cygwin*|*-mingw*)
--    # Tell libtool to build DLLs on Windows
--    extra_ldflags_libobjc='$(lt_host_flags)'
--    ;;
--esac
--
- 
- # Add CET specific flags if CET is enabled
- 
-@@ -3466,7 +3460,7 @@ case "$host" in
-     case "$enable_cet" in
-       auto)
- 	# Check if target supports multi-byte NOPs
--	# and if assembler supports CET insn.
-+	# and if compiler and assembler support CET insn.
- 	cet_save_CFLAGS="$CFLAGS"
- 	CFLAGS="$CFLAGS -fcf-protection"
- 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-@@ -8944,6 +8938,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+   --enable-maintainer-mode
+                           enable make rules and dependencies not useful (and
+                           sometimes confusing) to the casual installer
+@@ -7621,7 +7626,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -9594,6 +9599,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -11002,8 +8389,9 @@ index 5d1b424a66d..21ac18723c3 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -11011,15 +8399,16 @@ index 5d1b424a66d..21ac18723c3 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -11033,50 +8422,42 @@ index 5d1b424a66d..21ac18723c3 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -8961,10 +8996,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -9611,9 +9659,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -10771,7 +10815,7 @@ else
+@@ -11419,7 +11471,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 10784 "configure"
-+#line 10818 "configure"
+-#line 11422 "configure"
++#line 11474 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -10877,7 +10921,7 @@ else
+@@ -11525,7 +11577,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 10890 "configure"
-+#line 10924 "configure"
+-#line 11528 "configure"
++#line 11580 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11149,6 +11193,38 @@ $as_echo "no" >&6; }
- fi
+@@ -11786,6 +11838,14 @@ esac
+ 
  
  
 + if test x$enable_darwin_at_rpath = xyes; then
@@ -11087,169 +8468,277 @@ index 5d1b424a66d..21ac18723c3 100755
 +  ENABLE_DARWIN_AT_RPATH_FALSE=
 +fi
 +
+ 
+ 
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
+@@ -13461,6 +13521,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+     darwin* | rhapsody*)
+ 
+ 
++
++  # Publish an arg to allow the user to select that Darwin host (and target)
++  # libraries should be given install-names like @rpath/libfoo.dylib.  This
++  # requires that the user of the library then adds an 'rpath' to the DSO that
++  # needs access.
++  # NOTE: there are defaults below, for systems that support rpaths.  The person
++  # configuring can override the defaults for any system version that supports
++  # them - they are, however, forced off for system versions without support.
++  # Check whether --enable-darwin-at-rpath was given.
++if test "${enable_darwin_at_rpath+set}" = set; then :
++  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
++    # This is not supported before macOS 10.5 / Darwin9.
++    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
++	enable_darwin_at_rpath=no
++      ;;
++    esac
++   fi
++else
++  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
++    # As above, before 10.5 / Darwin9 this does not work.
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++       enable_darwin_at_rpath=no
++       ;;
++
++    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
++    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
++    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
++      enable_darwin_at_rpath=yes
++      ;;
++    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
++    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
++
++    esac
++
++fi
++
++
+   archive_cmds_need_lc_FC=no
+   hardcode_direct_FC=no
+   hardcode_automatic_FC=yes
+@@ -13478,9 +13581,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+   esac
+   if test "$_lt_dar_can_shared" = "yes"; then
+     output_verbose_link_cmd=func_echo_all
+-    archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
++    if test "x$enable_darwin_at_rpath" = "xyes"; then
++      _lt_install_name='@rpath/\$soname'
++    fi
++    archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ 
+   else
+@@ -17122,6 +17229,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then
+   as_fn_error $? "conditional \"BUILD_INFO\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
++  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+diff --git a/libgomp/configure.ac b/libgomp/configure.ac
+index cc96e5b753b..cef33212028 100644
+--- a/libgomp/configure.ac
++++ b/libgomp/configure.ac
+@@ -149,6 +149,7 @@ AM_PROG_LIBTOOL
+ ACX_LT_HOST_FLAGS
+ AC_SUBST(enable_shared)
+ AC_SUBST(enable_static)
++AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
+ 
+ AM_MAINTAINER_MODE
+ 
+diff --git a/libiberty/configure b/libiberty/configure
+index 860f981fa18..b8a19c42110 100755
+--- a/libiberty/configure
++++ b/libiberty/configure
+@@ -5258,8 +5258,8 @@ case "${enable_shared}" in
+   *) shared=yes ;;
+ esac
+ 
+-# ...unless --enable-host-shared was passed from top-level config:
+-if [ "${enable_host_shared}" = "yes" ]; then
++# ...unless --enable-host-{shared,pie} was passed from top-level config:
++if [ "${enable_host_shared}" = "yes" ] || [ "${enable_host_pie}" = "yes" ]; then
+   shared=yes
+ fi
+ 
+diff --git a/libiberty/configure.ac b/libiberty/configure.ac
+index 28d996f9cf7..6747a7b5cff 100644
+--- a/libiberty/configure.ac
++++ b/libiberty/configure.ac
+@@ -233,8 +233,8 @@ case "${enable_shared}" in
+   *) shared=yes ;;
+ esac
+ 
+-# ...unless --enable-host-shared was passed from top-level config:
+-if [[ "${enable_host_shared}" = "yes" ]]; then
++# ...unless --enable-host-{shared,pie} was passed from top-level config:
++if [[ "${enable_host_shared}" = "yes" ]] || [[ "${enable_host_pie}" = "yes" ]]; then
+   shared=yes
+ fi
+ 
+diff --git a/libitm/Makefile.am b/libitm/Makefile.am
+index 3f31ad30556..a25317b07fe 100644
+--- a/libitm/Makefile.am
++++ b/libitm/Makefile.am
+@@ -54,7 +54,12 @@ libitm_version_info = -version-info $(libtool_VERSION)
+ # want or need libstdc++.
+ libitm_la_DEPENDENCIES = $(libitm_version_dep)
+ libitm_la_LINK = $(LINK) $(libitm_la_LDFLAGS)
+-libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script)
++if ENABLE_DARWIN_AT_RPATH
++libitm_darwin_rpath = -Wc,-nodefaultrpaths
++libitm_darwin_rpath += -Wl,-rpath,@loader_path
++endif
++libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script) \
++  $(libitm_darwin_rpath)
+ 
+ libitm_la_SOURCES = \
+ 	aatree.cc alloc.cc alloc_c.cc alloc_cpp.cc barrier.cc beginend.cc \
+diff --git a/libitm/Makefile.in b/libitm/Makefile.in
+index 7f53ea9b9db..ed28db45057 100644
+--- a/libitm/Makefile.in
++++ b/libitm/Makefile.in
+@@ -481,7 +481,12 @@ libitm_version_info = -version-info $(libtool_VERSION)
+ # want or need libstdc++.
+ libitm_la_DEPENDENCIES = $(libitm_version_dep)
+ libitm_la_LINK = $(LINK) $(libitm_la_LDFLAGS)
+-libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script)
++@ENABLE_DARWIN_AT_RPATH_TRUE@libitm_darwin_rpath =  \
++@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wc,-nodefaultrpaths \
++@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
++libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script) \
++  $(libitm_darwin_rpath)
++
+ libitm_la_SOURCES = aatree.cc alloc.cc alloc_c.cc alloc_cpp.cc \
+ 	barrier.cc beginend.cc clone.cc eh_cpp.cc local.cc query.cc \
+ 	retry.cc rwlock.cc useraction.cc util.cc sjlj.S tls.cc \
+diff --git a/libitm/config/aarch64/sjlj.S b/libitm/config/aarch64/sjlj.S
+index 0342516cdc8..2c27f46dc43 100644
+--- a/libitm/config/aarch64/sjlj.S
++++ b/libitm/config/aarch64/sjlj.S
+@@ -57,10 +57,19 @@
+ 
+ 	.text
+ 	.align	2
++#if __ELF__
+ 	.global	_ITM_beginTransaction
+ 	.type	_ITM_beginTransaction, %function
+ 
+ _ITM_beginTransaction:
++
++#elif __MACH__
++	.global	__ITM_beginTransaction
 +
-+# Must come after libtool is initialized.
-+case "${host}" in
-+  *-darwin[4567]*)
-+    # Earlier Darwin versions need -single_module when linking libobjc; they
-+    # do not support @rpath.
-+    extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
-+    ;;
-+  *-darwin*)
-+    # Otherwise, single_module is the default and multi-module is ignored and
-+    # obsolete.
-+    extra_ldflags_libobjc='$(lt_host_flags)'
-+    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      extra_ldflags_libobjc="${extra_ldflags_libobjc} -Wc,-nodefaultrpaths"
-+      extra_ldflags_libobjc="${extra_ldflags_libobjc} -Wl,-rpath,@loader_path"
-+    fi
-+    ;;
-+  *-cygwin*|*-mingw*)
-+    # Tell libtool to build DLLs on Windows
-+    extra_ldflags_libobjc='$(lt_host_flags)'
-+    ;;
-+esac
++__ITM_beginTransaction:
 +
++#endif
 +
- # -------
- # Headers
- # -------
-@@ -11890,6 +11966,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
-   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
- Usually this means the macro was only invoked conditionally." "$LINENO" 5
- fi
-+if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
-+  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
-+Usually this means the macro was only invoked conditionally." "$LINENO" 5
-+fi
- 
- : "${CONFIG_STATUS=./config.status}"
- ac_write_fail=0
-diff --git a/libobjc/configure.ac b/libobjc/configure.ac
-index f8f577cfbef..2a9bf1fed4c 100644
---- a/libobjc/configure.ac
-+++ b/libobjc/configure.ac
-@@ -147,17 +147,6 @@ m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
- 
- # extra LD Flags which are required for targets
- ACX_LT_HOST_FLAGS
--case "${host}" in
--  *-darwin*)
--    # Darwin needs -single_module when linking libobjc
--    extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
--    ;;
--  *-cygwin*|*-mingw*)
--    # Tell libtool to build DLLs on Windows
--    extra_ldflags_libobjc='$(lt_host_flags)'
--    ;;
--esac
--AC_SUBST(extra_ldflags_libobjc)
+ 	cfi_startproc
+ 	CFI_PAC_KEY
+ 	PAC_AND_BTI
+@@ -84,8 +93,13 @@ _ITM_beginTransaction:
  
- # Add CET specific flags if CET is enabled
- GCC_CET_FLAGS(CET_FLAGS)
-@@ -182,6 +171,31 @@ AM_PROG_CC_C_O
+ 	/* Invoke GTM_begin_transaction with the struct we just built.  */
+ 	mov	x1, sp
++#if __ELF__
+ 	bl	GTM_begin_transaction
+-
++#elif __MACH__
++	bl	_GTM_begin_transaction
++#else
++#error "unexpected object format"
++#endif
+ 	/* Return; we don't need to restore any of the call-saved regs.  */
+ 	ldp	x29, x30, [sp], 11*16
+ 	cfi_adjust_cfa_offset(-11*16)
+@@ -95,14 +109,23 @@ _ITM_beginTransaction:
+ 	CFI_PAC_TOGGLE
+ 	ret
+ 	cfi_endproc
++#if __ELF__
+ 	.size	_ITM_beginTransaction, . - _ITM_beginTransaction
++#endif
  
- AC_PROG_MAKE_SET
+ 	.align	2
++#if __ELF__
+ 	.global	GTM_longjmp
+ 	.hidden	GTM_longjmp
+ 	.type	GTM_longjmp, %function
  
-+AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
+ GTM_longjmp:
 +
-+# Must come after libtool is initialized.
-+case "${host}" in
-+  *-darwin[[4567]]*)
-+    # Earlier Darwin versions need -single_module when linking libobjc; they
-+    # do not support @rpath.
-+    extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
-+    ;;
-+  *-darwin*)
-+    # Otherwise, single_module is the default and multi-module is ignored and
-+    # obsolete.
-+    extra_ldflags_libobjc='$(lt_host_flags)'
-+    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      extra_ldflags_libobjc="${extra_ldflags_libobjc} -Wc,-nodefaultrpaths"
-+      extra_ldflags_libobjc="${extra_ldflags_libobjc} -Wl,-rpath,@loader_path"
-+    fi
-+    ;;
-+  *-cygwin*|*-mingw*)
-+    # Tell libtool to build DLLs on Windows
-+    extra_ldflags_libobjc='$(lt_host_flags)'
-+    ;;
-+esac
-+AC_SUBST(extra_ldflags_libobjc)
++#elif __MACH__
++	.private_extern _GTM_longjmp
 +
- # -------
- # Headers
- # -------
-diff --git a/liboffloadmic/configure b/liboffloadmic/configure
-index dfa8287fd75..84447cbb7eb 100755
---- a/liboffloadmic/configure
-+++ b/liboffloadmic/configure
-@@ -639,6 +639,8 @@ link_offloadmic_host
- lt_cv_dlopen_libs
- toolexeclibdir
- toolexecdir
++_GTM_longjmp:
++#endif
+ 	/* The first parameter becomes the return value (x0).
+ 	   The third parameter is ignored for now.  */
+ 	cfi_startproc
+@@ -126,7 +149,9 @@ GTM_longjmp:
+ 	CFI_PAC_TOGGLE
+ 	br	x30
+ 	cfi_endproc
++#if __ELF__
+ 	.size	GTM_longjmp, . - GTM_longjmp
++#endif
+ 
+ /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code.  */
+ #define FEATURE_1_AND 0xc0000000
+diff --git a/libitm/configure b/libitm/configure
+index 6230c04dd24..014453a3f49 100755
+--- a/libitm/configure
++++ b/libitm/configure
+@@ -660,6 +660,8 @@ libtool_VERSION
+ MAINT
+ MAINTAINER_MODE_FALSE
+ MAINTAINER_MODE_TRUE
 +ENABLE_DARWIN_AT_RPATH_FALSE
 +ENABLE_DARWIN_AT_RPATH_TRUE
+ enable_static
+ enable_shared
  CXXCPP
- OTOOL64
- OTOOL
-@@ -782,6 +784,7 @@ with_pic
+@@ -810,6 +812,7 @@ with_pic
  enable_fast_install
  with_gnu_ld
  enable_libtool_lock
 +enable_darwin_at_rpath
- with_gcc_major_version_only
- '
-       ac_precious_vars='build_alias
-@@ -1434,6 +1437,8 @@ Optional Features:
+ enable_maintainer_mode
+ enable_linux_futex
+ enable_tls
+@@ -1462,6 +1465,8 @@ Optional Features:
    --enable-fast-install[=PKGS]
                            optimize for fast installation [default=yes]
    --disable-libtool-lock  avoid locking (might break parallel builds)
 +  --enable-darwin-at-path install libraries with @rpath/library-name, requires
 +                          rpaths to be added to executables
- 
- Optional Packages:
-   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-@@ -7900,23 +7905,25 @@ _LT_EOF
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
- $as_echo "$lt_cv_ld_force_load" >&6; }
--    case $host_os in
--    rhapsody* | darwin1.[012])
-+    # Allow for Darwin 4-7 (macOS 10.0-10.3) although these are not expect to
-+    # build without first building modern cctools / linker.
-+    case $host_cpu-$host_os in
-+    *-rhapsody* | *-darwin1.[012])
-       _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
--    darwin1.*)
-+    *-darwin1.*)
-       _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
--    darwin*) # darwin 5.x on
--      # if running on 10.5 or later, the deployment target defaults
--      # to the OS version, if on x86, and 10.4, the deployment
--      # target defaults to 10.4. Don't you love it?
--      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
--	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
--	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-+    *-darwin*)
-+      # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
-+      # deployment target is forced to an earlier version.
-+      case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
-+	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
-+	  ;;
+   --enable-maintainer-mode
+                           enable make rules and dependencies not useful (and
+                           sometimes confusing) to the casual installer
+@@ -8283,7 +8288,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
  	10.[012][,.]*)
--	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
--	10.*)
--	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
--      esac
-+	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-+	  ;;
-+	*)
-+	  ;;
-+     esac
-     ;;
-   esac
-     if test "$lt_cv_apple_cc_single_mod" = "yes"; then
-@@ -9614,6 +9621,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -10257,6 +10262,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -11266,8 +8755,9 @@ index dfa8287fd75..84447cbb7eb 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -11275,15 +8765,16 @@ index dfa8287fd75..84447cbb7eb 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -11297,49 +8788,41 @@ index dfa8287fd75..84447cbb7eb 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -9631,10 +9679,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -10274,9 +10322,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -11420,7 +11477,7 @@ else
+@@ -12082,7 +12134,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11433 "configure"
-+#line 11480 "configure"
+-#line 12085 "configure"
++#line 12137 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11526,7 +11583,7 @@ else
+@@ -12188,7 +12240,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11539 "configure"
-+#line 11586 "configure"
+-#line 12191 "configure"
++#line 12243 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -12402,6 +12459,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13064,6 +13116,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
        darwin* | rhapsody*)
  
  
@@ -11356,8 +8839,9 @@ index dfa8287fd75..84447cbb7eb 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -11365,15 +8849,16 @@ index dfa8287fd75..84447cbb7eb 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -11387,65 +8872,32 @@ index dfa8287fd75..84447cbb7eb 100755
    archive_cmds_need_lc_CXX=no
    hardcode_direct_CXX=no
    hardcode_automatic_CXX=yes
-@@ -12419,12 +12517,25 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13081,12 +13176,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
         if test "$lt_cv_apple_cc_single_mod" != "yes"; then
 -      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++      _lt_install_name='\$rpath/\$soname'
 +      if test "x$enable_darwin_at_rpath" = "xyes"; then
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring${_lt_dsymutil}"
-+      else
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++        _lt_install_name='@rpath/\$soname'
 +      fi
++      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring${_lt_dsymutil}"
        archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
      fi
  
-@@ -14265,16 +14376,6 @@ freebsd* | dragonfly*)
-   esac
-   ;;
+@@ -15458,6 +15561,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
  
--gnu*)
--  version_type=linux
--  need_lib_prefix=no
--  need_version=no
--  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
--  soname_spec='${libname}${release}${shared_ext}$major'
--  shlibpath_var=LD_LIBRARY_PATH
--  hardcode_into_libs=yes
--  ;;
--
- haiku*)
-   version_type=linux
-   need_lib_prefix=no
-@@ -14396,7 +14497,7 @@ linux*oldld* | linux*aout* | linux*coff*)
- # project, but have not yet been accepted: they are GCC-local changes
- # for the time being.  (See
- # https://lists.gnu.org/archive/html/libtool-patches/2018-05/msg00000.html)
--linux* | k*bsd*-gnu | kopensolaris*-gnu | uclinuxfdpiceabi)
-+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu* | uclinuxfdpiceabi)
-   version_type=linux
-   need_lib_prefix=no
-   need_version=no
-@@ -14784,6 +14885,15 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
- # Only expand once:
  
  
 + if test x$enable_darwin_at_rpath = xyes; then
@@ -11456,137 +8908,148 @@ index dfa8287fd75..84447cbb7eb 100755
 +  ENABLE_DARWIN_AT_RPATH_FALSE=
 +fi
 +
-+
- # Forbid libtool to hardcode RPATH, because we want to be able to specify
- # library search directory using LD_LIBRARY_PATH
- hardcode_into_libs=no
-@@ -14999,6 +15109,10 @@ if test -z "${LIBOFFLOADMIC_HOST_TRUE}" && test -z "${LIBOFFLOADMIC_HOST_FALSE}"
-   as_fn_error $? "conditional \"LIBOFFLOADMIC_HOST\" was never defined.
+ 
+ 
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
+@@ -18216,6 +18327,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then
+   as_fn_error $? "conditional \"BUILD_INFO\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
 +if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
 +  as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
 +Usually this means the macro was only invoked conditionally." "$LINENO" 5
 +fi
- 
- : "${CONFIG_STATUS=./config.status}"
- ac_write_fail=0
-diff --git a/liboffloadmic/configure.ac b/liboffloadmic/configure.ac
-index f64f182e8ef..b96e7eaf9e3 100644
---- a/liboffloadmic/configure.ac
-+++ b/liboffloadmic/configure.ac
-@@ -118,6 +118,8 @@ esac
- 
- AC_LIBTOOL_DLOPEN
+ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+diff --git a/libitm/configure.ac b/libitm/configure.ac
+index 050d6b23e18..d0d108e1737 100644
+--- a/libitm/configure.ac
++++ b/libitm/configure.ac
+@@ -157,6 +157,7 @@ AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
  AM_PROG_LIBTOOL
+ AC_SUBST(enable_shared)
+ AC_SUBST(enable_static)
 +AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
-+
- # Forbid libtool to hardcode RPATH, because we want to be able to specify
- # library search directory using LD_LIBRARY_PATH
- hardcode_into_libs=no
-diff --git a/liboffloadmic/plugin/Makefile.in b/liboffloadmic/plugin/Makefile.in
-index 8d5ad0025c2..c53f2d32b3b 100644
---- a/liboffloadmic/plugin/Makefile.in
-+++ b/liboffloadmic/plugin/Makefile.in
-@@ -123,10 +123,10 @@ subdir = .
- ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
- am__aclocal_m4_deps = $(top_srcdir)/../../config/acx.m4 \
- 	$(top_srcdir)/../../config/depstand.m4 \
--	$(top_srcdir)/../../config/toolexeclibdir.m4 \
- 	$(top_srcdir)/../../config/lead-dot.m4 \
- 	$(top_srcdir)/../../config/multi.m4 \
- 	$(top_srcdir)/../../config/override.m4 \
-+	$(top_srcdir)/../../config/toolexeclibdir.m4 \
- 	$(top_srcdir)/../../libtool.m4 \
- 	$(top_srcdir)/../../ltoptions.m4 \
- 	$(top_srcdir)/../../ltsugar.m4 \
-diff --git a/liboffloadmic/plugin/aclocal.m4 b/liboffloadmic/plugin/aclocal.m4
-index 9fa1d1216c1..1bb91402f66 100644
---- a/liboffloadmic/plugin/aclocal.m4
-+++ b/liboffloadmic/plugin/aclocal.m4
-@@ -1169,10 +1169,10 @@ AC_SUBST([am__untar])
- 
- m4_include([../../config/acx.m4])
- m4_include([../../config/depstand.m4])
--m4_include([../../config/toolexeclibdir.m4])
- m4_include([../../config/lead-dot.m4])
- m4_include([../../config/multi.m4])
- m4_include([../../config/override.m4])
-+m4_include([../../config/toolexeclibdir.m4])
- m4_include([../../libtool.m4])
- m4_include([../../ltoptions.m4])
- m4_include([../../ltsugar.m4])
-diff --git a/liboffloadmic/plugin/configure b/liboffloadmic/plugin/configure
-index 0b21d7d4eed..a9416401a65 100755
---- a/liboffloadmic/plugin/configure
-+++ b/liboffloadmic/plugin/configure
-@@ -635,6 +635,8 @@ LIBOBJS
- get_gcc_base_ver
- toolexeclibdir
- toolexecdir
+ 
+ AM_MAINTAINER_MODE
+ 
+diff --git a/libitm/configure.tgt b/libitm/configure.tgt
+index 0362e61570a..2818a587ebf 100644
+--- a/libitm/configure.tgt
++++ b/libitm/configure.tgt
+@@ -50,7 +50,7 @@ fi
+ # Map the target cpu to an ARCH sub-directory.  At the same time,
+ # work out any special compilation flags as necessary.
+ case "${target_cpu}" in
+-  aarch64*)		ARCH=aarch64 ;;
++  aarch64* | arm64*)	ARCH=aarch64 ;;
+   alpha*)		ARCH=alpha ;;
+   rs6000 | powerpc*)
+ 	XCFLAGS="${XCFLAGS} -mhtm"
+diff --git a/libitm/testsuite/lib/libitm.exp b/libitm/testsuite/lib/libitm.exp
+index da918d1ee8d..61bbfa0c923 100644
+--- a/libitm/testsuite/lib/libitm.exp
++++ b/libitm/testsuite/lib/libitm.exp
+@@ -159,6 +159,7 @@ proc libitm_init { args } {
+     }
+ 
+     if [istarget *-*-darwin*] {
++	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
+ 	lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
+     }
+ 
+diff --git a/libitm/testsuite/libitm.c++/c++.exp b/libitm/testsuite/libitm.c++/c++.exp
+index de45e7e5480..1b0ead05fee 100644
+--- a/libitm/testsuite/libitm.c++/c++.exp
++++ b/libitm/testsuite/libitm.c++/c++.exp
+@@ -56,8 +56,10 @@ if { $lang_test_file_found } {
+     # Gather a list of all tests.
+     set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
+ 
++    set stdcxxadder ""
+     if { $blddir != "" } {
+ 	set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
++	set stdcxxadder "-B ${blddir}/${lang_library_path}"
+     } else {
+ 	set ld_library_path "$always_ld_library_path"
+     }
+@@ -72,7 +74,7 @@ if { $lang_test_file_found } {
+     }
+ 
+     # Main loop.
+-    dg-runtest $tests "" $libstdcxx_includes
++    dg-runtest $tests $stdcxxadder $libstdcxx_includes
+ }
+ 
+ # All done.
+diff --git a/libobjc/configure b/libobjc/configure
+index 6da20b8e4ff..7087d079450 100755
+--- a/libobjc/configure
++++ b/libobjc/configure
+@@ -636,6 +636,9 @@ OBJC_BOEHM_GC_LIBS
+ OBJC_BOEHM_GC_INCLUDES
+ OBJC_BOEHM_GC
+ OBJC_GCFLAGS
++extra_ldflags_libobjc
 +ENABLE_DARWIN_AT_RPATH_FALSE
 +ENABLE_DARWIN_AT_RPATH_TRUE
- CXXCPP
+ SET_MAKE
  CPP
  OTOOL64
-@@ -778,6 +780,7 @@ with_pic
+@@ -667,7 +670,6 @@ RANLIB
+ AR
+ AS
+ XCFLAGS
+-extra_ldflags_libobjc
+ lt_host_flags
+ OBJEXT
+ EXEEXT
+@@ -755,6 +757,7 @@ with_pic
  enable_fast_install
  with_gnu_ld
  enable_libtool_lock
 +enable_darwin_at_rpath
- with_gcc_major_version_only
- '
-       ac_precious_vars='build_alias
-@@ -1431,6 +1434,8 @@ Optional Features:
+ enable_tls
+ enable_objc_gc
+ with_target_bdw_gc
+@@ -1392,6 +1395,8 @@ Optional Features:
    --enable-fast-install[=PKGS]
                            optimize for fast installation [default=yes]
    --disable-libtool-lock  avoid locking (might break parallel builds)
 +  --enable-darwin-at-path install libraries with @rpath/library-name, requires
 +                          rpaths to be added to executables
+   --enable-tls            Use thread-local storage [default=yes]
+   --enable-objc-gc        enable use of Boehm's garbage collector with the GNU
+                           Objective-C runtime
+@@ -3431,17 +3436,6 @@ esac
  
- Optional Packages:
-   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-@@ -7280,23 +7285,25 @@ _LT_EOF
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
- $as_echo "$lt_cv_ld_force_load" >&6; }
--    case $host_os in
--    rhapsody* | darwin1.[012])
-+    # Allow for Darwin 4-7 (macOS 10.0-10.3) although these are not expect to
-+    # build without first building modern cctools / linker.
-+    case $host_cpu-$host_os in
-+    *-rhapsody* | *-darwin1.[012])
-       _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
--    darwin1.*)
-+    *-darwin1.*)
-       _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
--    darwin*) # darwin 5.x on
--      # if running on 10.5 or later, the deployment target defaults
--      # to the OS version, if on x86, and 10.4, the deployment
--      # target defaults to 10.4. Don't you love it?
--      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
--	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
--	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-+    *-darwin*)
-+      # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
-+      # deployment target is forced to an earlier version.
-+      case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
-+	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
-+	  ;;
+ 
+ 
+-case "${host}" in
+-  *-darwin*)
+-    # Darwin needs -single_module when linking libobjc
+-    extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
+-    ;;
+-  *-cygwin*|*-mingw*)
+-    # Tell libtool to build DLLs on Windows
+-    extra_ldflags_libobjc='$(lt_host_flags)'
+-    ;;
+-esac
+-
+ 
+ # Add CET specific flags if CET is enabled
+ 
+@@ -6973,7 +6967,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
  	10.[012][,.]*)
--	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
--	10.*)
--	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
--      esac
-+	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-+	  ;;
-+	*)
-+	  ;;
-+     esac
-     ;;
-   esac
-     if test "$lt_cv_apple_cc_single_mod" = "yes"; then
-@@ -9261,6 +9268,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -8950,6 +8944,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -11603,8 +9066,9 @@ index 0b21d7d4eed..a9416401a65 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -11612,15 +9076,16 @@ index 0b21d7d4eed..a9416401a65 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -11634,155 +9099,42 @@ index 0b21d7d4eed..a9416401a65 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -9278,10 +9326,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -8967,9 +9004,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -11067,7 +11124,7 @@ else
+@@ -10796,7 +10837,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11080 "configure"
-+#line 11127 "configure"
+-#line 10799 "configure"
++#line 10840 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11173,7 +11230,7 @@ else
+@@ -10902,7 +10943,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11186 "configure"
-+#line 11233 "configure"
+-#line 10905 "configure"
++#line 10946 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -12049,6 +12106,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-       darwin* | rhapsody*)
- 
- 
-+
-+  # Publish an arg to allow the user to select that Darwin host (and target)
-+  # libraries should be given install-names like @rpath/libfoo.dylib.  This
-+  # requires that the user of the library then adds an 'rpath' to the DSO that
-+  # needs access.
-+  # NOTE: there are defaults below, for systems that support rpaths.  The person
-+  # configuring can override the defaults for any system version that supports
-+  # them - they are, however, forced off for system versions without support.
-+  # Check whether --enable-darwin-at-rpath was given.
-+if test "${enable_darwin_at_rpath+set}" = set; then :
-+  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
-+    # This is not supported before macOS 10.5 / Darwin9.
-+    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
-+	enable_darwin_at_rpath=no
-+      ;;
-+    esac
-+   fi
-+else
-+  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+       enable_darwin_at_rpath=no
-+       ;;
-+
-+    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
-+    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
-+    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
-+      enable_darwin_at_rpath=yes
-+      ;;
-+    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
-+    # work with either DYLD_LIBRARY_PATH or embedded rpaths.
-+
-+    esac
-+
-+fi
-+
-+
-   archive_cmds_need_lc_CXX=no
-   hardcode_direct_CXX=no
-   hardcode_automatic_CXX=yes
-@@ -12066,12 +12164,25 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-   esac
-   if test "$_lt_dar_can_shared" = "yes"; then
-     output_verbose_link_cmd=func_echo_all
--    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    fi
-        if test "$lt_cv_apple_cc_single_mod" != "yes"; then
--      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-+      if test "x$enable_darwin_at_rpath" = "xyes"; then
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring${_lt_dsymutil}"
-+      else
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-+      fi
-       archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
-     fi
- 
-@@ -13912,16 +14023,6 @@ freebsd* | dragonfly*)
-   esac
-   ;;
- 
--gnu*)
--  version_type=linux
--  need_lib_prefix=no
--  need_version=no
--  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
--  soname_spec='${libname}${release}${shared_ext}$major'
--  shlibpath_var=LD_LIBRARY_PATH
--  hardcode_into_libs=yes
--  ;;
--
- haiku*)
-   version_type=linux
-   need_lib_prefix=no
-@@ -14043,7 +14144,7 @@ linux*oldld* | linux*aout* | linux*coff*)
- # project, but have not yet been accepted: they are GCC-local changes
- # for the time being.  (See
- # https://lists.gnu.org/archive/html/libtool-patches/2018-05/msg00000.html)
--linux* | k*bsd*-gnu | kopensolaris*-gnu | uclinuxfdpiceabi)
-+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu* | uclinuxfdpiceabi)
-   version_type=linux
-   need_lib_prefix=no
-   need_version=no
-@@ -14431,6 +14532,15 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
- # Only expand once:
+@@ -11174,6 +11215,38 @@ $as_echo "no" >&6; }
+ fi
  
  
 + if test x$enable_darwin_at_rpath = xyes; then
@@ -11794,11 +9146,34 @@ index 0b21d7d4eed..a9416401a65 100755
 +fi
 +
 +
- # Forbid libtool to hardcode RPATH, because we want to be able to specify
- # library search directory using LD_LIBRARY_PATH
- hardcode_into_libs=no
-@@ -14634,6 +14744,10 @@ if test -z "${PLUGIN_HOST_TRUE}" && test -z "${PLUGIN_HOST_FALSE}"; then
-   as_fn_error $? "conditional \"PLUGIN_HOST\" was never defined.
++# Must come after libtool is initialized.
++case "${host}" in
++  *-darwin[4567]*)
++    # Earlier Darwin versions need -single_module when linking libobjc; they
++    # do not support @rpath.
++    extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
++    ;;
++  *-darwin*)
++    # Otherwise, single_module is the default and multi-module is ignored and
++    # obsolete.
++    extra_ldflags_libobjc='$(lt_host_flags)'
++    if test "x$enable_darwin_at_rpath" = "xyes"; then
++      extra_ldflags_libobjc="${extra_ldflags_libobjc} -Wc,-nodefaultrpaths"
++      extra_ldflags_libobjc="${extra_ldflags_libobjc} -Wl,-rpath,@loader_path"
++    fi
++    ;;
++  *-cygwin*|*-mingw*)
++    # Tell libtool to build DLLs on Windows
++    extra_ldflags_libobjc='$(lt_host_flags)'
++    ;;
++esac
++
++
+ # -------
+ # Headers
+ # -------
+@@ -11915,6 +11988,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
 +if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
@@ -11808,21 +9183,62 @@ index 0b21d7d4eed..a9416401a65 100755
  
  : "${CONFIG_STATUS=./config.status}"
  ac_write_fail=0
-diff --git a/liboffloadmic/plugin/configure.ac b/liboffloadmic/plugin/configure.ac
-index cbcd0130d05..3329b03638d 100644
---- a/liboffloadmic/plugin/configure.ac
-+++ b/liboffloadmic/plugin/configure.ac
-@@ -134,6 +134,8 @@ esac
+diff --git a/libobjc/configure.ac b/libobjc/configure.ac
+index 9bd7d59d597..cb21ebbfcc7 100644
+--- a/libobjc/configure.ac
++++ b/libobjc/configure.ac
+@@ -148,17 +148,6 @@ m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
+ 
+ # extra LD Flags which are required for targets
+ ACX_LT_HOST_FLAGS
+-case "${host}" in
+-  *-darwin*)
+-    # Darwin needs -single_module when linking libobjc
+-    extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
+-    ;;
+-  *-cygwin*|*-mingw*)
+-    # Tell libtool to build DLLs on Windows
+-    extra_ldflags_libobjc='$(lt_host_flags)'
+-    ;;
+-esac
+-AC_SUBST(extra_ldflags_libobjc)
+ 
+ # Add CET specific flags if CET is enabled
+ GCC_CET_FLAGS(CET_FLAGS)
+@@ -183,6 +172,31 @@ AM_PROG_CC_C_O
+ 
+ AC_PROG_MAKE_SET
  
- AC_LIBTOOL_DLOPEN
- AM_PROG_LIBTOOL
 +AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
 +
- # Forbid libtool to hardcode RPATH, because we want to be able to specify
- # library search directory using LD_LIBRARY_PATH
- hardcode_into_libs=no
++# Must come after libtool is initialized.
++case "${host}" in
++  *-darwin[[4567]]*)
++    # Earlier Darwin versions need -single_module when linking libobjc; they
++    # do not support @rpath.
++    extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
++    ;;
++  *-darwin*)
++    # Otherwise, single_module is the default and multi-module is ignored and
++    # obsolete.
++    extra_ldflags_libobjc='$(lt_host_flags)'
++    if test "x$enable_darwin_at_rpath" = "xyes"; then
++      extra_ldflags_libobjc="${extra_ldflags_libobjc} -Wc,-nodefaultrpaths"
++      extra_ldflags_libobjc="${extra_ldflags_libobjc} -Wl,-rpath,@loader_path"
++    fi
++    ;;
++  *-cygwin*|*-mingw*)
++    # Tell libtool to build DLLs on Windows
++    extra_ldflags_libobjc='$(lt_host_flags)'
++    ;;
++esac
++AC_SUBST(extra_ldflags_libobjc)
++
+ # -------
+ # Headers
+ # -------
 diff --git a/libphobos/configure b/libphobos/configure
-index 9da06f087d0..9fbb3c91e93 100755
+index 925c53c5f5e..969ae6077cc 100755
 --- a/libphobos/configure
 +++ b/libphobos/configure
 @@ -707,6 +707,8 @@ get_gcc_base_ver
@@ -11851,7 +9267,16 @@ index 9da06f087d0..9fbb3c91e93 100755
    --enable-werror         turns on -Werror [default=no]
    --enable-version-specific-runtime-libs
                            Specify that runtime libraries should be installed
-@@ -9944,6 +9949,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -8244,7 +8249,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -9949,6 +9954,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -11868,8 +9293,9 @@ index 9da06f087d0..9fbb3c91e93 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -11877,15 +9303,16 @@ index 9da06f087d0..9fbb3c91e93 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -11899,49 +9326,41 @@ index 9da06f087d0..9fbb3c91e93 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -9961,10 +10007,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -9966,9 +10014,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -11750,7 +11805,7 @@ else
+@@ -11774,7 +11826,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11753 "configure"
-+#line 11808 "configure"
+-#line 11777 "configure"
++#line 11829 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11856,7 +11911,7 @@ else
+@@ -11880,7 +11932,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11859 "configure"
-+#line 11914 "configure"
+-#line 11883 "configure"
++#line 11935 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -13381,6 +13436,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13405,6 +13457,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -11958,8 +9377,9 @@ index 9da06f087d0..9fbb3c91e93 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -11967,15 +9387,16 @@ index 9da06f087d0..9fbb3c91e93 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -11989,31 +9410,23 @@ index 9da06f087d0..9fbb3c91e93 100755
    archive_cmds_need_lc_D=no
    hardcode_direct_D=no
    hardcode_automatic_D=yes
-@@ -13398,10 +13494,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13422,9 +13517,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds_D="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_D="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_D="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_D="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_D="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_D="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_D="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_D="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_D="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_D="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_D="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_D="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds_D="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_D="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_D="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_D="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_D="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs_D=no
-@@ -14002,6 +14107,14 @@ CFLAGS=$lt_save_CFLAGS
+@@ -14026,6 +14125,14 @@ CFLAGS=$lt_save_CFLAGS
  
  
  
@@ -12028,7 +9441,7 @@ index 9da06f087d0..9fbb3c91e93 100755
  
  # libtool variables for Phobos shared and position-independent compiles.
  #
-@@ -15726,6 +15839,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+@@ -15750,6 +15857,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
    as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
@@ -12040,7 +9453,7 @@ index 9da06f087d0..9fbb3c91e93 100755
    as_fn_error $? "conditional \"DRUNTIME_CPU_AARCH64\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
 diff --git a/libphobos/configure.ac b/libphobos/configure.ac
-index 31209ba2920..cc372587939 100644
+index 464f4105430..ba8b5ecd65b 100644
 --- a/libphobos/configure.ac
 +++ b/libphobos/configure.ac
 @@ -93,6 +93,7 @@ AM_PROG_LIBTOOL
@@ -12052,7 +9465,7 @@ index 31209ba2920..cc372587939 100644
  # libtool variables for Phobos shared and position-independent compiles.
  #
 diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am
-index 6ca4012b713..861ec0ebc03 100644
+index 8225ba4a028..186948806d5 100644
 --- a/libphobos/libdruntime/Makefile.am
 +++ b/libphobos/libdruntime/Makefile.am
 @@ -128,8 +128,11 @@ ALL_DRUNTIME_SOURCES = $(DRUNTIME_DSOURCES) $(DRUNTIME_CSOURCES) \
@@ -12069,10 +9482,10 @@ index 6ca4012b713..861ec0ebc03 100644
  libgdruntime_la_DEPENDENCIES = $(DRTSTUFF)
  # Also override library link commands: This is not strictly
 diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in
-index f7f78d71ff7..9f3361c7702 100644
+index 797d6435a7c..cd13090010f 100644
 --- a/libphobos/libdruntime/Makefile.in
 +++ b/libphobos/libdruntime/Makefile.in
-@@ -805,8 +805,9 @@ ALL_DRUNTIME_SOURCES = $(DRUNTIME_DSOURCES) $(DRUNTIME_CSOURCES) \
+@@ -810,8 +810,9 @@ ALL_DRUNTIME_SOURCES = $(DRUNTIME_DSOURCES) $(DRUNTIME_CSOURCES) \
  toolexeclib_LTLIBRARIES = libgdruntime.la
  libgdruntime_la_SOURCES = $(ALL_DRUNTIME_SOURCES)
  libgdruntime_la_LIBTOOLFLAGS = 
@@ -12084,7 +9497,7 @@ index f7f78d71ff7..9f3361c7702 100644
  libgdruntime_la_LIBADD = $(LIBATOMIC) $(LIBBACKTRACE)
  libgdruntime_la_DEPENDENCIES = $(DRTSTUFF)
 diff --git a/libphobos/src/Makefile.am b/libphobos/src/Makefile.am
-index da7a2004ff8..a47d985c5b7 100644
+index 6474fca5eb5..f6521ed5860 100644
 --- a/libphobos/src/Makefile.am
 +++ b/libphobos/src/Makefile.am
 @@ -44,8 +44,11 @@ toolexeclib_DATA = libgphobos.spec
@@ -12101,10 +9514,10 @@ index da7a2004ff8..a47d985c5b7 100644
  libgphobos_la_LIBADD = ../libdruntime/libgdruntime_convenience.la
  else
 diff --git a/libphobos/src/Makefile.in b/libphobos/src/Makefile.in
-index 6f58fee01ac..212ea2469f2 100644
+index a6229587e7b..cc3358b437e 100644
 --- a/libphobos/src/Makefile.in
 +++ b/libphobos/src/Makefile.in
-@@ -528,8 +528,9 @@ toolexeclib_DATA = libgphobos.spec
+@@ -529,8 +529,9 @@ toolexeclib_DATA = libgphobos.spec
  toolexeclib_LTLIBRARIES = libgphobos.la
  libgphobos_la_SOURCES = $(ALL_PHOBOS_SOURCES)
  libgphobos_la_LIBTOOLFLAGS = 
@@ -12116,7 +9529,7 @@ index 6f58fee01ac..212ea2469f2 100644
  @ENABLE_LIBDRUNTIME_ONLY_FALSE@libgphobos_la_LIBADD = \
  @ENABLE_LIBDRUNTIME_ONLY_FALSE@    ../libdruntime/libgdruntime_convenience.la $(LIBZ)
 diff --git a/libquadmath/Makefile.am b/libquadmath/Makefile.am
-index 35dffb46f6e..4bf4bf6eebc 100644
+index 35dffb46f6e..0d02c95e738 100644
 --- a/libquadmath/Makefile.am
 +++ b/libquadmath/Makefile.am
 @@ -36,8 +36,13 @@ endif
@@ -12130,12 +9543,12 @@ index 35dffb46f6e..4bf4bf6eebc 100644
 +endif
  libquadmath_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
 -			 $(version_arg) $(lt_host_flags) -lm
-+	$(version_arg) $(lt_host_flags) $(LIBM) $(libquadmath_darwin_rpath) 
++	$(version_arg) $(lt_host_flags) $(LIBM) $(libquadmath_darwin_rpath)
  libquadmath_la_DEPENDENCIES = $(version_dep) $(libquadmath_la_LIBADD)
  
  nodist_libsubinclude_HEADERS = quadmath.h quadmath_weak.h
 diff --git a/libquadmath/Makefile.in b/libquadmath/Makefile.in
-index 8c011212258..b59aac7f1ac 100644
+index 8c011212258..068af559457 100644
 --- a/libquadmath/Makefile.in
 +++ b/libquadmath/Makefile.in
 @@ -355,6 +355,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -12154,12 +9567,12 @@ index 8c011212258..b59aac7f1ac 100644
 +@BUILD_LIBQUADMATH_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@	-Wl,-rpath,@loader_path
  @BUILD_LIBQUADMATH_TRUE@libquadmath_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
 -@BUILD_LIBQUADMATH_TRUE@			 $(version_arg) $(lt_host_flags) -lm
-+@BUILD_LIBQUADMATH_TRUE@	$(version_arg) $(lt_host_flags) $(LIBM) $(libquadmath_darwin_rpath) 
++@BUILD_LIBQUADMATH_TRUE@	$(version_arg) $(lt_host_flags) $(LIBM) $(libquadmath_darwin_rpath)
  
  @BUILD_LIBQUADMATH_TRUE@libquadmath_la_DEPENDENCIES = $(version_dep) $(libquadmath_la_LIBADD)
  @BUILD_LIBQUADMATH_TRUE@nodist_libsubinclude_HEADERS = quadmath.h quadmath_weak.h
 diff --git a/libquadmath/configure b/libquadmath/configure
-index b3ee64f9c7d..23a99be108f 100755
+index 958fb876c5b..9b1703d6ee5 100755
 --- a/libquadmath/configure
 +++ b/libquadmath/configure
 @@ -644,11 +644,14 @@ LIBQUAD_USE_SYMVER_GNU_FALSE
@@ -12194,7 +9607,16 @@ index b3ee64f9c7d..23a99be108f 100755
    --enable-maintainer-mode
                            enable make rules and dependencies not useful (and
                            sometimes confusing) to the casual installer
-@@ -8979,6 +8985,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -7272,7 +7278,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -8984,6 +8990,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -12211,8 +9633,9 @@ index b3ee64f9c7d..23a99be108f 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -12220,15 +9643,16 @@ index b3ee64f9c7d..23a99be108f 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -12242,49 +9666,41 @@ index b3ee64f9c7d..23a99be108f 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -8996,10 +9043,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -9001,9 +9050,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -10806,7 +10862,7 @@ else
+@@ -10830,7 +10883,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 10819 "configure"
-+#line 10865 "configure"
+-#line 10833 "configure"
++#line 10886 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -10912,7 +10968,7 @@ else
+@@ -10936,7 +10989,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 10925 "configure"
-+#line 10971 "configure"
+-#line 10939 "configure"
++#line 10992 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11173,6 +11229,14 @@ esac
+@@ -11197,6 +11250,14 @@ esac
  
  
  
@@ -12299,7 +9715,7 @@ index b3ee64f9c7d..23a99be108f 100755
  
  
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
-@@ -12137,6 +12201,148 @@ esac
+@@ -12161,6 +12222,148 @@ esac
  
  
  
@@ -12448,16 +9864,7 @@ index b3ee64f9c7d..23a99be108f 100755
  for ac_header in fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h
  do :
    as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-@@ -13031,7 +13237,7 @@ case "$host" in
-     case "$enable_cet" in
-       auto)
- 	# Check if target supports multi-byte NOPs
--	# and if assembler supports CET insn.
-+	# and if compiler and assembler support CET insn.
- 	cet_save_CFLAGS="$CFLAGS"
- 	CFLAGS="$CFLAGS -fcf-protection"
- 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-@@ -13397,6 +13603,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then
+@@ -13421,6 +13624,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then
    as_fn_error $? "conditional \"BUILD_INFO\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
@@ -12489,18 +9896,6 @@ index eec4084a45f..94a3f2179e9 100644
  AC_CHECK_HEADERS(fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h)
  LIBQUAD_CHECK_MATH_H_SIGNGAM
  
-diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in
-index aab88deb6e8..65e7f2e9553 100644
---- a/libsanitizer/Makefile.in
-+++ b/libsanitizer/Makefile.in
-@@ -345,7 +345,6 @@ pdfdir = @pdfdir@
- prefix = @prefix@
- program_transform_name = @program_transform_name@
- psdir = @psdir@
--runstatedir = @runstatedir@
- sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
- srcdir = @srcdir@
 diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
 index 4f802f723d6..223d3e07816 100644
 --- a/libsanitizer/asan/Makefile.am
@@ -12520,18 +9915,10 @@ index 4f802f723d6..223d3e07816 100644
  libasan_preinit.o: asan_preinit.o
  	cp $< $@
 diff --git a/libsanitizer/asan/Makefile.in b/libsanitizer/asan/Makefile.in
-index 2476fbc5a26..e88e5e0b0a7 100644
+index 7833a9a4c3f..e88e5e0b0a7 100644
 --- a/libsanitizer/asan/Makefile.in
 +++ b/libsanitizer/asan/Makefile.in
-@@ -399,7 +399,6 @@ pdfdir = @pdfdir@
- prefix = @prefix@
- program_transform_name = @program_transform_name@
- psdir = @psdir@
--runstatedir = @runstatedir@
- sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
- srcdir = @srcdir@
-@@ -466,7 +465,12 @@ libasan_la_LIBADD =  \
+@@ -465,7 +465,12 @@ libasan_la_LIBADD =  \
  	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
  	$(top_builddir)/lsan/libsanitizer_lsan.la $(am__append_2) \
  	$(am__append_3) $(LIBSTDCXX_RAW_CXX_LDFLAGS)
@@ -12546,7 +9933,7 @@ index 2476fbc5a26..e88e5e0b0a7 100644
  # Work around what appears to be a GNU make bug handling MAKEFLAGS
  # values defined in terms of make variables, as is the case for CC and
 diff --git a/libsanitizer/configure b/libsanitizer/configure
-index 771b135573a..dfd99e34288 100755
+index e7984f96615..43b8b1b0737 100755
 --- a/libsanitizer/configure
 +++ b/libsanitizer/configure
 @@ -666,6 +666,8 @@ LSAN_SUPPORTED_FALSE
@@ -12575,7 +9962,16 @@ index 771b135573a..dfd99e34288 100755
    --disable-werror        disable building with -Werror
    --enable-cet            enable Intel CET in target libraries [default=auto]
  
-@@ -10553,6 +10558,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -8853,7 +8858,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -10558,6 +10563,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -12592,8 +9988,9 @@ index 771b135573a..dfd99e34288 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -12601,15 +9998,16 @@ index 771b135573a..dfd99e34288 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -12623,49 +10021,41 @@ index 771b135573a..dfd99e34288 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -10570,10 +10616,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -10575,9 +10623,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -12359,7 +12414,7 @@ else
+@@ -12383,7 +12435,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 12362 "configure"
-+#line 12417 "configure"
+-#line 12386 "configure"
++#line 12438 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -12465,7 +12520,7 @@ else
+@@ -12489,7 +12541,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 12468 "configure"
-+#line 12523 "configure"
+-#line 12492 "configure"
++#line 12544 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -13341,6 +13396,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13365,6 +13417,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
        darwin* | rhapsody*)
  
  
@@ -12682,8 +10072,9 @@ index 771b135573a..dfd99e34288 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -12691,15 +10082,16 @@ index 771b135573a..dfd99e34288 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -12713,38 +10105,31 @@ index 771b135573a..dfd99e34288 100755
    archive_cmds_need_lc_CXX=no
    hardcode_direct_CXX=no
    hardcode_automatic_CXX=yes
-@@ -13358,12 +13454,25 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13382,12 +13477,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
         if test "$lt_cv_apple_cc_single_mod" != "yes"; then
 -      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++      _lt_install_name='\$rpath/\$soname'
 +      if test "x$enable_darwin_at_rpath" = "xyes"; then
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring${_lt_dsymutil}"
-+      else
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++        _lt_install_name='@rpath/\$soname'
 +      fi
++      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring${_lt_dsymutil}"
        archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
      fi
  
-@@ -15763,6 +15872,15 @@ esac
+@@ -15807,6 +15910,15 @@ esac
  
  
  
@@ -12760,7 +10145,7 @@ index 771b135573a..dfd99e34288 100755
  # The cast to long int works around a bug in the HP C Compiler
  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-@@ -17152,6 +17270,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then
+@@ -17205,6 +17317,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then
    as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
@@ -12772,7 +10157,7 @@ index 771b135573a..dfd99e34288 100755
    as_fn_error $? "conditional \"TSAN_SUPPORTED\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
 diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
-index 7f1ef3979c4..3549b904c62 100644
+index 04cd8910ed6..5906c8d4887 100644
 --- a/libsanitizer/configure.ac
 +++ b/libsanitizer/configure.ac
 @@ -85,6 +85,8 @@ esac
@@ -12785,10 +10170,10 @@ index 7f1ef3979c4..3549b904c62 100644
  
  if test "${multilib}" = "yes"; then
 diff --git a/libsanitizer/hwasan/Makefile.am b/libsanitizer/hwasan/Makefile.am
-index e12c0a0ce71..4061078c734 100644
+index 5a89189f6d8..11b1a9c5c57 100644
 --- a/libsanitizer/hwasan/Makefile.am
 +++ b/libsanitizer/hwasan/Makefile.am
-@@ -46,7 +46,11 @@ libhwasan_la_LIBADD += $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
+@@ -47,7 +47,11 @@ libhwasan_la_LIBADD += $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
  endif
  libhwasan_la_LIBADD += $(LIBSTDCXX_RAW_CXX_LDFLAGS)
  
@@ -12799,21 +10184,13 @@ index e12c0a0ce71..4061078c734 100644
 +libhwasan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
 +	$(link_libhwasan) $(libhwasan_darwin_rpath)
  
- # Work around what appears to be a GNU make bug handling MAKEFLAGS
- # values defined in terms of make variables, as is the case for CC and
+ libhwasan_preinit.o: hwasan_preinit.o
+ 	cp $< $@
 diff --git a/libsanitizer/hwasan/Makefile.in b/libsanitizer/hwasan/Makefile.in
-index 67553f3979d..d20f2dc6eef 100644
+index 4240aa90147..f9ec8f9c177 100644
 --- a/libsanitizer/hwasan/Makefile.in
 +++ b/libsanitizer/hwasan/Makefile.in
-@@ -387,7 +387,6 @@ pdfdir = @pdfdir@
- prefix = @prefix@
- program_transform_name = @program_transform_name@
- psdir = @psdir@
--runstatedir = @runstatedir@
- sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
- srcdir = @srcdir@
-@@ -442,7 +441,10 @@ libhwasan_la_SOURCES = $(hwasan_files)
+@@ -445,7 +445,10 @@ libhwasan_la_SOURCES = $(hwasan_files)
  libhwasan_la_LIBADD =  \
  	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
  	$(am__append_1) $(am__append_2) $(LIBSTDCXX_RAW_CXX_LDFLAGS)
@@ -12825,30 +10202,6 @@ index 67553f3979d..d20f2dc6eef 100644
  
  # Work around what appears to be a GNU make bug handling MAKEFLAGS
  # values defined in terms of make variables, as is the case for CC and
-diff --git a/libsanitizer/interception/Makefile.in b/libsanitizer/interception/Makefile.in
-index bce788aeea7..85dd386de47 100644
---- a/libsanitizer/interception/Makefile.in
-+++ b/libsanitizer/interception/Makefile.in
-@@ -317,7 +317,6 @@ pdfdir = @pdfdir@
- prefix = @prefix@
- program_transform_name = @program_transform_name@
- psdir = @psdir@
--runstatedir = @runstatedir@
- sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
- srcdir = @srcdir@
-diff --git a/libsanitizer/libbacktrace/Makefile.in b/libsanitizer/libbacktrace/Makefile.in
-index ece4f11a855..c0243fa4aab 100644
---- a/libsanitizer/libbacktrace/Makefile.in
-+++ b/libsanitizer/libbacktrace/Makefile.in
-@@ -367,7 +367,6 @@ pdfdir = @pdfdir@
- prefix = @prefix@
- program_transform_name = @program_transform_name@
- psdir = @psdir@
--runstatedir = @runstatedir@
- sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
- srcdir = @srcdir@
 diff --git a/libsanitizer/lsan/Makefile.am b/libsanitizer/lsan/Makefile.am
 index 6ff28ff5eea..7701b0e18cf 100644
 --- a/libsanitizer/lsan/Makefile.am
@@ -12869,18 +10222,10 @@ index 6ff28ff5eea..7701b0e18cf 100644
  	cp $< $@
  
 diff --git a/libsanitizer/lsan/Makefile.in b/libsanitizer/lsan/Makefile.in
-index 857f244cd86..078edf01fda 100644
+index d8fd4ee9557..078edf01fda 100644
 --- a/libsanitizer/lsan/Makefile.in
 +++ b/libsanitizer/lsan/Makefile.in
-@@ -362,7 +362,6 @@ pdfdir = @pdfdir@
- prefix = @prefix@
- program_transform_name = @program_transform_name@
- psdir = @psdir@
--runstatedir = @runstatedir@
- sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
- srcdir = @srcdir@
-@@ -414,7 +413,12 @@ liblsan_la_LIBADD =  \
+@@ -413,7 +413,12 @@ liblsan_la_LIBADD =  \
  	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
  	$(top_builddir)/interception/libinterception.la \
  	$(am__append_1) $(LIBSTDCXX_RAW_CXX_LDFLAGS)
@@ -12894,7 +10239,7 @@ index 857f244cd86..078edf01fda 100644
  
  # Work around what appears to be a GNU make bug handling MAKEFLAGS
  # values defined in terms of make variables, as is the case for CC and
-@@ -789,7 +793,6 @@ uninstall-am: uninstall-nodist_toolexeclibHEADERS \
+@@ -788,7 +793,6 @@ uninstall-am: uninstall-nodist_toolexeclibHEADERS \
  
  .PRECIOUS: Makefile
  
@@ -12902,23 +10247,11 @@ index 857f244cd86..078edf01fda 100644
  liblsan_preinit.o: lsan_preinit.o
  	cp $< $@
  
-diff --git a/libsanitizer/sanitizer_common/Makefile.in b/libsanitizer/sanitizer_common/Makefile.in
-index c4b009fed83..e5e1c1d51fe 100644
---- a/libsanitizer/sanitizer_common/Makefile.in
-+++ b/libsanitizer/sanitizer_common/Makefile.in
-@@ -354,7 +354,6 @@ pdfdir = @pdfdir@
- prefix = @prefix@
- program_transform_name = @program_transform_name@
- psdir = @psdir@
--runstatedir = @runstatedir@
- sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
- srcdir = @srcdir@
 diff --git a/libsanitizer/tsan/Makefile.am b/libsanitizer/tsan/Makefile.am
-index ae588a67df6..47ee50bee1a 100644
+index da80743da9d..01290b0313d 100644
 --- a/libsanitizer/tsan/Makefile.am
 +++ b/libsanitizer/tsan/Makefile.am
-@@ -58,7 +58,11 @@ libtsan_la_LIBADD += $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
+@@ -57,7 +57,11 @@ libtsan_la_LIBADD += $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
  libtsan_la_DEPENDENCIES +=$(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la
  endif
  libtsan_la_LIBADD += $(LIBSTDCXX_RAW_CXX_LDFLAGS)
@@ -12932,18 +10265,10 @@ index ae588a67df6..47ee50bee1a 100644
  libtsan_preinit.o: tsan_preinit.o
  	cp $< $@
 diff --git a/libsanitizer/tsan/Makefile.in b/libsanitizer/tsan/Makefile.in
-index 538d2e8eb68..d6efff71e2f 100644
+index 36498832bb8..95011584bcb 100644
 --- a/libsanitizer/tsan/Makefile.in
 +++ b/libsanitizer/tsan/Makefile.in
-@@ -391,7 +391,6 @@ pdfdir = @pdfdir@
- prefix = @prefix@
- program_transform_name = @program_transform_name@
- psdir = @psdir@
--runstatedir = @runstatedir@
- sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
- srcdir = @srcdir@
-@@ -466,7 +465,10 @@ libtsan_la_DEPENDENCIES =  \
+@@ -464,7 +464,10 @@ libtsan_la_DEPENDENCIES =  \
  	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
  	$(top_builddir)/interception/libinterception.la \
  	$(TSAN_TARGET_DEPENDENT_OBJECTS) $(am__append_2)
@@ -12974,18 +10299,10 @@ index d480f26adc0..7769b3437e4 100644
  # Use special rules for files that require RTTI support.
  ubsan_handlers_cxx.% ubsan_type_hash.% ubsan_type_hash_itanium.% : AM_CXXFLAGS += -frtti
 diff --git a/libsanitizer/ubsan/Makefile.in b/libsanitizer/ubsan/Makefile.in
-index 497e0338696..7e51480e970 100644
+index 92a8e387fd7..7e51480e970 100644
 --- a/libsanitizer/ubsan/Makefile.in
 +++ b/libsanitizer/ubsan/Makefile.in
-@@ -356,7 +356,6 @@ pdfdir = @pdfdir@
- prefix = @prefix@
- program_transform_name = @program_transform_name@
- psdir = @psdir@
--runstatedir = @runstatedir@
- sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
- srcdir = @srcdir@
-@@ -401,7 +400,12 @@ libubsan_la_SOURCES = $(ubsan_files)
+@@ -400,7 +400,12 @@ libubsan_la_SOURCES = $(ubsan_files)
  libubsan_la_LIBADD =  \
  	$(top_builddir)/sanitizer_common/libsanitizer_common.la \
  	$(am__append_1) $(am__append_2) $(LIBSTDCXX_RAW_CXX_LDFLAGS)
@@ -13000,7 +10317,7 @@ index 497e0338696..7e51480e970 100644
  # Work around what appears to be a GNU make bug handling MAKEFLAGS
  # values defined in terms of make variables, as is the case for CC and
 diff --git a/libssp/Makefile.am b/libssp/Makefile.am
-index 945dc3c8336..d2a92b3aed1 100644
+index 1636e43b369..f7ed2aa6043 100644
 --- a/libssp/Makefile.am
 +++ b/libssp/Makefile.am
 @@ -49,8 +49,12 @@ libssp_la_SOURCES = \
@@ -13035,7 +10352,7 @@ index bc8a0dc2b28..1cf86361b96 100644
  libssp_nonshared_la_SOURCES = \
  	ssp-local.c
 diff --git a/libssp/configure b/libssp/configure
-index 10ba209bde8..5d62fef54a1 100755
+index 492915d2ce0..7a3c784aaf4 100755
 --- a/libssp/configure
 +++ b/libssp/configure
 @@ -636,6 +636,8 @@ LIBOBJS
@@ -13064,16 +10381,16 @@ index 10ba209bde8..5d62fef54a1 100755
  
  Optional Packages:
    --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-@@ -4338,7 +4343,7 @@ case "$host" in
-     case "$enable_cet" in
-       auto)
- 	# Check if target supports multi-byte NOPs
--	# and if assembler supports CET insn.
-+	# and if compiler and assembler support CET insn.
- 	cet_save_CFLAGS="$CFLAGS"
- 	CFLAGS="$CFLAGS -fcf-protection"
- 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-@@ -9165,6 +9170,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -7458,7 +7463,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -9170,6 +9175,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -13090,8 +10407,9 @@ index 10ba209bde8..5d62fef54a1 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -13099,15 +10417,16 @@ index 10ba209bde8..5d62fef54a1 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -13121,49 +10440,41 @@ index 10ba209bde8..5d62fef54a1 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -9182,10 +9228,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -9187,9 +9235,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -10992,7 +11047,7 @@ else
+@@ -11016,7 +11068,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11005 "configure"
-+#line 11050 "configure"
+-#line 11019 "configure"
++#line 11071 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11098,7 +11153,7 @@ else
+@@ -11122,7 +11174,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 11111 "configure"
-+#line 11156 "configure"
+-#line 11125 "configure"
++#line 11177 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11376,6 +11431,15 @@ fi
+@@ -11400,6 +11452,15 @@ fi
  
  
  
@@ -13179,7 +10490,7 @@ index 10ba209bde8..5d62fef54a1 100755
  # Calculate toolexeclibdir
  # Also toolexecdir, though it's only used in toolexeclibdir
  case ${version_specific_libs} in
-@@ -11585,6 +11649,10 @@ if test -z "${LIBSSP_USE_SYMVER_SUN_TRUE}" && test -z "${LIBSSP_USE_SYMVER_SUN_F
+@@ -11609,6 +11670,10 @@ if test -z "${LIBSSP_USE_SYMVER_SUN_TRUE}" && test -z "${LIBSSP_USE_SYMVER_SUN_F
    as_fn_error $? "conditional \"LIBSSP_USE_SYMVER_SUN\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
@@ -13204,10 +10515,10 @@ index f30f81c54f6..90778e2355d 100644
  # Also toolexecdir, though it's only used in toolexeclibdir
  case ${version_specific_libs} in
 diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
-index eac60392121..bdaa160dac6 100755
+index 9b602777545..7f1874c413a 100755
 --- a/libstdc++-v3/configure
 +++ b/libstdc++-v3/configure
-@@ -786,6 +786,8 @@ GLIBCXX_HOSTED_TRUE
+@@ -789,6 +789,8 @@ GLIBCXX_HOSTED_TRUE
  glibcxx_compiler_shared_flag
  glibcxx_compiler_pic_flag
  glibcxx_lt_pic_flag
@@ -13216,15 +10527,15 @@ index eac60392121..bdaa160dac6 100755
  enable_static
  enable_shared
  lt_host_flags
-@@ -921,6 +923,7 @@ with_pic
+@@ -924,6 +926,7 @@ with_pic
  enable_fast_install
  with_gnu_ld
  enable_libtool_lock
 +enable_darwin_at_rpath
  enable_hosted_libstdcxx
+ enable_libstdcxx_hosted
  enable_libstdcxx_verbose
- enable_libstdcxx_pch
-@@ -1608,6 +1611,8 @@ Optional Features:
+@@ -1615,6 +1618,8 @@ Optional Features:
    --enable-fast-install[=PKGS]
                            optimize for fast installation [default=yes]
    --disable-libtool-lock  avoid locking (might break parallel builds)
@@ -13232,8 +10543,17 @@ index eac60392121..bdaa160dac6 100755
 +                          rpaths to be added to executables
    --disable-hosted-libstdcxx
                            only build freestanding C++ runtime support
-   --disable-libstdcxx-verbose
-@@ -10364,6 +10369,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+   --disable-libstdcxx-hosted
+@@ -8501,7 +8506,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -10341,6 +10346,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -13250,8 +10570,9 @@ index eac60392121..bdaa160dac6 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -13259,15 +10580,16 @@ index eac60392121..bdaa160dac6 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -13281,49 +10603,41 @@ index eac60392121..bdaa160dac6 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -10381,10 +10427,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -10358,9 +10406,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -12191,7 +12246,7 @@ else
+@@ -12187,7 +12239,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 12194 "configure"
-+#line 12249 "configure"
+-#line 12190 "configure"
++#line 12242 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -12297,7 +12352,7 @@ else
+@@ -12293,7 +12345,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 12300 "configure"
-+#line 12355 "configure"
+-#line 12296 "configure"
++#line 12348 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -13179,6 +13234,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13175,6 +13227,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
        darwin* | rhapsody*)
  
  
@@ -13340,8 +10654,9 @@ index eac60392121..bdaa160dac6 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -13349,15 +10664,16 @@ index eac60392121..bdaa160dac6 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -13371,38 +10687,31 @@ index eac60392121..bdaa160dac6 100755
    archive_cmds_need_lc_CXX=no
    hardcode_direct_CXX=no
    hardcode_automatic_CXX=yes
-@@ -13196,12 +13292,25 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13192,12 +13287,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
         if test "$lt_cv_apple_cc_single_mod" != "yes"; then
 -      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++      _lt_install_name='\$rpath/\$soname'
 +      if test "x$enable_darwin_at_rpath" = "xyes"; then
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring${_lt_dsymutil}"
-+      else
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++        _lt_install_name='@rpath/\$soname'
 +      fi
++      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring${_lt_dsymutil}"
        archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
      fi
  
-@@ -15578,6 +15687,14 @@ esac
+@@ -15594,6 +15697,14 @@ esac
  
  
  
@@ -13417,61 +10726,61 @@ index eac60392121..bdaa160dac6 100755
  
  if test "$enable_vtable_verify" = yes; then
    predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
-@@ -15981,7 +16098,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
+@@ -16017,7 +16128,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
    # Fake what AC_TRY_COMPILE does.
  
      cat > conftest.$ac_ext << EOF
--#line 15984 "configure"
-+#line 16101 "configure"
+-#line 16020 "configure"
++#line 16131 "configure"
  int main()
  {
    typedef bool atomic_type;
-@@ -16016,7 +16133,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
+@@ -16052,7 +16163,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
      rm -f conftest*
  
      cat > conftest.$ac_ext << EOF
--#line 16019 "configure"
-+#line 16136 "configure"
+-#line 16055 "configure"
++#line 16166 "configure"
  int main()
  {
    typedef short atomic_type;
-@@ -16051,7 +16168,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
+@@ -16087,7 +16198,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
      rm -f conftest*
  
      cat > conftest.$ac_ext << EOF
--#line 16054 "configure"
-+#line 16171 "configure"
+-#line 16090 "configure"
++#line 16201 "configure"
  int main()
  {
    // NB: _Atomic_word not necessarily int.
-@@ -16087,7 +16204,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
+@@ -16123,7 +16234,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
      rm -f conftest*
  
      cat > conftest.$ac_ext << EOF
--#line 16090 "configure"
-+#line 16207 "configure"
+-#line 16126 "configure"
++#line 16237 "configure"
  int main()
  {
    typedef long long atomic_type;
-@@ -16243,7 +16360,7 @@ $as_echo "mutex" >&6; }
+@@ -16279,7 +16390,7 @@ $as_echo "mutex" >&6; }
    # unnecessary for this test.
  
      cat > conftest.$ac_ext << EOF
--#line 16246 "configure"
-+#line 16363 "configure"
+-#line 16282 "configure"
++#line 16393 "configure"
  int main()
  {
    _Decimal32 d1;
-@@ -16285,7 +16402,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+@@ -16321,7 +16432,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
    # unnecessary for this test.
  
    cat > conftest.$ac_ext << EOF
--#line 16288 "configure"
-+#line 16405 "configure"
+-#line 16324 "configure"
++#line 16435 "configure"
  template
    struct same
    { typedef T2 type; };
-@@ -79038,6 +79155,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+@@ -73038,6 +73149,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
    as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
@@ -13483,10 +10792,10 @@ index eac60392121..bdaa160dac6 100755
    as_fn_error $? "conditional \"GLIBCXX_HOSTED\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
 diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
-index e59bcdb2944..f3dda5a4ff9 100644
+index 91b3c1f32f2..8832c70de3c 100644
 --- a/libstdc++-v3/configure.ac
 +++ b/libstdc++-v3/configure.ac
-@@ -99,6 +99,7 @@ AM_PROG_LIBTOOL
+@@ -108,6 +108,7 @@ AM_PROG_LIBTOOL
  ACX_LT_HOST_FLAGS
  AC_SUBST(enable_shared)
  AC_SUBST(enable_static)
@@ -13494,27 +10803,11 @@ index e59bcdb2944..f3dda5a4ff9 100644
  
  if test "$enable_vtable_verify" = yes; then
    predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
-diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
-index ec32980aa0d..da5b1578d91 100644
---- a/libstdc++-v3/configure.host
-+++ b/libstdc++-v3/configure.host
-@@ -234,11 +234,6 @@ case "${host_os}" in
-   darwin8 | darwin8.* )
-     # For 8+ compatibility is better if not -flat_namespace.
-     OPT_LDFLAGS="${OPT_LDFLAGS} -Wl,-single_module"
--    case "${host_cpu}" in
--      i[34567]86 | x86_64)
--        OPTIMIZE_CXXFLAGS="${OPTIMIZE_CXXFLAGS} -fvisibility-inlines-hidden"
--        ;;
--    esac
-     os_include_dir="os/bsd/darwin"
-     ;;
-   darwin*)
 diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
-index 9c3f4aca655..016d68ecd5f 100644
+index 5b9af41cdb9..925137c2ccc 100644
 --- a/libstdc++-v3/src/Makefile.am
 +++ b/libstdc++-v3/src/Makefile.am
-@@ -133,8 +133,13 @@ libstdc___la_DEPENDENCIES = \
+@@ -152,8 +152,13 @@ libstdc___la_DEPENDENCIES = \
  	$(top_builddir)/src/c++17/libc++17convenience.la \
  	$(top_builddir)/src/c++20/libc++20convenience.la
  
@@ -13530,10 +10823,10 @@ index 9c3f4aca655..016d68ecd5f 100644
  libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
  
 diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
-index 4a06f6cfec1..0dc6c9650fc 100644
+index f42d957af36..0ce75f30708 100644
 --- a/libstdc++-v3/src/Makefile.in
 +++ b/libstdc++-v3/src/Makefile.in
-@@ -546,8 +546,11 @@ libstdc___la_DEPENDENCIES = \
+@@ -560,8 +560,11 @@ libstdc___la_DEPENDENCIES = \
  	$(top_builddir)/src/c++17/libc++17convenience.la \
  	$(top_builddir)/src/c++20/libc++20convenience.la
  
@@ -13547,9 +10840,18 @@ index 4a06f6cfec1..0dc6c9650fc 100644
  libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
  @GLIBCXX_LDBL_ALT128_COMPAT_FALSE@@GLIBCXX_LDBL_COMPAT_TRUE@LTCXXCOMPILE64 = $(LTCXXCOMPILE)
 diff --git a/libtool.m4 b/libtool.m4
-index 17f8e5f3074..5452de03793 100644
+index b92e284d9f9..f3bddafc19d 100644
 --- a/libtool.m4
 +++ b/libtool.m4
+@@ -1005,7 +1005,7 @@ _LT_EOF
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[[89]]*|UNSET,*-darwin[[12]][[0123456789]]*)
++	UNSET,*-darwin[[89]]*|UNSET,*-darwin[[12]][[0-9]]*)
+ 	  ;;
+ 	10.[[012]][[,.]]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
 @@ -1039,6 +1039,45 @@ _LT_EOF
  m4_defun([_LT_DARWIN_LINKER_FEATURES],
  [
@@ -13568,23 +10870,23 @@ index 17f8e5f3074..5452de03793 100644
 +  [if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[[45678]]*|UNSET,rhapsody*|10.[[01234]][[,.]]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&AS_MESSAGE_LOG_FD
++      UNSET,darwin[[4-8]]*|UNSET,rhapsody*|10.[[0-4]][[,.]]*)
++	AC_MSG_WARN([Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)])
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
 +   fi],
 +  [case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[[45678]]*|UNSET,rhapsody*|10.[[01234]][[,.]]*)
++     UNSET,darwin[[4-8]]*|UNSET,rhapsody*|10.[[0-4]][[,.]]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[[56789]]*|UNSET,darwin2*|10.1[[123456789]][[,.]]*|1[[123456789]].*[[,.]]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&AS_MESSAGE_LOG_FD
++      UNSET,darwin1[[5-9]]*|UNSET,darwin2*|10.1[[1-9]][[,.]]*|1[[1-9]].*[[,.]]* )
++      AC_MSG_NOTICE([@rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)])
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -13596,39 +10898,32 @@ index 17f8e5f3074..5452de03793 100644
    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
    _LT_TAGVAR(hardcode_direct, $1)=no
    _LT_TAGVAR(hardcode_automatic, $1)=yes
-@@ -1056,13 +1095,26 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
+@@ -1056,13 +1095,21 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&AS_MESSAGE_LOG_FD
-+      _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&AS_MESSAGE_LOG_FD
-+      _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
      m4_if([$1], [CXX],
  [   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
 -      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++      _lt_install_name='\$rpath/\$soname'
 +      if test "x$enable_darwin_at_rpath" = "xyes"; then
-+        _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring${_lt_dsymutil}"
-+      else
-+        _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++        _lt_install_name='@rpath/\$soname'
 +      fi
++      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring${_lt_dsymutil}"
        _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
      fi
  ],[])
-@@ -4203,6 +4255,7 @@ _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
+@@ -4227,6 +4274,7 @@ _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
  	[Compiler flag to prevent dynamic linking])
  ])# _LT_COMPILER_PIC
  
@@ -13636,7 +10931,7 @@ index 17f8e5f3074..5452de03793 100644
  
  # _LT_LINKER_SHLIBS([TAGNAME])
  # ----------------------------
-@@ -6441,7 +6494,6 @@ fi # test "$_lt_caught_CXX_error" != yes
+@@ -6466,7 +6514,6 @@ fi # test "$_lt_caught_CXX_error" != yes
  AC_LANG_POP
  ])# _LT_LANG_CXX_CONFIG
  
@@ -13645,7 +10940,7 @@ index 17f8e5f3074..5452de03793 100644
  # ---------------------------------
  # Figure out "hidden" library dependencies from verbose
 diff --git a/libvtv/configure b/libvtv/configure
-index d64b4af5c6b..4280e3b20a9 100755
+index e7e490d8b3e..f09f4d9dbcf 100755
 --- a/libvtv/configure
 +++ b/libvtv/configure
 @@ -640,6 +640,8 @@ VTV_CYGMIN_FALSE
@@ -13674,7 +10969,16 @@ index d64b4af5c6b..4280e3b20a9 100755
    --enable-cet            enable Intel CET in target libraries [default=auto]
  
  Optional Packages:
-@@ -10448,6 +10453,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -8748,7 +8753,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -10453,6 +10458,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -13691,8 +10995,9 @@ index d64b4af5c6b..4280e3b20a9 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -13700,15 +11005,16 @@ index d64b4af5c6b..4280e3b20a9 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -13722,49 +11028,41 @@ index d64b4af5c6b..4280e3b20a9 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -10465,10 +10511,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -10470,9 +10518,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -12254,7 +12309,7 @@ else
+@@ -12278,7 +12330,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 12267 "configure"
-+#line 12312 "configure"
+-#line 12281 "configure"
++#line 12333 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -12360,7 +12415,7 @@ else
+@@ -12384,7 +12436,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 12373 "configure"
-+#line 12418 "configure"
+-#line 12387 "configure"
++#line 12439 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -13236,6 +13291,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13260,6 +13312,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
        darwin* | rhapsody*)
  
  
@@ -13781,8 +11079,9 @@ index d64b4af5c6b..4280e3b20a9 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -13790,15 +11089,16 @@ index d64b4af5c6b..4280e3b20a9 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -13812,64 +11112,31 @@ index d64b4af5c6b..4280e3b20a9 100755
    archive_cmds_need_lc_CXX=no
    hardcode_direct_CXX=no
    hardcode_automatic_CXX=yes
-@@ -13253,12 +13349,25 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -13277,12 +13372,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
         if test "$lt_cv_apple_cc_single_mod" != "yes"; then
 -      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++      _lt_install_name='\$rpath/\$soname'
 +      if test "x$enable_darwin_at_rpath" = "xyes"; then
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring${_lt_dsymutil}"
-+      else
-+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++        _lt_install_name='@rpath/\$soname'
 +      fi
++      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring${_lt_dsymutil}"
        archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
      fi
  
-@@ -15099,16 +15208,6 @@ freebsd* | dragonfly*)
-   esac
-   ;;
- 
--gnu*)
--  version_type=linux
--  need_lib_prefix=no
--  need_version=no
--  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
--  soname_spec='${libname}${release}${shared_ext}$major'
--  shlibpath_var=LD_LIBRARY_PATH
--  hardcode_into_libs=yes
--  ;;
--
- haiku*)
-   version_type=linux
-   need_lib_prefix=no
-@@ -15230,7 +15329,7 @@ linux*oldld* | linux*aout* | linux*coff*)
- # project, but have not yet been accepted: they are GCC-local changes
- # for the time being.  (See
- # https://lists.gnu.org/archive/html/libtool-patches/2018-05/msg00000.html)
--linux* | k*bsd*-gnu | kopensolaris*-gnu | uclinuxfdpiceabi)
-+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu* | uclinuxfdpiceabi)
-   version_type=linux
-   need_lib_prefix=no
-   need_version=no
-@@ -15642,6 +15741,14 @@ esac
+@@ -15676,6 +15779,14 @@ esac
  
  
  
@@ -13884,16 +11151,7 @@ index d64b4af5c6b..4280e3b20a9 100755
  
  # For libtool versioning info, format is CURRENT:REVISION:AGE
  libtool_VERSION=1:0:0
-@@ -15672,7 +15779,7 @@ case "$host" in
-     case "$enable_cet" in
-       auto)
- 	# Check if target supports multi-byte NOPs
--	# and if assembler supports CET insn.
-+	# and if compiler and assembler support CET insn.
- 	cet_save_CFLAGS="$CFLAGS"
- 	CFLAGS="$CFLAGS -fcf-protection"
- 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-@@ -15987,6 +16094,10 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+@@ -16021,6 +16132,10 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
    as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
@@ -13917,7 +11175,7 @@ index f3b937e4b10..50aaadbb3a3 100644
  # For libtool versioning info, format is CURRENT:REVISION:AGE
  libtool_VERSION=1:0:0
 diff --git a/lto-plugin/configure b/lto-plugin/configure
-index b820accfd65..8faa13c4a8b 100755
+index d522bd24c95..23162fc0fff 100755
 --- a/lto-plugin/configure
 +++ b/lto-plugin/configure
 @@ -634,6 +634,8 @@ LTLIBOBJS
@@ -13929,7 +11187,7 @@ index b820accfd65..8faa13c4a8b 100755
  OTOOL64
  OTOOL
  LIPO
-@@ -785,6 +787,7 @@ with_pic
+@@ -786,6 +788,7 @@ with_pic
  enable_fast_install
  with_gnu_ld
  enable_libtool_lock
@@ -13937,7 +11195,7 @@ index b820accfd65..8faa13c4a8b 100755
  '
        ac_precious_vars='build_alias
  host_alias
-@@ -1430,6 +1433,8 @@ Optional Features:
+@@ -1431,6 +1434,8 @@ Optional Features:
    --enable-fast-install[=PKGS]
                            optimize for fast installation [default=yes]
    --disable-libtool-lock  avoid locking (might break parallel builds)
@@ -13946,7 +11204,16 @@ index b820accfd65..8faa13c4a8b 100755
  
  Optional Packages:
    --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-@@ -10275,6 +10280,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -8603,7 +8608,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -10309,6 +10314,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -13963,8 +11230,9 @@ index b820accfd65..8faa13c4a8b 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -13972,15 +11240,16 @@ index b820accfd65..8faa13c4a8b 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -13994,49 +11263,41 @@ index b820accfd65..8faa13c4a8b 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -10292,10 +10338,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -10326,9 +10374,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -12081,7 +12136,7 @@ else
+@@ -12134,7 +12186,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 12084 "configure"
-+#line 12139 "configure"
+-#line 12137 "configure"
++#line 12189 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -12187,7 +12242,7 @@ else
+@@ -12240,7 +12292,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 12190 "configure"
-+#line 12245 "configure"
+-#line 12243 "configure"
++#line 12295 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -12424,6 +12479,14 @@ CC="$lt_save_CC"
+@@ -12477,6 +12529,14 @@ CC="$lt_save_CC"
  # Only expand once:
  
  
@@ -14051,7 +11312,7 @@ index b820accfd65..8faa13c4a8b 100755
  
  
  
-@@ -12670,6 +12733,10 @@ if test -z "${LTO_PLUGIN_USE_SYMVER_SUN_TRUE}" && test -z "${LTO_PLUGIN_USE_SYMV
+@@ -12723,6 +12783,10 @@ if test -z "${LTO_PLUGIN_USE_SYMVER_SUN_TRUE}" && test -z "${LTO_PLUGIN_USE_SYMV
    as_fn_error $? "conditional \"LTO_PLUGIN_USE_SYMVER_SUN\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
@@ -14063,22 +11324,41 @@ index b820accfd65..8faa13c4a8b 100755
  : "${CONFIG_STATUS=./config.status}"
  ac_write_fail=0
 diff --git a/lto-plugin/configure.ac b/lto-plugin/configure.ac
-index bc5b618a495..317596288b2 100644
+index 0a7202782ae..5812bbbfc08 100644
 --- a/lto-plugin/configure.ac
 +++ b/lto-plugin/configure.ac
-@@ -88,6 +88,7 @@ AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER_GNU, [test "x$lto_plugin_use_symver" = xgnu
- AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER_SUN, [test "x$lto_plugin_use_symver" = xsun])
+@@ -110,6 +110,7 @@ fi
+ AC_SUBST(ac_lto_plugin_extra_ldflags)
  
  AM_PROG_LIBTOOL
 +AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
  ACX_LT_HOST_FLAGS
  AC_SUBST(target_noncanonical)
  AC_TYPE_INT64_T
+diff --git a/zlib/Makefile.in b/zlib/Makefile.in
+index 3f5102d1b87..80fe3b69116 100644
+--- a/zlib/Makefile.in
++++ b/zlib/Makefile.in
+@@ -353,6 +353,8 @@ datadir = @datadir@
+ datarootdir = @datarootdir@
+ docdir = @docdir@
+ dvidir = @dvidir@
++enable_host_pie = @enable_host_pie@
++enable_host_shared = @enable_host_shared@
+ exec_prefix = @exec_prefix@
+ host = @host@
+ host_alias = @host_alias@
 diff --git a/zlib/configure b/zlib/configure
-index f489f31bc70..f7adce0db2c 100755
+index e35ac6e7e17..ccafc4f03f7 100755
 --- a/zlib/configure
 +++ b/zlib/configure
-@@ -639,6 +639,8 @@ TARGET_LIBRARY_FALSE
+@@ -635,10 +635,14 @@ am__EXEEXT_TRUE
+ LTLIBOBJS
+ LIBOBJS
+ PICFLAG
++enable_host_pie
++enable_host_shared
+ TARGET_LIBRARY_FALSE
  TARGET_LIBRARY_TRUE
  toolexeclibdir
  toolexecdir
@@ -14087,33 +11367,38 @@ index f489f31bc70..f7adce0db2c 100755
  CPP
  OTOOL64
  OTOOL
-@@ -776,6 +778,7 @@ with_pic
+@@ -776,8 +780,10 @@ with_pic
  enable_fast_install
  with_gnu_ld
  enable_libtool_lock
 +enable_darwin_at_rpath
  with_toolexeclibdir
  enable_host_shared
++enable_host_pie
  '
-@@ -1419,6 +1422,8 @@ Optional Features:
+       ac_precious_vars='build_alias
+ host_alias
+@@ -1419,7 +1425,10 @@ Optional Features:
    --enable-fast-install[=PKGS]
                            optimize for fast installation [default=yes]
    --disable-libtool-lock  avoid locking (might break parallel builds)
 +  --enable-darwin-at-path install libraries with @rpath/library-name, requires
 +                          rpaths to be added to executables
    --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
  
  Optional Packages:
-@@ -4169,7 +4174,7 @@ case "$host" in
-     case "$enable_cet" in
-       auto)
- 	# Check if target supports multi-byte NOPs
--	# and if assembler supports CET insn.
-+	# and if compiler and assembler support CET insn.
- 	cet_save_CFLAGS="$CFLAGS"
- 	CFLAGS="$CFLAGS -fcf-protection"
- 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-@@ -8908,6 +8913,47 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+@@ -6934,7 +6943,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
+       # darwin 5.x (macOS 10.1) onwards we only need to adjust when the
+       # deployment target is forced to an earlier version.
+       case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in
+-	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0123456789]*)
++	UNSET,*-darwin[89]*|UNSET,*-darwin[12][0-9]*)
+ 	  ;;
+ 	10.[012][,.]*)
+ 	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+@@ -8913,6 +8922,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
      darwin* | rhapsody*)
  
  
@@ -14130,8 +11415,9 @@ index f489f31bc70..f7adce0db2c 100755
 +  enableval=$enable_darwin_at_rpath; if test "x$enable_darwin_at_rpath" = "xyes"; then
 +    # This is not supported before macOS 10.5 / Darwin9.
 +    case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
-+      UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
-+	echo "WARNING: Darwin @rpath library names are incompatible with macOS versions earlier than 10.5 (rpaths disabled)" 1>&5
++      UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&5
++$as_echo "$as_me: WARNING: Darwin @rpath library names are incompatible with OSX versions earlier than 10.5 (rpaths disabled)" >&2;}
 +	enable_darwin_at_rpath=no
 +      ;;
 +    esac
@@ -14139,15 +11425,16 @@ index f489f31bc70..f7adce0db2c 100755
 +else
 +  case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host_os in
 +    # As above, before 10.5 / Darwin9 this does not work.
-+     UNSET,darwin[45678]*|UNSET,rhapsody*|10.[01234][,.]*)
++     UNSET,darwin[4-8]*|UNSET,rhapsody*|10.[0-4][,.]*)
 +       enable_darwin_at_rpath=no
 +       ;;
 +
 +    # We cannot build and test reliably on macOS 10.11+ (Darwin15+) without use
 +    # of rpaths, since runpaths set via DYLD_LIBRARY_PATH are elided by key
 +    # system executables (e.g. /bin/sh).  Force rpaths on for these systems.
-+      UNSET,darwin1[56789]*|UNSET,darwin2*|10.1[123456789][,.]*|1[123456789].*[,.]* )
-+      echo "@rpath library names are needed on macOS versions later than 10.11 (rpaths enabled)" 1>&5
++      UNSET,darwin1[5-9]*|UNSET,darwin2*|10.1[1-9][,.]*|1[1-9].*[,.]* )
++      { $as_echo "$as_me:${as_lineno-$LINENO}: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&5
++$as_echo "$as_me: @rpath library names are needed on macOS versions later than 10.11 (rpaths have been enabled)" >&6;}
 +      enable_darwin_at_rpath=yes
 +      ;;
 +    # NOTE: we are not (yet) doing anything for 10.5 .. 10.10, since they can
@@ -14161,49 +11448,41 @@ index f489f31bc70..f7adce0db2c 100755
    archive_cmds_need_lc=no
    hardcode_direct=no
    hardcode_automatic=yes
-@@ -8925,10 +8971,19 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+@@ -8930,9 +8982,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
    esac
    if test "$_lt_dar_can_shared" = "yes"; then
      output_verbose_link_cmd=func_echo_all
 -    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
--    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
--    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
--    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++    _lt_install_name='\$rpath/\$soname'
 +    if test "x$enable_darwin_at_rpath" = "xyes"; then
-+      echo "using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name @rpath/\$soname \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-+    else
-+      echo "NOT using Darwin @rpath" 1>&5
-+      archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-+      module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-+      archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-+      module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++      _lt_install_name='@rpath/\$soname'
 +    fi
++    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dsymutil}"
+     module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name ${_lt_install_name} \$verstring ${_lt_dar_export_syms}${_lt_dsymutil}"
+     module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
  
    else
-   ld_shlibs=no
-@@ -10735,7 +10790,7 @@ else
+@@ -10759,7 +10815,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 10748 "configure"
-+#line 10793 "configure"
+-#line 10762 "configure"
++#line 10818 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -10841,7 +10896,7 @@ else
+@@ -10865,7 +10921,7 @@ else
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
--#line 10854 "configure"
-+#line 10899 "configure"
+-#line 10868 "configure"
++#line 10924 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
-@@ -11078,6 +11133,14 @@ CC="$lt_save_CC"
+@@ -11102,6 +11158,14 @@ CC="$lt_save_CC"
  # Only expand once:
  
  
@@ -14218,7 +11497,41 @@ index f489f31bc70..f7adce0db2c 100755
  
  # Find CPP now so that any conditional tests below won't do it and
  # thereby make the resulting definitions conditional.
-@@ -11708,6 +11771,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+@@ -11548,15 +11612,31 @@ else
+   multilib_arg=
+ fi
+ 
++# Enable --enable-host-shared.
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
++  enableval=$enable_host_shared;
++fi
++
++
++
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
++
++
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
+ else
+   PICFLAG=
+ fi
+ 
+ 
+-
+ ac_config_files="$ac_config_files Makefile"
+ 
+ cat >confcache <<\_ACEOF
+@@ -11732,6 +11812,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
    as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
  fi
@@ -14230,7 +11543,7 @@ index f489f31bc70..f7adce0db2c 100755
    as_fn_error $? "conditional \"TARGET_LIBRARY\" was never defined.
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
 diff --git a/zlib/configure.ac b/zlib/configure.ac
-index be1cfe29651..2327d003a05 100644
+index be1cfe29651..9501cdfea85 100644
 --- a/zlib/configure.ac
 +++ b/zlib/configure.ac
 @@ -64,6 +64,7 @@ GCC_CET_FLAGS(CET_FLAGS)
@@ -14241,3 +11554,33 @@ index be1cfe29651..2327d003a05 100644
  
  # Find CPP now so that any conditional tests below won't do it and
  # thereby make the resulting definitions conditional.
+@@ -122,11 +123,26 @@ else
+   multilib_arg=
+ fi
+ 
++# Enable --enable-host-shared.
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
+-AC_SUBST(PICFLAG)
++		[build host code as shared libraries])])
++AC_SUBST(enable_host_shared)
++
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])])
++AC_SUBST(enable_host_pie)
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
+ 
++AC_SUBST(PICFLAG)
+ AC_CONFIG_FILES([Makefile])
+ AC_OUTPUT
diff --git a/build/pkgs/gcc/patches/gcc-multiarch.patch b/build/pkgs/gcc/patches/gcc-multiarch.patch
new file mode 100644
index 00000000000..869bb212859
--- /dev/null
+++ b/build/pkgs/gcc/patches/gcc-multiarch.patch
@@ -0,0 +1,235 @@
+# DP: - Remaining multiarch patches, not yet submitted upstream.
+# DP: - Add MULTIARCH_DIRNAME definitions for multilib configurations,
+# DP:   which are used for the non-multilib builds.
+
+2013-06-12  Matthias Klose  
+
+	* config/i386/t-linux64: Set MULTIARCH_DIRNAME.
+	* config/i386/t-kfreebsd: Set MULTIARCH_DIRNAME.
+	* config.gcc (i[34567]86-*-linux* | x86_64-*-linux*): Prepend
+	i386/t-linux to $tmake_file;
+	set default ABI to N64 for mips64el.
+	* config/mips/t-linux64: Set MULTIARCH_DIRNAME.
+	* config/rs6000/t-linux64: Set MULTIARCH_DIRNAME.
+	* config/s390/t-linux64: Set MULTIARCH_DIRNAME.
+	* config/sparc/t-linux64: Set MULTIARCH_DIRNAME.
+	* src/gcc/config/mips/mips.h: (/usr)/lib as default path.
+
+Index: b/gcc/config/sh/t-linux
+===================================================================
+--- a/gcc/config/sh/t-linux
++++ b/gcc/config/sh/t-linux
+@@ -1,3 +1,11 @@
+ MULTILIB_DIRNAMES=
+ MULTILIB_MATCHES=
++
++ifneq (,$(findstring sh4,$(target)))
++MULTILIB_OSDIRNAMES = .:sh4-linux-gnu sh4_nofpu-linux-gnu:sh4-linux-gnu
++MULTIARCH_DIRNAME = $(call if_multiarch,sh4-linux-gnu)
++else
++MULTILIB_OSDIRNAMES = .:sh3-linux-gnu sh3_nofpu-linux-gnu:sh3-linux-gnu
++MULTIARCH_DIRNAME = $(call if_multiarch,sh3-linux-gnu)
++endif
+ MULTILIB_EXCEPTIONS=m1 mb/m1 m2a
+Index: b/gcc/config/sparc/t-linux64
+===================================================================
+--- a/gcc/config/sparc/t-linux64
++++ b/gcc/config/sparc/t-linux64
+@@ -27,3 +27,5 @@ MULTILIB_OPTIONS = m64/m32
+ MULTILIB_DIRNAMES = 64 32
+ MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:sparc64-linux-gnu)
+ MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:sparc-linux-gnu)
++
++MULTIARCH_DIRNAME = $(call if_multiarch,sparc$(if $(findstring 64,$(target)),64)-linux-gnu)
+Index: b/gcc/config/s390/t-linux64
+===================================================================
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -9,3 +9,5 @@ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+ MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+ MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++
++MULTIARCH_DIRNAME = $(call if_multiarch,s390$(if $(findstring s390x,$(target)),x)-linux-gnu)
+Index: b/gcc/config/rs6000/t-linux64
+===================================================================
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -31,6 +31,8 @@ MULTILIB_EXTRA_OPTS :=
+ MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+ MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
+ 
++MULTIARCH_DIRNAME = $(call if_multiarch,powerpc$(if $(findstring 64,$(target)),64)-linux-gnu)
++
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.cc
+ 	$(COMPILE) $<
+ 	$(POSTCOMPILE)
+Index: b/gcc/config/i386/t-linux64
+===================================================================
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -36,3 +36,13 @@ MULTILIB_DIRNAMES   = $(patsubst m%, %,
+ MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+ MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++
++ifneq (,$(findstring x86_64,$(target)))
++  ifneq (,$(findstring biarchx32.h,$(tm_include_list)))
++  MULTIARCH_DIRNAME = $(call if_multiarch,x86_64-linux-gnux32)
++  else
++  MULTIARCH_DIRNAME = $(call if_multiarch,x86_64-linux-gnu)
++  endif
++else
++  MULTIARCH_DIRNAME = $(call if_multiarch,i386-linux-gnu)
++endif
+Index: b/gcc/config/i386/t-kfreebsd
+===================================================================
+--- a/gcc/config/i386/t-kfreebsd
++++ b/gcc/config/i386/t-kfreebsd
+@@ -1,5 +1,9 @@
+-MULTIARCH_DIRNAME = $(call if_multiarch,i386-kfreebsd-gnu)
++ifeq (,$(MULTIARCH_DIRNAME))
++  MULTIARCH_DIRNAME = $(call if_multiarch,i386-kfreebsd-gnu)
++endif
+ 
+ # MULTILIB_OSDIRNAMES are set in t-linux64.
+ KFREEBSD_OS = $(filter kfreebsd%, $(word 3, $(subst -, ,$(target))))
+ MULTILIB_OSDIRNAMES := $(filter-out mx32=%,$(subst linux,$(KFREEBSD_OS),$(MULTILIB_OSDIRNAMES)))
++
++MULTIARCH_DIRNAME := $(subst linux,$(KFREEBSD_OS),$(MULTIARCH_DIRNAME))
+Index: b/gcc/config/mips/t-linux64
+===================================================================
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -18,24 +18,28 @@
+ 
+ MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64
+ MULTILIB_DIRNAMES = n32 32 64
++MIPS_R6 = $(if $(findstring r6, $(firstword $(subst -, ,$(target)))),r6)
++MIPS_32 = $(if $(findstring r6, $(firstword $(subst -, ,$(target)))),32)
++MIPS_ISA = $(if $(findstring r6, $(firstword $(subst -, ,$(target)))),isa)
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
++
+ ifeq (yes,$(enable_multiarch))
+   ifneq (,$(findstring gnuabi64,$(target)))
+     MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++        ../lib32$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
++        ../libo32$(call if_multiarch,:mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
++        ../lib$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+   else ifneq (,$(findstring gnuabin32,$(target)))
+     MULTILIB_OSDIRNAMES = \
+-	../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++        ../lib$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
++        ../libo32$(call if_multiarch,:mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
++        ../lib64$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+   else
+     MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++        ../lib32$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
++        ../lib$(call if_multiarch,:mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
++        ../lib64$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+   endif
+ else
+   MULTILIB_OSDIRNAMES = \
+@@ -43,3 +47,13 @@ else
+ 	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+ 	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+ endif
++
++ifneq (,$(findstring abin32,$(target)))
++MULTIARCH_DIRNAME = $(call if_multiarch,mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT))
++else
++ifneq (,$(findstring abi64,$(target)))
++MULTIARCH_DIRNAME = $(call if_multiarch,mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++else
++MULTIARCH_DIRNAME = $(call if_multiarch,mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT))
++endif
++endif
+Index: b/gcc/config.gcc
+===================================================================
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -2519,7 +2519,8 @@ mips*-*-linux*)				# Linux MIPS, either
+ 	extra_options="${extra_options} linux-android.opt"
+ 	case ${target} in
+ 		mipsisa32r6*)
+-			default_mips_arch=mips32r6
++			with_arch_32="mips32r6"
++			with_arch_64="mips64r6"
+ 			;;
+ 		mipsisa32r2*)
+ 			default_mips_arch=mips32r2
+@@ -2541,7 +2542,8 @@ mips*-*-linux*)				# Linux MIPS, either
+ 			;;
+ 		mipsisa64r6*-*-linux-gnuabi64)
+ 			default_mips_abi=64
+-			default_mips_arch=mips64r6
++			with_arch_32="mips32r6"
++			with_arch_64="mips64r6"
+ 			enable_mips_multilibs="yes"
+ 			;;
+ 		mipsisa64r6*-*-linux*)
+@@ -5656,7 +5658,7 @@ case ${target} in
+ 		;;
+ 	i[34567]86-*-linux* | x86_64-*-linux*)
+ 		extra_objs="${extra_objs} gnu-property.o"
+-		tmake_file="$tmake_file i386/t-linux i386/t-gnu-property"
++		tmake_file="i386/t-linux $tmake_file i386/t-gnu-property"
+ 		;;
+ 	i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu)
+ 		tmake_file="$tmake_file i386/t-kfreebsd"
+Index: b/gcc/config/riscv/t-linux
+===================================================================
+--- a/gcc/config/riscv/t-linux
++++ b/gcc/config/riscv/t-linux
+@@ -1,3 +1,5 @@
+ # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/
+ MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
+ MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
++
++MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu)
+Index: b/gcc/Makefile.in
+===================================================================
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -553,7 +553,7 @@ BUILD_SYSTEM_HEADER_DIR = `echo @BUILD_S
+ STMP_FIXINC = @STMP_FIXINC@
+ 
+ # Test to see whether  exists in the system header files.
+-LIMITS_H_TEST = [ -f $(BUILD_SYSTEM_HEADER_DIR)/limits.h ]
++LIMITS_H_TEST = [ -f $(BUILD_SYSTEM_HEADER_DIR)/limits.h -o -f $(BUILD_SYSTEM_HEADER_DIR)/$(MULTIARCH_DIRNAME)/limits.h ]
+ 
+ # Directory for prefix to system directories, for
+ # each of $(system_prefix)/usr/include, $(system_prefix)/usr/lib, etc.
+Index: b/gcc/config/aarch64/t-aarch64-linux
+===================================================================
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+Index: b/gcc/config/arc/t-multilib-linux
+===================================================================
+--- a/gcc/config/arc/t-multilib-linux
++++ b/gcc/config/arc/t-multilib-linux
+@@ -23,3 +23,6 @@ MULTILIB_DIRNAMES = hs archs hs38 hs38_l
+ # Aliases:
+ MULTILIB_MATCHES += mcpu?arc700=mA7
+ MULTILIB_MATCHES += mcpu?arc700=mARC700
++
++MULTILIB_OSDIRNAMES =
++MULTIARCH_DIRNAME = $(call if_multiarch,arc-linux-gnu)
diff --git a/build/pkgs/gcc/patches/gcc-multilib-multiarch.patch b/build/pkgs/gcc/patches/gcc-multilib-multiarch.patch
index 9a9a63bf41a..af5580055e8 100644
--- a/build/pkgs/gcc/patches/gcc-multilib-multiarch.patch
+++ b/build/pkgs/gcc/patches/gcc-multilib-multiarch.patch
@@ -1,14 +1,65 @@
-On 64-bit Linux target systems, install 64-bit libraries to ${prefix}/lib
-instead of ${prefix}/lib64
+# DP: Don't auto-detect multilib osdirnames.
 
-Adapted to GCC 7.2.0 from Debian's patch at:
-
-https://salsa.debian.org/toolchain-team/gcc/blob/988272d6dcf649c1d6018763d1ee4b4df191d607/debian/patches/gcc-multilib-multiarch.diff
-diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64
-index e422c44..f7d946b 100644
+Index: b/gcc/config/sparc/t-linux64
+===================================================================
+--- a/gcc/config/sparc/t-linux64
++++ b/gcc/config/sparc/t-linux64
+@@ -25,7 +25,12 @@
+ 
+ MULTILIB_OPTIONS = m64/m32
+ MULTILIB_DIRNAMES = 64 32
++ifneq (,$(findstring sparc64,$(target)))
++MULTILIB_OSDIRNAMES = ../lib$(call if_multiarch,:sparc64-linux-gnu)
++MULTILIB_OSDIRNAMES += ../lib32$(call if_multiarch,:sparc-linux-gnu)
++else
+ MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:sparc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:sparc-linux-gnu)
++MULTILIB_OSDIRNAMES += ../lib$(call if_multiarch,:sparc-linux-gnu)
++endif
+ 
+ MULTIARCH_DIRNAME = $(call if_multiarch,sparc$(if $(findstring 64,$(target)),64)-linux-gnu)
+Index: b/gcc/config/s390/t-linux64
+===================================================================
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,7 +7,12 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
++ifneq (,$(findstring s390x,$(target)))
++MULTILIB_OSDIRNAMES = ../lib$(call if_multiarch,:s390x-linux-gnu)
++MULTILIB_OSDIRNAMES += ../lib32$(call if_multiarch,:s390-linux-gnu)
++else
+ MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES += ../lib$(call if_multiarch,:s390-linux-gnu)
++endif
+ 
+ MULTIARCH_DIRNAME = $(call if_multiarch,s390$(if $(findstring s390x,$(target)),x)-linux-gnu)
+Index: b/gcc/config/rs6000/t-linux64
+===================================================================
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,13 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
++ifneq (,$(findstring powerpc64,$(target)))
++MULTILIB_OSDIRNAMES := m64=../lib$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES += m32=../lib32$(call if_multiarch,:powerpc-linux-gnu)
++else
+ MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES += m32=../lib$(call if_multiarch,:powerpc-linux-gnu)
++endif
+ 
+ MULTIARCH_DIRNAME = $(call if_multiarch,powerpc$(if $(findstring 64,$(target)),64)-linux-gnu)
+ 
+Index: b/gcc/config/i386/t-linux64
+===================================================================
 --- a/gcc/config/i386/t-linux64
 +++ b/gcc/config/i386/t-linux64
-@@ -33,6 +33,16 @@
+@@ -33,9 +33,19 @@
  comma=,
  MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
  MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
@@ -26,36 +77,11 @@ index e422c44..f7d946b 100644
 +MULTILIB_OSDIRNAMES+= m32=../lib$(call if_multiarch,:i386-linux-gnu)
 +MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
 +endif
-diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64
-index 100f9da..d981884 100644
---- a/gcc/config/mips/t-linux64
-+++ b/gcc/config/mips/t-linux64
-@@ -20,7 +20,20 @@ MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64
- MULTILIB_DIRNAMES = n32 32 64
- MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
- MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
-+
-+ifneq (,$(findstring gnuabi64,$(target)))
-+MULTILIB_OSDIRNAMES = \
-+        ../lib32$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
-+        ../libo32$(call if_multiarch,:mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
-+        ../lib$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
-+else ifneq (,$(findstring gnuabin32,$(target)))
-+MULTILIB_OSDIRNAMES = \
-+        ../lib$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
-+        ../libo32$(call if_multiarch,:mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
-+        ../lib64$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
-+else
- MULTILIB_OSDIRNAMES = \
--	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
--	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
--	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
-+        ../lib32$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
-+        ../lib$(call if_multiarch,:mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
-+        ../lib64$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
-+endif
-diff --git a/gcc/config/rs6000/t-linux b/gcc/config/rs6000/t-linux
-index 4cb63bd..c058471 100644
+ 
+ ifneq (,$(findstring x86_64,$(target)))
+   ifneq (,$(findstring biarchx32.h,$(tm_include_list)))
+Index: b/gcc/config/rs6000/t-linux
+===================================================================
 --- a/gcc/config/rs6000/t-linux
 +++ b/gcc/config/rs6000/t-linux
 @@ -2,7 +2,7 @@
@@ -65,56 +91,36 @@ index 4cb63bd..c058471 100644
 -MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
 +MULTILIB_OSDIRNAMES := .=../lib$(call if_multiarch,:powerpc64-linux-gnu)
  else
- ifneq (,$(findstring spe,$(target)))
- MULTIARCH_DIRNAME := powerpc-linux-gnuspe$(if $(findstring 8548,$(with_cpu)),,v1)
-diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64
-index 2830ed0..5a3ccb5 100644
---- a/gcc/config/rs6000/t-linux64
-+++ b/gcc/config/rs6000/t-linux64
-@@ -28,8 +28,13 @@
- MULTILIB_OPTIONS    := m64/m32
- MULTILIB_DIRNAMES   := 64 32
- MULTILIB_EXTRA_OPTS := 
-+ifneq (,$(findstring powerpc64,$(target)))
-+MULTILIB_OSDIRNAMES := m64=../lib$(call if_multiarch,:powerpc64-linux-gnu)
-+MULTILIB_OSDIRNAMES += m32=../lib32$(call if_multiarch,:powerpc-linux-gnu)
-+else
- MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
--MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
-+MULTILIB_OSDIRNAMES += m32=../lib$(call if_multiarch,:powerpc-linux-gnu)
-+endif
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+Index: b/gcc/config/loongarch/t-linux
+===================================================================
+--- a/gcc/config/loongarch/t-linux
++++ b/gcc/config/loongarch/t-linux
+@@ -32,22 +32,19 @@ ifneq ($(call if_multiarch,yes),yes)
+ else
+     # Only define MULTIARCH_DIRNAME when multiarch is enabled,
+     # or it would always introduce ${target} into the search path.
+-    MULTIARCH_DIRNAME = $(LA_MULTIARCH_TRIPLET)
++    MULTIARCH_DIRNAME = $(call if_multiarch,loongarch64-linux-gnu)
+ endif
  
- rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
- 	$(COMPILE) $<
-diff --git a/gcc/config/s390/t-linux64 b/gcc/config/s390/t-linux64
-index cc6ab36..677219e 100644
---- a/gcc/config/s390/t-linux64
-+++ b/gcc/config/s390/t-linux64
-@@ -7,5 +7,10 @@
+ # Don't define MULTILIB_OSDIRNAMES if multilib is disabled.
+ ifeq ($(filter LA_DISABLE_MULTILIB,$(tm_defines)),)
  
- MULTILIB_OPTIONS = m64/m31
- MULTILIB_DIRNAMES = 64 32
-+ifneq (,$(findstring s390x,$(target)))
-+MULTILIB_OSDIRNAMES = ../lib$(call if_multiarch,:s390x-linux-gnu)
-+MULTILIB_OSDIRNAMES += ../lib32$(call if_multiarch,:s390-linux-gnu)
-+else
- MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
--MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
-+MULTILIB_OSDIRNAMES += ../lib$(call if_multiarch,:s390-linux-gnu)
-+endif
-diff --git a/gcc/config/sparc/t-linux64 b/gcc/config/sparc/t-linux64
-index 7511c38..6c59863 100644
---- a/gcc/config/sparc/t-linux64
-+++ b/gcc/config/sparc/t-linux64
-@@ -25,5 +25,10 @@
+     MULTILIB_OSDIRNAMES = \
+-      mabi.lp64d=../lib64$\
+-      $(call if_multiarch,:loongarch64-linux-gnu)
++      mabi.lp64d=../lib$(call if_multiarch,:loongarch64-linux-gnu)
  
- MULTILIB_OPTIONS = m64/m32
- MULTILIB_DIRNAMES = 64 32
-+ifneq (,$(findstring sparc64,$(target)))
-+MULTILIB_OSDIRNAMES = ../lib$(call if_multiarch,:sparc64-linux-gnu)
-+MULTILIB_OSDIRNAMES += ../lib32$(call if_multiarch,:sparc-linux-gnu)
-+else
- MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:sparc64-linux-gnu)
--MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:sparc-linux-gnu)
-+MULTILIB_OSDIRNAMES += ../lib$(call if_multiarch,:sparc-linux-gnu)
-+endif
+     MULTILIB_OSDIRNAMES += \
+-      mabi.lp64f=../lib64/f32$\
+-      $(call if_multiarch,:loongarch64-linux-gnuf32)
++      mabi.lp64f=../lib/f32$(call if_multiarch,:loongarch64-linux-gnuf32)
+ 
+     MULTILIB_OSDIRNAMES += \
+-      mabi.lp64s=../lib64/sf$\
+-      $(call if_multiarch,:loongarch64-linux-gnusf)
++      mabi.lp64s=../lib/sf$(call if_multiarch,:loongarch64-linux-gnusf)
+ 
+ endif
diff --git a/build/pkgs/gcc/patches/gcc-xcode15-warnings.patch b/build/pkgs/gcc/patches/gcc-xcode15-warnings.patch
new file mode 100644
index 00000000000..5d1a8ca9160
--- /dev/null
+++ b/build/pkgs/gcc/patches/gcc-xcode15-warnings.patch
@@ -0,0 +1,25 @@
+diff --git a/gcc/config/aarch64/darwin.h b/gcc/config/aarch64/darwin.h
+index 5609c569dc1..9fcbfa3d777 100644
+--- a/gcc/config/aarch64/darwin.h
++++ b/gcc/config/aarch64/darwin.h
+@@ -65,10 +65,6 @@ along with GCC; see the file COPYING3.  If not see
+ #define DARWIN_NOPIE_SPEC \
+ " %= 6.2.1; this test is copied from FLINT.
+            AC_MSG_CHECKING([if version of GMP is greater than 6.2.1])
+            AC_COMPILE_IFELSE([
+                AC_LANG_PROGRAM(
+                    [[#include 
+                     ]],
+                    [[#if (__GNU_MP_VERSION < 6) \
+                       || (__GNU_MP_VERSION == 6 && __GNU_MP_VERSION_MINOR < 2) \
+                       || (__GNU_MP_VERSION == 6 && __GNU_MP_VERSION_MINOR == 2 && __GNU_MP_VERSION_PATCHLEVEL < 1)
+                      # error GMP version 6.2.1 or later is required
+                      #endif
+                     ]]
+                )], [dnl
+                    AC_MSG_RESULT([yes])
+                ], [dnl
+                    AC_MSG_RESULT([no])
+                    sage_spkg_install_gmp=yes
+                ])
+            dnl The test above uses the headers only. To protect against header/library
+            dnl mismatches, we now check for a function.
             dnl mpn_gcd_11 appeared in GMP 6.2.1
             dnl It is undocumented but is used by Flint when built with default
             dnl flags.
             AC_SEARCH_LIBS([__gmpn_gcd_11], [gmp], [],
                 [sage_spkg_install_gmp=yes])
-], [], [], [
+], [], [], [dnl
     if test x$sage_spkg_install_gmp = xyes; then
         AC_SUBST(SAGE_GMP_PREFIX, ['$SAGE_LOCAL'])
         AC_SUBST(SAGE_GMP_INCLUDE, ['$SAGE_LOCAL/include'])
diff --git a/build/pkgs/gmpy2/checksums.ini b/build/pkgs/gmpy2/checksums.ini
index e852852d410..34824279321 100644
--- a/build/pkgs/gmpy2/checksums.ini
+++ b/build/pkgs/gmpy2/checksums.ini
@@ -1,5 +1,4 @@
 tarball=gmpy2-VERSION.tar.gz
 sha1=700ef438964acd286d52e973a833cd57ae9a7ad7
-md5=72b93048015b28efcf92ed702014a61c
-cksum=3542820546
+sha256=3b8acc939a40411a8ad5541ed178ff866dd1759e667ee26fe34c9291b6b350c3
 upstream_url=https://pypi.io/packages/source/g/gmpy2/gmpy2-VERSION.tar.gz
diff --git a/build/pkgs/gnumake_tokenpool/checksums.ini b/build/pkgs/gnumake_tokenpool/checksums.ini
index 76c234c4404..889f64341f2 100644
--- a/build/pkgs/gnumake_tokenpool/checksums.ini
+++ b/build/pkgs/gnumake_tokenpool/checksums.ini
@@ -1,5 +1,4 @@
 tarball=gnumake_tokenpool-VERSION-py3-none-any.whl
 sha1=882c694dc3c0a935275a8d2acd9e766399719754
-md5=cc18b6c7a339d8140f5b2dc248ef24bc
-cksum=2989045922
+sha256=0c49578df1a76b6ff7724b99053d96f1583bd3e52fe9547587cfb6ffdb0d1fcd
 upstream_url=https://pypi.io/packages/py3/g/gnumake_tokenpool/gnumake_tokenpool-VERSION-py3-none-any.whl
diff --git a/build/pkgs/gp2c/checksums.ini b/build/pkgs/gp2c/checksums.ini
index d8b896e2ed5..198917ec563 100644
--- a/build/pkgs/gp2c/checksums.ini
+++ b/build/pkgs/gp2c/checksums.ini
@@ -1,4 +1,3 @@
 tarball=gp2c-VERSION.tar.gz
 sha1=6bce2bbb69227de44fa768619d1dffa861d6470a
-md5=41d3e76fb070ba7f73242b76ae5cb529
-cksum=2256538341
+sha256=e0f89183ae4ea24fc41e1da3df3cca11e4f7061237cee0553082c7806ef917f6
diff --git a/build/pkgs/graphs/checksums.ini b/build/pkgs/graphs/checksums.ini
index 7ec4a8a6ada..002c07affac 100644
--- a/build/pkgs/graphs/checksums.ini
+++ b/build/pkgs/graphs/checksums.ini
@@ -1,5 +1,4 @@
 tarball=graphs-VERSION.tar.bz2
 sha1=c3b9fcbc92482efd6b7f6f3a33df5a78e1256aa1
-md5=4357919410e8ac2611c9fe643976c8ff
-cksum=2340933149
+sha256=07237c0d9853611505c389fd7bb92500c8743f5631babb4d0f45dfd8332f3741
 upstream_url=http://users.ox.ac.uk/~coml0531/sage/graphs-VERSION.tar.bz2
diff --git a/build/pkgs/gsl/checksums.ini b/build/pkgs/gsl/checksums.ini
index 8bef7d5f43c..bfa1139780a 100644
--- a/build/pkgs/gsl/checksums.ini
+++ b/build/pkgs/gsl/checksums.ini
@@ -1,5 +1,4 @@
 tarball=gsl-VERSION.tar.gz
 sha1=549e1105cd1198537be9707257161531e109bd94
-md5=36aee97e67f64dbdab7afae197e3483b
-cksum=171022903
+sha256=dcb0fbd43048832b757ff9942691a8dd70026d5da0ff85601e52687f6deeb34b
 upstream_url=https://ftp.gnu.org/gnu/gsl/gsl-VERSION.tar.gz
diff --git a/build/pkgs/h11/checksums.ini b/build/pkgs/h11/checksums.ini
index 19d629f0852..8e1952d648a 100644
--- a/build/pkgs/h11/checksums.ini
+++ b/build/pkgs/h11/checksums.ini
@@ -1,5 +1,4 @@
 tarball=h11-VERSION-py3-none-any.whl
 sha1=c502d56dc3288212142a398704a5109749331dd8
-md5=47f19bfed53c8f9278749c532490977e
-cksum=462065947
+sha256=e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761
 upstream_url=https://pypi.io/packages/py3/h/h11/h11-VERSION-py3-none-any.whl
diff --git a/build/pkgs/hatch_fancy_pypi_readme/checksums.ini b/build/pkgs/hatch_fancy_pypi_readme/checksums.ini
index 067609dd4fc..c624067269f 100644
--- a/build/pkgs/hatch_fancy_pypi_readme/checksums.ini
+++ b/build/pkgs/hatch_fancy_pypi_readme/checksums.ini
@@ -1,5 +1,4 @@
 tarball=hatch_fancy_pypi_readme-VERSION-py3-none-any.whl
 sha1=25cd6749c20a6803cbf1b6c4d29338c344a8f09c
-md5=a38ee7191a80ebdbbf0f126f7dff7e46
-cksum=1509914432
+sha256=26ec5c7cfd9f604eff0ae6c927d7b197b220706dca203f0aad1928abc81f3a46
 upstream_url=https://pypi.io/packages/py3/h/hatch_fancy_pypi_readme/hatch_fancy_pypi_readme-VERSION-py3-none-any.whl
diff --git a/build/pkgs/hatch_vcs/checksums.ini b/build/pkgs/hatch_vcs/checksums.ini
index e9908b1540e..dcfa6ea3e03 100644
--- a/build/pkgs/hatch_vcs/checksums.ini
+++ b/build/pkgs/hatch_vcs/checksums.ini
@@ -1,5 +1,4 @@
 tarball=hatch_vcs-VERSION-py3-none-any.whl
 sha1=a4da813bf9a745ed2020bf462f4bc19a1ab7fc11
-md5=82bee9889b95170e550c98f8dd11bc61
-cksum=1575327634
+sha256=b8a2b6bee54cf6f9fc93762db73890017ae59c9081d1038a41f16235ceaf8b2c
 upstream_url=https://pypi.io/packages/py3/h/hatch_vcs/hatch_vcs-VERSION-py3-none-any.whl
diff --git a/build/pkgs/hatchling/checksums.ini b/build/pkgs/hatchling/checksums.ini
index 1d5f9b819ce..ce647e83c52 100644
--- a/build/pkgs/hatchling/checksums.ini
+++ b/build/pkgs/hatchling/checksums.ini
@@ -1,5 +1,4 @@
 tarball=hatchling-VERSION-py3-none-any.whl
 sha1=2212af13a26dbaea72c7a4ecbdb950c05f6e7c00
-md5=0301aa5bc8739e9f4d58e29d285fb2f7
-cksum=1232194081
+sha256=30ec7ee09f6e17b73257eedfd7f5bb5a9b028a6cf6d144d9faad1d826fa203b8
 upstream_url=https://pypi.io/packages/py3/h/hatchling/hatchling-VERSION-py3-none-any.whl
diff --git a/build/pkgs/httpcore/checksums.ini b/build/pkgs/httpcore/checksums.ini
index 81e08584fbe..627dc72c115 100644
--- a/build/pkgs/httpcore/checksums.ini
+++ b/build/pkgs/httpcore/checksums.ini
@@ -1,5 +1,4 @@
 tarball=httpcore-VERSION-py3-none-any.whl
 sha1=e83eb30232906df8ac673d6c49c657957dc00ce1
-md5=9f99e1b4ed8ba940bd698e21af54ef6d
-cksum=2564019022
+sha256=ac418c1db41bade2ad53ae2f3834a3a0f5ae76b56cf5aa497d2d033384fc7d73
 upstream_url=https://pypi.io/packages/py3/h/httpcore/httpcore-VERSION-py3-none-any.whl
diff --git a/build/pkgs/httpx/checksums.ini b/build/pkgs/httpx/checksums.ini
index 11b2b37b2f2..adc2d9ae791 100644
--- a/build/pkgs/httpx/checksums.ini
+++ b/build/pkgs/httpx/checksums.ini
@@ -1,5 +1,4 @@
 tarball=httpx-VERSION-py3-none-any.whl
 sha1=01f2a657e43842cb7c8dda30d38860fa741acb7e
-md5=9bab916547b4c85999c568d12e04edc4
-cksum=4048488492
+sha256=71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5
 upstream_url=https://pypi.io/packages/py3/h/httpx/httpx-VERSION-py3-none-any.whl
diff --git a/build/pkgs/idna/checksums.ini b/build/pkgs/idna/checksums.ini
index 10e80a0fd10..0381d537291 100644
--- a/build/pkgs/idna/checksums.ini
+++ b/build/pkgs/idna/checksums.ini
@@ -1,5 +1,4 @@
 tarball=idna-VERSION-py3-none-any.whl
 sha1=352c6bd8ee12319953116397718c1a8ab6887259
-md5=903a924c21b63a610a641a651f38d72f
-cksum=177777344
+sha256=c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f
 upstream_url=https://pypi.io/packages/py3/i/idna/idna-VERSION-py3-none-any.whl
diff --git a/build/pkgs/igraph/checksums.ini b/build/pkgs/igraph/checksums.ini
index 51192799072..6d63bbce214 100644
--- a/build/pkgs/igraph/checksums.ini
+++ b/build/pkgs/igraph/checksums.ini
@@ -1,5 +1,4 @@
 tarball=igraph-VERSION.tar.gz
 sha1=40efbd2adf3c1cc0a2bb3e14f4c7898d053f1fe4
-md5=87d287445c44fdd19ad67a25e0e0859b
-cksum=2559618807
+sha256=ac5fa94ae6fd1eace651e4b235e99c056479a5c5d0d641aed30240ac33b19403
 upstream_url=https://github.com/igraph/igraph/releases/download/VERSION/igraph-VERSION.tar.gz
diff --git a/build/pkgs/imagesize/checksums.ini b/build/pkgs/imagesize/checksums.ini
index 3410cc38578..75413be5c69 100644
--- a/build/pkgs/imagesize/checksums.ini
+++ b/build/pkgs/imagesize/checksums.ini
@@ -1,5 +1,4 @@
 tarball=imagesize-VERSION-py2.py3-none-any.whl
 sha1=6054e528ed40a9979df9952437a20c3e5773d972
-md5=020f792680bad3d268a7321947e4e542
-cksum=379545474
+sha256=0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b
 upstream_url=https://pypi.io/packages/py2.py3/i/imagesize/imagesize-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/iml/checksums.ini b/build/pkgs/iml/checksums.ini
index 628d5461e70..df0743f2ae6 100644
--- a/build/pkgs/iml/checksums.ini
+++ b/build/pkgs/iml/checksums.ini
@@ -1,4 +1,3 @@
 tarball=iml-VERSION.tar.bz2
 sha1=8aba468a62e6fb0584be9b014350b734663c0670
-md5=a8083e70c0c4378f69eb772c1eeed6f0
-cksum=2793221462
+sha256=220161bbe4b54b24fcffc6c9117c8c8c09f2f13a9e2351cc2ef0dbac33bd418a
diff --git a/build/pkgs/importlib_metadata/checksums.ini b/build/pkgs/importlib_metadata/checksums.ini
index 3f05bd40dcb..d21661c6dbc 100644
--- a/build/pkgs/importlib_metadata/checksums.ini
+++ b/build/pkgs/importlib_metadata/checksums.ini
@@ -1,5 +1,4 @@
 tarball=importlib_metadata-VERSION-py3-none-any.whl
 sha1=82c9e2e6cfbb2d5a14558085efa65e75a95bd12f
-md5=6e7b1ecc1d63501048d17b2a59e74878
-cksum=905912098
+sha256=4805911c3a4ec7c3966410053e9ec6a1fecd629117df5adee56dfc9432a1081e
 upstream_url=https://pypi.io/packages/py3/i/importlib_metadata/importlib_metadata-VERSION-py3-none-any.whl
diff --git a/build/pkgs/importlib_metadata/spkg-configure.m4 b/build/pkgs/importlib_metadata/spkg-configure.m4
index e096a0182a5..7507a56462c 100644
--- a/build/pkgs/importlib_metadata/spkg-configure.m4
+++ b/build/pkgs/importlib_metadata/spkg-configure.m4
@@ -1,24 +1,27 @@
-SAGE_SPKG_CONFIGURE([importlib_metadata], [
+SAGE_SPKG_CONFIGURE([importlib_metadata], [dnl
   SAGE_PYTHON_PACKAGE_CHECK([importlib_metadata])
 ],[
-  # Three of our python packages are backport packages providing
-  # python-3.11 features (see coding_in_python.rst):
-  #
-  #   * importlib_metadata
-  #   * importlib_resources
-  #   * typing_extensions
-  #
-  # These packages are therefore not needed with >=python-3.11. Here
-  # we test for a python minor version component greater than or equal
-  # to 11, and mark this package as "not required" if we succeed.
-  AC_MSG_CHECKING([for >=python-3.11])
-
-  # Keep in mind that False (~ zero) in python is success in the shell
-  AS_IF(["${PYTHON_FOR_VENV}" -c "import sys; sys.exit(sys.version_info.minor < 11)"],[
-    AC_MSG_RESULT([yes])
+  dnl Three of our python packages are backport packages providing
+  dnl python-3.11 features (see coding_in_python.rst):
+  dnl
+  dnl   * importlib_metadata
+  dnl   * importlib_resources
+  dnl   * typing_extensions
+  dnl
+  dnl These packages are therefore not needed with >=python-3.11. Here
+  dnl we test for a python minor version component greater than or equal
+  dnl to 11, and mark this package as "not required" if we succeed.
+  AS_IF([test -z "${PYTHON_FOR_VENV}"], [dnl
+    dnl Python from our SPKG is new enough, no need for the backport package.
     sage_require_importlib_metadata="no"
-  ],[
-    AC_MSG_RESULT([no])
+  ], [dnl
+    AC_MSG_CHECKING([for >=python-3.11])
+    dnl Keep in mind that False (~ zero) in python is success in the shell
+    AS_IF(["${PYTHON_FOR_VENV}" -c "import sys; sys.exit(sys.version_info.minor < 11)"], [dnl
+      AC_MSG_RESULT([yes])
+      sage_require_importlib_metadata="no"
+    ],[dnl
+      AC_MSG_RESULT([no])
+    ])
   ])
 ])
-
diff --git a/build/pkgs/importlib_resources/checksums.ini b/build/pkgs/importlib_resources/checksums.ini
index e733e142b52..c4025635c2f 100644
--- a/build/pkgs/importlib_resources/checksums.ini
+++ b/build/pkgs/importlib_resources/checksums.ini
@@ -1,5 +1,4 @@
 tarball=importlib_resources-VERSION-py3-none-any.whl
 sha1=5caa4e8a9ee93123a5c3badb6edbc009b5d8494a
-md5=a4ba26d808eed58bde249276da04c9e1
-cksum=2487282894
+sha256=e8bf90d8213b486f428c9c39714b920041cb02c184686a3dee24905aaa8105d6
 upstream_url=https://pypi.io/packages/py3/i/importlib_resources/importlib_resources-VERSION-py3-none-any.whl
diff --git a/build/pkgs/importlib_resources/spkg-configure.m4 b/build/pkgs/importlib_resources/spkg-configure.m4
index 1416ec5c200..05f83a86052 100644
--- a/build/pkgs/importlib_resources/spkg-configure.m4
+++ b/build/pkgs/importlib_resources/spkg-configure.m4
@@ -1,23 +1,27 @@
-SAGE_SPKG_CONFIGURE([importlib_resources], [
+SAGE_SPKG_CONFIGURE([importlib_resources], [dnl
   SAGE_PYTHON_PACKAGE_CHECK([importlib_resources])
 ],[
-  # Three of our python packages are backport packages providing
-  # python-3.11 features (see coding_in_python.rst):
-  #
-  #   * importlib_metadata
-  #   * importlib_resources
-  #   * typing_extensions
-  #
-  # These packages are therefore not needed with >=python-3.11. Here
-  # we test for a python minor version component greater than or equal
-  # to 11, and mark this package as "not required" if we succeed.
-  AC_MSG_CHECKING([for >=python-3.11])
-
-  # Keep in mind that False (~ zero) in python is success in the shell
-  AS_IF(["${PYTHON_FOR_VENV}" -c "import sys; sys.exit(sys.version_info.minor < 11)"],[
-    AC_MSG_RESULT([yes])
+  dnl Three of our python packages are backport packages providing
+  dnl python-3.11 features (see coding_in_python.rst):
+  dnl
+  dnl   * importlib_metadata
+  dnl   * importlib_resources
+  dnl   * typing_extensions
+  dnl
+  dnl These packages are therefore not needed with >=python-3.11. Here
+  dnl we test for a python minor version component greater than or equal
+  dnl to 11, and mark this package as "not required" if we succeed.
+  AS_IF([test -z "${PYTHON_FOR_VENV}"], [dnl
+    dnl Python from our SPKG is new enough, no need for the backport package.
     sage_require_importlib_resources="no"
-  ],[
-    AC_MSG_RESULT([no])
+  ], [dnl
+    AC_MSG_CHECKING([for >=python-3.11])
+    dnl Keep in mind that False (~ zero) in python is success in the shell
+    AS_IF(["${PYTHON_FOR_VENV}" -c "import sys; sys.exit(sys.version_info.minor < 11)"], [dnl
+      AC_MSG_RESULT([yes])
+      sage_require_importlib_resources="no"
+    ],[dnl
+      AC_MSG_RESULT([no])
+    ])
   ])
 ])
diff --git a/build/pkgs/info/checksums.ini b/build/pkgs/info/checksums.ini
index cf6afe0684c..20442649954 100644
--- a/build/pkgs/info/checksums.ini
+++ b/build/pkgs/info/checksums.ini
@@ -1,5 +1,4 @@
 tarball=texinfo-VERSION.tar.xz
 sha1=356a623b88401d7c993408f33450c8104aad9df8
-md5=37bf94fd255729a14d4ea3dda119f81a
-cksum=1448415744
+sha256=74b420d09d7f528e84f97aa330f0dd69a98a6053e7a4e01767eed115038807bf
 upstream_url=https://ftp.gnu.org/gnu/texinfo/texinfo-VERSION.tar.xz
diff --git a/build/pkgs/ipykernel/checksums.ini b/build/pkgs/ipykernel/checksums.ini
index 1dc395313d6..ccb54046f0a 100644
--- a/build/pkgs/ipykernel/checksums.ini
+++ b/build/pkgs/ipykernel/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ipykernel-VERSION.tar.gz
 sha1=3465b4aa523705e930f295b5c549924e376a02e2
-md5=f48666313b1ddf7b796b9a58805ba71b
-cksum=2919090600
+sha256=7d5d594b6690654b4d299edba5e872dc17bb7396a8d0609c97cb7b8a1c605de6
 upstream_url=https://pypi.io/packages/source/i/ipykernel/ipykernel-VERSION.tar.gz
diff --git a/build/pkgs/ipympl/checksums.ini b/build/pkgs/ipympl/checksums.ini
index 2c724147c64..ec23f194f50 100644
--- a/build/pkgs/ipympl/checksums.ini
+++ b/build/pkgs/ipympl/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ipympl-VERSION-py2.py3-none-any.whl
 sha1=9848409026669d9edd83074730d7e2456ae8a187
-md5=e08ec29d29955174178b7230d41a7ff7
-cksum=490103438
+sha256=d113cd55891bafe9b27ef99b6dd111a87beb6bb2ae550c404292272103be8013
 upstream_url=https://pypi.io/packages/py2.py3/i/ipympl/ipympl-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/ipython/checksums.ini b/build/pkgs/ipython/checksums.ini
index cf6feff95e3..0f7cc9c7d51 100644
--- a/build/pkgs/ipython/checksums.ini
+++ b/build/pkgs/ipython/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ipython-VERSION.tar.gz
 sha1=4b5ab06a1b5e1a3285ac91d7dac9a22d18898a31
-md5=b56b71635168357dc94ac384b0a78f0c
-cksum=1043636334
+sha256=ca6f079bb33457c66e233e4580ebfc4128855b4cf6370dddd73842a9563e8a27
 upstream_url=https://pypi.io/packages/source/i/ipython/ipython-VERSION.tar.gz
diff --git a/build/pkgs/ipython_genutils/checksums.ini b/build/pkgs/ipython_genutils/checksums.ini
index 363c3428a98..64e87d3d967 100644
--- a/build/pkgs/ipython_genutils/checksums.ini
+++ b/build/pkgs/ipython_genutils/checksums.ini
@@ -1,4 +1,3 @@
 tarball=ipython_genutils-VERSION.tar.gz
 sha1=5bbf262704d1406ed63e639c5136bf80b87272c5
-md5=5a4f9781f78466da0ea1a648f3e1f79f
-cksum=2736651136
+sha256=eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8
diff --git a/build/pkgs/ipywidgets/checksums.ini b/build/pkgs/ipywidgets/checksums.ini
index a04080bb509..ad3dca0b6d8 100644
--- a/build/pkgs/ipywidgets/checksums.ini
+++ b/build/pkgs/ipywidgets/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ipywidgets-VERSION.tar.gz
 sha1=95f7ec13e8ce75e2da40c1789b4af291946a6d99
-md5=2809d1668037606caac588cab329bece
-cksum=1839869422
+sha256=40211efb556adec6fa450ccc2a77d59ca44a060f4f9f136833df59c9f538e6e8
 upstream_url=https://pypi.io/packages/source/i/ipywidgets/ipywidgets-VERSION.tar.gz
diff --git a/build/pkgs/isl/checksums.ini b/build/pkgs/isl/checksums.ini
index f9ce14a528a..8017dc5cc24 100644
--- a/build/pkgs/isl/checksums.ini
+++ b/build/pkgs/isl/checksums.ini
@@ -1,4 +1,3 @@
 tarball=isl-VERSION.tar.bz2
 sha1=b1d96b7b44c72f86c98d4fbd4caaa7796b27681e
-md5=cb396f31b24aeeac49840b519741b0e1
-cksum=4190462468
+sha256=b587e083eb65a8b394e833dea1744f21af3f0e413a448c17536b5549ae42a4c2
diff --git a/build/pkgs/isoduration/checksums.ini b/build/pkgs/isoduration/checksums.ini
index 490fd21be52..d3e080d1982 100644
--- a/build/pkgs/isoduration/checksums.ini
+++ b/build/pkgs/isoduration/checksums.ini
@@ -1,5 +1,4 @@
 tarball=isoduration-VERSION-py3-none-any.whl
 sha1=a113878d368fee6881efcfd12421b12f8e6ae11c
-md5=c5f76c264bf80cca84b99c48d8af5afb
-cksum=3373220361
+sha256=b2904c2a4228c3d44f409c8ae8e2370eb21a26f7ac2ec5446df141dde3452042
 upstream_url=https://pypi.io/packages/py3/i/isoduration/isoduration-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jedi/checksums.ini b/build/pkgs/jedi/checksums.ini
index 291cf130faf..bbfe9535f75 100644
--- a/build/pkgs/jedi/checksums.ini
+++ b/build/pkgs/jedi/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jedi-VERSION.tar.gz
 sha1=07d1e04c24cecf1b7f38f8905ce81c006f76cc20
-md5=0951191b506b660bfdb90c3dcd5b3254
-cksum=8256815
+sha256=cf0496f3651bc65d7174ac1b7d043eff454892c708a87d1b683e57b569927ffd
 upstream_url=https://pypi.io/packages/source/j/jedi/jedi-VERSION.tar.gz
diff --git a/build/pkgs/jinja2/checksums.ini b/build/pkgs/jinja2/checksums.ini
index 3d2a3484695..fa9f5daf853 100644
--- a/build/pkgs/jinja2/checksums.ini
+++ b/build/pkgs/jinja2/checksums.ini
@@ -1,5 +1,4 @@
 tarball=Jinja2-VERSION-py3-none-any.whl
 sha1=2a4d66fe16c565145c8bec1b22d57ab1e7028613
-md5=bb730eed73dcd0bc2b04c71555f37d92
-cksum=1024075345
+sha256=7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa
 upstream_url=https://pypi.io/packages/py3/j/jinja2/Jinja2-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jmol/checksums.ini b/build/pkgs/jmol/checksums.ini
index 71b5b403ed1..fed8afec819 100644
--- a/build/pkgs/jmol/checksums.ini
+++ b/build/pkgs/jmol/checksums.ini
@@ -1,4 +1,3 @@
 tarball=jmol-VERSION.tar.bz2
 sha1=63aa528c1105733b1ad2cde222cf8c7ba7f456c4
-md5=99974970fe3c78e4401bf62780185fee
-cksum=3961597437
+sha256=ebf9cd42cd8e3839cf94ec11691b98a9b00917f3485a821291b76d7ecd6ffe9d
diff --git a/build/pkgs/json5/checksums.ini b/build/pkgs/json5/checksums.ini
index 5e05994b435..d95e497ddc7 100644
--- a/build/pkgs/json5/checksums.ini
+++ b/build/pkgs/json5/checksums.ini
@@ -1,5 +1,4 @@
 tarball=json5-VERSION-py2.py3-none-any.whl
 sha1=54bf91b9c2812e82ccd212cefca5bc5607a538b4
-md5=aede9af2a42cc0cd928e4dc99e9a6a45
-cksum=134804175
+sha256=740c7f1b9e584a468dbb2939d8d458db3427f2c93ae2139d05f47e453eae964f
 upstream_url=https://pypi.io/packages/py2.py3/j/json5/json5-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/jsonpointer/checksums.ini b/build/pkgs/jsonpointer/checksums.ini
index 67173595af5..df24503fc54 100644
--- a/build/pkgs/jsonpointer/checksums.ini
+++ b/build/pkgs/jsonpointer/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jsonpointer-VERSION-py2.py3-none-any.whl
 sha1=de1b07c2d014f5b8e672cf0fb1225b2232d0b414
-md5=eb9dcb8c4ccf5d97cea88a7d13510032
-cksum=1224177904
+sha256=15d51bba20eea3165644553647711d150376234112651b4f1811022aecad7d7a
 upstream_url=https://pypi.io/packages/py2.py3/j/jsonpointer/jsonpointer-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/jsonschema/checksums.ini b/build/pkgs/jsonschema/checksums.ini
index e2b4c0ecb27..89a23a0d2cf 100644
--- a/build/pkgs/jsonschema/checksums.ini
+++ b/build/pkgs/jsonschema/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jsonschema-VERSION.tar.gz
 sha1=9f762c6c2b92defddf1c441cce8132d021252b2c
-md5=7c65ceb8923c83cb1f22c2b5a86d99b0
-cksum=2329321415
+sha256=0f864437ab8b6076ba6707453ef8f98a6a0d512a80e93f8abdb676f737ecb60d
 upstream_url=https://pypi.io/packages/source/j/jsonschema/jsonschema-VERSION.tar.gz
diff --git a/build/pkgs/jsonschema_specifications/checksums.ini b/build/pkgs/jsonschema_specifications/checksums.ini
index b0a51d9b7b4..df5d6944abd 100644
--- a/build/pkgs/jsonschema_specifications/checksums.ini
+++ b/build/pkgs/jsonschema_specifications/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jsonschema_specifications-VERSION-py3-none-any.whl
 sha1=4132bed31478bc96960099e58ae4c083c514c551
-md5=dbd17550f666e0f9aa74270d0d4e97a3
-cksum=135654159
+sha256=764a2b9325c225208121948b15f2b2d16fddbe223fdfc096b45c70c1f7f7b8c1
 upstream_url=https://pypi.io/packages/py3/j/jsonschema_specifications/jsonschema_specifications-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jupymake/checksums.ini b/build/pkgs/jupymake/checksums.ini
index 9e697f2a1dc..cc9c4dcaea7 100644
--- a/build/pkgs/jupymake/checksums.ini
+++ b/build/pkgs/jupymake/checksums.ini
@@ -1,4 +1,3 @@
 tarball=JuPyMake-VERSION.tar.gz
 sha1=0dc4e4a29afbdc733908249cd28b7ed4c4ab8b73
-md5=646f0c6c91166ea84e233587fc2dec1e
-cksum=4049738923
+sha256=4c756cd6a6056a20cd71f7b5e463c79dad0257241bbd32a40b750882fafdb545
diff --git a/build/pkgs/jupyter_client/checksums.ini b/build/pkgs/jupyter_client/checksums.ini
index b91837ba332..af7a000f71d 100644
--- a/build/pkgs/jupyter_client/checksums.ini
+++ b/build/pkgs/jupyter_client/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyter_client-VERSION-py3-none-any.whl
 sha1=341f822626b55b53f03a21a44d78dc203472406b
-md5=cca418dacc69d69f3e3c71704f1fd259
-cksum=753481733
+sha256=5eb9f55eb0650e81de6b7e34308d8b92d04fe4ec41cd8193a913979e33d8e1a5
 upstream_url=https://pypi.io/packages/py3/j/jupyter_client/jupyter_client-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jupyter_core/checksums.ini b/build/pkgs/jupyter_core/checksums.ini
index 0c807beeff7..672c7f93bcc 100644
--- a/build/pkgs/jupyter_core/checksums.ini
+++ b/build/pkgs/jupyter_core/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyter_core-VERSION.tar.gz
 sha1=0fe33e3247e595cdb83e2220f02c566ea9397e6a
-md5=1d61b3c16f6781d8f44e1bd95cd8e73f
-cksum=523684111
+sha256=0c28db6cbe2c37b5b398e1a1a5b22f84fd64cd10afc1f6c05b02fb09481ba45f
 upstream_url=https://pypi.io/packages/source/j/jupyter_core/jupyter_core-VERSION.tar.gz
diff --git a/build/pkgs/jupyter_events/checksums.ini b/build/pkgs/jupyter_events/checksums.ini
index b0721f150a1..d7fc20e35ba 100644
--- a/build/pkgs/jupyter_events/checksums.ini
+++ b/build/pkgs/jupyter_events/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyter_events-VERSION-py3-none-any.whl
 sha1=1b3fd8c003ea9e51b0f2d38daa89fded161767f7
-md5=c29e5cb7f9f1b3916b2d9d416b470294
-cksum=2851951719
+sha256=57a2749f87ba387cd1bfd9b22a0875b889237dbf2edc2121ebb22bde47036c17
 upstream_url=https://pypi.io/packages/py3/j/jupyter_events/jupyter_events-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jupyter_jsmol/checksums.ini b/build/pkgs/jupyter_jsmol/checksums.ini
index 9ac2c41a8e4..533f2b689d3 100644
--- a/build/pkgs/jupyter_jsmol/checksums.ini
+++ b/build/pkgs/jupyter_jsmol/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyter_jsmol-VERSION-py2.py3-none-any.whl
 sha1=b00f1ca76aaa906c7c0a43e36baf608183f3d552
-md5=dd786877513296a36a08518ad64ace47
-cksum=2135042898
+sha256=dca3a232f98aa92739de8b7905765d22f325a2ba5d7a3a2f5b2374e88cc80471
 upstream_url=https://pypi.io/packages/py2.py3/j/jupyter_jsmol/jupyter_jsmol-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/jupyter_lsp/checksums.ini b/build/pkgs/jupyter_lsp/checksums.ini
index 0e0a2cbf90e..b925e4da051 100644
--- a/build/pkgs/jupyter_lsp/checksums.ini
+++ b/build/pkgs/jupyter_lsp/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyter_lsp-VERSION-py3-none-any.whl
 sha1=0f7a63d99c5cf624315583099f00eafc4b996b59
-md5=9c17daaa4372bffca936c1b6977e713b
-cksum=1933820697
+sha256=9e06b8b4f7dd50300b70dd1a78c0c3b0c3d8fa68e0f2d8a5d1fbab62072aca3f
 upstream_url=https://pypi.io/packages/py3/j/jupyter_lsp/jupyter_lsp-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jupyter_server/checksums.ini b/build/pkgs/jupyter_server/checksums.ini
index e81f1110be3..9519eaa2ae6 100644
--- a/build/pkgs/jupyter_server/checksums.ini
+++ b/build/pkgs/jupyter_server/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyter_server-VERSION-py3-none-any.whl
 sha1=a54aa7f6f1657a55cae9ecc4a6654b6e3ca5fb73
-md5=b028711b35fa80f6c7b01a54bd70718a
-cksum=1159424906
+sha256=8e4b90380b59d7a1e31086c4692231f2a2ea4cb269f5516e60aba72ce8317fc9
 upstream_url=https://pypi.io/packages/py3/j/jupyter_server/jupyter_server-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jupyter_server_terminals/checksums.ini b/build/pkgs/jupyter_server_terminals/checksums.ini
index 99f9ede51e0..be5ba3efe9b 100644
--- a/build/pkgs/jupyter_server_terminals/checksums.ini
+++ b/build/pkgs/jupyter_server_terminals/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyter_server_terminals-VERSION-py3-none-any.whl
 sha1=fd1201e9f0064b2a5a05ed7346dfe52546f13b0b
-md5=6312ef2342aa944aaa59619249d7248b
-cksum=2312769383
+sha256=75779164661cec02a8758a5311e18bb8eb70c4e86c6b699403100f1585a12a36
 upstream_url=https://pypi.io/packages/py3/j/jupyter_server_terminals/jupyter_server_terminals-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jupyter_sphinx/checksums.ini b/build/pkgs/jupyter_sphinx/checksums.ini
index a61d047a41d..fc843987136 100644
--- a/build/pkgs/jupyter_sphinx/checksums.ini
+++ b/build/pkgs/jupyter_sphinx/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyter_sphinx-VERSION.tar.gz
 sha1=85e6e1665488fac3131da2e3ab9648037c0d1da9
-md5=397d3b20c8df015bf6a1e50d0208590d
-cksum=524174657
+sha256=2e23699a3a1cf5db31b10981da5aa32606ee730f6b73a844d1e76d800756af56
 upstream_url=https://pypi.io/packages/source/j/jupyter_sphinx/jupyter_sphinx-VERSION.tar.gz
diff --git a/build/pkgs/jupyterlab/checksums.ini b/build/pkgs/jupyterlab/checksums.ini
index f98b0077323..eea8e9d4191 100644
--- a/build/pkgs/jupyterlab/checksums.ini
+++ b/build/pkgs/jupyterlab/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyterlab-VERSION-py3-none-any.whl
 sha1=4efdd879660e719fd49be6ec169272f32a16593e
-md5=968a2b0458440a6b018ff2863a66e4af
-cksum=2309499829
+sha256=67dbec7057c6ad46f08a3667a80bdb890df9453822c93b5ddfd5e8313a718ef9
 upstream_url=https://pypi.io/packages/py3/j/jupyterlab/jupyterlab-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jupyterlab_mathjax2/checksums.ini b/build/pkgs/jupyterlab_mathjax2/checksums.ini
index 6a428bd21dc..3ff851f18bb 100644
--- a/build/pkgs/jupyterlab_mathjax2/checksums.ini
+++ b/build/pkgs/jupyterlab_mathjax2/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyterlab_mathjax2-VERSION-py3-none-any.whl
 sha1=4e2bb182594a6c4f5d4edfb4f6e33597f09de402
-md5=4172e36b068af6a3f36c26a3f1946dc9
-cksum=387386440
+sha256=c65c401ee5638e7cbf1223ba95aceed8b26a2a3e48fd1d585a10dd95b9327a8f
 upstream_url=https://pypi.io/packages/py3/j/jupyterlab_mathjax2/jupyterlab_mathjax2-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jupyterlab_pygments/checksums.ini b/build/pkgs/jupyterlab_pygments/checksums.ini
index 6f5af4d8afd..7cbeda65aab 100644
--- a/build/pkgs/jupyterlab_pygments/checksums.ini
+++ b/build/pkgs/jupyterlab_pygments/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyterlab_pygments-VERSION-py2.py3-none-any.whl
 sha1=601f547767fa867494ff0764891807904b8ebbd2
-md5=44194b8e643cf025ec3a91f0c751c7d7
-cksum=4169885263
+sha256=2405800db07c9f770863bcf8049a529c3dd4d3e28536638bd7c1c01d2748309f
 upstream_url=https://pypi.io/packages/py2.py3/j/jupyterlab_pygments/jupyterlab_pygments-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/jupyterlab_server/checksums.ini b/build/pkgs/jupyterlab_server/checksums.ini
index 3bd8926fd7b..84eeb7a8b8d 100644
--- a/build/pkgs/jupyterlab_server/checksums.ini
+++ b/build/pkgs/jupyterlab_server/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyterlab_server-VERSION-py3-none-any.whl
 sha1=1fff8c8bc4c81b006cb83d4524dc8a6f3364e57c
-md5=795bbf343ae17b75a31a50ef574d4b77
-cksum=696988100
+sha256=5f077e142bb8dc9b843d960f940c513581bceca3793a0d80f9c67d9522c4e876
 upstream_url=https://pypi.io/packages/py3/j/jupyterlab_server/jupyterlab_server-VERSION-py3-none-any.whl
diff --git a/build/pkgs/jupyterlab_widgets/checksums.ini b/build/pkgs/jupyterlab_widgets/checksums.ini
index 7da29e7849e..f7a3c9bbeb8 100644
--- a/build/pkgs/jupyterlab_widgets/checksums.ini
+++ b/build/pkgs/jupyterlab_widgets/checksums.ini
@@ -1,5 +1,4 @@
 tarball=jupyterlab_widgets-VERSION-py3-none-any.whl
 sha1=b10775bb3966af627bb44fbda4efb553b24a5b93
-md5=fc3c9f41000461dbdca2b965fcee37db
-cksum=441194289
+sha256=3cf5bdf5b897bf3bccf1c11873aa4afd776d7430200f765e0686bd352487b58d
 upstream_url=https://pypi.io/packages/py3/j/jupyterlab_widgets/jupyterlab_widgets-VERSION-py3-none-any.whl
diff --git a/build/pkgs/kenzo/checksums.ini b/build/pkgs/kenzo/checksums.ini
index 7fff82ca271..882ad8e2c97 100644
--- a/build/pkgs/kenzo/checksums.ini
+++ b/build/pkgs/kenzo/checksums.ini
@@ -1,5 +1,4 @@
 tarball=kenzo-VERSION.tar.gz
-upstream_url=https://github.com/miguelmarco/kenzo/releases/download/VERSION/kenzo-VERSION.tar.gz
 sha1=76115aae9972090d5d51fee18592fc7a79461474
-md5=3a3d5350fb17304f03e614713e585ed4
-cksum=2981306888
+sha256=2a23697611a37714433a9e273098d0b2dfe4fdcd83d98b9fc8d7a055c064ed6b
+upstream_url=https://github.com/miguelmarco/kenzo/releases/download/VERSION/kenzo-VERSION.tar.gz
diff --git a/build/pkgs/kissat/checksums.ini b/build/pkgs/kissat/checksums.ini
index 85929110253..c929e1733e1 100644
--- a/build/pkgs/kissat/checksums.ini
+++ b/build/pkgs/kissat/checksums.ini
@@ -1,5 +1,4 @@
 tarball=kissat-rel-VERSION.tar.gz
 sha1=49972324939761306ee50cfa3df93cd3cd530256
-md5=1d0fa246c5451e3592910f2c9a5f3476
-cksum=2570717921
+sha256=e85c757179bf7d96d21d2d6e3f0a8f2337d416b0e13ae065a9a8d52e30048bd3
 upstream_url=https://github.com/arminbiere/kissat/archive/refs/tags/rel-VERSION.tar.gz
diff --git a/build/pkgs/kiwisolver/checksums.ini b/build/pkgs/kiwisolver/checksums.ini
index db7ec7448ef..84fc1beba83 100644
--- a/build/pkgs/kiwisolver/checksums.ini
+++ b/build/pkgs/kiwisolver/checksums.ini
@@ -1,5 +1,4 @@
 tarball=kiwisolver-VERSION.tar.gz
 sha1=e5234bdcb7e7b620d47a00da076d50f2b63d8649
-md5=20dea6992699d6be8a563995d7fe0309
-cksum=1731645516
+sha256=e57e563a57fb22a142da34f38acc2fc1a5c864bc29ca1517a88abc963e60d6ec
 upstream_url=https://files.pythonhosted.org/packages/source/k/kiwisolver/kiwisolver-VERSION.tar.gz
diff --git a/build/pkgs/latte_int/checksums.ini b/build/pkgs/latte_int/checksums.ini
index 804020ed92d..8b73fd1e4f2 100644
--- a/build/pkgs/latte_int/checksums.ini
+++ b/build/pkgs/latte_int/checksums.ini
@@ -1,5 +1,4 @@
 tarball=latte-int-VERSION.tar.gz
 sha1=0ba017349b21a9fdb34b74d7e23d584aa562b8f7
-md5=aa062777c4879f566134d048ce4c87d6
-cksum=3733141299
+sha256=006c10ebe5d5bfdc9b159cba6264a4432861fe763ce05fe821624ab7d3fc2170
 upstream_url=https://github.com/latte-int/latte/releases/download/version_1_7_6/latte-int-VERSION.tar.gz
diff --git a/build/pkgs/lcalc/checksums.ini b/build/pkgs/lcalc/checksums.ini
index f755f54b49e..b56cf1b79bf 100644
--- a/build/pkgs/lcalc/checksums.ini
+++ b/build/pkgs/lcalc/checksums.ini
@@ -1,5 +1,4 @@
 tarball=lcalc-VERSION.tar.xz
 sha1=dacf9ab672136edc2af5fe9adb7b0ced1e63eeff
-md5=c496e95ae07a58085e93b2b3c3348719
-cksum=1694786
+sha256=d780c385579cc6ee45fa27ccd2d3a3c4157fbb5ef8cd1b8951d1028bbc64c035
 upstream_url=https://gitlab.com/sagemath/lcalc/uploads/25f029f3c02fcb6c3174972e0ac0e192/lcalc-VERSION.tar.xz
diff --git a/build/pkgs/libatomic_ops/checksums.ini b/build/pkgs/libatomic_ops/checksums.ini
index 92ac5be4cd5..bd2b5075221 100644
--- a/build/pkgs/libatomic_ops/checksums.ini
+++ b/build/pkgs/libatomic_ops/checksums.ini
@@ -1,5 +1,4 @@
 tarball=libatomic_ops-VERSION.tar.gz
 sha1=69223bbec025a0d57977feb861479f78a5e6c8d7
-md5=a7e51e8041c3e60c298c037b2789c3fa
-cksum=596151076
+sha256=15676e7674e11bda5a7e50a73f4d9e7d60452271b8acf6fd39a71fefdf89fa31
 upstream_url=https://github.com/ivmai/libatomic_ops/releases/download/vVERSION/libatomic_ops-VERSION.tar.gz
diff --git a/build/pkgs/libbraiding/checksums.ini b/build/pkgs/libbraiding/checksums.ini
index 466c33c66a5..5a956e027bf 100644
--- a/build/pkgs/libbraiding/checksums.ini
+++ b/build/pkgs/libbraiding/checksums.ini
@@ -1,5 +1,4 @@
 tarball=libbraiding-VERSION-actually-VERSION.tar.gz
 sha1=b7e13778784fe1e36e7c0cbd7a4c234a090cd1b2
-md5=0513967c81b783ea66336b7ad0562534
-cksum=3619705925
+sha256=73087d1145ace719eafeda1db1c28b5fe1c981b7e784dc59f2b1d6fc4ff75f80
 upstream_url=https://github.com/miguelmarco/libbraiding/releases/download/VERSION/libbraiding-VERSION.tar.gz
diff --git a/build/pkgs/libffi/checksums.ini b/build/pkgs/libffi/checksums.ini
index fbcc6a81efd..327da6eed8b 100644
--- a/build/pkgs/libffi/checksums.ini
+++ b/build/pkgs/libffi/checksums.ini
@@ -1,4 +1,3 @@
 tarball=libffi-VERSION.tar.gz
 sha1=280c265b789e041c02e5c97815793dfc283fb1e6
-md5=83b89587607e3eb65c70d361f13bab43
-cksum=691100768
+sha256=d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37
diff --git a/build/pkgs/libgd/checksums.ini b/build/pkgs/libgd/checksums.ini
index 504b0d2d5be..128e99830cf 100644
--- a/build/pkgs/libgd/checksums.ini
+++ b/build/pkgs/libgd/checksums.ini
@@ -1,5 +1,4 @@
 tarball=libgd-VERSION.tar.xz
 sha1=7ce6ecb5aed26c08246a37b6351c886ab4b51ca2
-md5=7a58b54d375eda236414201252a0ee3c
-cksum=1360697583
+sha256=3fe822ece20796060af63b7c60acb151e5844204d289da0ce08f8fdf131e5a61
 upstream_url=https://github.com/libgd/libgd/releases/download/gd-VERSION/libgd-VERSION.tar.xz
diff --git a/build/pkgs/libhomfly/checksums.ini b/build/pkgs/libhomfly/checksums.ini
index 0d3a841d93c..e763424cc34 100644
--- a/build/pkgs/libhomfly/checksums.ini
+++ b/build/pkgs/libhomfly/checksums.ini
@@ -1,5 +1,4 @@
 tarball=libhomfly-VERSION.tar.gz
 sha1=a8a4d9fb5bfacdbacab32bb0c8ea6d21ad9f7e54
-md5=1bb639fd4182be7ac9dbec0c3e631ce2
-cksum=920200221
+sha256=f990d991d29a590c54b09eff68bc209c4cf2b8b12d945351688d2db8a0d30979
 upstream_url=https://github.com/miguelmarco/libhomfly/releases/download/VERSION/libhomfly-VERSION.tar.gz
diff --git a/build/pkgs/libogg/checksums.ini b/build/pkgs/libogg/checksums.ini
index 0307fec2b99..b82853fc105 100644
--- a/build/pkgs/libogg/checksums.ini
+++ b/build/pkgs/libogg/checksums.ini
@@ -1,4 +1,3 @@
 tarball=libogg-VERSION.tar.gz
 sha1=270685c2a3d9dc6c98372627af99868aa4b4db53
-md5=ba526cd8f4403a5d351a9efaa8608fbc
-cksum=1193714825
+sha256=4e343f07aa5a1de8e0fa1107042d472186b3470d846b20b115b964eba5bae554
diff --git a/build/pkgs/libpng/checksums.ini b/build/pkgs/libpng/checksums.ini
index c6c7adab90b..3ff528ccdc6 100644
--- a/build/pkgs/libpng/checksums.ini
+++ b/build/pkgs/libpng/checksums.ini
@@ -1,4 +1,3 @@
 tarball=libpng-VERSION.tar.gz
 sha1=012c842e6454dc38c6390623ed31ec4005c00584
-md5=68553080685f812d1dd7a6b8215c37d8
-cksum=1294784956
+sha256=e30bf36cd5882e017c23a5c6a79a9aa1a744dd5841bb45ff7035ec6e3b3096b8
diff --git a/build/pkgs/libsemigroups/checksums.ini b/build/pkgs/libsemigroups/checksums.ini
index 4e13a36cb35..e258d4f2058 100644
--- a/build/pkgs/libsemigroups/checksums.ini
+++ b/build/pkgs/libsemigroups/checksums.ini
@@ -1,5 +1,4 @@
 tarball=libsemigroups-VERSION.tar.gz
 sha1=86375824b47ce4b0e23570122e873f67136d0c0a
-md5=ff79ad5fbc8bfeb64d48faaf24106b98
-cksum=2845045455
+sha256=6214fd9e87af3834ff5eb6377cde1cbef76c74b233e1b0c4d15af1d2311692b4
 upstream_url=https://github.com/libsemigroups/libsemigroups/releases/download/vVERSION/libsemigroups-VERSION.tar.gz
diff --git a/build/pkgs/libtheora/checksums.ini b/build/pkgs/libtheora/checksums.ini
index f18d6c544c5..b940bb462c1 100644
--- a/build/pkgs/libtheora/checksums.ini
+++ b/build/pkgs/libtheora/checksums.ini
@@ -1,4 +1,3 @@
 tarball=libtheora-VERSION.tar.bz2
 sha1=8dcaa8e61cd86eb1244467c0b64b9ddac04ae262
-md5=292ab65cedd5021d6b7ddd117e07cd8e
-cksum=480505883
+sha256=b6ae1ee2fa3d42ac489287d3ec34c5885730b1296f0801ae577a35193d3affbc
diff --git a/build/pkgs/lidia/checksums.ini b/build/pkgs/lidia/checksums.ini
index a72a61954a1..29d6de29c90 100644
--- a/build/pkgs/lidia/checksums.ini
+++ b/build/pkgs/lidia/checksums.ini
@@ -1,4 +1,3 @@
 tarball=lidia-VERSION.tar.gz
 sha1=93da2f24e3caa4c10452b4f088382084da3ddfbd
-md5=2d75b417194e98be64dd85368e149cf4
-cksum=1175913571
+sha256=a5a07e65fc48c9230e9669e4d968b4ede2cac234a49d0c8c93b85040d0d79c41
diff --git a/build/pkgs/lie/checksums.ini b/build/pkgs/lie/checksums.ini
index 83fede0fa5f..312aa3cbe54 100644
--- a/build/pkgs/lie/checksums.ini
+++ b/build/pkgs/lie/checksums.ini
@@ -1,4 +1,3 @@
 tarball=lie-VERSION.tar.gz
 sha1=bf8d2303c02738cfd2c899332d736b5364322a5d
-md5=2e98f252364d43557a322ea7eb677944
-cksum=3838739617
+sha256=c4d6f67fa17d2bc77c875a5b2ad2b42ffc5cadf30e7d1c64c097648ccb918b1e
diff --git a/build/pkgs/linbox/checksums.ini b/build/pkgs/linbox/checksums.ini
index 397bf97190f..8024fa48645 100644
--- a/build/pkgs/linbox/checksums.ini
+++ b/build/pkgs/linbox/checksums.ini
@@ -1,5 +1,4 @@
 tarball=linbox-VERSION.tar.gz
-sha1=24e8bdbd16fe3dedce0dd343398999a4aed7c02c
-md5=1e1b95f12f015815a0194eac0cb611d0
-cksum=253115750
-upstream_url=https://github.com/linbox-team/linbox/releases/download/vVERSION/linbox-VERSION.tar.gz
\ No newline at end of file
+sha1=8e8352dcbdf1f2412404e2ef1c81e556554755f3
+sha256=2a260d1aff12f9e4431929b5d5b26e70c26f004d16b47f81ccc0ee8c0d0b09d5
+upstream_url=https://github.com/mkoeppe/linbox/releases/download/v1.7.0%2Bsage-2024-05-18/linbox-1.7.0.tar.gz
diff --git a/build/pkgs/linbox/package-version.txt b/build/pkgs/linbox/package-version.txt
index bd8bf882d06..7f3ed41a2c8 100644
--- a/build/pkgs/linbox/package-version.txt
+++ b/build/pkgs/linbox/package-version.txt
@@ -1 +1 @@
-1.7.0
+1.7.0+sage-2024-05-18
diff --git a/build/pkgs/linbox/patches/310-backport.patch b/build/pkgs/linbox/patches/310-backport.patch
index c0c44bc1ec7..986ac298ce2 100644
--- a/build/pkgs/linbox/patches/310-backport.patch
+++ b/build/pkgs/linbox/patches/310-backport.patch
@@ -27,7 +27,7 @@ index 59006d6c5f..2604f47b81 100644
 +				const_cast(_data_beg)  = iter._data_beg ;
 +				const_cast(_data_end)  = iter._data_end  ;
 +				const_cast(_field)     = iter._field ;
-+				const_cast(ld)         = iter._ld ;
++				const_cast(_ld)         = iter._ld ;
  				_row       = iter._row ;
  
  				return *this;
@@ -48,7 +48,7 @@ index 498a5525db..a60943868b 100644
 +				const_cast(_data_end)= iter._data_end  ;
 +				const_cast(_field) = iter._field  ;
 +				const_cast&>(_rowid) = iter._rowid;
-+				const_cast(ld) = iter._ld ;
++				const_cast(_ld) = iter._ld ;
  				_row = iter._row ;
  
  				return *this;
@@ -63,7 +63,7 @@ index 498a5525db..a60943868b 100644
 +				const_cast(_data_beg) = iter._data_beg ;
 +				const_cast(_data_end) = iter._data_end  ;
 +				const_cast(_field)    = iter._field ;
-+				const_cast(ld)= iter._ld ;
++				const_cast(_ld)= iter._ld ;
  				_row       = iter._row ;
  
  				return *this;
diff --git a/build/pkgs/lrcalc/checksums.ini b/build/pkgs/lrcalc/checksums.ini
index 8b8620ba521..dc42cc9271a 100644
--- a/build/pkgs/lrcalc/checksums.ini
+++ b/build/pkgs/lrcalc/checksums.ini
@@ -1,5 +1,4 @@
 tarball=liblrcalc-VERSION.tar.gz
 sha1=2a98661eb39c7ef526c932f7886fc3142fd639ab
-md5=7cfa8f67287f2b70a15a833b94bc24b6
-cksum=2250996027
+sha256=996ac00e6ea8321ef09b34478f5379f613933c3254aeba624b6419b8afa5df57
 upstream_url=https://sites.math.rutgers.edu/~asbuch/lrcalc/lrcalc-VERSION.tar.gz
diff --git a/build/pkgs/lrcalc_python/checksums.ini b/build/pkgs/lrcalc_python/checksums.ini
index bdfef8711e6..99e136d82bb 100644
--- a/build/pkgs/lrcalc_python/checksums.ini
+++ b/build/pkgs/lrcalc_python/checksums.ini
@@ -1,5 +1,4 @@
 tarball=lrcalc-VERSION.tar.gz
 sha1=3e9366d9e8b8beccec70b07d174b8f6683c01574
-md5=4ae444d12ed8e0dd770594ea3ef4a208
-cksum=2741305196
+sha256=e3a0509aeda487b412b391a52e817ca36b5c063a8305e09fd54d53259dd6aaa9
 upstream_url=https://pypi.io/packages/source/l/lrcalc/lrcalc-VERSION.tar.gz
diff --git a/build/pkgs/lrslib/checksums.ini b/build/pkgs/lrslib/checksums.ini
index e296ecf4a74..0874680c33b 100644
--- a/build/pkgs/lrslib/checksums.ini
+++ b/build/pkgs/lrslib/checksums.ini
@@ -1,5 +1,4 @@
 tarball=lrslib-VERSION.tar.gz
 sha1=4723f2b96e4b59d8366316b84214d6221b7ee7ce
-md5=b379d2bdef0f5200c6274d9c50361b7c
-cksum=1216904185
+sha256=a202f3fb24a2e8561786dff679c7603c04c66d24728ad8aaba0b40dbdf9fb6a8
 upstream_url=https://github.com/mkoeppe/lrslib/releases/download/lrslib-VERSION/lrslib-VERSION.tar.gz
diff --git a/build/pkgs/m4ri/checksums.ini b/build/pkgs/m4ri/checksums.ini
index f7a8318e9dd..0deac09bc50 100644
--- a/build/pkgs/m4ri/checksums.ini
+++ b/build/pkgs/m4ri/checksums.ini
@@ -1,4 +1,3 @@
 tarball=m4ri-VERSION.tar.gz
 sha1=7d0d680f1e983c1d5b24e49f25194e2f327690b4
-md5=3fb6a27437bf535128d605fe47c8fae8
-cksum=1002661464
+sha256=a2ba0d74ec5129c6fab59cd7d8e7a9f00a69ec63b76672105faef524f9d88556
diff --git a/build/pkgs/m4rie/checksums.ini b/build/pkgs/m4rie/checksums.ini
index 6c4abb19145..096641cd512 100644
--- a/build/pkgs/m4rie/checksums.ini
+++ b/build/pkgs/m4rie/checksums.ini
@@ -1,4 +1,3 @@
 tarball=m4rie-VERSION.tar.gz
 sha1=728524509dd30da2dc960814b61d0bae67f83043
-md5=e7685c63e7bab4c5a0922a161499ba83
-cksum=127676695
+sha256=aea462e8c9b4c0303c0a064bd7ead52fe81214e59a7fc694f350161cad4f2c85
diff --git a/build/pkgs/markupsafe/checksums.ini b/build/pkgs/markupsafe/checksums.ini
index 0a124ae8e91..53502ada131 100644
--- a/build/pkgs/markupsafe/checksums.ini
+++ b/build/pkgs/markupsafe/checksums.ini
@@ -1,5 +1,4 @@
 tarball=MarkupSafe-VERSION.tar.gz
 sha1=ffca1ac960cedaf0cb419b5c97b64aab12220d04
-md5=8138329a11cf4bd0f9db780b2af26c66
-cksum=379626437
+sha256=3aae9af4cac263007fd6309c64c6ab4506dd2b79382d9d19a1994f9240b8db4f
 upstream_url=https://pypi.io/packages/source/m/markupsafe/MarkupSafe-VERSION.tar.gz
diff --git a/build/pkgs/mathics/checksums.ini b/build/pkgs/mathics/checksums.ini
index eeb1b4462f8..d43327d515d 100644
--- a/build/pkgs/mathics/checksums.ini
+++ b/build/pkgs/mathics/checksums.ini
@@ -1,5 +1,4 @@
 tarball=Mathics3-VERSION.tar.gz
 sha1=a72550d3df97dd4055cf903a9f012683ca2adf35
-md5=f221aaf0ef9a27e2953429a32fe94652
-cksum=658740029
+sha256=d50ee5ad07db845609078c99af789253337a45f50bef6f8b09262f48dca8da7c
 upstream_url=https://pypi.io/packages/source/M/Mathics3/Mathics3-VERSION.tar.gz
diff --git a/build/pkgs/mathics_scanner/checksums.ini b/build/pkgs/mathics_scanner/checksums.ini
index 46b8d9ed821..9d04979b6bd 100644
--- a/build/pkgs/mathics_scanner/checksums.ini
+++ b/build/pkgs/mathics_scanner/checksums.ini
@@ -1,5 +1,4 @@
 tarball=Mathics_Scanner-VERSION.tar.gz
 sha1=c89bb997c1da04c1cfe945d16be96bdb0c6ae9a8
-md5=5c1aabb415729617d8ebe03470f92339
-cksum=1258714825
+sha256=7b05939751aacea42f3fc4e7eb1ab111f9fe32bae827e89f46a50e04907b19ef
 upstream_url=https://pypi.io/packages/source/m/mathics_scanner/Mathics_Scanner-VERSION.tar.gz
diff --git a/build/pkgs/mathjax/checksums.ini b/build/pkgs/mathjax/checksums.ini
index 6a6b233b2ae..9be83c3fee4 100644
--- a/build/pkgs/mathjax/checksums.ini
+++ b/build/pkgs/mathjax/checksums.ini
@@ -1,4 +1,3 @@
 tarball=mathjax-VERSION.tar.gz
 sha1=3f7abecf8cacd7f5d7f9ae6c3baca7739101c17d
-md5=ba1a65ab58aaad6c84f39735c619bc34
-cksum=1142131398
+sha256=9b2ed180ff2ddb8d4ea1d00e4d14791320c35496f57073514a129c0c67f7625b
diff --git a/build/pkgs/matplotlib/checksums.ini b/build/pkgs/matplotlib/checksums.ini
index 6be6d882f3b..317be590bcf 100644
--- a/build/pkgs/matplotlib/checksums.ini
+++ b/build/pkgs/matplotlib/checksums.ini
@@ -1,5 +1,4 @@
 tarball=matplotlib-VERSION.tar.gz
 sha1=b3391b48ab0bf91778064ce5b2226ff2a2658d7c
-md5=2c70bea4dea84c090a7ecc8e0bb0748f
-cksum=1228885956
+sha256=df8505e1c19d5c2c26aff3497a7cbd3ccfc2e97043d1e4db3e76afa399164b69
 upstream_url=https://pypi.io/packages/source/m/matplotlib/matplotlib-VERSION.tar.gz
diff --git a/build/pkgs/matplotlib_inline/checksums.ini b/build/pkgs/matplotlib_inline/checksums.ini
index 73d1d152d74..294cf1a777a 100644
--- a/build/pkgs/matplotlib_inline/checksums.ini
+++ b/build/pkgs/matplotlib_inline/checksums.ini
@@ -1,5 +1,4 @@
 tarball=matplotlib-inline-VERSION.tar.gz
 sha1=a09347e3f2eaa6f9453c773132bf4bd9d38e2163
-md5=aded9a57e2f526f76b3a4851d5528d4f
-cksum=3152771377
+sha256=f887e5f10ba98e8d2b150ddcf4702c1e5f8b3a20005eb0f74bfdbd360ee6f304
 upstream_url=https://pypi.io/packages/source/m/matplotlib_inline/matplotlib-inline-VERSION.tar.gz
diff --git a/build/pkgs/matroid_database/checksums.ini b/build/pkgs/matroid_database/checksums.ini
index 377ec62176e..39761ab122f 100644
--- a/build/pkgs/matroid_database/checksums.ini
+++ b/build/pkgs/matroid_database/checksums.ini
@@ -1,5 +1,4 @@
 tarball=matroid_database-VERSION-py3-none-any.whl
 sha1=5879d6ca685f27df69134f56c07af50f9a2e6622
-md5=e5d667282b7926a2fd268d14f9414214
-cksum=1875993705
+sha256=c82e58ee8fec8d94263b981c4397bb0df8f489cdfbd37b399ea5a01b9c12c099
 upstream_url=https://pypi.io/packages/py3/m/matroid_database/matroid_database-VERSION-py3-none-any.whl
diff --git a/build/pkgs/maxima/checksums.ini b/build/pkgs/maxima/checksums.ini
index 0f594389fe6..164be5ccf3f 100644
--- a/build/pkgs/maxima/checksums.ini
+++ b/build/pkgs/maxima/checksums.ini
@@ -1,5 +1,4 @@
 tarball=maxima-VERSION.tar.gz
 sha1=1010594e6d6082bbd8efaac1b7756ec1721a4ed5
-md5=3c01f1daa6936e11d8713fef7751d3fe
-cksum=2420393096
+sha256=7390f06b48da65c9033e8b2f629b978b90056454a54022db7de70e2225aa8b07
 upstream_url=https://sourceforge.net/projects/maxima/files/Maxima-source/VERSION-source/maxima-VERSION.tar.gz/download
diff --git a/build/pkgs/mcqd/checksums.ini b/build/pkgs/mcqd/checksums.ini
index 631b2445e05..aa8ec3fce16 100644
--- a/build/pkgs/mcqd/checksums.ini
+++ b/build/pkgs/mcqd/checksums.ini
@@ -1,4 +1,3 @@
 tarball=mcqd-VERSION.tar.bz2
 sha1=9c55da46815aa3903f0be2d1ffbdff9c17d4aa31
-md5=831538634b7b7efe15b5e5ad3d9c59c2
-cksum=2853560422
+sha256=54d378f51833f046bbceba2186d52c08026a295d0dfb74d2319e0ec7e3618f58
diff --git a/build/pkgs/meataxe/checksums.ini b/build/pkgs/meataxe/checksums.ini
index ada4cb16f11..66d345805f4 100644
--- a/build/pkgs/meataxe/checksums.ini
+++ b/build/pkgs/meataxe/checksums.ini
@@ -1,5 +1,4 @@
 tarball=shared_meataxe-VERSION.tar.bz2
 sha1=6764f72fab8b4472660cff6605087356ab91d3b7
-md5=c9af9efa686e120612455778d64a71ca
-cksum=1648865875
+sha256=b8c5ff558712b266eef76a4ebc7a06e98cdef04cc46c542a1a725e318365969d
 upstream_url=https://github.com/simon-king-jena/SharedMeatAxe/releases/download/vVERSION/shared_meataxe-VERSION.tar.bz2
diff --git a/build/pkgs/memory_allocator/checksums.ini b/build/pkgs/memory_allocator/checksums.ini
index 76e62a79758..9aaa169c6dd 100644
--- a/build/pkgs/memory_allocator/checksums.ini
+++ b/build/pkgs/memory_allocator/checksums.ini
@@ -1,5 +1,4 @@
 tarball=memory_allocator-VERSION.tar.gz
 sha1=21661580dd3f41aac0f2090033d8804e6ff495d9
-md5=2a5e087c686b04996ccb88ce56cad9f0
-cksum=3481909016
+sha256=d609216b03031967e2b45a804b12ff9029578f4ec019fde42cf6aed6ca09efe4
 upstream_url=https://pypi.io/packages/source/m/memory_allocator/memory_allocator-VERSION.tar.gz
diff --git a/build/pkgs/meson/checksums.ini b/build/pkgs/meson/checksums.ini
index 0d4a8f89a48..00cf028db1e 100644
--- a/build/pkgs/meson/checksums.ini
+++ b/build/pkgs/meson/checksums.ini
@@ -1,5 +1,4 @@
 tarball=meson-VERSION-py3-none-any.whl
 sha1=baf5b9bc9ca97f18c7dc87cfaf0e1dc4d617a4cf
-md5=d418e644c04e55872ce3d7b6de007dbe
-cksum=559088366
+sha256=d5223ecca9564d735d36daaba2571abc6c032c8c3a7ffa0674e803ef0c7e0219
 upstream_url=https://pypi.io/packages/py3/m/meson/meson-VERSION-py3-none-any.whl
diff --git a/build/pkgs/meson_python/checksums.ini b/build/pkgs/meson_python/checksums.ini
index 1561ae04424..7aa199d18fb 100644
--- a/build/pkgs/meson_python/checksums.ini
+++ b/build/pkgs/meson_python/checksums.ini
@@ -1,5 +1,4 @@
 tarball=meson_python-VERSION.tar.gz
 sha1=71bf382c2f2e76aada2f511a84bd59a99a6b1238
-md5=e91eb9946d7bb8be06e434c5a2dadd05
-cksum=535820777
+sha256=fddb73eecd49e89c1c41c87937cd89c2d0b65a1c63ba28238681d4bd9484d26f
 upstream_url=https://pypi.io/packages/source/m/meson_python/meson_python-VERSION.tar.gz
diff --git a/build/pkgs/mistune/checksums.ini b/build/pkgs/mistune/checksums.ini
index b8b60db1d7b..93397f7ab48 100644
--- a/build/pkgs/mistune/checksums.ini
+++ b/build/pkgs/mistune/checksums.ini
@@ -1,5 +1,4 @@
 tarball=mistune-VERSION.tar.gz
 sha1=c15d02c98d04a3e615c3c1932d1b9a3b1759067a
-md5=a4437edb22cf6519a7c61730fecb1a3f
-cksum=2925260381
+sha256=9ee0a66053e2267aba772c71e06891fa8f1af6d4b01d5e84e267b4570d4d9808
 upstream_url=https://pypi.io/packages/source/m/mistune/mistune-VERSION.tar.gz
diff --git a/build/pkgs/modular_decomposition/checksums.ini b/build/pkgs/modular_decomposition/checksums.ini
index 2c97fe5389a..f113e676bb1 100644
--- a/build/pkgs/modular_decomposition/checksums.ini
+++ b/build/pkgs/modular_decomposition/checksums.ini
@@ -1,4 +1,3 @@
 tarball=modular_decomposition-VERSION.tar.bz2
 sha1=b0ce6d839d1cd2e93d806e70b13bc40bcdbaf9e9
-md5=9bc5245c5fab9df4f45c8e10c27cf3b8
-cksum=2034006428
+sha256=cf2a950c5d2b320770afb0cda195e5df46a24c4fd5056906ca9502260b33446b
diff --git a/build/pkgs/modular_resolution/checksums.ini b/build/pkgs/modular_resolution/checksums.ini
index 5d1d465cead..681841188f2 100644
--- a/build/pkgs/modular_resolution/checksums.ini
+++ b/build/pkgs/modular_resolution/checksums.ini
@@ -1,5 +1,4 @@
 tarball=modular_resolution-VERSION.tar.gz
 sha1=09ee61b1f9a33fb3e9bf0b658f81d3ede5748328
-md5=0e59e69a46014b8935c5e081d3bfc57a
-cksum=2981185519
+sha256=87b36c8c6ecc5dfe7a2594ce3ea35bb937d3b1a566860ddc138cac33dffc4490
 upstream_url=https://github.com/sagemath/modular_resolution/releases/download/VERSION/modular_resolution-VERSION.tar.gz
diff --git a/build/pkgs/mpc/checksums.ini b/build/pkgs/mpc/checksums.ini
index 8a8cefd6b0c..378d9f58370 100644
--- a/build/pkgs/mpc/checksums.ini
+++ b/build/pkgs/mpc/checksums.ini
@@ -1,5 +1,4 @@
 tarball=mpc-VERSION.tar.gz
 sha1=bac1c1fa79f5602df1e29e4684e103ad55714e02
-md5=5c9bc658c9fd0f940e8e3e0f09530c62
-cksum=3202795598
+sha256=ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8
 upstream_url=https://ftp.gnu.org/gnu/mpc/mpc-VERSION.tar.gz
diff --git a/build/pkgs/mpfi/checksums.ini b/build/pkgs/mpfi/checksums.ini
index 6d6940e0237..e776cbb2a25 100644
--- a/build/pkgs/mpfi/checksums.ini
+++ b/build/pkgs/mpfi/checksums.ini
@@ -1,4 +1,3 @@
 tarball=mpfi-VERSION.tar.bz2
 sha1=6a44e59f69fa72b4fe1c67b9c9ccf678f321ef80
-md5=1c233f3646bfb8a363aee0cc653c8baa
-cksum=4291278873
+sha256=c04f52cb306824b91b6d6eacf4f675b91fdee47c30f14d5b346dbfcd2492d274
diff --git a/build/pkgs/mpfr/checksums.ini b/build/pkgs/mpfr/checksums.ini
index 766356c1fd4..4a1b68cfe48 100644
--- a/build/pkgs/mpfr/checksums.ini
+++ b/build/pkgs/mpfr/checksums.ini
@@ -1,5 +1,4 @@
 tarball=mpfr-VERSION.tar.bz2
 sha1=f9dbe49b092e4c8e0a039e6d46c059696cc2f51c
-md5=7765afa036e4ce7fb0e02bce0fef894b
-cksum=1526077734
+sha256=b9df93635b20e4089c29623b19420c4ac848a1b29df1cfd59f26cab0d2666aa0
 upstream_url=https://www.mpfr.org/mpfr-current/mpfr-VERSION.tar.bz2
diff --git a/build/pkgs/mpfrcx/checksums.ini b/build/pkgs/mpfrcx/checksums.ini
index 7f1ac08b4e6..0cc2a0a2c05 100644
--- a/build/pkgs/mpfrcx/checksums.ini
+++ b/build/pkgs/mpfrcx/checksums.ini
@@ -1,5 +1,4 @@
 tarball=mpfrcx-VERSION.tar.gz
 sha1=460bc7cb48fae4f8070b73912080fdf0c08c93b6
-md5=45077ba92dccc25488086962d160de6c
-cksum=1142118879
+sha256=9da9b3614c0a3e00e6ed2b82fc935d1c838d97074dc59cb388f8fafbe3db8594
 upstream_url=https://www.multiprecision.org/downloads/mpfrcx-VERSION.tar.gz
diff --git a/build/pkgs/mpmath/checksums.ini b/build/pkgs/mpmath/checksums.ini
index 08d6d38673d..e6964d7c004 100644
--- a/build/pkgs/mpmath/checksums.ini
+++ b/build/pkgs/mpmath/checksums.ini
@@ -1,5 +1,4 @@
 tarball=mpmath-VERSION.tar.gz
 sha1=b7c00f35eb35978197c8f5afc11a8b4b994dd382
-md5=d5d17bbefea73eeb959967351d905306
-cksum=1852385672
+sha256=7a28eb2a9774d00c7bc92411c19a89209d5da7c4c9a9e227be8330a23a25b91f
 upstream_url=https://files.pythonhosted.org/packages/source/m/mpmath/mpmath-VERSION.tar.gz
diff --git a/build/pkgs/msolve/checksums.ini b/build/pkgs/msolve/checksums.ini
index 5b8cb2b9a6e..9ce7c826190 100644
--- a/build/pkgs/msolve/checksums.ini
+++ b/build/pkgs/msolve/checksums.ini
@@ -1,5 +1,4 @@
 tarball=msolve-VERSION.tar.gz
 sha1=01b7c4b7b6a7df5051c1357e69d9b1fd381d2907
-md5=b45cdaa5a0e588a5382660ce1c245e65
-cksum=3873680457
+sha256=1f7cd8207836f522cbbc96f3bfbe431f794a31562be2c04ae1df981557c5d145
 upstream_url=https://msolve.lip6.fr/downloads/vVERSION/msolve-VERSION.tar.gz
diff --git a/build/pkgs/nauty/checksums.ini b/build/pkgs/nauty/checksums.ini
index f699a05e9fc..9663569c7c4 100644
--- a/build/pkgs/nauty/checksums.ini
+++ b/build/pkgs/nauty/checksums.ini
@@ -1,5 +1,4 @@
 tarball=nauty${VERSION}.tar.gz
 sha1=672e9fc9dfd07201af37ee65807a9b493331ed92
-md5=16c6edc1a8747c9281041b7c7092135f
-cksum=2663136901
+sha256=159d2156810a6bb240410cd61eb641add85088d9f15c888cdaa37b8681f929ce
 upstream_url=https://pallini.di.uniroma1.it/nauty${VERSION_MAJOR}_${VERSION_MINOR}_${VERSION_MICRO}.tar.gz
diff --git a/build/pkgs/nbclient/checksums.ini b/build/pkgs/nbclient/checksums.ini
index a5f4616ad8b..6290bb30c93 100644
--- a/build/pkgs/nbclient/checksums.ini
+++ b/build/pkgs/nbclient/checksums.ini
@@ -1,5 +1,4 @@
 tarball=nbclient-VERSION-py3-none-any.whl
 sha1=fcb4ad9b3ea1bea4d305076c0a7640a483bd11f3
-md5=db61a38c8b66b5b9c7f6f0c7c7de8f26
-cksum=2793018181
+sha256=25e861299e5303a0477568557c4045eccc7a34c17fc08e7959558707b9ebe548
 upstream_url=https://pypi.io/packages/py3/n/nbclient/nbclient-VERSION-py3-none-any.whl
diff --git a/build/pkgs/nbconvert/checksums.ini b/build/pkgs/nbconvert/checksums.ini
index 20eb0e3e2df..56a861567e4 100644
--- a/build/pkgs/nbconvert/checksums.ini
+++ b/build/pkgs/nbconvert/checksums.ini
@@ -1,5 +1,4 @@
 tarball=nbconvert-VERSION-py3-none-any.whl
 sha1=5317fa68bbd7f66fc3fcc5b0e6b0d6e2df967ba0
-md5=ad534f2db53d8677b790be0e98992f8e
-cksum=2885634129
+sha256=39fe4b8bdd1b0104fdd86fc8a43a9077ba64c720bda4c6132690d917a0a154ee
 upstream_url=https://pypi.io/packages/py3/n/nbconvert/nbconvert-VERSION-py3-none-any.whl
diff --git a/build/pkgs/nbformat/checksums.ini b/build/pkgs/nbformat/checksums.ini
index 81f66428e25..e7a225cadfe 100644
--- a/build/pkgs/nbformat/checksums.ini
+++ b/build/pkgs/nbformat/checksums.ini
@@ -1,5 +1,4 @@
 tarball=nbformat-VERSION-py3-none-any.whl
 sha1=e38af74817e9d81101583363d9ffe349f0038eb9
-md5=0821545beba702b7001ad5bd744c89ba
-cksum=2633499795
+sha256=1c5172d786a41b82bcfd0c23f9e6b6f072e8fb49c39250219e4acfff1efe89e9
 upstream_url=https://pypi.io/packages/py3/n/nbformat/nbformat-VERSION-py3-none-any.whl
diff --git a/build/pkgs/ncurses/checksums.ini b/build/pkgs/ncurses/checksums.ini
index f67d0e23402..1e4d3ce8d6c 100644
--- a/build/pkgs/ncurses/checksums.ini
+++ b/build/pkgs/ncurses/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ncurses-VERSION.tar.gz
 sha1=38fb1462d13b04bb900adf07918725c4b7ed0682
-md5=a2736befde5fee7d2b7eb45eb281cdbe
-cksum=981463359
+sha256=97fc51ac2b085d4cde31ef4d2c3122c21abc217e9090a43a30fc5ec21684e059
 upstream_url=https://ftp.gnu.org/pub/gnu/ncurses/ncurses-VERSION.tar.gz
diff --git a/build/pkgs/nest_asyncio/checksums.ini b/build/pkgs/nest_asyncio/checksums.ini
index 9752b8da3bb..2e37d5585ca 100644
--- a/build/pkgs/nest_asyncio/checksums.ini
+++ b/build/pkgs/nest_asyncio/checksums.ini
@@ -1,5 +1,4 @@
 tarball=nest_asyncio-VERSION.tar.gz
 sha1=e7d8036f6558011c5ae0c649e0af21eb530044d3
-md5=9f0fe9ca229b1eef6e1ffba266413616
-cksum=3560927178
+sha256=25aa2ca0d2a5b5531956b9e273b45cf664cae2b145101d73b86b199978d48fdb
 upstream_url=https://pypi.io/packages/source/n/nest_asyncio/nest_asyncio-VERSION.tar.gz
diff --git a/build/pkgs/networkx/checksums.ini b/build/pkgs/networkx/checksums.ini
index 6daf026581b..7e02c083c6d 100644
--- a/build/pkgs/networkx/checksums.ini
+++ b/build/pkgs/networkx/checksums.ini
@@ -1,5 +1,4 @@
 tarball=networkx-VERSION.tar.gz
 sha1=b12cf95ed8bc3fe568e3c8e023473a3767c43f8d
-md5=e81583dcb3d929b60660721912f3faed
-cksum=2601544693
+sha256=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 upstream_url=https://pypi.io/packages/source/n/networkx/networkx-VERSION.tar.gz
diff --git a/build/pkgs/ninja_build/checksums.ini b/build/pkgs/ninja_build/checksums.ini
index 43ddbfd6334..d640d72d1fc 100644
--- a/build/pkgs/ninja_build/checksums.ini
+++ b/build/pkgs/ninja_build/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ninja_build-VERSION.tar.gz
 sha1=938723cdfc7a6f7c8f84c83b9a2cecdf1e5e1ad3
-md5=32151c08211d7ca3c1d832064f6939b0
-cksum=4040304461
+sha256=31747ae633213f1eda3842686f83c2aa1412e0f5691d1c14dbbcc67fe7400cea
 upstream_url=https://github.com/ninja-build/ninja/archive/refs/tags/vVERSION.tar.gz
diff --git a/build/pkgs/normaliz/checksums.ini b/build/pkgs/normaliz/checksums.ini
index fd5561cad24..acb6e5cde7f 100644
--- a/build/pkgs/normaliz/checksums.ini
+++ b/build/pkgs/normaliz/checksums.ini
@@ -1,5 +1,4 @@
 tarball=normaliz-VERSION.tar.gz
 sha1=d3c4e554c6a5ccf4fd04147e7744a63e3def1766
-md5=1c7a7833ad180ef4e0e4f124ed398973
-cksum=3124231015
+sha256=365e1d1e2a338dc4df1947a440e606bb66dd261307e617905e8eca64eaafcf6e
 upstream_url=https://github.com/Normaliz/Normaliz/releases/download/vVERSION/normaliz-VERSION.tar.gz
diff --git a/build/pkgs/notebook/checksums.ini b/build/pkgs/notebook/checksums.ini
index 1fe102fa1f0..2c1fd65675e 100644
--- a/build/pkgs/notebook/checksums.ini
+++ b/build/pkgs/notebook/checksums.ini
@@ -1,5 +1,4 @@
 tarball=notebook-VERSION-py3-none-any.whl
 sha1=90ec65091058ac541a55cc2417de83c1bcb24985
-md5=bf0fe0b56048113cd8a9e2df7add9fe9
-cksum=1004716816
+sha256=197d8e0595acabf4005851c8716e952a81b405f7aefb648067a761fbde267ce7
 upstream_url=https://pypi.io/packages/py3/n/notebook/notebook-VERSION-py3-none-any.whl
diff --git a/build/pkgs/notebook_shim/checksums.ini b/build/pkgs/notebook_shim/checksums.ini
index c646e5c3ae9..001afb43e00 100644
--- a/build/pkgs/notebook_shim/checksums.ini
+++ b/build/pkgs/notebook_shim/checksums.ini
@@ -1,5 +1,4 @@
 tarball=notebook_shim-VERSION-py3-none-any.whl
 sha1=9bb3dce360ce69aec99f873d8e80c1e9fdf92fde
-md5=f2207bef3d00f9b2dc14b0eeec63460d
-cksum=2703250856
+sha256=a83496a43341c1674b093bfcebf0fe8e74cbe7eda5fd2bbc56f8e39e1486c0c7
 upstream_url=https://pypi.io/packages/py3/n/notebook_shim/notebook_shim-VERSION-py3-none-any.whl
diff --git a/build/pkgs/notedown/checksums.ini b/build/pkgs/notedown/checksums.ini
index 7ea822115b8..b8d26fb8b32 100644
--- a/build/pkgs/notedown/checksums.ini
+++ b/build/pkgs/notedown/checksums.ini
@@ -1,4 +1,3 @@
 tarball=notedown-VERSION.tar.gz
 sha1=9af1839933b4978fba9d2290c2fe39a5de2d02fe
-md5=00d72f37e8a64d7f4c66ea8e0d214236
-cksum=2709668480
+sha256=36e033ebbbe5aca0fab031ffaf3611d5bc5c50237df68ff81bb95f8be353a1ee
diff --git a/build/pkgs/ntl/checksums.ini b/build/pkgs/ntl/checksums.ini
index 57769694456..f3b58e77570 100644
--- a/build/pkgs/ntl/checksums.ini
+++ b/build/pkgs/ntl/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ntl-VERSION.tar.gz
 sha1=a55050ca07fb42c6f9e9a479b6f80be6f1f77886
-md5=abd887865df30c02609210a86cb953b1
-cksum=322384454
+sha256=210d06c31306cbc6eaf6814453c56c776d9d8e8df36d74eb306f6a523d1c6a8a
 upstream_url=https://src.fedoraproject.org/repo/pkgs/ntl/ntl-11.5.1.tar.gz/sha512/cf1f642b8a0f9cdc6dda888e07183817dc67ff494e56a852053aeb15b3d2a0e61fbc05824779c5d1f20b8115fba6f97266acf7e0b0b527c25df5989c86d5928f/ntl-11.5.1.tar.gz
diff --git a/build/pkgs/numpy/checksums.ini b/build/pkgs/numpy/checksums.ini
index f53c6020879..fde72f78b6d 100644
--- a/build/pkgs/numpy/checksums.ini
+++ b/build/pkgs/numpy/checksums.ini
@@ -1,5 +1,4 @@
 tarball=numpy-VERSION.tar.gz
 sha1=915414f1efabd7c183583154cf1a709bd2745828
-md5=1c915dc6c36dd4c674d9379e9470ff8b
-cksum=161965903
+sha256=697df43e2b6310ecc9d95f05d5ef20eacc09c7c4ecc9da3f235d39e71b7da1e4
 upstream_url=https://pypi.io/packages/source/n/numpy/numpy-VERSION.tar.gz
diff --git a/build/pkgs/onetbb/checksums.ini b/build/pkgs/onetbb/checksums.ini
index 42e837760b6..6573c2f7b99 100644
--- a/build/pkgs/onetbb/checksums.ini
+++ b/build/pkgs/onetbb/checksums.ini
@@ -1,5 +1,4 @@
 tarball=onetbb-VERSION.tar.gz
 sha1=740e86b703f42446ddde392b73a9db3dc0f5f4cd
-md5=b301151120b08a17e98dcdda6e4f6011
-cksum=3287903962
+sha256=782ce0cab62df9ea125cdea253a50534862b563f1d85d4cda7ad4e77550ac363
 upstream_url=https://github.com/oneapi-src/oneTBB/archive/refs/tags/vVERSION.tar.gz
diff --git a/build/pkgs/openblas/checksums.ini b/build/pkgs/openblas/checksums.ini
index 5527989eebf..e05d9117e1f 100644
--- a/build/pkgs/openblas/checksums.ini
+++ b/build/pkgs/openblas/checksums.ini
@@ -1,5 +1,4 @@
 tarball=openblas-VERSION.tar.gz
 sha1=af6dce0e486e684be842053fcbd98eaf97e39749
-md5=bd496a1c81769ed19a161c1f8f904ccd
-cksum=1399957963
+sha256=4e6e4f5cb14c209262e33e6816d70221a2fe49eb69eaf0a06f065598ac602c68
 upstream_url=https://github.com/xianyi/OpenBLAS/archive/vVERSION.tar.gz
diff --git a/build/pkgs/openssl/checksums.ini b/build/pkgs/openssl/checksums.ini
index 9a4767ed76c..6e2b7e18955 100644
--- a/build/pkgs/openssl/checksums.ini
+++ b/build/pkgs/openssl/checksums.ini
@@ -1,5 +1,4 @@
 tarball=openssl-VERSION.tar.gz
 sha1=b48e20c07facfdf6da9ad43a6c5126d51897699b
-md5=e6a199cdf867873eef2c6491b674edbc
-cksum=391245670
+sha256=f93c9e8edde5e9166119de31755fc87b4aa34863662f67ddfcba14d0b6b69b61
 upstream_url=https://www.openssl.org/source/openssl-VERSION.tar.gz
diff --git a/build/pkgs/osqp_python/checksums.ini b/build/pkgs/osqp_python/checksums.ini
index f4edea03b65..d8e1ae4b81b 100644
--- a/build/pkgs/osqp_python/checksums.ini
+++ b/build/pkgs/osqp_python/checksums.ini
@@ -1,5 +1,4 @@
 tarball=osqp-VERSION.tar.gz
 sha1=3358e48aa6d81496665a8b0ee157465ce6cd329a
-md5=22ee4f843ca15a98437f053e47d15e3d
-cksum=2552259420
+sha256=03e460e683ec2ce0f839353ddfa3c4c8ffa509ab8cf6a2b2afbb586fa453e180
 upstream_url=https://pypi.io/packages/source/o/osqp/osqp-VERSION.tar.gz
diff --git a/build/pkgs/overrides/checksums.ini b/build/pkgs/overrides/checksums.ini
index cd313073a39..2812a196d90 100644
--- a/build/pkgs/overrides/checksums.ini
+++ b/build/pkgs/overrides/checksums.ini
@@ -1,5 +1,4 @@
 tarball=overrides-VERSION-py3-none-any.whl
 sha1=740e9e607a9e4f78dea7a1b82bcb27f285bc5f48
-md5=ed4ab0bd43112d05105576f0a50f5aa7
-cksum=3865068538
+sha256=3ad24583f86d6d7a49049695efe9933e67ba62f0c7625d53c59fa832ce4b8b7d
 upstream_url=https://pypi.io/packages/py3/o/overrides/overrides-VERSION-py3-none-any.whl
diff --git a/build/pkgs/p_group_cohomology/checksums.ini b/build/pkgs/p_group_cohomology/checksums.ini
index 2f5d6e8f3b5..d375c41b162 100644
--- a/build/pkgs/p_group_cohomology/checksums.ini
+++ b/build/pkgs/p_group_cohomology/checksums.ini
@@ -1,5 +1,4 @@
 tarball=p_group_cohomology-VERSION.tar.xz
 sha1=d1d9a54f212a6de7d6a7e3afff80ffc3475264ad
-md5=9a57cd7dd045dfd5e014473d543060c2
-cksum=2489285741
+sha256=c958ffe8d56a5349372b2842da0c54c788cb0b1bc81bcebf8fb1d155320ae018
 upstream_url=https://github.com/sagemath/p_group_cohomology/releases/download/vVERSION/p_group_cohomology-VERSION.tar.xz
diff --git a/build/pkgs/packaging/checksums.ini b/build/pkgs/packaging/checksums.ini
index 69a230aa11c..4b1b2974bde 100644
--- a/build/pkgs/packaging/checksums.ini
+++ b/build/pkgs/packaging/checksums.ini
@@ -1,5 +1,4 @@
 tarball=packaging-VERSION-py3-none-any.whl
 sha1=21573cef174a05ac2794b34f3841d6f9ea9fa507
-md5=8b7ed65f4b1a2175ccab25317f2efccc
-cksum=4283692602
+sha256=2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5
 upstream_url=https://pypi.io/packages/py3/p/packaging/packaging-VERSION-py3-none-any.whl
diff --git a/build/pkgs/palettable/checksums.ini b/build/pkgs/palettable/checksums.ini
index 9370cd53f51..1ec683df7d8 100644
--- a/build/pkgs/palettable/checksums.ini
+++ b/build/pkgs/palettable/checksums.ini
@@ -1,5 +1,4 @@
 tarball=palettable-VERSION.tar.gz
 sha1=4bdbbeae7f20bc71ce8246cb5269da2c3046ad62
-md5=a7601ef44fafa2b8914fa1f9626d860e
-cksum=3558581833
+sha256=72feca71cf7d79830cd6d9181b02edf227b867d503bec953cf9fa91bf44896bd
 upstream_url=https://pypi.io/packages/source/p/palettable/palettable-VERSION.tar.gz
diff --git a/build/pkgs/palp/checksums.ini b/build/pkgs/palp/checksums.ini
index 5de0d462b06..8e579188a92 100644
--- a/build/pkgs/palp/checksums.ini
+++ b/build/pkgs/palp/checksums.ini
@@ -1,5 +1,4 @@
 tarball=palp-VERSION.tar.gz
 sha1=99b0d8f7c998549f9f1be6302950659ff01bac77
-md5=b9508b9e08954215c88320d4a5940d91
-cksum=2027098672
+sha256=0540e827b1b481a55285146377b3910991cd6bc8da67f351c15226eec6a95702
 upstream_url=http://hep.itp.tuwien.ac.at/~kreuzer/CY/palp/palp-VERSION.tar.gz
diff --git a/build/pkgs/pandoc_attributes/checksums.ini b/build/pkgs/pandoc_attributes/checksums.ini
index 0757440458b..44da773ed63 100644
--- a/build/pkgs/pandoc_attributes/checksums.ini
+++ b/build/pkgs/pandoc_attributes/checksums.ini
@@ -1,4 +1,3 @@
 tarball=pandoc_attributes-VERSION.zip
 sha1=e06bdb16ece5ea6aa64d93ef1ea6c836fe971c5d
-md5=dd541a17acd84f398e29dc57d1add4ae
-cksum=723213323
+sha256=b6fc22f658c7d65a551ef7700e8e08e445bdadf626c5e5c617187f586882af00
diff --git a/build/pkgs/pandocfilters/checksums.ini b/build/pkgs/pandocfilters/checksums.ini
index 507472f9621..d85750a17f7 100644
--- a/build/pkgs/pandocfilters/checksums.ini
+++ b/build/pkgs/pandocfilters/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pandocfilters-VERSION.tar.gz
 sha1=bdee4f81063c02168b421640f3e18917011153df
-md5=d625fec43c27f091e465ff28df763a66
-cksum=1628002258
+sha256=0b679503337d233b4339a817bfc8c50064e2eff681314376a47cb582305a7a38
 upstream_url=https://pypi.io/packages/source/p/pandocfilters/pandocfilters-VERSION.tar.gz
diff --git a/build/pkgs/papilo/checksums.ini b/build/pkgs/papilo/checksums.ini
index 8bebc605f2c..831334dbdb9 100644
--- a/build/pkgs/papilo/checksums.ini
+++ b/build/pkgs/papilo/checksums.ini
@@ -1,5 +1,4 @@
 tarball=papilo-VERSION.tar.gz
 sha1=069f64ff25cfb08c9b2a416d1d215bd5b907c877
-md5=d58b7c991ac1c4a863de92a404409ca8
-cksum=1552180280
+sha256=4ed759e55fe1c74be779137e4e3cdae67e1b64bd62ca31793ca3b321509c27a8
 upstream_url=https://github.com/scipopt/papilo/archive/refs/tags/vVERSION.tar.gz
diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
index b6fc05baa1a..12c05141bf1 100644
--- a/build/pkgs/pari/checksums.ini
+++ b/build/pkgs/pari/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pari-VERSION.tar.gz
 sha1=ae962671b5bf86849d2021113dfb5b2f59331a10
-md5=4ab5c81d93f4bccb94e483b8b48fc336
-cksum=598072677
+sha256=c3545bfee0c6dfb40b77fb4bbabaf999d82e60069b9f6d28bcb6cf004c8c5c0f
 upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
diff --git a/build/pkgs/pari_elldata/checksums.ini b/build/pkgs/pari_elldata/checksums.ini
index d3858e5dde1..165db556b19 100644
--- a/build/pkgs/pari_elldata/checksums.ini
+++ b/build/pkgs/pari_elldata/checksums.ini
@@ -1,4 +1,3 @@
 tarball=elldata.tgz
 sha1=85f51ef85390f0f737fba10567d7d47f99249780
-md5=0ae49b7aa6a012ccd2804bfb831d3686
-cksum=1365963558
+sha256=6c909f09bb19c8a8125145b1aac3758915daa7fd03530bc909dcb460d4eecb38
diff --git a/build/pkgs/pari_galdata/checksums.ini b/build/pkgs/pari_galdata/checksums.ini
index 82fe02e0371..d35a0e09eec 100644
--- a/build/pkgs/pari_galdata/checksums.ini
+++ b/build/pkgs/pari_galdata/checksums.ini
@@ -1,4 +1,3 @@
 tarball=pari_galdata-VERSION.tar.bz2
 sha1=4ae710687cb711c49645314c28d53ab3b3a38706
-md5=b661c455bb1b2028b3b957d3bc8595de
-cksum=3937576682
+sha256=3d3ce1cec77a523971f53c225b78ed8bdd23e2fbfce03742d93a65a8fe4021cf
diff --git a/build/pkgs/pari_galpol/checksums.ini b/build/pkgs/pari_galpol/checksums.ini
index 530a5a72f09..b6acb470f5d 100644
--- a/build/pkgs/pari_galpol/checksums.ini
+++ b/build/pkgs/pari_galpol/checksums.ini
@@ -1,4 +1,3 @@
 tarball=galpol.tgz
 sha1=b072d752207bf598c86c896dc2ce35314fd9aff4
-md5=6ebd6057f1b252f7f9b77525c27f447d
-cksum=547352040
+sha256=562af28316ee335ee38c1172c2d5ecccb79f55c368fb9f2c6f40fc0f416bb01b
diff --git a/build/pkgs/pari_jupyter/checksums.ini b/build/pkgs/pari_jupyter/checksums.ini
index 43f7d3085ca..bdd7d5278be 100644
--- a/build/pkgs/pari_jupyter/checksums.ini
+++ b/build/pkgs/pari_jupyter/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pari-jupyter-VERSION.tar.gz
 sha1=b410ee0352cd58f5f140246540b71b5ff83ddf73
-md5=5a8353259bbaec1f0314d1b1b726c9cb
-cksum=1481362803
+sha256=7cd9291d05b92b8303c6ae8cf25622e5ecbab1ac2bcf13911f900ea987471b9d
 upstream_url=https://pypi.io/packages/source/p/pari_jupyter/pari-jupyter-VERSION.tar.gz
diff --git a/build/pkgs/pari_nftables/checksums.ini b/build/pkgs/pari_nftables/checksums.ini
index 3463064475d..c613d0a86e6 100644
--- a/build/pkgs/pari_nftables/checksums.ini
+++ b/build/pkgs/pari_nftables/checksums.ini
@@ -1,4 +1,3 @@
 tarball=nftables.tgz
 sha1=90df66222346b0dbca68925671a374f5e286daeb
-md5=82788524f36bbbba886785c940c859db
-cksum=1478870095
+sha256=8dd3393ce6b3cfcf599f094f7b22bdffe17c3ba25deb912513d54676bd7cfe92
diff --git a/build/pkgs/pari_seadata/checksums.ini b/build/pkgs/pari_seadata/checksums.ini
index 097c3a558d7..05eb1542ba1 100644
--- a/build/pkgs/pari_seadata/checksums.ini
+++ b/build/pkgs/pari_seadata/checksums.ini
@@ -1,4 +1,3 @@
 tarball=seadata.tgz
 sha1=fa3deb36df0ce71a466eb0ff0d4a18d48d44e8b9
-md5=6e9c119ccb3c65916a48e1a8cd899558
-cksum=3015139491
+sha256=c9282a525ea3f92c1f9c6c69e37ac5a87b48fb9ccd943cfd7c881a3851195833
diff --git a/build/pkgs/pari_seadata_small/checksums.ini b/build/pkgs/pari_seadata_small/checksums.ini
index efca3bbdc15..5e8d8eb033a 100644
--- a/build/pkgs/pari_seadata_small/checksums.ini
+++ b/build/pkgs/pari_seadata_small/checksums.ini
@@ -1,4 +1,3 @@
 tarball=pari_seadata_small-VERSION.tar.bz2
 sha1=9df70728bfae81fad4ff66a3c7f57d99bbe70732
-md5=5a9a6200e4536d2c6b4020c4313721f5
-cksum=3561726107
+sha256=1992496212a965958ac36bb14c8e59d87086261c18d70aa4bc45ae4da464dcda
diff --git a/build/pkgs/parso/checksums.ini b/build/pkgs/parso/checksums.ini
index fdaddf5e808..caae59d79e8 100644
--- a/build/pkgs/parso/checksums.ini
+++ b/build/pkgs/parso/checksums.ini
@@ -1,5 +1,4 @@
 tarball=parso-VERSION.tar.gz
 sha1=1a34ea6e597a6498ef5c154195f9ffe8dda3d254
-md5=7ee251113f31f8d851c4a5d9e98977cb
-cksum=566121311
+sha256=8c07be290bb59f03588915921e29e8a50002acaf2cdc5fa0e0114f91709fafa0
 upstream_url=https://pypi.io/packages/source/p/parso/parso-VERSION.tar.gz
diff --git a/build/pkgs/patch/checksums.ini b/build/pkgs/patch/checksums.ini
index fa51ec84b12..9943634658e 100644
--- a/build/pkgs/patch/checksums.ini
+++ b/build/pkgs/patch/checksums.ini
@@ -1,4 +1,3 @@
 tarball=patch-VERSION.tar.gz
 sha1=04d23f6e48e95efb07d12ccf44d1f35fb210f457
-md5=ed4d5674ef4543b4eb463db168886dc7
-cksum=2777655587
+sha256=7436f5a19f93c3ca83153ce9c5cbe4847e97c5d956e57a220121e741f6e7968f
diff --git a/build/pkgs/patchelf/checksums.ini b/build/pkgs/patchelf/checksums.ini
index bd52a82dbc5..b13ebbc4d64 100644
--- a/build/pkgs/patchelf/checksums.ini
+++ b/build/pkgs/patchelf/checksums.ini
@@ -1,5 +1,4 @@
 tarball=patchelf-VERSION.tar.bz2
 sha1=5d9c1690c0fbe70c312f43d597e04b6c1eeffc60
-md5=04d243d3626a33201b0d6eef0e2c4317
-cksum=92812155
+sha256=39e8aeccd7495d54df094d2b4a7c08010ff7777036faaf24f28e07777d1598e2
 upstream_url=https://github.com/NixOS/patchelf/releases/download/VERSION/patchelf-VERSION.tar.bz2
diff --git a/build/pkgs/pathspec/checksums.ini b/build/pkgs/pathspec/checksums.ini
index a562884cca1..62d6d08775e 100644
--- a/build/pkgs/pathspec/checksums.ini
+++ b/build/pkgs/pathspec/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pathspec-VERSION-py3-none-any.whl
 sha1=e31b7b2b1a59ab192eb2e92ac283211a11039769
-md5=53caa061bbda861c5b4766f41b084ec8
-cksum=1745881358
+sha256=a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08
 upstream_url=https://pypi.io/packages/py3/p/pathspec/pathspec-VERSION-py3-none-any.whl
diff --git a/build/pkgs/perl_term_readline_gnu/checksums.ini b/build/pkgs/perl_term_readline_gnu/checksums.ini
index cc68c96c1ed..4cfe731ee63 100644
--- a/build/pkgs/perl_term_readline_gnu/checksums.ini
+++ b/build/pkgs/perl_term_readline_gnu/checksums.ini
@@ -1,4 +1,3 @@
 tarball=Term-ReadLine-Gnu-VERSION.tar.gz
 sha1=1f57fe986d56c6afa5eb868ca36dc5f0f8dcc3b6
-md5=514619d68bda1618da61b19d04b5cefe
-cksum=677275902
+sha256=575d32d4ab67cd656f314e8d0ee3d45d2491078f3b2421e520c4273e92eb9125
diff --git a/build/pkgs/pexpect/checksums.ini b/build/pkgs/pexpect/checksums.ini
index e4c530a042d..413053e79a1 100644
--- a/build/pkgs/pexpect/checksums.ini
+++ b/build/pkgs/pexpect/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pexpect-VERSION.tar.gz
 sha1=5bff9230c419eecbf701059f104e74a3f3a1b208
-md5=f48d48325ee7f1221add0396ea9e2f14
-cksum=2367435032
+sha256=ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f
 upstream_url=https://pypi.io/packages/source/p/pexpect/pexpect-VERSION.tar.gz
diff --git a/build/pkgs/pickleshare/checksums.ini b/build/pkgs/pickleshare/checksums.ini
index 13537caad36..c29bd06194f 100644
--- a/build/pkgs/pickleshare/checksums.ini
+++ b/build/pkgs/pickleshare/checksums.ini
@@ -1,4 +1,3 @@
 tarball=pickleshare-VERSION.tar.gz
 sha1=c583011994ee0733ea4a6330af81c175180dcc3d
-md5=44ab782615894a812ab96669a122a634
-cksum=1895214791
+sha256=87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca
diff --git a/build/pkgs/pillow/checksums.ini b/build/pkgs/pillow/checksums.ini
index 48c6c3f46ae..7e64940e75b 100644
--- a/build/pkgs/pillow/checksums.ini
+++ b/build/pkgs/pillow/checksums.ini
@@ -1,5 +1,4 @@
 tarball=Pillow-VERSION.tar.gz
 sha1=be2dc6aeee145894f3ccbc2358a37f7849e710aa
-md5=a55618c5d2fd64048dd3ea41bc39f7cd
-cksum=3616378816
+sha256=e6bf8de6c36ed96c86ea3b6e1d5273c53f46ef518a062464cd7ef5dd2cf92e38
 upstream_url=https://pypi.io/packages/source/p/pillow/Pillow-VERSION.tar.gz
diff --git a/build/pkgs/pint/checksums.ini b/build/pkgs/pint/checksums.ini
index b852d25efe6..7e883f32e55 100644
--- a/build/pkgs/pint/checksums.ini
+++ b/build/pkgs/pint/checksums.ini
@@ -1,5 +1,4 @@
 tarball=Pint-VERSION.tar.gz
 sha1=c14ac08ca2d5a68d79ea7cd2252dc7e2a572c56a
-md5=522a8e633e487e92ba54ccbec395947a
-cksum=2139030399
+sha256=387cf04078dc7dfe4a708033baad54ab61d82ab06c4ee3d4922b1e45d5626067
 upstream_url=https://pypi.io/packages/source/p/pint/Pint-VERSION.tar.gz
diff --git a/build/pkgs/pip/checksums.ini b/build/pkgs/pip/checksums.ini
index ebfbc1a26a1..62ecf000278 100644
--- a/build/pkgs/pip/checksums.ini
+++ b/build/pkgs/pip/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pip-VERSION-py3-none-any.whl
 sha1=e44313ae1e6af3c2bd3b60ab2fa8c34308d00555
-md5=74e3c5e4082113b1239ca0e9abfd1e82
-cksum=88131429
+sha256=ba0d021a166865d2265246961bec0152ff124de910c5cc39f1156ce3fa7c69dc
 upstream_url=https://pypi.io/packages/py3/p/pip/pip-VERSION-py3-none-any.whl
diff --git a/build/pkgs/pkgconf/checksums.ini b/build/pkgs/pkgconf/checksums.ini
index a65038ec333..ec43fd8c4c3 100644
--- a/build/pkgs/pkgconf/checksums.ini
+++ b/build/pkgs/pkgconf/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pkgconf-VERSION.tar.xz
 sha1=2b76eb2d88b2c4aecba937b337d218a13b67f14b
-md5=823212dc241793df8ff1d097769a3473
-cksum=896868382
+sha256=ef9c7e61822b7cb8356e6e9e1dca58d9556f3200d78acab35e4347e9d4c2bbaf
 upstream_url=https://distfiles.dereferenced.org/pkgconf/pkgconf-VERSION.tar.xz
diff --git a/build/pkgs/pkgconfig/checksums.ini b/build/pkgs/pkgconfig/checksums.ini
index 80d5aac1b27..4ecbe8c0096 100644
--- a/build/pkgs/pkgconfig/checksums.ini
+++ b/build/pkgs/pkgconfig/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pkgconfig-VERSION-py3-none-any.whl
 sha1=bca14b2806a8e8afb0bd04f8e3675550b286dda8
-md5=80f1e06563f3af0f090694db58736455
-cksum=15738577
+sha256=d20023bbeb42ee6d428a0fac6e0904631f545985a10cdd71a20aa58bc47a4209
 upstream_url=https://pypi.io/packages/py3/p/pkgconfig/pkgconfig-VERSION-py3-none-any.whl
diff --git a/build/pkgs/planarity/checksums.ini b/build/pkgs/planarity/checksums.ini
index 309daa93278..06b8d7622c6 100644
--- a/build/pkgs/planarity/checksums.ini
+++ b/build/pkgs/planarity/checksums.ini
@@ -1,5 +1,4 @@
 tarball=planarity-VERSION.tar.gz
 sha1=8407bccf33c07bf0dae22d79b5e6ac7d89c62ea3
-md5=200116e6a67544c8e94f9de7c3ba1b1a
-cksum=4207261512
+sha256=63e979d37e7160e4e72a286a8dd7ba74e4795f63742f417c8ba1cea2b2a51280
 upstream_url=http://users.ox.ac.uk/~coml0531/sage/planarity-VERSION.tar.gz
diff --git a/build/pkgs/plantri/checksums.ini b/build/pkgs/plantri/checksums.ini
index f999a981a69..1ba9d0dc2aa 100644
--- a/build/pkgs/plantri/checksums.ini
+++ b/build/pkgs/plantri/checksums.ini
@@ -1,5 +1,4 @@
 tarball=plantri${VERSION_MAJOR}${VERSION_MINOR}.tar.gz
 sha1=a04aec2fa90c43f1c9bef59d041a54d8fa5bf562
-md5=ea765b3508dd56384f94ad1f032e2dd4
-cksum=3200215885
+sha256=5036804de6e3bee7bd54b6e46009a2c1f7c89067010b5e532cda84907a3559a2
 upstream_url=https://users.cecs.anu.edu.au/~bdm/plantri/plantri${VERSION_MAJOR}${VERSION_MINOR}.tar.gz
diff --git a/build/pkgs/platformdirs/checksums.ini b/build/pkgs/platformdirs/checksums.ini
index f8770e91289..28576a25b7f 100644
--- a/build/pkgs/platformdirs/checksums.ini
+++ b/build/pkgs/platformdirs/checksums.ini
@@ -1,5 +1,4 @@
 tarball=platformdirs-VERSION-py3-none-any.whl
 sha1=487a4610a037c90b242aafbe1e3f8b6ebb3ba1c8
-md5=99200c4e22d44a64a9c3ad0c72a317af
-cksum=1011122610
+sha256=0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068
 upstream_url=https://pypi.io/packages/py3/p/platformdirs/platformdirs-VERSION-py3-none-any.whl
diff --git a/build/pkgs/pluggy/checksums.ini b/build/pkgs/pluggy/checksums.ini
index 02c89db5e83..80a46179d43 100644
--- a/build/pkgs/pluggy/checksums.ini
+++ b/build/pkgs/pluggy/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pluggy-VERSION-py3-none-any.whl
 sha1=25492905db99a151fc86368f0cca518a5ee5a832
-md5=9d0a58f023a0642eebae7c19f2729b72
-cksum=273236458
+sha256=d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7
 upstream_url=https://pypi.io/packages/py3/p/pluggy/pluggy-VERSION-py3-none-any.whl
diff --git a/build/pkgs/ply/checksums.ini b/build/pkgs/ply/checksums.ini
index bf06a90d888..f1003c4c4a0 100644
--- a/build/pkgs/ply/checksums.ini
+++ b/build/pkgs/ply/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ply-VERSION.tar.gz
 sha1=10a555a32095991fbc7f7ed10c677a14e21fad1d
-md5=6465f602e656455affcd7c5734c638f8
-cksum=375283112
+sha256=00c7c1aaa88358b9c765b6d3000c6eec0ba42abca5351b095321aef446081da3
 upstream_url=https://pypi.io/packages/source/p/ply/ply-VERSION.tar.gz
diff --git a/build/pkgs/polylib/checksums.ini b/build/pkgs/polylib/checksums.ini
index 9a8aed1a91f..1ddf004b9f8 100644
--- a/build/pkgs/polylib/checksums.ini
+++ b/build/pkgs/polylib/checksums.ini
@@ -1,4 +1,3 @@
 tarball=polylib-VERSION.tar.gz
 sha1=72b23c09a50ce9583c419e8376544630d6f99ea3
-md5=c0088786e0a5ae64b7cc47ad19ae4f83
-cksum=116350713
+sha256=84622ff9dfa5d06f0c266960ed078bd3577a30fde6d7f8bed1041b9838cb731f
diff --git a/build/pkgs/polymake/checksums.ini b/build/pkgs/polymake/checksums.ini
index 2ef0a4e00be..b76cd23ad88 100644
--- a/build/pkgs/polymake/checksums.ini
+++ b/build/pkgs/polymake/checksums.ini
@@ -1,5 +1,4 @@
 tarball=polymake-VERSION-minimal.tar.bz2
 sha1=0445f1a6d174906317a07c4bef299d0b4502c779
-md5=7a86d17822f229d6088dd7d65c8c1cad
-cksum=2732048385
+sha256=5df6f0acd700119bd0c4b5766762852ffbd857765b5dcc88802ff5d2108add23
 upstream_url=https://polymake.org/lib/exe/fetch.php/download/polymake-VERSION-minimal.tar.bz2
diff --git a/build/pkgs/polytopes_db/checksums.ini b/build/pkgs/polytopes_db/checksums.ini
index ceb452697f3..afbc690ce11 100644
--- a/build/pkgs/polytopes_db/checksums.ini
+++ b/build/pkgs/polytopes_db/checksums.ini
@@ -1,4 +1,3 @@
 tarball=polytopes_db-VERSION.tar.bz2
 sha1=6a9d12740588ea5c0efc0e82776d8386e7887b47
-md5=64c5fba9568891a2dbde5d433ce668e2
-cksum=3276110922
+sha256=cb788bdfca6e00864ec0bfa67932a68ae68bfeb9c527a91be90ad218026a0ce0
diff --git a/build/pkgs/polytopes_db_4d/checksums.ini b/build/pkgs/polytopes_db_4d/checksums.ini
index d87e456c4a8..bdcbebe37f9 100644
--- a/build/pkgs/polytopes_db_4d/checksums.ini
+++ b/build/pkgs/polytopes_db_4d/checksums.ini
@@ -1,5 +1,4 @@
 tarball=polytopes_db_4d-VERSION.spkg
 sha1=c9779821e365df2d7f9bc684f9e2ec0e95fb8650
-md5=fe775a26fd7b2afc187e9bfabfb1b86a
-cksum=3415837678
+sha256=44fb1552261acca8b9e2e3253098ea3f364663bc48343fdbd121951bf02b8e55
 upstream_url=http://ftp.sparcs.org/sage/spkg/huge/polytopes_db_4d-VERSION.spkg
diff --git a/build/pkgs/ppl/checksums.ini b/build/pkgs/ppl/checksums.ini
index ba15444f72f..9e2bc4cc0e1 100644
--- a/build/pkgs/ppl/checksums.ini
+++ b/build/pkgs/ppl/checksums.ini
@@ -1,4 +1,3 @@
 tarball=ppl-VERSION.tar.bz2
 sha1=727ac98a9365a617dc26bfd7961417d9d3ff4e74
-md5=50a757d37cced76e51b97709a4cf455a
-cksum=158857820
+sha256=2d470b0c262904f190a19eac57fb5c2387b1bfc3510de25a08f3c958df62fdf1
diff --git a/build/pkgs/pplpy/checksums.ini b/build/pkgs/pplpy/checksums.ini
index 73f16fc3f00..76268f169e2 100644
--- a/build/pkgs/pplpy/checksums.ini
+++ b/build/pkgs/pplpy/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pplpy-VERSION.tar.gz
 sha1=dc9e8a7a867ee1c066bdbecf22b6a59dc2052711
-md5=220fc7ab95d7bd62d40acb276f9b149f
-cksum=2156962833
+sha256=db7a3b571d6ef053f75137975e947c3a1c1e45a30bab90eaf215b4e5cc15797e
 upstream_url=https://pypi.io/packages/source/p/pplpy/pplpy-VERSION.tar.gz
diff --git a/build/pkgs/primecount/checksums.ini b/build/pkgs/primecount/checksums.ini
index 11900687fca..c3f0b9ce77d 100644
--- a/build/pkgs/primecount/checksums.ini
+++ b/build/pkgs/primecount/checksums.ini
@@ -1,5 +1,4 @@
 tarball=primecount-VERSION.tar.gz
 sha1=3854ef6c7f454086f31aa80d68f628c5b685d702
-md5=a566d9b95ccc01f0c7c1329ca4c06b89
-cksum=1260437024
+sha256=e9a1fa2c41b9a7b84f2bead21b53cc9f7e2a5a0a34ddd818431a4e789aa44230
 upstream_url=https://github.com/kimwalisch/primecount/archive/refs/tags/vVERSION.tar.gz
diff --git a/build/pkgs/primecount/spkg-install.in b/build/pkgs/primecount/spkg-install.in
index 0a63840d8cb..7589fad8cb9 100644
--- a/build/pkgs/primecount/spkg-install.in
+++ b/build/pkgs/primecount/spkg-install.in
@@ -1,3 +1,7 @@
+if [ "$UNAME" = "Darwin" ]; then
+    LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib"
+    export LDFLAGS
+fi
 cd src
 
 # Issue #33054: primecount needs "-std=gnu++..."
diff --git a/build/pkgs/primecountpy/checksums.ini b/build/pkgs/primecountpy/checksums.ini
index f8f503d3ee6..57cae477764 100644
--- a/build/pkgs/primecountpy/checksums.ini
+++ b/build/pkgs/primecountpy/checksums.ini
@@ -1,5 +1,4 @@
 tarball=primecountpy-VERSION.tar.gz
 sha1=3526784adad04d67a15f05fb1367d12ec50a59dc
-md5=e25806cba603d04cc7bc1852df5d0b92
-cksum=4293153144
+sha256=78fe7cc32115f0669a45d7c90faaf39f7ce3939e39e2e7e5f14c17fe4bff0676
 upstream_url=https://pypi.io/packages/source/p/primecountpy/primecountpy-VERSION.tar.gz
diff --git a/build/pkgs/primecountpy/spkg-install.in b/build/pkgs/primecountpy/spkg-install.in
index 37ac1a53437..829ebe2fcc5 100644
--- a/build/pkgs/primecountpy/spkg-install.in
+++ b/build/pkgs/primecountpy/spkg-install.in
@@ -1,2 +1,7 @@
+if [ "$UNAME" = "Darwin" ]; then
+    LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib"
+    export LDFLAGS
+fi
+
 cd src
 sdh_pip_install .
diff --git a/build/pkgs/primesieve/checksums.ini b/build/pkgs/primesieve/checksums.ini
index 2f3dc247407..faae4fa7982 100644
--- a/build/pkgs/primesieve/checksums.ini
+++ b/build/pkgs/primesieve/checksums.ini
@@ -1,5 +1,4 @@
 tarball=primesieve-VERSION.tar.gz
 sha1=cb0a7c49b37b51980fc610d3041b9591c67a460c
-md5=73f51a77b0d43356b404999e777ad910
-cksum=1567518743
+sha256=b29a7ec855764ce7474d00be03e1d83209bd097faa3778382dfb73a06866097e
 upstream_url=https://github.com/kimwalisch/primesieve/archive/refs/tags/vVERSION.tar.gz
diff --git a/build/pkgs/prometheus_client/checksums.ini b/build/pkgs/prometheus_client/checksums.ini
index a4d2d472c6e..9f4fa1845da 100644
--- a/build/pkgs/prometheus_client/checksums.ini
+++ b/build/pkgs/prometheus_client/checksums.ini
@@ -1,5 +1,4 @@
 tarball=prometheus_client-VERSION.tar.gz
 sha1=dabd66e652ea8275b4980e337cefcea68cc0b560
-md5=295568805ef560acd16eecb18137ef30
-cksum=1955633542
+sha256=5459c427624961076277fdc6dc50540e2bacb98eebde99886e59ec55ed92093a
 upstream_url=https://pypi.io/packages/source/p/prometheus-client/prometheus_client-VERSION.tar.gz
diff --git a/build/pkgs/prompt_toolkit/checksums.ini b/build/pkgs/prompt_toolkit/checksums.ini
index 1d0b8a0a02b..3f4bd25570c 100644
--- a/build/pkgs/prompt_toolkit/checksums.ini
+++ b/build/pkgs/prompt_toolkit/checksums.ini
@@ -1,5 +1,4 @@
 tarball=prompt_toolkit-VERSION.tar.gz
 sha1=b5ada8cb45c11f9184c990bd33a98d3d690e6edc
-md5=f33c0f4ae8d11addababf6d90c98f8bc
-cksum=1262534330
+sha256=3527b7af26106cbc65a040bcc84839a3566ec1b051bb0bfe953631e704b0ff7d
 upstream_url=https://pypi.io/packages/source/p/prompt_toolkit/prompt_toolkit-VERSION.tar.gz
diff --git a/build/pkgs/psutil/checksums.ini b/build/pkgs/psutil/checksums.ini
index f9d3d687f9d..417c2210384 100644
--- a/build/pkgs/psutil/checksums.ini
+++ b/build/pkgs/psutil/checksums.ini
@@ -1,5 +1,4 @@
 tarball=psutil-VERSION.tar.gz
 sha1=24c493ef33d4df44e76a1801e480b4185bd911c5
-md5=eec35090e7474e471a12f0dd16c981f9
-cksum=3278898496
+sha256=e4b92ddcd7dd4cdd3f900180ea1e104932c7bce234fb88976e2a3b296441225a
 upstream_url=https://pypi.io/packages/source/p/psutil/psutil-VERSION.tar.gz
diff --git a/build/pkgs/ptyprocess/checksums.ini b/build/pkgs/ptyprocess/checksums.ini
index d55046be142..36a12e0f438 100644
--- a/build/pkgs/ptyprocess/checksums.ini
+++ b/build/pkgs/ptyprocess/checksums.ini
@@ -1,5 +1,4 @@
 tarball=ptyprocess-VERSION.tar.gz
 sha1=2d8830d1025c8e33149c7723c2f283122f9488c1
-md5=9da200c397cb1752209a6b718b6cfc68
-cksum=2094263560
+sha256=5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220
 upstream_url=https://pypi.io/packages/source/p/ptyprocess/ptyprocess-VERSION.tar.gz
diff --git a/build/pkgs/pure_eval/checksums.ini b/build/pkgs/pure_eval/checksums.ini
index d83180b3c78..7fb86e03cc4 100644
--- a/build/pkgs/pure_eval/checksums.ini
+++ b/build/pkgs/pure_eval/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pure_eval-VERSION.tar.gz
 sha1=45813e75b359573c2ef49430673812ea3f8f81f2
-md5=212fd27ca2c58d9effddec69748d738a
-cksum=757891676
+sha256=2b45320af6dfaa1750f543d714b6d1c520a1688dec6fd24d339063ce0aaa9ac3
 upstream_url=https://pypi.io/packages/source/p/pure_eval/pure_eval-VERSION.tar.gz
diff --git a/build/pkgs/py/checksums.ini b/build/pkgs/py/checksums.ini
index 83f808c63bc..9c10e7b6cf8 100644
--- a/build/pkgs/py/checksums.ini
+++ b/build/pkgs/py/checksums.ini
@@ -1,5 +1,4 @@
 tarball=py-VERSION.tar.gz
 sha1=bb8aa4f56e3ced1cd61906495150e7ca2dacc10b
-md5=bde7dcc1cb452a1e10206ef2f811ba88
-cksum=1774689161
+sha256=51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719
 upstream_url=https://pypi.io/packages/source/p/py/py-VERSION.tar.gz
diff --git a/build/pkgs/pybind11/checksums.ini b/build/pkgs/pybind11/checksums.ini
index c8b9c661568..c3112e54327 100644
--- a/build/pkgs/pybind11/checksums.ini
+++ b/build/pkgs/pybind11/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pybind11-VERSION.tar.gz
 sha1=3c75333a9056f0be18eb612803cd46a2bb0c87fc
-md5=67c58224e41c442e47fa84e7789c2c39
-cksum=419587142
+sha256=00cd59116a6e8155aecd9174f37ba299d1d397ed4a6b86ac1dfe01b3e40f2cc4
 upstream_url=https://pypi.io/packages/source/p/pybind11/pybind11-VERSION.tar.gz
diff --git a/build/pkgs/pycosat/checksums.ini b/build/pkgs/pycosat/checksums.ini
index 0ded8feb643..7e70a7f5476 100644
--- a/build/pkgs/pycosat/checksums.ini
+++ b/build/pkgs/pycosat/checksums.ini
@@ -1,4 +1,3 @@
 tarball=pycosat-VERSION.tar.gz
 sha1=1c2243fcc52491db8aa11558d4df626f28311757
-md5=08e378db1c15dc1668bc62897bd325a5
-cksum=2006887185
+sha256=abcaf3d6afb332b0d8363590d0aaa81f00f71142900fbae2608f7d595d5e4492
diff --git a/build/pkgs/pycparser/checksums.ini b/build/pkgs/pycparser/checksums.ini
index c4eb97e2c59..1e113dfcbf8 100644
--- a/build/pkgs/pycparser/checksums.ini
+++ b/build/pkgs/pycparser/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pycparser-VERSION.tar.gz
 sha1=359c718c6ece361047f61846b9fa4ea0239576dc
-md5=48f7d743bf018f7bb2ffc5fb976d1492
-cksum=1065143416
+sha256=e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206
 upstream_url=https://pypi.io/packages/source/p/pycparser/pycparser-VERSION.tar.gz
diff --git a/build/pkgs/pygments/checksums.ini b/build/pkgs/pygments/checksums.ini
index 45387936c10..c534a4a9a4d 100644
--- a/build/pkgs/pygments/checksums.ini
+++ b/build/pkgs/pygments/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pygments-VERSION-py3-none-any.whl
 sha1=053e17b72ffea04e200d7b34edbe0f96b4b68e4b
-md5=05bab8cd38860c62d6e146ec2949fefe
-cksum=964137483
+sha256=b27c2826c47d0f3219f29554824c30c5e8945175d888647acd804ddd04af846c
 upstream_url=https://pypi.io/packages/py3/p/pygments/pygments-VERSION-py3-none-any.whl
diff --git a/build/pkgs/pynormaliz/checksums.ini b/build/pkgs/pynormaliz/checksums.ini
index 327461a230f..25b41b1c0ab 100644
--- a/build/pkgs/pynormaliz/checksums.ini
+++ b/build/pkgs/pynormaliz/checksums.ini
@@ -1,5 +1,4 @@
 tarball=PyNormaliz-VERSION.tar.gz
 sha1=08617ca50ce0e0317a3377381bf37c1a0ab826c1
-md5=9ae78f7638741c26b588443f0d6024ce
-cksum=4090940781
+sha256=359218cf35f400c43f338a132b7887f6a2affb05057c4e7eaa315a9f2b6a8b39
 upstream_url=https://pypi.io/packages/source/p/pynormaliz/PyNormaliz-VERSION.tar.gz
diff --git a/build/pkgs/pyparsing/checksums.ini b/build/pkgs/pyparsing/checksums.ini
index a6e8820e3c3..7c946098d45 100644
--- a/build/pkgs/pyparsing/checksums.ini
+++ b/build/pkgs/pyparsing/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pyparsing-VERSION-py3-none-any.whl
 sha1=c44cd9476ad90a48af0f27d8f7966136b2a93fc6
-md5=314b4874edfbc558e02f89d371043e9f
-cksum=3947575213
+sha256=32c7c0b711493c72ff18a981d24f28aaf9c1fb7ed5e9667c9e84e3db623bdbfb
 upstream_url=https://pypi.io/packages/py3/p/pyparsing/pyparsing-VERSION-py3-none-any.whl
diff --git a/build/pkgs/pyproject_api/checksums.ini b/build/pkgs/pyproject_api/checksums.ini
index 9fc8e383a7c..cb551b5f7dd 100644
--- a/build/pkgs/pyproject_api/checksums.ini
+++ b/build/pkgs/pyproject_api/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pyproject_api-VERSION-py3-none-any.whl
 sha1=5ea24c784a68fd0ef0228c332dc078ce64387eb8
-md5=8941280ffec3eb79a8cd6e380774980f
-cksum=913049079
+sha256=4c0116d60476b0786c88692cf4e325a9814965e2469c5998b830bba16b183675
 upstream_url=https://pypi.io/packages/py3/p/pyproject_api/pyproject_api-VERSION-py3-none-any.whl
diff --git a/build/pkgs/pyproject_hooks/checksums.ini b/build/pkgs/pyproject_hooks/checksums.ini
index f35e59aa59f..4688d10283b 100644
--- a/build/pkgs/pyproject_hooks/checksums.ini
+++ b/build/pkgs/pyproject_hooks/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pyproject_hooks-VERSION-py3-none-any.whl
 sha1=6c99163c52786fb97eac8b4e38cc13fa3af141a9
-md5=68020c2619c7a744dcee12b670c9f413
-cksum=3405759428
+sha256=283c11acd6b928d2f6a7c73fa0d01cb2bdc5f07c57a2eeb6e83d5e56b97976f8
 upstream_url=https://pypi.io/packages/py3/p/pyproject_hooks/pyproject_hooks-VERSION-py3-none-any.whl
diff --git a/build/pkgs/pyproject_metadata/checksums.ini b/build/pkgs/pyproject_metadata/checksums.ini
index 6fb14a63679..446d55ef265 100644
--- a/build/pkgs/pyproject_metadata/checksums.ini
+++ b/build/pkgs/pyproject_metadata/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pyproject-metadata-VERSION.tar.gz
 sha1=41fba5c33917d77b9364fadb76e590e86789634d
-md5=ca5e9527cff96153a976e14530b53746
-cksum=2053869519
+sha256=0a94f18b108b9b21f3a26a3d541f056c34edcb17dc872a144a15618fed7aef67
 upstream_url=https://pypi.io/packages/source/p/pyproject_metadata/pyproject-metadata-VERSION.tar.gz
diff --git a/build/pkgs/pyrsistent/checksums.ini b/build/pkgs/pyrsistent/checksums.ini
index cffce58a92e..b7a30f5a171 100644
--- a/build/pkgs/pyrsistent/checksums.ini
+++ b/build/pkgs/pyrsistent/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pyrsistent-VERSION.tar.gz
 sha1=79980873658f7634ae25758b9710088b62e0612a
-md5=761266eab1f9dc9280cdb0a6d2dedb08
-cksum=2666822194
+sha256=1a2994773706bbb4995c31a97bc94f1418314923bd1048c6d964837040376440
 upstream_url=https://pypi.io/packages/source/p/pyrsistent/pyrsistent-VERSION.tar.gz
diff --git a/build/pkgs/pyscipopt/checksums.ini b/build/pkgs/pyscipopt/checksums.ini
index 1232c25dff5..a88c5cf04d8 100644
--- a/build/pkgs/pyscipopt/checksums.ini
+++ b/build/pkgs/pyscipopt/checksums.ini
@@ -1,5 +1,4 @@
 tarball=PySCIPOpt-VERSION.tar.gz
 sha1=713e32cc0ff112500c4f43487614094ece4a8bbf
-md5=ee425a362744a4475228510b48781be9
-cksum=1541742154
+sha256=f9c36c941e1373406b00c030f2511578c3fb02a95a2cf5559772deb846a0af47
 upstream_url=https://pypi.io/packages/source/p/pyscipopt/PySCIPOpt-VERSION.tar.gz
diff --git a/build/pkgs/pysingular/checksums.ini b/build/pkgs/pysingular/checksums.ini
index eedd093dcdd..9f26a37fc9b 100644
--- a/build/pkgs/pysingular/checksums.ini
+++ b/build/pkgs/pysingular/checksums.ini
@@ -1,5 +1,4 @@
 tarball=PySingular-VERSION.tar.gz
 sha1=c8d4bbe4552490aac37afe6d87a2cd3a7b445a7e
-md5=84a8639d33a5b03637a7ca3ea322b085
-cksum=822399760
+sha256=ca03d1d7538fc61f4350acff42708c6c443e0232712a2dc42ce72140831ef60c
 upstream_url=https://pypi.io/packages/source/p/pysingular/PySingular-VERSION.tar.gz
diff --git a/build/pkgs/python3/checksums.ini b/build/pkgs/python3/checksums.ini
index 936ac821ed2..f0f0ce6eb75 100644
--- a/build/pkgs/python3/checksums.ini
+++ b/build/pkgs/python3/checksums.ini
@@ -1,5 +1,4 @@
 tarball=Python-VERSION.tar.xz
 sha1=a368aeed7a3325e47b55168452c356a8eb27ab50
-md5=b353b8433e560e1af2b130f56dfbd973
-cksum=534846730
+sha256=9e06008c8901924395bc1da303eac567a729ae012baa182ab39269f650383bb3
 upstream_url=https://www.python.org/ftp/python/VERSION/Python-VERSION.tar.xz
diff --git a/build/pkgs/python_build/checksums.ini b/build/pkgs/python_build/checksums.ini
index df10f8d3196..c2bafe9d49d 100644
--- a/build/pkgs/python_build/checksums.ini
+++ b/build/pkgs/python_build/checksums.ini
@@ -1,5 +1,4 @@
 tarball=build-VERSION-py3-none-any.whl
 sha1=950bf228726af5041adbe2bb04a7ca74e27bce60
-md5=6f34942a01c3307b42556ee7628f3d1d
-cksum=4005002353
+sha256=75e10f767a433d9a86e50d83f418e83efc18ede923ee5ff7df93b6cb0306c5d4
 upstream_url=https://pypi.io/packages/py3/b/build/build-VERSION-py3-none-any.whl
diff --git a/build/pkgs/python_flint/checksums.ini b/build/pkgs/python_flint/checksums.ini
index 265d92659e1..19d40c1c7b1 100644
--- a/build/pkgs/python_flint/checksums.ini
+++ b/build/pkgs/python_flint/checksums.ini
@@ -1,5 +1,4 @@
 tarball=python-flint-VERSION.tar.gz
 sha1=c7d5b3b8db47c903eea9e752bd7732e34d6c5945
-md5=6473f4da8959f0ec085db62bca3e40e3
-cksum=2814579556
+sha256=f829e00774534891b38de41bc511cf6c7d6d216544a6a84b92d9e1f159de0878
 upstream_url=https://pypi.io/packages/source/p/python_flint/python-flint-VERSION.tar.gz
diff --git a/build/pkgs/python_igraph/checksums.ini b/build/pkgs/python_igraph/checksums.ini
index e3ba512eb8f..ecdc7ea2dfe 100644
--- a/build/pkgs/python_igraph/checksums.ini
+++ b/build/pkgs/python_igraph/checksums.ini
@@ -1,5 +1,4 @@
 tarball=python-igraph-VERSION.tar.gz
 sha1=ef7ee85cb1bc83109c744d5dd6bbe5e37598ce3f
-md5=788bd70bd286651774f15b20af956081
-cksum=1447848766
+sha256=e55df60f882a51b8e8c1c5e7e940c5f90685d75634ea6df63bebcc983397adfa
 upstream_url=https://pypi.io/packages/source/i/igraph/igraph-VERSION.tar.gz
diff --git a/build/pkgs/python_json_logger/checksums.ini b/build/pkgs/python_json_logger/checksums.ini
index b17d08d7100..2856b66a14f 100644
--- a/build/pkgs/python_json_logger/checksums.ini
+++ b/build/pkgs/python_json_logger/checksums.ini
@@ -1,5 +1,4 @@
 tarball=python_json_logger-VERSION-py3-none-any.whl
 sha1=c1176f521d95b5452b6169943b2b9b259e024b39
-md5=618fc5f196be90261afa8372eb458f47
-cksum=349551342
+sha256=f380b826a991ebbe3de4d897aeec42760035ac760345e57b812938dc8b35e2bd
 upstream_url=https://pypi.io/packages/py3/p/python_json_logger/python_json_logger-VERSION-py3-none-any.whl
diff --git a/build/pkgs/pythran/checksums.ini b/build/pkgs/pythran/checksums.ini
index 5e9aebabe99..03d21286397 100644
--- a/build/pkgs/pythran/checksums.ini
+++ b/build/pkgs/pythran/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pythran-VERSION.tar.gz
 sha1=dc8a6035c0c46d36630085003160a3aba4444add
-md5=cc6fa05e583733182d06d2e41e03cc10
-cksum=3823048752
+sha256=f9bc61bcb96df2cd4b578abc5a62dfb3fbb0b0ef02c264513dfb615c5f87871c
 upstream_url=https://pypi.io/packages/source/p/pythran/pythran-VERSION.tar.gz
diff --git a/build/pkgs/pytz/checksums.ini b/build/pkgs/pytz/checksums.ini
index 0b0e03e9863..8ff6396f13e 100644
--- a/build/pkgs/pytz/checksums.ini
+++ b/build/pkgs/pytz/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pytz-VERSION.tar.gz
 sha1=be3f14bc0d6b89b8c579d8ae4e0fcb4478ff92e6
-md5=84e6569fcc917b096cca1063819c4ab0
-cksum=3925580206
+sha256=7b4fddbeb94a1eba4b557da24f19fdf9db575192544270a9101d8509f9f43d7b
 upstream_url=https://pypi.io/packages/source/p/pytz/pytz-VERSION.tar.gz
diff --git a/build/pkgs/pytz_deprecation_shim/checksums.ini b/build/pkgs/pytz_deprecation_shim/checksums.ini
index 4c5f6546961..199685f084c 100644
--- a/build/pkgs/pytz_deprecation_shim/checksums.ini
+++ b/build/pkgs/pytz_deprecation_shim/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pytz_deprecation_shim-VERSION.tar.gz
 sha1=d7900c309c26d48f6499fbda955eb80bd0b437dd
-md5=f563b4bdc56f40acb2498fd1caf6dd1b
-cksum=2491832159
+sha256=af097bae1b616dde5c5744441e2ddc69e74dfdcb0c263129610d85b87445a59d
 upstream_url=https://pypi.io/packages/source/p/pytz_deprecation_shim/pytz_deprecation_shim-VERSION.tar.gz
diff --git a/build/pkgs/pyyaml/checksums.ini b/build/pkgs/pyyaml/checksums.ini
index 6918d8fda58..1e9b9f74722 100644
--- a/build/pkgs/pyyaml/checksums.ini
+++ b/build/pkgs/pyyaml/checksums.ini
@@ -1,5 +1,4 @@
 tarball=PyYAML-VERSION.tar.gz
 sha1=a80d802ad8f693bed34c8fb5ee168a1872663c9a
-md5=c9246277af2d9a13b7018af267a0831a
-cksum=2585952669
+sha256=bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43
 upstream_url=https://pypi.io/packages/source/p/pyyaml/PyYAML-VERSION.tar.gz
diff --git a/build/pkgs/pyzmq/checksums.ini b/build/pkgs/pyzmq/checksums.ini
index 091981fb051..b4b99817bdc 100644
--- a/build/pkgs/pyzmq/checksums.ini
+++ b/build/pkgs/pyzmq/checksums.ini
@@ -1,5 +1,4 @@
 tarball=pyzmq-VERSION.tar.gz
 sha1=f750e59a3d5fcca64d0a1a6723c1bc72173e976f
-md5=993a646d3f1c6201a8c93bcb2d2f867e
-cksum=2057198190
+sha256=259c22485b71abacdfa8bf79720cd7bcf4b9d128b30ea554f01ae71fdbfdaa23
 upstream_url=https://pypi.io/packages/source/p/pyzmq/pyzmq-VERSION.tar.gz
diff --git a/build/pkgs/qdldl_python/checksums.ini b/build/pkgs/qdldl_python/checksums.ini
index defd264f787..a444f898ae6 100644
--- a/build/pkgs/qdldl_python/checksums.ini
+++ b/build/pkgs/qdldl_python/checksums.ini
@@ -1,5 +1,4 @@
 tarball=qdldl-VERSION.tar.gz
 sha1=af76c57ca1787f5e44e42f6c9f916b84ae599f1f
-md5=63d719bd8073c1661a1baa6b510b8aad
-cksum=105675620
+sha256=69c092f6e1fc23fb779a80a62e6fcdfe2eba05c925860248c4d6754f4736938f
 upstream_url=https://pypi.io/packages/source/q/qdldl/qdldl-VERSION.tar.gz
diff --git a/build/pkgs/qepcad/checksums.ini b/build/pkgs/qepcad/checksums.ini
index 48c23eaad91..01f75bcc26e 100644
--- a/build/pkgs/qepcad/checksums.ini
+++ b/build/pkgs/qepcad/checksums.ini
@@ -1,5 +1,4 @@
 tarball=qepcad-VERSION.tar.gz
 sha1=644324e1224350cc663e93c5ce99b93de0de26e3
-md5=f368459cfab2d42caa40919e60093020
-cksum=783450087
+sha256=075db8950ef2a6d11f099b85820363f7b4d61f4aff3425cb799d7567dc1254fc
 upstream_url=https://www.usna.edu/Users/cs/wcbrown/qepcad/INSTALL/qepcad-B.VERSION.tgz
diff --git a/build/pkgs/qhull/checksums.ini b/build/pkgs/qhull/checksums.ini
index 65635055fa6..fd1421d5d62 100644
--- a/build/pkgs/qhull/checksums.ini
+++ b/build/pkgs/qhull/checksums.ini
@@ -1,5 +1,4 @@
 tarball=qhull-VERSION.tgz
 sha1=2dbc240919560ac008a92363984754a70677b353
-md5=295f7332269a38279478f555cc185296
-cksum=3092762704
+sha256=b5c2d7eb833278881b952c8a52d20179eab87766b00b865000469a45c1838b7e
 upstream_url=http://www.qhull.org/download/qhull-VERSION.tgz
diff --git a/build/pkgs/readline/checksums.ini b/build/pkgs/readline/checksums.ini
index 05d4f89539f..5f3fbae748b 100644
--- a/build/pkgs/readline/checksums.ini
+++ b/build/pkgs/readline/checksums.ini
@@ -1,5 +1,4 @@
 tarball=readline-VERSION.tar.gz
 sha1=8a05ad0d0ad67e18c383f1b2cf6a23bcbd46f87a
-md5=12819fa739a78a6172400f399ab34f81
-cksum=829245750
+sha256=7589a2381a8419e68654a47623ce7dfcb756815c8fee726b98f90bf668af7bc6
 upstream_url=https://ftp.gnu.org/gnu/readline/readline-VERSION.tar.gz
diff --git a/build/pkgs/referencing/checksums.ini b/build/pkgs/referencing/checksums.ini
index a121d900f04..293629ca16d 100644
--- a/build/pkgs/referencing/checksums.ini
+++ b/build/pkgs/referencing/checksums.ini
@@ -1,5 +1,4 @@
 tarball=referencing-VERSION-py3-none-any.whl
 sha1=9d710ba3a604d24ffded218a3813b5fd1fe2e495
-md5=d12db197f05a5c560011e40e1852e8fc
-cksum=2747749685
+sha256=160f24a7d2411dc82b1efd96dfb083ee9e5cc9bc8e492d323e0dd853989d37b3
 upstream_url=https://pypi.io/packages/py3/r/referencing/referencing-VERSION-py3-none-any.whl
diff --git a/build/pkgs/requests/checksums.ini b/build/pkgs/requests/checksums.ini
index a28e4ca5db0..8b0dc85bd89 100644
--- a/build/pkgs/requests/checksums.ini
+++ b/build/pkgs/requests/checksums.ini
@@ -1,5 +1,4 @@
 tarball=requests-VERSION-py3-none-any.whl
 sha1=60b928b15e05d04a33b880a0232e44258c777740
-md5=0cb4b772a1a652cf3d170a6c42a69098
-cksum=1658568655
+sha256=58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f
 upstream_url=https://pypi.io/packages/py3/r/requests/requests-VERSION-py3-none-any.whl
diff --git a/build/pkgs/rfc3339_validator/checksums.ini b/build/pkgs/rfc3339_validator/checksums.ini
index f91914fd5f7..a0766fbec23 100644
--- a/build/pkgs/rfc3339_validator/checksums.ini
+++ b/build/pkgs/rfc3339_validator/checksums.ini
@@ -1,5 +1,4 @@
 tarball=rfc3339_validator-VERSION-py2.py3-none-any.whl
 sha1=daa86cb641dfd6ebfef4ece6dea1be8fd63dec00
-md5=e16fb743ff1c88d7c7de18890935b647
-cksum=2330309218
+sha256=24f6ec1eda14ef823da9e36ec7113124b39c04d50a4d3d3a3c2859577e7791fa
 upstream_url=https://pypi.io/packages/py2.py3/r/rfc3339_validator/rfc3339_validator-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/rfc3986_validator/checksums.ini b/build/pkgs/rfc3986_validator/checksums.ini
index c0ad30c07e7..5d08b72ca0e 100644
--- a/build/pkgs/rfc3986_validator/checksums.ini
+++ b/build/pkgs/rfc3986_validator/checksums.ini
@@ -1,5 +1,4 @@
 tarball=rfc3986_validator-VERSION-py2.py3-none-any.whl
 sha1=c0fabd5c0568cc516f9258f3e5846a04a059dc31
-md5=41aef4395cd3d560c96a3992534dfd53
-cksum=1606077510
+sha256=2f235c432ef459970b4306369336b9d5dbdda31b510ca1e327636e01f528bfa9
 upstream_url=https://pypi.io/packages/py2.py3/r/rfc3986_validator/rfc3986_validator-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/rpy2/checksums.ini b/build/pkgs/rpy2/checksums.ini
index ece539eec53..62224bc62f8 100644
--- a/build/pkgs/rpy2/checksums.ini
+++ b/build/pkgs/rpy2/checksums.ini
@@ -1,5 +1,4 @@
 tarball=rpy2-VERSION.tar.gz
 sha1=7d236c0c6982333b20b6a126f0c17a5481fea64b
-md5=8842b153925a2eca21e2552e964facbb
-cksum=1249008138
+sha256=5d31a5ea43f5a59f6dec30faca87edb01fc9b8affa0beae96a99be923bd7dab3
 upstream_url=https://pypi.io/packages/source/r/rpy2/rpy2-VERSION.tar.gz
diff --git a/build/pkgs/rst2ipynb/checksums.ini b/build/pkgs/rst2ipynb/checksums.ini
index de9e93fce3f..2248cc0a54a 100644
--- a/build/pkgs/rst2ipynb/checksums.ini
+++ b/build/pkgs/rst2ipynb/checksums.ini
@@ -1,5 +1,4 @@
 tarball=rst2ipynb-VERSION.tar.gz
 sha1=98926df9a8336c8974f446a2a858458495b5aec4
-md5=eedfb3d5b8634e36b680ad86771cec38
-cksum=3973650989
+sha256=30d70b0e96f1c37baad9c8dbe904fc2567354eec02c52b94e7c7287b6268eaa3
 upstream_url=https://pypi.io/packages/source/r/rst2ipynb/rst2ipynb-VERSION.tar.gz
diff --git a/build/pkgs/rubiks/checksums.ini b/build/pkgs/rubiks/checksums.ini
index 35c77e8ff4b..f53803060f1 100644
--- a/build/pkgs/rubiks/checksums.ini
+++ b/build/pkgs/rubiks/checksums.ini
@@ -1,5 +1,4 @@
 tarball=rubiks-VERSION-unix.tar.bz2
 sha1=c12069ed1eb0fc19f80a474b1c4bad2d845f5e40
-md5=c1108799440f7f974e55ef967ae6642a
-cksum=215946372
+sha256=aae4c88c0f1cf84718c1a6e31e027a2886e9eaea65051385339fd98be8693e07
 upstream_url=https://users.ox.ac.uk/~coml0531/tmp/rubiks-VERSION-unix.tar.bz2
diff --git a/build/pkgs/rw/checksums.ini b/build/pkgs/rw/checksums.ini
index eaf5817e53c..c7bf058cd40 100644
--- a/build/pkgs/rw/checksums.ini
+++ b/build/pkgs/rw/checksums.ini
@@ -1,5 +1,4 @@
 tarball=rw-VERSION.tar.gz
 sha1=5c9c8a5c2eda798f6b0fe5218ba08ef429e0aa9f
-md5=829612ea322d64bc529ffbb6be42d97e
-cksum=93091513
+sha256=c1e03506fe25cdfcb428c051fc56b2d2affb5b06fba3f2ce756631466befb441
 upstream_url=https://sourceforge.net/projects/rankwidth/files/rw-VERSION.tar.gz
diff --git a/build/pkgs/saclib/checksums.ini b/build/pkgs/saclib/checksums.ini
index 1f0289be1e8..1e7d0c75cfc 100644
--- a/build/pkgs/saclib/checksums.ini
+++ b/build/pkgs/saclib/checksums.ini
@@ -1,5 +1,4 @@
 tarball=saclibVERSION.tar.gz
 sha1=6f37da451e1003b381e8a9dd7f60ec265021d061
-md5=2a251651bc96a14eba4300f18ec4cbb4
-cksum=3062086094
+sha256=e8e3acb253c64394f35c8e17942f764cae34df731f3fe3d749b6a2ae1fb8203b
 upstream_url=https://www.usna.edu/Users/cs/wcbrown/qepcad/INSTALL/saclibVERSION.tgz
diff --git a/build/pkgs/sage_conf/version_requirements.txt b/build/pkgs/sage_conf/version_requirements.txt
index 858e8da5968..58f6d1bfc6a 100644
--- a/build/pkgs/sage_conf/version_requirements.txt
+++ b/build/pkgs/sage_conf/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sage-conf ~= 10.4b6
+sage-conf ~= 10.4b7
diff --git a/build/pkgs/sage_docbuild/version_requirements.txt b/build/pkgs/sage_docbuild/version_requirements.txt
index 0005ac13ace..a69a5b27f2d 100644
--- a/build/pkgs/sage_docbuild/version_requirements.txt
+++ b/build/pkgs/sage_docbuild/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sage-docbuild ~= 10.4b6
+sage-docbuild ~= 10.4b7
diff --git a/build/pkgs/sage_numerical_backends_coin/checksums.ini b/build/pkgs/sage_numerical_backends_coin/checksums.ini
index 3e33bd4feec..53ebb086e1c 100644
--- a/build/pkgs/sage_numerical_backends_coin/checksums.ini
+++ b/build/pkgs/sage_numerical_backends_coin/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sage_numerical_backends_coin-VERSION.tar.gz
 sha1=5c9708603564c55fa5fddf66ac06f68f4c6145e2
-md5=94ed7c290defc4bf16dcdb0e0c67ca35
-cksum=2355301440
+sha256=d48b7c550bc727f58ce28c03cc572f37e7e6267a0c73366aa6cf852c80af6a39
 upstream_url=https://pypi.io/packages/source/s/sage_numerical_backends_coin/sage_numerical_backends_coin-VERSION.tar.gz
diff --git a/build/pkgs/sage_numerical_backends_cplex/checksums.ini b/build/pkgs/sage_numerical_backends_cplex/checksums.ini
index 498a4464973..633b6676b48 100644
--- a/build/pkgs/sage_numerical_backends_cplex/checksums.ini
+++ b/build/pkgs/sage_numerical_backends_cplex/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sage_numerical_backends_cplex-VERSION.tar.gz
 sha1=59b5f344f5b3d2e1f2fb7dcddef208bcc99e710a
-md5=f8dcd101092634dac83097a36d64c872
-cksum=2646359461
+sha256=4e4ce4464a26d1c0bb340273f0731f75b037550dc35afd143e95b94168f2eca1
 upstream_url=https://pypi.io/packages/source/s/sage_numerical_backends_cplex/sage_numerical_backends_cplex-VERSION.tar.gz
diff --git a/build/pkgs/sage_numerical_backends_gurobi/checksums.ini b/build/pkgs/sage_numerical_backends_gurobi/checksums.ini
index d5e6fd8e2b1..70dc24885c2 100644
--- a/build/pkgs/sage_numerical_backends_gurobi/checksums.ini
+++ b/build/pkgs/sage_numerical_backends_gurobi/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sage_numerical_backends_gurobi-VERSION.tar.gz
 sha1=36a2bfa1cfa2f4fdcb9dc979e80177580bb7aac2
-md5=0a77377fad705950c4b7b14b366ebaa6
-cksum=478792673
+sha256=bb073ce2d7972aabafd2a074c46231204fe3a04d273b247ee9a03ca8938d17e0
 upstream_url=https://pypi.io/packages/source/s/sage_numerical_backends_gurobi/sage_numerical_backends_gurobi-VERSION.tar.gz
diff --git a/build/pkgs/sage_setup/version_requirements.txt b/build/pkgs/sage_setup/version_requirements.txt
index 4efa9ed072c..690c1a22a50 100644
--- a/build/pkgs/sage_setup/version_requirements.txt
+++ b/build/pkgs/sage_setup/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sage-setup ~= 10.4b6
+sage-setup ~= 10.4b7
diff --git a/build/pkgs/sage_sws2rst/version_requirements.txt b/build/pkgs/sage_sws2rst/version_requirements.txt
index a44b4f816f4..e4634286686 100644
--- a/build/pkgs/sage_sws2rst/version_requirements.txt
+++ b/build/pkgs/sage_sws2rst/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sage-sws2rst ~= 10.4b6
+sage-sws2rst ~= 10.4b7
diff --git a/build/pkgs/sagelib/spkg-install.in b/build/pkgs/sagelib/spkg-install.in
index 8b3b4485504..0b1329bf1b1 100644
--- a/build/pkgs/sagelib/spkg-install.in
+++ b/build/pkgs/sagelib/spkg-install.in
@@ -60,20 +60,16 @@ if [ "$SAGE_EDITABLE" = yes ]; then
         cd $SAGE_PKGS/sagelib/src && time sdh_setup_bdist_wheel && sdh_store_wheel .
     fi
 else
+    # Now implied: "$SAGE_WHEELS" = yes
     # Make sure that an installed old version of sagelib in which sage is an ordinary package
     # does not shadow the namespace package sage during the build.
     (cd "$SITEPACKAGESDIR" && rm -f sage/__init__.py)
     # Likewise, we should remove the egg-link that may have been installed previously.
     (cd "$SITEPACKAGESDIR" && rm -f sagemath-standard.egg-link)
 
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # Use --no-build-isolation to avoid rebuilds because of dependencies:
-        # Compiling sage/interfaces/sagespawn.pyx because it depends on /private/var/folders/38/wnh4gf1552g_crsjnv2vmmww0000gp/T/pip-build-env-609n5985/overlay/lib/python3.10/site-packages/Cython/Includes/posix/unistd.pxd
-        sdh_pip_install --no-build-isolation .
-    else
-        SAGE_OPTIONAL_PACKAGES_WITH_EXTENSIONS+="mcqd,tdlib,coxeter3,sirocco,meataxe,bliss"
-        python3 -u setup.py --no-user-cfg build install || exit 1
-    fi
+    # Use --no-build-isolation to avoid rebuilds because of dependencies:
+    # Compiling sage/interfaces/sagespawn.pyx because it depends on /private/var/folders/38/wnh4gf1552g_crsjnv2vmmww0000gp/T/pip-build-env-609n5985/overlay/lib/python3.10/site-packages/Cython/Includes/posix/unistd.pxd
+    sdh_pip_install --no-build-isolation .
 fi
 
 # Remove (potentially invalid) star import caches.
diff --git a/build/pkgs/sagelib/version_requirements.txt b/build/pkgs/sagelib/version_requirements.txt
index 43ee6e618ef..63f73939615 100644
--- a/build/pkgs/sagelib/version_requirements.txt
+++ b/build/pkgs/sagelib/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-standard ~= 10.4b6
+sagemath-standard ~= 10.4b7
diff --git a/build/pkgs/sagemath_bliss/spkg-install.in b/build/pkgs/sagemath_bliss/spkg-install.in
index ccd53947ab0..2a2d7efba78 100644
--- a/build/pkgs/sagemath_bliss/spkg-install.in
+++ b/build/pkgs/sagemath_bliss/spkg-install.in
@@ -10,9 +10,6 @@ if [ "$SAGE_EDITABLE" = yes ]; then
         sdh_setup_bdist_wheel && sdh_store_wheel .
     fi
 else
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # Modularized install via wheels
-        sdh_pip_install .
-    # else nothing to do in legacy direct installation.
-    fi
+    # Modularized install via wheels. Now implied: "$SAGE_WHEELS" = yes
+    sdh_pip_install .
 fi
diff --git a/build/pkgs/sagemath_bliss/version_requirements.txt b/build/pkgs/sagemath_bliss/version_requirements.txt
index 11ff86c39e6..9e36e39aeaf 100644
--- a/build/pkgs/sagemath_bliss/version_requirements.txt
+++ b/build/pkgs/sagemath_bliss/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-bliss ~= 10.4b6
+sagemath-bliss ~= 10.4b7
diff --git a/build/pkgs/sagemath_categories/version_requirements.txt b/build/pkgs/sagemath_categories/version_requirements.txt
index 4bf63679c82..16288aa2e89 100644
--- a/build/pkgs/sagemath_categories/version_requirements.txt
+++ b/build/pkgs/sagemath_categories/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-categories ~= 10.4b6
+sagemath-categories ~= 10.4b7
diff --git a/build/pkgs/sagemath_coxeter3/spkg-install.in b/build/pkgs/sagemath_coxeter3/spkg-install.in
deleted file mode 100644
index ccd53947ab0..00000000000
--- a/build/pkgs/sagemath_coxeter3/spkg-install.in
+++ /dev/null
@@ -1,18 +0,0 @@
-cd src
-
-export PIP_NO_INDEX=true
-export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS"
-
-if [ "$SAGE_EDITABLE" = yes ]; then
-    # SAGE_ROOT/src/setup.py installs everything, nothing to do...
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # ... except we build the wheel if requested
-        sdh_setup_bdist_wheel && sdh_store_wheel .
-    fi
-else
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # Modularized install via wheels
-        sdh_pip_install .
-    # else nothing to do in legacy direct installation.
-    fi
-fi
diff --git a/build/pkgs/sagemath_coxeter3/spkg-install.in b/build/pkgs/sagemath_coxeter3/spkg-install.in
new file mode 120000
index 00000000000..e38ca3ace8b
--- /dev/null
+++ b/build/pkgs/sagemath_coxeter3/spkg-install.in
@@ -0,0 +1 @@
+../sagemath_bliss/spkg-install.in
\ No newline at end of file
diff --git a/build/pkgs/sagemath_coxeter3/version_requirements.txt b/build/pkgs/sagemath_coxeter3/version_requirements.txt
index 4d8933d8f37..b1de7530945 100644
--- a/build/pkgs/sagemath_coxeter3/version_requirements.txt
+++ b/build/pkgs/sagemath_coxeter3/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-coxeter3 ~= 10.4b6
+sagemath-coxeter3 ~= 10.4b7
diff --git a/build/pkgs/sagemath_environment/version_requirements.txt b/build/pkgs/sagemath_environment/version_requirements.txt
index c97a53a9437..f1e2646a607 100644
--- a/build/pkgs/sagemath_environment/version_requirements.txt
+++ b/build/pkgs/sagemath_environment/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-environment ~= 10.4b6
+sagemath-environment ~= 10.4b7
diff --git a/build/pkgs/sagemath_mcqd/spkg-install.in b/build/pkgs/sagemath_mcqd/spkg-install.in
deleted file mode 100644
index ccd53947ab0..00000000000
--- a/build/pkgs/sagemath_mcqd/spkg-install.in
+++ /dev/null
@@ -1,18 +0,0 @@
-cd src
-
-export PIP_NO_INDEX=true
-export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS"
-
-if [ "$SAGE_EDITABLE" = yes ]; then
-    # SAGE_ROOT/src/setup.py installs everything, nothing to do...
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # ... except we build the wheel if requested
-        sdh_setup_bdist_wheel && sdh_store_wheel .
-    fi
-else
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # Modularized install via wheels
-        sdh_pip_install .
-    # else nothing to do in legacy direct installation.
-    fi
-fi
diff --git a/build/pkgs/sagemath_mcqd/spkg-install.in b/build/pkgs/sagemath_mcqd/spkg-install.in
new file mode 120000
index 00000000000..e38ca3ace8b
--- /dev/null
+++ b/build/pkgs/sagemath_mcqd/spkg-install.in
@@ -0,0 +1 @@
+../sagemath_bliss/spkg-install.in
\ No newline at end of file
diff --git a/build/pkgs/sagemath_mcqd/version_requirements.txt b/build/pkgs/sagemath_mcqd/version_requirements.txt
index 697eed8cf48..3127a29f151 100644
--- a/build/pkgs/sagemath_mcqd/version_requirements.txt
+++ b/build/pkgs/sagemath_mcqd/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-mcqd ~= 10.4b6
+sagemath-mcqd ~= 10.4b7
diff --git a/build/pkgs/sagemath_meataxe/spkg-install.in b/build/pkgs/sagemath_meataxe/spkg-install.in
deleted file mode 100644
index ccd53947ab0..00000000000
--- a/build/pkgs/sagemath_meataxe/spkg-install.in
+++ /dev/null
@@ -1,18 +0,0 @@
-cd src
-
-export PIP_NO_INDEX=true
-export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS"
-
-if [ "$SAGE_EDITABLE" = yes ]; then
-    # SAGE_ROOT/src/setup.py installs everything, nothing to do...
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # ... except we build the wheel if requested
-        sdh_setup_bdist_wheel && sdh_store_wheel .
-    fi
-else
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # Modularized install via wheels
-        sdh_pip_install .
-    # else nothing to do in legacy direct installation.
-    fi
-fi
diff --git a/build/pkgs/sagemath_meataxe/spkg-install.in b/build/pkgs/sagemath_meataxe/spkg-install.in
new file mode 120000
index 00000000000..e38ca3ace8b
--- /dev/null
+++ b/build/pkgs/sagemath_meataxe/spkg-install.in
@@ -0,0 +1 @@
+../sagemath_bliss/spkg-install.in
\ No newline at end of file
diff --git a/build/pkgs/sagemath_meataxe/version_requirements.txt b/build/pkgs/sagemath_meataxe/version_requirements.txt
index 8e7db0b81a8..9b329c34940 100644
--- a/build/pkgs/sagemath_meataxe/version_requirements.txt
+++ b/build/pkgs/sagemath_meataxe/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-meataxe ~= 10.4b6
+sagemath-meataxe ~= 10.4b7
diff --git a/build/pkgs/sagemath_objects/version_requirements.txt b/build/pkgs/sagemath_objects/version_requirements.txt
index 92bb9707da1..cdec9b0c857 100644
--- a/build/pkgs/sagemath_objects/version_requirements.txt
+++ b/build/pkgs/sagemath_objects/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-objects ~= 10.4b6
+sagemath-objects ~= 10.4b7
diff --git a/build/pkgs/sagemath_repl/version_requirements.txt b/build/pkgs/sagemath_repl/version_requirements.txt
index 2b2a5e66ef5..f041ca7788d 100644
--- a/build/pkgs/sagemath_repl/version_requirements.txt
+++ b/build/pkgs/sagemath_repl/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-repl ~= 10.4b6
+sagemath-repl ~= 10.4b7
diff --git a/build/pkgs/sagemath_sirocco/spkg-install.in b/build/pkgs/sagemath_sirocco/spkg-install.in
deleted file mode 100644
index ccd53947ab0..00000000000
--- a/build/pkgs/sagemath_sirocco/spkg-install.in
+++ /dev/null
@@ -1,18 +0,0 @@
-cd src
-
-export PIP_NO_INDEX=true
-export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS"
-
-if [ "$SAGE_EDITABLE" = yes ]; then
-    # SAGE_ROOT/src/setup.py installs everything, nothing to do...
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # ... except we build the wheel if requested
-        sdh_setup_bdist_wheel && sdh_store_wheel .
-    fi
-else
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # Modularized install via wheels
-        sdh_pip_install .
-    # else nothing to do in legacy direct installation.
-    fi
-fi
diff --git a/build/pkgs/sagemath_sirocco/spkg-install.in b/build/pkgs/sagemath_sirocco/spkg-install.in
new file mode 120000
index 00000000000..e38ca3ace8b
--- /dev/null
+++ b/build/pkgs/sagemath_sirocco/spkg-install.in
@@ -0,0 +1 @@
+../sagemath_bliss/spkg-install.in
\ No newline at end of file
diff --git a/build/pkgs/sagemath_sirocco/version_requirements.txt b/build/pkgs/sagemath_sirocco/version_requirements.txt
index 106893032ab..a788b285678 100644
--- a/build/pkgs/sagemath_sirocco/version_requirements.txt
+++ b/build/pkgs/sagemath_sirocco/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-sirocco ~= 10.4b6
+sagemath-sirocco ~= 10.4b7
diff --git a/build/pkgs/sagemath_tdlib/dependencies b/build/pkgs/sagemath_tdlib/dependencies
index b22ab6c52a7..468986b44b0 100644
--- a/build/pkgs/sagemath_tdlib/dependencies
+++ b/build/pkgs/sagemath_tdlib/dependencies
@@ -1 +1 @@
- tdlib cysignals | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig $(PYTHON)
+ tdlib cysignals boost_cropped | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig $(PYTHON)
diff --git a/build/pkgs/sagemath_tdlib/spkg-install.in b/build/pkgs/sagemath_tdlib/spkg-install.in
deleted file mode 100644
index ccd53947ab0..00000000000
--- a/build/pkgs/sagemath_tdlib/spkg-install.in
+++ /dev/null
@@ -1,18 +0,0 @@
-cd src
-
-export PIP_NO_INDEX=true
-export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS"
-
-if [ "$SAGE_EDITABLE" = yes ]; then
-    # SAGE_ROOT/src/setup.py installs everything, nothing to do...
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # ... except we build the wheel if requested
-        sdh_setup_bdist_wheel && sdh_store_wheel .
-    fi
-else
-    if [ "$SAGE_WHEELS" = yes ]; then
-        # Modularized install via wheels
-        sdh_pip_install .
-    # else nothing to do in legacy direct installation.
-    fi
-fi
diff --git a/build/pkgs/sagemath_tdlib/spkg-install.in b/build/pkgs/sagemath_tdlib/spkg-install.in
new file mode 120000
index 00000000000..e38ca3ace8b
--- /dev/null
+++ b/build/pkgs/sagemath_tdlib/spkg-install.in
@@ -0,0 +1 @@
+../sagemath_bliss/spkg-install.in
\ No newline at end of file
diff --git a/build/pkgs/sagemath_tdlib/version_requirements.txt b/build/pkgs/sagemath_tdlib/version_requirements.txt
index 71dc621822a..356961322c6 100644
--- a/build/pkgs/sagemath_tdlib/version_requirements.txt
+++ b/build/pkgs/sagemath_tdlib/version_requirements.txt
@@ -1,2 +1,2 @@
 # This file is updated on every release by the sage-update-version script
-sagemath-tdlib ~= 10.4b6
+sagemath-tdlib ~= 10.4b7
diff --git a/build/pkgs/sagenb_export/checksums.ini b/build/pkgs/sagenb_export/checksums.ini
index e7a10e0c0cd..cf021ab516f 100644
--- a/build/pkgs/sagenb_export/checksums.ini
+++ b/build/pkgs/sagenb_export/checksums.ini
@@ -1,4 +1,3 @@
 tarball=sagenb_export-VERSION.tar.gz
 sha1=98d268fd21200482299b66196028d55dec923466
-md5=2f88a08db0d5dd39a9a27eec4cf16192
-cksum=607250687
+sha256=b642321ccd94da4d04afa12f33b6cea7c8db289f3283c6e39b3a50131780bb5a
diff --git a/build/pkgs/sagetex/checksums.ini b/build/pkgs/sagetex/checksums.ini
index ec20a91fb3d..7cfac7e72f3 100644
--- a/build/pkgs/sagetex/checksums.ini
+++ b/build/pkgs/sagetex/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sagetex-VERSION.tar.gz
 sha1=821c8a6ab11ee651d0dcc599c5582fefb6706775
-md5=a7ddbe41ea3d816e839ddda3ec28f89a
-cksum=1768053059
+sha256=03162ec62cb86da13a747f982241af3e4f4cdd4d29fcba8fbb6c6982a9e906d9
 upstream_url=https://pypi.io/packages/source/s/sagetex/sagetex-VERSION.tar.gz
diff --git a/build/pkgs/scip/checksums.ini b/build/pkgs/scip/checksums.ini
index 9dce3926f9b..d99a2b7930f 100644
--- a/build/pkgs/scip/checksums.ini
+++ b/build/pkgs/scip/checksums.ini
@@ -1,5 +1,4 @@
 tarball=scip-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}.tar.gz
 sha1=bb28aef4bad00a1ff2c7f4ee982961709d15b9f8
-md5=2fdbc40c98d380b12586bcef6819b9d7
-cksum=1262698285
+sha256=ee221bd13a6b24738f2e74321e2efdebd6d7c603574ca6f6cb9d4472ead2c22f
 upstream_url=https://github.com/scipopt/scip/archive/refs/tags/v${VERSION_MAJOR}${VERSION_MINOR}${VERSION_MICRO}.tar.gz
diff --git a/build/pkgs/scip_sdp/checksums.ini b/build/pkgs/scip_sdp/checksums.ini
index 94370bcab39..33aa56647eb 100644
--- a/build/pkgs/scip_sdp/checksums.ini
+++ b/build/pkgs/scip_sdp/checksums.ini
@@ -1,5 +1,4 @@
 tarball=scipsdp-VERSION.tgz
 sha1=d5482fd414fdcaa38d6d80111bbe8931aeef63ea
-md5=0de7752ba6602e3432940eaaf79dfa9d
-cksum=162799809
+sha256=6c8fbc15fc87bf4e12e0cafa4d1887933843447982d5ac3e8eb5e745d80b6d1a
 upstream_url=http://www.opt.tu-darmstadt.de/scipsdp/downloads/scipsdp-VERSION.tgz
diff --git a/build/pkgs/scipy/checksums.ini b/build/pkgs/scipy/checksums.ini
index 762809ffd08..8871f77250b 100644
--- a/build/pkgs/scipy/checksums.ini
+++ b/build/pkgs/scipy/checksums.ini
@@ -1,5 +1,4 @@
 tarball=scipy-VERSION.tar.gz
 sha1=0fd6e14972d8dd9b4a656686a40aed00ad0f1396
-md5=22683fcf9a411f0a5254b7509bea0a6b
-cksum=1907765013
+sha256=4bf5abab8a36d20193c698b0f1fc282c1d083c94723902c447e5d2f1780936a3
 upstream_url=https://pypi.io/packages/source/s/scipy/scipy-VERSION.tar.gz
diff --git a/build/pkgs/scs/checksums.ini b/build/pkgs/scs/checksums.ini
index 572dded9919..ceaf994ac5f 100644
--- a/build/pkgs/scs/checksums.ini
+++ b/build/pkgs/scs/checksums.ini
@@ -1,5 +1,4 @@
 tarball=scs-VERSION.tar.gz
 sha1=92e4ff21b450c9659f610064eb79e804de9167b4
-md5=dc86b5ed0a0a22453bb88feacf31539a
-cksum=4083736723
+sha256=e3bd779e7e977e3ae5a2f2035aa4c2a309e29082d59a722d5d6592edc4bdb4b3
 upstream_url=https://pypi.io/packages/source/s/scs/scs-VERSION.tar.gz
diff --git a/build/pkgs/send2trash/checksums.ini b/build/pkgs/send2trash/checksums.ini
index 1b16811d046..d99aecb6b2f 100644
--- a/build/pkgs/send2trash/checksums.ini
+++ b/build/pkgs/send2trash/checksums.ini
@@ -1,5 +1,4 @@
 tarball=Send2Trash-VERSION.tar.gz
 sha1=211092dcefa5468582f7d083472ad7f1880cc019
-md5=3fc7ff801bc76da65cf4e97d6b89025e
-cksum=3017010359
+sha256=c132d59fa44b9ca2b1699af5c86f57ce9f4c5eb56629d5d55fbb7a35f84e2312
 upstream_url=https://pypi.io/packages/source/s/send2trash/Send2Trash-VERSION.tar.gz
diff --git a/build/pkgs/setuptools/checksums.ini b/build/pkgs/setuptools/checksums.ini
index bcd55128882..2436821630d 100644
--- a/build/pkgs/setuptools/checksums.ini
+++ b/build/pkgs/setuptools/checksums.ini
@@ -1,5 +1,4 @@
 tarball=setuptools-VERSION-py3-none-any.whl
 sha1=49841be6743b2d129d01d02d5fd339dd693c99dc
-md5=1555b24e28b53f3342e557500dedf8f3
-cksum=3445997019
+sha256=c636ac361bc47580504644275c9ad802c50415c7522212252c033bd15f301f32
 upstream_url=https://pypi.io/packages/py3/s/setuptools/setuptools-VERSION-py3-none-any.whl
diff --git a/build/pkgs/setuptools_scm/checksums.ini b/build/pkgs/setuptools_scm/checksums.ini
index fd10a17aea2..7d85feb982f 100644
--- a/build/pkgs/setuptools_scm/checksums.ini
+++ b/build/pkgs/setuptools_scm/checksums.ini
@@ -1,5 +1,4 @@
 tarball=setuptools_scm-VERSION-py3-none-any.whl
 sha1=cfde7254fe351b69cd4bf02e1b57e0b3c59aa9a6
-md5=4c054a609965886703ede26a4ba3206d
-cksum=1360813947
+sha256=b47844cd2a84b83b3187a5782c71128c28b4c94cad8bfb871da2784a5cb54c4f
 upstream_url=https://pypi.io/packages/py3/s/setuptools_scm/setuptools_scm-VERSION-py3-none-any.whl
diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
index 3273f5f7055..69cc9aae6e3 100644
--- a/build/pkgs/singular/checksums.ini
+++ b/build/pkgs/singular/checksums.ini
@@ -1,5 +1,4 @@
 tarball=singular-VERSION.tar.gz
 sha1=1f678e1cc756fd8dc29dcdef5ae67441b6bcc779
-md5=09382cdacbfe67b4099056b65c2ec016
-cksum=244065751
+sha256=c269abbd24c84fe33edc0af1e78b8fec53d8e94338410ac06c2666cfd40d43f2
 upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/${VERSION_MAJOR}-${VERSION_MINOR}-${VERSION_MICRO}/singular-VERSION.tar.gz
diff --git a/build/pkgs/singular_jupyter/checksums.ini b/build/pkgs/singular_jupyter/checksums.ini
index 7def85d733f..7264f159769 100644
--- a/build/pkgs/singular_jupyter/checksums.ini
+++ b/build/pkgs/singular_jupyter/checksums.ini
@@ -1,4 +1,3 @@
 tarball=jupyter_kernel_singular-VERSION.tar.gz
 sha1=e10d0894cac9ee111e34c6d6d6e409b26edf108f
-md5=c2acfe07c1094200dac521d2e8dcb2a9
-cksum=970360836
+sha256=1cf81f2a166b548e49ebd6a7623f7fb6d618dc0ab08d28867ee60cc2c4a30d5a
diff --git a/build/pkgs/sirocco/checksums.ini b/build/pkgs/sirocco/checksums.ini
index 2f0181ec823..19cbe71816c 100644
--- a/build/pkgs/sirocco/checksums.ini
+++ b/build/pkgs/sirocco/checksums.ini
@@ -1,5 +1,4 @@
 tarball=libsirocco-VERSION.tar.gz
 sha1=23311c0944f0c128b493589c1575476cf88177b6
-md5=e86b1dc9b72aee0d80186be7f49c295e
-cksum=784051898
+sha256=e86c9fe3b1f2cf0d3a7381d21c1fc4670f14b538c60c7cc6410ccb0f5b1fbaf8
 upstream_url=https://github.com/miguelmarco/SIROCCO2/releases/download/VERSION/libsirocco-VERSION.tar.gz
diff --git a/build/pkgs/sirocco/dependencies b/build/pkgs/sirocco/dependencies
new file mode 100644
index 00000000000..5bcf2cdfb19
--- /dev/null
+++ b/build/pkgs/sirocco/dependencies
@@ -0,0 +1 @@
+mpfr
diff --git a/build/pkgs/six/checksums.ini b/build/pkgs/six/checksums.ini
index a0614f6049b..24f678da7eb 100644
--- a/build/pkgs/six/checksums.ini
+++ b/build/pkgs/six/checksums.ini
@@ -1,5 +1,4 @@
 tarball=six-VERSION-py2.py3-none-any.whl
 sha1=79e6f2e4f9e24898f1896df379871b9c9922f147
-md5=529d7fd7e14612ccde86417b4402d6f3
-cksum=2975792266
+sha256=8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
 upstream_url=https://pypi.io/packages/py2.py3/s/six/six-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/sniffio/checksums.ini b/build/pkgs/sniffio/checksums.ini
index d8475bc91d3..8379b1841d0 100644
--- a/build/pkgs/sniffio/checksums.ini
+++ b/build/pkgs/sniffio/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sniffio-VERSION-py3-none-any.whl
 sha1=16f883fd7e31aa383df8901002f9ce5cec7606e5
-md5=7890655ffc549d04087bbc2f93332034
-cksum=2528943486
+sha256=eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384
 upstream_url=https://pypi.io/packages/py3/s/sniffio/sniffio-VERSION-py3-none-any.whl
diff --git a/build/pkgs/snowballstemmer/checksums.ini b/build/pkgs/snowballstemmer/checksums.ini
index dcc56ed9ed4..cab5be15660 100644
--- a/build/pkgs/snowballstemmer/checksums.ini
+++ b/build/pkgs/snowballstemmer/checksums.ini
@@ -1,5 +1,4 @@
 tarball=snowballstemmer-VERSION.tar.gz
 sha1=aaf1b0e3b58d25e2e297ea3dbef59d8534ef8d92
-md5=4332ddc7bbee0f344a03915b2ad59a54
-cksum=3477609484
+sha256=09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1
 upstream_url=https://pypi.io/packages/source/s/snowballstemmer/snowballstemmer-VERSION.tar.gz
diff --git a/build/pkgs/soplex/checksums.ini b/build/pkgs/soplex/checksums.ini
index 866f76b3ba9..4eb6d430aff 100644
--- a/build/pkgs/soplex/checksums.ini
+++ b/build/pkgs/soplex/checksums.ini
@@ -1,5 +1,4 @@
 tarball=soplex-VERSION.tar.gz
 sha1=5d0e7fa41b45aa0877134a5b8e261d9608505636
-md5=28be7e9aa5579ccd62cbe492d874ca2a
-cksum=232471152
+sha256=ab1906d3afb1793a6f129a5baef9dd8eee929ee945aade427cb9f0b17888239c
 upstream_url=https://github.com/scipopt/soplex/archive/refs/tags/release-${VERSION_MAJOR}${VERSION_MINOR}${VERSION_MICRO}.tar.gz
diff --git a/build/pkgs/soupsieve/checksums.ini b/build/pkgs/soupsieve/checksums.ini
index df73b2d47ba..3e9ef0ba9fc 100644
--- a/build/pkgs/soupsieve/checksums.ini
+++ b/build/pkgs/soupsieve/checksums.ini
@@ -1,5 +1,4 @@
 tarball=soupsieve-VERSION-py3-none-any.whl
 sha1=a155a6208211aa90bbc3bcfc9cab194a05000e59
-md5=80ebff671b2b8a346c2922b1feebf995
-cksum=275705301
+sha256=eaa337ff55a1579b6549dc679565eac1e3d000563bcb1c8ab0d0fefbc0c2cdc7
 upstream_url=https://pypi.io/packages/py3/s/soupsieve/soupsieve-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sphinx/checksums.ini b/build/pkgs/sphinx/checksums.ini
index c1741587efb..5cd194279be 100644
--- a/build/pkgs/sphinx/checksums.ini
+++ b/build/pkgs/sphinx/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinx-VERSION-py3-none-any.whl
 sha1=d4155cf2dbd768db9431fddcb7f53dd67caf56e1
-md5=35ced785936bf05d6b2769a797b15adf
-cksum=1007986807
+sha256=1e09160a40b956dc623c910118fa636da93bd3ca0b9876a7b3df90f07d691560
 upstream_url=https://pypi.io/packages/py3/s/sphinx/sphinx-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sphinx_basic_ng/checksums.ini b/build/pkgs/sphinx_basic_ng/checksums.ini
index 7c1f69fc872..4933de2fa24 100644
--- a/build/pkgs/sphinx_basic_ng/checksums.ini
+++ b/build/pkgs/sphinx_basic_ng/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinx_basic_ng-VERSION-py3-none-any.whl
 sha1=abcd9bda6ae61bb20c52bf46c17fb1bbdfdab4ea
-md5=39e1f6e303b3b485200b11abe9a5d552
-cksum=1539165518
+sha256=eb09aedbabfb650607e9b4b68c9d240b90b1e1be221d6ad71d61c52e29f7932b
 upstream_url=https://pypi.io/packages/py3/s/sphinx_basic_ng/sphinx_basic_ng-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sphinx_copybutton/checksums.ini b/build/pkgs/sphinx_copybutton/checksums.ini
index faf4fc2e45d..1c83ae582e0 100644
--- a/build/pkgs/sphinx_copybutton/checksums.ini
+++ b/build/pkgs/sphinx_copybutton/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinx_copybutton-VERSION-py3-none-any.whl
 sha1=a15e038b665225b13f7bd3eae6a2a64c8bd4b582
-md5=6781b8e0c3f77c146776b07ab345402a
-cksum=1069247069
+sha256=fb543fd386d917746c9a2c50360c7905b605726b9355cd26e9974857afeae06e
 upstream_url=https://pypi.io/packages/py3/s/sphinx_copybutton/sphinx_copybutton-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sphinx_inline_tabs/checksums.ini b/build/pkgs/sphinx_inline_tabs/checksums.ini
index f8423958dd5..93c03352650 100644
--- a/build/pkgs/sphinx_inline_tabs/checksums.ini
+++ b/build/pkgs/sphinx_inline_tabs/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinx_inline_tabs-VERSION-py3-none-any.whl
 sha1=1404e320d0533280355e7e1e71cffd9937015027
-md5=7373d0ebd34be8f9ac2ed62bc63f4582
-cksum=2708358042
+sha256=06809ac613f7c48ddd6e2fa588413e3fe92cff2397b56e2ccf0b0218f9ef6a78
 upstream_url=https://pypi.io/packages/py3/s/sphinx_inline_tabs/sphinx_inline_tabs-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sphinxcontrib_applehelp/checksums.ini b/build/pkgs/sphinxcontrib_applehelp/checksums.ini
index f3bd0dc0b95..25ebbacf69a 100644
--- a/build/pkgs/sphinxcontrib_applehelp/checksums.ini
+++ b/build/pkgs/sphinxcontrib_applehelp/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinxcontrib_applehelp-VERSION-py3-none-any.whl
 sha1=e426527562da2c5c520b27c58210cd1d44a1185b
-md5=2d4ea0fe463afb95f8c2ef125587934a
-cksum=3631877161
+sha256=cb61eb0ec1b61f349e5cc36b2028e9e7ca765be05e49641c97241274753067b4
 upstream_url=https://pypi.io/packages/py3/s/sphinxcontrib_applehelp/sphinxcontrib_applehelp-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sphinxcontrib_devhelp/checksums.ini b/build/pkgs/sphinxcontrib_devhelp/checksums.ini
index 865c81de2b9..03e4c534a7a 100644
--- a/build/pkgs/sphinxcontrib_devhelp/checksums.ini
+++ b/build/pkgs/sphinxcontrib_devhelp/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinxcontrib_devhelp-VERSION-py3-none-any.whl
 sha1=c1c774393d267d97eaf07f0e5c740f82af24d628
-md5=961a181d10d6d062ddaf5ed9321871f8
-cksum=1442746149
+sha256=6485d09629944511c893fa11355bda18b742b83a2b181f9a009f7e500595c90f
 upstream_url=https://pypi.io/packages/py3/s/sphinxcontrib_devhelp/sphinxcontrib_devhelp-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sphinxcontrib_htmlhelp/checksums.ini b/build/pkgs/sphinxcontrib_htmlhelp/checksums.ini
index 28acb5af66f..02f3fefa8df 100644
--- a/build/pkgs/sphinxcontrib_htmlhelp/checksums.ini
+++ b/build/pkgs/sphinxcontrib_htmlhelp/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinxcontrib_htmlhelp-VERSION-py3-none-any.whl
 sha1=6b60c617a0fe98a663ca146edc03867581da5e07
-md5=69b417211acf45aef9512adc660623c5
-cksum=3983023906
+sha256=393f04f112b4d2f53d93448d4bce35842f62b307ccdc549ec1585e950bc35e04
 upstream_url=https://pypi.io/packages/py3/s/sphinxcontrib_htmlhelp/sphinxcontrib_htmlhelp-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sphinxcontrib_jsmath/checksums.ini b/build/pkgs/sphinxcontrib_jsmath/checksums.ini
index 87b533edaf2..5ad932e6f6c 100644
--- a/build/pkgs/sphinxcontrib_jsmath/checksums.ini
+++ b/build/pkgs/sphinxcontrib_jsmath/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinxcontrib_jsmath-VERSION-py2.py3-none-any.whl
 sha1=beff4fc35d13a5f2883bc129f28ac031046195c5
-md5=4a9dbd97819fa713147472387ebd845d
-cksum=747406250
+sha256=2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178
 upstream_url=https://pypi.io/packages/py2.py3/s/sphinxcontrib_jsmath/sphinxcontrib_jsmath-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/sphinxcontrib_qthelp/checksums.ini b/build/pkgs/sphinxcontrib_qthelp/checksums.ini
index c47e8a51079..bb35693af5e 100644
--- a/build/pkgs/sphinxcontrib_qthelp/checksums.ini
+++ b/build/pkgs/sphinxcontrib_qthelp/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinxcontrib_qthelp-VERSION-py3-none-any.whl
 sha1=8f593bd6ca46487ed25ee0fca50f0d88b18e5f9e
-md5=3d3730f8492cffc8394868adad27e378
-cksum=1687408767
+sha256=e2ae3b5c492d58fcbd73281fbd27e34b8393ec34a073c792642cd8e529288182
 upstream_url=https://pypi.io/packages/py3/s/sphinxcontrib_qthelp/sphinxcontrib_qthelp-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sphinxcontrib_serializinghtml/checksums.ini b/build/pkgs/sphinxcontrib_serializinghtml/checksums.ini
index 94e0addaab8..292f6b2b195 100644
--- a/build/pkgs/sphinxcontrib_serializinghtml/checksums.ini
+++ b/build/pkgs/sphinxcontrib_serializinghtml/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinxcontrib_serializinghtml-VERSION-py3-none-any.whl
 sha1=a5198a72d1668e97fdda39a559586bcf57cb7278
-md5=2c757ab993b2dd53bf3246188e2b37ad
-cksum=1878315415
+sha256=326369b8df80a7d2d8d7f99aa5ac577f51ea51556ed974e7716cfd4fca3f6cb7
 upstream_url=https://pypi.io/packages/py3/s/sphinxcontrib_serializinghtml/sphinxcontrib_serializinghtml-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sphinxcontrib_websupport/checksums.ini b/build/pkgs/sphinxcontrib_websupport/checksums.ini
index ef1421c9146..9964fd80b13 100644
--- a/build/pkgs/sphinxcontrib_websupport/checksums.ini
+++ b/build/pkgs/sphinxcontrib_websupport/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sphinxcontrib_websupport-VERSION-py3-none-any.whl
 sha1=649d1447a4773b665588060efda66344cb9b99a5
-md5=472e9b717e65a1c130bc02696b6801f8
-cksum=906870632
+sha256=2dc179d7f821ebd54f31f93c894ca52435ebc5364e4e4dfb0da834ac119d51fd
 upstream_url=https://pypi.io/packages/py3/s/sphinxcontrib_websupport/sphinxcontrib_websupport-VERSION-py3-none-any.whl
diff --git a/build/pkgs/sqlite/checksums.ini b/build/pkgs/sqlite/checksums.ini
index 777aa3953a3..144a50566d4 100644
--- a/build/pkgs/sqlite/checksums.ini
+++ b/build/pkgs/sqlite/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sqlite-autoconf-${VERSION_MAJOR}${VERSION_MINOR}0${VERSION_MICRO}00.tar.gz
 sha1=a4bcf9e951bfb9745214241ba08476299fc2dc1e
-md5=f5752052fc5b8e1b539af86a3671eac7
-cksum=763219165
+sha256=bd90c3eb96bee996206b83be7065c9ce19aef38c3f4fb53073ada0d0b69bbce3
 upstream_url=https://www.sqlite.org/2021/sqlite-autoconf-${VERSION_MAJOR}${VERSION_MINOR}0${VERSION_MICRO}00.tar.gz
diff --git a/build/pkgs/stack_data/checksums.ini b/build/pkgs/stack_data/checksums.ini
index f86f44c1587..5761a624c1e 100644
--- a/build/pkgs/stack_data/checksums.ini
+++ b/build/pkgs/stack_data/checksums.ini
@@ -1,5 +1,4 @@
 tarball=stack_data-VERSION.tar.gz
 sha1=7f7627afc47570ffb06924c1b2fbb48e21bac724
-md5=d04f7cda6589138e90691aec1edbf0d5
-cksum=4043168585
+sha256=836a778de4fec4dcd1dcd89ed8abff8a221f58308462e1c4aa2a3cf30148f0b9
 upstream_url=https://pypi.io/packages/source/s/stack_data/stack_data-VERSION.tar.gz
diff --git a/build/pkgs/suitesparse/checksums.ini b/build/pkgs/suitesparse/checksums.ini
index fa6fbb6f9a4..e05ee205baf 100644
--- a/build/pkgs/suitesparse/checksums.ini
+++ b/build/pkgs/suitesparse/checksums.ini
@@ -1,5 +1,4 @@
 tarball=SuiteSparse-VERSION.tar.gz
 sha1=83dd96b32701e12b7577acb7d9aea80138d7e46e
-md5=68bb912f3cf3d2b01f30ebafef690302
-cksum=178881779
+sha256=acb4d1045f48a237e70294b950153e48dce5b5f9ca8190e86c2b8c54ce00a7ee
 upstream_url=https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/refs/tags/vVERSION.tar.gz
diff --git a/build/pkgs/surf/checksums.ini b/build/pkgs/surf/checksums.ini
index 8d9fde8d4f7..c0977836876 100644
--- a/build/pkgs/surf/checksums.ini
+++ b/build/pkgs/surf/checksums.ini
@@ -1,4 +1,3 @@
 tarball=surf-VERSION.tar.gz
 sha1=570dc2ab09619a907d2f6a142b0d268082cfc003
-md5=ca1a57804cc6efc7d14f285d54119b33
-cksum=2431066768
+sha256=f5e4c78c4c9c8b70e7aee2471db4b006eed2e0bd4afc0c19e3801a42c2c0a370
diff --git a/build/pkgs/symengine/checksums.ini b/build/pkgs/symengine/checksums.ini
index 9ba59940a9f..72907d5595e 100644
--- a/build/pkgs/symengine/checksums.ini
+++ b/build/pkgs/symengine/checksums.ini
@@ -1,6 +1,4 @@
 tarball=symengine-VERSION.tar.gz
 sha1=2dfee07108509963f3dbe3d9cad9de76d85e551f
-md5=4074f3c76570bdc2ae9914edafa29eb6
-cksum=3782541135
+sha256=f6972acd6a65354f6414e69460d2e175729470632bdac05919bc2f7f32e48cbd
 upstream_url=https://github.com/symengine/symengine/releases/download/vVERSION/symengine-VERSION.tar.gz
-
diff --git a/build/pkgs/symengine_py/checksums.ini b/build/pkgs/symengine_py/checksums.ini
index f8790fdfb4e..b8984f6553c 100644
--- a/build/pkgs/symengine_py/checksums.ini
+++ b/build/pkgs/symengine_py/checksums.ini
@@ -1,5 +1,4 @@
 tarball=symengine.py-VERSION.tar.gz
 sha1=4a8da0d0a057c8709c5b28543dbb3d26a060f013
-md5=d10f4ba5c27b09ef234fcafddf824ce5
-cksum=1332096394
-upstream_url=https://pypi.io/packages/source/p/symengine/symengine-VERSION.tar.gz
+sha256=0dd30d29b804ebb7251bddec29c38c3b1fc15ea6953a2c57ee758d5f6fcba458
+upstream_url=https://pypi.io/packages/source/s/symengine/symengine-VERSION.tar.gz
diff --git a/build/pkgs/symengine_py/spkg-install.in b/build/pkgs/symengine_py/spkg-install.in
index 37ac1a53437..829ebe2fcc5 100644
--- a/build/pkgs/symengine_py/spkg-install.in
+++ b/build/pkgs/symengine_py/spkg-install.in
@@ -1,2 +1,7 @@
+if [ "$UNAME" = "Darwin" ]; then
+    LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib"
+    export LDFLAGS
+fi
+
 cd src
 sdh_pip_install .
diff --git a/build/pkgs/symmetrica/checksums.ini b/build/pkgs/symmetrica/checksums.ini
index 6d06ebda462..07664bc3183 100644
--- a/build/pkgs/symmetrica/checksums.ini
+++ b/build/pkgs/symmetrica/checksums.ini
@@ -1,5 +1,4 @@
 tarball=symmetrica-VERSION.tar.xz
 sha1=0044cc087ff04267c246e730c6570d89f6e593af
-md5=cd4716c26b5c625a012c22656113ef6f
-cksum=1186250347
+sha256=05ae107ec41f38cada19c26b6d7884970cbafae6e3b55ec3964896230358b456
 upstream_url=http://users.ox.ac.uk/~coml0531/sage/symmetrica-VERSION.tar.xz
diff --git a/build/pkgs/sympow/checksums.ini b/build/pkgs/sympow/checksums.ini
index 87bf0086178..30eff47b596 100644
--- a/build/pkgs/sympow/checksums.ini
+++ b/build/pkgs/sympow/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sympow-vVERSION.tar.gz
 sha1=37a909c26009415197b5088a2f1b53dd3558f494
-md5=51f2c717c84ec9c2840af740751cf797
-cksum=1444149964
+sha256=53631afa6c68dd008400681af0fe1d60ada36716215449f2a668853ed04455ac
 upstream_url=https://github.com/mkoeppe/sympow/releases/download/vVERSION/sympow-vVERSION.tar.gz
diff --git a/build/pkgs/sympy/checksums.ini b/build/pkgs/sympy/checksums.ini
index 72ea62bb91f..4a8b9107b71 100644
--- a/build/pkgs/sympy/checksums.ini
+++ b/build/pkgs/sympy/checksums.ini
@@ -1,5 +1,4 @@
 tarball=sympy-VERSION.tar.gz
 sha1=604968f191e2d69053b8310066d089f73a1bd109
-md5=3e0033109352d7303ea97b9216e16645
-cksum=2437095035
+sha256=ebf595c8dac3e0fdc4152c51878b498396ec7f30e7a914d6071e674d49420fb8
 upstream_url=https://github.com/sympy/sympy/releases/download/sympy-VERSION/sympy-VERSION.tar.gz
diff --git a/build/pkgs/tachyon/checksums.ini b/build/pkgs/tachyon/checksums.ini
index 0300429a939..bd19e444c37 100644
--- a/build/pkgs/tachyon/checksums.ini
+++ b/build/pkgs/tachyon/checksums.ini
@@ -1,4 +1,3 @@
 tarball=tachyon-VERSION.tar.bz2
 sha1=9866dc93e129115994708efa6e7ca16e20d58237
-md5=fac22f4a5f675229bcc14264af4e7b81
-cksum=3876215200
+sha256=e8888a410610e2726dca32f40f31ff34a83cb474b41e5a1e0ac8bbb175e1a466
diff --git a/build/pkgs/tdlib/checksums.ini b/build/pkgs/tdlib/checksums.ini
index 7f557c54f86..6f3275ad092 100644
--- a/build/pkgs/tdlib/checksums.ini
+++ b/build/pkgs/tdlib/checksums.ini
@@ -1,4 +1,3 @@
 tarball=tdlib-VERSION.tar.gz
 sha1=8e200d0e3ac009030f3ada6658d20717e433220f
-md5=6bd9e7d9dae616079d511658f70eff73
-cksum=2382384273
+sha256=5a40375e738e9e6dbd37f53e54deb1efa6b58f154d83b7bfeaee9f47d47b444b
diff --git a/build/pkgs/terminado/checksums.ini b/build/pkgs/terminado/checksums.ini
index be9b273fa2b..ce9c0407bad 100644
--- a/build/pkgs/terminado/checksums.ini
+++ b/build/pkgs/terminado/checksums.ini
@@ -1,5 +1,4 @@
 tarball=terminado-VERSION.tar.gz
 sha1=608fcc44b845e1fb783e361d59e79fba83126e14
-md5=aafcc42623986e42469712786edb127c
-cksum=3344744872
+sha256=6ccbbcd3a4f8a25a5ec04991f39a0b8db52dfcd487ea0e578d977e6752380333
 upstream_url=https://pypi.io/packages/source/t/terminado/terminado-VERSION.tar.gz
diff --git a/build/pkgs/texlive_luatex/distros/arch.txt b/build/pkgs/texlive_luatex/distros/arch.txt
index 2eec092a978..d2b702df88a 100644
--- a/build/pkgs/texlive_luatex/distros/arch.txt
+++ b/build/pkgs/texlive_luatex/distros/arch.txt
@@ -1 +1 @@
-texlive-collection-luatex
+texlive-luatex
diff --git a/build/pkgs/texttable/checksums.ini b/build/pkgs/texttable/checksums.ini
index d8725b785b2..3446dba447f 100644
--- a/build/pkgs/texttable/checksums.ini
+++ b/build/pkgs/texttable/checksums.ini
@@ -1,5 +1,4 @@
 tarball=texttable-VERSION.tar.gz
 sha1=0fa175fa6e0fefea31434746641bedc8cbb60248
-md5=e5d380c04fab132ccf0bbfd4f761bd51
-cksum=274394355
+sha256=2d2068fb55115807d3ac77a4ca68fa48803e84ebb0ee2340f858107a36522638
 upstream_url=https://pypi.io/packages/source/t/texttable/texttable-VERSION.tar.gz
diff --git a/build/pkgs/threejs/checksums.ini b/build/pkgs/threejs/checksums.ini
index 8fd18f13afd..4786adc786f 100644
--- a/build/pkgs/threejs/checksums.ini
+++ b/build/pkgs/threejs/checksums.ini
@@ -1,5 +1,4 @@
 tarball=threejs-sage-VERSION.tar.gz
 sha1=db7910b25fe9df7849528cffd06f2a40a90c82c0
-md5=ba8faf405988e066d8ce7e176f3624f2
-cksum=2491453519
+sha256=718767ab55876a3e957d1cfe89a322c6d9fa680fc737b9ca668aee6a3eac3bb8
 upstream_url=https://github.com/sagemath/threejs-sage/archive/VERSION.tar.gz
diff --git a/build/pkgs/tides/checksums.ini b/build/pkgs/tides/checksums.ini
index f75423db3a7..a54e2bdebd1 100644
--- a/build/pkgs/tides/checksums.ini
+++ b/build/pkgs/tides/checksums.ini
@@ -1,4 +1,3 @@
 tarball=tides-VERSION.tar.gz
 sha1=2a70d8e08c364abff3314b9f15022aba2b62c1e7
-md5=200db1104c40f0c4f7bce806c773c87f
-cksum=2240108013
+sha256=9ba5490f7c22f7a56f23d29dcb314df9811bd82dd21d5e19b3cca5a9d86d919a
diff --git a/build/pkgs/tinycss2/checksums.ini b/build/pkgs/tinycss2/checksums.ini
index c905e293396..a6abd957086 100644
--- a/build/pkgs/tinycss2/checksums.ini
+++ b/build/pkgs/tinycss2/checksums.ini
@@ -1,5 +1,4 @@
 tarball=tinycss2-VERSION.tar.gz
 sha1=3871ffec30bde346d1a17f80a423dce488bad4f7
-md5=e8a06102e7f42ca791463f11ce7b814d
-cksum=1840765267
+sha256=8cff3a8f066c2ec677c06dbc7b45619804a6938478d9d73c284b29d14ecb0627
 upstream_url=https://pypi.io/packages/source/t/tinycss2/tinycss2-VERSION.tar.gz
diff --git a/build/pkgs/tomli/checksums.ini b/build/pkgs/tomli/checksums.ini
index f2edcb641cb..00d70337b2b 100644
--- a/build/pkgs/tomli/checksums.ini
+++ b/build/pkgs/tomli/checksums.ini
@@ -1,5 +1,4 @@
 tarball=tomli-VERSION-py3-none-any.whl
 sha1=5bfc83c14bc54e6193a0d50a50c16a88eda0c4fa
-md5=a8a774971c6d046cf1c87cd801dd158f
-cksum=891457836
+sha256=939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc
 upstream_url=https://pypi.io/packages/py3/t/tomli/tomli-VERSION-py3-none-any.whl
diff --git a/build/pkgs/topcom/checksums.ini b/build/pkgs/topcom/checksums.ini
index 764c422b5ac..1a00b4da1ec 100644
--- a/build/pkgs/topcom/checksums.ini
+++ b/build/pkgs/topcom/checksums.ini
@@ -1,5 +1,4 @@
 tarball=TOPCOM-1_1_2.tgz
 sha1=65db8c00309f3bf8467ee5ba9da109c196db3461
-md5=dbda1ae7946251c9502444ee9b0a2c62
-cksum=1598684291
+sha256=4fb10754ee5b76056441fea98f2c8dee5db6f2984d8c14283b49239ad4378ab6
 upstream_url=https://users.ox.ac.uk/~coml0531/tmp/TOPCOM-1_1_2.tgz
diff --git a/build/pkgs/tornado/checksums.ini b/build/pkgs/tornado/checksums.ini
index 08508eba5d2..9cc0e020c01 100644
--- a/build/pkgs/tornado/checksums.ini
+++ b/build/pkgs/tornado/checksums.ini
@@ -1,5 +1,4 @@
 tarball=tornado-VERSION.tar.gz
 sha1=5b4036313660a74034186ac63b10d244ca9444b8
-md5=460b467761e5ff74202b5bf8054c8116
-cksum=3932629794
+sha256=72291fa6e6bc84e626589f1c29d90a5a6d593ef5ae68052ee2ef000dfd273dee
 upstream_url=https://pypi.io/packages/source/t/tornado/tornado-VERSION.tar.gz
diff --git a/build/pkgs/tox/checksums.ini b/build/pkgs/tox/checksums.ini
index caf44efe123..fa5a87fb673 100644
--- a/build/pkgs/tox/checksums.ini
+++ b/build/pkgs/tox/checksums.ini
@@ -1,5 +1,4 @@
 tarball=tox-VERSION-py3-none-any.whl
 sha1=d3312285c4988d3307d3b000a8a18cfcb16aea29
-md5=127a9d3fae61a0967f14ab6d59fd118f
-cksum=4147794288
+sha256=da761b4a57ee2b92b5ce39f48ff723fc42d185bf2af508effb683214efa662ea
 upstream_url=https://pypi.io/packages/py3/t/tox/tox-VERSION-py3-none-any.whl
diff --git a/build/pkgs/traitlets/checksums.ini b/build/pkgs/traitlets/checksums.ini
index 711eb90d8f5..4be4683da86 100644
--- a/build/pkgs/traitlets/checksums.ini
+++ b/build/pkgs/traitlets/checksums.ini
@@ -1,5 +1,4 @@
 tarball=traitlets-VERSION.tar.gz
 sha1=9f4cb2a04ffba7029ad67bbec3d39a23e9095db2
-md5=63c6bb056dec2a062a854d90fa6b4933
-cksum=2387245107
+sha256=fcdaa8ac49c04dfa0ed3ee3384ef6dfdb5d6f3741502be247279407679296772
 upstream_url=https://pypi.io/packages/source/t/traitlets/traitlets-VERSION.tar.gz
diff --git a/build/pkgs/trove_classifiers/checksums.ini b/build/pkgs/trove_classifiers/checksums.ini
index 8bd0eca4933..8d25c121cc2 100644
--- a/build/pkgs/trove_classifiers/checksums.ini
+++ b/build/pkgs/trove_classifiers/checksums.ini
@@ -1,5 +1,4 @@
 tarball=trove_classifiers-VERSION-py3-none-any.whl
 sha1=36240d053d16400380aee01f0879785693008a96
-md5=02b3e7b2eb81c3656fa859a87482f120
-cksum=1500381935
+sha256=678bd6fcc5218d72e3304e27a608acc9b91e17bd00c3f3d8c968497c843ad98b
 upstream_url=https://pypi.io/packages/py3/t/trove_classifiers/trove_classifiers-VERSION-py3-none-any.whl
diff --git a/build/pkgs/types_python_dateutil/checksums.ini b/build/pkgs/types_python_dateutil/checksums.ini
index f0dc860781b..6ebc189c635 100644
--- a/build/pkgs/types_python_dateutil/checksums.ini
+++ b/build/pkgs/types_python_dateutil/checksums.ini
@@ -1,5 +1,4 @@
 tarball=types_python_dateutil-VERSION-py3-none-any.whl
 sha1=c039b93ad4b5f3ea1c6aac3d08386995e8c7b19e
-md5=6281a2b67e2347366238ef28e3f8a070
-cksum=1399426019
+sha256=f977b8de27787639986b4e28963263fd0e5158942b3ecef91b9335c130cb1ce9
 upstream_url=https://pypi.io/packages/py3/t/types_python_dateutil/types_python_dateutil-VERSION-py3-none-any.whl
diff --git a/build/pkgs/typing_extensions/checksums.ini b/build/pkgs/typing_extensions/checksums.ini
index babfa059d5c..2c1dd61052d 100644
--- a/build/pkgs/typing_extensions/checksums.ini
+++ b/build/pkgs/typing_extensions/checksums.ini
@@ -1,5 +1,4 @@
 tarball=typing_extensions-VERSION-py3-none-any.whl
 sha1=84d6a73b5a5d303c9187a861d5eedd50da42e7a3
-md5=9c84e613da80ced7a5e86329ec75dc6c
-cksum=2951292774
+sha256=8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0
 upstream_url=https://pypi.io/packages/py3/t/typing_extensions/typing_extensions-VERSION-py3-none-any.whl
diff --git a/build/pkgs/typing_extensions/spkg-configure.m4 b/build/pkgs/typing_extensions/spkg-configure.m4
index fec3271a44b..6fa102774d4 100644
--- a/build/pkgs/typing_extensions/spkg-configure.m4
+++ b/build/pkgs/typing_extensions/spkg-configure.m4
@@ -1,24 +1,27 @@
-SAGE_SPKG_CONFIGURE([typing_extensions],[
+SAGE_SPKG_CONFIGURE([typing_extensions], [dnl
   SAGE_PYTHON_PACKAGE_CHECK([typing_extensions])
 ],[
-  # Three of our python packages are backport packages providing
-  # python-3.11 features (see coding_in_python.rst):
-  #
-  #   * importlib_metadata
-  #   * importlib_resources
-  #   * typing_extensions
-  #
-  # These packages are therefore not needed with >=python-3.11. Here
-  # we test for a python minor version component greater than or equal
-  # to 11, and mark this package as "not required" if we succeed.
-  AC_MSG_CHECKING([for >=python-3.11])
-
-  # Keep in mind that False (~ zero) in python is success in the shell
-  AS_IF(["${PYTHON_FOR_VENV}" -c "import sys; sys.exit(sys.version_info.minor < 11)"],[
-    AC_MSG_RESULT([yes])
+  dnl Three of our python packages are backport packages providing
+  dnl python-3.11 features (see coding_in_python.rst):
+  dnl
+  dnl   * importlib_metadata
+  dnl   * importlib_resources
+  dnl   * typing_extensions
+  dnl
+  dnl These packages are therefore not needed with >=python-3.11. Here
+  dnl we test for a python minor version component greater than or equal
+  dnl to 11, and mark this package as "not required" if we succeed.
+  AS_IF([test -z "${PYTHON_FOR_VENV}"], [dnl
+    dnl Python from our SPKG is new enough, no need for the backport package.
     sage_require_typing_extensions="no"
-  ],[
-    AC_MSG_RESULT([no])
+  ], [dnl
+    AC_MSG_CHECKING([for >=python-3.11])
+    dnl Keep in mind that False (~ zero) in python is success in the shell
+    AS_IF(["${PYTHON_FOR_VENV}" -c "import sys; sys.exit(sys.version_info.minor < 11)"], [dnl
+      AC_MSG_RESULT([yes])
+      sage_require_typing_extensions="no"
+    ],[dnl
+      AC_MSG_RESULT([no])
+    ])
   ])
 ])
-
diff --git a/build/pkgs/tzdata/checksums.ini b/build/pkgs/tzdata/checksums.ini
index 342e71f3761..449a195f648 100644
--- a/build/pkgs/tzdata/checksums.ini
+++ b/build/pkgs/tzdata/checksums.ini
@@ -1,5 +1,4 @@
 tarball=tzdata-VERSION-py2.py3-none-any.whl
 sha1=4686c7c91a01d5af9075903937c343afa05c141b
-md5=5e534124c0c916ab617421247649b193
-cksum=2929397850
+sha256=7e65763eef3120314099b6939b5546db7adce1e7d6f2e179e3df563c70511eda
 upstream_url=https://pypi.io/packages/py2.py3/t/tzdata/tzdata-VERSION-py2.py3-none-any.whl
diff --git a/build/pkgs/tzlocal/checksums.ini b/build/pkgs/tzlocal/checksums.ini
index eb9533b0f63..5c246c69ced 100644
--- a/build/pkgs/tzlocal/checksums.ini
+++ b/build/pkgs/tzlocal/checksums.ini
@@ -1,5 +1,4 @@
 tarball=tzlocal-VERSION.tar.gz
 sha1=1d61e52edddf882c9af4f5f3f1be0db3788dd7b5
-md5=c209a72fd296ff6e1a98d55c2382ba79
-cksum=1644259932
+sha256=46eb99ad4bdb71f3f72b7d24f4267753e240944ecfc16f25d2719ba89827a803
 upstream_url=https://pypi.io/packages/source/t/tzlocal/tzlocal-VERSION.tar.gz
diff --git a/build/pkgs/uri_template/checksums.ini b/build/pkgs/uri_template/checksums.ini
index cdcfc0caeaa..601b51db908 100644
--- a/build/pkgs/uri_template/checksums.ini
+++ b/build/pkgs/uri_template/checksums.ini
@@ -1,5 +1,4 @@
 tarball=uri_template-VERSION-py3-none-any.whl
 sha1=bbc8808bdb7e687f0c099c8120cd901dc90bce69
-md5=7d7f28c2ffd7d4746174ab761f6025e5
-cksum=1943559906
+sha256=a44a133ea12d44a0c0f06d7d42a52d71282e77e2f937d8abd5655b8d56fc1363
 upstream_url=https://pypi.io/packages/py3/u/uri_template/uri_template-VERSION-py3-none-any.whl
diff --git a/build/pkgs/urllib3/checksums.ini b/build/pkgs/urllib3/checksums.ini
index 6967bd9a90c..1fbf6f0991c 100644
--- a/build/pkgs/urllib3/checksums.ini
+++ b/build/pkgs/urllib3/checksums.ini
@@ -1,5 +1,4 @@
 tarball=urllib3-VERSION-py3-none-any.whl
 sha1=1e197082cd0d0f98bc97f2fbfd7d2a597e3ff3e4
-md5=56a1919e2243cc6af59b23c06eda3783
-cksum=3597756225
+sha256=55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3
 upstream_url=https://pypi.io/packages/py3/u/urllib3/urllib3-VERSION-py3-none-any.whl
diff --git a/build/pkgs/valgrind/checksums.ini b/build/pkgs/valgrind/checksums.ini
index 242642cedef..3ffe6ab866a 100644
--- a/build/pkgs/valgrind/checksums.ini
+++ b/build/pkgs/valgrind/checksums.ini
@@ -1,4 +1,3 @@
 tarball=valgrind-VERSION.tar.bz2
 sha1=182afd405b92ddb6f52c6729e848eacf4b1daf46
-md5=74175426afa280184b62591b58c671b3
-cksum=2472830850
+sha256=037c11bfefd477cc6e9ebe8f193bb237fe397f7ce791b4a4ce3fa1c6a520baa5
diff --git a/build/pkgs/virtualenv/checksums.ini b/build/pkgs/virtualenv/checksums.ini
index 90a2a903926..386df56a132 100644
--- a/build/pkgs/virtualenv/checksums.ini
+++ b/build/pkgs/virtualenv/checksums.ini
@@ -1,5 +1,4 @@
 tarball=virtualenv-VERSION-py3-none-any.whl
 sha1=9c942063d76d85361f0567b59cce8238c57f1183
-md5=7dec1148d91180767ae908dc49a7ebf5
-cksum=3612060825
+sha256=4238949c5ffe6876362d9c0180fc6c3a824a7b12b80604eeb8085f2ed7460de3
 upstream_url=https://pypi.io/packages/py3/v/virtualenv/virtualenv-VERSION-py3-none-any.whl
diff --git a/build/pkgs/wcwidth/checksums.ini b/build/pkgs/wcwidth/checksums.ini
index 2745366a726..18801e12105 100644
--- a/build/pkgs/wcwidth/checksums.ini
+++ b/build/pkgs/wcwidth/checksums.ini
@@ -1,5 +1,4 @@
 tarball=wcwidth-VERSION.tar.gz
 sha1=49bdbcac346f31be8201c663082331b693264382
-md5=c37cceb9d573adcce0b3e5167ecb1df9
-cksum=68756555
+sha256=f01c104efdf57971bcb756f054dd58ddec5204dd15fa31d6503ea57947d97c02
 upstream_url=https://pypi.io/packages/source/w/wcwidth/wcwidth-VERSION.tar.gz
diff --git a/build/pkgs/webcolors/checksums.ini b/build/pkgs/webcolors/checksums.ini
index 4a7e6f5de15..2db93e1e869 100644
--- a/build/pkgs/webcolors/checksums.ini
+++ b/build/pkgs/webcolors/checksums.ini
@@ -1,5 +1,4 @@
 tarball=webcolors-VERSION-py3-none-any.whl
 sha1=e13a9143964b824fc4972b60eddd8115f6839a26
-md5=d9e9ac7c1da7a2b18975265cf0a953ac
-cksum=371137261
+sha256=29bc7e8752c0a1bd4a1f03c14d6e6a72e93d82193738fa860cbff59d0fcc11bf
 upstream_url=https://pypi.io/packages/py3/w/webcolors/webcolors-VERSION-py3-none-any.whl
diff --git a/build/pkgs/webencodings/checksums.ini b/build/pkgs/webencodings/checksums.ini
index 1f1d3fd16a4..2f82dab8136 100644
--- a/build/pkgs/webencodings/checksums.ini
+++ b/build/pkgs/webencodings/checksums.ini
@@ -1,4 +1,3 @@
 tarball=webencodings-VERSION.tar.gz
 sha1=fd870193fde74183c0e1cd43bce01a4a930cd049
-md5=32f6e261d52e57bf7e1c4d41546d15b8
-cksum=777885313
+sha256=b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923
diff --git a/build/pkgs/websocket_client/checksums.ini b/build/pkgs/websocket_client/checksums.ini
index 5ebee45e9f9..6cc10d23812 100644
--- a/build/pkgs/websocket_client/checksums.ini
+++ b/build/pkgs/websocket_client/checksums.ini
@@ -1,5 +1,4 @@
 tarball=websocket_client-VERSION-py3-none-any.whl
 sha1=eb78bd39f1ae4d531cc965bd21d121ba3d156f84
-md5=bea7b61d0eda66ffb9071c469d937255
-cksum=21706746
+sha256=084072e0a7f5f347ef2ac3d8698a5e0b4ffbfcab607628cadabc650fc9a83a24
 upstream_url=https://pypi.io/packages/py3/w/websocket_client/websocket_client-VERSION-py3-none-any.whl
diff --git a/build/pkgs/wheel/checksums.ini b/build/pkgs/wheel/checksums.ini
index 6e28451ce44..ea4d40c1f27 100644
--- a/build/pkgs/wheel/checksums.ini
+++ b/build/pkgs/wheel/checksums.ini
@@ -1,5 +1,4 @@
 tarball=wheel-VERSION-py3-none-any.whl
 sha1=71a83a2237cb57ab45bdafed364564e36ca5dc95
-md5=e65b1197e1dfc6bbc8df362935f5943d
-cksum=1664872683
+sha256=55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81
 upstream_url=https://pypi.io/packages/py3/w/wheel/wheel-VERSION-py3-none-any.whl
diff --git a/build/pkgs/widgetsnbextension/checksums.ini b/build/pkgs/widgetsnbextension/checksums.ini
index 6c7893d9502..099c0acb09e 100644
--- a/build/pkgs/widgetsnbextension/checksums.ini
+++ b/build/pkgs/widgetsnbextension/checksums.ini
@@ -1,5 +1,4 @@
 tarball=widgetsnbextension-VERSION-py3-none-any.whl
 sha1=067535b5d1738a4de0abb5f1219581a4a66d243c
-md5=ac2760673371602f990bb24ac7925c5f
-cksum=1509404095
+sha256=91452ca8445beb805792f206e560c1769284267a30ceb1cec9f5bcc887d15175
 upstream_url=https://pypi.io/packages/py3/w/widgetsnbextension/widgetsnbextension-VERSION-py3-none-any.whl
diff --git a/build/pkgs/xz/checksums.ini b/build/pkgs/xz/checksums.ini
index 6fa58c3a084..6e4c2226c96 100644
--- a/build/pkgs/xz/checksums.ini
+++ b/build/pkgs/xz/checksums.ini
@@ -1,5 +1,4 @@
 tarball=xz-VERSION.tar.gz
 sha1=fa2ae4db119f639a01b02f99f1ba671ece2828eb
-md5=0d270c997aff29708c74d53f599ef717
-cksum=1153713708
+sha256=f6f4910fd033078738bd82bfba4f49219d03b17eb0794eb91efbae419f4aba10
 upstream_url=https://tukaani.org/xz/xz-VERSION.tar.gz
diff --git a/build/pkgs/zeromq/checksums.ini b/build/pkgs/zeromq/checksums.ini
index bc7f6b0c8b1..dfa643cc6e7 100644
--- a/build/pkgs/zeromq/checksums.ini
+++ b/build/pkgs/zeromq/checksums.ini
@@ -1,5 +1,4 @@
 tarball=zeromq-VERSION.tar.gz
 sha1=bdbf686c8a40ba638e21cf74e34dbb425e108500
-md5=ae933b1e98411fd7cb8309f9502d2737
-cksum=1351453048
+sha256=6653ef5910f17954861fe72332e68b03ca6e4d9c7160eb3a8de5a5a913bfab43
 upstream_url=https://github.com/zeromq/libzmq/releases/download/vVERSION/zeromq-VERSION.tar.gz
diff --git a/build/pkgs/zipp/checksums.ini b/build/pkgs/zipp/checksums.ini
index 7c9d001b307..aef55046c00 100644
--- a/build/pkgs/zipp/checksums.ini
+++ b/build/pkgs/zipp/checksums.ini
@@ -1,5 +1,4 @@
 tarball=zipp-VERSION-py3-none-any.whl
 sha1=8dd92e1b777b02ec6e1ebe72926d32a82c58b246
-md5=d93f0b8485000b37800a6de09ed6c1cb
-cksum=3547254189
+sha256=0e923e726174922dce09c53c59ad483ff7bbb8e572e00c7f7c46b88556409f31
 upstream_url=https://pypi.io/packages/py3/z/zipp/zipp-VERSION-py3-none-any.whl
diff --git a/build/pkgs/zlib/checksums.ini b/build/pkgs/zlib/checksums.ini
index 4b1b46adcaa..5c0549d268c 100644
--- a/build/pkgs/zlib/checksums.ini
+++ b/build/pkgs/zlib/checksums.ini
@@ -1,4 +1,3 @@
 tarball=zlib-VERSION.tar.gz
 sha1=e6d119755acdf9104d7ba236b1242696940ed6dd
-md5=1c9f62f0778697a09d36121ead88e08e
-cksum=2150653187
+sha256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
diff --git a/build/sage_bootstrap/app.py b/build/sage_bootstrap/app.py
index cf11e3c4da7..018e5a2d5b5 100644
--- a/build/sage_bootstrap/app.py
+++ b/build/sage_bootstrap/app.py
@@ -387,7 +387,7 @@ def fix_checksum(self, package_name):
         if not os.path.exists(pkg.tarball.upstream_fqn):
             log.info('Ignoring {0} because tarball is not cached'.format(package_name))
             return
-        if pkg.tarball.checksum_verifies():
+        if pkg.tarball.checksum_verifies(force_sha256=True):
             log.info('Checksum of {0} (tarball {1}) unchanged'.format(package_name, pkg.tarball_filename))
         else:
             log.info('Updating checksum of {0} (tarball {1})'.format(package_name, pkg.tarball_filename))
diff --git a/build/sage_bootstrap/cksum.py b/build/sage_bootstrap/cksum.py
deleted file mode 100644
index e507aee3941..00000000000
--- a/build/sage_bootstrap/cksum.py
+++ /dev/null
@@ -1,96 +0,0 @@
-"""
-The unix cksum tool
-
-This is a weak checksum, only included for legacy reasons.
-"""
-
-# Fun table, e.g. http://www.nco.ncep.noaa.gov/pmb/codes/nwprod/util/sorc/wgrib2.cd/grib2/wgrib2/crc32.c
-
-crctab = [
-    0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc,
-    0x17c56b6b, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f,
-    0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a,
-    0x384fbdbd, 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9,
-    0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8,
-    0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3,
-    0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e,
-    0x95609039, 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
-    0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84,
-    0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, 0xd4326d90, 0xd0f37027,
-    0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022,
-    0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
-    0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077,
-    0x30476dc0, 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c,
-    0x2e003dc5, 0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1,
-    0x1fcdbb16, 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
-    0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb,
-    0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08,
-    0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d,
-    0x40d816ba, 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e,
-    0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f,
-    0x8e6c3698, 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044,
-    0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050, 0xe9362689,
-    0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
-    0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683,
-    0xd1799b34, 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59,
-    0x608edb80, 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c,
-    0x774bb0eb, 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f,
-    0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e,
-    0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5,
-    0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48,
-    0x0e56f0ff, 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
-    0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2,
-    0xe6ea3d65, 0xeba91bbc, 0xef68060b, 0xd727bbb6, 0xd3e6a601,
-    0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604,
-    0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
-    0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6,
-    0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad,
-    0x81b02d74, 0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7,
-    0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
-    0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd,
-    0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e,
-    0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b,
-    0x0fdc1bec, 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088,
-    0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, 0xc5a92679,
-    0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12,
-    0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af,
-    0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
-    0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5,
-    0x9e7d9662, 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06,
-    0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03,
-    0xb1f740b4]
-
-
-def UNSIGNED(n):
-    return n & 0xffffffff
-
-
-class CksumAlgorithm(object):
-
-    def __init__(self):
-        self._value = 0
-        self._length = 0
-
-    def update(self, buffer):
-        value = self._value
-        if isinstance(buffer, str):
-            buffer = list(map(ord, list(buffer)))
-        else:
-            buffer = list(buffer)
-        for ch in buffer:
-            tabidx = (value >> 24) ^ ch
-            value = UNSIGNED((value << 8)) ^ crctab[tabidx]
-        self._value = value
-        self._length += len(buffer)
-
-    def get_value(self):
-        n = self._length
-        value = self._value
-        while n:
-            c = n & 0o377
-            n = n >> 8
-            value = UNSIGNED(value << 8) ^ crctab[(value >> 24) ^ c]
-        return UNSIGNED(~value)
-
-    def hexdigest(self):
-        return str(self.get_value())
diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
index 176e842e43b..bc607ebb6e6 100644
--- a/build/sage_bootstrap/package.py
+++ b/build/sage_bootstrap/package.py
@@ -107,19 +107,6 @@ def name(self):
         """
         return self.__name
 
-    @property
-    def md5(self):
-        """
-        Return the MD5 checksum
-
-        Do not use, this is ancient! Use :meth:`sha1` instead.
-
-        OUTPUT:
-
-        String.
-        """
-        return self.__md5
-
     @property
     def sha1(self):
         """
@@ -132,17 +119,15 @@ def sha1(self):
         return self.__sha1
 
     @property
-    def cksum(self):
+    def sha256(self):
         """
-        Return the Ck sum checksum
-
-        Do not use, this is ancient! Use :meth:`sha1` instead.
+        Return the SHA256 checksum
 
         OUTPUT:
 
         String.
         """
-        return self.__cksum
+        return self.__sha256
 
     @property
     def tarball(self):
@@ -539,9 +524,8 @@ def _init_checksum(self):
                     result[var] = value
         except IOError:
             pass
-        self.__md5 = result.get('md5', None)
         self.__sha1 = result.get('sha1', None)
-        self.__cksum = result.get('cksum', None)
+        self.__sha256 = result.get('sha256', None)
         self.__tarball_pattern = result.get('tarball', None)
         self.__tarball_upstream_url_pattern = result.get('upstream_url', None)
         # Name of the directory containing the checksums.ini file
diff --git a/build/sage_bootstrap/tarball.py b/build/sage_bootstrap/tarball.py
index c974d8ac310..54af50dd8f8 100644
--- a/build/sage_bootstrap/tarball.py
+++ b/build/sage_bootstrap/tarball.py
@@ -119,18 +119,23 @@ def _compute_sha1(self):
         import hashlib
         return self._compute_hash(hashlib.sha1())
 
-    def _compute_md5(self):
+    def _compute_sha256(self):
         import hashlib
-        return self._compute_hash(hashlib.md5())
+        return self._compute_hash(hashlib.sha256())
 
-    def _compute_cksum(self):
-        from sage_bootstrap.cksum import CksumAlgorithm
-        return self._compute_hash(CksumAlgorithm())
-
-    def checksum_verifies(self):
+    def checksum_verifies(self, force_sha256=False):
         """
         Test whether the checksum of the downloaded file is correct.
         """
+        if self.package.sha256:
+            sha256 = self._compute_sha256()
+            if sha256 != self.package.sha256:
+                return False
+        elif force_sha256:
+            log.warning('sha256 not available for {0}'.format(self.package.name))
+            return False
+        else:
+            log.warning('sha256 not available for {0}, using sha1'.format(self.package.name))
         sha1 = self._compute_sha1()
         return sha1 == self.package.sha1
 
diff --git a/build/sage_bootstrap/updater.py b/build/sage_bootstrap/updater.py
index 67f1c961124..7631e83b9cf 100644
--- a/build/sage_bootstrap/updater.py
+++ b/build/sage_bootstrap/updater.py
@@ -45,8 +45,7 @@ def checksums_ini(self):
         result = [
             'tarball=' + self.package.tarball_pattern,
             'sha1=' + tarball._compute_sha1(),
-            'md5=' + tarball._compute_md5(),
-            'cksum=' + tarball._compute_cksum()
+            'sha256=' + tarball._compute_sha256()
         ]
         if self.package.tarball_upstream_url_pattern:
             result.append('upstream_url=' + self.package.tarball_upstream_url_pattern)
diff --git a/build/test/test_cksum.py b/build/test/test_cksum.py
deleted file mode 100644
index e3bf0564813..00000000000
--- a/build/test/test_cksum.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# ****************************************************************************
-#       Copyright (C) 2015 Volker Braun 
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#                  https://www.gnu.org/licenses/
-# ****************************************************************************
-
-
-import unittest
-from sage_bootstrap.cksum import CksumAlgorithm
-
-
-class CksumTestCase(unittest.TestCase):
-
-    def test_cksum_bytes(self):
-        cksum = CksumAlgorithm()
-        cksum.update(b'The quick brown fox jumps over the lazy dog\n')
-        self.assertEqual(cksum.hexdigest(), '2382472371')
-
-    def test_cksum_string(self):
-        cksum = CksumAlgorithm()
-        cksum.update('The quick brown fox jumps over the lazy dog\n')
-        self.assertEqual(cksum.hexdigest(), '2382472371')
diff --git a/configure.ac b/configure.ac
index 7816aca796e..764d8a43d82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,8 +135,19 @@ AC_ARG_ENABLE([editable],
 AC_ARG_ENABLE([wheels],
               [AS_HELP_STRING([--enable-wheels],
                               [build wheels for the Sage library and update them on "sage -b"; if disabled, use "make wheels" to build wheels])],
-              [AC_SUBST([SAGE_WHEELS], [$enableval])],
-              [])
+              [dnl
+                 AS_VAR_IF([SAGE_EDITABLE], [yes], [dnl
+                 ], [dnl
+                   AC_MSG_NOTICE([direct installation of the Sage library (--disable-editable --disable-wheels) is no longer supported; ignoring --disable-wheels])
+                 ])
+                 AC_SUBST([SAGE_WHEELS], [$enableval])
+              ], [dnl
+                 AS_VAR_IF([SAGE_EDITABLE], [yes], [dnl
+                   AC_SUBST([SAGE_WHEELS], [no])
+                 ], [dnl
+                   AC_SUBST([SAGE_WHEELS], [yes])
+                 ])
+              ])
 
 # Check whether we are on a supported platform
 AC_CANONICAL_BUILD()
diff --git a/docker/Dockerfile b/docker/Dockerfile
index cc0701d8d81..a74b451bc3b 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -230,8 +230,10 @@ FROM run-time-dependencies as sagemath
 ARG HOME=/home/sage
 ARG SAGE_ROOT=/home/sage/sage
 COPY --chown=sage:sage --from=make-release $SAGE_ROOT/ $SAGE_ROOT/
-# Put scripts to start gap, gp, maxima, ... in /usr/bin
-RUN sudo $SAGE_ROOT/sage --nodotsage -c "install_scripts('/usr/bin')"
+# set path in bashrc to start gap, gp, maxima, ... this does not
+# affect Sage (see https://github.com/sagemath/sage/pull/38049)
+RUN echo "export PATH=$SAGE_ROOT/local/bin:$PATH" >> ~/.bashrc
+
 COPY ./docker/entrypoint.sh /usr/local/bin/sage-entrypoint
 WORKDIR $HOME
 ENTRYPOINT ["/usr/local/bin/sage-entrypoint"]
diff --git a/pkgs/sage-conf/VERSION.txt b/pkgs/sage-conf/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sage-conf/VERSION.txt
+++ b/pkgs/sage-conf/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sage-conf_conda/VERSION.txt b/pkgs/sage-conf_conda/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sage-conf_conda/VERSION.txt
+++ b/pkgs/sage-conf_conda/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sage-conf_pypi/VERSION.txt b/pkgs/sage-conf_pypi/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sage-conf_pypi/VERSION.txt
+++ b/pkgs/sage-conf_pypi/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sage-docbuild/VERSION.txt b/pkgs/sage-docbuild/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sage-docbuild/VERSION.txt
+++ b/pkgs/sage-docbuild/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sage-setup/VERSION.txt b/pkgs/sage-setup/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sage-setup/VERSION.txt
+++ b/pkgs/sage-setup/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sage-sws2rst/VERSION.txt b/pkgs/sage-sws2rst/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sage-sws2rst/VERSION.txt
+++ b/pkgs/sage-sws2rst/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sagemath-bliss/VERSION.txt b/pkgs/sagemath-bliss/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sagemath-bliss/VERSION.txt
+++ b/pkgs/sagemath-bliss/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sagemath-categories/VERSION.txt b/pkgs/sagemath-categories/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sagemath-categories/VERSION.txt
+++ b/pkgs/sagemath-categories/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sagemath-coxeter3/VERSION.txt b/pkgs/sagemath-coxeter3/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sagemath-coxeter3/VERSION.txt
+++ b/pkgs/sagemath-coxeter3/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sagemath-coxeter3/pyproject.toml.m4 b/pkgs/sagemath-coxeter3/pyproject.toml.m4
index 9f9c9dedd5e..58d4483f8bd 100644
--- a/pkgs/sagemath-coxeter3/pyproject.toml.m4
+++ b/pkgs/sagemath-coxeter3/pyproject.toml.m4
@@ -5,6 +5,7 @@ requires = [
     SPKG_INSTALL_REQUIRES_setuptools
     SPKG_INSTALL_REQUIRES_sage_setup
     SPKG_INSTALL_REQUIRES_sagemath_environment
+    SPKG_INSTALL_REQUIRES_sagemath_objects
     SPKG_INSTALL_REQUIRES_cython
     SPKG_INSTALL_REQUIRES_cysignals
     SPKG_INSTALL_REQUIRES_pkgconfig
diff --git a/pkgs/sagemath-environment/VERSION.txt b/pkgs/sagemath-environment/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sagemath-environment/VERSION.txt
+++ b/pkgs/sagemath-environment/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sagemath-mcqd/VERSION.txt b/pkgs/sagemath-mcqd/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sagemath-mcqd/VERSION.txt
+++ b/pkgs/sagemath-mcqd/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sagemath-meataxe/VERSION.txt b/pkgs/sagemath-meataxe/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sagemath-meataxe/VERSION.txt
+++ b/pkgs/sagemath-meataxe/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sagemath-meataxe/pyproject.toml.m4 b/pkgs/sagemath-meataxe/pyproject.toml.m4
index b4a504c4f1f..fdbcd55424f 100644
--- a/pkgs/sagemath-meataxe/pyproject.toml.m4
+++ b/pkgs/sagemath-meataxe/pyproject.toml.m4
@@ -5,6 +5,7 @@ requires = [
     SPKG_INSTALL_REQUIRES_setuptools
     SPKG_INSTALL_REQUIRES_sage_setup
     SPKG_INSTALL_REQUIRES_sagemath_environment
+    SPKG_INSTALL_REQUIRES_sagemath_objects
     SPKG_INSTALL_REQUIRES_cython
     SPKG_INSTALL_REQUIRES_cysignals
     SPKG_INSTALL_REQUIRES_pkgconfig
diff --git a/pkgs/sagemath-objects/VERSION.txt b/pkgs/sagemath-objects/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sagemath-objects/VERSION.txt
+++ b/pkgs/sagemath-objects/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sagemath-repl/VERSION.txt b/pkgs/sagemath-repl/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sagemath-repl/VERSION.txt
+++ b/pkgs/sagemath-repl/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sagemath-sirocco/VERSION.txt b/pkgs/sagemath-sirocco/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sagemath-sirocco/VERSION.txt
+++ b/pkgs/sagemath-sirocco/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/pkgs/sagemath-standard/setup.py b/pkgs/sagemath-standard/setup.py
index 29c8744f910..785923c5a0e 100755
--- a/pkgs/sagemath-standard/setup.py
+++ b/pkgs/sagemath-standard/setup.py
@@ -52,12 +52,12 @@
 
 from sage_setup.command.sage_build_cython import sage_build_cython
 from sage_setup.command.sage_build_ext import sage_build_ext
-from sage_setup.command.sage_install import sage_develop, sage_install_and_clean
+from sage_setup.command.sage_install import sage_develop, sage_install
 
 cmdclass = dict(build_cython=sage_build_cython,
                 build_ext=sage_build_ext,
                 develop=sage_develop,
-                install=sage_install_and_clean)
+                install=sage_install)
 
 #########################################################
 ### Discovering Sources
diff --git a/pkgs/sagemath-tdlib/VERSION.txt b/pkgs/sagemath-tdlib/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/pkgs/sagemath-tdlib/VERSION.txt
+++ b/pkgs/sagemath-tdlib/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/ruff.toml b/ruff.toml
index d6dd6fed1bd..b3070914153 100644
--- a/ruff.toml
+++ b/ruff.toml
@@ -3,12 +3,12 @@
 # Assume Python 3.9
 target-version = "py39"
 
-select = [
+lint.select = [
     "E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
     "F", # pyflakes - https://docs.astral.sh/ruff/rules/#pyflakes-f
     "I", # isort - https://docs.astral.sh/ruff/rules/#isort-i
     "PL", # pylint - https://docs.astral.sh/ruff/rules/#pylint-pl
 ]
-ignore = [
+lint.ignore = [
     "E501", # Line too long - hard to avoid in doctests, and better handled by black.
 ]
diff --git a/src/VERSION.txt b/src/VERSION.txt
index 54ab6979ef2..6ab83c553f1 100644
--- a/src/VERSION.txt
+++ b/src/VERSION.txt
@@ -1 +1 @@
-10.4.beta6
+10.4.beta7
diff --git a/src/bin/sage-env b/src/bin/sage-env
index 61901897bcd..b9221fe3567 100644
--- a/src/bin/sage-env
+++ b/src/bin/sage-env
@@ -370,22 +370,38 @@ if [ -n "$PYTHONHOME" ]; then
 fi
 
 if [ -n "$SAGE_LOCAL" ]; then
-    # On OS X, test whether "ld-classic" is present in the installed
-    # version of the command-line tools. If so, we add "-ld_classic"
-    # to LD_FLAGS. See #36599.
-    # When the full XCode is installed and in use, for example after
-    # "sudo xcode-select -s /Applications/Xcode.app", then "xcode-select -p"
-    # gives "/Applications/Xcode.app/Contents/Developer", but "ld-classic"
-    # is not in the subdirectory "usr/bin/" but rather in the subdirectory
-    # "Toolchains/XcodeDefault.xctoolchain/usr/bin/". See #37237.
-    # However, if LD is set explicitly, as it is within conda on macOS,
-    # do not not do this.
-    if [ "$UNAME" = "Darwin" ] && [ -z "$LD" ] && [ -x "$(xcode-select -p)/usr/bin/ld-classic" -o -x "$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld-classic" ] ; then
-        LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-ld_classic,-rpath,$SAGE_LOCAL/lib $LDFLAGS"
-    else
-        LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS"
+    # Construct and export LDFLAGS
+    if [ "$UNAME" = "Darwin" ]; then
+       LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS"
+       # On OS X, use the old linker if it is available.
+       # if "ld-classic" is present in the selected XCode
+       # toolchain, add "-Wl,-ld_classic" to LDFLAGS (see #36599) unless
+       # LD is already set, as it will be with conda on macOS.  When the
+       # selected toolchain is in the Xcode app the output of "xcode-select -p"
+       # is "/Applications/Xcode.app/Contents/Developer", but "ld-classic" is
+       # not in the subdirectory "usr/bin/" but rather in the subdirectory
+       # "Toolchains/XcodeDefault.xctoolchain/usr/bin/".  (See #37237.)
+       if [ -z "$LD" ]; then
+	   # Running xcode-select on a system with no toolchain writes an
+	   # error message to stderr, so redirect stderr to /dev/null. 
+	   XCODE_PATH=$(/usr/bin/xcode-select -p 2> /dev/null)
+	   if [ -n $XCODE_PATH ]; then
+               if [ -x "$XCODE_PATH/usr/bin/ld-classic" -o \
+		       -x "$XCODE_PATH/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld-classic" ]; then
+		   LDFLAGS="$LDFLAGS -Wl,-ld_classic"
+               fi
+           else
+               # On a macOS system with no toolchain we don't want this script
+               # to call gcc because that will also print an error message to
+               # stderr.  We can avoid this by setting AS and LD to their
+               # default values.
+               AS=as
+               LD=ld
+	   fi
+       fi
     fi
     if [ "$UNAME" = "Linux" ]; then
+	LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS"
         LDFLAGS="-Wl,-rpath-link,$SAGE_LOCAL/lib $LDFLAGS"
     fi
     export LDFLAGS
diff --git a/src/bin/sage-fixdoctests b/src/bin/sage-fixdoctests
index 49de702cd51..0d55581c505 100755
--- a/src/bin/sage-fixdoctests
+++ b/src/bin/sage-fixdoctests
@@ -300,6 +300,9 @@ def process_block(block, src_in_lines, file_optional_tags, venv_explainer=''):
         got = ['']
     else:
         expected, got = block.split('\nGot:\n')
+        got = re.sub(r'(doctest:warning).*^( *DeprecationWarning:)',
+                     r'\1...\n\2',
+                     got, 1, re.DOTALL | re.MULTILINE)
         got = got.splitlines()      # got can't be the empty string
 
     if args.only_tags:
diff --git a/src/bin/sage-version.sh b/src/bin/sage-version.sh
index bab5675baae..174881ad48d 100644
--- a/src/bin/sage-version.sh
+++ b/src/bin/sage-version.sh
@@ -4,6 +4,6 @@
 # which stops "setup.py develop" from rewriting it as a Python file.
 :
 # This file is auto-generated by the sage-update-version script, do not edit!
-SAGE_VERSION='10.4.beta6'
-SAGE_RELEASE_DATE='2024-05-12'
-SAGE_VERSION_BANNER='SageMath version 10.4.beta6, Release Date: 2024-05-12'
+SAGE_VERSION='10.4.beta7'
+SAGE_RELEASE_DATE='2024-05-25'
+SAGE_VERSION_BANNER='SageMath version 10.4.beta7, Release Date: 2024-05-25'
diff --git a/src/doc/en/developer/portability_platform_table.rst b/src/doc/en/developer/portability_platform_table.rst
index bf843b0a353..6b8c0724001 100644
--- a/src/doc/en/developer/portability_platform_table.rst
+++ b/src/doc/en/developer/portability_platform_table.rst
@@ -376,60 +376,6 @@
 .. |codespace-ubuntu-noble-maximal| image:: https://github.com/codespaces/badge.svg
    :target: https://codespaces.new/sagemath/sage?devcontainer_path=.devcontainer%2Fportability-ubuntu-noble-maximal%2Fdevcontainer.json
 
-.. |image-debian-buster-gcc_spkg-minimal-with-system-packages| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-minimal-with-system-packages/size?tag=dev&label=with-system-packages&color=%23696969
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-minimal-with-system-packages
-
-.. |image-debian-buster-gcc_spkg-minimal-configured| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-minimal-configured/latest_tag?ignore=latest,dev,*-failed&label=configured&color=%23696969
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-minimal-configured
-
-.. |image-debian-buster-gcc_spkg-minimal-with-targets-pre| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-minimal-with-targets-pre/latest_tag?ignore=latest,dev,*-failed&label=with-targets-pre&color=%23677895
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-minimal-with-targets-pre
-
-.. |image-debian-buster-gcc_spkg-minimal-with-targets| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-minimal-with-targets/latest_tag?ignore=latest,dev,*-failed&label=with-targets&color=%236686c1
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-minimal-with-targets
-
-.. |image-debian-buster-gcc_spkg-minimal-with-targets-optional| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-minimal-with-targets-optional/latest_tag?ignore=latest,dev,*-failed&label=with-targets-optional&color=%236495ed
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-minimal-with-targets-optional
-
-.. |codespace-debian-buster-gcc_spkg-minimal| image:: https://github.com/codespaces/badge.svg
-   :target: https://codespaces.new/sagemath/sage?devcontainer_path=.devcontainer%2Fportability-debian-buster-gcc_spkg-minimal%2Fdevcontainer.json
-
-.. |image-debian-buster-gcc_spkg-standard-with-system-packages| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-standard-with-system-packages/size?tag=dev&label=with-system-packages&color=%23696969
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-standard-with-system-packages
-
-.. |image-debian-buster-gcc_spkg-standard-configured| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-standard-configured/latest_tag?ignore=latest,dev,*-failed&label=configured&color=%23696969
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-standard-configured
-
-.. |image-debian-buster-gcc_spkg-standard-with-targets-pre| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-standard-with-targets-pre/latest_tag?ignore=latest,dev,*-failed&label=with-targets-pre&color=%235d8a4c
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-standard-with-targets-pre
-
-.. |image-debian-buster-gcc_spkg-standard-with-targets| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-standard-with-targets/latest_tag?ignore=latest,dev,*-failed&label=with-targets&color=%2350ab2e
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-standard-with-targets
-
-.. |image-debian-buster-gcc_spkg-standard-with-targets-optional| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-standard-with-targets-optional/latest_tag?ignore=latest,dev,*-failed&label=with-targets-optional&color=%2344cc11
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-standard-with-targets-optional
-
-.. |codespace-debian-buster-gcc_spkg-standard| image:: https://github.com/codespaces/badge.svg
-   :target: https://codespaces.new/sagemath/sage?devcontainer_path=.devcontainer%2Fportability-debian-buster-gcc_spkg-standard%2Fdevcontainer.json
-
-.. |image-debian-buster-gcc_spkg-maximal-with-system-packages| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-maximal-with-system-packages/size?tag=dev&label=with-system-packages&color=%23696969
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-maximal-with-system-packages
-
-.. |image-debian-buster-gcc_spkg-maximal-configured| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-maximal-configured/latest_tag?ignore=latest,dev,*-failed&label=configured&color=%23696969
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-maximal-configured
-
-.. |image-debian-buster-gcc_spkg-maximal-with-targets-pre| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-maximal-with-targets-pre/latest_tag?ignore=latest,dev,*-failed&label=with-targets-pre&color=%238f6b8d
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-maximal-with-targets-pre
-
-.. |image-debian-buster-gcc_spkg-maximal-with-targets| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-maximal-with-targets/latest_tag?ignore=latest,dev,*-failed&label=with-targets&color=%23b46eb2
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-maximal-with-targets
-
-.. |image-debian-buster-gcc_spkg-maximal-with-targets-optional| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-buster-gcc_spkg-maximal-with-targets-optional/latest_tag?ignore=latest,dev,*-failed&label=with-targets-optional&color=%23da70d6
-   :target: https://ghcr.io/sagemath/sage/sage-debian-buster-gcc_spkg-maximal-with-targets-optional
-
-.. |codespace-debian-buster-gcc_spkg-maximal| image:: https://github.com/codespaces/badge.svg
-   :target: https://codespaces.new/sagemath/sage?devcontainer_path=.devcontainer%2Fportability-debian-buster-gcc_spkg-maximal%2Fdevcontainer.json
-
 .. |image-debian-bullseye-minimal-with-system-packages| image:: https://ghcr-badge.egpl.dev/sagemath/sage/sage-debian-bullseye-minimal-with-system-packages/size?tag=dev&label=with-system-packages&color=%23696969
    :target: https://ghcr.io/sagemath/sage/sage-debian-bullseye-minimal-with-system-packages
 
@@ -2513,17 +2459,6 @@
    * -    ‑*maximal*
      - |image-ubuntu-noble-maximal-with-system-packages| |image-ubuntu-noble-maximal-with-targets-pre|
      -
-   * - **debian**-buster-gcc_spkg 
-       
-          ‑*minimal*
-     - |image-debian-buster-gcc_spkg-minimal-with-system-packages| |image-debian-buster-gcc_spkg-minimal-with-targets-pre| |image-debian-buster-gcc_spkg-minimal-with-targets| |image-debian-buster-gcc_spkg-minimal-with-targets-optional|
-     - |codespace-debian-buster-gcc_spkg-minimal|
-   * -    ‑*standard*
-     - |image-debian-buster-gcc_spkg-standard-with-system-packages| |image-debian-buster-gcc_spkg-standard-with-targets-pre| |image-debian-buster-gcc_spkg-standard-with-targets| |image-debian-buster-gcc_spkg-standard-with-targets-optional|
-     - |codespace-debian-buster-gcc_spkg-standard|
-   * -    ‑*maximal*
-     - |image-debian-buster-gcc_spkg-maximal-with-system-packages| |image-debian-buster-gcc_spkg-maximal-with-targets-pre|
-     -
    * - **debian**-bullseye 
        
           ‑*minimal*
diff --git a/src/doc/en/developer/tools.rst b/src/doc/en/developer/tools.rst
index 737d7410a48..bc18723cb24 100644
--- a/src/doc/en/developer/tools.rst
+++ b/src/doc/en/developer/tools.rst
@@ -49,7 +49,7 @@ available::
   --tox [options]  -- general entry point for testing
                                   and linting of the Sage library
      -e      -- run specific test environments; default:
-                         doctest,coverage,startuptime,pycodestyle-minimal,relint,codespell,rst
+                         doctest,coverage,startuptime,pycodestyle-minimal,relint,codespell,rst,ruff-minimal
         doctest                -- run the Sage doctester
                                   (same as "sage -t")
         coverage               -- give information about doctest coverage of files
@@ -60,11 +60,13 @@ available::
         relint                 -- check whether some forbidden patterns appear
         codespell              -- check for misspelled words in source code
         rst                    -- validate Python docstrings markup as reStructuredText
+        ruff-minimal           -- check against Sage's minimal style conventions
         coverage.py            -- run the Sage doctester with Coverage.py
         coverage.py-html       -- run the Sage doctester with Coverage.py, generate HTML report
         pyright                -- run the static typing checker pyright
         pycodestyle            -- check against the Python style conventions of PEP8
         cython-lint            -- check Cython files for code style
+        ruff                   -- check against Python style conventions
      -p auto          -- run test environments in parallel
      --help           -- show tox help
 
@@ -287,6 +289,20 @@ for Python code, written in Rust.
 It comes with a large choice of possible checks, and has the capacity
 to fix some of the warnings it emits.
 
+Sage defines two configurations for ruff.  The command ``./sage -tox -e ruff-minimal`` uses
+ruff in a minimal configuration. As of Sage 10.3, the entire Sage library conforms to this
+configuration. When preparing a Sage PR, developers should verify that
+``./sage -tox -e ruff-minimal`` passes.
+
+The second configuration is used with the command ``./sage -tox -e ruff`` and runs a
+more thorough check.  When preparing a PR that adds new code,
+developers should verify that ``./sage -tox -e ruff`` does not
+issue warnings for the added code.  This will avoid later cleanup
+PRs as the Sage codebase is moving toward full PEP 8 compliance.
+
+On the other hand, it is usually not advisable to mix coding-style
+fixes with productive changes on the same PR because this would
+makes it harder for reviewers to evaluate the changes.
 
 .. _section-tools-relint:
 
diff --git a/src/doc/en/installation/source.rst b/src/doc/en/installation/source.rst
index 2ba63eae3e8..c3272e62552 100644
--- a/src/doc/en/installation/source.rst
+++ b/src/doc/en/installation/source.rst
@@ -5,7 +5,7 @@
 Install from Source Code
 ========================
 
-Building Sage from the :wikipedia:`source code ` has the major
+Building Sage from the source code has the major
 advantage that your install will be optimized for your particular computer and
 should therefore offer better performance and compatibility than a binary
 install.
@@ -602,8 +602,9 @@ Make targets
 ------------
 
 To build Sage from scratch, you would typically execute ``make`` in Sage's home
-directory to build Sage and its :wikipedia:`HTML `
-documentation.
+directory to build Sage and its documentation in HTML format, suitable for
+viewing in a web browser.
+
 The ``make`` command is pretty smart, so if your build of Sage is interrupted,
 then running ``make`` again should cause it to pick up where it left off.
 The ``make`` command can also be given options, which control what is built and
diff --git a/src/doc/en/reference/calculus/index.rst b/src/doc/en/reference/calculus/index.rst
index c9a5158e522..0f451a50613 100644
--- a/src/doc/en/reference/calculus/index.rst
+++ b/src/doc/en/reference/calculus/index.rst
@@ -23,6 +23,7 @@ Using calculus
 
 - :doc:`More about symbolic variables and functions `
 - :doc:`Main operations on symbolic expressions `
+- :doc:`sage/calculus/expr`
 - :doc:`Assumptions about symbols and functions `
 - :doc:`sage/symbolic/relation`
 - :doc:`sage/symbolic/integration/integral`
@@ -65,6 +66,7 @@ Internal functionality supporting calculus
 
    sage/symbolic/expression
    sage/symbolic/callable
+   sage/calculus/expr
    sage/symbolic/assumptions
    sage/symbolic/relation
    sage/calculus/calculus
diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
index 0c6be456348..9f50df55b5d 100644
--- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
@@ -126,13 +126,10 @@ This base class provides a lot more methods than a general parent::
      '_zero_ideal',
      'algebraic_closure',
      'base_extend',
-     'derivation',
-     'derivation_module',
      'divides',
      'epsilon',
      'extension',
      'fraction_field',
-     'frobenius_endomorphism',
      'gen',
      'gens',
      'ideal',
diff --git a/src/sage/algebras/all.py b/src/sage/algebras/all.py
index a98f5284eca..0e995a677ec 100644
--- a/src/sage/algebras/all.py
+++ b/src/sage/algebras/all.py
@@ -22,18 +22,18 @@
 
 import sage.algebras.catalog as algebras
 
-from .quatalg.all import *
-from .steenrod.all import *
-from .fusion_rings.all import *
-from .lie_algebras.all import *
-from .quantum_groups.all import *
-from .lie_conformal_algebras.all import *
+from sage.algebras.quatalg.all import *
+from sage.algebras.steenrod.all import *
+from sage.algebras.fusion_rings.all import *
+from sage.algebras.lie_algebras.all import *
+from sage.algebras.quantum_groups.all import *
+from sage.algebras.lie_conformal_algebras.all import *
 
 # Algebra base classes
-from .free_algebra import FreeAlgebra
-from .free_algebra_quotient import FreeAlgebraQuotient
+from sage.algebras.free_algebra import FreeAlgebra
+from sage.algebras.free_algebra_quotient import FreeAlgebraQuotient
 
-from .finite_dimensional_algebras.all import FiniteDimensionalAlgebra
+from sage.algebras.finite_dimensional_algebras.all import FiniteDimensionalAlgebra
 
 lazy_import('sage.algebras.group_algebra', 'GroupAlgebra')
 
@@ -52,8 +52,8 @@
 
 lazy_import('sage.algebras.shuffle_algebra', 'ShuffleAlgebra')
 
-from .clifford_algebra import CliffordAlgebra, ExteriorAlgebra
-from .weyl_algebra import DifferentialWeylAlgebra
+from sage.algebras.clifford_algebra import CliffordAlgebra, ExteriorAlgebra
+from sage.algebras.weyl_algebra import DifferentialWeylAlgebra
 
 lazy_import('sage.algebras.commutative_dga', 'GradedCommutativeAlgebra')
 
diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
index 17bc36b1661..fba00aca3a6 100644
--- a/src/sage/algebras/cluster_algebra.py
+++ b/src/sage/algebras/cluster_algebra.py
@@ -1769,7 +1769,7 @@ def d_vector_to_g_vector(self, d) -> tuple:
             sage: A.d_vector_to_g_vector((1,0,-1))
             (-1, 1, 2)
         """
-        dm = vector((x if x < 0 else 0 for x in d))
+        dm = vector(x if x < 0 else 0 for x in d)
         dp = vector(d) - dm
         return tuple(- dm - self.euler_matrix() * dp)
 
diff --git a/src/sage/algebras/finite_dimensional_algebras/all.py b/src/sage/algebras/finite_dimensional_algebras/all.py
index add5ff8ecd6..acf12b5758a 100644
--- a/src/sage/algebras/finite_dimensional_algebras/all.py
+++ b/src/sage/algebras/finite_dimensional_algebras/all.py
@@ -1 +1 @@
-from .finite_dimensional_algebra import FiniteDimensionalAlgebra
+from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra import FiniteDimensionalAlgebra
diff --git a/src/sage/algebras/fusion_rings/f_matrix.py b/src/sage/algebras/fusion_rings/f_matrix.py
index 47f5976cf03..2e40be57df6 100644
--- a/src/sage/algebras/fusion_rings/f_matrix.py
+++ b/src/sage/algebras/fusion_rings/f_matrix.py
@@ -41,6 +41,7 @@
 from sage.rings.polynomial.polydict import ETuple
 from sage.rings.qqbar import AA, QQbar, number_field_elements_from_algebraics
 
+
 class FMatrix(SageObject):
     r"""
     An F-matrix for a :class:`FusionRing`.
@@ -297,7 +298,7 @@ def __init__(self, fusion_ring, fusion_label="f", var_prefix='fx', inject_variab
         self.pool = None
 
     #######################
-    ### Class utilities ###
+    #   Class utilities   #
     #######################
 
     def _repr_(self):
@@ -434,26 +435,22 @@ def fmat(self, a, b, c, d, x, y, data=True):
              (-zeta60^14 + zeta60^6 + zeta60^4 - 1),
              (zeta60^14 - zeta60^6 - zeta60^4 + 1)]
         """
-        if (self._FR.Nk_ij(a, b, x) == 0 or self._FR.Nk_ij(x, c, d) == 0
-            or self._FR.Nk_ij(b, c, y) == 0 or self._FR.Nk_ij(a, y, d) == 0):
+        if (self._FR.Nk_ij(a, b, x) == 0
+                or self._FR.Nk_ij(x, c, d) == 0
+                or self._FR.Nk_ij(b, c, y) == 0
+                or self._FR.Nk_ij(a, y, d) == 0):
             return 0
 
         # Some known zero F-symbols
         if a == self._FR.one():
-            if x == b and y == d:
-                return 1
-            else:
-                return 0
+            return 1 if x == b and y == d else 0
+
         if b == self._FR.one():
-            if x == a and y == c:
-                return 1
-            else:
-                return 0
+            return 1 if x == a and y == c else 0
+
         if c == self._FR.one():
-            if x == d and y == b:
-                return 1
-            else:
-                return 0
+            return 1 if x == d and y == b else 0
+
         if data:
             # Better to use try/except for speed. Somewhat trivial, but worth
             # hours when method is called ~10^11 times
@@ -461,8 +458,8 @@ def fmat(self, a, b, c, d, x, y, data=True):
                 return self._fvars[a, b, c, d, x, y]
             except KeyError:
                 return 0
-        else:
-            return (a, b, c, d, x, y)
+
+        return (a, b, c, d, x, y)
 
     def fmatrix(self, a, b, c, d):
         r"""
@@ -583,7 +580,7 @@ def findcases(self, output=False):
             idx_map = {}
             ret = {}
         id_anyon = self._FR.one()
-        for (a, b, c, d) in product(self._FR.basis(), repeat=4):
+        for a, b, c, d in product(self._FR.basis(), repeat=4):
             if a == id_anyon or b == id_anyon or c == id_anyon:
                 continue
             for x in self.f_from(a, b, c, d):
@@ -593,10 +590,8 @@ def findcases(self, output=False):
                         ret[(a, b, c, d, x, y)] = v
                         idx_map[i] = (a, b, c, d, x, y)
                     i += 1
-        if output:
-            return idx_map, ret
-        else:
-            return i
+
+        return (idx_map, ret) if output else i
 
     def f_from(self, a, b, c, d):
         r"""
@@ -649,7 +644,7 @@ def f_to(self, a, b, c, d):
                 if self._FR.Nk_ij(b, c, y) != 0 and self._FR.Nk_ij(a, y, d) != 0]
 
     ####################
-    ### Data getters ###
+    #   Data getters   #
     ####################
 
     def get_fvars(self):
@@ -855,7 +850,7 @@ def get_radical_expression(self):
         return {sextuple: val.radical_expression() for sextuple, val in self.get_fvars_in_alg_field().items()}
 
     #######################
-    ### Private helpers ###
+    #   Private helpers   #
     #######################
 
     def _get_known_vals(self):
@@ -894,12 +889,12 @@ def _get_known_nonz(self):
              100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100)
         """
         nonz = {idx: 100 for idx in self._singles}
-        for idx, v in self._ks.items():
+        for idx, _ in self._ks.items():
             nonz[idx] = 100
         return ETuple(nonz, self._poly_ring.ngens())
 
     ##############################
-    ### Variables partitioning ###
+    #   Variables partitioning   #
     ##############################
 
     def largest_fmat_size(self):
@@ -967,7 +962,7 @@ def get_fvars_by_size(self, n, indices=False):
         return var_set
 
     ############################
-    ### Checkpoint utilities ###
+    #   Checkpoint utilities   #
     ############################
 
     def save_fvars(self, filename):
@@ -1009,12 +1004,10 @@ def save_fvars(self, filename):
             True
             sage: os.remove(filename)
         """
-        final_state = [
-            self._fvars,
-            self._non_cyc_roots,
-            self.get_coerce_map_from_fr_cyclotomic_field(),
-            self._qqbar_embedding,
-            ]
+        final_state = [self._fvars,
+                       self._non_cyc_roots,
+                       self.get_coerce_map_from_fr_cyclotomic_field(),
+                       self._qqbar_embedding]
         with open(filename, 'wb') as f:
             pickle.dump(final_state, f)
 
@@ -1212,7 +1205,7 @@ def _restore_state(self, filename):
         self._update_reduction_params()
 
     #################
-    ### MapReduce ###
+    #   MapReduce   #
     #################
 
     def start_worker_pool(self, processes=None):
@@ -1275,7 +1268,7 @@ class methods.
             self._reset_solver_state()
         # Set up shared memory resource handlers
         n_proc = cpu_count() if processes is None else processes
-        self._pid_list = shared_memory.ShareableList([0]*(n_proc+1))
+        self._pid_list = shared_memory.ShareableList([0] * (n_proc+1))
         pids_name = self._pid_list.shm.name
         self._solved = shared_memory.ShareableList(self._solved)
         s_name = self._solved.shm.name
@@ -1304,7 +1297,7 @@ def init(fmats_id, solved_name, vd_name, ks_names, fvar_names, n_proc, pids_name
         self.pool = Pool(processes=n_proc, initializer=init, initargs=args)
         self._pid_list[0] = getpid()
         for i, p in enumerate(self.pool._pool):
-            self._pid_list[i+1] = p.pid
+            self._pid_list[i + 1] = p.pid
         # return True
 
     def shutdown_worker_pool(self):
@@ -1394,7 +1387,7 @@ def _map_triv_reduce(self, mapper, input_iter, worker_pool=None, chunksize=None,
         return results
 
     ########################
-    ### Equations set up ###
+    #   Equations set up   #
     ########################
 
     def get_orthogonality_constraints(self, output=True):
@@ -1494,7 +1487,9 @@ def get_defining_equations(self, option, output=True):
             self._reset_solver_state()
         n_proc = self.pool._processes if self.pool is not None else 1
         params = [(child_id, n_proc, output) for child_id in range(n_proc)]
-        eqns = self._map_triv_reduce('get_reduced_'+option, params, worker_pool=self.pool, chunksize=1, mp_thresh=0)
+        eqns = self._map_triv_reduce('get_reduced_' + option, params,
+                                     worker_pool=self.pool, chunksize=1,
+                                     mp_thresh=0)
         if output:
             F = self._field
             for i, eq_tup in enumerate(eqns):
@@ -1503,7 +1498,7 @@ def get_defining_equations(self, option, output=True):
         self.ideal_basis.extend(eqns)
 
     ############################
-    ### Equations processing ###
+    #   Equations processing   #
     ############################
 
     def _tup_to_fpoly(self, eq_tup):
@@ -1611,7 +1606,7 @@ def _triangular_elim(self, eqns=None, verbose=True):
         self.ideal_basis = eqns
 
     #####################
-    ### Graph methods ###
+    #   Graph methods   #
     #####################
 
     def equations_graph(self, eqns=None):
@@ -1820,7 +1815,7 @@ def _get_component_variety(self, var, eqns):
         return [{inv_idx_map[i]: value for i, (key, value) in enumerate(sorted(soln.items()))} for soln in var_in_R]
 
     #######################
-    ### Solution method ###
+    #   Solution method   #
     #######################
 
     # TODO: this can probably be improved by constructing a set of defining polynomials
@@ -1919,7 +1914,7 @@ def _get_explicit_solution(self, eqns=None, verbose=True):
             for fx, rhs in self._ks.items():
                 if not self._solved[fx]:
                     lt = (ETuple({fx: 2}, n), one)
-                    eqns.append(((lt, (ETuple({}, n), -rhs))))
+                    eqns.append((lt, (ETuple({}, n), -rhs)))
         eqns_partition = self._partition_eqns(verbose=verbose)
 
         F = self._field
@@ -1956,20 +1951,20 @@ def _get_explicit_solution(self, eqns=None, verbose=True):
             if self.attempt_number_field_computation():
                 if verbose:
                     print("Computing appropriate NumberField...")
-                roots = [self._FR.field().gen()]+[r[1] for r in non_cyclotomic_roots]
+                roots = [self._FR.field().gen()] + [r[1] for r in non_cyclotomic_roots]
                 self._field, bf_elts, self._qqbar_embedding = number_field_elements_from_algebraics(roots, minimal=True)
             else:
                 self._field = QQbar
                 bf_elts = [self._qqbar_embedding(F.gen())]
                 bf_elts += [rhs for fx, rhs in non_cyclotomic_roots]
-                self._qqbar_embedding = lambda x : x
+                self._qqbar_embedding = lambda x: x
             self._non_cyc_roots = bf_elts[1:]
 
             # Embed cyclotomic field into newly constructed base field
             cyc_gen_as_bf_elt = bf_elts.pop(0)
             phi = self._FR.field().hom([cyc_gen_as_bf_elt], self._field)
             self._coerce_map_from_cyc_field = phi
-            numeric_fvars = {k : phi(v) for k, v in numeric_fvars.items()}
+            numeric_fvars = {k: phi(v) for k, v in numeric_fvars.items()}
             for i, elt in enumerate(bf_elts):
                 numeric_fvars[non_cyclotomic_roots[i][0]] = elt
             # Update polynomial ring
@@ -2114,7 +2109,7 @@ def find_orthogonal_solution(self, checkpoint=False, save_results="", warm_start
                 print("Set up {} hex and orthogonality constraints...".format(len(self.ideal_basis)))
 
         # Unzip _fvars and link to shared_memory structure if using multiprocessing
-        if use_mp:# and loads_shared_memory:
+        if use_mp:  # and loads_shared_memory:
             self._fvars = self._shared_fvars
         else:
             n = self._poly_ring.ngens()
@@ -2164,12 +2159,12 @@ def find_orthogonal_solution(self, checkpoint=False, save_results="", warm_start
         self._chkpt_status = 7
         self.clear_equations()
         if checkpoint:
-            remove("fmatrix_solver_checkpoint_"+self.get_fr_str()+".pickle")
+            remove("fmatrix_solver_checkpoint_" + self.get_fr_str() + ".pickle")
         if save_results:
             self.save_fvars(save_results)
 
     #########################
-    ### Cyclotomic method ###
+    #   Cyclotomic method   #
     #########################
 
     def _fix_gauge(self, algorithm=""):
@@ -2202,8 +2197,8 @@ def _fix_gauge(self, algorithm=""):
                     break
 
             # Fix var = 1, substitute, and solve equations
-            self.ideal_basis.add(var-1)
-            print("adding equation...", var-1)
+            self.ideal_basis.add(var - 1)
+            print("adding equation...", var - 1)
             self.ideal_basis = set(Ideal(list(self.ideal_basis)).groebner_basis(algorithm=algorithm))
             self._substitute_degree_one()
             self._update_equations()
@@ -2336,7 +2331,7 @@ def find_cyclotomic_solution(self, equations=None, algorithm="", verbose=True, o
         if equations is None:
             if verbose:
                 print("Setting up hexagons and pentagons...")
-            equations = self.get_defining_equations("hexagons")+self.get_defining_equations("pentagons")
+            equations = self.get_defining_equations("hexagons") + self.get_defining_equations("pentagons")
         if verbose:
             print("Finding a Groebner basis...")
         self.ideal_basis = set(Ideal(equations).groebner_basis(algorithm=algorithm))
@@ -2352,7 +2347,7 @@ def find_cyclotomic_solution(self, equations=None, algorithm="", verbose=True, o
             return self._fvars
 
     #####################
-    ### Verifications ###
+    #   Verifications   #
     #####################
 
     def fmats_are_orthogonal(self):
diff --git a/src/sage/algebras/lie_algebras/classical_lie_algebra.py b/src/sage/algebras/lie_algebras/classical_lie_algebra.py
index fae28403d4f..88bf60e9950 100644
--- a/src/sage/algebras/lie_algebras/classical_lie_algebra.py
+++ b/src/sage/algebras/lie_algebras/classical_lie_algebra.py
@@ -447,8 +447,8 @@ def __init__(self, R, n):
         gens = []
         for i in range(n):
             for j in range(n):
-                names.append('E_{0}_{1}'.format(i,j))
-                mat = MS({(i,j):one})
+                names.append('E_{}_{}'.format(i, j))
+                mat = MS({(i, j): one})
                 mat.set_immutable()
                 gens.append(mat)
         self._n = n
diff --git a/src/sage/algebras/lie_algebras/free_lie_algebra.py b/src/sage/algebras/lie_algebras/free_lie_algebra.py
index e641a9140e7..43818e4fc8b 100644
--- a/src/sage/algebras/lie_algebras/free_lie_algebra.py
+++ b/src/sage/algebras/lie_algebras/free_lie_algebra.py
@@ -80,7 +80,7 @@ def _repr_(self):
             sage: L.Lyndon()
             Free Lie algebra generated by (x, y) over Rational Field in the Lyndon basis
         """
-        return "{0} in the {1} basis".format(self.realization_of(), self._basis_name)
+        return "{} in the {} basis".format(self.realization_of(), self._basis_name)
 
     def _repr_term(self, x):
         """
diff --git a/src/sage/algebras/lie_algebras/heisenberg.py b/src/sage/algebras/lie_algebras/heisenberg.py
index 269965b91fd..76dd9931ab4 100644
--- a/src/sage/algebras/lie_algebras/heisenberg.py
+++ b/src/sage/algebras/lie_algebras/heisenberg.py
@@ -194,7 +194,8 @@ def step(self):
     class Element(LieAlgebraElement):
         pass
 
-class HeisenbergAlgebra_fd():
+
+class HeisenbergAlgebra_fd:
     """
     Common methods for finite-dimensional Heisenberg algebras.
     """
@@ -417,7 +418,8 @@ def _repr_(self):
             sage: lie_algebras.Heisenberg(QQ, 3)
             Heisenberg algebra of rank 3 over Rational Field
         """
-        return "Heisenberg algebra of rank {0} over {1}".format(self._n, self.base_ring())
+        return "Heisenberg algebra of rank {} over {}".format(self._n, self.base_ring())
+
 
 class InfiniteHeisenbergAlgebra(HeisenbergAlgebra_abstract, LieAlgebraWithGenerators):
     r"""
diff --git a/src/sage/algebras/lie_algebras/lie_algebra.py b/src/sage/algebras/lie_algebras/lie_algebra.py
index 6c6757fcdd4..885dcf44f0d 100644
--- a/src/sage/algebras/lie_algebras/lie_algebra.py
+++ b/src/sage/algebras/lie_algebras/lie_algebra.py
@@ -894,7 +894,7 @@ def __init__(self, R, names=None, index_set=None, category=None):
         LieAlgebraWithGenerators.__init__(self, R, names, index_set, category)
         self.__ngens = len(self._indices)
 
-    def _repr_(self):
+    def _repr_(self) -> str:
         """
         Return a string representation of ``self``.
 
@@ -905,9 +905,9 @@ def _repr_(self):
             Lie algebra on 2 generators (x, y) over Rational Field
         """
         if self.__ngens == 1:
-            return "Lie algebra on the generator {0} over {1}".format(
+            return "Lie algebra on the generator {} over {}".format(
                 self.gen(0), self.base_ring())
-        return "Lie algebra on {0} generators {1} over {2}".format(
+        return "Lie algebra on {} generators {} over {}".format(
             self.__ngens, self.gens(), self.base_ring())
 
     @lazy_attribute
diff --git a/src/sage/algebras/lie_algebras/representation.py b/src/sage/algebras/lie_algebras/representation.py
index c6bd62dd0cc..b283bf3e694 100644
--- a/src/sage/algebras/lie_algebras/representation.py
+++ b/src/sage/algebras/lie_algebras/representation.py
@@ -16,13 +16,10 @@
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
 
-from sage.misc.lazy_attribute import lazy_attribute
-from sage.misc.cachefunc import cached_method
 from sage.sets.family import Family, AbstractFamily
 from sage.matrix.constructor import matrix
 from sage.combinat.free_module import CombinatorialFreeModule
 from sage.categories.modules import Modules
-from copy import copy
 
 
 class Representation_abstract:
@@ -590,7 +587,7 @@ def __init__(self, L, minimal=False):
             prev = LCS[-1]
             for D in reversed(LCS[:-1]):
                 temp = [L(bred) for b in D.basis() if (bred := prev.reduce(L(b)))]
-                basis_by_deg[self._step-len(basis_by_deg)] = L.echelon_form(temp)
+                basis_by_deg[self._step - len(basis_by_deg)] = L.echelon_form(temp)
                 prev = D
 
         L_basis = sum((basis_by_deg[deg] for deg in sorted(basis_by_deg)), [])
@@ -602,7 +599,7 @@ def __init__(self, L, minimal=False):
             self._invcob = cob.inverse()
             scoeffs = {}
             for i, b in enumerate(L_basis):
-                for j, bp in enumerate(L_basis[i+1:], start=i+1):
+                for j, bp in enumerate(L_basis[i+1:], start=i + 1):
                     scoeffs[i, j] = (self._invcob * b.bracket(bp)._vector_()).dict()
             index_set = tuple(range(L.dimension()))
             from sage.algebras.lie_algebras.lie_algebra import LieAlgebra
@@ -617,7 +614,7 @@ def __init__(self, L, minimal=False):
                                                for n in range(self._step+1)])
 
         if self._minimal:
-            X = set([tuple(index) for index in indices])
+            X = {tuple(index) for index in indices}
             monoid = self._pbw._indices
             I = monoid._indices
             one = L.base_ring().one()
@@ -642,7 +639,7 @@ def test_ideal(m, X):
                         return False
                 return True
 
-            to_remove = set([None])
+            to_remove = {None}
             while to_remove:
                 X -= to_remove
                 to_remove = set()
@@ -683,7 +680,7 @@ def _latex_(self):
         """
         from sage.misc.latex import latex
         g = latex(self._lie_algebra)
-        ret = "U({0}) / U({0})^{{{1}}}".format(g, self._step+1)
+        ret = "U({0}) / U({0})^{{{1}}}".format(g, self._step + 1)
         if self._minimal:
             return "\\min " + ret
         return ret
diff --git a/src/sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py b/src/sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py
index 8aefdd9d3a6..425f35be158 100644
--- a/src/sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py
+++ b/src/sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py
@@ -59,7 +59,7 @@ def __init__(self, R, index_set=None, central_elements=None, category=None,
         self._names = names
         self._latex_names = latex_names
 
-    def _repr_(self):
+    def _repr_(self) -> str:
         """
         The name of this Lie conformal algebra.
 
@@ -71,9 +71,9 @@ def _repr_(self):
             Lie conformal algebra with generators (a, K) over Rational Field
         """
         if self._ngens == 1:
-            return "Lie conformal algebra generated by {0} over {1}".format(
+            return "Lie conformal algebra generated by {} over {}".format(
                 self.gen(0), self.base_ring())
-        return "Lie conformal algebra with generators {0} over {1}".format(
+        return "Lie conformal algebra with generators {} over {}".format(
             self.gens(), self.base_ring())
 
     def _an_element_(self):
diff --git a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py
index 09fb63a0a4c..bf08362ae92 100644
--- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py
+++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py
@@ -222,12 +222,12 @@ def _latex_(self):
         except ValueError:
             names = None
         if names:
-            terms = [("T^{{({0})}}{1}".format(k1, names[p._index_to_pos[k0]]), v) if k1 > 1
+            terms = [("T^{{({})}}{}".format(k1, names[p._index_to_pos[k0]]), v) if k1 > 1
                      else ("T{}".format(names[p._index_to_pos[k0]]), v) if k1 == 1
                      else ("{}".format(names[p._index_to_pos[k0]]), v)
                      for (k0, k1), v in self.monomial_coefficients().items()]
         else:
-            terms = [("T^{{({0})}}{1}".format(k1, latex(k0)), v) if k1 > 1
+            terms = [("T^{{({})}}{}".format(k1, latex(k0)), v) if k1 > 1
                      else ("T{}".format(latex(k0)), v) if k1 == 1
                      else ("{}".format(latex(k0)), v)
                      for (k0, k1), v in self.monomial_coefficients().items()]
diff --git a/src/sage/algebras/orlik_solomon.py b/src/sage/algebras/orlik_solomon.py
index caea1a60d37..d70df4c5c5e 100644
--- a/src/sage/algebras/orlik_solomon.py
+++ b/src/sage/algebras/orlik_solomon.py
@@ -132,7 +132,7 @@ def __init__(self, R, M, ordering=None):
             self._broken_circuits[frozenset(L[1:])] = L[0]
 
         cat = Algebras(R).FiniteDimensional().WithBasis().Graded()
-        CombinatorialFreeModule.__init__(self, R, M.no_broken_circuits_sets(ordering),
+        CombinatorialFreeModule.__init__(self, R, list(M.no_broken_circuits_sets(ordering)),
                                          prefix='OS', bracket='{',
                                          sorting_key=self._sort_key,
                                          category=cat)
diff --git a/src/sage/algebras/orlik_terao.py b/src/sage/algebras/orlik_terao.py
index d1f3fb38af7..222e2152739 100644
--- a/src/sage/algebras/orlik_terao.py
+++ b/src/sage/algebras/orlik_terao.py
@@ -25,7 +25,7 @@ class OrlikTeraoAlgebra(CombinatorialFreeModule):
     r"""
     An Orlik-Terao algebra.
 
-    Let `R` be a commutative ring. Let `M` be a matroid with ground set
+    Let `R` be a commutative ring. Let `M` be a matroid with groundset
     `X` with some fixed ordering and representation `A = (a_x)_{x \in X}`
     (so `a_x` is a (column) vector). Let `C(M)` denote the set of circuits
     of `M`. Let `P` denote the quotient algebra `R[e_x \mid x \in X] /
@@ -65,7 +65,7 @@ class OrlikTeraoAlgebra(CombinatorialFreeModule):
 
     - ``R`` -- the base ring
     - ``M`` -- the defining matroid
-    - ``ordering`` -- (optional) an ordering of the ground set
+    - ``ordering`` -- (optional) an ordering of the groundset
 
     EXAMPLES:
 
@@ -164,7 +164,7 @@ def __init__(self, R, M, ordering=None):
             self._broken_circuits[frozenset(L[1:])] = L[0]
 
         cat = Algebras(R).FiniteDimensional().Commutative().WithBasis().Graded()
-        CombinatorialFreeModule.__init__(self, R, M.no_broken_circuits_sets(ordering),
+        CombinatorialFreeModule.__init__(self, R, list(M.no_broken_circuits_sets(ordering)),
                                          prefix='OT', bracket='{',
                                          sorting_key=self._sort_key,
                                          category=cat)
@@ -252,7 +252,7 @@ def algebra_generators(self):
         r"""
         Return the algebra generators of ``self``.
 
-        These form a family indexed by the ground set `X` of `M`. For
+        These form a family indexed by the groundset `X` of `M`. For
         each `x \in X`, the `x`-th element is `e_x`.
 
         EXAMPLES::
@@ -323,7 +323,7 @@ def product_on_basis(self, a, b):
         TESTS:
 
         Let us check that `e_{s_1} e_{s_2} \cdots e_{s_k} = e_S` for any
-        subset `S = \{ s_1 < s_2 < \cdots < s_k \}` of the ground set::
+        subset `S = \{ s_1 < s_2 < \cdots < s_k \}` of the groundset::
 
             sage: # needs sage.graphs
             sage: G = Graph([[1,2],[1,2],[2,3],[3,4],[4,2]], multiedges=True)
@@ -355,11 +355,11 @@ def product_on_basis(self, a, b):
     def subset_image(self, S):
         r"""
         Return the element `e_S` of ``self`` corresponding to a
-        subset ``S`` of the ground set of the defining matroid.
+        subset ``S`` of the groundset of the defining matroid.
 
         INPUT:
 
-        - ``S`` -- a frozenset which is a subset of the ground set of `M`
+        - ``S`` -- a frozenset which is a subset of the groundset of `M`
 
         EXAMPLES::
 
diff --git a/src/sage/algebras/quatalg/all.py b/src/sage/algebras/quatalg/all.py
index 0f0d45c0217..23bd4edac89 100644
--- a/src/sage/algebras/quatalg/all.py
+++ b/src/sage/algebras/quatalg/all.py
@@ -1 +1 @@
-from .quaternion_algebra import QuaternionAlgebra
+from sage.algebras.quatalg.quaternion_algebra import QuaternionAlgebra
diff --git a/src/sage/algebras/splitting_algebra.py b/src/sage/algebras/splitting_algebra.py
index 991d6240a09..1ba73baf9cb 100644
--- a/src/sage/algebras/splitting_algebra.py
+++ b/src/sage/algebras/splitting_algebra.py
@@ -274,16 +274,16 @@ def __init__(self, monic_polynomial, names='X', iterate=True, warning=True):
 
             verbose("base_ring_step %s defined:" % (base_ring_step))
 
-            # ------------------------------------------------------------------------------------
+            # -------------------------------------------------------------
             # splitting first root off
-            # ------------------------------------------------------------------------------------
+            # -------------------------------------------------------------
             from copy import copy
             root_names_reduces = copy(root_names)
             root_names_reduces.remove(root_name)
 
             P = base_ring_step[root_names_reduces[0]]
             p = P(monic_polynomial.dict())
-            q, _ = p.quo_rem((P.gen() - first_root))
+            q, _ = p.quo_rem(P.gen() - first_root)
 
             verbose("Invoking recursion with: %s" % (q,))
 
diff --git a/src/sage/algebras/steenrod/all.py b/src/sage/algebras/steenrod/all.py
index 134b2b032cf..0eb1625852c 100644
--- a/src/sage/algebras/steenrod/all.py
+++ b/src/sage/algebras/steenrod/all.py
@@ -1,7 +1,7 @@
 """
 The Steenrod algebra
 """
-from .steenrod_algebra import SteenrodAlgebra, Sq
+from sage.algebras.steenrod.steenrod_algebra import SteenrodAlgebra, Sq
 from sage.misc.lazy_import import lazy_import
 lazy_import('sage.algebras.steenrod.steenrod_algebra_bases',
             'steenrod_algebra_basis',
diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
index f3f5447245f..6a87404e3af 100644
--- a/src/sage/algebras/steenrod/steenrod_algebra.py
+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
@@ -606,7 +606,7 @@ def __init__(self, p=2, basis='milnor', **kwds):
         base_ring = GF(p)
         self._profile = profile
         self._truncation_type = truncation_type
-        if ((not self._generic and ((profile and profile[0] < Infinity)))
+        if ((not self._generic and profile and profile[0] < Infinity)
             or (self._generic and profile != ((), ()) and profile[0]
                 and profile[0][0] < Infinity)
                 or (truncation_type < Infinity)):
diff --git a/src/sage/all.py b/src/sage/all.py
index b1f35e3a738..2b5c83a2c37 100644
--- a/src/sage/all.py
+++ b/src/sage/all.py
@@ -59,7 +59,7 @@
 
 ################ end setup warnings ###############################
 
-from .all__sagemath_repl import *  # includes .all__sagemath_objects, .all__sagemath_environment
+from sage.all__sagemath_repl import *  # includes .all__sagemath_objects, .all__sagemath_environment
 
 ###################################################################
 
diff --git a/src/sage/all__sagemath_categories.py b/src/sage/all__sagemath_categories.py
index 4f438a77cbe..872e717af00 100644
--- a/src/sage/all__sagemath_categories.py
+++ b/src/sage/all__sagemath_categories.py
@@ -1,4 +1,4 @@
-from .all__sagemath_objects import *
+from sage.all__sagemath_objects import *
 
 from sage.categories.all import *
 
diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
index d77919bc8bd..ca3403e382c 100644
--- a/src/sage/all__sagemath_repl.py
+++ b/src/sage/all__sagemath_repl.py
@@ -97,8 +97,8 @@
                                 r"removed from itertools in Python 3.14.")
 
 
-from .all__sagemath_objects import *
-from .all__sagemath_environment import *
+from sage.all__sagemath_objects import *
+from sage.all__sagemath_environment import *
 
 from sage.doctest.all    import *
 from sage.repl.all       import *
diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
index 6d11707f785..3ef06d88106 100644
--- a/src/sage/arith/misc.py
+++ b/src/sage/arith/misc.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Miscellaneous arithmetic functions
 
diff --git a/src/sage/calculus/all.py b/src/sage/calculus/all.py
index c83a97f6eb4..fc7f54a6758 100644
--- a/src/sage/calculus/all.py
+++ b/src/sage/calculus/all.py
@@ -21,7 +21,8 @@
                         eulers_method_2x2_plot, desolve_rk4, desolve_system_rk4,
                         desolve_odeint, desolve_mintides, desolve_tides_mpfr)
 
-from .var import (var, function, clear_vars)
+from sage.calculus.expr import symbolic_expression
+from sage.calculus.var import (var, function, clear_vars)
 
 from .transforms.all import *
 
@@ -30,204 +31,4 @@
 lazy_import("sage.calculus.riemann", ["Riemann_Map"])
 lazy_import("sage.calculus.interpolators", ["polygon_spline", "complex_cubic_spline"])
 
-from sage.modules.free_module_element import vector
-from sage.matrix.constructor import matrix
-
-
-def symbolic_expression(x):
-    """
-    Create a symbolic expression or vector of symbolic expressions from x.
-
-    INPUT:
-
-    - ``x`` - an object
-
-    OUTPUT:
-
-    - a symbolic expression.
-
-    EXAMPLES::
-
-        sage: a = symbolic_expression(3/2); a
-        3/2
-        sage: type(a)
-        
-        sage: R. = QQ[]; type(x)
-        
-        sage: a = symbolic_expression(2*x^2 + 3); a
-        2*x^2 + 3
-        sage: type(a)
-        
-        sage: from sage.structure.element import Expression
-        sage: isinstance(a, Expression)
-        True
-        sage: a in SR
-        True
-        sage: a.parent()
-        Symbolic Ring
-
-    Note that equations exist in the symbolic ring::
-
-        sage: E = EllipticCurve('15a'); E
-        Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 10*x - 10 over Rational Field
-        sage: symbolic_expression(E)
-        x*y + y^2 + y == x^3 + x^2 - 10*x - 10
-        sage: symbolic_expression(E) in SR
-        True
-
-    If ``x`` is a list or tuple, create a vector of symbolic expressions::
-
-        sage: v = symbolic_expression([x,1]); v
-        (x, 1)
-        sage: v.base_ring()
-        Symbolic Ring
-        sage: v = symbolic_expression((x,1)); v
-        (x, 1)
-        sage: v.base_ring()
-        Symbolic Ring
-        sage: v = symbolic_expression((3,1)); v
-        (3, 1)
-        sage: v.base_ring()
-        Symbolic Ring
-        sage: E = EllipticCurve('15a'); E
-        Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 10*x - 10 over Rational Field
-        sage: v = symbolic_expression([E,E]); v
-        (x*y + y^2 + y == x^3 + x^2 - 10*x - 10, x*y + y^2 + y == x^3 + x^2 - 10*x - 10)
-        sage: v.base_ring()
-        Symbolic Ring
-
-    Likewise, if ``x`` is a vector, create a vector of symbolic expressions::
-
-        sage: u = vector([1, 2, 3])
-        sage: v = symbolic_expression(u); v
-        (1, 2, 3)
-        sage: v.parent()
-        Vector space of dimension 3 over Symbolic Ring
-
-    If ``x`` is a list or tuple of lists/tuples/vectors, create a matrix of symbolic expressions::
-
-        sage: M = symbolic_expression([[1, x, x^2], (x, x^2, x^3), vector([x^2, x^3, x^4])]); M
-        [  1   x x^2]
-        [  x x^2 x^3]
-        [x^2 x^3 x^4]
-        sage: M.parent()
-        Full MatrixSpace of 3 by 3 dense matrices over Symbolic Ring
-
-    If ``x`` is a matrix, create a matrix of symbolic expressions::
-
-        sage: A = matrix([[1, 2, 3], [4, 5, 6]])
-        sage: B = symbolic_expression(A); B
-        [1 2 3]
-        [4 5 6]
-        sage: B.parent()
-        Full MatrixSpace of 2 by 3 dense matrices over Symbolic Ring
-
-    If ``x`` is a function, for example defined by a ``lambda`` expression, create a
-    symbolic function::
-
-        sage: f = symbolic_expression(lambda z: z^2 + 1); f
-        z |--> z^2 + 1
-        sage: f.parent()
-        Callable function ring with argument z
-        sage: f(7)
-        50
-
-    If ``x`` is a list or tuple of functions, or if ``x`` is a function that returns a list
-    or tuple, create a callable symbolic vector::
-
-        sage: symbolic_expression([lambda mu, nu: mu^2 + nu^2, lambda mu, nu: mu^2 - nu^2])
-        (mu, nu) |--> (mu^2 + nu^2, mu^2 - nu^2)
-        sage: f = symbolic_expression(lambda uwu: [1, uwu, uwu^2]); f
-        uwu |--> (1, uwu, uwu^2)
-        sage: f.parent()
-        Vector space of dimension 3 over Callable function ring with argument uwu
-        sage: f(5)
-        (1, 5, 25)
-        sage: f(5).parent()
-        Vector space of dimension 3 over Symbolic Ring
-
-    TESTS:
-
-    Lists, tuples, and vectors of length 0 become vectors over a symbolic ring::
-
-        sage: symbolic_expression([]).parent()
-        Vector space of dimension 0 over Symbolic Ring
-        sage: symbolic_expression(()).parent()
-        Vector space of dimension 0 over Symbolic Ring
-        sage: symbolic_expression(vector(QQ, 0)).parent()
-        Vector space of dimension 0 over Symbolic Ring
-
-    If a matrix has dimension 0, the result is still a matrix over a symbolic ring::
-
-        sage: symbolic_expression(matrix(QQ, 2, 0)).parent()
-        Full MatrixSpace of 2 by 0 dense matrices over Symbolic Ring
-        sage: symbolic_expression(matrix(QQ, 0, 3)).parent()
-        Full MatrixSpace of 0 by 3 dense matrices over Symbolic Ring
-
-    Also functions defined using ``def`` can be used, but we do not advertise it as a use case::
-
-        sage: def sos(x, y):
-        ....:     return x^2 + y^2
-        sage: symbolic_expression(sos)
-        (x, y) |--> x^2 + y^2
-
-    Functions that take a varying number of arguments or keyword-only arguments are not accepted::
-
-        sage: def variadic(x, *y):
-        ....:     return x
-        sage: symbolic_expression(variadic)
-        Traceback (most recent call last):
-        ...
-        TypeError: unable to convert  to a symbolic expression
-
-        sage: def function_with_keyword_only_arg(x, *, sign=1):
-        ....:     return sign * x
-        sage: symbolic_expression(function_with_keyword_only_arg)
-        Traceback (most recent call last):
-        ...
-        TypeError: unable to convert 
-        to a symbolic expression
-    """
-    from sage.symbolic.expression import Expression
-    from sage.symbolic.ring import SR
-    from sage.modules.free_module_element import is_FreeModuleElement
-    from sage.structure.element import is_Matrix
-
-    if isinstance(x, Expression):
-        return x
-    elif hasattr(x, '_symbolic_'):
-        return x._symbolic_(SR)
-    elif isinstance(x, (tuple, list)) or is_FreeModuleElement(x):
-        expressions = [symbolic_expression(item) for item in x]
-        if not expressions:
-            # Make sure it is symbolic also when length is 0
-            return vector(SR, 0)
-        if is_FreeModuleElement(expressions[0]):
-            return matrix(expressions)
-        return vector(expressions)
-    elif is_Matrix(x):
-        if not x.nrows() or not x.ncols():
-            # Make sure it is symbolic and of correct dimensions
-            # also when a matrix dimension is 0
-            return matrix(SR, x.nrows(), x.ncols())
-        rows = [symbolic_expression(row) for row in x.rows()]
-        return matrix(rows)
-    elif callable(x):
-        from inspect import signature, Parameter
-        try:
-            s = signature(x)
-        except ValueError:
-            pass
-        else:
-            if all(param.kind in (Parameter.POSITIONAL_ONLY, Parameter.POSITIONAL_OR_KEYWORD)
-                   for param in s.parameters.values()):
-                vars = [SR.var(name) for name in s.parameters.keys()]
-                result = x(*vars)
-                if isinstance(result, (tuple, list)):
-                    return vector(SR, result).function(*vars)
-                else:
-                    return SR(result).function(*vars)
-    return SR(x)
-
-
 from . import desolvers
diff --git a/src/sage/calculus/expr.py b/src/sage/calculus/expr.py
new file mode 100644
index 00000000000..0aa62851d24
--- /dev/null
+++ b/src/sage/calculus/expr.py
@@ -0,0 +1,203 @@
+r"""
+Constructor for symbolic expressions
+"""
+
+from sage.misc.lazy_import import lazy_import
+from sage.structure.element import is_Matrix
+from sage.symbolic.expression import Expression
+from sage.symbolic.ring import SR
+
+lazy_import('sage.modules.free_module_element', ['vector', 'FreeModuleElement'])
+lazy_import('sage.matrix.constructor', 'matrix')
+
+
+def symbolic_expression(x):
+    """
+    Create a symbolic expression or vector of symbolic expressions from x.
+
+    INPUT:
+
+    - ``x`` - an object
+
+    OUTPUT:
+
+    - a symbolic expression.
+
+    EXAMPLES::
+
+        sage: a = symbolic_expression(3/2); a
+        3/2
+        sage: type(a)
+        
+        sage: R. = QQ[]; type(x)
+        
+        sage: a = symbolic_expression(2*x^2 + 3); a
+        2*x^2 + 3
+        sage: type(a)
+        
+        sage: from sage.structure.element import Expression
+        sage: isinstance(a, Expression)
+        True
+        sage: a in SR
+        True
+        sage: a.parent()
+        Symbolic Ring
+
+    Note that equations exist in the symbolic ring::
+
+        sage: # needs sage.schemes
+        sage: E = EllipticCurve('15a'); E
+        Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 10*x - 10 over Rational Field
+        sage: symbolic_expression(E)
+        x*y + y^2 + y == x^3 + x^2 - 10*x - 10
+        sage: symbolic_expression(E) in SR
+        True
+
+    If ``x`` is a list or tuple, create a vector of symbolic expressions::
+
+        sage: v = symbolic_expression([x,1]); v
+        (x, 1)
+        sage: v.base_ring()
+        Symbolic Ring
+        sage: v = symbolic_expression((x,1)); v
+        (x, 1)
+        sage: v.base_ring()
+        Symbolic Ring
+        sage: v = symbolic_expression((3,1)); v
+        (3, 1)
+        sage: v.base_ring()
+        Symbolic Ring
+        sage: E = EllipticCurve('15a'); E
+        Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 10*x - 10 over Rational Field
+        sage: v = symbolic_expression([E,E]); v
+        (x*y + y^2 + y == x^3 + x^2 - 10*x - 10, x*y + y^2 + y == x^3 + x^2 - 10*x - 10)
+        sage: v.base_ring()
+        Symbolic Ring
+
+    Likewise, if ``x`` is a vector, create a vector of symbolic expressions::
+
+        sage: u = vector([1, 2, 3])
+        sage: v = symbolic_expression(u); v
+        (1, 2, 3)
+        sage: v.parent()
+        Vector space of dimension 3 over Symbolic Ring
+
+    If ``x`` is a list or tuple of lists/tuples/vectors, create a matrix of symbolic expressions::
+
+        sage: M = symbolic_expression([[1, x, x^2], (x, x^2, x^3), vector([x^2, x^3, x^4])]); M
+        [  1   x x^2]
+        [  x x^2 x^3]
+        [x^2 x^3 x^4]
+        sage: M.parent()
+        Full MatrixSpace of 3 by 3 dense matrices over Symbolic Ring
+
+    If ``x`` is a matrix, create a matrix of symbolic expressions::
+
+        sage: A = matrix([[1, 2, 3], [4, 5, 6]])
+        sage: B = symbolic_expression(A); B
+        [1 2 3]
+        [4 5 6]
+        sage: B.parent()
+        Full MatrixSpace of 2 by 3 dense matrices over Symbolic Ring
+
+    If ``x`` is a function, for example defined by a ``lambda`` expression, create a
+    symbolic function::
+
+        sage: f = symbolic_expression(lambda z: z^2 + 1); f
+        z |--> z^2 + 1
+        sage: f.parent()
+        Callable function ring with argument z
+        sage: f(7)
+        50
+
+    If ``x`` is a list or tuple of functions, or if ``x`` is a function that returns a list
+    or tuple, create a callable symbolic vector::
+
+        sage: symbolic_expression([lambda mu, nu: mu^2 + nu^2, lambda mu, nu: mu^2 - nu^2])
+        (mu, nu) |--> (mu^2 + nu^2, mu^2 - nu^2)
+        sage: f = symbolic_expression(lambda uwu: [1, uwu, uwu^2]); f
+        uwu |--> (1, uwu, uwu^2)
+        sage: f.parent()
+        Vector space of dimension 3 over Callable function ring with argument uwu
+        sage: f(5)
+        (1, 5, 25)
+        sage: f(5).parent()
+        Vector space of dimension 3 over Symbolic Ring
+
+    TESTS:
+
+    Lists, tuples, and vectors of length 0 become vectors over a symbolic ring::
+
+        sage: symbolic_expression([]).parent()
+        Vector space of dimension 0 over Symbolic Ring
+        sage: symbolic_expression(()).parent()
+        Vector space of dimension 0 over Symbolic Ring
+        sage: symbolic_expression(vector(QQ, 0)).parent()
+        Vector space of dimension 0 over Symbolic Ring
+
+    If a matrix has dimension 0, the result is still a matrix over a symbolic ring::
+
+        sage: symbolic_expression(matrix(QQ, 2, 0)).parent()
+        Full MatrixSpace of 2 by 0 dense matrices over Symbolic Ring
+        sage: symbolic_expression(matrix(QQ, 0, 3)).parent()
+        Full MatrixSpace of 0 by 3 dense matrices over Symbolic Ring
+
+    Also functions defined using ``def`` can be used, but we do not advertise it as a use case::
+
+        sage: def sos(x, y):
+        ....:     return x^2 + y^2
+        sage: symbolic_expression(sos)
+        (x, y) |--> x^2 + y^2
+
+    Functions that take a varying number of arguments or keyword-only arguments are not accepted::
+
+        sage: def variadic(x, *y):
+        ....:     return x
+        sage: symbolic_expression(variadic)
+        Traceback (most recent call last):
+        ...
+        TypeError: unable to convert  to a symbolic expression
+
+        sage: def function_with_keyword_only_arg(x, *, sign=1):
+        ....:     return sign * x
+        sage: symbolic_expression(function_with_keyword_only_arg)
+        Traceback (most recent call last):
+        ...
+        TypeError: unable to convert 
+        to a symbolic expression
+    """
+    if isinstance(x, Expression):
+        return x
+    elif hasattr(x, '_symbolic_'):
+        return x._symbolic_(SR)
+    elif isinstance(x, (tuple, list, FreeModuleElement)):
+        expressions = [symbolic_expression(item) for item in x]
+        if not expressions:
+            # Make sure it is symbolic also when length is 0
+            return vector(SR, 0)
+        if isinstance(expressions[0], FreeModuleElement):
+            return matrix(expressions)
+        return vector(expressions)
+    elif is_Matrix(x):
+        if not x.nrows() or not x.ncols():
+            # Make sure it is symbolic and of correct dimensions
+            # also when a matrix dimension is 0
+            return matrix(SR, x.nrows(), x.ncols())
+        rows = [symbolic_expression(row) for row in x.rows()]
+        return matrix(rows)
+    elif callable(x):
+        from inspect import signature, Parameter
+        try:
+            s = signature(x)
+        except ValueError:
+            pass
+        else:
+            if all(param.kind in (Parameter.POSITIONAL_ONLY, Parameter.POSITIONAL_OR_KEYWORD)
+                   for param in s.parameters.values()):
+                vars = [SR.var(name) for name in s.parameters.keys()]
+                result = x(*vars)
+                if isinstance(result, (tuple, list)):
+                    return vector(SR, result).function(*vars)
+                else:
+                    return SR(result).function(*vars)
+    return SR(x)
diff --git a/src/sage/calculus/transforms/all.py b/src/sage/calculus/transforms/all.py
index 379b3b69c37..c42ae401653 100644
--- a/src/sage/calculus/transforms/all.py
+++ b/src/sage/calculus/transforms/all.py
@@ -2,4 +2,5 @@
 
 lazy_import("sage.calculus.transforms.fft", ["FastFourierTransform", "FFT"])
 lazy_import("sage.calculus.transforms.dwt", ["WaveletTransform", "DWT"])
-from .dft import IndexedSequence
+from sage.calculus.transforms.dft import IndexedSequence
+del lazy_import
diff --git a/src/sage/categories/bimodules.py b/src/sage/categories/bimodules.py
index f45f42c52dc..5748ebb52b0 100644
--- a/src/sage/categories/bimodules.py
+++ b/src/sage/categories/bimodules.py
@@ -150,7 +150,7 @@ def right_base_ring(self):
         """
         return self._right_base_ring
 
-    def _latex_(self):
+    def _latex_(self) -> str:
         r"""
         Return a latex representation of ``self``.
 
@@ -160,9 +160,9 @@ def _latex_(self):
             {\mathbf{Bimodules}}_{\Bold{Q}, \Bold{Z}}
         """
         from sage.misc.latex import latex
-        return "{{{0}}}_{{{1}, {2}}}".format(Category._latex_(self),
-                                             latex(self._left_base_ring),
-                                             latex(self._right_base_ring))
+        return "{{{}}}_{{{}, {}}}".format(Category._latex_(self),
+                                          latex(self._left_base_ring),
+                                          latex(self._right_base_ring))
 
     def super_categories(self):
         """
diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
index ce316e50138..37192366c6d 100644
--- a/src/sage/categories/category.py
+++ b/src/sage/categories/category.py
@@ -2571,10 +2571,16 @@ def is_Category(x):
     EXAMPLES::
 
         sage: sage.categories.category.is_Category(CommutativeAdditiveSemigroups())
+        doctest:warning...
+        DeprecationWarning: the function is_Category is deprecated;
+        use 'isinstance(..., Category)' instead
+        See https://github.com/sagemath/sage/issues/37922 for details.
         True
         sage: sage.categories.category.is_Category(ZZ)
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37922, "the function is_Category is deprecated; use 'isinstance(..., Category)' instead")
     return isinstance(x, Category)
 
 
diff --git a/src/sage/categories/commutative_rings.py b/src/sage/categories/commutative_rings.py
index 38ae0d22ada..c5e5f85193d 100644
--- a/src/sage/categories/commutative_rings.py
+++ b/src/sage/categories/commutative_rings.py
@@ -13,6 +13,7 @@
 
 from sage.categories.category_with_axiom import CategoryWithAxiom
 from sage.categories.cartesian_product import CartesianProductsCategory
+from sage.structure.sequence import Sequence
 
 
 class CommutativeRings(CategoryWithAxiom):
@@ -267,6 +268,206 @@ def over(self, base=None, gen=None, gens=None, name=None, names=None):
                 gens = (gen,)
             return RingExtension(self, base, gens, names)
 
+        def frobenius_endomorphism(self, n=1):
+            """
+            Return the Frobenius endomorphism.
+
+            INPUT:
+
+            - ``n`` -- a nonnegative integer (default: 1)
+
+            OUTPUT:
+
+            The `n`-th power of the absolute arithmetic Frobenius
+            endomorphism on this commutative ring.
+
+            EXAMPLES::
+
+                sage: K. = PowerSeriesRing(GF(5))
+                sage: Frob = K.frobenius_endomorphism(); Frob
+                Frobenius endomorphism x |--> x^5 of Power Series Ring in u
+                 over Finite Field of size 5
+                sage: Frob(u)
+                u^5
+
+            We can specify a power::
+
+                sage: f = K.frobenius_endomorphism(2); f
+                Frobenius endomorphism x |--> x^(5^2) of Power Series Ring in u
+                 over Finite Field of size 5
+                sage: f(1+u)
+                1 + u^25
+            """
+            from sage.rings.morphism import FrobeniusEndomorphism_generic
+            return FrobeniusEndomorphism_generic(self, n)
+
+        def derivation_module(self, codomain=None, twist=None):
+            r"""
+            Return the module of derivations over this ring.
+
+            INPUT:
+
+            - ``codomain`` -- an algebra over this ring or a ring homomorphism
+              whose domain is this ring or ``None`` (default: ``None``); if it
+              is a morphism, the codomain of derivations will be the codomain
+              of the morphism viewed as an algebra over ``self`` through the
+              given morphism; if ``None``, the codomain will be this ring
+
+            - ``twist`` -- a morphism from this ring to ``codomain``
+              or ``None`` (default: ``None``); if ``None``, the coercion
+              map from this ring to ``codomain`` will be used
+
+            .. NOTE::
+
+                A twisted derivation with respect to `\theta` (or a
+                `\theta`-derivation for short) is an additive map `d`
+                satisfying the following axiom for all `x, y` in the domain:
+
+                .. MATH::
+
+                    d(xy) = \theta(x) d(y) + d(x) y.
+
+            EXAMPLES::
+
+                sage: R. = QQ[]
+                sage: M = R.derivation_module(); M                                          # needs sage.modules
+                Module of derivations over
+                 Multivariate Polynomial Ring in x, y, z over Rational Field
+                sage: M.gens()                                                              # needs sage.modules
+                (d/dx, d/dy, d/dz)
+
+            We can specify a different codomain::
+
+                sage: K = R.fraction_field()
+                sage: M = R.derivation_module(K); M                                         # needs sage.modules
+                Module of derivations
+                 from Multivariate Polynomial Ring in x, y, z over Rational Field
+                   to Fraction Field of
+                      Multivariate Polynomial Ring in x, y, z over Rational Field
+                sage: M.gen() / x                                                           # needs sage.modules
+                1/x*d/dx
+
+            Here is an example with a non-canonical defining morphism::
+
+                sage: ev = R.hom([QQ(0), QQ(1), QQ(2)])
+                sage: ev
+                Ring morphism:
+                  From: Multivariate Polynomial Ring in x, y, z over Rational Field
+                  To:   Rational Field
+                  Defn: x |--> 0
+                        y |--> 1
+                        z |--> 2
+                sage: M = R.derivation_module(ev)                                           # needs sage.modules
+                sage: M                                                                     # needs sage.modules
+                Module of derivations
+                 from Multivariate Polynomial Ring in x, y, z over Rational Field
+                   to Rational Field
+
+            Elements in `M` acts as derivations at `(0,1,2)`::
+
+                sage: # needs sage.modules
+                sage: Dx = M.gen(0); Dx
+                d/dx
+                sage: Dy = M.gen(1); Dy
+                d/dy
+                sage: Dz = M.gen(2); Dz
+                d/dz
+                sage: f = x^2 + y^2 + z^2
+                sage: Dx(f)  # = 2*x evaluated at (0,1,2)
+                0
+                sage: Dy(f)  # = 2*y evaluated at (0,1,2)
+                2
+                sage: Dz(f)  # = 2*z evaluated at (0,1,2)
+                4
+
+            An example with a twisting homomorphism::
+
+                sage: theta = R.hom([x^2, y^2, z^2])
+                sage: M = R.derivation_module(twist=theta); M                               # needs sage.modules
+                Module of twisted derivations over Multivariate Polynomial Ring in x, y, z
+                 over Rational Field (twisting morphism: x |--> x^2, y |--> y^2, z |--> z^2)
+
+            .. SEEALSO::
+
+                :meth:`derivation`
+
+            """
+            from sage.rings.derivation import RingDerivationModule
+            if codomain is None:
+                codomain = self
+            return RingDerivationModule(self, codomain, twist)
+
+        def derivation(self, arg=None, twist=None):
+            r"""
+            Return the twisted or untwisted derivation over this ring
+            specified by ``arg``.
+
+            .. NOTE::
+
+                A twisted derivation with respect to `\theta` (or a
+                `\theta`-derivation for short) is an additive map `d`
+                satisfying the following axiom for all `x, y` in the domain:
+
+                .. MATH::
+
+                    d(xy) = \theta(x) d(y) + d(x) y.
+
+            INPUT:
+
+            - ``arg`` -- (optional) a generator or a list of coefficients
+              that defines the derivation
+
+            - ``twist`` -- (optional) the twisting homomorphism
+
+            EXAMPLES::
+
+                sage: R. = QQ[]
+                sage: R.derivation()                                                        # needs sage.modules
+                d/dx
+
+            In that case, ``arg`` could be a generator::
+
+                sage: R.derivation(y)                                                       # needs sage.modules
+                d/dy
+
+            or a list of coefficients::
+
+                sage: R.derivation([1,2,3])                                                 # needs sage.modules
+                d/dx + 2*d/dy + 3*d/dz
+
+            It is not possible to define derivations with respect to a
+            polynomial which is not a variable::
+
+                sage: R.derivation(x^2)                                                     # needs sage.modules
+                Traceback (most recent call last):
+                ...
+                ValueError: unable to create the derivation
+
+            Here is an example with twisted derivations::
+
+                sage: R. = QQ[]
+                sage: theta = R.hom([x^2, y^2, z^2])
+                sage: f = R.derivation(twist=theta); f                                      # needs sage.modules
+                0
+                sage: f.parent()                                                            # needs sage.modules
+                Module of twisted derivations over Multivariate Polynomial Ring in x, y, z
+                 over Rational Field (twisting morphism: x |--> x^2, y |--> y^2, z |--> z^2)
+
+            Specifying a scalar, the returned twisted derivation is the
+            corresponding multiple of `\theta - id`::
+
+                sage: R.derivation(1, twist=theta)                                          # needs sage.modules
+                [x |--> x^2, y |--> y^2, z |--> z^2] - id
+                sage: R.derivation(x, twist=theta)                                          # needs sage.modules
+                x*([x |--> x^2, y |--> y^2, z |--> z^2] - id)
+
+            """
+            if isinstance(arg, (list, tuple)):
+                codomain = Sequence([self(0)] + list(arg)).universe()
+            else:
+                codomain = self
+            return self.derivation_module(codomain, twist=twist)(arg)
+
     class ElementMethods:
         pass
 
diff --git a/src/sage/categories/drinfeld_modules.py b/src/sage/categories/drinfeld_modules.py
index 380318c37ff..4a19a91e4cc 100644
--- a/src/sage/categories/drinfeld_modules.py
+++ b/src/sage/categories/drinfeld_modules.py
@@ -549,8 +549,7 @@ def random_object(self, rank):
 
         K = self._base_field
         coeffs = [self._constant_coefficient]
-        for _ in range(rank-1):
-            coeffs.append(K.random_element())
+        coeffs.extend(K.random_element() for _ in range(rank - 1))
         dom_coeff = 0
         while dom_coeff == 0:
             dom_coeff = K.random_element()
diff --git a/src/sage/categories/fields.py b/src/sage/categories/fields.py
index e0b03fa0901..c09e4bc50e6 100644
--- a/src/sage/categories/fields.py
+++ b/src/sage/categories/fields.py
@@ -498,19 +498,14 @@ def _squarefree_decomposition_univariate_polynomial(self, f):
                 cur = cur.gcd(cur.derivative())
                 f.append(cur)
 
-            g = []
-            for i in range(len(f) - 1):
-                g.append(f[i] // f[i+1])
-
-            a = []
-            for i in range(len(g) - 1):
-                a.append(g[i] // g[i+1])
+            g = [f[i] // f[i + 1] for i in range(len(f) - 1)]
+            a = [g[i] // g[i + 1] for i in range(len(g) - 1)]
             a.append(g[-1])
 
             unit = f[-1]
             for i in range(len(a)):
                 if a[i].degree() > 0:
-                    factors.append((a[i], i+1))
+                    factors.append((a[i], i + 1))
                 else:
                     unit = unit * a[i].constant_coefficient() ** (i + 1)
 
diff --git a/src/sage/categories/functor.pyx b/src/sage/categories/functor.pyx
index 889de1d7e7d..34678169ac5 100644
--- a/src/sage/categories/functor.pyx
+++ b/src/sage/categories/functor.pyx
@@ -179,9 +179,9 @@ cdef class Functor(SageObject):
             Finite Field of size 2
 
         """
-        if not category.is_Category(domain):
+        if not isinstance(domain, category.Category):
             raise TypeError("domain (=%s) must be a category" % domain)
-        if not category.is_Category(codomain):
+        if not isinstance(codomain, category.Category):
             raise TypeError("codomain (=%s) must be a category" % codomain)
         self.__domain = domain
         self.__codomain = codomain
diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
index 29f4c7df69a..e763a022d4c 100644
--- a/src/sage/categories/homset.py
+++ b/src/sage/categories/homset.py
@@ -522,9 +522,6 @@ def End(X, category=None):
          from Alternating group of order 3!/2 as a permutation group
          to Alternating group of order 3!/2 as a permutation group
          in Category of finite enumerated permutation groups
-        sage: from sage.categories.homset import is_Endset
-        sage: is_Endset(S)
-        True
         sage: S.domain()
         Alternating group of order 3!/2 as a permutation group
 
@@ -1298,14 +1295,21 @@ def is_Homset(x):
         sage: P. = ZZ[]
         sage: f = P.hom([1/2*t])
         sage: is_Homset(f)
+        doctest:warning...
+        DeprecationWarning: the function is_Homset is deprecated;
+        use 'isinstance(..., Homset)' instead
+        See https://github.com/sagemath/sage/issues/37922 for details.
         False
         sage: is_Homset(f.category())
         False
         sage: is_Homset(f.parent())
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37922, "the function is_Homset is deprecated; use 'isinstance(..., Homset)' instead")
     return isinstance(x, Homset)
 
+
 def is_Endset(x):
     """
     Return ``True`` if ``x`` is a set of endomorphisms in a category.
@@ -1316,9 +1320,15 @@ def is_Endset(x):
         sage: P. = ZZ[]
         sage: f = P.hom([1/2*t])
         sage: is_Endset(f.parent())
+        doctest:warning...
+        DeprecationWarning: the function is_Endset is deprecated;
+        use 'isinstance(..., Homset) and ....is_endomorphism_set()' instead
+        See https://github.com/sagemath/sage/issues/37922 for details.
         False
         sage: g = P.hom([2*t])
         sage: is_Endset(g.parent())
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37922, "the function is_Endset is deprecated; use 'isinstance(..., Homset) and ....is_endomorphism_set()' instead")
     return isinstance(x, Homset) and x.is_endomorphism_set()
diff --git a/src/sage/categories/poor_man_map.py b/src/sage/categories/poor_man_map.py
index 6fc55a02104..1ee3962f84f 100644
--- a/src/sage/categories/poor_man_map.py
+++ b/src/sage/categories/poor_man_map.py
@@ -225,8 +225,8 @@ def __mul__(self, other):
             other_codomain = None
 
         if self_domain is not None and other_codomain is not None:
-            from sage.structure.parent import is_Parent
-            if is_Parent(self_domain) and is_Parent(other_codomain):
+            from sage.structure.parent import Parent
+            if isinstance(self_domain, Parent) and isinstance(other_codomain, Parent):
                 if not self_domain.has_coerce_map_from(other_codomain):
                     raise ValueError("the codomain %r does not coerce into the domain %r" % (other_codomain, self_domain))
 
diff --git a/src/sage/categories/schemes.py b/src/sage/categories/schemes.py
index 0d62237a636..cb1133a2192 100644
--- a/src/sage/categories/schemes.py
+++ b/src/sage/categories/schemes.py
@@ -139,8 +139,8 @@ def _call_(self, x):
                       To:   Rational Field
 
         """
-        from sage.schemes.generic.scheme import is_Scheme
-        if is_Scheme(x):
+        from sage.schemes.generic.scheme import Scheme
+        if isinstance(x, Scheme):
             return x
         from sage.schemes.generic.morphism import is_SchemeMorphism
         if is_SchemeMorphism(x):
@@ -197,9 +197,9 @@ def _repr_object_names(self):
             sage: Schemes(Spec(ZZ)) # indirect doctest
             Category of schemes over Integer Ring
         """
-        from sage.schemes.generic.scheme import is_AffineScheme
+        from sage.schemes.generic.scheme import AffineScheme
         base = self.base()
-        if is_AffineScheme(base):
+        if isinstance(base, AffineScheme):
             base = base.coordinate_ring()
         return f"schemes over {base}"
 
@@ -228,8 +228,8 @@ def __init__(self, base):
             sage: AbelianVarieties(Spec(QQ))
             Category of abelian varieties over Rational Field
         """
-        from sage.schemes.generic.scheme import is_AffineScheme
-        if is_AffineScheme(base):
+        from sage.schemes.generic.scheme import AffineScheme
+        if isinstance(base, AffineScheme):
             base = base.coordinate_ring()
         if base not in Fields():
             raise ValueError('category of abelian varieties is only defined over fields')
@@ -331,8 +331,8 @@ def __init__(self, base):
             sage: Jacobians(Spec(QQ))
             Category of Jacobians over Rational Field
         """
-        from sage.schemes.generic.scheme import is_AffineScheme
-        if is_AffineScheme(base):
+        from sage.schemes.generic.scheme import AffineScheme
+        if isinstance(base, AffineScheme):
             base = base.coordinate_ring()
         if base not in Fields():
             raise ValueError('category of Jacobians is only defined over fields')
diff --git a/src/sage/categories/simplicial_sets.py b/src/sage/categories/simplicial_sets.py
index 7b7bbf827af..4eb27f085ca 100644
--- a/src/sage/categories/simplicial_sets.py
+++ b/src/sage/categories/simplicial_sets.py
@@ -509,8 +509,7 @@ def covering_map(self, character):
                                         lifted = h
                                         break
                                 grelems = [cells_dict[(f0.nondegenerate(), lifted)].apply_degeneracies(*f0.degeneracies())]
-                                for f in faces[1:]:
-                                    grelems.append(cells_dict[(f.nondegenerate(), g)].apply_degeneracies(*f.degeneracies()))
+                                grelems.extend(cells_dict[(f.nondegenerate(), g)].apply_degeneracies(*f.degeneracies()) for f in faces[1:])
                                 faces_dict[cell] = grelems
                 cover = SimplicialSet(faces_dict, base_point=cells_dict[(self.base_point(), G.one())])
                 cover_map_data = {c: s[0] for (s, c) in cells_dict.items()}
diff --git a/src/sage/coding/source_coding/all.py b/src/sage/coding/source_coding/all.py
index dc95b1fb9f3..119db02385e 100644
--- a/src/sage/coding/source_coding/all.py
+++ b/src/sage/coding/source_coding/all.py
@@ -1 +1 @@
-from .huffman import Huffman
+from sage.coding.source_coding.huffman import Huffman
diff --git a/src/sage/combinat/all.py b/src/sage/combinat/all.py
index 4ab35568bb4..e38c88411ec 100644
--- a/src/sage/combinat/all.py
+++ b/src/sage/combinat/all.py
@@ -50,13 +50,13 @@
 install_doc(__package__, __doc__)
 
 # install modules quickref and tutorial to the containing package
-from . import quickref, tutorial
+from sage.combinat import quickref, tutorial
 install_dict(__package__, {'quickref': quickref, 'tutorial': tutorial})
 del quickref, tutorial
 
 from sage.misc.lazy_import import lazy_import
 
-from .combinat import (CombinatorialObject,
+from sage.combinat.combinat import (CombinatorialObject,
                        bell_number, bell_polynomial, bernoulli_polynomial,
                        catalan_number, euler_number,
                        fibonacci, fibonacci_sequence, fibonacci_xrange,
@@ -65,11 +65,11 @@
                        polygonal_number, stirling_number1, stirling_number2,
                        tuples, unordered_tuples)
 
-from .expnums import expnums
+from sage.combinat.expnums import expnums
 
 from sage.combinat.chas.all import *
 from sage.combinat.crystals.all import *
-from .rigged_configurations.all import *
+from sage.combinat.rigged_configurations.all import *
 
 from sage.combinat.dlx import DLXMatrix, AllExactCovers, OneExactCover
 
@@ -77,42 +77,42 @@
 from sage.combinat.designs.all import *
 
 # Free modules and friends
-from .free_module import CombinatorialFreeModule
-from .debruijn_sequence import DeBruijnSequences
+from sage.combinat.free_module import CombinatorialFreeModule
+from sage.combinat.debruijn_sequence import DeBruijnSequences
 
-from .schubert_polynomial import SchubertPolynomialRing
+from sage.combinat.schubert_polynomial import SchubertPolynomialRing
 lazy_import('sage.combinat.key_polynomial', 'KeyPolynomialBasis', as_='KeyPolynomials')
-from .symmetric_group_algebra import SymmetricGroupAlgebra, HeckeAlgebraSymmetricGroupT
-from .symmetric_group_representations import SymmetricGroupRepresentation, SymmetricGroupRepresentations
-from .yang_baxter_graph import YangBaxterGraph
+from sage.combinat.symmetric_group_algebra import SymmetricGroupAlgebra, HeckeAlgebraSymmetricGroupT
+from sage.combinat.symmetric_group_representations import SymmetricGroupRepresentation, SymmetricGroupRepresentations
+from sage.combinat.yang_baxter_graph import YangBaxterGraph
 
 # Permutations
-from .permutation import Permutation, Permutations, Arrangements, CyclicPermutations, CyclicPermutationsOfPartition
-from .affine_permutation import AffinePermutationGroup
+from sage.combinat.permutation import Permutation, Permutations, Arrangements, CyclicPermutations, CyclicPermutationsOfPartition
+from sage.combinat.affine_permutation import AffinePermutationGroup
 lazy_import('sage.combinat.colored_permutations', ['ColoredPermutations',
                                                    'SignedPermutation',
                                                    'SignedPermutations'])
-from .derangements import Derangements
+from sage.combinat.derangements import Derangements
 lazy_import('sage.combinat.baxter_permutations', ['BaxterPermutations'])
 
 # RSK
-from .rsk import RSK, RSK_inverse, robinson_schensted_knuth, robinson_schensted_knuth_inverse, InsertionRules
+from sage.combinat.rsk import RSK, RSK_inverse, robinson_schensted_knuth, robinson_schensted_knuth_inverse, InsertionRules
 
 # HillmanGrassl
 lazy_import("sage.combinat.hillman_grassl", ["WeakReversePlanePartition", "WeakReversePlanePartitions"])
 
 # PerfectMatchings
-from .perfect_matching import PerfectMatching, PerfectMatchings
+from sage.combinat.perfect_matching import PerfectMatching, PerfectMatchings
 
 # Integer lists
-from .integer_lists import IntegerListsLex
+from sage.combinat.integer_lists import IntegerListsLex
 
 # Compositions
-from .composition import Composition, Compositions
-from .composition_signed import SignedCompositions
+from sage.combinat.composition import Composition, Compositions
+from sage.combinat.composition_signed import SignedCompositions
 
 # Partitions
-from .partition import (Partition, Partitions, PartitionsInBox,
+from sage.combinat.partition import (Partition, Partitions, PartitionsInBox,
                         OrderedPartitions, PartitionsGreatestLE,
                         PartitionsGreatestEQ, number_of_partitions)
 
@@ -121,13 +121,13 @@
 lazy_import('sage.combinat.skew_partition', ['SkewPartition', 'SkewPartitions'])
 
 # Partition algebra
-from .partition_algebra import SetPartitionsAk, SetPartitionsPk, SetPartitionsTk, SetPartitionsIk, SetPartitionsBk, SetPartitionsSk, SetPartitionsRk, SetPartitionsPRk
+from sage.combinat.partition_algebra import SetPartitionsAk, SetPartitionsPk, SetPartitionsTk, SetPartitionsIk, SetPartitionsBk, SetPartitionsSk, SetPartitionsRk, SetPartitionsPRk
 
 # Raising operators
 lazy_import('sage.combinat.partition_shifting_algebras', 'ShiftingOperatorAlgebra')
 
 # Diagram algebra
-from .diagram_algebras import PartitionAlgebra, BrauerAlgebra, TemperleyLiebAlgebra, PlanarAlgebra, PropagatingIdeal
+from sage.combinat.diagram_algebras import PartitionAlgebra, BrauerAlgebra, TemperleyLiebAlgebra, PlanarAlgebra, PropagatingIdeal
 
 # Descent algebra
 lazy_import('sage.combinat.descent_algebra', 'DescentAlgebra')
@@ -137,24 +137,24 @@
             ['VectorPartition', 'VectorPartitions'])
 
 # Similarity class types
-from .similarity_class_type import PrimarySimilarityClassType, PrimarySimilarityClassTypes, SimilarityClassType, SimilarityClassTypes
+from sage.combinat.similarity_class_type import PrimarySimilarityClassType, PrimarySimilarityClassTypes, SimilarityClassType, SimilarityClassTypes
 
 # Cores
-from .core import Core, Cores
+from sage.combinat.core import Core, Cores
 
 # Tableaux
 lazy_import('sage.combinat.tableau',
             ["Tableau", "SemistandardTableau", "StandardTableau", "RowStandardTableau", "IncreasingTableau",
              "Tableaux", "SemistandardTableaux", "StandardTableaux", "RowStandardTableaux", "IncreasingTableaux"])
-from .skew_tableau import SkewTableau, SkewTableaux, StandardSkewTableaux, SemistandardSkewTableaux
-from .ribbon_shaped_tableau import RibbonShapedTableau, RibbonShapedTableaux, StandardRibbonShapedTableaux
-from .ribbon_tableau import RibbonTableaux, RibbonTableau, MultiSkewTableaux, MultiSkewTableau, SemistandardMultiSkewTableaux
-from .composition_tableau import CompositionTableau, CompositionTableaux
+from sage.combinat.skew_tableau import SkewTableau, SkewTableaux, StandardSkewTableaux, SemistandardSkewTableaux
+from sage.combinat.ribbon_shaped_tableau import RibbonShapedTableau, RibbonShapedTableaux, StandardRibbonShapedTableaux
+from sage.combinat.ribbon_tableau import RibbonTableaux, RibbonTableau, MultiSkewTableaux, MultiSkewTableau, SemistandardMultiSkewTableaux
+from sage.combinat.composition_tableau import CompositionTableau, CompositionTableaux
 
 lazy_import('sage.combinat.tableau_tuple',
             ['TableauTuple', 'StandardTableauTuple', 'RowStandardTableauTuple',
              'TableauTuples', 'StandardTableauTuples', 'RowStandardTableauTuples'])
-from .k_tableau import WeakTableau, WeakTableaux, StrongTableau, StrongTableaux
+from sage.combinat.k_tableau import WeakTableau, WeakTableaux, StrongTableau, StrongTableaux
 lazy_import('sage.combinat.lr_tableau', ['LittlewoodRichardsonTableau',
                                          'LittlewoodRichardsonTableaux'])
 lazy_import('sage.combinat.shifted_primed_tableau', ['ShiftedPrimedTableaux',
@@ -165,14 +165,14 @@
             ["StandardSuperTableau", "SemistandardSuperTableau", "StandardSuperTableaux", "SemistandardSuperTableaux"])
 
 # Words
-from .words.all import *
+from sage.combinat.words.all import *
 
 lazy_import('sage.combinat.subword', 'Subwords')
 
-from .graph_path import GraphPaths
+from sage.combinat.graph_path import GraphPaths
 
 # Tuples
-from .tuple import Tuples, UnorderedTuples
+from sage.combinat.tuple import Tuples, UnorderedTuples
 
 # Alternating sign matrices
 lazy_import('sage.combinat.alternating_sign_matrix', ('AlternatingSignMatrix',
@@ -196,53 +196,53 @@
             ['ParkingFunctions', 'ParkingFunction'])
 
 # Trees and Tamari interval posets
-from .ordered_tree import (OrderedTree, OrderedTrees,
+from sage.combinat.ordered_tree import (OrderedTree, OrderedTrees,
                           LabelledOrderedTree, LabelledOrderedTrees)
-from .binary_tree import (BinaryTree, BinaryTrees,
+from sage.combinat.binary_tree import (BinaryTree, BinaryTrees,
                          LabelledBinaryTree, LabelledBinaryTrees)
 lazy_import('sage.combinat.interval_posets', ['TamariIntervalPoset', 'TamariIntervalPosets'])
 lazy_import('sage.combinat.rooted_tree', ('RootedTree', 'RootedTrees',
                          'LabelledRootedTree', 'LabelledRootedTrees'))
 
-from .combination import Combinations
+from sage.combinat.combination import Combinations
 
-from .set_partition import SetPartition, SetPartitions
-from .set_partition_ordered import OrderedSetPartition, OrderedSetPartitions
+from sage.combinat.set_partition import SetPartition, SetPartitions
+from sage.combinat.set_partition_ordered import OrderedSetPartition, OrderedSetPartitions
 lazy_import('sage.combinat.multiset_partition_into_sets_ordered',
             ['OrderedMultisetPartitionIntoSets',
              'OrderedMultisetPartitionsIntoSets'])
-from .subset import Subsets, subsets, powerset, uniq
-from .necklace import Necklaces
+from sage.combinat.subset import Subsets, subsets, powerset, uniq
+from sage.combinat.necklace import Necklaces
 lazy_import('sage.combinat.dyck_word', ('DyckWords', 'DyckWord'))
 lazy_import('sage.combinat.nu_dyck_word', ('NuDyckWords', 'NuDyckWord'))
-from .sloane_functions import sloane
+from sage.combinat.sloane_functions import sloane
 lazy_import('sage.combinat.superpartition', ('SuperPartition',
                                              'SuperPartitions'))
 
 lazy_import('sage.combinat.parallelogram_polyomino',
             ['ParallelogramPolyomino', 'ParallelogramPolyominoes'])
 
-from .root_system.all import *
-from .sf.all import *
-from .ncsf_qsym.all import *
-from .ncsym.all import *
+from sage.combinat.root_system.all import *
+from sage.combinat.sf.all import *
+from sage.combinat.ncsf_qsym.all import *
+from sage.combinat.ncsym.all import *
 lazy_import('sage.combinat.fqsym', 'FreeQuasisymmetricFunctions')
-from .matrices.all import *
+from sage.combinat.matrices.all import *
 # Posets
-from .posets.all import *
+from sage.combinat.posets.all import *
 
 # Cluster Algebras and Quivers
-from .cluster_algebra_quiver.all import *
+from sage.combinat.cluster_algebra_quiver.all import *
 
-from . import ranker
+from sage.combinat import ranker
 
-from .integer_vector import IntegerVectors
-from .integer_vector_weighted import WeightedIntegerVectors
-from .integer_vectors_mod_permgroup import IntegerVectorsModPermutationGroup
+from sage.combinat.integer_vector import IntegerVectors
+from sage.combinat.integer_vector_weighted import WeightedIntegerVectors
+from sage.combinat.integer_vectors_mod_permgroup import IntegerVectorsModPermutationGroup
 
 lazy_import('sage.combinat.q_analogues', ['gaussian_binomial', 'q_binomial', 'number_of_irreducible_polynomials'])
 
-from .species.all import *
+from sage.combinat.species.all import *
 
 lazy_import('sage.combinat.kazhdan_lusztig', 'KazhdanLusztigPolynomial')
 
diff --git a/src/sage/combinat/debruijn_sequence.pyx b/src/sage/combinat/debruijn_sequence.pyx
index 02e224283c2..3a201b34e60 100644
--- a/src/sage/combinat/debruijn_sequence.pyx
+++ b/src/sage/combinat/debruijn_sequence.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 De Bruijn sequences
 
diff --git a/src/sage/combinat/designs/all.py b/src/sage/combinat/designs/all.py
index 0948c6fa281..bf00b490c3b 100644
--- a/src/sage/combinat/designs/all.py
+++ b/src/sage/combinat/designs/all.py
@@ -43,7 +43,8 @@
 
 
 lazy_import('sage.combinat.designs.incidence_structures', 'IncidenceStructure')
-lazy_import('sage.combinat.designs.incidence_structures', 'IncidenceStructure', 'BlockDesign')
+lazy_import('sage.combinat.designs.incidence_structures',
+            'IncidenceStructure', 'BlockDesign')
 
 lazy_import('sage.combinat.designs.incidence_structures',
             'IncidenceStructure', as_='Hypergraph')
@@ -51,4 +52,6 @@
 lazy_import('sage.combinat.designs.covering_design',
             ['CoveringDesign', 'schonheim', 'trivial_covering_design'])
 
-from . import design_catalog as designs
+from sage.combinat.designs import design_catalog as designs
+del lazy_import
+del install_doc
diff --git a/src/sage/combinat/fast_vector_partitions.pyx b/src/sage/combinat/fast_vector_partitions.pyx
index fe937b75ee7..4d00d062d96 100644
--- a/src/sage/combinat/fast_vector_partitions.pyx
+++ b/src/sage/combinat/fast_vector_partitions.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Brent Yorgey's fast algorithm for integer vector (multiset) partitions.
 
diff --git a/src/sage/combinat/matrices/dancing_links.pyx b/src/sage/combinat/matrices/dancing_links.pyx
index 0ef6eed0026..5035bb0480b 100644
--- a/src/sage/combinat/matrices/dancing_links.pyx
+++ b/src/sage/combinat/matrices/dancing_links.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # distutils: language = c++
 """
 Dancing Links internal pyx code
diff --git a/src/sage/combinat/matrices/hadamard_matrix.py b/src/sage/combinat/matrices/hadamard_matrix.py
index 8c6b2f10395..d3f0d7c2bca 100644
--- a/src/sage/combinat/matrices/hadamard_matrix.py
+++ b/src/sage/combinat/matrices/hadamard_matrix.py
@@ -1641,7 +1641,7 @@ def is_skew_hadamard_matrix(M, normalized=False, verbose=False):
 
 
 @matrix_method
-def hadamard_matrix(n, existence=False, check=True):
+def hadamard_matrix(n, existence=False, check=True, construction_name=False):
     r"""
     Tries to construct a Hadamard matrix using the available methods.
 
@@ -1663,6 +1663,9 @@ def hadamard_matrix(n, existence=False, check=True):
     - ``check`` -- boolean (default: ``True``); whether to check that output is correct before
       returning it. As this is expected to be useless (but we are cautious
       guys), you may want to disable it whenever you want speed.
+    - ``construction_name`` -- boolean (default: ``False``); if it is ``True``,
+      ``existence`` is ``True``, and a matrix exists, output the construction name.
+      It has no effect if ``existence`` is set to ``False``.
 
     EXAMPLES::
 
@@ -1709,6 +1712,11 @@ def hadamard_matrix(n, existence=False, check=True):
         [ 1 -1| 1  1|-1 -1|-1 -1| 1  1| 1 -1]
         [ 1  1| 1 -1|-1  1|-1  1| 1 -1|-1 -1]
 
+    To find how the matrix is obtained, use ``construction_name`` ::
+
+        sage: matrix.hadamard(476, existence=True, construction_name=True)
+        'cooper-wallis small cases: 476'
+
     TESTS::
 
         sage: matrix.hadamard(10,existence=True)
@@ -1728,25 +1736,35 @@ def hadamard_matrix(n, existence=False, check=True):
         sage: matrix.hadamard(324, existence=True)
         True
     """
+    name = str(n)
+    if construction_name:
+        def report_name(nam):
+            return nam
+    else:
+        def report_name(nam):
+            return True
+
     if not (n % 4 == 0) and (n > 2):
         if existence:
             return False
         raise ValueError("The Hadamard matrix of order %s does not exist" % n)
     if n == 2:
         if existence:
-            return True
+            return report_name(name)
         M = matrix([[1, 1], [1, -1]])
     elif n == 1:
         if existence:
-            return True
+            return report_name(name)
         M = matrix([1])
     elif is_prime_power(n//2 - 1) and (n//2 - 1) % 4 == 1:
+        name = "paleyII " + name
         if existence:
-            return True
+            return report_name(name)
         M = hadamard_matrix_paleyII(n)
     elif n == 4 or n % 8 == 0 and hadamard_matrix(n//2, existence=True) is True:
+        name = "doubling " + name
         if existence:
-            return True
+            return report_name(name)
         had = hadamard_matrix(n//2, check=False)
         chad1 = matrix([list(r) + list(r) for r in had.rows()])
         mhad = (-1) * had
@@ -1755,44 +1773,53 @@ def hadamard_matrix(n, existence=False, check=True):
                        for i in range(R)])
         M = chad1.stack(chad2)
     elif is_prime_power(n - 1) and (n - 1) % 4 == 3:
+        name = "paleyI " + name
         if existence:
-            return True
+            return report_name(name)
         M = hadamard_matrix_paleyI(n)
     elif williamson_hadamard_matrix_smallcases(n, existence=True):
+        name = "small cases: " + name
         if existence:
-            return True
+            return report_name(name)
         M = williamson_hadamard_matrix_smallcases(n, check=False)
     elif n == 156:
         if existence:
-            return True
+            return report_name(name)
         M = hadamard_matrix_156()
     elif hadamard_matrix_cooper_wallis_smallcases(n, existence=True):
+        name = "cooper-wallis small cases: " + name
         if existence:
-            return True
+            return report_name(name)
         M = hadamard_matrix_cooper_wallis_smallcases(n, check=False)
     elif turyn_type_hadamard_matrix_smallcases(n, existence=True):
+        name = "turyn type small cases: " + name
         if existence:
-            return True
+            return report_name(name)
         M = turyn_type_hadamard_matrix_smallcases(n, check=False)
     elif hadamard_matrix_miyamoto_construction(n, existence=True):
+        name = "miyamoto " + name
         if existence:
-            return True
+            return report_name(name)
         M = hadamard_matrix_miyamoto_construction(n, check=False)
     elif hadamard_matrix_from_sds(n, existence=True):
+        name = "SDS " + name
         if existence:
-            return True
+            return report_name(name)
         M = hadamard_matrix_from_sds(n, check=False)
     elif hadamard_matrix_spence_construction(n, existence=True):
+        name = "spence " + name
         if existence:
-            return True
+            return report_name(name)
         M = hadamard_matrix_spence_construction(n, check=False)
     elif skew_hadamard_matrix(n, existence=True) is True:
+        name = "skew " + name
         if existence:
-            return True
+            return report_name(name)
         M = skew_hadamard_matrix(n, check=False)
     elif regular_symmetric_hadamard_matrix_with_constant_diagonal(n, 1, existence=True) is True:
+        name = "RSHCD " + name
         if existence:
-            return True
+            return report_name(name)
         M = regular_symmetric_hadamard_matrix_with_constant_diagonal(n, 1)
     else:
         if existence:
@@ -3054,7 +3081,8 @@ def pm_to_good_matrix(s, sign=1):
 _skew_had_cache = {}
 
 
-def skew_hadamard_matrix(n, existence=False, skew_normalize=True, check=True):
+def skew_hadamard_matrix(n, existence=False, skew_normalize=True, check=True,
+                         construction_name=False):
     r"""
     Tries to construct a skew Hadamard matrix.
 
@@ -3079,6 +3107,9 @@ def skew_hadamard_matrix(n, existence=False, skew_normalize=True, check=True):
     - ``check`` -- boolean (default: ``True``); whether to check that output is
       correct before returning it. As this is expected to be useless (but we are
       cautious guys), you may want to disable it whenever you want speed
+    - ``construction_name`` -- boolean (default: ``False``); if it is ``True``,
+      ``existence`` is ``True``, and a matrix exists, output the construction name.
+      It has no effect if ``existence`` is set to ``False``.
 
     EXAMPLES::
 
@@ -3092,6 +3123,8 @@ def skew_hadamard_matrix(n, existence=False, skew_normalize=True, check=True):
         sage: skew_hadamard_matrix(2)
         [ 1  1]
         [-1  1]
+        sage: skew_hadamard_matrix(196, existence=True, construction_name=True)
+        'Williamson-Goethals-Seidel: 196'
 
     TESTS::
 
@@ -3136,52 +3169,62 @@ def skew_hadamard_matrix(n, existence=False, skew_normalize=True, check=True):
     if n < 1:
         raise ValueError("parameter n must be strictly positive")
 
-    def true():
-        _skew_had_cache[n] = True
+    def true(nam):
+        _skew_had_cache[n] = nam
+        if construction_name:
+            return nam+": "+str(n)
         return True
     M = None
+    name = ''
     if existence and n in _skew_had_cache:
-        return True
+        return true(_skew_had_cache[n])
     if not (n % 4 == 0) and (n > 2):
         if existence:
             return False
         raise ValueError("A skew Hadamard matrix of order %s does not exist" % n)
     if n == 2:
         if existence:
-            return true()
+            return true(name)
         M = matrix([[1, 1], [-1, 1]])
     elif n == 1:
         if existence:
-            return true()
+            return true(name)
         M = matrix([1])
     elif skew_hadamard_matrix_from_good_matrices_smallcases(n, existence=True):
+        name = "good matrices small cases"
         if existence:
-            return true()
+            return true(name)
         M = skew_hadamard_matrix_from_good_matrices_smallcases(n, check=False)
     elif is_prime_power(n - 1) and ((n - 1) % 4 == 3):
+        name = "paleyI"
         if existence:
-            return true()
+            return true(name)
         M = hadamard_matrix_paleyI(n, normalize=False)
     elif is_prime_power(n//2 - 1) and (n//2 - 1) % 8 == 5:
+        name = "spence"
         if existence:
-            return true()
+            return true(name)
         M = skew_hadamard_matrix_spence_construction(n, check=False)
     elif skew_hadamard_matrix_from_complementary_difference_sets(n, existence=True):
+        name = "complementary DS"
         if existence:
-            return true()
+            return true(name)
         M = skew_hadamard_matrix_from_complementary_difference_sets(n, check=False)
     elif skew_hadamard_matrix_spence_1975(n, existence=True):
+        name = "spence [Spe1975b]"
         if existence:
-            return true()
+            return true(name)
         M = skew_hadamard_matrix_spence_1975(n, check=False)
     elif skew_hadamard_matrix_from_orthogonal_design(n, existence=True):
+        name = "orthogonal design"
         if existence:
-            return true()
+            return true(name)
         M = skew_hadamard_matrix_from_orthogonal_design(n, check=False)
     elif n % 8 == 0:
         if skew_hadamard_matrix(n//2, existence=True) is True:  # (Lemma 14.1.6 in [Ha83]_)
+            name = "doubling"
             if existence:
-                return true()
+                return true(name)
             H = skew_hadamard_matrix(n//2, check=False)
             M = block_matrix([[H, H], [-H.T, H.T]])
 
@@ -3190,8 +3233,10 @@ def true():
                 n1 = n//d
                 if is_prime_power(d - 1) and (d % 4 == 0) and (n1 % 4 == 0)\
                     and skew_hadamard_matrix(n1, existence=True) is True:
+                    from sage.arith.misc import factor
+                    name = "williamson - Lemma 14.1.5 [Ha83] ("+str(factor(d-1))+","+str(n1)+") "
                     if existence:
-                        return true()
+                        return true(name)
                     H = skew_hadamard_matrix(n1, check=False)-I(n1)
                     U = matrix(ZZ, d, lambda i, j: -1 if i == j == 0 else
                                         1 if i == j == 1 or (i > 1 and j-1 == d-i)
@@ -3203,8 +3248,9 @@ def true():
                     break
     if M is None:  # try Williamson-Goethals-Seidel construction
         if GS_skew_hadamard_smallcases(n, existence=True) is True:
+            name = "Williamson-Goethals-Seidel"
             if existence:
-                return true()
+                return true(name)
             M = GS_skew_hadamard_smallcases(n)
 
         else:
@@ -3215,7 +3261,7 @@ def true():
         M = normalise_hadamard(M, skew=True)
     if check:
         assert is_hadamard_matrix(M, normalized=skew_normalize, skew=True)
-    _skew_had_cache[n] = True
+    _skew_had_cache[n] = name
     return M
 
 
diff --git a/src/sage/combinat/ncsf_qsym/all.py b/src/sage/combinat/ncsf_qsym/all.py
index db6cb1f065e..fee9641a1ee 100644
--- a/src/sage/combinat/ncsf_qsym/all.py
+++ b/src/sage/combinat/ncsf_qsym/all.py
@@ -12,5 +12,5 @@
 from sage.misc.namespace_package import install_doc
 install_doc(__package__, __doc__)
 
-from .qsym import QuasiSymmetricFunctions
-from .ncsf import NonCommutativeSymmetricFunctions
+from sage.combinat.ncsf_qsym.qsym import QuasiSymmetricFunctions
+from sage.combinat.ncsf_qsym.ncsf import NonCommutativeSymmetricFunctions
diff --git a/src/sage/combinat/ncsym/all.py b/src/sage/combinat/ncsym/all.py
index 7a174e45ccf..cdeeec1ae41 100644
--- a/src/sage/combinat/ncsym/all.py
+++ b/src/sage/combinat/ncsym/all.py
@@ -11,5 +11,5 @@
 from sage.misc.namespace_package import install_doc
 install_doc(__package__, __doc__)
 
-from .ncsym import SymmetricFunctionsNonCommutingVariables
-from .dual import SymmetricFunctionsNonCommutingVariablesDual
+from sage.combinat.ncsym.ncsym import SymmetricFunctionsNonCommutingVariables
+from sage.combinat.ncsym.dual import SymmetricFunctionsNonCommutingVariablesDual
diff --git a/src/sage/combinat/posets/all.py b/src/sage/combinat/posets/all.py
index f7f8bdcc7fc..b608b0094d1 100644
--- a/src/sage/combinat/posets/all.py
+++ b/src/sage/combinat/posets/all.py
@@ -36,8 +36,10 @@
 from sage.misc.namespace_package import install_doc
 install_doc(__package__, __doc__)
 
-from .posets import Poset
+from sage.combinat.posets.posets import Poset
 
-from .lattices import LatticePoset, MeetSemilattice, JoinSemilattice
+from sage.combinat.posets.lattices import LatticePoset, MeetSemilattice, JoinSemilattice
 
-from .poset_examples import posets, Posets
+from sage.combinat.posets.poset_examples import posets, Posets
+
+del install_doc
diff --git a/src/sage/combinat/root_system/all.py b/src/sage/combinat/root_system/all.py
index 263a4d916d2..9c50eb57af1 100644
--- a/src/sage/combinat/root_system/all.py
+++ b/src/sage/combinat/root_system/all.py
@@ -121,12 +121,12 @@
 
 from sage.misc.lazy_import import lazy_import
 
-from .cartan_type import CartanType
-from .dynkin_diagram import DynkinDiagram
-from .cartan_matrix import CartanMatrix
-from .coxeter_matrix import CoxeterMatrix
-from .coxeter_type import CoxeterType
-from .root_system import RootSystem, WeylDim
+from sage.combinat.root_system.cartan_type import CartanType
+from sage.combinat.root_system.dynkin_diagram import DynkinDiagram
+from sage.combinat.root_system.cartan_matrix import CartanMatrix
+from sage.combinat.root_system.coxeter_matrix import CoxeterMatrix
+from sage.combinat.root_system.coxeter_type import CoxeterType
+from sage.combinat.root_system.root_system import RootSystem, WeylDim
 lazy_import('sage.combinat.root_system.weyl_group', ['WeylGroup',
                                                      'WeylGroupElement'])
 lazy_import('sage.combinat.root_system.reflection_group_real',
@@ -136,7 +136,7 @@
 lazy_import('sage.combinat.root_system.coxeter_group', 'CoxeterGroup')
 lazy_import('sage.combinat.root_system.weyl_characters', ['WeylCharacterRing',
                                                           'WeightRing'])
-from .branching_rules import BranchingRule, branching_rule_from_plethysm, branching_rule
+from sage.combinat.root_system.branching_rules import BranchingRule, branching_rule_from_plethysm, branching_rule
 
 lazy_import('sage.combinat.root_system.non_symmetric_macdonald_polynomials', 'NonSymmetricMacdonaldPolynomials')
 lazy_import('sage.combinat.root_system.integrable_representations', 'IntegrableRepresentation')
diff --git a/src/sage/combinat/words/all.py b/src/sage/combinat/words/all.py
index 687b572c8e5..8d5798c549c 100644
--- a/src/sage/combinat/words/all.py
+++ b/src/sage/combinat/words/all.py
@@ -43,11 +43,11 @@
 from sage.misc.namespace_package import install_doc
 install_doc(__package__, __doc__)
 
-from .alphabet import Alphabet, build_alphabet
-from .morphism import WordMorphism
-from .paths import WordPaths
-from .word import Word
-from .word_options import WordOptions
-from .word_generators import words
-from .words import Words, FiniteWords, InfiniteWords
-from .lyndon_word import LyndonWord, LyndonWords, StandardBracketedLyndonWords
+from sage.combinat.words.alphabet import Alphabet, build_alphabet
+from sage.combinat.words.morphism import WordMorphism
+from sage.combinat.words.paths import WordPaths
+from sage.combinat.words.word import Word
+from sage.combinat.words.word_options import WordOptions
+from sage.combinat.words.word_generators import words
+from sage.combinat.words.words import Words, FiniteWords, InfiniteWords
+from sage.combinat.words.lyndon_word import LyndonWord, LyndonWords, StandardBracketedLyndonWords
diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
index e5a82735137..d5b5e51e8bc 100644
--- a/src/sage/cpython/atexit.pyx
+++ b/src/sage/cpython/atexit.pyx
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 
 """Utilities for interfacing with the standard library's atexit module."""
 
diff --git a/src/sage/cpython/string.pyx b/src/sage/cpython/string.pyx
index a35fbd41881..0bf650ef85a 100644
--- a/src/sage/cpython/string.pyx
+++ b/src/sage/cpython/string.pyx
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 """
 String <-> bytes encoding/decoding
 
diff --git a/src/sage/crypto/boolean_function.pyx b/src/sage/crypto/boolean_function.pyx
index 70833c63dc3..e12ae15dbc8 100644
--- a/src/sage/crypto/boolean_function.pyx
+++ b/src/sage/crypto/boolean_function.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Boolean functions
 
diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
index e90ffea8fca..9d5e2029407 100644
--- a/src/sage/data_structures/bitset.pyx
+++ b/src/sage/data_structures/bitset.pyx
@@ -857,7 +857,6 @@ cdef class FrozenBitset:
         """
         return bitset_bytes(self._bitset)
 
-
     def __repr__(self):
         """
         Return a string representing the bitset as a binary vector.
diff --git a/src/sage/data_structures/blas_dict.pyx b/src/sage/data_structures/blas_dict.pyx
index c13cab2aab9..2aec4dceeb5 100644
--- a/src/sage/data_structures/blas_dict.pyx
+++ b/src/sage/data_structures/blas_dict.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Basic Linear Algebra Subroutines on dictionaries
 
diff --git a/src/sage/data_structures/bounded_integer_sequences.pyx b/src/sage/data_structures/bounded_integer_sequences.pyx
index 40638ab399c..7119ffdd3d5 100644
--- a/src/sage/data_structures/bounded_integer_sequences.pyx
+++ b/src/sage/data_structures/bounded_integer_sequences.pyx
@@ -126,6 +126,7 @@ cimport cython
 # (De)allocation, copying
 #
 
+
 @cython.overflowcheck
 cdef bint biseq_init(biseq_t R, mp_size_t l, mp_bitcnt_t itemsize) except -1:
     """
@@ -1388,6 +1389,7 @@ cpdef BoundedIntegerSequence NewBISEQ(tuple bitset_data, mp_bitcnt_t itembitsize
     biseq_unpickle(out.data, bitset_data, itembitsize, length)
     return out
 
+
 def _biseq_stresstest():
     """
     This function creates many bounded integer sequences and manipulates them
diff --git a/src/sage/databases/all.py b/src/sage/databases/all.py
index a6571c7a5df..1f1e9ace1d8 100644
--- a/src/sage/databases/all.py
+++ b/src/sage/databases/all.py
@@ -5,7 +5,7 @@
 
     * CremonaDatabase() - Cremona's tables of elliptic curves and related data.
 
-    * findstat -- The FindStat database (http://www.findstat.org/).
+    * findstat -- The FindStat database (https://www.findstat.org/).
 
     * JonesDatabase() -- returns the John Jones table of number fields
       with bounded ramification and degree <= 6.
@@ -48,7 +48,7 @@
 # ****************************************************************************
 from sage.misc.lazy_import import lazy_import
 
-from .sql_db import SQLQuery, SQLDatabase
+from sage.databases.sql_db import SQLQuery, SQLDatabase
 
 lazy_import('sage.databases.conway', 'ConwayPolynomials')
 
@@ -67,16 +67,17 @@
 
 lazy_import('sage.databases.odlyzko', 'zeta_zeros')
 
-from .db_modular_polynomials import \
-     ClassicalModularPolynomialDatabase, \
-     DedekindEtaModularPolynomialDatabase, \
-     DedekindEtaModularCorrespondenceDatabase, \
-     AtkinModularPolynomialDatabase, \
-     AtkinModularCorrespondenceDatabase
+from sage.databases.db_modular_polynomials import \
+    ClassicalModularPolynomialDatabase, \
+    DedekindEtaModularPolynomialDatabase, \
+    DedekindEtaModularCorrespondenceDatabase, \
+    AtkinModularPolynomialDatabase, \
+    AtkinModularCorrespondenceDatabase
 
-from .db_class_polynomials import \
-     HilbertClassPolynomialDatabase
+from sage.databases.db_class_polynomials import \
+    HilbertClassPolynomialDatabase
 
 lazy_import('sage.databases.cunningham_tables', 'cunningham_prime_factors')
 
 lazy_import('sage.databases.findstat', ['findstat', 'findmap'])
+del lazy_import
diff --git a/src/sage/databases/conway.py b/src/sage/databases/conway.py
index 54912a2471c..7c7c3af42ac 100644
--- a/src/sage/databases/conway.py
+++ b/src/sage/databases/conway.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Frank Lübeck's tables of Conway polynomials over finite fields
 """
diff --git a/src/sage/databases/cubic_hecke_db.py b/src/sage/databases/cubic_hecke_db.py
index ad3dc8cd399..c4c2eab0f8c 100644
--- a/src/sage/databases/cubic_hecke_db.py
+++ b/src/sage/databases/cubic_hecke_db.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Cubic Hecke database
 
diff --git a/src/sage/databases/findstat.py b/src/sage/databases/findstat.py
index 062bde84b74..3b27e18a06d 100644
--- a/src/sage/databases/findstat.py
+++ b/src/sage/databases/findstat.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 FindStat - the search engine for combinatorial statistics and maps
 
diff --git a/src/sage/databases/knotinfo_db.py b/src/sage/databases/knotinfo_db.py
index 8817a304d85..3d8f8897aec 100644
--- a/src/sage/databases/knotinfo_db.py
+++ b/src/sage/databases/knotinfo_db.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 KnotInfo database
 
diff --git a/src/sage/databases/oeis.py b/src/sage/databases/oeis.py
index 040a2460289..8af804b6a0a 100644
--- a/src/sage/databases/oeis.py
+++ b/src/sage/databases/oeis.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 The On-Line Encyclopedia of Integer Sequences (OEIS)
 
@@ -111,7 +110,7 @@
     sage: b.formulas()[0]
     'E.g.f.: exp(exp(x) - 1).'
     sage: [i for i in b.comments() if 'prime' in i][-1]
-    'Number n is prime if ...'
+    'When n is prime, ...'
     sage: [n for n in range(2, 20) if (b(n)-2) % n == 0]
     [2, 3, 5, 7, 11, 13, 17, 19]
 
@@ -500,7 +499,8 @@ def find_by_description(self, description, max_results=3, first_result=0):
                    'start': str(first_result)}
         url = oeis_url + "search?" + urlencode(options)
         sequence_list = _fetch(url).split('\n\n')[2:-1]
-        return FancyTuple([self.find_by_entry(entry=_) for _ in sequence_list])
+        T = [self.find_by_entry(entry=s) for s in sequence_list]
+        return FancyTuple([s for s in T if not s.is_dead()])
 
     def find_by_subsequence(self, subsequence, max_results=3, first_result=0):
         r"""
@@ -729,6 +729,10 @@ def _field(self, key, warn=True):
 
         This method allows to handle the ``_fields`` dictionary in a lazy way.
 
+        INPUT:
+
+        - ``warn`` -- ignored
+
         TESTS::
 
             sage: s = oeis._imaginary_sequence()
@@ -742,7 +746,6 @@ def _field(self, key, warn=True):
             for line in self.raw_entry().splitlines():
                 fields[line[1]].append(line[11:])
             self._fields = fields
-            self.is_dead(warn_only=warn)
             return self._fields[key]
 
     def id(self, format='A'):
@@ -1103,25 +1106,18 @@ def natural_object(self):
             from sage.rings.integer_ring import ZZ
             return Sequence(self.first_terms(), ZZ)
 
-    def is_dead(self, warn_only=False):
+    def is_dead(self, warn_only=False) -> bool:
         r"""
-        Tell whether the sequence is dead (i.e. erroneous).
+        Tell whether the sequence is dead.
 
         INPUT:
 
-        - warn_only -- (bool, default: ``False``), whether to warn when the
-          sequence is dead instead of returning a boolean.
+        - ``warn_only`` -- ignored
 
         EXAMPLES:
 
-        A warning is triggered if any field of a dead sequence is accessed,
-        unless :meth:`is_dead` is called before::
-
             sage: s = oeis(17)                      # optional -- internet
             sage: s                                 # optional -- internet
-            doctest:warning
-            ...
-            RuntimeWarning: This sequence is dead: "A000017: Erroneous version of A032522."
             A000017: Erroneous version of A032522.
 
         TESTS::
@@ -1135,20 +1131,12 @@ def is_dead(self, warn_only=False):
 
             sage: u = oeis._imaginary_sequence(ident='A999994', keywords='dead')
             sage: u
-            doctest:warning
-            ...
-            RuntimeWarning: This sequence is dead: "A999994: The characteristic sequence of 42 plus one, starting from 38."
             A999994: The characteristic sequence of 42 plus one, starting from 38.
 
             sage: u.is_dead()
             True
         """
-        if warn_only:
-            if 'dead' in self.keywords(warn_only):
-                from warnings import warn
-                warn('This sequence is dead: "{}: {}"'.format(self.id(), self.name()), RuntimeWarning)
-        else:
-            return 'dead' in self.keywords(warn_only)
+        return 'dead' in self.keywords()
 
     def is_finite(self):
         r"""
@@ -1269,9 +1257,6 @@ def first_terms(self, number=None):
         Handle dead sequences, see :issue:`17330` ::
 
             sage: oeis(5000).first_terms(12)            # optional -- internet
-            doctest:warning
-            ...
-            RuntimeWarning: This sequence is dead: "A005000: Erroneous version of A006505."
             (1, 0, 0, 1, 1, 1, 11, 36, 92, 491, 2537)
 
         TESTS::
@@ -1559,13 +1544,14 @@ def links(self, browse=None, format='guess'):
         """
         def url_absolute(s):
             return re.sub(r'\"\/', '\"' + oeis_url, s)
+
         if browse is None:
             if format == 'guess':
                 return self.links(format='url')
             elif format == 'raw':
                 return FancyTuple(self._field('H'))
             elif format == 'html':
-                return HtmlFragment(FancyTuple([url_absolute(_) for _ in self._field('H')]))
+                return HtmlFragment(FancyTuple([url_absolute(f) for f in self._field('H')]))
             elif format == 'url':
                 url_list = flatten([_urls(url_absolute(string)) for string in self._field('H')])
                 return FancyTuple(url_list)
@@ -1602,7 +1588,6 @@ def formulas(self):
             sage: s = oeis._imaginary_sequence()
             sage: s.formulas()
             0: For n big enough, s(n+1) - s(n) = 0.
-
         """
         return FancyTuple(self._field('F'))
 
@@ -1618,7 +1603,7 @@ def cross_references(self, fetch=False):
         OUTPUT:
 
         - if ``fetch`` is ``False``, return a list of OEIS IDs (strings).
-        - if ``fetch`` if ``True``, return a tuple of OEIS sequences.
+        - if ``fetch`` is ``True``, return a tuple of OEIS sequences.
 
         EXAMPLES::
 
@@ -1648,9 +1633,9 @@ def cross_references(self, fetch=False):
         """
         ref_list = re.findall('A[0-9]{6}', " ".join(self._field('Y')))
         if fetch:
-            return FancyTuple([oeis.find_by_id(_) for _ in ref_list])
-        else:
-            return tuple(ref_list)
+            T = [oeis.find_by_id(r) for r in ref_list]
+            return FancyTuple([s for s in T if not s.is_dead()])
+        return tuple(ref_list)
 
     def extensions_or_errors(self):
         r"""
@@ -1676,7 +1661,6 @@ def extensions_or_errors(self):
             sage: s = oeis._imaginary_sequence()
             sage: s.extensions_or_errors()
             0: This sequence does not contain errors.
-
         """
         return FancyTuple(self._field('E'))
 
@@ -2010,13 +1994,9 @@ def test_compile_sage_code(self):
 
             sage: s = oeis.find_by_id('A000154')        # optional -- internet
             sage: s.test_compile_sage_code()            # optional -- internet
-            doctest:warning
-            ...
-            RuntimeWarning: This sequence is dead: ...
             True
         """
         if self.is_dead():
-            self.is_dead(warn_only=True)
             return True
         filt = self.programs(language='sage')
         if filt:
diff --git a/src/sage/databases/sql_db.py b/src/sage/databases/sql_db.py
index ebc6d5f0eea..cae2b9c8430 100644
--- a/src/sage/databases/sql_db.py
+++ b/src/sage/databases/sql_db.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Relational (sqlite) Databases Module
 
diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py
index 8485525f8e0..ef70ddf9298 100644
--- a/src/sage/doctest/parsing.py
+++ b/src/sage/doctest/parsing.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 """
 Parsing docstrings
 
diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
index 68da2754fc9..344122a02e2 100644
--- a/src/sage/doctest/reporting.py
+++ b/src/sage/doctest/reporting.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Reporting doctest results
 
diff --git a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py
index 6938068bbc6..a1e4bc1700d 100644
--- a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py
@@ -50,7 +50,7 @@ class initialization directly.
 from sage.schemes.affine.affine_morphism import SchemeMorphism_polynomial_affine_space
 from sage.schemes.affine.affine_morphism import SchemeMorphism_polynomial_affine_space_field
 from sage.schemes.affine.affine_morphism import SchemeMorphism_polynomial_affine_space_finite_field
-from sage.schemes.affine.affine_space import is_AffineSpace
+from sage.schemes.affine.affine_space import AffineSpace_generic
 from sage.schemes.affine.affine_space import AffineSpace
 from sage.schemes.affine.affine_subscheme import AlgebraicScheme_subscheme_affine
 from sage.schemes.generic.morphism import SchemeMorphism_polynomial
@@ -246,7 +246,7 @@ def __classcall_private__(cls, morphism_or_polys, domain=None):
             R = morphism.base_ring()
             polys = list(morphism)
             domain = morphism.domain()
-            if not is_AffineSpace(domain) and not isinstance(domain, AlgebraicScheme_subscheme_affine):
+            if not isinstance(domain, AffineSpace_generic) and not isinstance(domain, AlgebraicScheme_subscheme_affine):
                 raise ValueError('"domain" must be an affine scheme')
             if domain != morphism_or_polys.codomain():
                 raise ValueError('domain and codomain do not agree')
@@ -295,7 +295,7 @@ def __classcall_private__(cls, morphism_or_polys, domain=None):
         R = domain.base_ring()
         if isinstance(R, sage.rings.abc.SymbolicRing):
             raise TypeError("symbolic ring cannot be the base ring")
-        if not is_AffineSpace(domain) and not isinstance(domain, AlgebraicScheme_subscheme_affine):
+        if not isinstance(domain, AffineSpace_generic) and not isinstance(domain, AlgebraicScheme_subscheme_affine):
             raise ValueError('"domain" must be an affine scheme')
 
         if R not in Fields():
@@ -523,8 +523,8 @@ def dynatomic_polynomial(self, period):
             sage: G.dehomogenize(1).dynatomic_polynomial(2)
             (1/4*c + 1/4)*x^2 + (-c - 1/2)*x + c + 1
         """
-        from sage.schemes.affine.affine_space import is_AffineSpace
-        if not is_AffineSpace(self.domain()):
+        from sage.schemes.affine.affine_space import AffineSpace_generic
+        if not isinstance(self.domain(), AffineSpace_generic):
             raise NotImplementedError("not implemented for subschemes")
         if self.domain().dimension_relative() > 1:
             raise TypeError("does not make sense in dimension >1")
@@ -1065,8 +1065,8 @@ def cyclegraph(self):
         """
         V = []
         E = []
-        from sage.schemes.affine.affine_space import is_AffineSpace
-        if is_AffineSpace(self.domain()):
+        from sage.schemes.affine.affine_space import AffineSpace_generic
+        if isinstance(self.domain(), AffineSpace_generic):
             for P in self.domain():
                 V.append(str(P))
                 Q = self(P)
diff --git a/src/sage/dynamics/arithmetic_dynamics/all.py b/src/sage/dynamics/arithmetic_dynamics/all.py
index f536734b5d9..66773e29d76 100644
--- a/src/sage/dynamics/arithmetic_dynamics/all.py
+++ b/src/sage/dynamics/arithmetic_dynamics/all.py
@@ -1,12 +1,13 @@
 from sage.misc.lazy_import import lazy_import
 
-from .generic_ds import DynamicalSystem
-from .affine_ds import DynamicalSystem_affine
-from .projective_ds import DynamicalSystem_projective
-from .product_projective_ds import DynamicalSystem_product_projective
-from .berkovich_ds import DynamicalSystem_Berkovich
-from .dynamical_semigroup import DynamicalSemigroup
-from .dynamical_semigroup import DynamicalSemigroup_affine
-from .dynamical_semigroup import DynamicalSemigroup_projective
+from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem
+from sage.dynamics.arithmetic_dynamics.affine_ds import DynamicalSystem_affine
+from sage.dynamics.arithmetic_dynamics.projective_ds import DynamicalSystem_projective
+from sage.dynamics.arithmetic_dynamics.product_projective_ds import DynamicalSystem_product_projective
+from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich
+from sage.dynamics.arithmetic_dynamics.dynamical_semigroup import DynamicalSemigroup
+from sage.dynamics.arithmetic_dynamics.dynamical_semigroup import DynamicalSemigroup_affine
+from sage.dynamics.arithmetic_dynamics.dynamical_semigroup import DynamicalSemigroup_projective
 lazy_import('sage.dynamics.arithmetic_dynamics.wehlerK3', 'WehlerK3Surface')
 lazy_import('sage.dynamics.arithmetic_dynamics.wehlerK3', 'random_WehlerK3Surface')
+del lazy_import
diff --git a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py
index 5559a48ecce..be1ef46b251 100644
--- a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py
@@ -34,11 +34,11 @@
 from sage.rings.infinity import Infinity
 from sage.rings.integer_ring import ZZ
 from sage.rings.rational_field import QQ
-from sage.schemes.affine.affine_space import is_AffineSpace
+from sage.schemes.affine.affine_space import AffineSpace_generic
 from sage.schemes.berkovich.berkovich_space import (Berkovich_Cp_Affine,
-                                Berkovich_Cp_Projective, is_Berkovich_Cp,
+                                Berkovich_Cp_Projective, Berkovich_Cp,
                                 Berkovich_Element_Cp_Affine)
-from sage.schemes.projective.projective_space import is_ProjectiveSpace
+from sage.schemes.projective.projective_space import ProjectiveSpace_ring
 from sage.structure.element import Element
 
 lazy_import('sage.rings.padics.padic_base_generic', 'pAdicBaseGeneric')
@@ -241,7 +241,7 @@ def __classcall_private__(cls, dynamical_system, domain=None, ideal=None):
                     2*3^7 + 2*3^8 + 2*3^9 + 2*3^10 + 2*3^11 + 2*3^12 + 2*3^13 + 2*3^14 +
                     2*3^15 + 2*3^16 + 2*3^17 + 2*3^18 + 2*3^19 + 2*3^20 + O(3^21))
         """
-        if not (is_Berkovich_Cp(domain) or domain is None):
+        if not (isinstance(domain, Berkovich_Cp) or domain is None):
             raise TypeError('domain must be a Berkovich space over Cp, not %s' % domain)
 
         if isinstance(domain, Berkovich_Cp_Affine):
@@ -269,7 +269,7 @@ def __classcall_private__(cls, dynamical_system, domain=None, ideal=None):
         if not isinstance(morphism_domain.base_ring(), pAdicBaseGeneric):
             if morphism_domain.base_ring() in NumberFields():
                 if domain is None and ideal is not None:
-                    if is_AffineSpace(morphism_domain):
+                    if isinstance(morphism_domain, AffineSpace_generic):
                         domain = Berkovich_Cp_Affine(morphism_domain.base_ring(), ideal)
                     else:
                         domain = Berkovich_Cp_Projective(morphism_domain, ideal)
@@ -281,7 +281,7 @@ def __classcall_private__(cls, dynamical_system, domain=None, ideal=None):
                 raise ValueError('base ring of domain of dynamical_system must be p-adic or a number field '
                     'not %s' % morphism_domain.base_ring())
 
-        if is_AffineSpace(morphism_domain):
+        if isinstance(morphism_domain, AffineSpace_generic):
             return DynamicalSystem_Berkovich_affine(dynamical_system, domain)
 
         return DynamicalSystem_Berkovich_projective(dynamical_system, domain)
@@ -531,7 +531,7 @@ def __classcall_private__(cls, dynamical_system, domain=None):
                 raise TypeError('affine dynamical system passed to projective constructor')
         R = dynamical_system.base_ring()
         morphism_domain = dynamical_system.domain()
-        if not is_ProjectiveSpace(morphism_domain):
+        if not isinstance(morphism_domain, ProjectiveSpace_ring):
             raise TypeError('the domain of dynamical_system must be projective space, not %s' % morphism_domain)
         if morphism_domain.dimension_relative() != 1:
             raise ValueError('domain was not relative dimension 1')
@@ -1015,7 +1015,7 @@ def __classcall_private__(cls, dynamical_system, domain=None):
                 raise TypeError('projective dynamical system passed to affine constructor')
         R = dynamical_system.base_ring()
         morphism_domain = dynamical_system.domain()
-        if not is_AffineSpace(morphism_domain):
+        if not isinstance(morphism_domain, AffineSpace_generic):
             raise TypeError('the domain of dynamical_system must be affine space, not %s' % morphism_domain)
         if morphism_domain.dimension_relative() != 1:
             raise ValueError('domain not relative dimension 1')
diff --git a/src/sage/dynamics/arithmetic_dynamics/generic_ds.py b/src/sage/dynamics/arithmetic_dynamics/generic_ds.py
index 0afff17895c..be678cca40a 100644
--- a/src/sage/dynamics/arithmetic_dynamics/generic_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/generic_ds.py
@@ -34,9 +34,9 @@ class initialization directly.
 from sage.misc.lazy_import import lazy_import
 from sage.rings.finite_rings.finite_field_base import FiniteField
 from sage.rings.rational_field import QQ
-from sage.schemes.affine.affine_space import is_AffineSpace
+from sage.schemes.affine.affine_space import AffineSpace_generic
 from sage.schemes.affine.affine_subscheme import AlgebraicScheme_subscheme_affine
-from sage.schemes.berkovich.berkovich_space import is_Berkovich_Cp
+from sage.schemes.berkovich.berkovich_space import Berkovich_Cp
 from sage.schemes.generic.morphism import SchemeMorphism_polynomial
 
 lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic')
@@ -165,10 +165,10 @@ def __classcall_private__(cls, morphism_or_polys, domain=None, names=None):
         if isinstance(morphism_or_polys, SchemeMorphism_polynomial):
             domain = morphism_or_polys.domain()
         if domain is not None:
-            if is_AffineSpace(domain) or isinstance(domain, AlgebraicScheme_subscheme_affine):
+            if isinstance(domain, AffineSpace_generic) or isinstance(domain, AlgebraicScheme_subscheme_affine):
                 from sage.dynamics.arithmetic_dynamics.affine_ds import DynamicalSystem_affine
                 return DynamicalSystem_affine(morphism_or_polys, domain)
-            if is_Berkovich_Cp(domain):
+            if isinstance(domain, Berkovich_Cp):
                 from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich
                 return DynamicalSystem_Berkovich(morphism_or_polys,domain)
 
diff --git a/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py
index 44565197717..706bb28cbef 100644
--- a/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py
@@ -327,8 +327,8 @@ def cyclegraph(self):
         """
         V = []
         E = []
-        from sage.schemes.product_projective.space import is_ProductProjectiveSpaces
-        if is_ProductProjectiveSpaces(self.domain()):
+        from sage.schemes.product_projective.space import ProductProjectiveSpaces_ring
+        if isinstance(self.domain(), ProductProjectiveSpaces_ring):
             for P in self.domain():
                 V.append(str(P))
                 Q = self(P)
diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
index 4b42ad87b1f..9bd6aa91a48 100644
--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Dynamical systems on projective schemes
 
@@ -103,12 +102,12 @@ class initialization directly.
 from sage.rings.rational_field import QQ
 from sage.rings.real_mpfr import RealField
 from sage.schemes.generic.morphism import SchemeMorphism_polynomial
-from sage.schemes.product_projective.space import is_ProductProjectiveSpaces
+from sage.schemes.product_projective.space import ProductProjectiveSpaces_ring
 from sage.schemes.projective.projective_morphism import (
     SchemeMorphism_polynomial_projective_space,
     SchemeMorphism_polynomial_projective_space_field,
     SchemeMorphism_polynomial_projective_space_finite_field)
-from sage.schemes.projective.projective_space import ProjectiveSpace, is_ProjectiveSpace
+from sage.schemes.projective.projective_space import ProjectiveSpace, ProjectiveSpace_ring
 from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective
 from sage.structure.element import get_coercion_model
 
@@ -374,7 +373,7 @@ def __classcall_private__(cls, morphism_or_polys, domain=None, names=None):
             polys = list(morphism_or_polys)
             if domain != morphism_or_polys.codomain():
                 raise ValueError('domain and codomain do not agree')
-            if not is_ProjectiveSpace(domain) and not isinstance(domain, AlgebraicScheme_subscheme_projective):
+            if not isinstance(domain, ProjectiveSpace_ring) and not isinstance(domain, AlgebraicScheme_subscheme_projective):
                 raise ValueError('"domain" must be a projective scheme')
             if R not in Fields():
                 return typecall(cls, polys, domain)
@@ -430,7 +429,7 @@ def __classcall_private__(cls, morphism_or_polys, domain=None, names=None):
         if isinstance(R, sage.rings.abc.SymbolicRing):
             raise TypeError("the base ring cannot be the Symbolic Ring or a symbolic subring")
 
-        if is_ProductProjectiveSpaces(domain):
+        if isinstance(domain, ProductProjectiveSpaces_ring):
             splitpolys = domain._factors(polys)
             for split_poly in splitpolys:
                 split_d = domain._degree(split_poly[0])
@@ -451,7 +450,7 @@ def __classcall_private__(cls, morphism_or_polys, domain=None, names=None):
             msg = 'polys (={}) must be of the same degree'
             raise ValueError(msg.format(polys))
 
-        if not is_ProjectiveSpace(domain) and not isinstance(domain, AlgebraicScheme_subscheme_projective):
+        if not isinstance(domain, ProjectiveSpace_ring) and not isinstance(domain, AlgebraicScheme_subscheme_projective):
             raise ValueError('"domain" must be a projective scheme')
         if R not in Fields():
             return typecall(cls, polys, domain)
@@ -1264,7 +1263,7 @@ def arakelov_zhang_pairing(self, g, **kwds):
         if n <= 0:
             raise ValueError("Period must be a positive integer.")
 
-        if not (is_ProjectiveSpace(f_domain) and is_ProjectiveSpace(g_domain)):
+        if not (isinstance(f_domain, ProjectiveSpace_ring) and isinstance(g_domain, ProjectiveSpace_ring)):
             raise NotImplementedError("Not implemented for subschemes.")
 
         if f_domain.dimension_relative() > 1:
@@ -1804,7 +1803,7 @@ def primes_of_bad_reduction(self, check=True):
             sage: f.primes_of_bad_reduction()                                           # needs sage.rings.function_field
             [5, 37, 2239, 304432717]
         """
-        if (not is_ProjectiveSpace(self.domain())) or (not is_ProjectiveSpace(self.codomain())):
+        if (not isinstance(self.domain(), ProjectiveSpace_ring)) or (not isinstance(self.codomain(), ProjectiveSpace_ring)):
             raise NotImplementedError("not implemented for subschemes")
         K = FractionField(self.codomain().base_ring())
         #The primes of bad reduction are the support of the resultant for number fields
@@ -3771,7 +3770,7 @@ def critical_subscheme(self):
             TypeError: the function is not a morphism
         """
         PS = self.domain()
-        if not is_ProjectiveSpace(PS):
+        if not isinstance(PS, ProjectiveSpace_ring):
             raise NotImplementedError("not implemented for subschemes")
         if not self.is_morphism():
             raise TypeError("the function is not a morphism")
@@ -4080,7 +4079,7 @@ def is_dynamical_belyi_map(self):
             False
         """
         P = self.codomain()
-        if not is_ProjectiveSpace(P):
+        if not isinstance(P, ProjectiveSpace_ring):
             raise NotImplementedError('only implemented for dynamical systems on projective space')
         if P.dimension_relative() != 1:
             raise NotImplementedError('only implemented for maps on projective space of dimension 1')
@@ -5238,7 +5237,7 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur
 
         if (n < 1):
             raise ValueError("period must be a positive integer")
-        if not is_ProjectiveSpace(PS):
+        if not isinstance(PS, ProjectiveSpace_ring):
             raise NotImplementedError("not implemented for subschemes")
 
         if PS.dimension_relative() > 1:
@@ -5746,7 +5745,7 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point',
         if n < 1:
             raise ValueError("period must be a positive integer")
         dom = self.domain()
-        if not is_ProjectiveSpace(dom):
+        if not isinstance(dom, ProjectiveSpace_ring):
             raise NotImplementedError("not implemented for subschemes")
         if self.degree() <= 1:
             raise TypeError("must have degree at least 2")
@@ -6397,7 +6396,7 @@ def _is_preperiodic(self, P, err=0.1, return_period=False):
             True
         """
         codomain = self.codomain()
-        if not is_ProjectiveSpace(codomain):
+        if not isinstance(codomain, ProjectiveSpace_ring):
             # in order to calculate the canonical height, we need
             # this map to be a morphism of projective space
             ambient_space = codomain.ambient_space()
@@ -6516,7 +6515,7 @@ def postcritical_set(self, check=True):
             sage: g.postcritical_set()
             [(1 : 0), (0 : 1), (a + 2 : 1)]
         """
-        if not is_ProjectiveSpace(self.domain()):
+        if not isinstance(self.domain(), ProjectiveSpace_ring):
             raise ValueError('must be a dynamical system on projective space')
         if self.domain().dimension_relative() != 1:
             raise ValueError('must be defined on projective space of dimension 1')
@@ -9106,7 +9105,7 @@ def cyclegraph(self):
         """
         V = []
         E = []
-        if is_ProjectiveSpace(self.domain()):
+        if isinstance(self.domain(), ProjectiveSpace_ring):
             for P in self.domain():
                 V.append(P)
                 try:
diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx b/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx
index f05806f4935..ed616b19181 100644
--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx
+++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx
@@ -82,8 +82,8 @@ cpdef _fast_possible_periods(self, return_points=False):
         raise TypeError("must be prime field")
 
     PS = self.domain()
-    from sage.schemes.projective.projective_space import is_ProjectiveSpace
-    if not is_ProjectiveSpace(PS) or PS != self.codomain():
+    from sage.schemes.projective.projective_space import ProjectiveSpace_ring
+    if not isinstance(PS, ProjectiveSpace_ring) or PS != self.codomain():
         raise NotImplementedError("must be an endomorphism of projective space")
 
     p = PS.base_ring().order()
@@ -178,6 +178,7 @@ def _enum_points(int prime, int dimension):
             yield _get_point_from_hash(value, prime, dimension)
         current_range = current_range * prime
 
+
 cpdef int _hash(list Point, int prime) noexcept:
     """
     Hash point given as list to unique number.
diff --git a/src/sage/dynamics/cellular_automata/elementary.py b/src/sage/dynamics/cellular_automata/elementary.py
index 26e68c37b01..77d5b705fcb 100644
--- a/src/sage/dynamics/cellular_automata/elementary.py
+++ b/src/sage/dynamics/cellular_automata/elementary.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 """
 Elementary Cellular Automata
 
diff --git a/src/sage/dynamics/cellular_automata/glca.py b/src/sage/dynamics/cellular_automata/glca.py
index 6b062f2a441..8c896a981e9 100644
--- a/src/sage/dynamics/cellular_automata/glca.py
+++ b/src/sage/dynamics/cellular_automata/glca.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 """
 Graftal Lace Cellular Automata
 
diff --git a/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx b/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx
index 43ce0effd58..07794702909 100644
--- a/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx
+++ b/src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx
@@ -59,6 +59,7 @@ def _color_to_RGB(color):
         color = [int(255.0 * k) for k in Color(color)]
     return tuple(color)
 
+
 cpdef fast_mandelbrot_plot(double x_center, double y_center,
  double image_width, long max_iteration, long pixel_count,
  long level_sep, long color_num, base_color):
diff --git a/src/sage/ext/fast_callable.pyx b/src/sage/ext/fast_callable.pyx
index b9072da61c5..2904ce78a71 100644
--- a/src/sage/ext/fast_callable.pyx
+++ b/src/sage/ext/fast_callable.pyx
@@ -608,6 +608,7 @@ def function_name(fn):
     except AttributeError:
         return "{%r}" % fn
 
+
 cdef class ExpressionTreeBuilder:
     r"""
     A class with helper methods for building Expressions.
@@ -1713,6 +1714,7 @@ class IntegerPowerFunction():
         """
         return x**self.exponent
 
+
 cdef dict builtin_functions = None
 cpdef dict get_builtin_functions():
     r"""
@@ -2426,6 +2428,7 @@ class CompilerInstrSpec():
         """
         return "CompilerInstrSpec(%d, %d, %s)" % (self.n_inputs, self.n_outputs, self.parameters)
 
+
 def op_list(args, metadata):
     r"""
     Given a dictionary with the result of calling get_current on an
diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
index 26a5c848bb5..b5d9e422410 100644
--- a/src/sage/ext/memory.pyx
+++ b/src/sage/ext/memory.pyx
@@ -93,4 +93,5 @@ def init_memory_functions():
     """
     mp_set_memory_functions(sage_sig_malloc, sage_sig_realloc, sage_sig_free)
 
+
 init_memory_functions()
diff --git a/src/sage/features/__init__.py b/src/sage/features/__init__.py
index 86a777ee915..b8deaa350e5 100644
--- a/src/sage/features/__init__.py
+++ b/src/sage/features/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Testing for features of the environment at runtime
 
diff --git a/src/sage/features/csdp.py b/src/sage/features/csdp.py
index 8f2e18dc182..b5aaa80e0bf 100644
--- a/src/sage/features/csdp.py
+++ b/src/sage/features/csdp.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Feature for testing the presence of ``csdp``
 """
diff --git a/src/sage/features/ecm.py b/src/sage/features/ecm.py
index 79a1e77918f..980878cd9f7 100644
--- a/src/sage/features/ecm.py
+++ b/src/sage/features/ecm.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Feature for testing the presence of ``ecm`` or ``gmp-ecm``
 """
diff --git a/src/sage/features/lrs.py b/src/sage/features/lrs.py
index 6eb0a11b642..97897bc23c8 100644
--- a/src/sage/features/lrs.py
+++ b/src/sage/features/lrs.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Feature for testing the presence of ``lrslib``
 """
diff --git a/src/sage/features/msolve.py b/src/sage/features/msolve.py
index c90f7e5aaf6..9d58a25628e 100644
--- a/src/sage/features/msolve.py
+++ b/src/sage/features/msolve.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Feature for testing the presence of msolve
 
diff --git a/src/sage/features/pandoc.py b/src/sage/features/pandoc.py
index 00ee6055024..275ba2c9b36 100644
--- a/src/sage/features/pandoc.py
+++ b/src/sage/features/pandoc.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Feature for testing the presence of ``pandoc``
 """
diff --git a/src/sage/functions/all.py b/src/sage/functions/all.py
index 4cf9005f7e3..4e4c092bc0f 100644
--- a/src/sage/functions/all.py
+++ b/src/sage/functions/all.py
@@ -3,91 +3,94 @@
 
 lazy_import('sage.functions.piecewise', 'piecewise')
 lazy_import('sage.functions.error', ['erf', 'erfc', 'erfi', 'erfinv',
-    'fresnel_sin', 'fresnel_cos'])
+                                     'fresnel_sin', 'fresnel_cos'])
 
-from .trig import ( sin, cos, sec, csc, cot, tan,
-                   asin, acos, atan,
-                   acot, acsc, asec,
-                   arcsin, arccos, arctan,
-                   arccot, arccsc, arcsec,
-                   arctan2, atan2)
+from sage.functions.trig import (sin, cos, sec, csc, cot, tan,
+                                 asin, acos, atan,
+                                 acot, acsc, asec,
+                                 arcsin, arccos, arctan,
+                                 arccot, arccsc, arcsec,
+                                 arctan2, atan2)
 
-from .hyperbolic import ( tanh, sinh, cosh, coth, sech, csch,
-                         asinh, acosh, atanh, acoth, asech, acsch,
-                         arcsinh, arccosh, arctanh, arccoth, arcsech, arccsch )
+from sage.functions.hyperbolic import (tanh, sinh, cosh, coth, sech, csch,
+                                       asinh, acosh, atanh, acoth, asech, acsch,
+                                       arcsinh, arccosh, arctanh, arccoth, arcsech, arccsch)
 
-reciprocal_trig_functions = {'sec': cos, 'csc': sin, 'cot': tan, 'sech': cosh, 'csch': sinh, 'coth': tanh}
+reciprocal_trig_functions = {'sec': cos, 'csc': sin,
+                             'cot': tan, 'sech': cosh, 'csch': sinh, 'coth': tanh}
 
 
-from .other import ( ceil, floor, abs_symbolic, sqrt, real_nth_root,
-                    arg, real_part, real, frac,
-                    factorial, binomial,
-                    imag_part, imag, imaginary, conjugate, cases,
-                    complex_root_of)
+from sage.functions.other import (ceil, floor, abs_symbolic, sqrt, real_nth_root,
+                                  arg, real_part, real, frac,
+                                  factorial, binomial,
+                                  imag_part, imag, imaginary, conjugate, cases,
+                                  complex_root_of)
 
-from .log import (exp, exp_polar, log, ln, polylog, dilog, lambert_w, harmonic_number)
+from sage.functions.log import (exp, exp_polar, log, ln,
+                                polylog, dilog, lambert_w, harmonic_number)
 
-from .transcendental import (zeta, zetaderiv, zeta_symmetric, hurwitz_zeta,
-                            dickman_rho, stieltjes)
+from sage.functions.transcendental import (zeta, zetaderiv, zeta_symmetric, hurwitz_zeta,
+                                           dickman_rho, stieltjes)
 
-from .bessel import (bessel_I, bessel_J, bessel_K, bessel_Y,
-                    Bessel, struve_H, struve_L, hankel1, hankel2,
+from sage.functions.bessel import (bessel_I, bessel_J, bessel_K, bessel_Y,
+                                   Bessel, struve_H, struve_L, hankel1, hankel2,
                                    spherical_bessel_J, spherical_bessel_Y,
                                    spherical_hankel1, spherical_hankel2)
 
-from .special import (spherical_harmonic, elliptic_e,
-                     elliptic_f, elliptic_ec, elliptic_eu,
-                     elliptic_kc, elliptic_pi, elliptic_j)
+from sage.functions.special import (spherical_harmonic, elliptic_e,
+                                    elliptic_f, elliptic_ec, elliptic_eu,
+                                    elliptic_kc, elliptic_pi, elliptic_j)
 
-from .jacobi import (jacobi, inverse_jacobi, jacobi_nd, jacobi_ns, jacobi_nc,
-                    jacobi_dn, jacobi_ds, jacobi_dc, jacobi_sn, jacobi_sd,
-                    jacobi_sc, jacobi_cn, jacobi_cd, jacobi_cs, jacobi_am,
-                    inverse_jacobi_nd, inverse_jacobi_ns, inverse_jacobi_nc,
-                    inverse_jacobi_dn, inverse_jacobi_ds, inverse_jacobi_dc,
-                    inverse_jacobi_sn, inverse_jacobi_sd, inverse_jacobi_sc,
-                    inverse_jacobi_cn, inverse_jacobi_cd, inverse_jacobi_cs)
+from sage.functions.jacobi import (jacobi, inverse_jacobi, jacobi_nd, jacobi_ns, jacobi_nc,
+                                   jacobi_dn, jacobi_ds, jacobi_dc, jacobi_sn, jacobi_sd,
+                                   jacobi_sc, jacobi_cn, jacobi_cd, jacobi_cs, jacobi_am,
+                                   inverse_jacobi_nd, inverse_jacobi_ns, inverse_jacobi_nc,
+                                   inverse_jacobi_dn, inverse_jacobi_ds, inverse_jacobi_dc,
+                                   inverse_jacobi_sn, inverse_jacobi_sd, inverse_jacobi_sc,
+                                   inverse_jacobi_cn, inverse_jacobi_cd, inverse_jacobi_cs)
 
-from .orthogonal_polys import (chebyshev_T,
-                               chebyshev_U,
-                               gen_laguerre,
-                               gen_legendre_P,
-                               gen_legendre_Q,
-                               hermite,
-                               jacobi_P,
-                               laguerre,
-                               legendre_P,
-                               legendre_Q,
-                               ultraspherical,
-                               gegenbauer,
-                               krawtchouk,
-                               meixner,
-                               hahn)
+from sage.functions.orthogonal_polys import (chebyshev_T,
+                                             chebyshev_U,
+                                             gen_laguerre,
+                                             gen_legendre_P,
+                                             gen_legendre_Q,
+                                             hermite,
+                                             jacobi_P,
+                                             laguerre,
+                                             legendre_P,
+                                             legendre_Q,
+                                             ultraspherical,
+                                             gegenbauer,
+                                             krawtchouk,
+                                             meixner,
+                                             hahn)
 
-from .spike_function import spike_function
+from sage.functions.spike_function import spike_function
 
-from .prime_pi import legendre_phi, partial_sieve_function, prime_pi
+from sage.functions.prime_pi import legendre_phi, partial_sieve_function, prime_pi
 
-from .wigner import (wigner_3j, clebsch_gordan, racah, wigner_6j,
-                    wigner_9j, gaunt)
+from sage.functions.wigner import (wigner_3j, clebsch_gordan, racah, wigner_6j,
+                                   wigner_9j, gaunt)
 
-from .generalized import (dirac_delta, heaviside, unit_step, sgn, sign,
-                         kronecker_delta)
+from sage.functions.generalized import (dirac_delta, heaviside, unit_step, sgn, sign,
+                                        kronecker_delta)
 
-from .min_max import max_symbolic, min_symbolic
+from sage.functions.min_max import max_symbolic, min_symbolic
 
-from .airy import airy_ai, airy_ai_prime, airy_bi, airy_bi_prime
+from sage.functions.airy import airy_ai, airy_ai_prime, airy_bi, airy_bi_prime
 
-from .exp_integral import (exp_integral_e, exp_integral_e1, log_integral, li, Li,
-                          log_integral_offset,
-                          sin_integral, cos_integral, Si, Ci,
-                          sinh_integral, cosh_integral, Shi, Chi,
-                          exponential_integral_1, Ei, exp_integral_ei)
+from sage.functions.exp_integral import (exp_integral_e, exp_integral_e1, log_integral, li, Li,
+                                         log_integral_offset,
+                                         sin_integral, cos_integral, Si, Ci,
+                                         sinh_integral, cosh_integral, Shi, Chi,
+                                         exponential_integral_1, Ei, exp_integral_ei)
 
-from .hypergeometric import hypergeometric, hypergeometric_M, hypergeometric_U
+from sage.functions.hypergeometric import hypergeometric, hypergeometric_M, hypergeometric_U
 
-from .gamma import (gamma, psi, beta, log_gamma,
-                    gamma_inc, gamma_inc_lower)
+from sage.functions.gamma import (gamma, psi, beta, log_gamma,
+                                  gamma_inc, gamma_inc_lower)
 
 Γ = gamma
 ψ = psi
 ζ = zeta
+del lazy_import
diff --git a/src/sage/game_theory/normal_form_game.py b/src/sage/game_theory/normal_form_game.py
index 93cfe25a883..3783018909a 100644
--- a/src/sage/game_theory/normal_form_game.py
+++ b/src/sage/game_theory/normal_form_game.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Normal form games with N players.
 
diff --git a/src/sage/games/all.py b/src/sage/games/all.py
index e3e31bcf03e..be1a1f2cbfc 100644
--- a/src/sage/games/all.py
+++ b/src/sage/games/all.py
@@ -1,2 +1,2 @@
-from .sudoku import Sudoku, sudoku
-from .hexad import Minimog
+from sage.games.sudoku import Sudoku, sudoku
+from sage.games.hexad import Minimog
diff --git a/src/sage/games/quantumino.py b/src/sage/games/quantumino.py
index d5646406882..5d47bd8b5e1 100644
--- a/src/sage/games/quantumino.py
+++ b/src/sage/games/quantumino.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Family Games America's Quantumino solver
 
diff --git a/src/sage/games/sudoku_backtrack.pyx b/src/sage/games/sudoku_backtrack.pyx
index 9d02c4fcf9a..748a34a8d31 100644
--- a/src/sage/games/sudoku_backtrack.pyx
+++ b/src/sage/games/sudoku_backtrack.pyx
@@ -4,6 +4,7 @@ This module contains Cython code for a backtracking algorithm to solve Sudoku pu
 Once Cython implements closures and the ``yield`` keyword is possible, this can be moved into the ``sage.games.sudoku`` module, as part of the ``Sudoku.backtrack`` method, and this module can be banned.
 """
 
+
 def backtrack_all(n, puzzle):
     r"""
     A routine to compute all the solutions to a Sudoku puzzle.
diff --git a/src/sage/geometry/all.py b/src/sage/geometry/all.py
index e4b4d933bc4..0115d5b3ba8 100644
--- a/src/sage/geometry/all.py
+++ b/src/sage/geometry/all.py
@@ -1,6 +1,6 @@
-from .polyhedron.all import *
-from .hyperbolic_space.all import *
-from .polyhedral_complex import PolyhedralComplex
+from sage.geometry.polyhedron.all import *
+from sage.geometry.hyperbolic_space.all import *
+from sage.geometry.polyhedral_complex import PolyhedralComplex
 from sage.misc.lazy_import import lazy_import
 
 lazy_import('sage.geometry.cone', ['Cone', 'random_cone'])
diff --git a/src/sage/geometry/polyhedron/parent.py b/src/sage/geometry/polyhedron/parent.py
index 5fad17dc55a..79a77e51556 100644
--- a/src/sage/geometry/polyhedron/parent.py
+++ b/src/sage/geometry/polyhedron/parent.py
@@ -14,7 +14,7 @@
 from sage.structure.parent import Parent
 from sage.structure.element import get_coercion_model
 from sage.structure.unique_representation import UniqueRepresentation
-from sage.modules.free_module import FreeModule, is_FreeModule
+from sage.modules.free_module import FreeModule, FreeModule_generic
 from sage.misc.cachefunc import cached_method, cached_function
 from sage.misc.lazy_import import lazy_import
 import sage.rings.abc
@@ -1009,7 +1009,7 @@ def _get_action_(self, other, op, self_is_left):
         from sage.structure.coerce_actions import ActedUponAction
         from sage.categories.action import PrecomposedAction
 
-        if op is operator.add and is_FreeModule(other):
+        if op is operator.add and isinstance(other, FreeModule_generic):
             base_ring = self._coerce_base_ring(other)
             extended_self = self.base_extend(base_ring)
             extended_other = other.base_extend(base_ring)
diff --git a/src/sage/geometry/triangulation/all.py b/src/sage/geometry/triangulation/all.py
index d40e50321f8..fa72ba05f83 100644
--- a/src/sage/geometry/triangulation/all.py
+++ b/src/sage/geometry/triangulation/all.py
@@ -1 +1 @@
-from .point_configuration import PointConfiguration
+from sage.geometry.triangulation.point_configuration import PointConfiguration
diff --git a/src/sage/graphs/all.py b/src/sage/graphs/all.py
index 68529637000..a3142e83e22 100644
--- a/src/sage/graphs/all.py
+++ b/src/sage/graphs/all.py
@@ -4,14 +4,15 @@
 lazy_import("sage.graphs.graph_generators", "graphs")
 lazy_import("sage.graphs.digraph_generators", "digraphs")
 lazy_import("sage.graphs.hypergraph_generators", "hypergraphs")
-lazy_import("sage.graphs.graph_database", ["GraphDatabase", "GenericGraphQuery", "GraphQuery"])
-from .graph import Graph
-from .digraph import DiGraph
-from .bipartite_graph import BipartiteGraph
+lazy_import("sage.graphs.graph_database", [
+            "GraphDatabase", "GenericGraphQuery", "GraphQuery"])
+from sage.graphs.graph import Graph
+from sage.graphs.digraph import DiGraph
+from sage.graphs.bipartite_graph import BipartiteGraph
 import sage.graphs.weakly_chordal
 import sage.graphs.lovasz_theta
 import sage.graphs.partial_cube
-from . import graph_list as graphs_list
+from sage.graphs import graph_list as graphs_list
 lazy_import("sage.graphs", "graph_coloring")
 lazy_import("sage.graphs.graph_database", "graph_db_info")
 lazy_import("sage.graphs.graph_editor", "graph_editor")
@@ -37,3 +38,4 @@
     ...
     NameError: name 'clique_number' is not defined
 """
+del lazy_import
diff --git a/src/sage/graphs/base/graph_backends.pyx b/src/sage/graphs/base/graph_backends.pyx
index 77961c33cf6..50e05f24e7b 100644
--- a/src/sage/graphs/base/graph_backends.pyx
+++ b/src/sage/graphs/base/graph_backends.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Backends for Sage (di)graphs
 
diff --git a/src/sage/graphs/generic_graph_pyx.pyx b/src/sage/graphs/generic_graph_pyx.pyx
index 74a6f13c1c6..e00fb5c3fb0 100644
--- a/src/sage/graphs/generic_graph_pyx.pyx
+++ b/src/sage/graphs/generic_graph_pyx.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 GenericGraph Cython functions
 
diff --git a/src/sage/graphs/graph_decompositions/clique_separators.pyx b/src/sage/graphs/graph_decompositions/clique_separators.pyx
index 0989a5a9dae..3cb10805b8a 100644
--- a/src/sage/graphs/graph_decompositions/clique_separators.pyx
+++ b/src/sage/graphs/graph_decompositions/clique_separators.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # cython: binding=True
 # distutils: language = c++
 r"""
diff --git a/src/sage/graphs/graph_decompositions/tree_decomposition.pyx b/src/sage/graphs/graph_decompositions/tree_decomposition.pyx
index 0fb9f87c6ee..f97fa2779fe 100644
--- a/src/sage/graphs/graph_decompositions/tree_decomposition.pyx
+++ b/src/sage/graphs/graph_decompositions/tree_decomposition.pyx
@@ -798,6 +798,7 @@ def treewidth(g, k=None, kmin=None, certificate=False, algorithm=None, nice=Fals
 
     return tree_decomp
 
+
 def make_nice_tree_decomposition(graph, tree_decomp):
     r"""
     Return a *nice* tree decomposition (TD) of the TD ``tree_decomp``.
diff --git a/src/sage/graphs/path_enumeration.pyx b/src/sage/graphs/path_enumeration.pyx
index 78832f89134..ed00cc46dc2 100644
--- a/src/sage/graphs/path_enumeration.pyx
+++ b/src/sage/graphs/path_enumeration.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # cython: binding=True
 # distutils: language = c++
 r"""
diff --git a/src/sage/graphs/strongly_regular_db.pyx b/src/sage/graphs/strongly_regular_db.pyx
index 27cfd3da535..b24441b3f18 100644
--- a/src/sage/graphs/strongly_regular_db.pyx
+++ b/src/sage/graphs/strongly_regular_db.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Database of strongly regular graphs
 
diff --git a/src/sage/graphs/traversals.pyx b/src/sage/graphs/traversals.pyx
index d7dfad47a30..6e13fe98ff6 100644
--- a/src/sage/graphs/traversals.pyx
+++ b/src/sage/graphs/traversals.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # cython: binding=True
 # distutils: language = c++
 r"""
diff --git a/src/sage/groups/abelian_gps/all.py b/src/sage/groups/abelian_gps/all.py
index 2bb91f85f3b..f0c228a6a90 100644
--- a/src/sage/groups/abelian_gps/all.py
+++ b/src/sage/groups/abelian_gps/all.py
@@ -2,7 +2,7 @@
 all.py -- export of abelian groups to Sage
 """
 
-#*****************************************************************************
+# *****************************************************************************
 #
 #   Sage: Open Source Mathematical Software
 #
@@ -21,9 +21,9 @@
 #*****************************************************************************
 
 #from dual_abelian_group import DualAbelianGroup
-from .abelian_group import AbelianGroup, word_problem
-from .values import AbelianGroupWithValues
+from sage.groups.abelian_gps.abelian_group import AbelianGroup, word_problem
+from sage.groups.abelian_gps.values import AbelianGroupWithValues
 
 # TODO:
 # Implement group homset, conversion of generator images to morphism
-from .abelian_group_morphism import AbelianGroupMorphism
+from sage.groups.abelian_gps.abelian_group_morphism import AbelianGroupMorphism
diff --git a/src/sage/groups/additive_abelian/all.py b/src/sage/groups/additive_abelian/all.py
index 956cf00614e..e65582f51b2 100644
--- a/src/sage/groups/additive_abelian/all.py
+++ b/src/sage/groups/additive_abelian/all.py
@@ -1,3 +1,3 @@
 
-from .additive_abelian_group import AdditiveAbelianGroup
-from .additive_abelian_wrapper import *
+from sage.groups.additive_abelian.additive_abelian_group import AdditiveAbelianGroup
+from sage.groups.additive_abelian.additive_abelian_wrapper import *
diff --git a/src/sage/groups/all.py b/src/sage/groups/all.py
index 5fa9ccfac39..66f3a106e54 100644
--- a/src/sage/groups/all.py
+++ b/src/sage/groups/all.py
@@ -1,18 +1,18 @@
 from sage.misc.lazy_import import lazy_import
 
-from .pari_group import PariGroup
+from sage.groups.pari_group import PariGroup
 
-from .matrix_gps.all import *
-from .abelian_gps.all import *
+from sage.groups.matrix_gps.all import *
+from sage.groups.abelian_gps.all import *
 
-from .perm_gps.all import *
+from sage.groups.perm_gps.all import *
 
-from .generic import (discrete_log, discrete_log_rho, discrete_log_lambda,
+from sage.groups.generic import (discrete_log, discrete_log_rho, discrete_log_lambda,
                       linear_relation, multiple, multiples, order_from_multiple)
 
 lazy_import('sage.groups.class_function', 'ClassFunction')
 
-from .additive_abelian.all import *
+from sage.groups.additive_abelian.all import *
 
 lazy_import('sage.groups.conjugacy_classes', ['ConjugacyClass', 'ConjugacyClassGAP'])
 
diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
index 1df22e6c3a6..4d5562fc661 100644
--- a/src/sage/groups/matrix_gps/finitely_generated.py
+++ b/src/sage/groups/matrix_gps/finitely_generated.py
@@ -72,7 +72,7 @@
 from sage.groups.matrix_gps.group_element import is_MatrixGroupElement
 from sage.groups.matrix_gps.matrix_group import MatrixGroup_generic
 from sage.matrix.constructor import matrix
-from sage.matrix.matrix_space import is_MatrixSpace
+from sage.matrix.matrix_space import MatrixSpace
 from sage.misc.cachefunc import cached_method
 from sage.rings.integer_ring import ZZ
 from sage.structure.element import is_Matrix
@@ -130,7 +130,7 @@ def normalize_square_matrices(matrices):
         raise ValueError('not all matrices have the same size')
     gens = Sequence(gens, immutable=True)
     MS = gens.universe()
-    if not is_MatrixSpace(MS):
+    if not isinstance(MS, MatrixSpace):
         raise TypeError('all generators must be matrices')
     if MS.nrows() != MS.ncols():
         raise ValueError('matrices must be square')
diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
index 4763b13721a..c39c0e3bd80 100644
--- a/src/sage/groups/matrix_gps/isometries.py
+++ b/src/sage/groups/matrix_gps/isometries.py
@@ -227,9 +227,9 @@ def _get_action_(self, S, op, self_on_left):
                 return GroupActionOnSubmodule(self, S)
             if S is self._invariant_quotient_module:
                 return GroupActionOnQuotientModule(self, S)
-            from sage.modules.fg_pid.fgp_module import is_FGP_Module
+            from sage.modules.fg_pid.fgp_module import FGP_Module_class
             T = self._invariant_quotient_module
-            if is_FGP_Module(S):
+            if isinstance(S, FGP_Module_class):
                 if S.is_submodule(T):
                     V = S.V()
                     if all(V == V * f.matrix() for f in self.gens()):
diff --git a/src/sage/groups/matrix_gps/linear.py b/src/sage/groups/matrix_gps/linear.py
index e8c7ddd08a3..bd77d7ce19a 100644
--- a/src/sage/groups/matrix_gps/linear.py
+++ b/src/sage/groups/matrix_gps/linear.py
@@ -68,6 +68,8 @@
 from sage.misc.latex import latex
 from sage.misc.misc_c import prod
 from sage.rings.infinity import Infinity
+from sage.rings.integer_ring import ZZ
+from sage.rings.finite_rings.integer_mod_ring import Integers
 
 
 ###############################################################################
@@ -311,7 +313,7 @@ def _check_matrix(self, x, *args):
                 raise TypeError('matrix must non-zero determinant')
 
     def order(self):
-        """
+        r"""
         Return the order of ``self``.
 
         EXAMPLES::
@@ -320,6 +322,31 @@ def order(self):
             sage: G.order()
             372000
 
+        The order computation also works over the base rings `\ZZ/n\ZZ`::
+
+            sage: GL(4, Integers(15)).order()
+            2815842631680000000
+
+            sage: SL(4, Integers(15)).order()
+            351980328960000000
+
+            sage: G = GL(2, Integers(6))
+            sage: G.order() == len(list(G))
+            True
+
+            sage: H = SL(2, Integers(6))
+            sage: H.order() == len(list(H))
+            True
+
+        Arbitrary base rings are currently not fully supported::
+
+            sage: R. = PolynomialRing(GF(7))
+            sage: S = R.quotient(x^2 + 5)
+            sage: GL(2, S).order()
+            Traceback (most recent call last):
+            ...
+            NotImplementedError: order computation of linear groups not fully supported for arbitrary base rings
+
         TESTS:
 
         Check if :issue:`36876` is fixed::
@@ -340,18 +367,71 @@ def order(self):
             True
             sage: S.order()
             117600
-        """
-        n = self.degree()
 
-        if self.base_ring().is_finite():
-            q = self.base_ring().order()
+        Check if :issue:`37934` is fixed::
+
+            sage: GL(2, Integers(4)).order()
+            96
+
+            sage: GL(2, Integers(1)).order()
+            1
+
+            sage: GL(1, ZZ).order()
+            2
+        """
+        def order_over_finite_field(q, n):
             ord = prod(q**n - q**i for i in range(n))
             if self._special:
-                return ord / (q-1)
+                return ord // (q-1)
             return ord
 
-        if self._special and n == 1:
-            return 1
-        return Infinity
+        n = self.degree()
+        R = self.base_ring()
+
+        if R.is_finite():
+            q = R.order()
+
+            if q == 1:
+                return ZZ.one()
+
+            if R.is_field():
+                return order_over_finite_field(q, n)
+
+            if R == Integers(q):
+                ord = ZZ.one()
+
+                # By the Chinese remainder theorem we need to build the product
+                # over the orders of GL(n, ZZ/p^e ZZ) (or SL) for all prime
+                # powers in the factorization of q
+                for (p,e) in q.factor():
+                    ord_base = order_over_finite_field(p, n)
+
+                    if not self._special:
+                        ord *= p**((e-1)*n**2) * ord_base
+
+                    # We apply |SL(n, R)| = |GL(n, R)| / euler_phi(q), but since we
+                    # already iterate over the prime factorization of q, we divide
+                    # out euler_phi(q) iteratively. Noting that (p-1) is already
+                    # handled in the call to order_over_finite_field, we only
+                    # need to remove p^(e-1) compared to the above formula
+                    else:
+                        ord *= p**((e-1)*(n**2-1)) * ord_base
+
+                return ord
+
+            raise NotImplementedError("order computation of linear groups not "
+                                      "fully supported for arbitrary base rings")
+
+        if n > 1 or (R.is_field() and not self._special):
+            return Infinity
+
+        if self._special:
+            return ZZ.one()
+
+        if R == ZZ:
+            return ZZ(2)
+
+        raise NotImplementedError("order computation of linear groups not "
+                                  "fully supported for arbitrary base rings")
 
     cardinality = order
diff --git a/src/sage/groups/perm_gps/all.py b/src/sage/groups/perm_gps/all.py
index ae405f298a2..2cda7602d8c 100644
--- a/src/sage/groups/perm_gps/all.py
+++ b/src/sage/groups/perm_gps/all.py
@@ -1,20 +1,20 @@
-from .permgroup_named import (SymmetricGroup, AlternatingGroup,
-                              DihedralGroup, SplitMetacyclicGroup,
-                              SemidihedralGroup, CyclicPermutationGroup,
-                              DiCyclicGroup, TransitiveGroup,
-                              PGL, PSL, PSp, PSU, PGU,
-                              MathieuGroup, KleinFourGroup, QuaternionGroup,
-                              PrimitiveGroup, PrimitiveGroups,
-                              SuzukiGroup, TransitiveGroups,
-                              GeneralDihedralGroup, SmallPermutationGroup)
+from sage.groups.perm_gps.permgroup_named import (SymmetricGroup, AlternatingGroup,
+                                                  DihedralGroup, SplitMetacyclicGroup,
+                                                  SemidihedralGroup, CyclicPermutationGroup,
+                                                  DiCyclicGroup, TransitiveGroup,
+                                                  PGL, PSL, PSp, PSU, PGU,
+                                                  MathieuGroup, KleinFourGroup, QuaternionGroup,
+                                                  PrimitiveGroup, PrimitiveGroups,
+                                                  SuzukiGroup, TransitiveGroups,
+                                                  GeneralDihedralGroup, SmallPermutationGroup)
 
-from .permgroup import PermutationGroup, PermutationGroup_generic, PermutationGroup_subgroup, direct_product_permgroups
+from sage.groups.perm_gps.permgroup import PermutationGroup, PermutationGroup_generic, PermutationGroup_subgroup, direct_product_permgroups
 
-from .constructor import PermutationGroupElement
+from sage.groups.perm_gps.constructor import PermutationGroupElement
 
-from .permgroup_morphism import (PermutationGroupMorphism as PermutationGroupMap,
-                                 PermutationGroupMorphism_im_gens,
-                                 PermutationGroupMorphism_id)
+from sage.groups.perm_gps.permgroup_morphism import (PermutationGroupMorphism as PermutationGroupMap,
+                                                     PermutationGroupMorphism_im_gens,
+                                                     PermutationGroupMorphism_id)
 PermutationGroupMorphism = PermutationGroupMorphism_im_gens
 
-from .cubegroup import CubeGroup, RubiksCube
+from sage.groups.perm_gps.cubegroup import CubeGroup, RubiksCube
diff --git a/src/sage/homology/all.py b/src/sage/homology/all.py
index d9306c19daa..21a95c6c4af 100644
--- a/src/sage/homology/all.py
+++ b/src/sage/homology/all.py
@@ -1,6 +1,6 @@
-from .chain_complex import ChainComplex
+from sage.homology.chain_complex import ChainComplex
 
-from .chain_complex_morphism import ChainComplexMorphism
+from sage.homology.chain_complex_morphism import ChainComplexMorphism
 
 from sage.misc.lazy_import import lazy_import
 lazy_import('sage.homology.koszul_complex', 'KoszulComplex')
diff --git a/src/sage/homology/chain_complex.py b/src/sage/homology/chain_complex.py
index 7f7cfb5e27b..680a5a911d7 100644
--- a/src/sage/homology/chain_complex.py
+++ b/src/sage/homology/chain_complex.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Chain complexes
 
diff --git a/src/sage/homology/chain_homotopy.py b/src/sage/homology/chain_homotopy.py
index 91ae14eda11..3b5dece7d91 100644
--- a/src/sage/homology/chain_homotopy.py
+++ b/src/sage/homology/chain_homotopy.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Chain homotopies and chain contractions
 
diff --git a/src/sage/interacts/all.py b/src/sage/interacts/all.py
index c53a1e11ecf..87d00072798 100644
--- a/src/sage/interacts/all.py
+++ b/src/sage/interacts/all.py
@@ -17,9 +17,10 @@
 # ****************************************************************************
 from sage.misc.lazy_import import lazy_import
 
-from . import calculus
-from . import geometry
-from . import statistics
-from . import fractals
-from . import algebra
+from sage.interacts import calculus
+from sage.interacts import geometry
+from sage.interacts import statistics
+from sage.interacts import fractals
+from sage.interacts import algebra
 lazy_import('sage.interacts.library', 'demo')
+del lazy_import
diff --git a/src/sage/interfaces/all.py b/src/sage/interfaces/all.py
index ed71b662362..83100b2c3de 100644
--- a/src/sage/interfaces/all.py
+++ b/src/sage/interfaces/all.py
@@ -1,15 +1,15 @@
 # interfaces to other interpreters
 
-from .sage0 import sage0, sage0_version, Sage
-from .gap import gap, gap_reset_workspace, Gap
-from .gp import gp, gp_version, Gp
+from sage.interfaces.sage0 import sage0, sage0_version, Sage
+from sage.interfaces.gap import gap, gap_reset_workspace, Gap
+from sage.interfaces.gp import gp, gp_version, Gp
 # import problems
 # from maxima_lib import maxima_lib
-from .maxima import maxima, Maxima
-from .singular import singular, singular_version, Singular
+from sage.interfaces.maxima import maxima, Maxima
+from sage.interfaces.singular import singular, singular_version, Singular
 
-from .magma import magma, Magma
-from .polymake import polymake
+from sage.interfaces.magma import magma, Magma
+from sage.interfaces.polymake import polymake
 
 from sage.misc.lazy_import import lazy_import
 
@@ -48,3 +48,4 @@
               'kash', 'magma', 'macaulay2', 'maple', 'maxima',
               'mathematica', 'mwrank', 'octave', 'r', 'singular',
               'sage0', 'sage']
+del lazy_import
diff --git a/src/sage/interfaces/frobby.py b/src/sage/interfaces/frobby.py
index 75e6da5b4d9..498a5a6da58 100644
--- a/src/sage/interfaces/frobby.py
+++ b/src/sage/interfaces/frobby.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Interface to Frobby for fast computations on monomial ideals.
 
diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
index 2e49e4c106f..d08fbb872ba 100644
--- a/src/sage/interfaces/gap.py
+++ b/src/sage/interfaces/gap.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Interface to GAP
 
diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
index 28d9d58473d..f2e3b7ab2e1 100644
--- a/src/sage/interfaces/genus2reduction.py
+++ b/src/sage/interfaces/genus2reduction.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Conductor and reduction types for genus 2 curves
 
diff --git a/src/sage/interfaces/maxima_abstract.py b/src/sage/interfaces/maxima_abstract.py
index 767b5173823..2aaf9815b03 100644
--- a/src/sage/interfaces/maxima_abstract.py
+++ b/src/sage/interfaces/maxima_abstract.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Abstract interface to Maxima
 
diff --git a/src/sage/interfaces/r.py b/src/sage/interfaces/r.py
index 232d767c944..2d0b393ab0c 100644
--- a/src/sage/interfaces/r.py
+++ b/src/sage/interfaces/r.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Interfaces to R
 
diff --git a/src/sage/knots/gauss_code.py b/src/sage/knots/gauss_code.py
index 0a631bdd0d5..9d5a816d577 100644
--- a/src/sage/knots/gauss_code.py
+++ b/src/sage/knots/gauss_code.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Helper functions related to Gauss codes of knots
 
diff --git a/src/sage/knots/knot.py b/src/sage/knots/knot.py
index 10f0e241608..9d6a73cbfbf 100644
--- a/src/sage/knots/knot.py
+++ b/src/sage/knots/knot.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Knots
 
diff --git a/src/sage/knots/knotinfo.py b/src/sage/knots/knotinfo.py
index d30fd678735..6932b835476 100644
--- a/src/sage/knots/knotinfo.py
+++ b/src/sage/knots/knotinfo.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Access to the KnotInfo database
 
diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
index 732eb115584..770d59c02b5 100644
--- a/src/sage/lfunctions/pari.py
+++ b/src/sage/lfunctions/pari.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 `L`-functions from PARI
 
diff --git a/src/sage/libs/eclib/all.py b/src/sage/libs/eclib/all.py
index 717a66fae7b..500cdfd1192 100644
--- a/src/sage/libs/eclib/all.py
+++ b/src/sage/libs/eclib/all.py
@@ -1,4 +1,4 @@
-from .constructor import CremonaModularSymbols
-from .interface import mwrank_EllipticCurve, mwrank_MordellWeil
-from .mwrank import get_precision, set_precision
-from .mwrank import initprimes as mwrank_initprimes
+from sage.libs.eclib.constructor import CremonaModularSymbols
+from sage.libs.eclib.interface import mwrank_EllipticCurve, mwrank_MordellWeil
+from sage.libs.eclib.mwrank import get_precision, set_precision
+from sage.libs.eclib.mwrank import initprimes as mwrank_initprimes
diff --git a/src/sage/libs/eclib/mwrank.pyx b/src/sage/libs/eclib/mwrank.pyx
index c685c329926..26a57f86a49 100644
--- a/src/sage/libs/eclib/mwrank.pyx
+++ b/src/sage/libs/eclib/mwrank.pyx
@@ -530,6 +530,7 @@ def parse_point_list(s):
     pts = s[2:-2].split('],[')
     return [[Integer(x) for x in pt.split(",")] for pt in pts]
 
+
 cdef class _mw:
     """
     Cython class wrapping eclib's mw class.
diff --git a/src/sage/libs/flint/acb.pxd b/src/sage/libs/flint/acb.pxd
index 9017379224b..b064c51a422 100644
--- a/src/sage/libs/flint/acb.pxd
+++ b/src/sage/libs/flint/acb.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/acb_calc.pxd b/src/sage/libs/flint/acb_calc.pxd
index 45e6a27db09..324f9d93faf 100644
--- a/src/sage/libs/flint/acb_calc.pxd
+++ b/src/sage/libs/flint/acb_calc.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/acb_dft.pxd b/src/sage/libs/flint/acb_dft.pxd
index 08542aabeca..2d5fad12a12 100644
--- a/src/sage/libs/flint/acb_dft.pxd
+++ b/src/sage/libs/flint/acb_dft.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/acb_dirichlet.pxd b/src/sage/libs/flint/acb_dirichlet.pxd
index a76a8711c84..347ea46204e 100644
--- a/src/sage/libs/flint/acb_dirichlet.pxd
+++ b/src/sage/libs/flint/acb_dirichlet.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/acb_elliptic.pxd b/src/sage/libs/flint/acb_elliptic.pxd
index cfeb04feaf3..67808767b3f 100644
--- a/src/sage/libs/flint/acb_elliptic.pxd
+++ b/src/sage/libs/flint/acb_elliptic.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/acb_hypgeom.pxd b/src/sage/libs/flint/acb_hypgeom.pxd
index 4b8d8664e87..b306e364cc7 100644
--- a/src/sage/libs/flint/acb_hypgeom.pxd
+++ b/src/sage/libs/flint/acb_hypgeom.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/acb_mat.pxd b/src/sage/libs/flint/acb_mat.pxd
index 031913ab07a..88199387d1e 100644
--- a/src/sage/libs/flint/acb_mat.pxd
+++ b/src/sage/libs/flint/acb_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/acb_modular.pxd b/src/sage/libs/flint/acb_modular.pxd
index 8a6b824883d..3a352653992 100644
--- a/src/sage/libs/flint/acb_modular.pxd
+++ b/src/sage/libs/flint/acb_modular.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/acb_poly.pxd b/src/sage/libs/flint/acb_poly.pxd
index 2e4e900cac0..bdfdfb5c2d3 100644
--- a/src/sage/libs/flint/acb_poly.pxd
+++ b/src/sage/libs/flint/acb_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/acf.pxd b/src/sage/libs/flint/acf.pxd
index 0e65a589a7e..e6ac0c77d94 100644
--- a/src/sage/libs/flint/acf.pxd
+++ b/src/sage/libs/flint/acf.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/aprcl.pxd b/src/sage/libs/flint/aprcl.pxd
index 4eaa71b85bc..047f59b177b 100644
--- a/src/sage/libs/flint/aprcl.pxd
+++ b/src/sage/libs/flint/aprcl.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/arb.pxd b/src/sage/libs/flint/arb.pxd
index 9da42e43fb8..78668caf76d 100644
--- a/src/sage/libs/flint/arb.pxd
+++ b/src/sage/libs/flint/arb.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/arb_calc.pxd b/src/sage/libs/flint/arb_calc.pxd
index 47ff5273d9c..84d87d91d66 100644
--- a/src/sage/libs/flint/arb_calc.pxd
+++ b/src/sage/libs/flint/arb_calc.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/arb_fmpz_poly.pxd b/src/sage/libs/flint/arb_fmpz_poly.pxd
index cee8a0ef8dc..977195aeb0c 100644
--- a/src/sage/libs/flint/arb_fmpz_poly.pxd
+++ b/src/sage/libs/flint/arb_fmpz_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/arb_fpwrap.pxd b/src/sage/libs/flint/arb_fpwrap.pxd
index 7a5aada626f..1aef64e7d55 100644
--- a/src/sage/libs/flint/arb_fpwrap.pxd
+++ b/src/sage/libs/flint/arb_fpwrap.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/arb_hypgeom.pxd b/src/sage/libs/flint/arb_hypgeom.pxd
index 1d82b859eac..bf44a1c0d3f 100644
--- a/src/sage/libs/flint/arb_hypgeom.pxd
+++ b/src/sage/libs/flint/arb_hypgeom.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/arb_mat.pxd b/src/sage/libs/flint/arb_mat.pxd
index 133a4bac57f..d8efa0e8903 100644
--- a/src/sage/libs/flint/arb_mat.pxd
+++ b/src/sage/libs/flint/arb_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/arb_poly.pxd b/src/sage/libs/flint/arb_poly.pxd
index 754dec0bf72..9a53f927cad 100644
--- a/src/sage/libs/flint/arb_poly.pxd
+++ b/src/sage/libs/flint/arb_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/arf.pxd b/src/sage/libs/flint/arf.pxd
index 8e2218d7d8a..f4b54a2c15d 100644
--- a/src/sage/libs/flint/arf.pxd
+++ b/src/sage/libs/flint/arf.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/arith.pxd b/src/sage/libs/flint/arith.pxd
index 70e7f5e5d29..fe58c2183f4 100644
--- a/src/sage/libs/flint/arith.pxd
+++ b/src/sage/libs/flint/arith.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/bernoulli.pxd b/src/sage/libs/flint/bernoulli.pxd
index edbff6fb26e..e985285df84 100644
--- a/src/sage/libs/flint/bernoulli.pxd
+++ b/src/sage/libs/flint/bernoulli.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/bool_mat.pxd b/src/sage/libs/flint/bool_mat.pxd
index 0ef3b44feb8..d5a749f96b6 100644
--- a/src/sage/libs/flint/bool_mat.pxd
+++ b/src/sage/libs/flint/bool_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/ca.pxd b/src/sage/libs/flint/ca.pxd
index 121a90b2f94..423e4918895 100644
--- a/src/sage/libs/flint/ca.pxd
+++ b/src/sage/libs/flint/ca.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/ca_ext.pxd b/src/sage/libs/flint/ca_ext.pxd
index 62aa7309934..20cd13cc5f8 100644
--- a/src/sage/libs/flint/ca_ext.pxd
+++ b/src/sage/libs/flint/ca_ext.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/ca_field.pxd b/src/sage/libs/flint/ca_field.pxd
index 3116540c419..058361ce57a 100644
--- a/src/sage/libs/flint/ca_field.pxd
+++ b/src/sage/libs/flint/ca_field.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/ca_mat.pxd b/src/sage/libs/flint/ca_mat.pxd
index 600f5d50887..f24c6714d19 100644
--- a/src/sage/libs/flint/ca_mat.pxd
+++ b/src/sage/libs/flint/ca_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/ca_poly.pxd b/src/sage/libs/flint/ca_poly.pxd
index a18a3cdfcd4..cdc846e0d89 100644
--- a/src/sage/libs/flint/ca_poly.pxd
+++ b/src/sage/libs/flint/ca_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/ca_vec.pxd b/src/sage/libs/flint/ca_vec.pxd
index 3ed69ea9968..69f8e24b255 100644
--- a/src/sage/libs/flint/ca_vec.pxd
+++ b/src/sage/libs/flint/ca_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/calcium.pxd b/src/sage/libs/flint/calcium.pxd
index 60507d53ac6..1903ee8631e 100644
--- a/src/sage/libs/flint/calcium.pxd
+++ b/src/sage/libs/flint/calcium.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/d_mat.pxd b/src/sage/libs/flint/d_mat.pxd
index 0f398f5ada0..5a5780fd66b 100644
--- a/src/sage/libs/flint/d_mat.pxd
+++ b/src/sage/libs/flint/d_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/d_vec.pxd b/src/sage/libs/flint/d_vec.pxd
index 3ce55fde92a..69fd96b0b8e 100644
--- a/src/sage/libs/flint/d_vec.pxd
+++ b/src/sage/libs/flint/d_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/dirichlet.pxd b/src/sage/libs/flint/dirichlet.pxd
index 79d9908fd9e..127b857244a 100644
--- a/src/sage/libs/flint/dirichlet.pxd
+++ b/src/sage/libs/flint/dirichlet.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/dlog.pxd b/src/sage/libs/flint/dlog.pxd
index 68bbaa2690a..c6949694c9f 100644
--- a/src/sage/libs/flint/dlog.pxd
+++ b/src/sage/libs/flint/dlog.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/double_extras.pxd b/src/sage/libs/flint/double_extras.pxd
index 1019aca407d..40ab71e7003 100644
--- a/src/sage/libs/flint/double_extras.pxd
+++ b/src/sage/libs/flint/double_extras.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/double_interval.pxd b/src/sage/libs/flint/double_interval.pxd
index 72de28838b8..3127d9f75a8 100644
--- a/src/sage/libs/flint/double_interval.pxd
+++ b/src/sage/libs/flint/double_interval.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fexpr.pxd b/src/sage/libs/flint/fexpr.pxd
index 7a264b74639..34ff7149082 100644
--- a/src/sage/libs/flint/fexpr.pxd
+++ b/src/sage/libs/flint/fexpr.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fexpr_builtin.pxd b/src/sage/libs/flint/fexpr_builtin.pxd
index d434d9c40d6..fbfafea07d3 100644
--- a/src/sage/libs/flint/fexpr_builtin.pxd
+++ b/src/sage/libs/flint/fexpr_builtin.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fft.pxd b/src/sage/libs/flint/fft.pxd
index e5362f1b90b..67149434970 100644
--- a/src/sage/libs/flint/fft.pxd
+++ b/src/sage/libs/flint/fft.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/flint.pxd b/src/sage/libs/flint/flint.pxd
index 33af77f9c16..434e4d624ad 100644
--- a/src/sage/libs/flint/flint.pxd
+++ b/src/sage/libs/flint/flint.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
index 61ebabac2b0..be665bc0953 100644
--- a/src/sage/libs/flint/fmpq.pxd
+++ b/src/sage/libs/flint/fmpq.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpq_mat.pxd b/src/sage/libs/flint/fmpq_mat.pxd
index 0227b8523a6..949ff967246 100644
--- a/src/sage/libs/flint/fmpq_mat.pxd
+++ b/src/sage/libs/flint/fmpq_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpq_mpoly.pxd b/src/sage/libs/flint/fmpq_mpoly.pxd
index 34caf4ba56f..d465946a785 100644
--- a/src/sage/libs/flint/fmpq_mpoly.pxd
+++ b/src/sage/libs/flint/fmpq_mpoly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpq_mpoly_factor.pxd b/src/sage/libs/flint/fmpq_mpoly_factor.pxd
index c291de6946c..e1e001b6d87 100644
--- a/src/sage/libs/flint/fmpq_mpoly_factor.pxd
+++ b/src/sage/libs/flint/fmpq_mpoly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
index f8622ebfd41..9982cbca879 100644
--- a/src/sage/libs/flint/fmpq_poly.pxd
+++ b/src/sage/libs/flint/fmpq_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpq_vec.pxd b/src/sage/libs/flint/fmpq_vec.pxd
index 6606e041d58..f92297d1464 100644
--- a/src/sage/libs/flint/fmpq_vec.pxd
+++ b/src/sage/libs/flint/fmpq_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
index 237ac135cd9..3553025d602 100644
--- a/src/sage/libs/flint/fmpz.pxd
+++ b/src/sage/libs/flint/fmpz.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_extras.pxd b/src/sage/libs/flint/fmpz_extras.pxd
index 940d1fdb766..afaf1dbdccb 100644
--- a/src/sage/libs/flint/fmpz_extras.pxd
+++ b/src/sage/libs/flint/fmpz_extras.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_factor.pxd b/src/sage/libs/flint/fmpz_factor.pxd
index 1e93305c7f5..1b0851d0b14 100644
--- a/src/sage/libs/flint/fmpz_factor.pxd
+++ b/src/sage/libs/flint/fmpz_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_lll.pxd b/src/sage/libs/flint/fmpz_lll.pxd
index f673f775794..dee95ac1d03 100644
--- a/src/sage/libs/flint/fmpz_lll.pxd
+++ b/src/sage/libs/flint/fmpz_lll.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mat.pxd b/src/sage/libs/flint/fmpz_mat.pxd
index abde570c32f..76b14823e08 100644
--- a/src/sage/libs/flint/fmpz_mat.pxd
+++ b/src/sage/libs/flint/fmpz_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mod.pxd b/src/sage/libs/flint/fmpz_mod.pxd
index 4089589dd53..ee031a6e6ac 100644
--- a/src/sage/libs/flint/fmpz_mod.pxd
+++ b/src/sage/libs/flint/fmpz_mod.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mod_mat.pxd b/src/sage/libs/flint/fmpz_mod_mat.pxd
index ce473497e3a..b4306390668 100644
--- a/src/sage/libs/flint/fmpz_mod_mat.pxd
+++ b/src/sage/libs/flint/fmpz_mod_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mod_mpoly.pxd b/src/sage/libs/flint/fmpz_mod_mpoly.pxd
index d0a32382809..2d1b35443f6 100644
--- a/src/sage/libs/flint/fmpz_mod_mpoly.pxd
+++ b/src/sage/libs/flint/fmpz_mod_mpoly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd b/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd
index c1c9657975e..1100b2eac91 100644
--- a/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd
+++ b/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
index 302113e191b..f9b2d05e11e 100644
--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
+++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd
index 312ceb175c9..106800d842d 100644
--- a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd
+++ b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mod_vec.pxd b/src/sage/libs/flint/fmpz_mod_vec.pxd
index 5b1bc0c4715..f7541ad4819 100644
--- a/src/sage/libs/flint/fmpz_mod_vec.pxd
+++ b/src/sage/libs/flint/fmpz_mod_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mpoly.pxd b/src/sage/libs/flint/fmpz_mpoly.pxd
index 0cc6dd108bd..ec6aaa02ebe 100644
--- a/src/sage/libs/flint/fmpz_mpoly.pxd
+++ b/src/sage/libs/flint/fmpz_mpoly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mpoly_factor.pxd b/src/sage/libs/flint/fmpz_mpoly_factor.pxd
index a48f7052f42..ec529c54a2d 100644
--- a/src/sage/libs/flint/fmpz_mpoly_factor.pxd
+++ b/src/sage/libs/flint/fmpz_mpoly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_mpoly_q.pxd b/src/sage/libs/flint/fmpz_mpoly_q.pxd
index 349902f74fb..d331ee4e333 100644
--- a/src/sage/libs/flint/fmpz_mpoly_q.pxd
+++ b/src/sage/libs/flint/fmpz_mpoly_q.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
index 59508fe6c19..da9a1ce72be 100644
--- a/src/sage/libs/flint/fmpz_poly.pxd
+++ b/src/sage/libs/flint/fmpz_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_poly_factor.pxd b/src/sage/libs/flint/fmpz_poly_factor.pxd
index bca34daa554..96e0617c644 100644
--- a/src/sage/libs/flint/fmpz_poly_factor.pxd
+++ b/src/sage/libs/flint/fmpz_poly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_poly_mat.pxd b/src/sage/libs/flint/fmpz_poly_mat.pxd
index 83ed1d8bced..440290464cc 100644
--- a/src/sage/libs/flint/fmpz_poly_mat.pxd
+++ b/src/sage/libs/flint/fmpz_poly_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
index 26de673bb6c..7422a568882 100644
--- a/src/sage/libs/flint/fmpz_poly_q.pxd
+++ b/src/sage/libs/flint/fmpz_poly_q.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpz_vec.pxd b/src/sage/libs/flint/fmpz_vec.pxd
index 0418fbc6242..11ab3e56ad4 100644
--- a/src/sage/libs/flint/fmpz_vec.pxd
+++ b/src/sage/libs/flint/fmpz_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fmpzi.pxd b/src/sage/libs/flint/fmpzi.pxd
index 885615314a5..a70fb7ca1c6 100644
--- a/src/sage/libs/flint/fmpzi.pxd
+++ b/src/sage/libs/flint/fmpzi.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq.pxd b/src/sage/libs/flint/fq.pxd
index 01c8f5887a2..aa087889862 100644
--- a/src/sage/libs/flint/fq.pxd
+++ b/src/sage/libs/flint/fq.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_default.pxd b/src/sage/libs/flint/fq_default.pxd
index 3d622002a0e..4e7f8c6c32b 100644
--- a/src/sage/libs/flint/fq_default.pxd
+++ b/src/sage/libs/flint/fq_default.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_default_mat.pxd b/src/sage/libs/flint/fq_default_mat.pxd
index 20601d54cac..e395beaa804 100644
--- a/src/sage/libs/flint/fq_default_mat.pxd
+++ b/src/sage/libs/flint/fq_default_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_default_poly.pxd b/src/sage/libs/flint/fq_default_poly.pxd
index e1c93ca322f..fa682818058 100644
--- a/src/sage/libs/flint/fq_default_poly.pxd
+++ b/src/sage/libs/flint/fq_default_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_default_poly_factor.pxd b/src/sage/libs/flint/fq_default_poly_factor.pxd
index aff2870099e..ae8ed26a97e 100644
--- a/src/sage/libs/flint/fq_default_poly_factor.pxd
+++ b/src/sage/libs/flint/fq_default_poly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_embed.pxd b/src/sage/libs/flint/fq_embed.pxd
index 4f14b164d02..2b42a91057a 100644
--- a/src/sage/libs/flint/fq_embed.pxd
+++ b/src/sage/libs/flint/fq_embed.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_mat.pxd b/src/sage/libs/flint/fq_mat.pxd
index 72fa6c63e15..27c8bf48d38 100644
--- a/src/sage/libs/flint/fq_mat.pxd
+++ b/src/sage/libs/flint/fq_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_nmod.pxd b/src/sage/libs/flint/fq_nmod.pxd
index 83085408d29..2a796c1939d 100644
--- a/src/sage/libs/flint/fq_nmod.pxd
+++ b/src/sage/libs/flint/fq_nmod.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_nmod_embed.pxd b/src/sage/libs/flint/fq_nmod_embed.pxd
index 6a7dbe52068..6b6d98307e6 100644
--- a/src/sage/libs/flint/fq_nmod_embed.pxd
+++ b/src/sage/libs/flint/fq_nmod_embed.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_nmod_mat.pxd b/src/sage/libs/flint/fq_nmod_mat.pxd
index 7c9f8a92548..0026aae5e0d 100644
--- a/src/sage/libs/flint/fq_nmod_mat.pxd
+++ b/src/sage/libs/flint/fq_nmod_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_nmod_mpoly.pxd b/src/sage/libs/flint/fq_nmod_mpoly.pxd
index eeddd4e9053..3e5bb56569b 100644
--- a/src/sage/libs/flint/fq_nmod_mpoly.pxd
+++ b/src/sage/libs/flint/fq_nmod_mpoly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd b/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd
index a5419d1c4be..f8d3f3aff4b 100644
--- a/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd
+++ b/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_nmod_poly.pxd b/src/sage/libs/flint/fq_nmod_poly.pxd
index 13440cd550f..74e05c89f6d 100644
--- a/src/sage/libs/flint/fq_nmod_poly.pxd
+++ b/src/sage/libs/flint/fq_nmod_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_nmod_poly_factor.pxd b/src/sage/libs/flint/fq_nmod_poly_factor.pxd
index da8dd3686a0..697a45abf66 100644
--- a/src/sage/libs/flint/fq_nmod_poly_factor.pxd
+++ b/src/sage/libs/flint/fq_nmod_poly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_nmod_vec.pxd b/src/sage/libs/flint/fq_nmod_vec.pxd
index 6c68e8e169f..47b1a2b4158 100644
--- a/src/sage/libs/flint/fq_nmod_vec.pxd
+++ b/src/sage/libs/flint/fq_nmod_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_poly.pxd b/src/sage/libs/flint/fq_poly.pxd
index 2010796af67..29fcd71c12a 100644
--- a/src/sage/libs/flint/fq_poly.pxd
+++ b/src/sage/libs/flint/fq_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_poly_factor.pxd b/src/sage/libs/flint/fq_poly_factor.pxd
index d7e1a8b0e60..44d61edcdd7 100644
--- a/src/sage/libs/flint/fq_poly_factor.pxd
+++ b/src/sage/libs/flint/fq_poly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_vec.pxd b/src/sage/libs/flint/fq_vec.pxd
index ec5d5bdf6a2..b9079a68274 100644
--- a/src/sage/libs/flint/fq_vec.pxd
+++ b/src/sage/libs/flint/fq_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_zech.pxd b/src/sage/libs/flint/fq_zech.pxd
index 1fa779ae88b..ff71cd830f2 100644
--- a/src/sage/libs/flint/fq_zech.pxd
+++ b/src/sage/libs/flint/fq_zech.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_zech_embed.pxd b/src/sage/libs/flint/fq_zech_embed.pxd
index 59f66f7f5ae..a88b1757b12 100644
--- a/src/sage/libs/flint/fq_zech_embed.pxd
+++ b/src/sage/libs/flint/fq_zech_embed.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_zech_mat.pxd b/src/sage/libs/flint/fq_zech_mat.pxd
index c4ee5d2fb59..102c1c2ebc3 100644
--- a/src/sage/libs/flint/fq_zech_mat.pxd
+++ b/src/sage/libs/flint/fq_zech_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_zech_poly.pxd b/src/sage/libs/flint/fq_zech_poly.pxd
index 21cefa1c67f..1271077c660 100644
--- a/src/sage/libs/flint/fq_zech_poly.pxd
+++ b/src/sage/libs/flint/fq_zech_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_zech_poly_factor.pxd b/src/sage/libs/flint/fq_zech_poly_factor.pxd
index 111ec01ac9f..84da1f39d11 100644
--- a/src/sage/libs/flint/fq_zech_poly_factor.pxd
+++ b/src/sage/libs/flint/fq_zech_poly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/fq_zech_vec.pxd b/src/sage/libs/flint/fq_zech_vec.pxd
index 02c71129d70..ce7250f0bd5 100644
--- a/src/sage/libs/flint/fq_zech_vec.pxd
+++ b/src/sage/libs/flint/fq_zech_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/gr.pxd b/src/sage/libs/flint/gr.pxd
index 2d15538d94d..6bf60b93957 100644
--- a/src/sage/libs/flint/gr.pxd
+++ b/src/sage/libs/flint/gr.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/gr_generic.pxd b/src/sage/libs/flint/gr_generic.pxd
index 9bdf9a80232..6d7e36068ca 100644
--- a/src/sage/libs/flint/gr_generic.pxd
+++ b/src/sage/libs/flint/gr_generic.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/gr_mat.pxd b/src/sage/libs/flint/gr_mat.pxd
index 501be55b79e..e8da56ffb99 100644
--- a/src/sage/libs/flint/gr_mat.pxd
+++ b/src/sage/libs/flint/gr_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/gr_mpoly.pxd b/src/sage/libs/flint/gr_mpoly.pxd
index c587f378017..ba6f3b6b1ee 100644
--- a/src/sage/libs/flint/gr_mpoly.pxd
+++ b/src/sage/libs/flint/gr_mpoly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/gr_poly.pxd b/src/sage/libs/flint/gr_poly.pxd
index c6e11462a1c..e185c46ff98 100644
--- a/src/sage/libs/flint/gr_poly.pxd
+++ b/src/sage/libs/flint/gr_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/gr_special.pxd b/src/sage/libs/flint/gr_special.pxd
index adf199366fe..060572b600a 100644
--- a/src/sage/libs/flint/gr_special.pxd
+++ b/src/sage/libs/flint/gr_special.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/gr_vec.pxd b/src/sage/libs/flint/gr_vec.pxd
index bc7c81f7960..8244a2edf60 100644
--- a/src/sage/libs/flint/gr_vec.pxd
+++ b/src/sage/libs/flint/gr_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/hypgeom.pxd b/src/sage/libs/flint/hypgeom.pxd
index 9eaa171d3b4..7d3e4682e23 100644
--- a/src/sage/libs/flint/hypgeom.pxd
+++ b/src/sage/libs/flint/hypgeom.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/long_extras.pxd b/src/sage/libs/flint/long_extras.pxd
index e578cac1e83..e714e410ae6 100644
--- a/src/sage/libs/flint/long_extras.pxd
+++ b/src/sage/libs/flint/long_extras.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/mag.pxd b/src/sage/libs/flint/mag.pxd
index 738fd8a9a30..45d2565406b 100644
--- a/src/sage/libs/flint/mag.pxd
+++ b/src/sage/libs/flint/mag.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/mpf_mat.pxd b/src/sage/libs/flint/mpf_mat.pxd
index b4524a336cf..4b4ba5c455a 100644
--- a/src/sage/libs/flint/mpf_mat.pxd
+++ b/src/sage/libs/flint/mpf_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/mpf_vec.pxd b/src/sage/libs/flint/mpf_vec.pxd
index 4fc582675f5..5cf10e93233 100644
--- a/src/sage/libs/flint/mpf_vec.pxd
+++ b/src/sage/libs/flint/mpf_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/mpfr_mat.pxd b/src/sage/libs/flint/mpfr_mat.pxd
index ffb91d684d7..42d02e03f74 100644
--- a/src/sage/libs/flint/mpfr_mat.pxd
+++ b/src/sage/libs/flint/mpfr_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/mpfr_vec.pxd b/src/sage/libs/flint/mpfr_vec.pxd
index 5c3fec6f735..de27754cf27 100644
--- a/src/sage/libs/flint/mpfr_vec.pxd
+++ b/src/sage/libs/flint/mpfr_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/mpn_extras.pxd b/src/sage/libs/flint/mpn_extras.pxd
index cd029b2d9ad..c1a63d0efdd 100644
--- a/src/sage/libs/flint/mpn_extras.pxd
+++ b/src/sage/libs/flint/mpn_extras.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/mpoly.pxd b/src/sage/libs/flint/mpoly.pxd
index 2b9f5393227..8016e65e201 100644
--- a/src/sage/libs/flint/mpoly.pxd
+++ b/src/sage/libs/flint/mpoly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/nf.pxd b/src/sage/libs/flint/nf.pxd
index 73fb2aeb7c2..52e4ef3dcef 100644
--- a/src/sage/libs/flint/nf.pxd
+++ b/src/sage/libs/flint/nf.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/nf_elem.pxd b/src/sage/libs/flint/nf_elem.pxd
index 7ec811389d9..6c440b60c3f 100644
--- a/src/sage/libs/flint/nf_elem.pxd
+++ b/src/sage/libs/flint/nf_elem.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/nmod.pxd b/src/sage/libs/flint/nmod.pxd
index 1330498f255..07678e8c051 100644
--- a/src/sage/libs/flint/nmod.pxd
+++ b/src/sage/libs/flint/nmod.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/nmod_mat.pxd b/src/sage/libs/flint/nmod_mat.pxd
index bf33d0837b6..61215ee6adb 100644
--- a/src/sage/libs/flint/nmod_mat.pxd
+++ b/src/sage/libs/flint/nmod_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/nmod_mpoly.pxd b/src/sage/libs/flint/nmod_mpoly.pxd
index 0730f6db650..5537d451f0e 100644
--- a/src/sage/libs/flint/nmod_mpoly.pxd
+++ b/src/sage/libs/flint/nmod_mpoly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/nmod_mpoly_factor.pxd b/src/sage/libs/flint/nmod_mpoly_factor.pxd
index 23c6b47384f..1e89eeb82f8 100644
--- a/src/sage/libs/flint/nmod_mpoly_factor.pxd
+++ b/src/sage/libs/flint/nmod_mpoly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/nmod_poly.pxd b/src/sage/libs/flint/nmod_poly.pxd
index eb5cd984fd6..eb518d5b7d3 100644
--- a/src/sage/libs/flint/nmod_poly.pxd
+++ b/src/sage/libs/flint/nmod_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/nmod_poly_factor.pxd b/src/sage/libs/flint/nmod_poly_factor.pxd
index f885c202785..e4c0975d47d 100644
--- a/src/sage/libs/flint/nmod_poly_factor.pxd
+++ b/src/sage/libs/flint/nmod_poly_factor.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/nmod_poly_mat.pxd b/src/sage/libs/flint/nmod_poly_mat.pxd
index 7156ddd97ea..99fa07792eb 100644
--- a/src/sage/libs/flint/nmod_poly_mat.pxd
+++ b/src/sage/libs/flint/nmod_poly_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/nmod_vec.pxd b/src/sage/libs/flint/nmod_vec.pxd
index 326ea21b98a..6faf0bd7d82 100644
--- a/src/sage/libs/flint/nmod_vec.pxd
+++ b/src/sage/libs/flint/nmod_vec.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/padic.pxd b/src/sage/libs/flint/padic.pxd
index ef190a51a9e..7fe76c7c1b7 100644
--- a/src/sage/libs/flint/padic.pxd
+++ b/src/sage/libs/flint/padic.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/padic_mat.pxd b/src/sage/libs/flint/padic_mat.pxd
index 4a64baa9b1f..b7c47a751f6 100644
--- a/src/sage/libs/flint/padic_mat.pxd
+++ b/src/sage/libs/flint/padic_mat.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/padic_poly.pxd b/src/sage/libs/flint/padic_poly.pxd
index caca76b79db..47aab0d6238 100644
--- a/src/sage/libs/flint/padic_poly.pxd
+++ b/src/sage/libs/flint/padic_poly.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/partitions.pxd b/src/sage/libs/flint/partitions.pxd
index 9b76ea11b68..c8202f0a9bf 100644
--- a/src/sage/libs/flint/partitions.pxd
+++ b/src/sage/libs/flint/partitions.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/perm.pxd b/src/sage/libs/flint/perm.pxd
index 3e2f935d591..2b2ddaa535c 100644
--- a/src/sage/libs/flint/perm.pxd
+++ b/src/sage/libs/flint/perm.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/profiler.pxd b/src/sage/libs/flint/profiler.pxd
index 87c2c4684fd..905d6f832db 100644
--- a/src/sage/libs/flint/profiler.pxd
+++ b/src/sage/libs/flint/profiler.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/qadic.pxd b/src/sage/libs/flint/qadic.pxd
index 86db643ec2a..1ee8e65e1b4 100644
--- a/src/sage/libs/flint/qadic.pxd
+++ b/src/sage/libs/flint/qadic.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/qfb.pxd b/src/sage/libs/flint/qfb.pxd
index d881ababd29..5df77f71bd1 100644
--- a/src/sage/libs/flint/qfb.pxd
+++ b/src/sage/libs/flint/qfb.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/qqbar.pxd b/src/sage/libs/flint/qqbar.pxd
index aafe994212f..6732a5eb51f 100644
--- a/src/sage/libs/flint/qqbar.pxd
+++ b/src/sage/libs/flint/qqbar.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/qsieve.pxd b/src/sage/libs/flint/qsieve.pxd
index fe25087758c..7bd1bf5b862 100644
--- a/src/sage/libs/flint/qsieve.pxd
+++ b/src/sage/libs/flint/qsieve.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/thread_pool.pxd b/src/sage/libs/flint/thread_pool.pxd
index 137eae2b7a6..9a697f8d7c0 100644
--- a/src/sage/libs/flint/thread_pool.pxd
+++ b/src/sage/libs/flint/thread_pool.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/flint/ulong_extras.pxd b/src/sage/libs/flint/ulong_extras.pxd
index 8593c3725f2..e4c4ab06a97 100644
--- a/src/sage/libs/flint/ulong_extras.pxd
+++ b/src/sage/libs/flint/ulong_extras.pxd
@@ -4,6 +4,7 @@
 ################################################################################
 # This file is auto-generated by the script
 #   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.
+# From the commit 3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a
 # Do not modify by hand! Fix and rerun the script instead.
 ################################################################################
 
diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
index f1482997b86..7ca4a666abc 100644
--- a/src/sage/libs/gap/element.pyx
+++ b/src/sage/libs/gap/element.pyx
@@ -2504,6 +2504,7 @@ cdef class GapElement_Function(GapElement):
         cdef Obj result = NULL
         cdef Obj arg_list
         cdef int n = len(args)
+        cdef volatile Obj v2
 
         if n > 0 and n <= 3:
             libgap = self.parent()
@@ -2522,10 +2523,11 @@ cdef class GapElement_Function(GapElement):
                                            (a[0]).value,
                                            (a[1]).value)
             elif n == 3:
+                v2 = (a[2]).value
                 result = GAP_CallFunc3Args(self.value,
                                            (a[0]).value,
                                            (a[1]).value,
-                                           (a[2]).value)
+                                           v2)
             else:
                 arg_list = make_gap_list(args)
                 result = GAP_CallFuncList(self.value, arg_list)
diff --git a/src/sage/libs/giac/__init__.py b/src/sage/libs/giac/__init__.py
index e7d7bc67d14..0ce070994dd 100644
--- a/src/sage/libs/giac/__init__.py
+++ b/src/sage/libs/giac/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Wrappers for Giac functions
 
diff --git a/src/sage/libs/glpk/error.pyx b/src/sage/libs/glpk/error.pyx
index 4fb01782205..0ba90710023 100644
--- a/src/sage/libs/glpk/error.pyx
+++ b/src/sage/libs/glpk/error.pyx
@@ -116,4 +116,5 @@ def setup_glpk_error_handler():
     glp_term_hook(sage_glpk_term_hook, NULL)
     glp_error_hook(sage_glpk_error_hook, NULL)
 
+
 setup_glpk_error_handler()
diff --git a/src/sage/libs/linkages/padics/Polynomial_ram.pxi b/src/sage/libs/linkages/padics/Polynomial_ram.pxi
index e0584ecb8ad..c65760bd67f 100644
--- a/src/sage/libs/linkages/padics/Polynomial_ram.pxi
+++ b/src/sage/libs/linkages/padics/Polynomial_ram.pxi
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 This linkage file implements the padics API for ramified extensions using Sage
 Polynomials.
diff --git a/src/sage/libs/mpmath/all.py b/src/sage/libs/mpmath/all.py
index cae40f79314..ea35faeb721 100644
--- a/src/sage/libs/mpmath/all.py
+++ b/src/sage/libs/mpmath/all.py
@@ -1,7 +1,7 @@
 import mpmath
 
 # Patch mpmath to use Cythonized functions
-from . import utils as _utils
+from sage.libs.mpmath import utils as _utils
 
 # Also import internal functions
 from mpmath.libmp import *
@@ -10,16 +10,17 @@
 from mpmath import *
 
 # Utilities
-from .utils import call, mpmath_to_sage, sage_to_mpmath
+from sage.libs.mpmath.utils import call, mpmath_to_sage, sage_to_mpmath
 
 # Use mpmath internal functions for constants, to avoid unnecessary overhead
 _constants_funcs = {
-  'glaisher': glaisher_fixed,
-  'khinchin': khinchin_fixed,
-  'twinprime': twinprime_fixed,
-  'mertens': mertens_fixed
+    'glaisher': glaisher_fixed,
+    'khinchin': khinchin_fixed,
+    'twinprime': twinprime_fixed,
+    'mertens': mertens_fixed
 }
 
+
 def eval_constant(name, ring):
     prec = ring.precision() + 20
     return ring(_constants_funcs[name](prec)) >> prec
diff --git a/src/sage/libs/pari/all.py b/src/sage/libs/pari/all.py
index 8bcf5d827df..6cef5978cc1 100644
--- a/src/sage/libs/pari/all.py
+++ b/src/sage/libs/pari/all.py
@@ -1,3 +1,3 @@
 from cypari2.gen import Gen as pari_gen
 from cypari2 import PariError
-from . import pari
+from sage.libs.pari import pari
diff --git a/src/sage/libs/pynac/__init__.py b/src/sage/libs/pynac/__init__.py
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/src/sage/libs/pynac/pynac.py b/src/sage/libs/pynac/pynac.py
deleted file mode 100644
index ae39f63c4c2..00000000000
--- a/src/sage/libs/pynac/pynac.py
+++ /dev/null
@@ -1,25 +0,0 @@
-r"""
-Interface to the pynac library (deprecated module)
-
-This module consists only of deprecated lazy imports from
-:mod:`sage.symbolic.expression`.
-"""
-
-
-from sage.misc.lazy_import import lazy_import
-
-lazy_import('sage.symbolic.expression',
-            ['unpack_operands', 'paramset_from_Expression', 'get_ginac_serial', 'get_fn_serial',
-             'py_latex_variable_for_doctests', 'py_print_function_pystring',
-             'py_latex_function_pystring', 'tolerant_is_symbol', 'py_print_fderivative_for_doctests',
-             'py_latex_fderivative_for_doctests', 'test_binomial', 'py_real_for_doctests',
-             'py_imag_for_doctests', 'py_is_integer_for_doctests', 'py_is_crational_for_doctest',
-             'py_numer_for_doctests', 'py_denom_for_doctests', 'py_is_cinteger_for_doctest',
-             'py_float_for_doctests', 'py_tgamma_for_doctests', 'py_factorial_py', 'doublefactorial',
-             'py_stieltjes_for_doctests', 'py_zeta_for_doctests', 'py_exp_for_doctests',
-             'py_log_for_doctests', 'py_atan2_for_doctests', 'py_lgamma_for_doctests',
-             'py_mod_for_doctests', 'py_li_for_doctests', 'py_psi_for_doctests',
-             'py_psi2_for_doctests', 'py_li2_for_doctests', 'py_eval_unsigned_infinity_for_doctests',
-             'py_eval_infinity_for_doctests', 'py_eval_neg_infinity_for_doctests',
-             'register_symbol', 'init_pynac_I', 'init_function_table'],
-            deprecation=32386)
diff --git a/src/sage/libs/symmetrica/all.py b/src/sage/libs/symmetrica/all.py
index 7c5215f6444..f69490654af 100644
--- a/src/sage/libs/symmetrica/all.py
+++ b/src/sage/libs/symmetrica/all.py
@@ -1,100 +1,100 @@
-#from symmetrica import *
-
-from .symmetrica import start
-
-#kostka
-from .symmetrica import kostka_number_symmetrica as kostka_number
-from .symmetrica import kostka_tab_symmetrica as kostka_tab
-from .symmetrica import kostka_tafel_symmetrica as kostka_tafel
-
-
-#sab
-from .symmetrica import dimension_symmetrization_symmetrica as dimension_symmetrization
-from .symmetrica import bdg_symmetrica as bdg
-from .symmetrica import sdg_symmetrica as sdg
-from .symmetrica import odg_symmetrica as odg
-from .symmetrica import specht_dg_symmetrica as specht_dg
-from .symmetrica import ndg_symmetrica as ndg
-#from symmetrica import glmndg_symmetrica as glmndg
-
-
-#sc
-from .symmetrica import chartafel_symmetrica as chartafel
-from .symmetrica import charvalue_symmetrica as charvalue
-from .symmetrica import kranztafel_symmetrica as kranztafel
-#from symmetrica import c_ijk_sn_symmetrica  as c_ijk_sn
-
-#part
-from .symmetrica import strict_to_odd_part_symmetrica as strict_to_odd_part
-from .symmetrica import odd_to_strict_part_symmetrica as odd_to_strict
-from .symmetrica import q_core_symmetrica as q_core
-from .symmetrica import gupta_nm_symmetrica as gupta_nm
-from .symmetrica import gupta_tafel_symmetrica as gupta_tafel
-from .symmetrica import random_partition_symmetrica as random_partition
-
-
-#schur
-from .symmetrica import outerproduct_schur_symmetrica as outerproduct_schur
-from .symmetrica import dimension_schur_symmetrica as dimension_schur
-from .symmetrica import part_part_skewschur_symmetrica as part_part_skewschur
-from .symmetrica import newtrans_symmetrica as newtrans
-from .symmetrica import compute_schur_with_alphabet_symmetrica as compute_schur_with_alphabet
-from .symmetrica import compute_homsym_with_alphabet_symmetrica as compute_homsym_with_alphabet
-from .symmetrica import compute_elmsym_with_alphabet_symmetrica as compute_elmsym_with_alphabet
-from .symmetrica import compute_monomial_with_alphabet_symmetrica as compute_monomial_with_alphabet
-from .symmetrica import compute_powsym_with_alphabet_symmetrica as compute_powsym_with_alphabet
-from .symmetrica import compute_schur_with_alphabet_det_symmetrica as compute_schur_with_alphabet_det
-
-from .symmetrica import t_SCHUR_MONOMIAL_symmetrica as t_SCHUR_MONOMIAL
-from .symmetrica import t_SCHUR_HOMSYM_symmetrica as t_SCHUR_HOMSYM
-from .symmetrica import t_SCHUR_POWSYM_symmetrica as t_SCHUR_POWSYM
-from .symmetrica import t_SCHUR_ELMSYM_symmetrica as t_SCHUR_ELMSYM
-
-from .symmetrica import t_MONOMIAL_SCHUR_symmetrica as t_MONOMIAL_SCHUR
-from .symmetrica import t_MONOMIAL_HOMSYM_symmetrica as t_MONOMIAL_HOMSYM
-from .symmetrica import t_MONOMIAL_POWSYM_symmetrica as t_MONOMIAL_POWSYM
-from .symmetrica import t_MONOMIAL_ELMSYM_symmetrica as t_MONOMIAL_ELMSYM
-
-from .symmetrica import t_ELMSYM_SCHUR_symmetrica as t_ELMSYM_SCHUR
-from .symmetrica import t_ELMSYM_MONOMIAL_symmetrica as t_ELMSYM_MONOMIAL
-from .symmetrica import t_ELMSYM_HOMSYM_symmetrica as t_ELMSYM_HOMSYM
-from .symmetrica import t_ELMSYM_POWSYM_symmetrica as t_ELMSYM_POWSYM
-
-from .symmetrica import t_HOMSYM_SCHUR_symmetrica as t_HOMSYM_SCHUR
-from .symmetrica import t_HOMSYM_MONOMIAL_symmetrica as t_HOMSYM_MONOMIAL
-from .symmetrica import t_HOMSYM_POWSYM_symmetrica as t_HOMSYM_POWSYM
-from .symmetrica import t_HOMSYM_ELMSYM_symmetrica as t_HOMSYM_ELMSYM
-
-from .symmetrica import t_POWSYM_SCHUR_symmetrica as t_POWSYM_SCHUR
-from .symmetrica import t_POWSYM_HOMSYM_symmetrica as t_POWSYM_HOMSYM
-from .symmetrica import t_POWSYM_ELMSYM_symmetrica as t_POWSYM_ELMSYM
-from .symmetrica import t_POWSYM_MONOMIAL_symmetrica as t_POWSYM_MONOMIAL
-
-
-from .symmetrica import mult_schur_schur_symmetrica as mult_schur_schur
-from .symmetrica import mult_monomial_monomial_symmetrica as mult_monomial_monomial
-
-
-from .symmetrica import hall_littlewood_symmetrica as hall_littlewood
-
-from .symmetrica import t_POLYNOM_POWER_symmetrica as t_POLYNOM_POWER
-from .symmetrica import t_POLYNOM_SCHUR_symmetrica as t_POLYNOM_SCHUR
-from .symmetrica import t_POLYNOM_ELMSYM_symmetrica as t_POLYNOM_ELMSYM
-from .symmetrica import t_POLYNOM_MONOMIAL_symmetrica as t_POLYNOM_MONOMIAL
-
-from .symmetrica import scalarproduct_schur_symmetrica as scalarproduct_schur
-
-#plet
-from .symmetrica import plethysm_symmetrica as plethysm
-from .symmetrica import schur_schur_plet_symmetrica as schur_schur_plet
-
-#sb
-from .symmetrica import mult_schubert_schubert_symmetrica as mult_schubert_schubert
-from .symmetrica import t_SCHUBERT_POLYNOM_symmetrica as t_SCHUBERT_POLYNOM
-from .symmetrica import t_POLYNOM_SCHUBERT_symmetrica as t_POLYNOM_SCHUBERT
-from .symmetrica import mult_schubert_variable_symmetrica as mult_schubert_variable
-from .symmetrica import divdiff_perm_schubert_symmetrica as divdiff_perm_schubert
-from .symmetrica import scalarproduct_schubert_symmetrica as scalarproduct_schubert
-from .symmetrica import divdiff_schubert_symmetrica as divdiff_schubert
+# from symmetrica import *
+
+from sage.libs.symmetrica.symmetrica import start
+
+# kostka
+from sage.libs.symmetrica.symmetrica import kostka_number_symmetrica as kostka_number
+from sage.libs.symmetrica.symmetrica import kostka_tab_symmetrica as kostka_tab
+from sage.libs.symmetrica.symmetrica import kostka_tafel_symmetrica as kostka_tafel
+
+
+# sab
+from sage.libs.symmetrica.symmetrica import dimension_symmetrization_symmetrica as dimension_symmetrization
+from sage.libs.symmetrica.symmetrica import bdg_symmetrica as bdg
+from sage.libs.symmetrica.symmetrica import sdg_symmetrica as sdg
+from sage.libs.symmetrica.symmetrica import odg_symmetrica as odg
+from sage.libs.symmetrica.symmetrica import specht_dg_symmetrica as specht_dg
+from sage.libs.symmetrica.symmetrica import ndg_symmetrica as ndg
+# from symmetrica import glmndg_symmetrica as glmndg
+
+
+# sc
+from sage.libs.symmetrica.symmetrica import chartafel_symmetrica as chartafel
+from sage.libs.symmetrica.symmetrica import charvalue_symmetrica as charvalue
+from sage.libs.symmetrica.symmetrica import kranztafel_symmetrica as kranztafel
+# from symmetrica import c_ijk_sn_symmetrica  as c_ijk_sn
+
+# part
+from sage.libs.symmetrica.symmetrica import strict_to_odd_part_symmetrica as strict_to_odd_part
+from sage.libs.symmetrica.symmetrica import odd_to_strict_part_symmetrica as odd_to_strict
+from sage.libs.symmetrica.symmetrica import q_core_symmetrica as q_core
+from sage.libs.symmetrica.symmetrica import gupta_nm_symmetrica as gupta_nm
+from sage.libs.symmetrica.symmetrica import gupta_tafel_symmetrica as gupta_tafel
+from sage.libs.symmetrica.symmetrica import random_partition_symmetrica as random_partition
+
+
+# schur
+from sage.libs.symmetrica.symmetrica import outerproduct_schur_symmetrica as outerproduct_schur
+from sage.libs.symmetrica.symmetrica import dimension_schur_symmetrica as dimension_schur
+from sage.libs.symmetrica.symmetrica import part_part_skewschur_symmetrica as part_part_skewschur
+from sage.libs.symmetrica.symmetrica import newtrans_symmetrica as newtrans
+from sage.libs.symmetrica.symmetrica import compute_schur_with_alphabet_symmetrica as compute_schur_with_alphabet
+from sage.libs.symmetrica.symmetrica import compute_homsym_with_alphabet_symmetrica as compute_homsym_with_alphabet
+from sage.libs.symmetrica.symmetrica import compute_elmsym_with_alphabet_symmetrica as compute_elmsym_with_alphabet
+from sage.libs.symmetrica.symmetrica import compute_monomial_with_alphabet_symmetrica as compute_monomial_with_alphabet
+from sage.libs.symmetrica.symmetrica import compute_powsym_with_alphabet_symmetrica as compute_powsym_with_alphabet
+from sage.libs.symmetrica.symmetrica import compute_schur_with_alphabet_det_symmetrica as compute_schur_with_alphabet_det
+
+from sage.libs.symmetrica.symmetrica import t_SCHUR_MONOMIAL_symmetrica as t_SCHUR_MONOMIAL
+from sage.libs.symmetrica.symmetrica import t_SCHUR_HOMSYM_symmetrica as t_SCHUR_HOMSYM
+from sage.libs.symmetrica.symmetrica import t_SCHUR_POWSYM_symmetrica as t_SCHUR_POWSYM
+from sage.libs.symmetrica.symmetrica import t_SCHUR_ELMSYM_symmetrica as t_SCHUR_ELMSYM
+
+from sage.libs.symmetrica.symmetrica import t_MONOMIAL_SCHUR_symmetrica as t_MONOMIAL_SCHUR
+from sage.libs.symmetrica.symmetrica import t_MONOMIAL_HOMSYM_symmetrica as t_MONOMIAL_HOMSYM
+from sage.libs.symmetrica.symmetrica import t_MONOMIAL_POWSYM_symmetrica as t_MONOMIAL_POWSYM
+from sage.libs.symmetrica.symmetrica import t_MONOMIAL_ELMSYM_symmetrica as t_MONOMIAL_ELMSYM
+
+from sage.libs.symmetrica.symmetrica import t_ELMSYM_SCHUR_symmetrica as t_ELMSYM_SCHUR
+from sage.libs.symmetrica.symmetrica import t_ELMSYM_MONOMIAL_symmetrica as t_ELMSYM_MONOMIAL
+from sage.libs.symmetrica.symmetrica import t_ELMSYM_HOMSYM_symmetrica as t_ELMSYM_HOMSYM
+from sage.libs.symmetrica.symmetrica import t_ELMSYM_POWSYM_symmetrica as t_ELMSYM_POWSYM
+
+from sage.libs.symmetrica.symmetrica import t_HOMSYM_SCHUR_symmetrica as t_HOMSYM_SCHUR
+from sage.libs.symmetrica.symmetrica import t_HOMSYM_MONOMIAL_symmetrica as t_HOMSYM_MONOMIAL
+from sage.libs.symmetrica.symmetrica import t_HOMSYM_POWSYM_symmetrica as t_HOMSYM_POWSYM
+from sage.libs.symmetrica.symmetrica import t_HOMSYM_ELMSYM_symmetrica as t_HOMSYM_ELMSYM
+
+from sage.libs.symmetrica.symmetrica import t_POWSYM_SCHUR_symmetrica as t_POWSYM_SCHUR
+from sage.libs.symmetrica.symmetrica import t_POWSYM_HOMSYM_symmetrica as t_POWSYM_HOMSYM
+from sage.libs.symmetrica.symmetrica import t_POWSYM_ELMSYM_symmetrica as t_POWSYM_ELMSYM
+from sage.libs.symmetrica.symmetrica import t_POWSYM_MONOMIAL_symmetrica as t_POWSYM_MONOMIAL
+
+
+from sage.libs.symmetrica.symmetrica import mult_schur_schur_symmetrica as mult_schur_schur
+from sage.libs.symmetrica.symmetrica import mult_monomial_monomial_symmetrica as mult_monomial_monomial
+
+
+from sage.libs.symmetrica.symmetrica import hall_littlewood_symmetrica as hall_littlewood
+
+from sage.libs.symmetrica.symmetrica import t_POLYNOM_POWER_symmetrica as t_POLYNOM_POWER
+from sage.libs.symmetrica.symmetrica import t_POLYNOM_SCHUR_symmetrica as t_POLYNOM_SCHUR
+from sage.libs.symmetrica.symmetrica import t_POLYNOM_ELMSYM_symmetrica as t_POLYNOM_ELMSYM
+from sage.libs.symmetrica.symmetrica import t_POLYNOM_MONOMIAL_symmetrica as t_POLYNOM_MONOMIAL
+
+from sage.libs.symmetrica.symmetrica import scalarproduct_schur_symmetrica as scalarproduct_schur
+
+# plet
+from sage.libs.symmetrica.symmetrica import plethysm_symmetrica as plethysm
+from sage.libs.symmetrica.symmetrica import schur_schur_plet_symmetrica as schur_schur_plet
+
+# sb
+from sage.libs.symmetrica.symmetrica import mult_schubert_schubert_symmetrica as mult_schubert_schubert
+from sage.libs.symmetrica.symmetrica import t_SCHUBERT_POLYNOM_symmetrica as t_SCHUBERT_POLYNOM
+from sage.libs.symmetrica.symmetrica import t_POLYNOM_SCHUBERT_symmetrica as t_POLYNOM_SCHUBERT
+from sage.libs.symmetrica.symmetrica import mult_schubert_variable_symmetrica as mult_schubert_variable
+from sage.libs.symmetrica.symmetrica import divdiff_perm_schubert_symmetrica as divdiff_perm_schubert
+from sage.libs.symmetrica.symmetrica import scalarproduct_schubert_symmetrica as scalarproduct_schubert
+from sage.libs.symmetrica.symmetrica import divdiff_schubert_symmetrica as divdiff_schubert
 
 start()
diff --git a/src/sage/logic/all.py b/src/sage/logic/all.py
index c8604a624e8..6fe860ea538 100644
--- a/src/sage/logic/all.py
+++ b/src/sage/logic/all.py
@@ -1,3 +1,3 @@
-from .logic import SymbolicLogic
+from sage.logic.logic import SymbolicLogic
 
-from . import propcalc
+from sage.logic import propcalc
diff --git a/src/sage/manifolds/differentiable/integrated_curve.py b/src/sage/manifolds/differentiable/integrated_curve.py
index 063611becce..fe0019b6a80 100644
--- a/src/sage/manifolds/differentiable/integrated_curve.py
+++ b/src/sage/manifolds/differentiable/integrated_curve.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Integrated Curves and Geodesics in Manifolds
 
diff --git a/src/sage/manifolds/differentiable/levi_civita_connection.py b/src/sage/manifolds/differentiable/levi_civita_connection.py
index 00ebf69b47f..d2d36db90bd 100644
--- a/src/sage/manifolds/differentiable/levi_civita_connection.py
+++ b/src/sage/manifolds/differentiable/levi_civita_connection.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Levi-Civita Connections
 
diff --git a/src/sage/manifolds/differentiable/manifold.py b/src/sage/manifolds/differentiable/manifold.py
index 4b5a793f762..b9a16553cee 100644
--- a/src/sage/manifolds/differentiable/manifold.py
+++ b/src/sage/manifolds/differentiable/manifold.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Differentiable Manifolds
 
diff --git a/src/sage/manifolds/section_module.py b/src/sage/manifolds/section_module.py
index 975113ca2c9..546d2e13f03 100644
--- a/src/sage/manifolds/section_module.py
+++ b/src/sage/manifolds/section_module.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Section Modules
 
diff --git a/src/sage/manifolds/subset.py b/src/sage/manifolds/subset.py
index d6de3069a6f..8acda706d8f 100644
--- a/src/sage/manifolds/subset.py
+++ b/src/sage/manifolds/subset.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Subsets of Topological Manifolds
 
diff --git a/src/sage/manifolds/subsets/pullback.py b/src/sage/manifolds/subsets/pullback.py
index 6ab4a28059f..f096b563844 100644
--- a/src/sage/manifolds/subsets/pullback.py
+++ b/src/sage/manifolds/subsets/pullback.py
@@ -16,7 +16,7 @@
 from sage.categories.sets_cat import Sets, EmptySetError
 from sage.categories.metric_spaces import MetricSpaces
 from sage.misc.lazy_import import lazy_import
-from sage.modules.free_module import is_FreeModule
+from sage.modules.free_module import FreeModule_generic
 from sage.rings.infinity import infinity, minus_infinity
 from sage.rings.integer_ring import ZZ
 from sage.rings.rational_field import QQ
@@ -829,7 +829,7 @@ def is_closed(self):
             # Regardless of their base_ring, we treat polyhedra as closed
             # convex subsets of R^n
             return True
-        elif is_FreeModule(self._codomain_subset) and self._codomain_subset.rank() != infinity:
+        elif isinstance(self._codomain_subset, FreeModule_generic) and self._codomain_subset.rank() != infinity:
             if self._codomain_subset.base_ring() in MetricSpaces().Complete():
                 # Closed topological vector subspace
                 return True
diff --git a/src/sage/manifolds/vector_bundle.py b/src/sage/manifolds/vector_bundle.py
index b851fa64fe7..2b25f07248f 100644
--- a/src/sage/manifolds/vector_bundle.py
+++ b/src/sage/manifolds/vector_bundle.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Topological Vector Bundle
 
diff --git a/src/sage/matrix/action.pyx b/src/sage/matrix/action.pyx
index 0db343c9eed..96587b99cbc 100644
--- a/src/sage/matrix/action.pyx
+++ b/src/sage/matrix/action.pyx
@@ -66,8 +66,8 @@ AUTHOR:
 
 import operator
 
-from sage.matrix.matrix_space import MatrixSpace, is_MatrixSpace
-from sage.modules.free_module import FreeModule, is_FreeModule
+from sage.matrix.matrix_space import MatrixSpace
+from sage.modules.free_module import FreeModule, FreeModule_generic
 from sage.structure.coerce cimport coercion_model
 from sage.categories.homset import Hom, End
 
@@ -100,7 +100,7 @@ cdef class MatrixMulAction(Action):
          over Univariate Polynomial Ring in x over Rational Field
     """
     def __init__(self, G, S, is_left):
-        if not is_MatrixSpace(G):
+        if not isinstance(G, MatrixSpace):
             raise TypeError("Not a matrix space: %s" % G)
         if isinstance(S, SchemeHomset_generic):
             if G.base_ring() is not S.domain().base_ring():
@@ -160,7 +160,7 @@ cdef class MatrixMatrixAction(MatrixMulAction):
         example is good practice.
     """
     def __init__(self, G, S):
-        if not is_MatrixSpace(S):
+        if not isinstance(S, MatrixSpace):
             raise TypeError("Not a matrix space: %s" % S)
 
         MatrixMulAction.__init__(self, G, S, True)
@@ -304,7 +304,7 @@ cdef class MatrixVectorAction(MatrixMulAction):
             ...
             TypeError: incompatible dimensions 3, 4
             """
-        if not is_FreeModule(S):
+        if not isinstance(S, FreeModule_generic):
             raise TypeError("Not a free module: %s" % S)
         MatrixMulAction.__init__(self, G, S, True)
 
@@ -355,7 +355,7 @@ cdef class VectorMatrixAction(MatrixMulAction):
             ...
             TypeError: incompatible dimensions 5, 3
         """
-        if not is_FreeModule(S):
+        if not isinstance(S, FreeModule_generic):
             raise TypeError("Not a free module: %s" % S)
         MatrixMulAction.__init__(self, G, S, False)
 
diff --git a/src/sage/matrix/all.py b/src/sage/matrix/all.py
index 041624f3853..0902e081afb 100644
--- a/src/sage/matrix/all.py
+++ b/src/sage/matrix/all.py
@@ -1,7 +1,8 @@
 from sage.misc.lazy_import import lazy_import
-from .matrix_space import MatrixSpace
-from .constructor import (matrix, Matrix, column_matrix, random_matrix,
-                         diagonal_matrix, identity_matrix, block_matrix,
-                         block_diagonal_matrix, jordan_block, zero_matrix,
-                         ones_matrix, elementary_matrix, companion_matrix)
+from sage.matrix.matrix_space import MatrixSpace
+from sage.matrix.constructor import (matrix, Matrix, column_matrix, random_matrix,
+                                     diagonal_matrix, identity_matrix, block_matrix,
+                                     block_diagonal_matrix, jordan_block, zero_matrix,
+                                     ones_matrix, elementary_matrix, companion_matrix)
 Mat = MatrixSpace
+del lazy_import
diff --git a/src/sage/matrix/matrix0.pyx b/src/sage/matrix/matrix0.pyx
index c1e538a441e..dca6985e3f0 100644
--- a/src/sage/matrix/matrix0.pyx
+++ b/src/sage/matrix/matrix0.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Base class for matrices, part 0
 
diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
index e36d913bcd9..cc15ea36efb 100644
--- a/src/sage/matrix/matrix2.pyx
+++ b/src/sage/matrix/matrix2.pyx
@@ -5786,7 +5786,7 @@ cdef class Matrix(Matrix1):
             sage: t.decomposition_of_subspace(v, check_restrict=False) == t.decomposition_of_subspace(v)                # needs sage.libs.pari
             True
         """
-        if not sage.modules.free_module.is_FreeModule(M):
+        if not isinstance(M, sage.modules.free_module.FreeModule_generic):
             raise TypeError("M must be a free module.")
         if not self.is_square():
             raise ArithmeticError("self must be a square matrix")
diff --git a/src/sage/matrix/matrix_gf2e_dense.pyx b/src/sage/matrix/matrix_gf2e_dense.pyx
index a089770ef4c..9a1f83bcc7a 100644
--- a/src/sage/matrix/matrix_gf2e_dense.pyx
+++ b/src/sage/matrix/matrix_gf2e_dense.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # distutils: libraries = m4rie M4RI_LIBRARIES m
 # distutils: library_dirs = M4RI_LIBDIR
 # distutils: include_dirs = M4RI_INCDIR
diff --git a/src/sage/matrix/matrix_integer_dense.pyx b/src/sage/matrix/matrix_integer_dense.pyx
index e06e5af4c35..84a61f15a5e 100644
--- a/src/sage/matrix/matrix_integer_dense.pyx
+++ b/src/sage/matrix/matrix_integer_dense.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # distutils: extra_compile_args = NTL_CFLAGS M4RI_CFLAGS
 # distutils: libraries = iml NTL_LIBRARIES gmp m CBLAS_LIBRARIES
 # distutils: library_dirs = NTL_LIBDIR CBLAS_LIBDIR
diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
index 31c6c1e9d1a..4e9540aab1a 100644
--- a/src/sage/matrix/matrix_integer_sparse.pyx
+++ b/src/sage/matrix/matrix_integer_sparse.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Sparse integer matrices
 
diff --git a/src/sage/matrix/matrix_mod2_dense.pyx b/src/sage/matrix/matrix_mod2_dense.pyx
index f7689c60b07..3b479299738 100644
--- a/src/sage/matrix/matrix_mod2_dense.pyx
+++ b/src/sage/matrix/matrix_mod2_dense.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # distutils: libraries = M4RI_LIBRARIES GDLIB_LIBRARIES LIBPNG_LIBRARIES ZLIB_LIBRARIES
 # distutils: library_dirs = M4RI_LIBDIR GDLIB_LIBDIR LIBPNG_LIBDIR ZLIB_LIBDIR
 # distutils: include_dirs = M4RI_INCDIR GDLIB_INCDIR LIBPNG_INCDIR ZLIB_INCDIR
diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
index 5d0db5fb742..54703de84c6 100644
--- a/src/sage/matrix/matrix_space.py
+++ b/src/sage/matrix/matrix_space.py
@@ -74,12 +74,18 @@ def is_MatrixSpace(x):
         sage: MS = MatrixSpace(QQ,2)
         sage: A = MS.random_element()
         sage: is_MatrixSpace(MS)
+        doctest:warning...
+        DeprecationWarning: the function is_MatrixSpace is deprecated;
+        use 'isinstance(..., MatrixSpace)' instead
+        See https://github.com/sagemath/sage/issues/37924 for details.
         True
         sage: is_MatrixSpace(A)
         False
         sage: is_MatrixSpace(5)
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37924, "the function is_MatrixSpace is deprecated; use 'isinstance(..., MatrixSpace)' instead")
     return isinstance(x, MatrixSpace)
 
 
@@ -1265,10 +1271,10 @@ def _get_action_(self, S, op, self_on_left):
             if op is operator.mul:
                 from . import action as matrix_action
                 if self_on_left:
-                    if is_MatrixSpace(S):
+                    if isinstance(S, MatrixSpace):
                         # matrix multiplications
                         return matrix_action.MatrixMatrixAction(self, S)
-                    elif sage.modules.free_module.is_FreeModule(S):
+                    elif isinstance(S, sage.modules.free_module.FreeModule_generic):
                         return matrix_action.MatrixVectorAction(self, S)
                     elif isinstance(S, SchemeHomset_points):
                         return matrix_action.MatrixSchemePointAction(self, S)
@@ -1278,10 +1284,10 @@ def _get_action_(self, S, op, self_on_left):
                         # action of base ring
                         return sage.structure.coerce_actions.RightModuleAction(S, self)
                 else:
-                    if is_MatrixSpace(S):
+                    if isinstance(S, MatrixSpace):
                         # matrix multiplications
                         return matrix_action.MatrixMatrixAction(S, self)
-                    elif sage.modules.free_module.is_FreeModule(S):
+                    elif isinstance(S, sage.modules.free_module.FreeModule_generic):
                         return matrix_action.VectorMatrixAction(self, S)
                     elif isinstance(S, SchemeHomset_generic):
                         return matrix_action.PolymapMatrixAction(self, S)
diff --git a/src/sage/matrix/special.py b/src/sage/matrix/special.py
index 0399db53a03..c2afffd7a4d 100644
--- a/src/sage/matrix/special.py
+++ b/src/sage/matrix/special.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Constructors for special matrices
 
diff --git a/src/sage/matroids/advanced.py b/src/sage/matroids/advanced.py
index 8a9509efddc..c401afc7699 100644
--- a/src/sage/matroids/advanced.py
+++ b/src/sage/matroids/advanced.py
@@ -13,6 +13,7 @@
         - :class:`MinorMatroid `
         - :class:`DualMatroid `
         - :class:`RankMatroid `
+        - :class:`CircuitsMatroid `
         - :class:`CircuitClosuresMatroid `
         - :class:`BasisMatroid `
         - :class:`FlatsMatroid `
diff --git a/src/sage/matroids/basis_exchange_matroid.pyx b/src/sage/matroids/basis_exchange_matroid.pyx
index 7e6d565a868..1fe648dc7d9 100644
--- a/src/sage/matroids/basis_exchange_matroid.pyx
+++ b/src/sage/matroids/basis_exchange_matroid.pyx
@@ -193,13 +193,13 @@ cdef class BasisExchangeMatroid(Matroid):
 
     cdef _relabel(self, mapping):
         """
-        Relabel each element ``e`` as ``mapping[e]``, where ``mapping`` is a
+        Relabel each element `e` as ``mapping[e]``, where ``mapping`` is a
         given injective map.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
         OUTPUT: ``None``
 
diff --git a/src/sage/matroids/basis_matroid.pyx b/src/sage/matroids/basis_matroid.pyx
index da6192324bc..6ff808d710f 100644
--- a/src/sage/matroids/basis_matroid.pyx
+++ b/src/sage/matroids/basis_matroid.pyx
@@ -525,16 +525,16 @@ cdef class BasisMatroid(BasisExchangeMatroid):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx
index a732ea192e2..a3f393f29fe 100644
--- a/src/sage/matroids/circuit_closures_matroid.pyx
+++ b/src/sage/matroids/circuit_closures_matroid.pyx
@@ -527,16 +527,16 @@ cdef class CircuitClosuresMatroid(Matroid):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
diff --git a/src/sage/matroids/circuits_matroid.pxd b/src/sage/matroids/circuits_matroid.pxd
index f495a1eff81..2c876fa3a48 100644
--- a/src/sage/matroids/circuits_matroid.pxd
+++ b/src/sage/matroids/circuits_matroid.pxd
@@ -2,23 +2,30 @@ from sage.matroids.matroid cimport Matroid
 from sage.matroids.set_system cimport SetSystem
 
 cdef class CircuitsMatroid(Matroid):
-    cdef frozenset _groundset  # _E
-    cdef int _matroid_rank  # _R
-    cdef SetSystem _C  # circuits
+    cdef frozenset _groundset
+    cdef int _matroid_rank
+    cdef set _C  # circuits
     cdef dict _k_C  # k-circuits (k=len)
+    cdef list _sorted_C_lens
     cdef bint _nsc_defined
     cpdef groundset(self)
     cpdef _rank(self, X)
     cpdef full_rank(self)
-    cpdef _is_independent(self, F)
-    cpdef _max_independent(self, F)
-    cpdef _circuit(self, F)
+    cpdef _is_independent(self, X)
+    cpdef _max_independent(self, X)
+    cpdef _circuit(self, X)
+    cpdef _closure(self, X)
 
     # enumeration
     cpdef bases(self)
+    cpdef nonbases(self)
+    cpdef independent_r_sets(self, long r)
+    cpdef dependent_r_sets(self, long r)
     cpdef circuits(self, k=*)
     cpdef nonspanning_circuits(self)
-    cpdef no_broken_circuits_sets(self, ordering=*)
+    cpdef no_broken_circuits_facets(self, ordering=*, reduced=*)
+    cpdef no_broken_circuits_sets(self, ordering=*, reduced=*)
+    cpdef broken_circuit_complex(self, ordering=*, reduced=*)
 
     # properties
     cpdef girth(self)
diff --git a/src/sage/matroids/circuits_matroid.pyx b/src/sage/matroids/circuits_matroid.pyx
index aec280a35f7..c7981feea84 100644
--- a/src/sage/matroids/circuits_matroid.pyx
+++ b/src/sage/matroids/circuits_matroid.pyx
@@ -30,11 +30,10 @@ AUTHORS:
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
 
-from sage.structure.richcmp cimport rich_to_bool, richcmp
-from sage.matroids.matroid cimport Matroid
-from sage.matroids.set_system cimport SetSystem
 from cpython.object cimport Py_EQ, Py_NE
-
+from sage.structure.richcmp cimport rich_to_bool, richcmp
+from .matroid cimport Matroid
+from .set_system cimport SetSystem
 
 cdef class CircuitsMatroid(Matroid):
     r"""
@@ -42,9 +41,9 @@ cdef class CircuitsMatroid(Matroid):
 
     INPUT:
 
-    - ``M`` -- a matroid (default: ``None``)
-    - ``groundset`` -- a list (default: ``None``); the groundset of the matroid
-    - ``circuits`` -- a list (default: ``None``); the collection of circuits of
+    - ``M`` -- matroid (default: ``None``)
+    - ``groundset`` -- list (default: ``None``); the groundset of the matroid
+    - ``circuits`` -- list (default: ``None``); the collection of circuits of
       the matroid
     - ``nsc_defined`` -- boolean (default: ``False``); whether the matroid was
       defined by its nonspanning circuits
@@ -69,18 +68,19 @@ cdef class CircuitsMatroid(Matroid):
         """
         if M is not None:
             self._groundset = frozenset(M.groundset())
-            self._C = SetSystem(list(M.groundset()), frozenset([frozenset(C) for C in M.circuits()]))
+            self._C = set([C for C in M.circuits()])
         else:
             self._groundset = frozenset(groundset)
-            self._C = SetSystem(list(groundset), frozenset([frozenset(C) for C in circuits]))
+            self._C = set([frozenset(C) for C in circuits])
         # k-circuits
         self._k_C = {}
         for C in self._C:
             try:
-                self._k_C[len(C)] += [C]
+                self._k_C[len(C)].add(C)
             except KeyError:
-                self._k_C[len(C)] = []
-                self._k_C[len(C)] += [C]
+                self._k_C[len(C)] = set()
+                self._k_C[len(C)].add(C)
+        self._sorted_C_lens = sorted(self._k_C)
         self._matroid_rank = self.rank(self._groundset)
         self._nsc_defined = nsc_defined
 
@@ -90,7 +90,7 @@ cdef class CircuitsMatroid(Matroid):
 
         The groundset is the set of elements that comprise the matroid.
 
-        OUTPUT: a set
+        OUTPUT: set
 
         EXAMPLES::
 
@@ -111,7 +111,7 @@ cdef class CircuitsMatroid(Matroid):
 
         - ``X`` -- an object with Python's ``frozenset`` interface
 
-        OUTPUT: an integer; the rank of ``X`` in the matroid
+        OUTPUT: integer
 
         EXAMPLES::
 
@@ -130,7 +130,7 @@ cdef class CircuitsMatroid(Matroid):
         The *rank* of the matroid is the size of the largest independent
         subset of the groundset.
 
-        OUTPUT: an integer; the rank of the matroid
+        OUTPUT: integer
 
         EXAMPLES::
 
@@ -140,13 +140,13 @@ cdef class CircuitsMatroid(Matroid):
         """
         return self._matroid_rank
 
-    cpdef _is_independent(self, F):
+    cpdef _is_independent(self, X):
         """
         Test if input is independent.
 
         INPUT:
 
-        - ``X`` -- An object with Python's ``frozenset`` interface containing
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
           a subset of ``self.groundset()``
 
         OUTPUT: boolean
@@ -159,25 +159,26 @@ cdef class CircuitsMatroid(Matroid):
             sage: M._is_independent(['y0', 'y2', 'y3', 'x2'])
             True
         """
-        cdef set I = set(F)
-        cdef int s = len(F)
-        for i in self._k_C:
-            if i <= s:
-                for C in self._k_C[i]:
-                    if C <= I:
-                        return False
+        cdef set XX = set(X)
+        cdef int i, l = len(XX)
+        for i in self._sorted_C_lens:
+            if i > l:
+                break
+            for C in self._k_C[i]:
+                if C <= XX:
+                    return False
         return True
 
-    cpdef _max_independent(self, F):
+    cpdef _max_independent(self, X):
         """
         Compute a maximal independent subset.
 
         INPUT:
 
-        - ``X`` -- An object with Python's ``frozenset`` interface containing
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
           a subset of ``self.groundset()``
 
-        OUTPUT: a frozenset; a maximal independent subset of ``X``
+        OUTPUT: frozenset; a maximal independent subset of ``X``
 
         EXAMPLES::
 
@@ -185,26 +186,27 @@ cdef class CircuitsMatroid(Matroid):
             sage: len(M._max_independent(M.groundset()))
             6
         """
-        cdef set I = set(F)
-        for i in self._k_C:
-            for C in self._k_C[i]:
-                if i <= len(I) and i > 0:
-                    if C <= I:
-                        e = next(iter(C))
-                        I.remove(e)
-
-        return frozenset(I)
+        cdef set XX = set(X)
+        cdef int i
+        cdef frozenset C
+        while True:
+            try:
+                C = self._circuit(XX)
+                e = next(iter(C))
+                XX.remove(e)
+            except (ValueError, StopIteration):
+                return frozenset(XX)
 
-    cpdef _circuit(self, F):
+    cpdef _circuit(self, X):
         """
         Return a minimal dependent subset.
 
         INPUT:
 
-        - ``X`` -- An object with Python's ``frozenset`` interface containing
-          a subset of ``self.groundset()``.
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
+          a subset of ``self.groundset()``
 
-        OUTPUT: a frozenset; a circuit contained in ``X``, if it exists.
+        OUTPUT: frozenset; a circuit contained in ``X``, if it exists.
         Otherwise an error is raised.
 
         EXAMPLES::
@@ -217,19 +219,53 @@ cdef class CircuitsMatroid(Matroid):
             ...
             ValueError: no circuit in independent set
         """
-        cdef set I = set(F)
-        for C in self._C:
-            if C <= I:
-                return C
+        cdef set XX = set(X)
+        cdef int i, l = len(XX)
+        for i in self._sorted_C_lens:
+            if i > l:
+                break
+            for C in self._k_C[i]:
+                if C <= XX:
+                    return C
         raise ValueError("no circuit in independent set")
 
+    cpdef _closure(self, X):
+        """
+        Return the closure of a set.
+
+        INPUT:
+
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
+          a subset of ``self.groundset()``
+
+        OUTPUT: :class:`frozenset`
+
+        EXAMPLES::
+
+            sage: from sage.matroids.circuits_matroid import CircuitsMatroid
+            sage: M = CircuitsMatroid(matroids.catalog.Vamos())
+            sage: sorted(M._closure(set(['a', 'b', 'c'])))
+            ['a', 'b', 'c', 'd']
+        """
+        cdef set XX = set(X)
+        cdef frozenset S
+        cdef int i
+        for i in self._sorted_C_lens:
+            if i > len(XX) + 1:
+                break
+            for C in self._k_C[i]:
+                S = C - XX
+                if len(S) == 1:
+                    XX.add(next(iter(S)))
+        return frozenset(XX)
+
     cpdef _is_isomorphic(self, other, certificate=False):
         """
         Test if ``self`` is isomorphic to ``other``.
 
         INPUT:
 
-        - ``other`` -- a matroid
+        - ``other`` -- matroid
         - ``certificate`` -- boolean (default: ``False``)
 
         OUTPUT: boolean, and, if ``certificate=True``, a dictionary giving the
@@ -253,7 +289,9 @@ cdef class CircuitsMatroid(Matroid):
         if certificate:
             return self._is_isomorphic(other), self._isomorphism(other)
         N = CircuitsMatroid(other)
-        return self._C._isomorphism(N._C) is not None
+        S = SetSystem(list(self._groundset), self._C)
+        O = SetSystem(list(N._groundset), N._C)
+        return S._isomorphism(O) is not None
 
     # representation
 
@@ -300,7 +338,7 @@ cdef class CircuitsMatroid(Matroid):
             sage: hash(M) == hash(O)
             False
         """
-        return hash(tuple([self.groundset(), frozenset(self._C)]))
+        return hash(tuple([self._groundset, frozenset(self._C)]))
 
     def __richcmp__(left, right, int op):
         r"""
@@ -368,16 +406,16 @@ cdef class CircuitsMatroid(Matroid):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
@@ -415,30 +453,24 @@ cdef class CircuitsMatroid(Matroid):
         r"""
         Return the bases of the matroid.
 
-        OUTPUT: a :class:`SetSystem`
+        OUTPUT: :class:`SetSystem`
 
         EXAMPLES::
 
             sage: from sage.matroids.circuits_matroid import CircuitsMatroid
-            sage: M = CircuitsMatroid(matroids.Uniform(2, 4))
+            sage: M = CircuitsMatroid(matroids.CompleteGraphic(4))
             sage: len(M.bases())
-            6
+            16
         """
-        cdef SetSystem B, NSC
-        cdef bint flag
-        B = SetSystem(list(self.groundset()))
-        NSC = self.nonspanning_circuits()
         from itertools import combinations
+        cdef set B = set()
+        cdef set NB = set(self.nonbases())
+        cdef frozenset SS
         for S in combinations(self._groundset, self._matroid_rank):
-            flag = True
-            S = frozenset(S)
-            for C in NSC:
-                if C <= S:
-                    flag = False
-                    break
-            if flag:
-                B.append(S)
-        return B
+            SS = frozenset(S)
+            if SS not in NB:
+                B.add(SS)
+        return SetSystem(list(self._groundset), B)
 
     def bases_iterator(self):
         r"""
@@ -460,11 +492,101 @@ cdef class CircuitsMatroid(Matroid):
              frozenset({2, 3})]
         """
         from itertools import combinations
-        cdef SetSystem NSC = self.nonspanning_circuits()
-        for B in combinations(self._groundset, self._matroid_rank):
-            B = frozenset(B)
-            if not any(C <= B for C in NSC):
-                yield B
+        cdef set B = set()
+        cdef set NB = set(self.nonbases())
+        cdef frozenset S
+        for SS in combinations(self._groundset, self._matroid_rank):
+            S = frozenset(SS)
+            if S not in NB:
+                yield S
+
+    cpdef nonbases(self):
+        r"""
+        Return the nonbases of the matroid.
+
+        OUTPUT: :class:`SetSystem`
+
+        EXAMPLES::
+
+            sage: from sage.matroids.circuits_matroid import CircuitsMatroid
+            sage: M = CircuitsMatroid(matroids.Uniform(2, 4))
+            sage: len(M.nonbases())
+            0
+            sage: M = CircuitsMatroid(matroids.CompleteGraphic(6))
+            sage: len(M.nonbases())
+            1707
+        """
+        return self.dependent_r_sets(self._matroid_rank)
+
+    cpdef independent_r_sets(self, long r):
+        r"""
+        Return the size-``r`` independent subsets of the matroid.
+
+        INPUT:
+
+        - ``r`` -- nonnegative integer
+
+        OUTPUT: :class:`SetSystem`
+
+        EXAMPLES::
+
+            sage: from sage.matroids.circuits_matroid import CircuitsMatroid
+            sage: M = CircuitsMatroid(matroids.catalog.Pappus())
+            sage: M.independent_r_sets(4)
+            SetSystem of 0 sets over 9 elements
+            sage: M.independent_r_sets(3)
+            SetSystem of 75 sets over 9 elements
+            sage: frozenset({'a', 'c', 'e'}) in _
+            True
+
+        .. SEEALSO::
+
+            :meth:`M.bases() `
+        """
+        from itertools import combinations
+        cdef set I_r = set()
+        cdef set D_r = set(self.dependent_r_sets(r))
+        cdef frozenset SS
+        for S in combinations(self._groundset, r):
+            SS = frozenset(S)
+            if SS not in D_r:
+                I_r.add(SS)
+        return SetSystem(list(self._groundset), I_r)
+
+    cpdef dependent_r_sets(self, long r):
+        r"""
+        Return the dependent subsets of fixed size.
+
+        INPUT:
+
+        - ``r`` -- nonnegative integer
+
+        OUTPUT: :class:`SetSystem`
+
+        EXAMPLES::
+
+            sage: from sage.matroids.circuits_matroid import CircuitsMatroid
+            sage: M = CircuitsMatroid(matroids.catalog.Vamos())
+            sage: M.dependent_r_sets(3)
+            SetSystem of 0 sets over 8 elements
+            sage: sorted([sorted(X) for X in M.dependent_r_sets(4)])
+            [['a', 'b', 'c', 'd'], ['a', 'b', 'e', 'f'], ['a', 'b', 'g', 'h'],
+             ['c', 'd', 'e', 'f'], ['e', 'f', 'g', 'h']]
+        """
+        cdef int i
+        cdef set NB = set()
+        cdef frozenset S
+        for i in range(min(self._k_C), r + 1):
+            if i in self._k_C:
+                for S in self._k_C[i]:
+                    NB.add(S)
+            if i == r:
+                break
+            for S in NB.copy():
+                NB.remove(S)
+                for e in S ^ self._groundset:
+                    NB.add(S | set([e]))
+        return SetSystem(list(self._groundset), NB)
 
     cpdef circuits(self, k=None):
         """
@@ -472,9 +594,9 @@ cdef class CircuitsMatroid(Matroid):
 
         INPUT:
 
-        - ``k`` -- an integer (optional); the length of the circuits
+        - ``k`` -- integer (optional); the length of the circuits
 
-        OUTPUT: a :class:`SetSystem`
+        OUTPUT: :class:`SetSystem`
 
         EXAMPLES::
 
@@ -490,17 +612,16 @@ cdef class CircuitsMatroid(Matroid):
              frozenset({0, 2, 3}),
              frozenset({1, 2, 3})]
         """
-        cdef SetSystem C
-        C = SetSystem(list(self.groundset()))
+        cdef set C = set()
         if k is not None:
             if k in self._k_C:
                 for c in self._k_C[k]:
-                    C.append(c)
+                    C.add(c)
         else:
             for i in self._k_C:
                 for c in self._k_C[i]:
-                    C.append(c)
-        return C
+                    C.add(c)
+        return SetSystem(list(self._groundset), C)
 
     def circuits_iterator(self, k=None):
         """
@@ -508,7 +629,7 @@ cdef class CircuitsMatroid(Matroid):
 
         INPUT:
 
-        - ``k`` -- an integer (optional); the length of the circuits
+        - ``k`` -- integer (optional); the length of the circuits
 
         EXAMPLES::
 
@@ -537,7 +658,7 @@ cdef class CircuitsMatroid(Matroid):
         """
         Return the nonspanning circuits of the matroid.
 
-        OUTPUT: a :class:`SetSystem`
+        OUTPUT: :class:`SetSystem`
 
         EXAMPLES::
 
@@ -545,12 +666,16 @@ cdef class CircuitsMatroid(Matroid):
             sage: M = CircuitsMatroid(matroids.Uniform(2, 4))
             sage: M.nonspanning_circuits()
             SetSystem of 0 sets over 4 elements
+            sage: M = matroids.Theta(5)
+            sage: M.nonspanning_circuits()
+            SetSystem of 15 sets over 10 elements
         """
-        cdef list NSC = []
+        cdef set NSC = set()
+        cdef int i
         for i in self._k_C:
-            if i <= self.rank():
-                NSC.extend(self._k_C[i])
-        return SetSystem(list(self.groundset()), NSC)
+            if i <= self._matroid_rank:
+                NSC.update(self._k_C[i])
+        return SetSystem(list(self._groundset), NSC)
 
     def nonspanning_circuits_iterator(self):
         """
@@ -563,78 +688,165 @@ cdef class CircuitsMatroid(Matroid):
             sage: list(M.nonspanning_circuits_iterator())
             []
         """
+        cdef int i
         for i in self._k_C:
-            if i <= self.rank():
+            if i <= self._matroid_rank:
                 for C in self._k_C[i]:
                     yield C
 
-    cpdef no_broken_circuits_sets(self, ordering=None):
+    cpdef no_broken_circuits_facets(self, ordering=None, reduced=False):
+        r"""
+        Return the no broken circuits (NBC) facets of ``self``.
+
+        INPUT:
+
+        - ``ordering`` -- list (optional); a total ordering of the groundset
+        - ``reduced`` -- boolean (default: ``False``)
+
+        OUTPUT: :class:`SetSystem`
+
+        EXAMPLES::
+
+            sage: M = Matroid(circuits=[[0, 1, 2]])
+            sage: M.no_broken_circuits_facets(ordering=[1, 0, 2])
+            SetSystem of 2 sets over 3 elements
+            sage: sorted([sorted(X) for X in _])
+            [[0, 1], [1, 2]]
+            sage: M.no_broken_circuits_facets(ordering=[1, 0, 2], reduced=True)
+            SetSystem of 2 sets over 3 elements
+            sage: sorted([sorted(X) for X in _])
+            [[0], [2]]
+        """
+        from itertools import combinations
+        from sage.matroids.utilities import cmp_elements_key
+        if ordering is None:
+            ordering = sorted(self._groundset, key=cmp_elements_key)
+        else:
+            if frozenset(ordering) != self._groundset:
+                raise ValueError("not an ordering of the groundset")
+
+        cdef int i, r = self._matroid_rank
+        cdef frozenset min_e = frozenset([ordering[0]])
+        cdef frozenset S
+        # compute broken circuits (with minimal element added)
+        cdef dict BC = {}
+        for i in range(r + 1):
+            BC[i] = set()
+        for C in self._C:
+            for e in ordering:
+                if e in C:
+                    S = C - frozenset([e]) | min_e
+                    if len(S) <= r:
+                        BC[len(S)].add(S)
+                    break
+
+        for i in range(r):
+            for S in BC[i].copy():
+                BC[i].remove(S)
+                for e in self._groundset ^ S:
+                    BC[i+1].add(S | set([e]))
+
+        cdef set B = set()
+        for SS in combinations(ordering[1:], self._matroid_rank - 1):
+            S = frozenset(SS)
+            if S | min_e not in BC[r]:
+                if not reduced:
+                    B.add(S | min_e)
+                else:
+                    B.add(S)
+
+        return SetSystem(list(self.groundset()), B)
+
+    cpdef no_broken_circuits_sets(self, ordering=None, reduced=False):
         r"""
         Return the no broken circuits (NBC) sets of ``self``.
 
-        An NBC set is a subset `A` of the ground set under some total
+        An NBC set is a subset `A` of the groundset under some total
         ordering `<` such that `A` contains no broken circuit.
 
         INPUT:
 
-        - ``ordering`` -- a total ordering of the groundset given as a list
+        - ``ordering`` -- list (optional); a total ordering of the groundset
+        - ``reduced`` -- boolean (default: ``False``)
 
-        OUTPUT: a list of frozensets
+        OUTPUT: :class:`SetSystem`
 
         EXAMPLES::
 
-            sage: M = Matroid(circuits=[[1,2,3], [3,4,5], [1,2,4,5]])
+            sage: M = Matroid(circuits=[[1, 2, 3], [3, 4, 5], [1, 2, 4, 5]])
             sage: SimplicialComplex(M.no_broken_circuits_sets())
             Simplicial complex with vertex set (1, 2, 3, 4, 5)
              and facets {(1, 2, 4), (1, 2, 5), (1, 3, 4), (1, 3, 5)}
-            sage: SimplicialComplex(M.no_broken_circuits_sets([5,4,3,2,1]))
+            sage: SimplicialComplex(M.no_broken_circuits_sets([5, 4, 3, 2, 1]))
             Simplicial complex with vertex set (1, 2, 3, 4, 5)
              and facets {(1, 3, 5), (1, 4, 5), (2, 3, 5), (2, 4, 5)}
 
         ::
 
-            sage: M = Matroid(circuits=[[1,2,3], [1,4,5], [2,3,4,5]])
-            sage: SimplicialComplex(M.no_broken_circuits_sets([5,4,3,2,1]))
+            sage: M = Matroid(circuits=[[1, 2, 3], [1, 4, 5], [2, 3, 4, 5]])
+            sage: SimplicialComplex(M.no_broken_circuits_sets([5, 4, 3, 2, 1]))
             Simplicial complex with vertex set (1, 2, 3, 4, 5)
              and facets {(1, 3, 5), (2, 3, 5), (2, 4, 5), (3, 4, 5)}
 
         TESTS::
 
-            sage: M = Matroid(circuits=[[1,2,3], [3,4,5], [1,2,4,5]])
+            sage: M = Matroid(circuits=[[1, 2, 3], [3, 4, 5], [1, 2, 4, 5]])
             sage: C1 = SimplicialComplex(M.no_broken_circuits_sets())
             sage: from sage.matroids.basis_matroid import BasisMatroid
-            sage: M = BasisMatroid(Matroid(circuits=[[1,2,3], [3,4,5], [1,2,4,5]]))
+            sage: M = BasisMatroid(Matroid(circuits=[[1, 2, 3], [3, 4, 5], [1, 2, 4, 5]]))
             sage: C2 = SimplicialComplex(M.no_broken_circuits_sets())
             sage: C1 == C2
             True
         """
-        from sage.matroids.utilities import cmp_elements_key
-        if ordering is None:
-            ordering = sorted(self.groundset(), key=cmp_elements_key)
-        else:
-            if frozenset(ordering) != self.groundset():
-                raise ValueError("not an ordering of the groundset")
+        from sage.topology.simplicial_complex import SimplicialComplex
+        cdef set NBC = set()
+        for f in SimplicialComplex(self.no_broken_circuits_facets(ordering, reduced),
+                                   maximality_check=False).face_iterator():
+            NBC.add(frozenset(f))
+        return SetSystem(list(self.groundset()), NBC)
 
-        # compute broken circuits
-        cdef list BC = []
-        for C in self._C:
-            for e in ordering:
-                if e in C:
-                    BC.append(C - set([e]))
-                    break
+    cpdef broken_circuit_complex(self, ordering=None, reduced=False):
+        r"""
+        Return the broken circuit complex of ``self``.
 
-        cdef list F = []  # broken circuit complex facets
-        for B in self.bases():
-            flag = True
-            for bc in BC:
-                if bc <= B:
-                    flag = False
-                    break
-            if flag:
-                F.append(B)
+        The broken circuit complex of a matroid with a total ordering `<`
+        on the groundset is obtained from the
+        :meth:`NBC sets ` under subset inclusion.
 
+        INPUT:
+
+        - ``ordering`` -- list (optional); a total ordering of the groundset
+        - ``reduced`` -- boolean (default: ``False``); whether to return the
+          reduced broken circuit complex (the link at the smallest element)
+
+        OUTPUT: a simplicial complex of the NBC sets under inclusion
+
+        EXAMPLES::
+
+            sage: M = Matroid(circuits=[[1, 2, 3], [3, 4, 5], [1, 2, 4, 5]])
+            sage: M.broken_circuit_complex()
+            Simplicial complex with vertex set (1, 2, 3, 4, 5)
+             and facets {(1, 2, 4), (1, 2, 5), (1, 3, 4), (1, 3, 5)}
+            sage: M.broken_circuit_complex([5, 4, 3, 2, 1])
+            Simplicial complex with vertex set (1, 2, 3, 4, 5)
+             and facets {(1, 3, 5), (1, 4, 5), (2, 3, 5), (2, 4, 5)}
+            sage: M.broken_circuit_complex([5, 4, 3, 2, 1], reduced=True)
+            Simplicial complex with vertex set (1, 2, 3, 4)
+             and facets {(1, 3), (1, 4), (2, 3), (2, 4)}
+
+        For a matroid with loops, the broken circuit complex is not defined,
+        and the method yields an error::
+
+            sage: M = Matroid(groundset=[0, 1, 2], circuits=[[0]])
+            sage: M.broken_circuit_complex()
+            Traceback (most recent call last):
+            ...
+            ValueError: broken circuit complex of matroid with loops is not defined
+        """
         from sage.topology.simplicial_complex import SimplicialComplex
-        return [frozenset(f) for f in SimplicialComplex(F).face_iterator()]
+        if self.loops():
+            raise ValueError("broken circuit complex of matroid with loops is not defined")
+        return SimplicialComplex(self.no_broken_circuits_facets(ordering, reduced), maximality_check=False)
 
     # properties
 
@@ -654,7 +866,8 @@ cdef class CircuitsMatroid(Matroid):
 
         [Oxl2011]_, p. 327.
         """
-        return min(self._k_C, default=float('inf'))
+        from sage.rings.infinity import infinity
+        return min(self._k_C, default=infinity)
 
     cpdef is_paving(self):
         """
@@ -689,15 +902,15 @@ cdef class CircuitsMatroid(Matroid):
             sage: M = Matroid(circuits=C)
             sage: M.is_valid()
             True
-            sage: C = [[1,2], [1, 2, 3], [3, 4, 5], [1, 2, 4, 5]]
+            sage: C = [[1, 2], [1, 2, 3], [3, 4, 5], [1, 2, 4, 5]]
             sage: M = Matroid(circuits=C)
             sage: M.is_valid()
             False
-            sage: C = [[3,6], [1, 2, 3], [3, 4, 5], [1, 2, 4, 5]]
+            sage: C = [[3, 6], [1, 2, 3], [3, 4, 5], [1, 2, 4, 5]]
             sage: M = Matroid(circuits=C)
             sage: M.is_valid()
             False
-            sage: C = [[3,6], [1, 2, 3], [3, 4, 5], [1, 2, 6], [6, 4, 5], [1, 2, 4, 5]]
+            sage: C = [[3, 6], [1, 2, 3], [3, 4, 5], [1, 2, 6], [6, 4, 5], [1, 2, 4, 5]]
             sage: M = Matroid(circuits=C)
             sage: M.is_valid()
             True
@@ -711,10 +924,9 @@ cdef class CircuitsMatroid(Matroid):
             False
         """
         from itertools import combinations_with_replacement
-        cdef int i, j, k, S_len
-        cdef frozenset C1, C2, C3, I12, U12
-        cdef bint flag
-        for (i, j) in combinations_with_replacement(sorted(self._k_C), 2):
+        cdef int i, j
+        cdef frozenset C1, C2, I12, U12
+        for (i, j) in combinations_with_replacement(self._sorted_C_lens, 2):
             # loop through all circuit length pairs (i, j) with i <= j
             for C1 in self._k_C[i]:
                 if not C1:  # the empty set can't be a circuit
@@ -730,18 +942,8 @@ cdef class CircuitsMatroid(Matroid):
                         return False
                     # check circuit elimination axiom
                     U12 = C1 | C2
-                    S_len = len(U12) - 1  # the size of S below
                     for e in I12:
-                        flag = False
                         S = U12 - {e}
-                        for k in self._k_C:
-                            if k <= S_len:
-                                for C3 in self._k_C[k]:
-                                    if C3 <= S:
-                                        flag = True
-                                        break
-                            if flag:
-                                break
-                        if not flag:
+                        if self._is_independent(S):
                             return False
         return True
diff --git a/src/sage/matroids/constructor.py b/src/sage/matroids/constructor.py
index 07e8597fdb8..9a44462fed3 100644
--- a/src/sage/matroids/constructor.py
+++ b/src/sage/matroids/constructor.py
@@ -102,6 +102,7 @@
 
 
 from itertools import combinations
+from sage.combinat.posets.lattices import FiniteLatticePoset
 from sage.matrix.constructor import Matrix
 from sage.structure.element import is_Matrix
 from sage.rings.integer_ring import ZZ
@@ -181,7 +182,7 @@ def Matroid(groundset=None, data=None, **kwds):
     - ``circuits`` -- The list of circuits of the matroid.
     - ``nonspanning_circuits`` -- The list of nonspanning circuits of the
       matroid.
-    - ``flats`` -- The dictionary of flats indexed by their rank.
+    - ``flats`` -- The dictionary, list, or lattice of flats of the matroid.
     - ``graph`` -- A graph, whose edges form the elements of the matroid.
     - ``matrix`` -- A matrix representation of the matroid.
     - ``reduced_matrix`` -- A reduced representation of the matroid: if
@@ -326,8 +327,8 @@ def Matroid(groundset=None, data=None, **kwds):
 
         Strange things can happen if the input does not satisfy the circuit
         axioms, and these can be caught by the
-        :meth:`is_valid() ` method. So
-        always check whether your input makes sense!
+        :meth:`is_valid() `
+        method. So please check that your input makes sense!
 
         ::
 
@@ -335,16 +336,44 @@ def Matroid(groundset=None, data=None, **kwds):
             sage: M.is_valid()
             False
 
-    #.  Dictionary of flats:
+    #.  Flats:
 
-        ::
+        Given a dictionary of flats indexed by their rank, we get a
+        :class:`FlatsMatroid `::
 
             sage: M = Matroid(flats={0: [''], 1: ['a', 'b'], 2: ['ab']})
+            sage: M.is_isomorphic(matroids.Uniform(2, 2)) and M.is_valid()
+            True
+            sage: type(M)
+            
+
+        If instead we simply provide a list of flats, then the class computes
+        and stores the lattice of flats upon definition. This can be
+        time-consuming, but after it's done we benefit from some faster methods
+        (e.g., :meth:`is_valid() `)::
+
+            sage: M = Matroid(flats=['', 'a', 'b', 'ab'])
+            sage: for i in range(M.rank() + 1):  # print flats by rank
+            ....:     print(f'{i}: {sorted([sorted(F) for F in M.flats(i)], key=str)}')
+            0: [[]]
+            1: [['a'], ['b']]
+            2: [['a', 'b']]
             sage: M.is_valid()
             True
             sage: type(M)
             
 
+        Finally, we can also directly provide a lattice of flats::
+
+            sage: from sage.combinat.posets.lattices import LatticePoset
+            sage: flats = [frozenset(F) for F in powerset('ab')]
+            sage: L_M = LatticePoset((flats, lambda x, y: x < y))
+            sage: M = Matroid(L_M)
+            sage: M.is_isomorphic(matroids.Uniform(2, 2)) and M.is_valid()
+            True
+            sage: type(M)
+            
+
     #.  Graph:
 
         Sage has great support for graphs, see :mod:`sage.graphs.graph`.
@@ -787,6 +816,8 @@ def Matroid(groundset=None, data=None, **kwds):
             key = 'matroid'
         elif isinstance(data, str):
             key = 'revlex'
+        elif isinstance(data, dict) or isinstance(data, FiniteLatticePoset):
+            key = 'flats'
         elif data is None:
             raise TypeError("no input data given for Matroid()")
         else:
@@ -860,8 +891,12 @@ def Matroid(groundset=None, data=None, **kwds):
         # Determine groundset
         if groundset is None:
             groundset = set()
-            for i in data:
-                for F in data[i]:
+            if isinstance(data, dict):
+                for i in data:
+                    for F in data[i]:
+                        groundset.update(F)
+            else:  # iterable of flats (including lattice)
+                for F in data:
                     groundset.update(F)
         M = FlatsMatroid(groundset=groundset, flats=data)
 
diff --git a/src/sage/matroids/database_matroids.py b/src/sage/matroids/database_matroids.py
index 28a149436f3..50d781d349f 100644
--- a/src/sage/matroids/database_matroids.py
+++ b/src/sage/matroids/database_matroids.py
@@ -1489,7 +1489,7 @@ def K5dual(groundset='abcdefghij'):
     EXAMPLES::
 
         sage: M = matroids.catalog.K5dual(); M
-        M*(K5): Matroid of rank 6 on 10 elements with 15 circuits
+        M*(K5): Dual of 'Graphic matroid of rank 4 on 10 elements'
         sage: M.is_3connected()
         True
         sage: G1 = M.automorphism_group()
@@ -1502,7 +1502,6 @@ def K5dual(groundset='abcdefghij'):
     [Oxl2011]_, p. 656.
     """
     M = CompleteGraphic(5).dual()
-    M = Matroid(circuits=list(M.circuits()))
     M = _rename_and_relabel(M, "M*(K5)", groundset)
     return M
 
@@ -2067,7 +2066,7 @@ def Z(r, t=True, groundset=None):
     - ``t`` -- boolean (default: ``True``); whether the spike is tipped
     - ``groundset`` -- a string (optional); the groundset of the matroid
 
-    OUTPUT: a matroid; the unique rank-`r` binary spike (tipped or tipless)
+    OUTPUT: matroid; the unique rank-`r` binary spike (tipped or tipless)
 
     EXAMPLES::
 
@@ -2173,7 +2172,7 @@ def Spike(r, t=True, C3=[], groundset=None):
       The default (i.e. the empty list) results in a free `r`-spike
     - ``groundset`` -- a string (optional); the groundset of the matroid
 
-    OUTPUT: a matroid; a rank-`r` spike (tipped or tipless)
+    OUTPUT: matroid; a rank-`r` spike (tipped or tipless)
 
     EXAMPLES::
 
@@ -2291,7 +2290,7 @@ def Theta(n, groundset=None):
     - ``n`` -- an integer (`n \ge 2`); the rank of the matroid
     - ``groundset`` -- a string (optional); the groundset of the matroid
 
-    OUTPUT: a matroid (`\Theta_n`)
+    OUTPUT: matroid (`\Theta_n`)
 
     EXAMPLES::
 
@@ -2364,7 +2363,7 @@ def Psi(r, groundset=None):
     - ``r`` -- an integer (`r \ge 3`); the rank of the matroid
     - ``groundset`` -- a string (optional); the groundset of the matroid
 
-    OUTPUT: a matroid (`\Psi_r`)
+    OUTPUT: matroid (`\Psi_r`)
 
     EXAMPLES::
 
@@ -5234,7 +5233,7 @@ def _rename_and_relabel(M, name=None, groundset=None):
     - ``name`` -- a string (optional)
     - ``groundset`` -- a string (optional)
 
-    OUTPUT: a matroid
+    OUTPUT: matroid
     """
     if groundset is not None:
         if len(groundset) != len(M.groundset()):
diff --git a/src/sage/matroids/dual_matroid.py b/src/sage/matroids/dual_matroid.py
index 37b9e6c046b..d17246ad2c5 100644
--- a/src/sage/matroids/dual_matroid.py
+++ b/src/sage/matroids/dual_matroid.py
@@ -4,7 +4,7 @@
 Theory
 ======
 
-Let `M` be a matroid with ground set `E`. If `B` is the set of bases of `M`,
+Let `M` be a matroid with groundset `E`. If `B` is the set of bases of `M`,
 then the set `\{E - b : b \in B\}` is the set of bases of another matroid, the
 dual of `M`.
 
@@ -24,10 +24,9 @@
 
 The class ``DualMatroid`` wraps around a matroid instance to represent its
 dual. Only useful for classes that don't have an explicit construction of the
-dual (such as :class:`RankMatroid `
-and
+dual (such as :class:`RankMatroid ` and
 :class:`CircuitClosuresMatroid `).
-It is also used as default implementation of the method
+It is also used as the default implementation of the method
 :meth:`M.dual() `.
 For direct access to the ``DualMatroid`` constructor, run::
 
@@ -35,14 +34,11 @@
 
 See also :mod:`sage.matroids.advanced`.
 
-
 AUTHORS:
 
 - Rudi Pendavingh, Michael Welsh, Stefan van Zwam (2013-04-01): initial version
-
-Methods
-=======
 """
+
 # ****************************************************************************
 #       Copyright (C) 2013 Rudi Pendavingh 
 #       Copyright (C) 2013 Michael Welsh 
@@ -57,19 +53,18 @@
 
 from .matroid import Matroid
 
-
 class DualMatroid(Matroid):
     r"""
     Dual of a matroid.
 
     For some matroid representations it can be computationally expensive to
     derive an explicit representation of the dual. This class wraps around any
-    matroid to provide an abstract dual. It also serves as default
-    implementation.
+    matroid to provide an abstract dual. It also serves as the default
+    implementation of the dual.
 
     INPUT:
 
-    - ``matroid`` - a matroid.
+    - ``matroid`` -- matroid
 
     EXAMPLES::
 
@@ -103,9 +98,17 @@ def __init__(self, matroid):
                  {'a', 'b', 'g', 'h'}, {'c', 'd', 'e', 'f'},
                  {'e', 'f', 'g', 'h'}},
              4: {{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}}}'
+
+        TESTS::
+
+            sage: from sage.matroids.dual_matroid import DualMatroid
+            sage: DualMatroid([])
+            Traceback (most recent call last):
+            ...
+            TypeError: no matroid provided to take the dual of
         """
         if not isinstance(matroid, Matroid):
-            raise TypeError("no matroid provided to take dual of.")
+            raise TypeError("no matroid provided to take the dual of")
         self._matroid = matroid
 
     def groundset(self):
@@ -114,9 +117,7 @@ def groundset(self):
 
         The groundset is the set of elements that comprise the matroid.
 
-        OUTPUT:
-
-        A set.
+        OUTPUT: set
 
         EXAMPLES::
 
@@ -135,11 +136,9 @@ def _rank(self, X):
 
         INPUT:
 
-        - ``X`` -- an object with Python's ``frozenset`` interface.
-
-        OUTPUT:
+        - ``X`` -- an object with Python's ``frozenset`` interface
 
-        The rank of ``X`` in the matroid.
+        OUTPUT: integer
 
         EXAMPLES::
 
@@ -155,12 +154,10 @@ def _corank(self, X):
 
         INPUT:
 
-        - ``X`` -- An object with Python's ``frozenset`` interface
-          containing a subset of ``self.groundset()``.
+        - ``X`` -- an object with Python's ``frozenset`` interface
+          containing a subset of ``self.groundset()``
 
-        OUTPUT:
-
-        The corank of ``X``.
+        OUTPUT: integer
 
         EXAMPLES::
 
@@ -176,12 +173,10 @@ def _max_independent(self, X):
 
         INPUT:
 
-        - ``X`` -- An object with Python's ``frozenset`` interface containing
-          a subset of ``self.groundset()``.
-
-        OUTPUT:
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
+          a subset of ``self.groundset()``
 
-        A maximal independent subset of ``X``.
+        OUTPUT: a maximal independent subset of ``X``
 
         EXAMPLES::
 
@@ -202,13 +197,11 @@ def _circuit(self, X):
 
         INPUT:
 
-        - ``X`` -- An object with Python's ``frozenset`` interface containing
-          a subset of ``self.groundset()``.
-
-        OUTPUT:
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
+          a subset of ``self.groundset()``
 
-        A circuit contained in ``X``, if it exists. Otherwise an error is
-        raised.
+        OUTPUT: a circuit contained in ``X``, if it exists; otherwise, an error is
+        raised
 
         EXAMPLES::
 
@@ -230,12 +223,10 @@ def _closure(self, X):
 
         INPUT:
 
-        - ``X`` -- An object with Python's ``frozenset`` interface containing
-          a subset of ``self.groundset()``.
-
-        OUTPUT:
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
+          a subset of ``self.groundset()``
 
-        The smallest closed set containing ``X``.
+        OUTPUT: the smallest closed set containing ``X``
 
         EXAMPLES::
 
@@ -251,12 +242,10 @@ def _max_coindependent(self, X):
 
         INPUT:
 
-        - ``X`` -- An object with Python's ``frozenset`` interface containing
-          a subset of ``self.groundset()``.
-
-        OUTPUT:
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
+          a subset of ``self.groundset()``
 
-        A maximal coindependent subset of ``X``.
+        OUTPUT: a maximal coindependent subset of ``X``
 
         EXAMPLES::
 
@@ -277,12 +266,10 @@ def _coclosure(self, X):
 
         INPUT:
 
-        - ``X`` -- An object with Python's ``frozenset`` interface containing
-          a subset of ``self.groundset()``.
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
+          a subset of ``self.groundset()``
 
-        OUTPUT:
-
-        The smallest coclosed set containing ``X``.
+        OUTPUT: the smallest coclosed set containing ``X``
 
         EXAMPLES::
 
@@ -298,13 +285,11 @@ def _cocircuit(self, X):
 
         INPUT:
 
-        - ``X`` -- An object with Python's ``frozenset`` interface containing
-          a subset of ``self.groundset()``.
-
-        OUTPUT:
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
+          a subset of ``self.groundset()``
 
-        A cocircuit contained in ``X``, if it exists. Otherwise an error is
-        raised.
+        OUTPUT: a cocircuit contained in ``X``, if it exists; otherwise, an error is
+        raised
 
         EXAMPLES::
 
@@ -324,14 +309,12 @@ def _minor(self, contractions=None, deletions=None):
 
         INPUT:
 
-        - ``contractions`` -- An object with Python's ``frozenset`` interface
-          containing a subset of ``self.groundset()``.
-        - ``deletions`` -- An object with Python's ``frozenset`` interface
-          containing a subset of ``self.groundset()``.
+        - ``contractions`` -- an object with Python's ``frozenset`` interface
+          containing a subset of ``self.groundset()``
+        - ``deletions`` -- an object with Python's ``frozenset`` interface
+          containing a subset of ``self.groundset()``
 
-        OUTPUT:
-
-        A ``DualMatroid`` instance representing
+        OUTPUT: a :class:`DualMatroid` representing
         `(``self._matroid`` / ``deletions`` \ ``contractions``)^*`
 
         .. NOTE::
@@ -339,8 +322,8 @@ def _minor(self, contractions=None, deletions=None):
             This method does NOT do any checks. Besides the assumptions above,
             we assume the following:
 
-            - ``contractions`` is independent
-            - ``deletions`` is coindependent
+            - ``contractions`` is independent;
+            - ``deletions`` is coindependent;
             - ``contractions`` and ``deletions`` are disjoint.
 
         EXAMPLES::
@@ -364,16 +347,13 @@ def dual(self):
         r"""
         Return the dual of the matroid.
 
-        Let `M` be a matroid with ground set `E`. If `B` is the set of bases
+        Let `M` be a matroid with groundset `E`. If `B` is the set of bases
         of `M`, then the set `\{E - b : b \in B\}` is the set of bases of
         another matroid, the *dual* of `M`. Note that the dual of the dual of
-        `M` equals `M`, so if this is the
-        :class:`DualMatroid` instance
+        `M` equals `M`, so if this is the :class:`DualMatroid` instance
         wrapping `M` then the returned matroid is `M`.
 
-        OUTPUT:
-
-        The dual matroid.
+        OUTPUT: the dual matroid
 
         EXAMPLES::
 
@@ -439,11 +419,9 @@ def __eq__(self, other):
 
         INPUT:
 
-        - ``other`` -- A matroid.
+        - ``other`` -- matroid
 
-        OUTPUT:
-
-        Boolean.
+        OUTPUT: boolean
 
         EXAMPLES::
 
@@ -471,11 +449,9 @@ def __ne__(self, other):
 
         INPUT:
 
-        - ``other`` -- A matroid.
-
-        OUTPUT:
+        - ``other`` -- matroid
 
-        Boolean.
+        OUTPUT: boolean
 
         EXAMPLES::
 
@@ -526,3 +502,64 @@ def __reduce__(self):
         data = (self._matroid, self.get_custom_name())
         version = 0
         return sage.matroids.unpickling.unpickle_dual_matroid, (version, data)
+
+    def relabel(self, mapping):
+        r"""
+        Return an isomorphic matroid with relabeled groundset.
+
+        The output is obtained by relabeling each element `e` by
+        ``mapping[e]``, where ``mapping`` is a given injective map. If
+        ``mapping[e]`` is not defined, then the identity map is assumed.
+
+        INPUT:
+
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
+
+        OUTPUT: matroid
+
+        EXAMPLES::
+
+            sage: M = matroids.catalog.K5dual(range(10))
+            sage: type(M)
+            
+            sage: sorted(M.groundset())
+            [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+            sage: N = M.dual().relabel({0:10})
+            sage: sorted(N.groundset())
+            [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+            sage: N.is_isomorphic(matroids.catalog.K5())
+            True
+
+        TESTS::
+
+            sage: M = matroids.catalog.K5dual(range(10))
+            sage: f = {0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e',
+            ....:      5: 'f', 6: 'g', 7: 'h', 8: 'i', 9: 'j'}
+            sage: N = M.relabel(f)
+            sage: for S in powerset(M.groundset()):
+            ....:     assert M.rank(S) == N.rank([f[x] for x in S])
+        """
+        M = self._matroid.relabel(mapping).dual()
+        return M
+
+    def is_valid(self):
+        """
+        Test if ``self`` obeys the matroid axioms.
+
+        For a :class:`DualMatroid`, we check its dual.
+
+        OUTPUT: boolean
+
+        EXAMPLES::
+
+            sage: M = matroids.catalog.K5dual()
+            sage: type(M)
+            
+            sage: M.is_valid()
+            True
+            sage: M = Matroid([[0, 1], [2, 3]])
+            sage: M.dual().is_valid()
+            False
+        """
+        return self._matroid.is_valid()
diff --git a/src/sage/matroids/flats_matroid.pxd b/src/sage/matroids/flats_matroid.pxd
index 440dac7012c..28a6d22deaf 100644
--- a/src/sage/matroids/flats_matroid.pxd
+++ b/src/sage/matroids/flats_matroid.pxd
@@ -1,16 +1,19 @@
-from sage.matroids.matroid cimport Matroid
+from .matroid cimport Matroid
 
 cdef class FlatsMatroid(Matroid):
-    cdef frozenset _groundset  # _E
-    cdef int _matroid_rank  # _R
+    cdef frozenset _groundset
+    cdef int _matroid_rank
     cdef dict _F  # flats
+    cdef object _L  # lattice of flats
     cpdef groundset(self)
     cpdef _rank(self, X)
     cpdef full_rank(self)
-    cpdef _is_independent(self, F)
+    cpdef _closure(self, X)
+    cpdef _is_closed(self, X)
 
     # enumeration
     cpdef flats(self, k)
+    cpdef whitney_numbers(self)
     cpdef whitney_numbers2(self)
 
     # isomorphism and relabeling
diff --git a/src/sage/matroids/flats_matroid.pyx b/src/sage/matroids/flats_matroid.pyx
index 74f64621dd1..18f117a503b 100644
--- a/src/sage/matroids/flats_matroid.pyx
+++ b/src/sage/matroids/flats_matroid.pyx
@@ -30,21 +30,21 @@ AUTHORS:
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
 
-from sage.structure.richcmp cimport rich_to_bool, richcmp
-from sage.matroids.matroid cimport Matroid
-from sage.matroids.set_system cimport SetSystem
-from sage.matroids.utilities import setprint_s
 from cpython.object cimport Py_EQ, Py_NE
-
+from sage.structure.richcmp cimport rich_to_bool, richcmp
+from .matroid cimport Matroid
+from .set_system cimport SetSystem
+from sage.combinat.posets.lattices import LatticePoset, FiniteLatticePoset
 
 cdef class FlatsMatroid(Matroid):
     r"""
     INPUT:
 
-    - ``M`` -- a matroid (default: ``None``)
-    - ``groundset`` -- a list (default: ``None``); the groundset of the matroid
-    - ``flats`` -- a dictionary (default: ``None``); the lists of `k`-flats of
-      the matroid, indexed by their rank `k`
+    - ``M`` -- matroid (default: ``None``)
+    - ``groundset`` -- list (default: ``None``); the groundset of the matroid
+    - ``flats`` -- (default: ``None``); the dictionary of the lists of flats
+      (indexed by their rank), or the list of all flats, or the lattice of
+      flats of the matroid
 
     .. NOTE::
 
@@ -65,24 +65,36 @@ cdef class FlatsMatroid(Matroid):
             sage: TestSuite(M).run()
         """
         self._F = {}
+        self._L = None
         if M is not None:
-            self._groundset = frozenset(M.groundset())
-            for i in range(len(M.groundset()) + 1):
+            self._groundset = M.groundset()
+            for i in range(M.rank() + 1):
                 for F in M.flats(i):
                     try:
-                        self._F[i].add(frozenset(F))
+                        self._F[i].add(F)
                     except KeyError:
                         self._F[i] = set()
-                        self._F[i].add(frozenset(F))
+                        self._F[i].add(F)
         else:
             self._groundset = frozenset(groundset)
-            for i in sorted(flats):
-                for F in flats[i]:
-                    try:
-                        self._F[i].add(frozenset(F))
-                    except KeyError:
-                        self._F[i] = set()
-                        self._F[i].add(frozenset(F))
+            if isinstance(flats, dict):
+                for i in sorted(flats):
+                    for F in flats[i]:
+                        try:
+                            self._F[i].add(frozenset(F))
+                        except KeyError:
+                            self._F[i] = set()
+                            self._F[i].add(frozenset(F))
+            else:  # store lattice of flats
+                if isinstance(flats, FiniteLatticePoset):
+                    self._L = flats
+                else:  # assume iterable of flats
+                    self._L = LatticePoset(([frozenset(F) for F in flats], lambda x, y: x < y))
+                self._matroid_rank = self._L.rank()
+                for i in range(self._matroid_rank + 1):
+                    self._F[i] = set()
+                for x in self._L:
+                    self._F[self._L.rank(x)].add(x)
         self._matroid_rank = max(self._F, default=-1)
 
     cpdef groundset(self):
@@ -91,7 +103,7 @@ cdef class FlatsMatroid(Matroid):
 
         The groundset is the set of elements that comprise the matroid.
 
-        OUTPUT: a set
+        OUTPUT: :class:`frozenset`
 
         EXAMPLES::
 
@@ -111,15 +123,15 @@ cdef class FlatsMatroid(Matroid):
 
         INPUT:
 
-        - ``X`` -- an object with Python's :class:`frozenset` interface
+        - ``X`` -- an object with Python's ``frozenset`` interface
 
-        OUTPUT: an integer; the rank of ``X`` in the matroid
+        OUTPUT: integer
 
         EXAMPLES::
 
             sage: from sage.matroids.flats_matroid import FlatsMatroid
             sage: M = FlatsMatroid(matroids.Theta(3))
-            sage: M._rank(['x1', 'y0', 'y2'])
+            sage: M._rank(frozenset(['x1', 'y0', 'y2']))
             2
 
         TESTS::
@@ -130,11 +142,10 @@ cdef class FlatsMatroid(Matroid):
             sage: for S in powerset(M.groundset()):
             ....:     assert M.rank(S) == F.rank(S)
         """
-        cdef frozenset XX = frozenset(X)
-        for i in range(self.rank() + 1):
-                for f in self._F[i]:
-                    if f >= XX:
-                        return i
+        for i in range(self._matroid_rank + 1):
+            for f in self._F[i]:
+                if f >= X:
+                    return i
 
     # optional
 
@@ -145,7 +156,7 @@ cdef class FlatsMatroid(Matroid):
         The *rank* of the matroid is the size of the largest independent
         subset of the groundset.
 
-        OUTPUT: an integer; the rank of the matroid
+        OUTPUT: integer
 
         EXAMPLES::
 
@@ -156,13 +167,63 @@ cdef class FlatsMatroid(Matroid):
         """
         return self._matroid_rank
 
+    cpdef _closure(self, X):
+        """
+        Return the closure of a set.
+
+        INPUT:
+
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
+          a subset of ``self.groundset()``
+
+        OUTPUT: :class:`frozenset`
+
+        EXAMPLES::
+
+            sage: from sage.matroids.flats_matroid import FlatsMatroid
+            sage: M = FlatsMatroid(matroids.catalog.Vamos())
+            sage: sorted(M._closure(frozenset(['a', 'b', 'c'])))
+            ['a', 'b', 'c', 'd']
+        """
+        cdef int i
+        for i in range(self._matroid_rank + 1):
+            for f in self._F[i]:
+                if f >= X:
+                    return f
+
+    cpdef _is_closed(self, X):
+        """
+        Test if input is a closed set.
+
+        INPUT:
+
+        - ``X`` -- an object with Python's ``frozenset`` interface containing
+          a subset of ``self.groundset()``
+
+        OUTPUT: boolean
+
+        EXAMPLES::
+
+            sage: from sage.matroids.flats_matroid import FlatsMatroid
+            sage: M = FlatsMatroid(matroids.catalog.Vamos())
+            sage: M._is_closed(frozenset(['a', 'b', 'c', 'd']))
+            True
+            sage: M._is_closed(frozenset(['a', 'b', 'c', 'e']))
+            False
+        """
+        cdef int i
+        for i in self._F:
+            if X in self._F[i]:
+                return True
+        return False
+
     cpdef _is_isomorphic(self, other, certificate=False):
         """
         Test if ``self`` is isomorphic to ``other``.
 
         INPUT:
 
-        - ``other`` -- a matroid
+        - ``other`` -- matroid
         - ``certificate`` -- boolean (default: ``False``)
 
 
@@ -186,8 +247,8 @@ cdef class FlatsMatroid(Matroid):
         if certificate:
             return self._is_isomorphic(other), self._isomorphism(other)
         N = FlatsMatroid(other)
-        flats_self = frozenset([F for i in self._F for F in self._F[i]])
-        flats_other = frozenset([F for i in N._F for F in N._F[i]])
+        flats_self = [F for i in self._F for F in self._F[i]]
+        flats_other = [F for i in N._F for F in N._F[i]]
         SS = SetSystem(list(self._groundset), flats_self)
         OS = SetSystem(list(N._groundset), flats_other)
         return SS._isomorphism(OS) is not None
@@ -304,16 +365,16 @@ cdef class FlatsMatroid(Matroid):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
@@ -354,9 +415,9 @@ cdef class FlatsMatroid(Matroid):
 
         INPUT:
 
-        - ``k`` -- an integer
+        - ``k`` -- integer
 
-        OUTPUT: a :class:`SetSystem`
+        OUTPUT: :class:`SetSystem`
 
         EXAMPLES::
 
@@ -380,7 +441,7 @@ cdef class FlatsMatroid(Matroid):
 
         INPUT:
 
-        - ``k`` -- an integer
+        - ``k`` -- integer
 
         EXAMPLES::
 
@@ -393,6 +454,61 @@ cdef class FlatsMatroid(Matroid):
             for F in self._F[k]:
                 yield F
 
+    def lattice_of_flats(self):
+        """
+        Return the lattice of flats of the matroid.
+
+        EXAMPLES::
+
+            sage: from sage.matroids.flats_matroid import FlatsMatroid
+            sage: M = FlatsMatroid(matroids.catalog.Fano())
+            sage: M.lattice_of_flats()
+            Finite lattice containing 16 elements
+        """
+        if self._L is None:
+            flats = [F for i in range(self._matroid_rank + 1) for F in self._F[i]]
+            self._L = LatticePoset((flats, lambda x, y: x < y))
+        return self._L
+
+    cpdef whitney_numbers(self):
+        r"""
+        Return the Whitney numbers of the first kind of the matroid.
+
+        The Whitney numbers of the first kind -- here encoded as a vector
+        `(w_0=1, \ldots, w_r)` -- are numbers of alternating sign, where `w_i`
+        is the value of the coefficient of the `(r-i)`-th degree term of the
+        matroid's characteristic polynomial. Moreover, `|w_i|` is the number of
+        `(i-1)`-dimensional faces of the broken circuit complex of the matroid.
+
+        OUTPUT: list of integers
+
+        EXAMPLES::
+
+            sage: from sage.matroids.flats_matroid import FlatsMatroid
+            sage: M = FlatsMatroid(matroids.catalog.BetsyRoss())
+            sage: M.whitney_numbers()
+            [1, -11, 35, -25]
+
+        TESTS::
+
+            sage: M = Matroid(flats=[[0], [0, 1]])
+            sage: M.whitney_numbers()
+            []
+        """
+        if self.loops():
+            return []
+        cdef list w = [0] * (self._matroid_rank + 1)
+        if self._L is None:
+            for S in self.no_broken_circuits_sets_iterator():
+                w[len(S)] += 1
+            from sage.rings.integer_ring import ZZ
+            return [ZZ((-1)**i * abs_w) for (i, abs_w) in enumerate(w)]
+        else:
+            mu = self._L.moebius_function_matrix()
+            for (i, F) in enumerate(self._L.list()):
+                w[self._L.rank(F)] += mu[0, i]
+            return w
+
     cpdef whitney_numbers2(self):
         r"""
         Return the Whitney numbers of the second kind of the matroid.
@@ -401,7 +517,7 @@ cdef class FlatsMatroid(Matroid):
         `(W_0, ..., W_r)`, where `W_i` is the number of flats of rank `i`, and
         `r` is the rank of the matroid.
 
-        OUTPUT: a list of integers
+        OUTPUT: list of integers
 
         EXAMPLES::
 
@@ -428,17 +544,18 @@ cdef class FlatsMatroid(Matroid):
         r"""
         Test if ``self`` obeys the matroid axioms.
 
-        For a matroid defined by its flats, we check the flat axioms.
+        For a matroid defined by its flats, we check the flats axioms.
+
+        If the lattice of flats has already been computed, we instead perform
+        the equivalent check of whether it forms a geometric lattice.
 
         OUTPUT: boolean
 
         EXAMPLES::
 
-            sage: M = Matroid(flats={0: [[]], 1: [[0], [1]], 2: [[0, 1]]})
-            sage: M.is_valid()
+            sage: Matroid(flats={0: [[]], 1: [[0], [1]], 2: [[0, 1]]}).is_valid()
             True
-            sage: M = Matroid(flats={0: [''], 1: ['a', 'b'], 2: ['ab']})
-            sage: M.is_valid()
+            sage: Matroid(flats={0: [''], 1: ['a', 'b'], 2: ['ab']}).is_valid()
             True
             sage: M = Matroid(flats={0: [[]], 1: [[0], [1]]})  # missing groundset
             sage: M.is_valid()
@@ -453,10 +570,44 @@ cdef class FlatsMatroid(Matroid):
             sage: M.is_valid()
             True
             sage: from sage.matroids.flats_matroid import FlatsMatroid
-            sage: M = FlatsMatroid(matroids.catalog.NonVamos())
+            sage: FlatsMatroid(matroids.catalog.NonVamos()).is_valid()
+            True
+
+        If we input a list or a lattice of flats, the method checks whether the
+        lattice of flats is geometric::
+
+            sage: Matroid(flats=[[], [0], [1], [0, 1]]).is_valid()
+            True
+            sage: Matroid(flats=['', 'a', 'b', 'ab']).is_valid()
+            True
+            sage: M = Matroid(flats=['',  # missing an extention of flat ['5'] by '6'
+            ....:                    '0','1','2','3','4','5','6','7','8','9','a','b','c',
+            ....:                    '45','46','47','4c','57','5c','67','6c','7c',
+            ....:                    '048','149','24a','34b','059','15a','25b','358',
+            ....:                    '06a','16b','268','369','07b','178','279','37a',
+            ....:                    '0123c','89abc',
+            ....:                    '0123456789abc'])
             sage: M.is_valid()
+            False
+            sage: Matroid(matroids.catalog.Fano().lattice_of_flats()).is_valid()
             True
 
+        Some invalid lists of flats are recognized before calling ``is_valid``,
+        upon the attempted matroid definition::
+
+            sage: M = Matroid(flats=[[], [0], [1]])  # missing groundset
+            Traceback (most recent call last):
+            ...
+            ValueError: not a join-semilattice: no top element
+            sage: Matroid(flats=[[0], [1], [0, 1]])  # missing an intersection
+            Traceback (most recent call last):
+            ...
+            ValueError: not a meet-semilattice: no bottom element
+            sage: Matroid(flats=[[], [0, 1], [2], [0], [1], [0, 1, 2]])
+            Traceback (most recent call last):
+            ...
+            ValueError: the poset is not ranked
+
         TESTS::
 
             sage: Matroid(flats={0: [], 1: [[0], [1]], 2: [[0, 1]]}).is_valid()  # missing an intersection
@@ -478,9 +629,26 @@ cdef class FlatsMatroid(Matroid):
             ....:                    3: ['0123456789abc']})
             sage: M.is_valid()
             False
+            sage: M = Matroid(flats=[[], [0], [1], [0], [0, 1]])  # duplicates are ignored
+            sage: M.lattice_of_flats()
+            Finite lattice containing 4 elements
+            sage: M.is_valid()
+            True
+            sage: M = Matroid(flats=['',
+            ....:                    '0','1','2','3','4','5','6','7','8','9','a','b','c',
+            ....:                    '45','46','47','4c','56','57','5c','67','6c','7c',
+            ....:                    '048','149','24a','34b','059','15a','25b','358',
+            ....:                    '06a','16b','268','369','07b','178','279','37a',
+            ....:                    '0123c','89abc',
+            ....:                    '0123456789abc'])
+            sage: M.is_valid()
+            True
         """
+        if self._L is not None:  # if the lattice of flats is available
+            return self._is_closed(self._groundset) and self._L.is_geometric()
+
         cdef int i, j, k
-        cdef frozenset F1, F2, F3, I12
+        cdef frozenset F1, F2, I12
         cdef list ranks, cover, flats_lst
         cdef bint flag
 
@@ -493,13 +661,7 @@ cdef class FlatsMatroid(Matroid):
             return False
 
         # the groundset must be a flat
-        flag = False
-        for i in self._F:
-            for F1 in self._F[i]:
-                if F1 == self._groundset:
-                    flag = True
-                    break
-        if not flag:
+        if not self._is_closed(self._groundset):
             return False
 
         # a single element extension of a flat must be a subset of exactly one flat
@@ -521,10 +683,9 @@ cdef class FlatsMatroid(Matroid):
                         I12 = F1 & F2
                         for k in self._F:
                             if k <= i:
-                                for F3 in self._F[k]:
-                                    if F3 == I12:
-                                        flag = True
-                                        break
+                                if I12 in self._F[k]:
+                                    flag = True
+                                    break
                                 if flag:
                                     break
                         if not flag:
diff --git a/src/sage/matroids/graphic_matroid.pyx b/src/sage/matroids/graphic_matroid.pyx
index 295034259a4..ee54feeb355 100644
--- a/src/sage/matroids/graphic_matroid.pyx
+++ b/src/sage/matroids/graphic_matroid.pyx
@@ -607,7 +607,7 @@ cdef class GraphicMatroid(Matroid):
                 # take contractions and deletions with what we have so far
                 # then use method from abstract matroid class
                 conset, delset = sanitize_contractions_deletions(self, contractions, deletions)
-                M = self.minor(contractions=conset, deletions=delset)
+                M = self._minor(contractions=conset, deletions=delset)
                 should_be_true, elements = Matroid._has_minor(M, N, certificate=True)
 
                 # elements is a tuple (contractions, deletions, dict)
@@ -1982,16 +1982,16 @@ cdef class GraphicMatroid(Matroid):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
index 0027d85073f..9efceb81b75 100644
--- a/src/sage/matroids/linear_matroid.pyx
+++ b/src/sage/matroids/linear_matroid.pyx
@@ -2977,16 +2977,16 @@ cdef class LinearMatroid(BasisExchangeMatroid):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
@@ -4029,16 +4029,16 @@ cdef class BinaryMatroid(LinearMatroid):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
@@ -4911,16 +4911,16 @@ cdef class TernaryMatroid(LinearMatroid):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
@@ -5623,16 +5623,16 @@ cdef class QuaternaryMatroid(LinearMatroid):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
@@ -6552,16 +6552,16 @@ cdef class RegularMatroid(LinearMatroid):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx
index 331470622de..7d6eec638b7 100644
--- a/src/sage/matroids/matroid.pyx
+++ b/src/sage/matroids/matroid.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 The abstract Matroid class
 
@@ -1149,7 +1148,7 @@ cdef class Matroid(SageObject):
             - ``deletions`` is coindependent
             - ``contractions`` and ``deletions`` are disjoint.
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
@@ -1260,7 +1259,7 @@ cdef class Matroid(SageObject):
         - ``hyperplanes`` -- the set of hyperplanes of a linear subclass of
           ``self``.
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
@@ -2663,7 +2662,7 @@ cdef class Matroid(SageObject):
 
             sage: M = matroids.catalog.Vamos()
             sage: M.dependent_r_sets(3)
-            []
+            SetSystem of 0 sets over 8 elements
             sage: sorted([sorted(X) for X in
             ....: matroids.catalog.Vamos().dependent_r_sets(4)])
             [['a', 'b', 'c', 'd'], ['a', 'b', 'e', 'f'], ['a', 'b', 'g', 'h'],
@@ -2673,12 +2672,13 @@ cdef class Matroid(SageObject):
 
         Test all subsets of the groundset of cardinality ``r``
         """
-        res = []
-        for X in combinations(self.groundset(), r):
-            X = frozenset(X)
-            if self._rank(X) < len(X):
-                res.append(X)
-        return res
+        cdef set D = set()
+        cdef frozenset X
+        for XX in combinations(self.groundset(), r):
+            X = frozenset(XX)
+            if not self._is_independent(X):
+                D.add(X)
+        return SetSystem(list(self.groundset()), D)
 
     def dependent_r_sets_iterator(self, long r):
         r"""
@@ -2853,10 +2853,9 @@ cdef class Matroid(SageObject):
 
             sage: M = matroids.catalog.Pappus()
             sage: M.independent_r_sets(4)
-            []
-            sage: S = M.independent_r_sets(3)
-            sage: len(S)
-            75
+            SetSystem of 0 sets over 9 elements
+            sage: S = M.independent_r_sets(3); S
+            SetSystem of 75 sets over 9 elements
             sage: frozenset({'a', 'c', 'e'}) in S
             True
 
@@ -2865,12 +2864,13 @@ cdef class Matroid(SageObject):
             :meth:`M.independent_sets() `
             :meth:`M.bases() `
         """
-        cdef list res = []
-        for X in combinations(self.groundset(), r):
-            X = frozenset(X)
-            if self._rank(X) == len(X):
-                res.append(X)
-        return res
+        cdef set I = set()
+        cdef frozenset X
+        for XX in combinations(self.groundset(), r):
+            X = frozenset(XX)
+            if self._is_independent(X):
+                I.add(X)
+        return SetSystem(list(self.groundset()), I)
 
     def independent_r_sets_iterator(self, r):
         r"""
@@ -3269,7 +3269,7 @@ cdef class Matroid(SageObject):
                 if is_indep:
                     B.append(frozenset(H))
                     next_level.extend(Ht)
-        return B
+        return SetSystem(list(self.groundset()), B)
 
     def no_broken_circuits_sets_iterator(self, ordering=None):
         r"""
@@ -4006,7 +4006,7 @@ cdef class Matroid(SageObject):
         - ``deletions`` -- (default: ``None``) an element or set of elements
           to be deleted
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         .. NOTE::
 
@@ -4294,7 +4294,7 @@ cdef class Matroid(SageObject):
         can be obtained by adding an element freely to the span of the matroid
         and then contracting that element.
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         .. SEEALSO::
 
@@ -4493,7 +4493,7 @@ cdef class Matroid(SageObject):
           each of these. If not specified, the element is assumed to be in the
           span of the full groundset.
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         .. NOTE::
 
@@ -4570,7 +4570,7 @@ cdef class Matroid(SageObject):
           of each of these. If not specified, the element is assumed to be in
           the cospan of the full groundset.
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         .. SEEALSO::
 
@@ -4899,7 +4899,7 @@ cdef class Matroid(SageObject):
         parallel class (a closed set of rank 1, that is, each pair in it forms
         a circuit of length 2).
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         .. SEEALSO::
 
@@ -4935,7 +4935,7 @@ cdef class Matroid(SageObject):
         element from each series class (a coclosed set of rank 1, that is,
         each pair in it forms a cocircuit of length 2).
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         .. SEEALSO::
 
@@ -8292,6 +8292,15 @@ cdef class Matroid(SageObject):
             Simplicial complex with vertex set (1, 2, 3, 4, 5)
              and facets {(1, 3, 5), (1, 4, 5), (2, 3, 5), (2, 4, 5)}
 
+        For a matroid with loops, the broken circuit complex is not defined,
+        and the method yields an error::
+
+            sage: M = Matroid(flats={0: ['a'], 1: ['ab', 'ac'], 2: ['abc']})
+            sage: M.broken_circuit_complex()
+            Traceback (most recent call last):
+            ...
+            ValueError: broken circuit complex of matroid with loops is not defined
+
         TESTS::
 
             sage: for M in matroids.AllMatroids(5):  # optional - matroid_database
@@ -8305,6 +8314,10 @@ cdef class Matroid(SageObject):
         from sage.topology.simplicial_complex import SimplicialComplex
         cdef int r = self.rank()
         cdef list facets = []
+        if self.loops():
+            raise ValueError("broken circuit complex of matroid with loops is not defined")
+        if ordering is None:
+            ordering = sorted(self.groundset(), key=cmp_elements_key)
         for S in self.no_broken_circuits_sets_iterator(ordering):
             if len(S) == r:
                 facets.append(S)
@@ -8555,9 +8568,9 @@ cdef class Matroid(SageObject):
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``; if ``mapping[e]`` is not defined then the identity
-          map is assumed
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`; if ``mapping[e]`` is not defined then the identity map
+          is assumed
 
         EXAMPLES::
 
@@ -8586,16 +8599,16 @@ cdef class Matroid(SageObject):
         r"""
         Return an isomorphic matroid with relabeled groundset.
 
-        The output is obtained by relabeling each element ``e`` by
+        The output is obtained by relabeling each element `e` by
         ``mapping[e]``, where ``mapping`` is a given injective map. If
         ``mapping[e]`` is not defined, then the identity map is assumed.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
-        OUTPUT: a matroid
+        OUTPUT: matroid
 
         EXAMPLES::
 
diff --git a/src/sage/matroids/set_system.pyx b/src/sage/matroids/set_system.pyx
index 1fc0ed4546a..97b816eb848 100644
--- a/src/sage/matroids/set_system.pyx
+++ b/src/sage/matroids/set_system.pyx
@@ -209,13 +209,13 @@ cdef class SetSystem:
 
     cdef _relabel(self, mapping):
         """
-        Relabel each element ``e`` of the ground set as ``mapping[e]``, where
+        Relabel each element `e` of the ground set as ``mapping[e]``, where
         ``mapping`` is a given injective map.
 
         INPUT:
 
-        - ``mapping`` -- a python object such that ``mapping[e]`` is the new
-          label of ``e``
+        - ``mapping`` -- a Python object such that ``mapping[e]`` is the new
+          label of `e`
 
         OUTPUT: ``None``
         """
diff --git a/src/sage/matroids/utilities.py b/src/sage/matroids/utilities.py
index d5e680fc6b9..0ab95bb02ec 100644
--- a/src/sage/matroids/utilities.py
+++ b/src/sage/matroids/utilities.py
@@ -493,7 +493,7 @@ def lift_cross_ratios(A, lift_map=None):
     INPUT:
 
     - ``A`` -- a matrix over a ring ``source_ring``.
-    - ``lift_map`` -- a python dictionary, mapping each cross ratio of ``A`` to some element
+    - ``lift_map`` -- a Python dictionary, mapping each cross ratio of ``A`` to some element
       of a target ring, and such that ``lift_map[source_ring(1)] = target_ring(1)``.
 
     OUTPUT:
diff --git a/src/sage/misc/callable_dict.pyx b/src/sage/misc/callable_dict.pyx
index b1f93240a6a..f46998a35a4 100644
--- a/src/sage/misc/callable_dict.pyx
+++ b/src/sage/misc/callable_dict.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Callable dictionaries
 """
diff --git a/src/sage/misc/lazy_string.pyx b/src/sage/misc/lazy_string.pyx
index a0efbb186bf..0d313efed0a 100644
--- a/src/sage/misc/lazy_string.pyx
+++ b/src/sage/misc/lazy_string.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Lazy strings
 
diff --git a/src/sage/misc/package_dir.py b/src/sage/misc/package_dir.py
index 71ec08b3ae0..50cb0fc5514 100644
--- a/src/sage/misc/package_dir.py
+++ b/src/sage/misc/package_dir.py
@@ -273,14 +273,14 @@ def is_package_or_sage_namespace_package_dir(path, *, distribution_filter=None):
 
         sage: directory = os.path.join(sage.libs.__path__[0], 'mpfr'); directory
         '.../sage/libs/mpfr'
-        sage: is_package_or_sage_namespace_package_dir(directory)
+        sage: is_package_or_sage_namespace_package_dir(directory)       # known bug (seen in build.yml)
         True
 
     :mod:`sage` is designated to become an implicit namespace package::
 
         sage: directory = sage.__path__[0]; directory
         '.../sage'
-        sage: is_package_or_sage_namespace_package_dir(directory)
+        sage: is_package_or_sage_namespace_package_dir(directory)       # known bug (seen in build.yml)
         True
 
     Not a package::
diff --git a/src/sage/misc/parser.pyx b/src/sage/misc/parser.pyx
index a028e953f90..cbc3c67b6d6 100644
--- a/src/sage/misc/parser.pyx
+++ b/src/sage/misc/parser.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 A parser for symbolic equations and expressions
 
diff --git a/src/sage/misc/remote_file.py b/src/sage/misc/remote_file.py
index 6afee87da11..d6ffd09c5ea 100644
--- a/src/sage/misc/remote_file.py
+++ b/src/sage/misc/remote_file.py
@@ -1,12 +1,11 @@
 "get_remote_file"
-
-
 import os
+from pathlib import Path
 from urllib.request import Request, urlopen
 from ssl import create_default_context as default_context
 
 
-def get_remote_file(filename, verbose=True):
+def get_remote_file(filename, verbose=True) -> Path:
     """
     INPUT:
 
@@ -17,8 +16,8 @@ def get_remote_file(filename, verbose=True):
 
     OUTPUT:
 
-    creates a file in the temp directory and returns the absolute path
-    to that file.
+    This creates a file in the temp directory and returns the absolute path
+    to that file as a :class:`Path` object.
 
     EXAMPLES::
 
@@ -34,7 +33,8 @@ def get_remote_file(filename, verbose=True):
         print("Attempting to load remote file: " + filename)
 
     from sage.misc.temporary_file import tmp_filename
-    temp_name = tmp_filename() + '.' + os.path.splitext(filename)[1][1:]
+    ext = os.path.splitext(filename)[1]
+    temp_name = Path(tmp_filename(ext=ext))
     # IMPORTANT -- urllib takes a long time to load,
     # so do not import it in the module scope.
 
@@ -44,7 +44,7 @@ def get_remote_file(filename, verbose=True):
         print("Loading started")
 
     content = urlopen(req, timeout=1, context=default_context())
-    with open(temp_name, 'wb') as f:
+    with temp_name.open('wb') as f:
         f.write(content.read())
 
     if verbose:
diff --git a/src/sage/misc/reset.pyx b/src/sage/misc/reset.pyx
index 1d979197d3d..e8247bb8f89 100644
--- a/src/sage/misc/reset.pyx
+++ b/src/sage/misc/reset.pyx
@@ -2,7 +2,6 @@
 """
 Interpreter reset
 """
-
 import sys
 
 # Exclude these from the reset command.
@@ -28,7 +27,7 @@ def reset(vars=None, attached=False):
     - ``vars`` -- a list, or space or comma separated string (default:
       ``None``), variables to restore
 
-    - ``attached`` -- boolean (default: ``False``), if ``vars`` is not None,
+    - ``attached`` -- boolean (default: ``False``), if ``vars`` is not ``None``,
       whether to detach all attached files
 
     EXAMPLES::
@@ -38,24 +37,26 @@ def reset(vars=None, attached=False):
         sage: x                                                                         # needs sage.symbolic
         x
 
-        sage: fn = tmp_filename(ext='foo.py')
+        sage: fn = tmp_filename(ext='.py')
         sage: sage.misc.reset.EXCLUDE.add('fn')
         sage: with open(fn, 'w') as f:
         ....:     _ = f.write('a = 111')
         sage: attach(fn)
-        sage: [fn] == attached_files()
+        sage: af = attached_files(); len(af)
+        1
+        sage: af == [fn]
         True
         sage: reset()
-        sage: [fn] == attached_files()
-        True
+        sage: af = attached_files(); len(af)
+        1
         sage: reset(attached=True)
-        sage: [fn] == attached_files()
-        False
+        sage: af = attached_files(); len(af)
+        0
         sage: sage.misc.reset.EXCLUDE.remove('fn')
 
     TESTS:
 
-    Confirm that assumptions don't survive a reset (:issue:`10855`)::
+    Confirm that assumptions do not survive a reset (:issue:`10855`)::
 
         sage: # needs sage.symbolic
         sage: assume(x > 3)
@@ -68,7 +69,6 @@ def reset(vars=None, attached=False):
         []
         sage: bool(x > 3)
         False
-
     """
     from sage.symbolic.assumptions import forget
     if vars is not None:
diff --git a/src/sage/modular/abvar/abvar.py b/src/sage/modular/abvar/abvar.py
index 8e0906e45a8..7b5a067af1f 100644
--- a/src/sage/modular/abvar/abvar.py
+++ b/src/sage/modular/abvar/abvar.py
@@ -51,7 +51,7 @@
 from sage.modular.modsym.modsym import ModularSymbols
 from sage.modular.modsym.space import ModularSymbolsSpace
 from sage.modular.quatalg.brandt import BrandtModule
-from sage.modules.free_module import is_FreeModule
+from sage.modules.free_module import FreeModule_generic
 from sage.modules.free_module_element import vector
 from sage.rings.fast_arith import prime_range
 from sage.rings.infinity import infinity
@@ -4009,7 +4009,7 @@ def __init__(self, groups, lattice=None, base_field=QQ, is_simple=None, newform_
             lattice = ZZ**(2 * self._ambient_dimension())
         if check:
             n = self._ambient_dimension()
-            if not is_FreeModule(lattice):
+            if not isinstance(lattice, FreeModule_generic):
                 raise TypeError("lattice must be a free module")
             if lattice.base_ring() != ZZ:
                 raise TypeError("lattice must be over ZZ")
diff --git a/src/sage/modular/abvar/all.py b/src/sage/modular/abvar/all.py
index f0971bc0b42..6ba2c77225d 100644
--- a/src/sage/modular/abvar/all.py
+++ b/src/sage/modular/abvar/all.py
@@ -1,7 +1,7 @@
 ###########################################################################
 #       Copyright (C) 2007 William Stein                #
 #  Distributed under the terms of the GNU General Public License (GPL)    #
-#                  http://www.gnu.org/licenses/                           #
+#                  https://www.gnu.org/licenses/                           #
 ###########################################################################
 
-from .constructor import J0, J1, JH, AbelianVariety
+from sage.modular.abvar.constructor import J0, J1, JH, AbelianVariety
diff --git a/src/sage/modular/abvar/finite_subgroup.py b/src/sage/modular/abvar/finite_subgroup.py
index 2725e11a387..00aa5afa414 100644
--- a/src/sage/modular/abvar/finite_subgroup.py
+++ b/src/sage/modular/abvar/finite_subgroup.py
@@ -103,7 +103,7 @@
 from sage.misc.lazy_import import lazy_import
 from sage.modular.abvar.torsion_point import TorsionPoint
 from sage.modules.module import Module
-from sage.modules.free_module import is_FreeModule
+from sage.modules.free_module import FreeModule_generic
 from sage.structure.gens_py import abelian_iterator
 from sage.structure.sequence import Sequence
 from sage.structure.richcmp import richcmp_method, richcmp
@@ -871,7 +871,7 @@ def __init__(self, abvar, lattice, field_of_definition=None, check=True):
             from sage.rings.qqbar import QQbar as field_of_definition
         if check:
             from .abvar import is_ModularAbelianVariety
-            if not is_FreeModule(lattice) or lattice.base_ring() != ZZ:
+            if not isinstance(lattice, FreeModule_generic) or lattice.base_ring() != ZZ:
                 raise TypeError("lattice must be a free module over ZZ")
             if not is_ModularAbelianVariety(abvar):
                 raise TypeError("abvar must be a modular abelian variety")
diff --git a/src/sage/modular/all.py b/src/sage/modular/all.py
index cfccb18e65f..73048018c69 100644
--- a/src/sage/modular/all.py
+++ b/src/sage/modular/all.py
@@ -1,24 +1,24 @@
 from sage.misc.lazy_import import lazy_import
 
-from .quatalg.all import *
+from sage.modular.quatalg.all import *
 
-from .modsym.all import *
+from sage.modular.modsym.all import *
 
-from .modform.all import *
+from sage.modular.modform.all import *
 
-from .ssmod.all import *
+from sage.modular.ssmod.all import *
 
-from .abvar.all import *
+from sage.modular.abvar.all import *
 
-from .dirichlet import (DirichletGroup,
-                        kronecker_character, kronecker_character_upside_down,
-                        trivial_character)
+from sage.modular.dirichlet import (DirichletGroup,
+                                    kronecker_character, kronecker_character_upside_down,
+                                    trivial_character)
 
-from .arithgroup.all import (Gamma0, Gamma1, GammaH, Gamma, SL2Z,
-                             ArithmeticSubgroup_Permutation,
-                             CongruenceSubgroup, FareySymbol)
+from sage.modular.arithgroup.all import (Gamma0, Gamma1, GammaH, Gamma, SL2Z,
+                                         ArithmeticSubgroup_Permutation,
+                                         CongruenceSubgroup, FareySymbol)
 
-from .cusps import Cusp, Cusps
+from sage.modular.cusps import Cusp, Cusps
 
 lazy_import('sage.modular.dims', ('dimension_cusp_forms',
                                   'dimension_new_cusp_forms',
@@ -27,19 +27,20 @@
                                   'sturm_bound'),
             deprecation=(32647, 'removed from main namespace'))
 
-from .etaproducts import (EtaGroup, EtaProduct, EtaGroupElement,
-                          AllCusps, CuspFamily)
+from sage.modular.etaproducts import (EtaGroup, EtaProduct, EtaGroupElement,
+                                      AllCusps, CuspFamily)
 
 lazy_import('sage.modular.multiple_zeta', ['Multizeta', 'Multizetas'])
 
-from .overconvergent.all import *
+from sage.modular.overconvergent.all import *
 
-from .local_comp.all import *
+from sage.modular.local_comp.all import *
 
-from .cusps_nf import NFCusp, NFCusps, Gamma0_NFCusps
+from sage.modular.cusps_nf import NFCusp, NFCusps, Gamma0_NFCusps
 
-from .btquotients.all import *
+from sage.modular.btquotients.all import *
 
-from .pollack_stevens.all import *
+from sage.modular.pollack_stevens.all import *
 
-from .quasimodform.all import *
+from sage.modular.quasimodform.all import *
+del lazy_import
diff --git a/src/sage/modular/arithgroup/all.py b/src/sage/modular/arithgroup/all.py
index d4fb241d1f9..2915566b73c 100644
--- a/src/sage/modular/arithgroup/all.py
+++ b/src/sage/modular/arithgroup/all.py
@@ -1,18 +1,19 @@
 # Note: the is_xxx functions are imported to here, but not from here up to sage.modular.all, so
 # they are invisible to the user but easy to import all in one go by other code that needs them.
 
-from .arithgroup_generic import is_ArithmeticSubgroup
-from .congroup_generic import is_CongruenceSubgroup, CongruenceSubgroup_constructor as CongruenceSubgroup
-from .congroup_gammaH import GammaH_constructor as GammaH, is_GammaH
-from .congroup_gamma1 import Gamma1_constructor as Gamma1, is_Gamma1
-from .congroup_gamma0 import Gamma0_constructor as Gamma0, is_Gamma0
-from .congroup_gamma import Gamma_constructor as Gamma, is_Gamma
-from .congroup_sl2z import SL2Z, is_SL2Z
+from sage.modular.arithgroup.arithgroup_generic import is_ArithmeticSubgroup
+from sage.modular.arithgroup.congroup_generic import is_CongruenceSubgroup, CongruenceSubgroup_constructor as CongruenceSubgroup
+from sage.modular.arithgroup.congroup_gammaH import GammaH_constructor as GammaH, is_GammaH
+from sage.modular.arithgroup.congroup_gamma1 import Gamma1_constructor as Gamma1, is_Gamma1
+from sage.modular.arithgroup.congroup_gamma0 import Gamma0_constructor as Gamma0, is_Gamma0
+from sage.modular.arithgroup.congroup_gamma import Gamma_constructor as Gamma, is_Gamma
+from sage.modular.arithgroup.congroup_sl2z import SL2Z, is_SL2Z
 
 from sage.misc.lazy_import import lazy_import
 lazy_import('sage.modular.arithgroup.arithgroup_perm', 'ArithmeticSubgroup_Permutation')
 
-from .congroup import (degeneracy_coset_representatives_gamma0,
-                            degeneracy_coset_representatives_gamma1)
+from sage.modular.arithgroup.congroup import (degeneracy_coset_representatives_gamma0,
+                                              degeneracy_coset_representatives_gamma1)
 
-from .farey_symbol import Farey as FareySymbol
+from sage.modular.arithgroup.farey_symbol import Farey as FareySymbol
+del lazy_import
diff --git a/src/sage/modular/btquotients/all.py b/src/sage/modular/btquotients/all.py
index 3807442da70..1e96b2db99b 100644
--- a/src/sage/modular/btquotients/all.py
+++ b/src/sage/modular/btquotients/all.py
@@ -1,3 +1,3 @@
-from .btquotient import BruhatTitsQuotient
-#from pautomorphicform import pAdicAutomorphicForms
-#from pautomorphicform import BruhatTitsHarmonicCocycles
+from sage.modular.btquotients.btquotient import BruhatTitsQuotient
+# from pautomorphicform import pAdicAutomorphicForms
+# from pautomorphicform import BruhatTitsHarmonicCocycles
diff --git a/src/sage/modular/hecke/algebra.py b/src/sage/modular/hecke/algebra.py
index 7253cf6c960..ab1321b077c 100644
--- a/src/sage/modular/hecke/algebra.py
+++ b/src/sage/modular/hecke/algebra.py
@@ -52,10 +52,16 @@ def is_HeckeAlgebra(x) -> bool:
 
         sage: from sage.modular.hecke.algebra import is_HeckeAlgebra
         sage: is_HeckeAlgebra(CuspForms(1, 12).anemic_hecke_algebra())
+        doctest:warning...
+        DeprecationWarning: the function is_HeckeAlgebra is deprecated;
+        use 'isinstance(..., HeckeAlgebra_base)' instead
+        See https://github.com/sagemath/sage/issues/37895 for details.
         True
         sage: is_HeckeAlgebra(ZZ)
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37895, "the function is_HeckeAlgebra is deprecated; use 'isinstance(..., HeckeAlgebra_base)' instead")
     return isinstance(x, HeckeAlgebra_base)
 
 
@@ -177,8 +183,8 @@ def __init__(self, M) -> None:
         """
         if isinstance(M, tuple):
             M = M[0]
-        from . import module
-        if not module.is_HeckeModule(M):
+        from .module import HeckeModule_generic
+        if not isinstance(M, HeckeModule_generic):
             msg = f"M (={M}) must be a HeckeModule"
             raise TypeError(msg)
         self.__M = M
@@ -246,7 +252,7 @@ def _element_constructor_(self, x, check=True):
             TypeError: Don't know how to construct an element of Anemic Hecke algebra acting on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field from Hecke operator T_11 on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field
 
         """
-        from .hecke_operator import HeckeAlgebraElement_matrix, HeckeOperator, is_HeckeOperator, is_HeckeAlgebraElement
+        from .hecke_operator import HeckeAlgebraElement_matrix, HeckeOperator, HeckeAlgebraElement
 
         if not isinstance(x, Element):
             x = self.base_ring()(x)
@@ -259,13 +265,13 @@ def _element_constructor_(self, x, check=True):
         if parent is self:
             return x
 
-        if is_HeckeOperator(x):
+        if isinstance(x, HeckeOperator):
             if x.parent() == self \
                     or (not self.is_anemic() and x.parent() == self.anemic_subalgebra()) \
                     or (self.is_anemic() and x.parent().anemic_subalgebra() == self and gcd(x.index(), self.level()) == 1):
                 return HeckeOperator(self, x.index())
 
-        if is_HeckeAlgebraElement(x):
+        if isinstance(x, HeckeAlgebraElement):
             if x.parent() == self or (not self.is_anemic() and x.parent() == self.anemic_subalgebra()):
                 if x.parent().module().basis_matrix() == self.module().basis_matrix():
                     return HeckeAlgebraElement_matrix(self, x.matrix())
diff --git a/src/sage/modular/hecke/all.py b/src/sage/modular/hecke/all.py
index 0aaa2232773..3c9230a2520 100644
--- a/src/sage/modular/hecke/all.py
+++ b/src/sage/modular/hecke/all.py
@@ -1,19 +1,19 @@
-from .homspace import HeckeModuleHomspace, is_HeckeModuleHomspace
+from sage.modular.hecke.homspace import HeckeModuleHomspace, is_HeckeModuleHomspace
 
-from .module import HeckeModule_free_module, HeckeModule_generic, is_HeckeModule
+from sage.modular.hecke.module import HeckeModule_free_module, HeckeModule_generic, is_HeckeModule
 
-from .hecke_operator import HeckeOperator, is_HeckeOperator
+from sage.modular.hecke.hecke_operator import HeckeOperator, is_HeckeOperator
 
-from .degenmap import DegeneracyMap
+from sage.modular.hecke.degenmap import DegeneracyMap
 
-from .algebra import HeckeAlgebra, is_HeckeAlgebra
+from sage.modular.hecke.algebra import HeckeAlgebra, is_HeckeAlgebra
 
-from .morphism import (HeckeModuleMorphism, HeckeModuleMorphism_matrix,
-                       is_HeckeModuleMorphism,
-                       is_HeckeModuleMorphism_matrix)
+from sage.modular.hecke.morphism import (HeckeModuleMorphism, HeckeModuleMorphism_matrix,
+                                         is_HeckeModuleMorphism,
+                                         is_HeckeModuleMorphism_matrix)
 
-from .element import HeckeModuleElement, is_HeckeModuleElement
+from sage.modular.hecke.element import HeckeModuleElement, is_HeckeModuleElement
 
-from .submodule import HeckeSubmodule, is_HeckeSubmodule
+from sage.modular.hecke.submodule import HeckeSubmodule, is_HeckeSubmodule
 
-from .ambient_module import AmbientHeckeModule, is_AmbientHeckeModule
+from sage.modular.hecke.ambient_module import AmbientHeckeModule, is_AmbientHeckeModule
diff --git a/src/sage/modular/hecke/ambient_module.py b/src/sage/modular/hecke/ambient_module.py
index 7805cd2d364..6c2e46a2b16 100644
--- a/src/sage/modular/hecke/ambient_module.py
+++ b/src/sage/modular/hecke/ambient_module.py
@@ -22,7 +22,7 @@
 from . import module
 from . import submodule
 
-from sage.modules.free_module import FreeModule, is_FreeModule
+from sage.modules.free_module import FreeModule, FreeModule_generic
 from sage.rings.integer import Integer
 
 import sage.arith.all as arith
@@ -41,6 +41,10 @@ def is_AmbientHeckeModule(x) -> bool:
 
         sage: from sage.modular.hecke.ambient_module import is_AmbientHeckeModule
         sage: is_AmbientHeckeModule(ModularSymbols(6))
+        doctest:warning...
+        DeprecationWarning: the function is_AmbientHeckeModule is deprecated;
+        use 'isinstance(..., AmbientHeckeModule)' instead
+        See https://github.com/sagemath/sage/issues/37895 for details.
         True
         sage: is_AmbientHeckeModule(ModularSymbols(6).cuspidal_subspace())
         False
@@ -49,6 +53,8 @@ def is_AmbientHeckeModule(x) -> bool:
         sage: is_AmbientHeckeModule(BrandtModule(2, 3))
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37895, "the function is_AmbientHeckeModule is deprecated; use 'isinstance(..., AmbientHeckeModule)' instead")
     return isinstance(x, AmbientHeckeModule)
 
 
@@ -280,11 +286,11 @@ def degeneracy_map(self, codomain, t=1):
 
         INPUT:
 
-        -  ``codomain`` - a Hecke module, which should be of the same type as
+        -  ``codomain`` -- a Hecke module, which should be of the same type as
            self, or a positive integer (in which case Sage will use
            :meth:`~hecke_module_of_level` to find the "natural" module of the
            corresponding level).
-        -  ``t`` - int, the parameter of the degeneracy map, i.e., the map is
+        -  ``t`` -- int, the parameter of the degeneracy map, i.e., the map is
            related to `f(q)` - `f(q^t)`.
 
         OUTPUT: A morphism from ``self`` to ``codomain``.
@@ -293,15 +299,16 @@ def degeneracy_map(self, codomain, t=1):
 
             sage: M = ModularSymbols(11,sign=1)
             sage: d1 = M.degeneracy_map(33); d1
-            Hecke module morphism degeneracy map corresponding to f(q) |--> f(q) defined by the matrix
+            Hecke module morphism degeneracy map corresponding to f(q) |--> f(q)
+            defined by the matrix
             [ 1  0  0  0 -2 -1]
             [ 0 -1  1  0  0  0]
-            Domain: Modular Symbols space of dimension 2 for Gamma_0(11) of weight ...
+            Domain:   Modular Symbols space of dimension 2 for Gamma_0(11) of weight ...
             Codomain: Modular Symbols space of dimension 6 for Gamma_0(33) of weight ...
-            sage: M.degeneracy_map(33,3).matrix()
+            sage: M.degeneracy_map(33, 3).matrix()
             [ 3  2  0  2 -2  1]
             [ 0  0 -1  1  0  0]
-            sage: M = ModularSymbols(33,sign=1)
+            sage: M = ModularSymbols(33, sign=1)
             sage: d2 = M.degeneracy_map(11); d2.matrix()
             [ 1  0]
             [ 0 -2]
@@ -315,9 +322,10 @@ def degeneracy_map(self, codomain, t=1):
 
         ::
 
-            sage: M = ModularSymbols(3,12,sign=1)
+            sage: M = ModularSymbols(3, 12, sign=1)
             sage: M.degeneracy_map(1)
-            Hecke module morphism degeneracy map corresponding to f(q) |--> f(q) defined by the matrix
+            Hecke module morphism degeneracy map corresponding to f(q) |--> f(q)
+            defined by the matrix
             [1 0]
             [0 0]
             [0 1]
@@ -342,8 +350,12 @@ def degeneracy_map(self, codomain, t=1):
             sage: D = ModularSymbols(10,4).cuspidal_submodule().decomposition()
             sage: D
             [
-            Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 10 for Gamma_0(10) of weight 4 with sign 0 over Rational Field,
-            Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 10 for Gamma_0(10) of weight 4 with sign 0 over Rational Field
+             Modular Symbols subspace of dimension 2 of
+              Modular Symbols space of dimension 10 for
+               Gamma_0(10) of weight 4 with sign 0 over Rational Field,
+             Modular Symbols subspace of dimension 4 of
+              Modular Symbols space of dimension 10 for
+               Gamma_0(10) of weight 4 with sign 0 over Rational Field
             ]
             sage: D[1].degeneracy_map(5)
             Hecke module morphism defined by the matrix
@@ -351,13 +363,15 @@ def degeneracy_map(self, codomain, t=1):
             [   0  1/2  3/2   -2]
             [   0   -1    1    0]
             [   0 -3/4 -1/4    1]
-            Domain: Modular Symbols subspace of dimension 4 of Modular Symbols space ...
+            Domain:   Modular Symbols subspace of dimension 4 of Modular Symbols space ...
             Codomain: Modular Symbols space of dimension 4 for Gamma_0(5) of weight ...
 
         We check for a subtle caching bug that came up in work on :issue:`10453`::
 
             sage: loads(dumps(J0(33).decomposition()[0].modular_symbols()))
-            Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 9 for Gamma_0(33) of weight 2 with sign 0 over Rational Field
+            Modular Symbols subspace of dimension 2 of
+             Modular Symbols space of dimension 9 for
+              Gamma_0(33) of weight 2 with sign 0 over Rational Field
 
         We check that certain absurd inputs are correctly caught::
 
@@ -367,7 +381,7 @@ def degeneracy_map(self, codomain, t=1):
             ...
             ValueError: the characters of the domain and codomain must match
         """
-        if is_AmbientHeckeModule(codomain):
+        if isinstance(codomain, AmbientHeckeModule):
             M = codomain
             level = int(M.level())
         else:
@@ -430,9 +444,9 @@ def degeneracy_map(self, codomain, t=1):
 
     def dual_free_module(self):
         r"""
-        The free module dual to self, as a submodule of the dual
+        The free module dual to ``self``, as a submodule of the dual
         module of the ambient space. As this space is ambient anyway,
-        this just returns self.free_module().
+        this just returns ``self.free_module()``.
 
         EXAMPLES::
 
@@ -450,19 +464,17 @@ def fcp(self, n, var='x'):
 
         INPUT:
 
+        -  ``self`` -- Hecke module invariant under the Hecke operator of index
+           `n`.
 
-        -  ``self`` - Hecke module invariant under the Hecke operator of index
-           n.
-
-        -  ``int n`` - a positive integer.
-
-        -  ``var`` - variable of polynomial (default `x`)
+        -  ``n`` -- a positive integer.
 
+        -  ``var`` -- variable of polynomial (default ``'x'``)
 
         OUTPUT:
 
-        -  ``list`` - list of the pairs (g,e), where g is an
-           irreducible factor of the characteristic polynomial of T_n, and e
+        -  ``list`` -- list of the pairs `(g,e)`, where `g` is an
+           irreducible factor of the characteristic polynomial of `T_n`, and `e`
            is its multiplicity.
 
         EXAMPLES::
@@ -497,13 +509,13 @@ def free_module(self):
 
     def hecke_bound(self):
         r"""
-        Return an integer B such that the Hecke operators `T_n`, for `n\leq B`,
+        Return an integer `B` such that the Hecke operators `T_n`, for `n\leq B`,
         generate the full Hecke algebra as a module over the base ring. Note
         that we include the `n` with `n` not coprime to the level.
 
         At present this returns an unproven guess for non-cuspidal spaces which
-        appears to be valid for `M_k(\Gamma_0(N))`, where k and N are the
-        weight and level of self. (It is clearly valid for *cuspidal* spaces
+        appears to be valid for `M_k(\Gamma_0(N))`, where `k` and `N` are the
+        weight and level of ``self``. (It is clearly valid for *cuspidal* spaces
         of any fixed character, as a consequence of the Sturm bound theorem.)
         It returns a hopelessly wrong answer for spaces of full level
         `\Gamma_1`.
@@ -514,7 +526,7 @@ def hecke_bound(self):
 
             sage: ModularSymbols(17, 4).hecke_bound()
             15
-            sage: ModularSymbols(Gamma1(17), 4).hecke_bound() # wrong!
+            sage: ModularSymbols(Gamma1(17), 4).hecke_bound()  # wrong!
             15
         """
         from sage.misc.verbose import verbose
@@ -528,10 +540,10 @@ def hecke_bound(self):
 
     def hecke_module_of_level(self, level):
         r"""
-        Return the Hecke module corresponding to self at the given level, which
-        should be either a divisor or a multiple of the level of self.
+        Return the Hecke module corresponding to ``self`` at the given level, which
+        should be either a divisor or a multiple of the level of ``self``.
 
-        This raises NotImplementedError, and should be overridden in
+        This raises :class:`NotImplementedError`, and should be overridden in
         derived classes.
 
         EXAMPLES::
@@ -550,13 +562,13 @@ def hecke_images(self, i, v):
 
         INPUT:
 
-        -  ``i`` - nonnegative integer
+        -  ``i`` -- nonnegative integer
 
-        -  ``v`` - a list of positive integer
+        -  ``v`` -- a list of positive integer
 
         OUTPUT:
 
-        -  ``matrix`` - whose rows are the Hecke images
+        -  ``matrix`` -- whose rows are the Hecke images
 
         EXAMPLES::
 
@@ -578,7 +590,7 @@ def hecke_images(self, i, v):
 
     def intersection(self, other):
         """
-        Return the intersection of self and other, which must both lie in
+        Return the intersection of ``self`` and ``other``, which must both lie in
         a common ambient space of modular symbols.
 
         EXAMPLES::
@@ -603,8 +615,8 @@ def is_ambient(self) -> bool:
 
         .. warning::
 
-           self can only be ambient by being of type
-           AmbientHeckeModule.
+           ``self`` can only be ambient by being of type
+           :class:`AmbientHeckeModule`.
 
            For example, decomposing a simple ambient space yields a
            single factor, and that factor is *not* considered an
@@ -699,7 +711,7 @@ def is_submodule(self, V):
 
     def linear_combination_of_basis(self, v):
         r"""
-        Given a list or vector of length equal to the dimension of self,
+        Given a list or vector of length equal to the dimension of ``self``,
         construct the appropriate linear combination of the basis vectors of
         self.
 
@@ -713,18 +725,18 @@ def linear_combination_of_basis(self, v):
 
     def new_submodule(self, p=None):
         """
-        Return the new or p-new submodule of self.
+        Return the new or `p`-new submodule of ``self``.
 
         INPUT:
 
-        -  ``p`` - (default: None); if not None, return only
-           the p-new submodule.
+        -  ``p`` - (default: ``None``); if not ``None``, return only
+           the `p`-new submodule.
 
-        OUTPUT: the new or p-new submodule of self, i.e. the intersection of
+        OUTPUT: the new or `p`-new submodule of ``self``, i.e. the intersection of
         the kernel of the degeneracy lowering maps to level `N/p` (for the
         given prime `p`, or for all prime divisors of `N` if `p` is not given).
 
-        If self is cuspidal this is a Hecke-invariant complement of the
+        If ``self`` is cuspidal, this is a Hecke-invariant complement of the
         corresponding old submodule, but this may break down on Eisenstein
         subspaces (see the amusing example in William Stein's book of a form
         which is new and old at the same time).
@@ -799,7 +811,7 @@ def new_submodule(self, p=None):
 
     def nonembedded_free_module(self):
         r"""
-        Return the free module corresponding to self as an abstract free module
+        Return the free module corresponding to ``self`` as an abstract free module
         (rather than as a submodule of an ambient free module).
 
         As this module is ambient anyway, this just returns
@@ -815,16 +827,16 @@ def nonembedded_free_module(self):
 
     def old_submodule(self, p=None):
         """
-        Return the old or p-old submodule of self, i.e. the sum of the images
+        Return the old or `p`-old submodule of ``self``, i.e. the sum of the images
         of the degeneracy maps from level `N/p` (for the given prime `p`, or
         for all primes `p` dividing `N` if `p` is not given).
 
         INPUT:
 
-        - ``p`` - (default: None); if not None, return only the p-old
+        - ``p`` - (default: ``None``); if not ``None``, return only the `p`-old
           submodule.
 
-        OUTPUT: the old or p-old submodule of self
+        OUTPUT: the old or `p`-old submodule of ``self``
 
         EXAMPLES::
 
@@ -841,14 +853,19 @@ def old_submodule(self, p=None):
 
             sage: e = DirichletGroup(16)([-1, 1])
             sage: M = ModularSymbols(e, 3, sign=1); M
-            Modular Symbols space of dimension 4 and level 16, weight 3, character [-1, 1], sign 1, over Rational Field
+            Modular Symbols space of dimension 4 and level 16, weight 3,
+             character [-1, 1], sign 1, over Rational Field
             sage: M.old_submodule()
-            Modular Symbols subspace of dimension 3 of Modular Symbols space of dimension 4 and level 16, weight 3, character [-1, 1], sign 1, over Rational Field
+            Modular Symbols subspace of dimension 3 of
+             Modular Symbols space of dimension 4 and level 16, weight 3,
+              character [-1, 1], sign 1, over Rational Field
 
         Illustrate that :issue:`10664` is fixed::
 
             sage: ModularSymbols(DirichletGroup(42)[7], 6, sign=1).old_subspace(3)
-            Modular Symbols subspace of dimension 0 of Modular Symbols space of dimension 40 and level 42, weight 6, character [-1, -1], sign 1, over Rational Field
+            Modular Symbols subspace of dimension 0 of
+             Modular Symbols space of dimension 40 and level 42, weight 6,
+              character [-1, -1], sign 1, over Rational Field
 
         """
         try:
@@ -918,16 +935,18 @@ def old_submodule(self, p=None):
     def submodule(self, M, Mdual=None, check=True):
         """
         Return the Hecke submodule of ``self`` generated by `M`, which may be a
-        submodule of the free module of self, or a list of elements of self.
+        submodule of the free module of ``self``, or a list of elements of ``self``.
 
         EXAMPLES::
 
             sage: M = ModularForms(37, 2)
             sage: A = M.submodule([M.newforms()[0].element(), M.newforms()[1].element()]); A
-            Modular Forms subspace of dimension 2 of Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(37) of weight 2 over Rational Field
+            Modular Forms subspace of dimension 2 of
+             Modular Forms space of dimension 3 for
+              Congruence Subgroup Gamma0(37) of weight 2 over Rational Field
         """
         if check:
-            if not is_FreeModule(M):
+            if not isinstance(M, FreeModule_generic):
                 V = self.free_module()
                 if isinstance(M, (list, tuple)):
                     M = V.span([V(x.element()) for x in M])
@@ -956,39 +975,43 @@ def _submodule_class(self):
     def submodule_from_nonembedded_module(self, V, Vdual=None, check=True):
         """
         Create a submodule of this module, from a submodule of an ambient free
-        module of the same rank as the rank of self.
+        module of the same rank as the rank of ``self``.
 
         INPUT:
 
-        -  ``V`` - submodule of ambient free module of the same rank as the
+        -  ``V`` -- submodule of ambient free module of the same rank as the
            rank of self.
 
-        -  ``Vdual`` - used to pass in dual submodule (may be None)
+        -  ``Vdual`` -- used to pass in dual submodule (may be ``None``)
 
-        -  ``check`` - whether to check that submodule is Hecke equivariant
+        -  ``check`` -- whether to check that submodule is Hecke-equivariant
 
-        OUTPUT: Hecke submodule of self
+        OUTPUT: Hecke submodule of ``self``
 
         EXAMPLES::
 
             sage: V = QQ^8
             sage: ModularForms(24, 2).submodule_from_nonembedded_module(V.submodule([0]))
-            Modular Forms subspace of dimension 0 of Modular Forms space of dimension 8 for Congruence Subgroup Gamma0(24) of weight 2 over Rational Field
+            Modular Forms subspace of dimension 0 of
+             Modular Forms space of dimension 8 for
+              Congruence Subgroup Gamma0(24) of weight 2 over Rational Field
         """
         return self.submodule(V, Vdual, check=check)
 
     def submodule_generated_by_images(self, M):
         """
         Return the submodule of this ambient modular symbols space
-        generated by the images under all degeneracy maps of M.
+        generated by the images under all degeneracy maps of `M`.
 
-        The space M must have the same weight, sign, and group or
+        The space `M` must have the same weight, sign, and group or
         character as this ambient space.
 
         EXAMPLES::
 
             sage: ModularSymbols(6, 12).submodule_generated_by_images(ModularSymbols(1,12))
-            Modular Symbols subspace of dimension 12 of Modular Symbols space of dimension 22 for Gamma_0(6) of weight 12 with sign 0 over Rational Field
+            Modular Symbols subspace of dimension 12 of
+             Modular Symbols space of dimension 22 for
+              Gamma_0(6) of weight 12 with sign 0 over Rational Field
         """
         S = self.zero_submodule()
         if self.level() % M.level() == 0:
diff --git a/src/sage/modular/hecke/element.py b/src/sage/modular/hecke/element.py
index f45a29f6b31..df828ebca66 100644
--- a/src/sage/modular/hecke/element.py
+++ b/src/sage/modular/hecke/element.py
@@ -35,10 +35,16 @@ def is_HeckeModuleElement(x):
     EXAMPLES::
 
         sage: sage.modular.hecke.all.is_HeckeModuleElement(0)
+        doctest:warning...
+        DeprecationWarning: the function is_HeckeModuleElement is deprecated;
+        use 'isinstance(..., HeckeModuleElement)' instead
+        See https://github.com/sagemath/sage/issues/37895 for details.
         False
         sage: sage.modular.hecke.all.is_HeckeModuleElement(BrandtModule(37)([1,2,3]))
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37895, "the function is_HeckeModuleElement is deprecated; use 'isinstance(..., HeckeModuleElement)' instead")
     return isinstance(x, HeckeModuleElement)
 
 
@@ -150,7 +156,7 @@ def _richcmp_(self, other, op):
         EXAMPLES::
 
             sage: M = ModularSymbols(11, 2)
-            sage: M.0 == M.1 # indirect doctest
+            sage: M.0 == M.1  # indirect doctest
             False
             sage: M.0 == (M.1 + M.0 - M.1)
             True
diff --git a/src/sage/modular/hecke/hecke_operator.py b/src/sage/modular/hecke/hecke_operator.py
index b1e6ea9707c..22d4ac929e9 100644
--- a/src/sage/modular/hecke/hecke_operator.py
+++ b/src/sage/modular/hecke/hecke_operator.py
@@ -35,10 +35,16 @@ def is_HeckeOperator(x):
         sage: from sage.modular.hecke.hecke_operator import is_HeckeOperator
         sage: M = ModularSymbols(Gamma0(7), 4)
         sage: is_HeckeOperator(M.T(3))
+        doctest:warning...
+        DeprecationWarning: the function is_HeckeOperator is deprecated;
+        use 'isinstance(..., HeckeOperator)' instead
+        See https://github.com/sagemath/sage/issues/37895 for details.
         True
         sage: is_HeckeOperator(M.T(3) + M.T(5))
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37895, "the function is_HeckeOperator is deprecated; use 'isinstance(..., HeckeOperator)' instead")
     return isinstance(x, HeckeOperator)
 
 
@@ -51,10 +57,16 @@ def is_HeckeAlgebraElement(x):
         sage: from sage.modular.hecke.hecke_operator import is_HeckeAlgebraElement
         sage: M = ModularSymbols(Gamma0(7), 4)
         sage: is_HeckeAlgebraElement(M.T(3))
+        doctest:warning...
+        DeprecationWarning: the function is_HeckeAlgebraElement is deprecated;
+        use 'isinstance(..., HeckeAlgebraElement)' instead
+        See https://github.com/sagemath/sage/issues/37895 for details.
         True
         sage: is_HeckeAlgebraElement(M.T(3) + M.T(5))
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37895, "the function is_HeckeAlgebraElement is deprecated; use 'isinstance(..., HeckeAlgebraElement)' instead")
     return isinstance(x, HeckeAlgebraElement)
 
 
@@ -69,10 +81,10 @@ def __init__(self, parent):
         EXAMPLES::
 
             sage: R = ModularForms(Gamma0(7), 4).hecke_algebra()
-            sage: sage.modular.hecke.hecke_operator.HeckeAlgebraElement(R) # please don't do this!
+            sage: sage.modular.hecke.hecke_operator.HeckeAlgebraElement(R)  # please don't do this!
             Generic element of a structure
         """
-        if not algebra.is_HeckeAlgebra(parent):
+        if not isinstance(parent, algebra.HeckeAlgebra_base):
             raise TypeError("parent (=%s) must be a Hecke algebra" % parent)
         AlgebraElement.__init__(self, parent)
 
@@ -85,9 +97,9 @@ def domain(self):
 
             sage: R = ModularForms(Gamma0(7), 4).hecke_algebra()
             sage: sage.modular.hecke.hecke_operator.HeckeAlgebraElement(R).domain()
-             Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) of weight 4 over Rational Field
+            Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7)
+             of weight 4 over Rational Field
         """
-
         return self.parent().module()
 
     def codomain(self):
@@ -99,7 +111,8 @@ def codomain(self):
 
             sage: R = ModularForms(Gamma0(7), 4).hecke_algebra()
             sage: sage.modular.hecke.hecke_operator.HeckeAlgebraElement(R).codomain()
-            Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) of weight 4 over Rational Field
+            Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7)
+             of weight 4 over Rational Field
         """
         return self.parent().module()
 
@@ -113,7 +126,8 @@ def hecke_module_morphism(self):
             sage: M = ModularSymbols(Gamma1(13))
             sage: t = M.hecke_operator(2)
             sage: t
-            Hecke operator T_2 on Modular Symbols space of dimension 15 for Gamma_1(13) of weight 2 with sign 0 over Rational Field
+            Hecke operator T_2 on Modular Symbols space of dimension 15 for Gamma_1(13)
+             of weight 2 with sign 0 over Rational Field
             sage: t.hecke_module_morphism()
             Hecke module morphism T_2 defined by the matrix
             [ 2  0  0  0  0  0  0  1  0  0  1  0  0  0  0]
@@ -131,7 +145,7 @@ def hecke_module_morphism(self):
             [ 0  0  0  0  0  1  1  0  0  1  0  0  0  0  0]
             [ 0  0  0  0  0  1  0  0  1 -1  2  0  0  0 -1]
             [ 0  0  0  0  0  0  0  0  0  1  0 -1  2  0 -1]
-            Domain: Modular Symbols space of dimension 15 for Gamma_1(13) of weight ...
+            Domain:   Modular Symbols space of dimension 15 for Gamma_1(13) of weight ...
             Codomain: Modular Symbols space of dimension 15 for Gamma_1(13) of weight ...
         """
         try:
diff --git a/src/sage/modular/hecke/homspace.py b/src/sage/modular/hecke/homspace.py
index 194162faba4..6971605ce91 100644
--- a/src/sage/modular/hecke/homspace.py
+++ b/src/sage/modular/hecke/homspace.py
@@ -20,7 +20,7 @@
 from sage.matrix.matrix_space import MatrixSpace
 from sage.categories.homset import HomsetWithBase
 from .morphism import HeckeModuleMorphism_matrix
-from .module import is_HeckeModule
+from .module import HeckeModule_generic
 
 
 def is_HeckeModuleHomspace(x):
@@ -31,10 +31,16 @@ def is_HeckeModuleHomspace(x):
 
         sage: M = ModularForms(Gamma0(7), 4)
         sage: sage.modular.hecke.homspace.is_HeckeModuleHomspace(Hom(M, M))
+        doctest:warning...
+        DeprecationWarning: the function is_HeckeModuleHomspace is deprecated;
+        use 'isinstance(..., HeckeModuleHomspace)' instead
+        See https://github.com/sagemath/sage/issues/37895 for details.
         True
         sage: sage.modular.hecke.homspace.is_HeckeModuleHomspace(Hom(M, QQ))
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37895, "the function is_HeckeModuleHomspace is deprecated; use 'isinstance(..., HeckeModuleHomspace)' instead")
     return isinstance(x, HeckeModuleHomspace)
 
 
@@ -66,7 +72,7 @@ def __init__(self, X, Y, category=None):
             sage: H = M.Hom(M)
             sage: TestSuite(H).run(skip='_test_elements')
         """
-        if not is_HeckeModule(X) or not is_HeckeModule(Y):
+        if not isinstance(X, HeckeModule_generic) or not isinstance(Y, HeckeModule_generic):
             raise TypeError("X and Y must be Hecke modules")
         if X.base_ring() != Y.base_ring():
             raise TypeError("X and Y must have the same base ring")
@@ -100,21 +106,21 @@ def __call__(self, A, name='', **kwds):
             [ -7   0   0]
             [  0   1 240]
             [  0   0 343]
-            Domain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
+            Domain:   Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
             Codomain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
             sage: H(H(M.hecke_operator(7)))
             Hecke module morphism T_7 defined by the matrix
             [ -7   0   0]
             [  0   1 240]
             [  0   0 343]
-            Domain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
+            Domain:   Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
             Codomain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
             sage: H(matrix(QQ, 3, srange(9)))
             Hecke module morphism defined by the matrix
             [0 1 2]
             [3 4 5]
             [6 7 8]
-            Domain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
+            Domain:   Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
             Codomain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
 
         TESTS:
@@ -122,7 +128,7 @@ def __call__(self, A, name='', **kwds):
         Make sure that the element is created correctly when the codomain is
         not the full module (related to :issue:`21497`)::
 
-            sage: M = ModularSymbols(Gamma0(3),weight=22,sign=1)
+            sage: M = ModularSymbols(Gamma0(3), weight=22, sign=1)
             sage: S = M.cuspidal_subspace()
             sage: H = S.Hom(S)
             sage: H(S.gens())
@@ -133,7 +139,7 @@ def __call__(self, A, name='', **kwds):
             [0 0 0 1 0 0]
             [0 0 0 0 1 0]
             [0 0 0 0 0 1]
-            Domain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
+            Domain:   Modular Symbols subspace of dimension 6 of Modular Symbols space ...
             Codomain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
 
             sage: H.zero() in H
@@ -189,7 +195,7 @@ def _an_element_(self):
             Hecke module morphism defined by the matrix
             [      260 -2108/135]
             [     4860      -284]
-            Domain: Modular Symbols subspace of dimension 2 of Modular Symbols space ...
+            Domain:   Modular Symbols subspace of dimension 2 of Modular Symbols space ...
             Codomain: Modular Symbols subspace of dimension 2 of Modular Symbols space ...
         """
         if self.domain() != self.codomain():
diff --git a/src/sage/modular/hecke/module.py b/src/sage/modular/hecke/module.py
index 65536b4a043..5e17fc23e0b 100644
--- a/src/sage/modular/hecke/module.py
+++ b/src/sage/modular/hecke/module.py
@@ -38,12 +38,18 @@ def is_HeckeModule(x):
 
         sage: from sage.modular.hecke.module import is_HeckeModule
         sage: is_HeckeModule(ModularForms(Gamma0(7), 4))
+        doctest:warning...
+        DeprecationWarning: the function is_HeckeModule is deprecated;
+        use 'isinstance(..., HeckeModule_generic)' instead
+        See https://github.com/sagemath/sage/issues/37895 for details.
         True
         sage: is_HeckeModule(QQ^3)
         False
         sage: is_HeckeModule(J0(37).homology())
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37895, "the function is_HeckeModule is deprecated; use 'isinstance(..., HeckeModule_generic)' instead")
     return isinstance(x, HeckeModule_generic)
 
 
@@ -652,7 +658,7 @@ def _element_eigenvalue(self, x, name='alpha'):
             sage: M._element_eigenvalue(M.0)
             1
         """
-        if not element.is_HeckeModuleElement(x):
+        if not isinstance(x, element.HeckeModuleElement):
             raise TypeError("x must be a Hecke module element.")
         if x not in self.ambient_hecke_module():
             raise ArithmeticError("x must be in the ambient Hecke module.")
diff --git a/src/sage/modular/hecke/morphism.py b/src/sage/modular/hecke/morphism.py
index ac9cfbf4e84..c43f227b1e6 100644
--- a/src/sage/modular/hecke/morphism.py
+++ b/src/sage/modular/hecke/morphism.py
@@ -42,8 +42,14 @@ def is_HeckeModuleMorphism(x):
     EXAMPLES::
 
         sage: sage.modular.hecke.morphism.is_HeckeModuleMorphism(ModularSymbols(6).hecke_operator(7).hecke_module_morphism())
+        doctest:warning...
+        DeprecationWarning: the function is_HeckeModuleMorphism is deprecated;
+        use 'isinstance(..., HeckeModuleMorphism)' instead
+        See https://github.com/sagemath/sage/issues/37895 for details.
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37895, "the function is_HeckeModuleMorphism is deprecated; use 'isinstance(..., HeckeModuleMorphism)' instead")
     return isinstance(x, HeckeModuleMorphism)
 
 
@@ -53,8 +59,14 @@ def is_HeckeModuleMorphism_matrix(x):
     EXAMPLES::
 
         sage: sage.modular.hecke.morphism.is_HeckeModuleMorphism_matrix(ModularSymbols(6).hecke_operator(7).matrix_form().hecke_module_morphism())
+        doctest:warning...
+        DeprecationWarning: the function is_HeckeModuleMorphism_matrix is deprecated;
+        use 'isinstance(..., HeckeModuleMorphism_matrix)' instead
+        See https://github.com/sagemath/sage/issues/37895 for details.
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37895, "the function is_HeckeModuleMorphism_matrix is deprecated; use 'isinstance(..., HeckeModuleMorphism_matrix)' instead")
     return isinstance(x, HeckeModuleMorphism_matrix)
 
 
diff --git a/src/sage/modular/hecke/submodule.py b/src/sage/modular/hecke/submodule.py
index 5e9bf127496..0e082093c9e 100644
--- a/src/sage/modular/hecke/submodule.py
+++ b/src/sage/modular/hecke/submodule.py
@@ -22,7 +22,7 @@
 import sage.arith.all as arith
 from sage.misc.verbose import verbose
 from sage.misc.cachefunc import cached_method
-from sage.modules.free_module import is_FreeModule
+from sage.modules.free_module import FreeModule_generic
 from sage.structure.richcmp import richcmp_method, richcmp_not_equal
 
 from . import module
@@ -35,10 +35,16 @@ def is_HeckeSubmodule(x):
     EXAMPLES::
 
         sage: sage.modular.hecke.submodule.is_HeckeSubmodule(ModularForms(1, 12))
+        doctest:warning...
+        DeprecationWarning: the function is_HeckeSubmodule is deprecated;
+        use 'isinstance(..., HeckeSubmodule)' instead
+        See https://github.com/sagemath/sage/issues/37895 for details.
         False
         sage: sage.modular.hecke.submodule.is_HeckeSubmodule(CuspForms(1, 12))
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37895, "the function is_HeckeSubmodule is deprecated; use 'isinstance(..., HeckeSubmodule)' instead")
     return isinstance(x, HeckeSubmodule)
 
 
@@ -81,7 +87,7 @@ def __init__(self, ambient, submodule, dual_free_module=None, check=True):
         from . import ambient_module
         if not isinstance(ambient, ambient_module.AmbientHeckeModule):
             raise TypeError("ambient must be an ambient Hecke module")
-        if not is_FreeModule(submodule):
+        if not isinstance(submodule, FreeModule_generic):
             raise TypeError("submodule must be a free module")
         if not submodule.is_submodule(ambient.free_module()):
             raise ValueError("submodule must be a submodule of the ambient free module")
@@ -96,7 +102,7 @@ def __init__(self, ambient, submodule, dual_free_module=None, check=True):
                                                 ambient.level(),
                                                 ambient.weight())
         if dual_free_module is not None:
-            if not is_FreeModule(dual_free_module):
+            if not isinstance(dual_free_module, FreeModule_generic):
                 raise TypeError("dual_free_module must be a free module")
             if dual_free_module.rank() != submodule.rank():
                 raise ArithmeticError("dual_free_module must have the same rank as submodule")
@@ -912,7 +918,7 @@ def submodule(self, M, Mdual=None, check=True):
             sage: S.submodule(S[0].free_module())
             Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 18 for Gamma_0(18) of weight 4 with sign 0 over Rational Field
         """
-        if not is_FreeModule(M):
+        if not isinstance(M, FreeModule_generic):
             V = self.ambient_module().free_module()
             if isinstance(M, (list, tuple)):
                 M = V.span([V(x.element()) for x in M])
diff --git a/src/sage/modular/local_comp/all.py b/src/sage/modular/local_comp/all.py
index 1df1ec59fd6..1177acd9b7e 100644
--- a/src/sage/modular/local_comp/all.py
+++ b/src/sage/modular/local_comp/all.py
@@ -1 +1 @@
-from .local_comp import LocalComponent
+from sage.modular.local_comp.local_comp import LocalComponent
diff --git a/src/sage/modular/modform/all.py b/src/sage/modular/modform/all.py
index feb1521d3ca..6461e3c7083 100644
--- a/src/sage/modular/modform/all.py
+++ b/src/sage/modular/modform/all.py
@@ -3,26 +3,27 @@
 #
 #  Distributed under the terms of the GNU General Public License (GPL)
 #
-#                  http://www.gnu.org/licenses/
+#                  https://www.gnu.org/licenses/
 #########################################################################
 
-from .constructor import ModularForms, CuspForms, EisensteinForms, Newforms, Newform
+from sage.modular.modform.constructor import ModularForms, CuspForms, EisensteinForms, Newforms, Newform
 
-from .eis_series import eisenstein_series_qexp, eisenstein_series_lseries
+from sage.modular.modform.eis_series import eisenstein_series_qexp, eisenstein_series_lseries
 
-from .half_integral import half_integral_weight_modform_basis
+from sage.modular.modform.half_integral import half_integral_weight_modform_basis
 
-from .theta import theta_qexp, theta2_qexp
+from sage.modular.modform.theta import theta_qexp, theta2_qexp
 
 from sage.misc.lazy_import import lazy_import
 
 lazy_import('sage.modular.modform.j_invariant', 'j_invariant_qexp')
 lazy_import('sage.modular.modform.vm_basis', ['victor_miller_basis', 'delta_qexp'])
 
-from .hecke_operator_on_qexp import hecke_operator_on_qexp, hecke_operator_on_basis
+from sage.modular.modform.hecke_operator_on_qexp import hecke_operator_on_qexp, hecke_operator_on_basis
 
-from .numerical import NumericalEigenforms as numerical_eigenforms
+from sage.modular.modform.numerical import NumericalEigenforms as numerical_eigenforms
 
-from .element import delta_lseries
+from sage.modular.modform.element import delta_lseries
 
-from .ring import ModularFormsRing
+from sage.modular.modform.ring import ModularFormsRing
+del lazy_import
diff --git a/src/sage/modular/modform_hecketriangle/all.py b/src/sage/modular/modform_hecketriangle/all.py
index cd236efc334..1c2bfeccdc6 100644
--- a/src/sage/modular/modform_hecketriangle/all.py
+++ b/src/sage/modular/modform_hecketriangle/all.py
@@ -11,19 +11,19 @@
 #  the License, or (at your option) any later version.
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
-from .hecke_triangle_groups import HeckeTriangleGroup
+from sage.modular.modform_hecketriangle.hecke_triangle_groups import HeckeTriangleGroup
 
-from .series_constructor import MFSeriesConstructor
+from sage.modular.modform_hecketriangle.series_constructor import MFSeriesConstructor
 
-from .graded_ring import (QuasiMeromorphicModularFormsRing,
-                          QuasiWeakModularFormsRing, QuasiModularFormsRing,
-                          QuasiCuspFormsRing, MeromorphicModularFormsRing,
-                          WeakModularFormsRing,
-                          ModularFormsRing, CuspFormsRing)
+from sage.modular.modform_hecketriangle.graded_ring import (QuasiMeromorphicModularFormsRing,
+                                                            QuasiWeakModularFormsRing, QuasiModularFormsRing,
+                                                            QuasiCuspFormsRing, MeromorphicModularFormsRing,
+                                                            WeakModularFormsRing,
+                                                            ModularFormsRing, CuspFormsRing)
 
-from .space import (QuasiMeromorphicModularForms, QuasiWeakModularForms,
-                    QuasiModularForms, QuasiCuspForms,
-                    MeromorphicModularForms, WeakModularForms, ModularForms,
-                    CuspForms, ZeroForm)
+from sage.modular.modform_hecketriangle.space import (QuasiMeromorphicModularForms, QuasiWeakModularForms,
+                                                      QuasiModularForms, QuasiCuspForms,
+                                                      MeromorphicModularForms, WeakModularForms, ModularForms,
+                                                      CuspForms, ZeroForm)
 
-from .subspace import ModularFormsSubSpace
+from sage.modular.modform_hecketriangle.subspace import ModularFormsSubSpace
diff --git a/src/sage/modular/modsym/all.py b/src/sage/modular/modsym/all.py
index 798a4a7d55f..f398a735a1e 100644
--- a/src/sage/modular/modsym/all.py
+++ b/src/sage/modular/modsym/all.py
@@ -1,15 +1,16 @@
 from sage.misc.lazy_import import lazy_import
 
-from .element import set_modsym_print_mode
+from sage.modular.modsym.element import set_modsym_print_mode
 
-from .modsym import ModularSymbols, ModularSymbols_clear_cache
+from sage.modular.modsym.modsym import ModularSymbols, ModularSymbols_clear_cache
 
 lazy_import('sage.modular.modsym.heilbronn', ['HeilbronnCremona', 'HeilbronnMerel'])
 
-from .p1list import P1List, lift_to_sl2z
+from sage.modular.modsym.p1list import P1List, lift_to_sl2z
 
-from .p1list_nf import P1NFList, MSymbol
+from sage.modular.modsym.p1list_nf import P1NFList, MSymbol
 
-from .ghlist import GHlist
+from sage.modular.modsym.ghlist import GHlist
 
-from .g1list import G1list
+from sage.modular.modsym.g1list import G1list
+del lazy_import
diff --git a/src/sage/modular/modsym/ambient.py b/src/sage/modular/modsym/ambient.py
index 00c97e59789..cbd6c8e80b3 100644
--- a/src/sage/modular/modsym/ambient.py
+++ b/src/sage/modular/modsym/ambient.py
@@ -88,7 +88,7 @@ class ``ModularSymbolsAmbient``, derived from
                                                    ManinSymbolList_gamma1,
                                                    ManinSymbolList_gamma_h,
                                                    ManinSymbolList_character)
-from sage.modules.free_module import is_FreeModule
+from sage.modules.free_module import FreeModule_generic
 from sage.modules.free_module_element import FreeModuleElement
 from sage.rings.integer import Integer
 from sage.rings.integer_ring import ZZ
@@ -2133,7 +2133,7 @@ def submodule(self, M, dual_free_module=None, check=True):
            Stein, 2007-07-27
         """
         if check:
-            if not is_FreeModule(M):
+            if not isinstance(M, FreeModule_generic):
                 V = self.free_module()
                 if not isinstance(M, (list, tuple)):
                     M = M.gens()
diff --git a/src/sage/modular/overconvergent/all.py b/src/sage/modular/overconvergent/all.py
index 11e23071854..ed9c2310568 100644
--- a/src/sage/modular/overconvergent/all.py
+++ b/src/sage/modular/overconvergent/all.py
@@ -1,5 +1,5 @@
-from .weightspace import WeightSpace_constructor as pAdicWeightSpace
+from sage.modular.overconvergent.weightspace import WeightSpace_constructor as pAdicWeightSpace
 
-from .genus0 import OverconvergentModularForms
+from sage.modular.overconvergent.genus0 import OverconvergentModularForms
 
-from .hecke_series import hecke_series
+from sage.modular.overconvergent.hecke_series import hecke_series
diff --git a/src/sage/modular/pollack_stevens/all.py b/src/sage/modular/pollack_stevens/all.py
index a51787d6fd2..981c5028543 100644
--- a/src/sage/modular/pollack_stevens/all.py
+++ b/src/sage/modular/pollack_stevens/all.py
@@ -1,3 +1,3 @@
-from .space import PollackStevensModularSymbols
-from .distributions import Symk
-from .distributions import OverconvergentDistributions
+from sage.modular.pollack_stevens.space import PollackStevensModularSymbols
+from sage.modular.pollack_stevens.distributions import Symk
+from sage.modular.pollack_stevens.distributions import OverconvergentDistributions
diff --git a/src/sage/modular/pollack_stevens/dist.pyx b/src/sage/modular/pollack_stevens/dist.pyx
index cd1ce2a722f..7902105454a 100644
--- a/src/sage/modular/pollack_stevens/dist.pyx
+++ b/src/sage/modular/pollack_stevens/dist.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # distutils: libraries = gmp
 # distutils: extra_compile_args = -D_XPG6
 """
diff --git a/src/sage/modular/quasimodform/all.py b/src/sage/modular/quasimodform/all.py
index 114783b2e37..f7e4444785d 100644
--- a/src/sage/modular/quasimodform/all.py
+++ b/src/sage/modular/quasimodform/all.py
@@ -1,2 +1,2 @@
 # Quasimodular forms rings
-from .ring import QuasiModularForms
+from sage.modular.quasimodform.ring import QuasiModularForms
diff --git a/src/sage/modular/quatalg/all.py b/src/sage/modular/quatalg/all.py
index e554527d96c..53103006057 100644
--- a/src/sage/modular/quatalg/all.py
+++ b/src/sage/modular/quatalg/all.py
@@ -1,2 +1,2 @@
 
-from .brandt import BrandtModule
+from sage.modular.quatalg.brandt import BrandtModule
diff --git a/src/sage/modules/fg_pid/fgp_module.py b/src/sage/modules/fg_pid/fgp_module.py
index 6965b4281b7..026f55533f7 100644
--- a/src/sage/modules/fg_pid/fgp_module.py
+++ b/src/sage/modules/fg_pid/fgp_module.py
@@ -214,7 +214,7 @@
 from itertools import product
 
 from sage.modules.module import Module
-from sage.modules.free_module import is_FreeModule
+from sage.modules.free_module import FreeModule_generic
 from sage.structure.all import parent
 from sage.structure.sequence import Sequence
 from .fgp_element import DEBUG, FGP_Element
@@ -280,10 +280,16 @@ def is_FGP_Module(x):
         sage: V = span([[1/2,1,1],[3/2,2,1],[0,0,1]],ZZ)
         sage: W = V.span([2*V.0 + 4*V.1, 9*V.0 + 12*V.1, 4*V.2]); Q = V/W
         sage: sage.modules.fg_pid.fgp_module.is_FGP_Module(V)
+        doctest:warning...
+        DeprecationWarning: the function is_FGP_Module is deprecated;
+        use 'isinstance(..., FGP_Module_class)' instead
+        See https://github.com/sagemath/sage/issues/37924 for details.
         False
         sage: sage.modules.fg_pid.fgp_module.is_FGP_Module(Q)
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37924, "the function is_FGP_Module is deprecated; use 'isinstance(..., FGP_Module_class)' instead")
     return isinstance(x, FGP_Module_class)
 
 
@@ -356,9 +362,9 @@ def __init__(self, V, W, check=True):
             
         """
         if check:
-            if not is_FreeModule(V):
+            if not isinstance(V, FreeModule_generic):
                 raise TypeError("V must be a FreeModule")
-            if not is_FreeModule(W):
+            if not isinstance(W, FreeModule_generic):
                 raise TypeError("W must be a FreeModule")
             if not W.is_submodule(V):
                 raise ValueError("W must be a submodule of V")
@@ -441,7 +447,7 @@ def _coerce_map_from_(self, S):
             sage: Q._coerce_map_from_(V.scale(2))
             True
         """
-        if is_FGP_Module(S):
+        if isinstance(S, FGP_Module_class):
             return S.has_canonical_map_to(self)
         return self._V.has_coerce_map_from(S)
 
@@ -500,8 +506,8 @@ def __truediv__(self, other):
             sage: Q/Q
             Finitely generated module V/W over Integer Ring with invariants ()
         """
-        if not is_FGP_Module(other):
-            if is_FreeModule(other):
+        if not isinstance(other, FGP_Module_class):
+            if isinstance(other, FreeModule_generic):
                 other = other / other.zero_submodule()
             else:
                 raise TypeError("other must be an FGP module")
@@ -525,7 +531,7 @@ def __eq__(self, other):
             sage: Q == V/V.zero_submodule()
             False
         """
-        if not is_FGP_Module(other):
+        if not isinstance(other, FGP_Module_class):
             return False
         return self._V == other._V and self._W == other._W
 
@@ -745,7 +751,7 @@ def submodule(self, x):
             ...
             ValueError: x.V() must be contained in self's V.
         """
-        if is_FGP_Module(x):
+        if isinstance(x, FGP_Module_class):
             if not x._W.is_submodule(self._W):
                 raise ValueError("x.W() must be contained in self's W.")
 
@@ -759,7 +765,7 @@ def submodule(self, x):
             raise TypeError("x must be a list, tuple, or FGP module")
 
         x = Sequence(x)
-        if is_FGP_Module(x.universe()):
+        if isinstance(x.universe(), FGP_Module_class):
             # TODO: possibly inefficient in some cases
             x = [self(v).lift() for v in x]
         V = self._V.submodule(x) + self._W
@@ -791,7 +797,7 @@ def has_canonical_map_to(self, A):
             False
 
         """
-        if not is_FGP_Module(A):
+        if not isinstance(A, FGP_Module_class):
             return False
         if self.cardinality() == 0 and self.base_ring() == A.base_ring():
             return True
@@ -1598,7 +1604,7 @@ def hom(self, im_gens, codomain=None, check=True):
                 N = codomain
                 im_gens = Sequence(im_gens, universe=N)
 
-        if is_FreeModule(N):
+        if isinstance(N, FreeModule_generic):
             # If im_smith_gens are not in an R-module, but are in a Free-module,
             # then we quotient out by the 0 submodule and get an R-module.
             N = FGP_Module(N, N.zero_submodule(), check=DEBUG)
@@ -2047,7 +2053,7 @@ def random_fgp_morphism_0(*args, **kwds):
         sage: mor = fgp.random_fgp_morphism_0(4)
         sage: mor.domain() == mor.codomain()
         True
-        sage: fgp.is_FGP_Module(mor.domain())
+        sage: isinstance(mor.domain(), fgp.FGP_Module_class)
         True
 
     Each generator is sent to a random multiple of itself::
diff --git a/src/sage/modules/fg_pid/fgp_morphism.py b/src/sage/modules/fg_pid/fgp_morphism.py
index c3b5374f706..ae8309d6d87 100644
--- a/src/sage/modules/fg_pid/fgp_morphism.py
+++ b/src/sage/modules/fg_pid/fgp_morphism.py
@@ -277,8 +277,8 @@ def __call__(self, x):
             sage: phi(8*Q.1) == phi(x)
             True
         """
-        from .fgp_module import is_FGP_Module
-        if is_FGP_Module(x):
+        from .fgp_module import FGP_Module_class
+        if isinstance(x, FGP_Module_class):
             if not x.is_submodule(self.domain()):
                 raise ValueError("x must be a submodule or element of the domain")
             # perhaps can be optimized with a matrix multiply; but note
@@ -355,8 +355,8 @@ def inverse_image(self, A):
             ...
             ValueError: A must be a submodule of the codomain
         """
-        from .fgp_module import is_FGP_Module
-        if not is_FGP_Module(A):
+        from .fgp_module import FGP_Module_class
+        if not isinstance(A, FGP_Module_class):
             raise TypeError("A must be a finitely generated quotient module")
         if not A.is_submodule(self.codomain()):
             raise ValueError("A must be a submodule of the codomain")
@@ -506,8 +506,8 @@ def __init__(self, X, Y, category=None):
             
         """
         if category is None:
-            from sage.modules.free_module import is_FreeModule
-            if is_FreeModule(X) and is_FreeModule(Y):
+            from sage.modules.free_module import FreeModule_generic
+            if isinstance(X, FreeModule_generic) and isinstance(Y, FreeModule_generic):
                 from sage.categories.modules_with_basis import ModulesWithBasis
                 category = ModulesWithBasis(X.base_ring())
             else:
diff --git a/src/sage/modules/filtered_vector_space.py b/src/sage/modules/filtered_vector_space.py
index 68bbff12c8d..6bf2ae7fc17 100644
--- a/src/sage/modules/filtered_vector_space.py
+++ b/src/sage/modules/filtered_vector_space.py
@@ -144,10 +144,16 @@ def is_FilteredVectorSpace(X):
         sage: from sage.modules.filtered_vector_space import is_FilteredVectorSpace
         sage: V = FilteredVectorSpace(2, 1)
         sage: is_FilteredVectorSpace(V)
+        doctest:warning...:
+        DeprecationWarning: the function is_FilteredVectorSpace is deprecated;
+        use 'isinstance(..., FilteredVectorSpace_class)' instead
+        See https://github.com/sagemath/sage/issues/37924 for details.
         True
         sage: is_FilteredVectorSpace('ceci n\'est pas une pipe')
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37924, "the function is_FilteredVectorSpace is deprecated; use 'isinstance(..., FilteredVectorSpace_class)' instead")
     return isinstance(X, FilteredVectorSpace_class)
 
 
diff --git a/src/sage/modules/free_module.py b/src/sage/modules/free_module.py
index 1654c8cf6ed..102d13aacd2 100644
--- a/src/sage/modules/free_module.py
+++ b/src/sage/modules/free_module.py
@@ -853,11 +853,17 @@ def is_FreeModule(M):
         sage: from sage.modules.free_module import is_FreeModule
         sage: V = ZZ^3
         sage: is_FreeModule(V)
+        doctest:warning...
+        DeprecationWarning: the function is_FreeModule is deprecated;
+        use 'isinstance(..., FreeModule_generic)' instead
+        See https://github.com/sagemath/sage/issues/37924 for details.
         True
         sage: W = V.span([ V.random_element() for i in range(2) ])
         sage: is_FreeModule(W)
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37924, "the function is_FreeModule is deprecated; use 'isinstance(..., FreeModule_generic)' instead")
     return isinstance(M, FreeModule_generic)
 
 
@@ -2745,7 +2751,7 @@ def direct_sum(self, other):
             [  0   1  -3   0   0   0]
             [  0   0   0 1/2   4   2]
         """
-        if not is_FreeModule(other):
+        if not isinstance(other, FreeModule_generic):
             raise TypeError("other must be a free module")
         if other.base_ring() != self.base_ring():
             raise TypeError("base rings of self and other must be the same")
@@ -2867,7 +2873,7 @@ def coordinate_module(self, V):
             [ 0  1  1  0 -2  1 -1  1 -1 -2  2  0  0  0  0  0  0  0  0]
             [ 0  0  3  0 -3  2 -1  2 -1 -4  2 -1 -2  1  2  0  0 -1  1]
         """
-        if not is_FreeModule(V):
+        if not isinstance(V, FreeModule_generic):
             raise ValueError("V must be a free module")
         A = self.basis_matrix()
         A = A.matrix_from_columns(A.pivots()).transpose()
@@ -4144,7 +4150,7 @@ def span_of_basis(self, basis, base_ring=None, check=True, already_echelonized=F
             ...
             ValueError: The given basis vectors must be linearly independent.
         """
-        if is_FreeModule(basis):
+        if isinstance(basis, FreeModule_generic):
             basis = basis.gens()
         if base_ring is None or base_ring == self.base_ring():
             try:
@@ -4306,7 +4312,7 @@ def vector_space_span(self, gens, check=True):
             Basis matrix:
             [  1 3/2   2]
         """
-        if is_FreeModule(gens):
+        if isinstance(gens, FreeModule_generic):
             gens = gens.gens()
         return FreeModule_submodule_field(self.ambient_vector_space(), gens, check=check)
 
@@ -4360,7 +4366,7 @@ def quotient_module(self, sub, check=True, **kwds):
         """
         # Calling is_subspace may be way too slow and repeat work done below.
         # It will be very desirable to somehow do this step better.
-        if check and (not is_FreeModule(sub) or not sub.is_submodule(self)):
+        if check and (not isinstance(sub, FreeModule_generic) or not sub.is_submodule(self)):
             try:
                 sub = self.submodule(sub)
             except (TypeError, ArithmeticError):
@@ -4695,7 +4701,7 @@ def span_of_basis(self, basis, base_ring=None, check=True, already_echelonized=F
             ...
             ValueError: The given basis vectors must be linearly independent.
         """
-        if is_FreeModule(basis):
+        if isinstance(basis, FreeModule_generic):
             basis = basis.gens()
         if base_ring is None:
             return FreeModule_submodule_with_basis_field(
@@ -5189,9 +5195,9 @@ def quotient_module(self, sub, check=True):
         """
         # Calling is_submodule may be way too slow and repeat work done below.
         # It will be very desirable to somehow do this step better.
-        if is_FreeModule(sub) and self.base_ring() != sub.base_ring():
+        if isinstance(sub, FreeModule_generic) and self.base_ring() != sub.base_ring():
             raise ValueError("base rings must be the same")
-        if check and (not is_FreeModule(sub) or not sub.is_subspace(self)):
+        if check and (not isinstance(sub, FreeModule_generic) or not sub.is_subspace(self)):
             try:
                 sub = self.subspace(sub)
             except (TypeError, ArithmeticError):
@@ -5342,7 +5348,7 @@ def quotient_abstract(self, sub, check=True, **kwds):
         """
         # Calling is_subspace may be way too slow and repeat work done below.
         # It will be very desirable to somehow do this step better.
-        if check and (not is_FreeModule(sub) or not sub.is_subspace(self)):
+        if check and (not isinstance(sub, FreeModule_generic) or not sub.is_subspace(self)):
             try:
                 sub = self.subspace(sub)
             except (TypeError, ArithmeticError):
@@ -5804,8 +5810,8 @@ def change_ring(self, R):
         """
         if self.base_ring() is R:
             return self
-        from sage.modules.free_quadratic_module import is_FreeQuadraticModule
-        if is_FreeQuadraticModule(self):
+        from sage.modules.free_quadratic_module import FreeQuadraticModule_generic
+        if isinstance(self, FreeQuadraticModule_generic):
             return FreeModule(R, self.rank(),
                               inner_product_matrix=self.inner_product_matrix(),
                               sparse=self.is_sparse())
@@ -8015,7 +8021,7 @@ def __init__(self, ambient, gens, check=True, already_echelonized=False, categor
             [ 1  0 -1]
             [ 0  1  2]
         """
-        if is_FreeModule(gens):
+        if isinstance(gens, FreeModule_generic):
             gens = gens.gens()
         FreeModule_submodule_with_basis_field.__init__(self, ambient,
                                                        basis=gens, check=check,
diff --git a/src/sage/modules/free_module_homspace.py b/src/sage/modules/free_module_homspace.py
index 9222bd8105e..ae4503ea9d3 100644
--- a/src/sage/modules/free_module_homspace.py
+++ b/src/sage/modules/free_module_homspace.py
@@ -97,6 +97,10 @@ def is_FreeModuleHomspace(x):
         sage: type(H)
         
         sage: sage.modules.free_module_homspace.is_FreeModuleHomspace(H)
+        doctest:warning...
+        DeprecationWarning: the function is_FreeModuleHomspace is deprecated;
+        use 'isinstance(..., FreeModuleHomspace)' instead
+        See https://github.com/sagemath/sage/issues/37924 for details.
         True
 
         sage: K = Hom(QQ^3, ZZ^2)
@@ -120,6 +124,8 @@ def is_FreeModuleHomspace(x):
         sage: sage.modules.free_module_homspace.is_FreeModuleHomspace('junk')
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37924, "the function is_FreeModuleHomspace is deprecated; use 'isinstance(..., FreeModuleHomspace)' instead")
     return isinstance(x, FreeModuleHomspace)
 
 
diff --git a/src/sage/modules/free_module_morphism.py b/src/sage/modules/free_module_morphism.py
index 6974b31f18c..173075ee5c0 100644
--- a/src/sage/modules/free_module_morphism.py
+++ b/src/sage/modules/free_module_morphism.py
@@ -90,7 +90,7 @@ def __init__(self, parent, A, side="left"):
             sage: type(phi)
             
         """
-        if not free_module_homspace.is_FreeModuleHomspace(parent):
+        if not isinstance(parent, free_module_homspace.FreeModuleHomspace):
             raise TypeError("parent (=%s) must be a free module hom space" % parent)
         if isinstance(A, matrix_morphism.MatrixMorphism):
             A = A.matrix()
@@ -128,7 +128,7 @@ def pushforward(self, x):
             sage: phi(2*W.1)
             (6, 0, 8/3)
         """
-        if free_module.is_FreeModule(x):
+        if isinstance(x, free_module.FreeModule_generic):
             V = self.domain().submodule(x)
             return self.restrict_domain(V).image()
         raise TypeError("`pushforward` is only defined for submodules")
diff --git a/src/sage/modules/free_quadratic_module.py b/src/sage/modules/free_quadratic_module.py
index 78b3b179b33..da54426e9c9 100644
--- a/src/sage/modules/free_quadratic_module.py
+++ b/src/sage/modules/free_quadratic_module.py
@@ -241,6 +241,10 @@ def is_FreeQuadraticModule(M):
         sage: from sage.modules.free_quadratic_module import is_FreeQuadraticModule
         sage: U = FreeModule(QQ,3)
         sage: is_FreeQuadraticModule(U)
+        doctest:warning...
+        DeprecationWarning: the function is_FreeQuadraticModule is deprecated;
+        use 'isinstance(..., FreeQuadraticModule_generic)' instead
+        See https://github.com/sagemath/sage/issues/37924 for details.
         False
         sage: V = FreeModule(QQ,3,inner_product_matrix=diagonal_matrix([1,1,1]))
         sage: is_FreeQuadraticModule(V)
@@ -249,6 +253,8 @@ def is_FreeQuadraticModule(M):
         sage: is_FreeQuadraticModule(W)
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37924, "the function is_FreeQuadraticModule is deprecated; use 'isinstance(..., FreeQuadraticModule_generic)' instead")
     return isinstance(M, FreeQuadraticModule_generic)
 
 
@@ -751,7 +757,7 @@ def span(self, gens, check=True, already_echelonized=False):
             Basis matrix:
             [1 1 1]
         """
-        if free_module.is_FreeModule(gens):
+        if isinstance(gens, free_module.FreeModule_generic):
             gens = gens.gens()
         if not isinstance(gens, (list, tuple)):
             raise TypeError("gens (=%s) must be a list or tuple" % gens)
diff --git a/src/sage/modules/matrix_morphism.py b/src/sage/modules/matrix_morphism.py
index ce2b88ede82..c1f882852fd 100644
--- a/src/sage/modules/matrix_morphism.py
+++ b/src/sage/modules/matrix_morphism.py
@@ -112,7 +112,7 @@ def __init__(self, parent, side='left'):
             sage: loads(A.dumps()) == A
             True
         """
-        if not sage.categories.homset.is_Homset(parent):
+        if not isinstance(parent, sage.categories.homset.Homset):
             raise TypeError("parent must be a Hom space")
         if side not in ["left", "right"]:
             raise ValueError("the argument side must be either 'left' or 'right'")
diff --git a/src/sage/modules/module.pyx b/src/sage/modules/module.pyx
index 2d7d21422ac..000c8a88bcd 100644
--- a/src/sage/modules/module.pyx
+++ b/src/sage/modules/module.pyx
@@ -174,9 +174,9 @@ cdef class Module(Parent):
 
         """
         try:
-            if (is_Module(M)
-                and self.base_ring().has_coerce_map_from(M.base_ring())
-                and M.change_ring(self.base_ring()).is_submodule(self)):
+            if (isinstance(M, Module)
+                    and self.base_ring().has_coerce_map_from(M.base_ring())
+                    and M.change_ring(self.base_ring()).is_submodule(self)):
                 return M.hom([self._element_constructor_(x) for x in M.gens()], self)
         except (TypeError, NotImplementedError, AttributeError, ArithmeticError):
             pass
@@ -284,10 +284,16 @@ def is_Module(x):
         sage: from sage.modules.module import is_Module
         sage: M = FreeModule(RationalField(),30)                                        # needs sage.modules
         sage: is_Module(M)                                                              # needs sage.modules
+        doctest:warning...
+        DeprecationWarning: the function is_Module is deprecated;
+        use 'isinstance(..., Module)' instead
+        See https://github.com/sagemath/sage/issues/37924 for details.
         True
         sage: is_Module(10)
         False
     """
+    from sage.misc.superseded import deprecation_cython
+    deprecation_cython(37924, "the function is_Module is deprecated; use 'isinstance(..., Module)' instead")
     return isinstance(x, Module)
 
 
@@ -305,15 +311,25 @@ def is_VectorSpace(x):
         sage: from sage.modules.module import is_Module, is_VectorSpace
         sage: M = FreeModule(RationalField(),30)
         sage: is_VectorSpace(M)
+        doctest:warning...
+        DeprecationWarning: the function is_VectorSpace is deprecated;
+        use 'isinstance(..., Module)' and check the base ring instead
+        See https://github.com/sagemath/sage/issues/37924 for details.
         True
         sage: M = FreeModule(IntegerRing(),30)
         sage: is_Module(M)
+        doctest:warning...
+        DeprecationWarning: the function is_Module is deprecated;
+        use 'isinstance(..., Module)' instead
+        See https://github.com/sagemath/sage/issues/37924 for details.
         True
         sage: is_VectorSpace(M)
         False
 
     """
+    from sage.misc.superseded import deprecation_cython
+    deprecation_cython(37924, "the function is_VectorSpace is deprecated; use 'isinstance(..., Module)' and check the base ring instead")
     try:
-        return is_Module(x) and x.base_ring().is_field()
+        return isinstance(x, Module) and x.base_ring().is_field()
     except AttributeError:
         return False
diff --git a/src/sage/modules/vector_space_homspace.py b/src/sage/modules/vector_space_homspace.py
index 475e70ed00f..bfbcae9ade0 100644
--- a/src/sage/modules/vector_space_homspace.py
+++ b/src/sage/modules/vector_space_homspace.py
@@ -221,6 +221,10 @@ def is_VectorSpaceHomspace(x):
         sage: type(H)
         
         sage: sage.modules.vector_space_homspace.is_VectorSpaceHomspace(H)
+        doctest:warning...
+        DeprecationWarning: the function is_VectorSpaceHomspace is deprecated;
+        use 'isinstance(..., VectorSpaceHomspace)' instead
+        See https://github.com/sagemath/sage/issues/37924 for details.
         True
 
         sage: K = Hom(QQ^3, ZZ^2)
@@ -238,6 +242,8 @@ def is_VectorSpaceHomspace(x):
         sage: sage.modules.vector_space_homspace.is_VectorSpaceHomspace('junk')
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37924, "the function is_VectorSpaceHomspace is deprecated; use 'isinstance(..., VectorSpaceHomspace)' instead")
     return isinstance(x, VectorSpaceHomspace)
 
 
diff --git a/src/sage/modules/vector_space_morphism.py b/src/sage/modules/vector_space_morphism.py
index dba263de586..c981acc8d67 100644
--- a/src/sage/modules/vector_space_morphism.py
+++ b/src/sage/modules/vector_space_morphism.py
@@ -696,7 +696,7 @@ def linear_transformation(arg0, arg1=None, arg2=None, side='left'):
     from sage.categories.homset import Hom
     from sage.matrix.constructor import matrix
     from sage.modules.free_module import VectorSpace
-    from sage.modules.module import is_VectorSpace
+    from sage.modules.module import Module
     try:
         from sage.modules.vector_callable_symbolic_dense import (
             Vector_callable_symbolic_dense,
@@ -706,8 +706,6 @@ def linear_transformation(arg0, arg1=None, arg2=None, side='left'):
 
     if side not in ['left', 'right']:
         raise ValueError("side must be 'left' or 'right', not {}".format(side))
-    if not (is_Matrix(arg0) or is_VectorSpace(arg0)):
-        raise TypeError('first argument must be a matrix or a vector space, not {}'.format(arg0))
     if is_Matrix(arg0):
         R = arg0.base_ring()
         if not R.is_field():
@@ -722,14 +720,15 @@ def linear_transformation(arg0, arg1=None, arg2=None, side='left'):
         arg2 = arg0
         arg0 = VectorSpace(R, arg2.nrows())
         arg1 = VectorSpace(R, arg2.ncols())
-    elif is_VectorSpace(arg0):
-        if not is_VectorSpace(arg1):
+    elif isinstance(arg0, Module) and arg0.base_ring().is_field():
+        if not (isinstance(arg1, Module) and arg1.base_ring().is_field()):
             msg = 'if first argument is a vector space, then second argument must be a vector space, not {0}'
             raise TypeError(msg.format(arg1))
         if arg0.base_ring() != arg1.base_ring():
             msg = 'vector spaces must have the same field of scalars, not {0} and {1}'
             raise TypeError(msg.format(arg0.base_ring(), arg1.base_ring()))
-
+    else:
+        raise TypeError('first argument must be a matrix or a vector space, not {}'.format(arg0))
     # Now arg0 = domain D, arg1 = codomain C, and
     #   both are vector spaces with common field of scalars
     #   use these to make a VectorSpaceHomSpace
@@ -869,7 +868,7 @@ def __init__(self, homspace, A, side="left"):
             sage: type(rho)
             
         """
-        if not vector_space_homspace.is_VectorSpaceHomspace(homspace):
+        if not isinstance(homspace, vector_space_homspace.VectorSpaceHomspace):
             raise TypeError('homspace must be a vector space hom space, not {}'.format(homspace))
         if isinstance(A, matrix_morphism.MatrixMorphism):
             A = A.matrix()
diff --git a/src/sage/modules/with_basis/indexed_element.pyx b/src/sage/modules/with_basis/indexed_element.pyx
index 1e8c8d9fb75..63c4ffaf485 100644
--- a/src/sage/modules/with_basis/indexed_element.pyx
+++ b/src/sage/modules/with_basis/indexed_element.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 An element in an indexed free module
 
diff --git a/src/sage/monoids/all.py b/src/sage/monoids/all.py
index cd2812c89f1..7b4543dd34c 100644
--- a/src/sage/monoids/all.py
+++ b/src/sage/monoids/all.py
@@ -1,11 +1,11 @@
 
-from .free_monoid import FreeMonoid
-from .string_monoid import (BinaryStrings, OctalStrings, HexadecimalStrings,
-                            Radix64Strings, AlphabeticStrings)
+from sage.monoids.free_monoid import FreeMonoid
+from sage.monoids.string_monoid import (BinaryStrings, OctalStrings, HexadecimalStrings,
+                                        Radix64Strings, AlphabeticStrings)
 
-from .free_abelian_monoid import FreeAbelianMonoid
+from sage.monoids.free_abelian_monoid import FreeAbelianMonoid
 
-from .string_ops import (
+from sage.monoids.string_ops import (
     strip_encoding,
     frequency_distribution,
     coincidence_index,
diff --git a/src/sage/numerical/interactive_simplex_method.py b/src/sage/numerical/interactive_simplex_method.py
index c2a10d6a4f6..2da9fa85057 100644
--- a/src/sage/numerical/interactive_simplex_method.py
+++ b/src/sage/numerical/interactive_simplex_method.py
@@ -197,12 +197,13 @@
 from sage.misc.lazy_import import lazy_import
 lazy_import("sage.plot.all", ["Graphics", "arrow", "line", "point", "rainbow", "text"])
 from sage.rings.infinity import Infinity
+from sage.rings.polynomial.polynomial_ring import polygen
 from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
+from sage.rings.polynomial.polynomial_element import Polynomial
 from sage.rings.rational_field import QQ
 from sage.rings.real_double import RDF
 from sage.rings.integer_ring import ZZ
 from sage.structure.all import SageObject
-from sage.symbolic.ring import SR
 
 
 # We produce rather complicated LaTeX code which needs some tweaks to be
@@ -316,8 +317,10 @@ def _latex_product(coefficients, variables,
             t = latex(v)
         else:
             t = latex(c)
-            if SR(c).operator() in [operator.add, operator.sub]:
-                t = r"\left( " + t + r" \right)"
+            if '+' in t or '-' in t:
+                from sage.symbolic.ring import SR
+                if SR(c).operator() in [operator.add, operator.sub]:
+                    t = r"\left( " + t + r" \right)"
             t += " " + latex(v)
         entries.extend([sign, t])
     if drop_plus:   # Don't start with +
@@ -1840,7 +1843,7 @@ def standard_form(self, transformation=False, **kwds):
             x = newx
             f = newf
 
-        objective_name = SR(kwds.get("objective_name", default_variable_name(
+        objective_name = polygen(ZZ, kwds.get("objective_name", default_variable_name(
             "primal objective" if self.is_primal() else "dual objective")))
         is_negative = self._is_negative
         constant_term = self._constant_term
@@ -1849,7 +1852,7 @@ def standard_form(self, transformation=False, **kwds):
             c = - c
             constant_term = - constant_term
             objective_name = - objective_name
-        kwds["objective_name"] = objective_name
+        kwds["objective_name"] = objective_name  # polynomial, no longer a string
         kwds["problem_type"] = "-max" if is_negative else "max"
         kwds["is_primal"] = self.is_primal()
         kwds["objective_constant_term"] = constant_term
@@ -2016,7 +2019,10 @@ def __init__(self, A, b, c, x="x", problem_type="max",
         if objective_name is None:
             objective_name = default_variable_name(
                 "primal objective" if is_primal else "dual objective")
-        self._objective_name = SR(objective_name)
+        if isinstance(objective_name, Polynomial):
+            self._objective_name = objective_name
+        else:
+            self._objective_name = polygen(ZZ, objective_name)
 
     @staticmethod
     def random_element(m, n, bound=5, special_probability=0.2,
@@ -3904,7 +3910,7 @@ def __init__(self, A, b, c, objective_value,
         c = copy(c)
         B = vector(basic_variables)
         N = vector(nonbasic_variables)
-        self._AbcvBNz = [A, b, c, objective_value, B, N, SR(objective_name)]
+        self._AbcvBNz = [A, b, c, objective_value, B, N, polygen(ZZ, objective_name)]
 
     @staticmethod
     def random_element(m, n, bound=5, special_probability=0.2):
diff --git a/src/sage/numerical/linear_tensor.py b/src/sage/numerical/linear_tensor.py
index 2402845b896..217bd98f3bb 100644
--- a/src/sage/numerical/linear_tensor.py
+++ b/src/sage/numerical/linear_tensor.py
@@ -269,8 +269,8 @@ def is_vector_space(self):
             sage: LF.tensor(RDF^(2,2)).is_vector_space()
             False
         """
-        from sage.modules.free_module import is_FreeModule
-        return is_FreeModule(self.free_module())
+        from sage.modules.free_module import FreeModule_generic
+        return isinstance(self.free_module(), FreeModule_generic)
 
     def is_matrix_space(self):
         """
@@ -290,8 +290,8 @@ def is_matrix_space(self):
             sage: LF.tensor(RDF^(2,2)).is_matrix_space()
             True
         """
-        from sage.matrix.matrix_space import is_MatrixSpace
-        return is_MatrixSpace(self.free_module())
+        from sage.matrix.matrix_space import MatrixSpace
+        return isinstance(self.free_module(), MatrixSpace)
 
     def linear_functions(self):
         """
diff --git a/src/sage/parallel/all.py b/src/sage/parallel/all.py
index 85f69c86165..dbb6ba2c851 100644
--- a/src/sage/parallel/all.py
+++ b/src/sage/parallel/all.py
@@ -1,4 +1,5 @@
 
-from .decorate import parallel, fork
+from sage.parallel.decorate import parallel, fork
 from sage.misc.lazy_import import lazy_import
 lazy_import('sage.parallel.parallelism', 'Parallelism')
+del lazy_import
diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
index 2765764cddf..edc93f06058 100644
--- a/src/sage/parallel/map_reduce.py
+++ b/src/sage/parallel/map_reduce.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Parallel computations using RecursivelyEnumeratedSet and Map-Reduce
 
diff --git a/src/sage/plot/all.py b/src/sage/plot/all.py
index 1f16e2d6789..565aa748be4 100644
--- a/src/sage/plot/all.py
+++ b/src/sage/plot/all.py
@@ -1,39 +1,39 @@
-from .graphics import Graphics
-from .plot import (plot, graphics_array, multi_graphics, list_plot,
-                   parametric_plot, polar_plot, plot_loglog, plot_semilogx,
-                   plot_semilogy, list_plot_loglog, list_plot_semilogx,
-                   list_plot_semilogy)
-from .line import line, line2d
-from .arrow import arrow, arrow2d
-from .bar_chart import bar_chart
-from .histogram import histogram
-from .bezier_path import bezier_path
-from .scatter_plot import scatter_plot
-from .disk import disk
-from .point import point, points, point2d
-from .matrix_plot import matrix_plot
-from .plot_field import plot_vector_field, plot_slope_field
-from .text import text
-from .polygon import polygon, polygon2d
-from .circle import circle
-from .ellipse import ellipse
-from .contour_plot import contour_plot, implicit_plot, region_plot
-from .density_plot import density_plot
-from .streamline_plot import streamline_plot
+from sage.plot.graphics import Graphics
+from sage.plot.plot import (plot, graphics_array, multi_graphics, list_plot,
+                            parametric_plot, polar_plot, plot_loglog, plot_semilogx,
+                            plot_semilogy, list_plot_loglog, list_plot_semilogx,
+                            list_plot_semilogy)
+from sage.plot.line import line, line2d
+from sage.plot.arrow import arrow, arrow2d
+from sage.plot.bar_chart import bar_chart
+from sage.plot.histogram import histogram
+from sage.plot.bezier_path import bezier_path
+from sage.plot.scatter_plot import scatter_plot
+from sage.plot.disk import disk
+from sage.plot.point import point, points, point2d
+from sage.plot.matrix_plot import matrix_plot
+from sage.plot.plot_field import plot_vector_field, plot_slope_field
+from sage.plot.text import text
+from sage.plot.polygon import polygon, polygon2d
+from sage.plot.circle import circle
+from sage.plot.ellipse import ellipse
+from sage.plot.contour_plot import contour_plot, implicit_plot, region_plot
+from sage.plot.density_plot import density_plot
+from sage.plot.streamline_plot import streamline_plot
 
 from sage.misc.lazy_import import lazy_import
-lazy_import("sage.plot.complex_plot",["complex_plot"])
+lazy_import("sage.plot.complex_plot", ["complex_plot"])
 
-from .arc import arc
+from sage.plot.arc import arc
 
-from .animate import animate
+from sage.plot.animate import animate
 
-from .plot3d.tachyon import Tachyon
+from sage.plot.plot3d.tachyon import Tachyon
 
-from .colors import Color, hue, rainbow, colors, colormaps
+from sage.plot.colors import Color, hue, rainbow, colors, colormaps
 
-from .step import plot_step_function
+from sage.plot.step import plot_step_function
 
-from .hyperbolic_arc import hyperbolic_arc
-from .hyperbolic_polygon import hyperbolic_triangle, hyperbolic_polygon
+from sage.plot.hyperbolic_arc import hyperbolic_arc
+from sage.plot.hyperbolic_polygon import hyperbolic_triangle, hyperbolic_polygon
 lazy_import("sage.plot.hyperbolic_regular_polygon", "hyperbolic_regular_polygon")
diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
index f22ae6756f8..258a6ca7047 100644
--- a/src/sage/plot/graphics.py
+++ b/src/sage/plot/graphics.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Graphics objects
 
diff --git a/src/sage/plot/plot3d/all.py b/src/sage/plot/plot3d/all.py
index 16c647c6b50..1fc801284f5 100644
--- a/src/sage/plot/plot3d/all.py
+++ b/src/sage/plot/plot3d/all.py
@@ -1,21 +1,22 @@
 
-from .plot3d            import plot3d, cylindrical_plot3d, spherical_plot3d, Spherical, SphericalElevation, Cylindrical
-from .parametric_plot3d import parametric_plot3d
-from .plot_field3d      import plot_vector_field3d
+from sage.plot.plot3d.plot3d import plot3d, cylindrical_plot3d, spherical_plot3d, Spherical, SphericalElevation, Cylindrical
+from sage.plot.plot3d.parametric_plot3d import parametric_plot3d
+from sage.plot.plot3d.plot_field3d import plot_vector_field3d
 
 # We lazy_import the following modules since they import numpy which slows down sage startup
 from sage.misc.lazy_import import lazy_import
-lazy_import("sage.plot.plot3d.implicit_plot3d",["implicit_plot3d"])
+lazy_import("sage.plot.plot3d.implicit_plot3d", ["implicit_plot3d"])
 
-from .list_plot3d       import list_plot3d
-from .revolution_plot3d import revolution_plot3d
+from sage.plot.plot3d.list_plot3d import list_plot3d
+from sage.plot.plot3d.revolution_plot3d import revolution_plot3d
 
-from .platonic          import tetrahedron, cube, octahedron, dodecahedron, icosahedron
+from sage.plot.plot3d.platonic import tetrahedron, cube, octahedron, dodecahedron, icosahedron
 
-from .shapes2           import sphere, line3d, polygon3d, polygons3d, point3d, text3d, bezier3d
+from sage.plot.plot3d.shapes2 import sphere, line3d, polygon3d, polygons3d, point3d, text3d, bezier3d
 
-from .shapes            import arrow3d
+from sage.plot.plot3d.shapes import arrow3d
 
-#from shapes import Box, ColorCube, Cone, Cylinder, LineSegment, Arrow, Sphere, Torus, Text as Text3D
-#from parametric_surface import ParametricSurface, MoebiusStrip
-#from plot3d import plot3d, axes as axes3d
+# from shapes import Box, ColorCube, Cone, Cylinder, LineSegment, Arrow, Sphere, Torus, Text as Text3D
+# from parametric_surface import ParametricSurface, MoebiusStrip
+# from plot3d import plot3d, axes as axes3d
+del lazy_import
diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx
index 66694f47a5f..4e35377bc25 100644
--- a/src/sage/plot/plot3d/base.pyx
+++ b/src/sage/plot/plot3d/base.pyx
@@ -983,7 +983,6 @@ cdef class Graphics3d(SageObject):
 
 """%(self.viewpoint().x3d_str(), self.x3d_str())
 
-
     ################ TACHYON ################
 
     ####### insertion of camera parameters
@@ -3370,6 +3369,7 @@ def optimal_extra_kwds(v):
         a.update(b)
     return a
 
+
 def _flip_orientation(v):
     """
     Switch from LH to RH coords to be consistent with Java rendition
@@ -3380,4 +3380,4 @@ def _flip_orientation(v):
             sage: _flip_orientation((1, 2, 3))
             (1, -2, 3)
     """
-    return (v[0],-v[1],v[2])
+    return (v[0], -v[1], v[2])
diff --git a/src/sage/plot/plot3d/index_face_set.pyx b/src/sage/plot/plot3d/index_face_set.pyx
index 4288db70005..4f84c73c8f4 100644
--- a/src/sage/plot/plot3d/index_face_set.pyx
+++ b/src/sage/plot/plot3d/index_face_set.pyx
@@ -197,6 +197,7 @@ cdef inline format_pmesh_face(face_c face, int has_color):
     # PyBytes_FromFormat is almost twice as slow
     return bytes_to_str(PyBytes_FromStringAndSize(ss, r))
 
+
 def midpoint(pointa, pointb, w):
     """
     Return the weighted mean of two points in 3-space.
diff --git a/src/sage/plot/plot3d/transform.pyx b/src/sage/plot/plot3d/transform.pyx
index ad9aae98278..060d5a7d3cd 100644
--- a/src/sage/plot/plot3d/transform.pyx
+++ b/src/sage/plot/plot3d/transform.pyx
@@ -104,7 +104,6 @@ cdef class Transformation:
             point_c_upper_bound(&upper, upper, res)
         return (lower.x, lower.y, lower.z), (upper.x, upper.y, upper.z)
 
-
     cdef void transform_point_c(self, point_c* res, point_c P) noexcept:
         point_c_transform(res, self._matrix_data, P)
 
diff --git a/src/sage/plot/point.py b/src/sage/plot/point.py
index 9377d2bec85..0c2a2897368 100644
--- a/src/sage/plot/point.py
+++ b/src/sage/plot/point.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Points
 
diff --git a/src/sage/probability/all.py b/src/sage/probability/all.py
index 689ee7a7934..646f3d5a2ad 100644
--- a/src/sage/probability/all.py
+++ b/src/sage/probability/all.py
@@ -1,9 +1,9 @@
 
-from .random_variable import (
-     DiscreteRandomVariable,
-     DiscreteProbabilitySpace )
+from sage.probability.random_variable import (
+    DiscreteRandomVariable,
+    DiscreteProbabilitySpace)
 
-from .probability_distribution import (
+from sage.probability.probability_distribution import (
     RealDistribution,
     SphericalDistribution,
-    GeneralDiscreteDistribution )
+    GeneralDiscreteDistribution)
diff --git a/src/sage/quadratic_forms/all.py b/src/sage/quadratic_forms/all.py
index 81d395f375c..5982c6b8a5a 100644
--- a/src/sage/quadratic_forms/all.py
+++ b/src/sage/quadratic_forms/all.py
@@ -1,19 +1,19 @@
-from .binary_qf import BinaryQF, BinaryQF_reduced_representatives
+from sage.quadratic_forms.binary_qf import BinaryQF, BinaryQF_reduced_representatives
 
-from .bqf_class_group import BQFClassGroup
+from sage.quadratic_forms.bqf_class_group import BQFClassGroup
 
-from .ternary_qf import TernaryQF, find_all_ternary_qf_by_level_disc, find_a_ternary_qf_by_level_disc
+from sage.quadratic_forms.ternary_qf import TernaryQF, find_all_ternary_qf_by_level_disc, find_a_ternary_qf_by_level_disc
 
-from .quadratic_form import QuadraticForm, DiagonalQuadraticForm, quadratic_form_from_invariants
+from sage.quadratic_forms.quadratic_form import QuadraticForm, DiagonalQuadraticForm, quadratic_form_from_invariants
 
-from .random_quadraticform import (random_quadraticform, random_quadraticform_with_conditions,
+from sage.quadratic_forms.random_quadraticform import (random_quadraticform, random_quadraticform_with_conditions,
                                    random_ternaryqf, random_ternaryqf_with_conditions)
 
-from .extras import least_quadratic_nonresidue, extend_to_primitive, is_triangular_number
+from sage.quadratic_forms.extras import least_quadratic_nonresidue, extend_to_primitive, is_triangular_number
 
-from .special_values import (gamma__exact, zeta__exact, QuadraticBernoulliNumber,
+from sage.quadratic_forms.special_values import (gamma__exact, zeta__exact, QuadraticBernoulliNumber,
                              quadratic_L_function__exact, quadratic_L_function__numerical)
 
-from .genera.genus import Genus
+from sage.quadratic_forms.genera.genus import Genus
 
-from .constructions import BezoutianQuadraticForm, HyperbolicPlane_quadratic_form
+from sage.quadratic_forms.constructions import BezoutianQuadraticForm, HyperbolicPlane_quadratic_form
diff --git a/src/sage/quadratic_forms/genera/all.py b/src/sage/quadratic_forms/genera/all.py
index b1f48b5b8f6..e92279814dd 100644
--- a/src/sage/quadratic_forms/genera/all.py
+++ b/src/sage/quadratic_forms/genera/all.py
@@ -5,4 +5,4 @@
 #
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
-from .genus import Genus, LocalGenusSymbol, is_GlobalGenus
+from sage.quadratic_forms.genera.genus import Genus, LocalGenusSymbol, is_GlobalGenus
diff --git a/src/sage/quivers/algebra_elements.pxi b/src/sage/quivers/algebra_elements.pxi
index 45d18478f60..e5ce6b3b0ac 100644
--- a/src/sage/quivers/algebra_elements.pxi
+++ b/src/sage/quivers/algebra_elements.pxi
@@ -32,8 +32,8 @@ cdef extern from *:  # Defined by Cython
     int likely(int) nogil
 
 ########################################
-##
-## Allocation and Deallocation of monomials
+#
+#  Allocation and Deallocation of monomials
 #
 # Monomials are expensive, hence, copying will just be done by increasing a
 # reference counter.
@@ -117,8 +117,8 @@ cdef bint mon_unpickle(path_mon_t out, tuple data) except -1:
 
 
 ########################################
-##
-## Monomial orders---we only use degree orders
+#
+#  Monomial orders---we only use degree orders
 
 # Negative degree reverse lexicographic ordering
 cdef int negdegrevlex(path_mon_t M1, path_mon_t M2) except -2:
@@ -128,7 +128,7 @@ cdef int negdegrevlex(path_mon_t M1, path_mon_t M2) except -2:
     # 3. deg(s_i) < deg(s_j), otherwise
     # 4. a*s_i*b <_revlex c*s_j*d, otherwise
     # 5. i deg(s_j), otherwise
     # 4. a*s_i*b <_revlex c*s_j*d, otherwise
     # 5. i deg(s_j), otherwise
     # 4. a*s_i*b <_lex c*s_j*d, otherwise
     # 5. icoef
-    #out.nxt = NULL  # to be taken care of externally
+    # out.nxt = NULL  # to be taken care of externally
     return out
 
 # Create a term with a given coefficient, but empty monomial
@@ -370,7 +370,7 @@ cdef path_term_t *term_create_blank(object coef) except NULL:
         out = check_malloc(sizeof(path_term_t))
     Py_INCREF(coef)
     out.coef = coef
-    #out.nxt = NULL  # to be taken care of externally
+    # out.nxt = NULL  # to be taken care of externally
     return out
 
 ######################################################################
@@ -429,8 +429,8 @@ cdef inline path_term_t *term_unpickle(object coef, tuple mon_data) except NULL:
     return out
 
 ########################################
-##
-## Multiplication of monomials
+#
+#  Multiplication of monomials
 
 # Return T*p, for a path p and a monomial T.
 cdef bint mon_mul_path(path_mon_t out, path_mon_t T, biseq_t p) except -1:
@@ -471,19 +471,20 @@ cdef bint path_mul_mon_mul_path(path_mon_t out, biseq_t p, path_mon_t T, biseq_t
     cdef mp_bitcnt_t pTsize = p.data.size+T.path.data.size
     sig_on()
     bitset_lshift(out.path.data, q.data, pTsize)
-    cdef mp_bitcnt_t p_offset = p.data.size%GMP_LIMB_BITS
+    cdef mp_bitcnt_t p_offset = p.data.size % GMP_LIMB_BITS
     # p_limbs gives the index of the limb that will store the first bit of the
     # shifted version of T.
     cdef mp_bitcnt_t p_limbs = (p.data.limbs - 1) if p_offset>0 else p.data.limbs
 
     # pT_limbs gives the index of the last limb used to store p+T
     cdef mp_bitcnt_t pT_limbs = (pTsize-1)//GMP_LIMB_BITS
-    if ((T.path.data.size-1)%GMP_LIMB_BITS)+p_offset >= GMP_LIMB_BITS:
+    if ((T.path.data.size-1) % GMP_LIMB_BITS) + p_offset >= GMP_LIMB_BITS:
         # We shift all limbs of T. The highest bits of the highest limbs are
         # pushed out and returned by mpn_lshift. We need to assign them to the
         # beginning of the last limb that is (partially) occupied by p+T
         out.path.data.bits[pT_limbs] |= mpn_lshift(out.path.data.bits+p_limbs,
-                                              T.path.data.bits, T.path.data.limbs, p_offset)
+                                                   T.path.data.bits,
+                                                   T.path.data.limbs, p_offset)
     else:
         if T.path.data.limbs>1:
             # If we would move all limbs of T, then the result would override
@@ -491,7 +492,9 @@ cdef bint path_mul_mon_mul_path(path_mon_t out, biseq_t p, path_mon_t T, biseq_t
             # but the last limb of T, assigning to the beginning of the last
             # limb of p+T the bits that have been pushed out.
             out.path.data.bits[pT_limbs] |= mpn_lshift(out.path.data.bits+p_limbs,
-                                                  T.path.data.bits, T.path.data.limbs-1, p_offset)
+                                                       T.path.data.bits,
+                                                       T.path.data.limbs-1,
+                                                       p_offset)
             # Last, we need to move the last limb of T (which is only
             # partially occupied), namely into the spot between the previously
             # moved parts of T and the beginning of the shifted copy of q.
@@ -502,7 +505,7 @@ cdef bint path_mul_mon_mul_path(path_mon_t out, biseq_t p, path_mon_t T, biseq_t
     sig_off()
 
 ########################################
-## Addition and scaling of terms
+#  Addition and scaling of terms
 
 # Return -T
 cdef path_term_t *term_neg(path_term_t *T) except NULL:
@@ -552,7 +555,7 @@ cdef path_term_t *term_scale(path_term_t *T, object coef) except NULL:
 
 # Return coef*T and recurse over T.nxt
 cdef path_term_t *term_scale_recursive(path_term_t *T, object coef) except NULL:
-    cdef path_term_t *out = term_scale(T,coef)
+    cdef path_term_t *out = term_scale(T, coef)
     cdef path_term_t *first = out
     T = T.nxt
     while T!=NULL:
@@ -617,8 +620,8 @@ cdef path_term_t *term_mul_term(path_term_t *T1, path_term_t *T2) except NULL:
     return out
 
 ########################################
-##
-## Basics for polynomials
+#
+#  Basics for polynomials
 
 # Create an empty polynomial
 cdef inline path_poly_t *poly_create() except NULL:
@@ -717,8 +720,8 @@ cdef bint poly_inplace_unpickle(path_poly_t *P, list data) except -1:
     return True
 
 ############################################
-##
-## Polynomial arithmetics
+#
+#  Polynomial arithmetics
 
 # Rich comparison of P1 and P2, using the given monomial ordering cmp_terms.
 # Return a boolean.
@@ -917,7 +920,7 @@ cdef path_poly_t *poly_add(path_poly_t *P1, path_poly_t *P2, path_order_t cmp_te
     cdef path_term_t *T2 = P2.lead
     cdef path_term_t *T = NULL
     cdef path_term_t *res
-    cdef size_t count1, count2 # How many terms of P1/P2 have been considered?
+    cdef size_t count1, count2  # How many terms of P1/P2 have been considered?
     count1 = 0
     count2 = 0
     cdef object coef
@@ -945,7 +948,7 @@ cdef path_poly_t *poly_add(path_poly_t *P1, path_poly_t *P2, path_order_t cmp_te
                 T.nxt = term_copy_recursive(T1)
             return out
 
-        c = cmp_terms(T1.mon,T2.mon)
+        c = cmp_terms(T1.mon, T2.mon)
         if c == 1:
             if T == NULL:
                 out.lead = term_copy(T1)
@@ -990,7 +993,7 @@ cdef path_poly_t *poly_sub(path_poly_t *P1, path_poly_t *P2, path_order_t cmp_te
     cdef path_term_t *T2 = P2.lead
     cdef path_term_t *T = NULL
     cdef path_term_t *res
-    cdef size_t count1, count2 # How many terms of P1/P2 have been considered?
+    cdef size_t count1, count2  # How many terms of P1/P2 have been considered?
     count1 = 0
     count2 = 0
     cdef object coef
@@ -1018,7 +1021,7 @@ cdef path_poly_t *poly_sub(path_poly_t *P1, path_poly_t *P2, path_order_t cmp_te
                 T.nxt = term_copy_recursive(T1)
             return out
 
-        c = cmp_terms(T1.mon,T2.mon)
+        c = cmp_terms(T1.mon, T2.mon)
         if c == 1:
             if T == NULL:
                 out.lead = term_copy(T1)
@@ -1054,8 +1057,8 @@ cdef path_poly_t *poly_sub(path_poly_t *P1, path_poly_t *P2, path_order_t cmp_te
             T1 = T1.nxt
             T2 = T2.nxt
 
-##
-## In-place addition of a multiple of a polynomial
+#
+#  In-place addition of a multiple of a polynomial
 # Replace P1 by P1+coef*P2*R. Return a pointer to the first term of P1
 # that may be involved in a change when calling the function again with
 # P1, P2 and a cofactor that is smaller than R wrt. cmp_terms.
@@ -1166,8 +1169,8 @@ cdef path_term_t *poly_iadd_lmul(path_poly_t *P1, object coef, path_poly_t *P2,
     return out
 
 ########################################
-##
-## Basics for homogeneous polynomials
+#
+#  Basics for homogeneous polynomials
 
 # Create an empty polynomial whose to-be-inserted terms
 # have start- and end-points of the given integer labels
@@ -1201,7 +1204,7 @@ cdef path_homog_poly_t *homog_poly_init_poly(int start, int end, path_poly_t *P)
 cdef path_homog_poly_t *homog_poly_init_list(int start, int end, list L, path_order_t cmp_terms, long pos) except NULL:
     cdef path_homog_poly_t * out = homog_poly_create(start, end)
     cdef QuiverPath P
-    for P,coef in L:
+    for P, coef in L:
         poly_iadd_term_d(out.poly, term_create(coef, P._path, pos, 0, 0), cmp_terms)
     return out
 
@@ -1241,7 +1244,7 @@ cdef list homog_poly_pickle(path_homog_poly_t *H):
 
 # De-linearisation
 cdef path_homog_poly_t *homog_poly_unpickle(list data) except NULL:
-    #ASSUMPTION: data is not empty
+    # ASSUMPTION: data is not empty
     cdef int start, end
     cdef list poly_data
     cdef path_homog_poly_t *out
diff --git a/src/sage/quivers/path_semigroup.py b/src/sage/quivers/path_semigroup.py
index 42ff7b0698e..860242334ba 100644
--- a/src/sage/quivers/path_semigroup.py
+++ b/src/sage/quivers/path_semigroup.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 """
 Path Semigroups
 """
diff --git a/src/sage/quivers/paths.pyx b/src/sage/quivers/paths.pyx
index aead99670ab..2f6dfc061b1 100644
--- a/src/sage/quivers/paths.pyx
+++ b/src/sage/quivers/paths.pyx
@@ -159,7 +159,7 @@ cdef class QuiverPath(MonoidElement):
         """
         MonoidElement.__init__(self, parent=parent)
         self._start = start
-        self._end   = end
+        self._end = end
         biseq_init_list(self._path, path, parent._nb_arrows)
 
     def __reduce__(self):
@@ -194,10 +194,10 @@ cdef class QuiverPath(MonoidElement):
         if h == -1:
             return -2
         return h
-        ## bitset_hash is not a good hash either
-        ## We should consider using FNV-1a hash, see http://www.isthe.com/chongo/tech/comp/fnv/,
-        ## Or the hash defined in http://burtleburtle.net/bob/hash/doobs.html
-        ## Or http://www.azillionmonkeys.com/qed/hash.html
+        # bitset_hash is not a good hash either
+        # We should consider using FNV-1a hash, see http://www.isthe.com/chongo/tech/comp/fnv/,
+        # Or the hash defined in http://burtleburtle.net/bob/hash/doobs.html
+        # Or http://www.azillionmonkeys.com/qed/hash.html
 
     def _repr_(self):
         r"""
@@ -429,7 +429,7 @@ cdef class QuiverPath(MonoidElement):
                 init = self._end
             if start < stop:
                 end = E[biseq_getitem(self._path, stop-1)][1]
-            else: # the result will be a path of length 0
+            else:  # the result will be a path of length 0
                 end = init
             OUT = self._new_(init, end)
             biseq_init_slice(OUT._path, self._path, start, stop, step)
@@ -500,7 +500,7 @@ cdef class QuiverPath(MonoidElement):
         if self._end != right._start:
             return None
         cdef QuiverPath OUT = self._new_(self._start, right._end)
-        biseq_init_concat(OUT._path, self._path,right._path)
+        biseq_init_concat(OUT._path, self._path, right._path)
         return OUT
 
     cpdef _mod_(self, other):
@@ -771,7 +771,7 @@ cdef class QuiverPath(MonoidElement):
         cdef QuiverPath out = QuiverPath.__new__(Q.element_class)
         out._parent = Q
         out._start = self._end
-        out._end   = self._start
+        out._end = self._start
         sig_check()
         biseq_init(out._path, self._path.length, self._path.itembitsize)
         cdef mp_size_t l = self._path.length - 1
diff --git a/src/sage/repl/attach.py b/src/sage/repl/attach.py
index 689759d50a8..f0d98d8a164 100644
--- a/src/sage/repl/attach.py
+++ b/src/sage/repl/attach.py
@@ -52,7 +52,7 @@
     Traceback (most recent call last):
     ...
         exec(code, globals)
-      File ".../foobar.sage....py", line ..., in 
+      File ".../foobar...sage.py", line ..., in 
         raise ValueError("third")   # this should appear in the source snippet...
     ValueError: third
     sage: detach(src)
@@ -67,16 +67,18 @@
 # (at your option) any later version.
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
+from __future__ import annotations
 
 import os
 import time
+from pathlib import Path
 from IPython.core.getipython import get_ipython
 
 from sage.repl.load import load, load_wrap
 import sage.repl.inputhook
 import sage.env
 
-# The attached files as a dict of {filename:mtime}
+# The attached files as a dict of {Path object:mtime}
 attached = {}
 
 
@@ -137,7 +139,7 @@ def load_attach_mode(load_debug=None, attach_debug=None):
         attach_debug_mode = attach_debug
 
 
-search_paths = []
+search_paths: list[Path] = []
 
 
 def load_attach_path(path=None, replace=False):
@@ -164,7 +166,7 @@ def load_attach_path(path=None, replace=False):
 
         sage: sage.repl.attach.reset(); reset_load_attach_path()
         sage: load_attach_path()
-        ['.']
+        [PosixPath('.')]
         sage: t_dir = tmp_dir()
         sage: fullpath = os.path.join(t_dir, 'test.py')
         sage: with open(fullpath, 'w') as f:
@@ -184,10 +186,13 @@ def load_attach_path(path=None, replace=False):
         sage: load_attach_path(t_dir)
         sage: attach('test.py')
         111
-        sage: attached_files() == [fullpath]
+        sage: af = attached_files(); len(af)
+        1
+        sage: af == [fullpath]
         True
+        sage: from pathlib import Path
         sage: sage.repl.attach.reset(); reset_load_attach_path()
-        sage: load_attach_path() == ['.']
+        sage: load_attach_path() == [Path('.')]
         True
         sage: with tempfile.TemporaryDirectory() as d:
         ....:     load_attach_path(d, replace=True)
@@ -199,33 +204,34 @@ def load_attach_path(path=None, replace=False):
     The function returns a reference to the path list::
 
         sage: reset_load_attach_path(); load_attach_path()
-        ['.']
+        [PosixPath('.')]
         sage: load_attach_path('/path/to/my/sage/scripts'); load_attach_path()
-        ['.', '/path/to/my/sage/scripts']
+        [PosixPath('.'), PosixPath('/path/to/my/sage/scripts')]
         sage: load_attach_path(['good', 'bad', 'ugly'], replace=True)
         sage: load_attach_path()
-        ['good', 'bad', 'ugly']
+        [PosixPath('good'), PosixPath('bad'), PosixPath('ugly')]
         sage: p = load_attach_path(); p.pop()
-        'ugly'
+        PosixPath('ugly')
         sage: p[0] = 'weird'; load_attach_path()
-        ['weird', 'bad']
+        ['weird', PosixPath('bad')]
         sage: reset_load_attach_path(); load_attach_path()
-        ['.']
+        [PosixPath('.')]
     """
     global search_paths
     if path is None:
         return search_paths
+
+    if not isinstance(path, list):
+        path = [Path(path)]
+    if replace:
+        search_paths = [Path(p) for p in path]
     else:
-        if not isinstance(path, list):
-            path = [path]
-        if replace:
-            search_paths = path
-        else:
-            for p in path:
-                if not p:
-                    continue
-                if p not in search_paths:
-                    search_paths.append(p)
+        for p in path:
+            if not p:
+                continue
+            as_path = Path(p)
+            if as_path not in search_paths:
+                search_paths.append(as_path)
 
 
 def reset_load_attach_path():
@@ -238,33 +244,34 @@ def reset_load_attach_path():
     EXAMPLES::
 
         sage: load_attach_path()
-        ['.']
+        [PosixPath('.')]
         sage: t_dir = tmp_dir()
         sage: load_attach_path(t_dir)
-        sage: t_dir in load_attach_path()
+        sage: from pathlib import Path
+        sage: Path(t_dir) in load_attach_path()
         True
         sage: reset_load_attach_path(); load_attach_path()
-        ['.']
+        [PosixPath('.')]
 
     At startup, Sage adds colon-separated paths in the environment
     variable ``SAGE_LOAD_ATTACH_PATH``::
 
         sage: reset_load_attach_path(); load_attach_path()
-        ['.']
+        [PosixPath('.')]
         sage: os.environ['SAGE_LOAD_ATTACH_PATH'] = '/veni/vidi:vici:'
         sage: from importlib import reload
         sage: reload(sage.repl.attach)    # Simulate startup
         
         sage: load_attach_path()
-        ['.', '/veni/vidi', 'vici']
+        [PosixPath('.'), PosixPath('/veni/vidi'), PosixPath('vici')]
         sage: del os.environ['SAGE_LOAD_ATTACH_PATH']
         sage: reload(sage.repl.preparse)    # Simulate startup
         
         sage: reset_load_attach_path(); load_attach_path()
-        ['.']
+        [PosixPath('.')]
     """
     global search_paths
-    search_paths = ['.']
+    search_paths = [Path()]
     for path in os.environ.get('SAGE_LOAD_ATTACH_PATH', '').split(':'):
         load_attach_path(path=path)
 
@@ -332,7 +339,9 @@ def attach(*files):
         sage: attach(t1, t2)
         hello world
         hi there xxx
-        sage: set(attached_files()) == set([t1,t2])
+        sage: af = attached_files(); len(af)
+        2
+        sage: t1 in af and t2 in af
         True
 
     .. SEEALSO::
@@ -370,7 +379,8 @@ def add_attached_file(filename):
 
     INPUT:
 
-    - ``filename`` -- string, the fully qualified file name.
+    - ``filename`` -- string (the fully qualified file name)
+      or :class:`Path` object
 
     EXAMPLES::
 
@@ -385,13 +395,13 @@ def add_attached_file(filename):
         []
     """
     sage.repl.inputhook.install()
-    fpath = os.path.abspath(filename)
-    attached[fpath] = os.path.getmtime(fpath)
+    fpath = Path(filename).absolute()
+    attached[fpath] = fpath.stat().st_mtime
 
 
-def attached_files():
+def attached_files() -> list:
     """
-    Returns a list of all files attached to the current session with
+    Return a list of all files attached to the current session with
     :meth:`attach`.
 
     OUTPUT:
@@ -405,13 +415,13 @@ def attached_files():
         sage: with open(t,'w') as f: _ = f.write("print('hello world')")
         sage: attach(t)
         hello world
-        sage: attached_files()
+        sage: af = attached_files(); af
         ['/....py']
-        sage: attached_files() == [t]
+        sage: af == [t]
         True
     """
     global attached
-    return sorted(attached)
+    return sorted(str(f) for f in attached)
 
 
 def detach(filename):
@@ -422,7 +432,8 @@ def detach(filename):
 
     INPUT:
 
-    - ``filename`` -- a string, or a list of strings, or a tuple of strings.
+    - ``filename`` -- a string, a list of strings or a tuple of strings
+      or a :class:`Path`, a list of :class:`Path` or a tuple of :class:`Path`
 
     EXAMPLES::
 
@@ -431,7 +442,9 @@ def detach(filename):
         sage: with open(t,'w') as f: _ = f.write("print('hello world')")
         sage: attach(t)
         hello world
-        sage: attached_files() == [t]
+        sage: af = attached_files(); len(af)
+        1
+        sage: af == [t]
         True
         sage: detach(t)
         sage: attached_files()
@@ -439,14 +452,16 @@ def detach(filename):
 
         sage: sage.repl.attach.reset(); reset_load_attach_path()
         sage: load_attach_path()
-        ['.']
+        [PosixPath('.')]
         sage: t_dir = tmp_dir()
         sage: fullpath = os.path.join(t_dir, 'test.py')
         sage: with open(fullpath, 'w') as f: _ = f.write("print(37 * 3)")
         sage: load_attach_path(t_dir, replace=True)
         sage: attach('test.py')
         111
-        sage: attached_files() == [os.path.normpath(fullpath)]
+        sage: af = attached_files(); len(af)
+        1
+        sage: af == [os.path.normpath(fullpath)]
         True
         sage: detach('test.py')
         sage: attached_files()
@@ -469,22 +484,24 @@ def detach(filename):
         ValueError: file '/dev/null/foobar.sage' is not attached, see attached_files()
     """
     if isinstance(filename, str):
-        filelist = [filename]
+        filelist = [Path(filename)]
     else:
-        filelist = [str(x) for x in filename]
+        filelist = [Path(x) for x in filename]
 
     global attached
     for filename in filelist:
-        fpath = os.path.expanduser(filename)
-        if not os.path.isabs(fpath):
+        fpath = filename.expanduser()
+        if not fpath.is_absolute():
             for path in load_attach_path():
-                epath = os.path.expanduser(path)
-                fpath = os.path.join(epath, filename)
-                fpath = os.path.abspath(fpath)
+                fpath = path.expanduser() / filename
+                fpath = fpath.absolute()
                 if fpath in attached:
                     break
+        abs_fpath = fpath.absolute()
         if fpath in attached:
             attached.pop(fpath)
+        elif abs_fpath in attached:
+            attached.pop(abs_fpath)
         else:
             raise ValueError("file '{0}' is not attached, see attached_files()".format(filename))
     if not attached:
@@ -502,7 +519,9 @@ def reset():
         sage: with open(t,'w') as f: _ = f.write("print('hello world')")
         sage: attach(t)
         hello world
-        sage: attached_files() == [t]
+        sage: af = attached_files(); len(af)
+        1
+        sage: af == [t]
         True
         sage: sage.repl.attach.reset()
         sage: attached_files()
@@ -514,7 +533,7 @@ def reset():
 
 def modified_file_iterator():
     """
-    Iterate over the changed files
+    Iterate over the changed files.
 
     As a side effect the stored time stamps are updated with the
     actual time stamps. So if you iterate over the attached files in
@@ -534,17 +553,17 @@ def modified_file_iterator():
         sage: sleep(1)   # filesystem mtime granularity
         sage: with open(t, 'w') as f: _ = f.write('1')
         sage: list(modified_file_iterator())
-        [('/.../tmp_....py', time.struct_time(...))]
+        [(PosixPath('/.../tmp_....py'), time.struct_time(...))]
     """
     global attached
     modified = {}
     for filename in list(attached):
         old_tm = attached[filename]
-        if not os.path.exists(filename):
+        if not filename.exists():
             print('### detaching file {0} because it does not exist (deleted?) ###'.format(filename))
             detach(filename)
             continue
-        new_tm = os.path.getmtime(filename)
+        new_tm = filename.stat().st_mtime
         if new_tm > old_tm:
             modified[filename] = new_tm
 
@@ -554,7 +573,7 @@ def modified_file_iterator():
 
     for filename in list(modified):
         old_tm = modified[filename]
-        new_tm = os.path.getmtime(filename)
+        new_tm = filename.stat().st_mtime
         if new_tm == old_tm:
             # file was modified but did not change in the last 100ms
             attached[filename] = new_tm
@@ -563,7 +582,7 @@ def modified_file_iterator():
 
 def reload_attached_files_if_modified():
     r"""
-    Reload attached files that have been modified
+    Reload attached files that have been modified.
 
     This is the internal implementation of the attach mechanism.
 
@@ -597,7 +616,7 @@ def reload_attached_files_if_modified():
     """
     ip = get_ipython()
     for filename, mtime in modified_file_iterator():
-        basename = os.path.basename(filename)
+        basename = filename.name
         timestr = time.strftime('%T', mtime)
         notice = '### reloading attached file {0} modified at {1} ###'.format(basename, timestr)
         if ip:
diff --git a/src/sage/repl/display/fancy_repr.py b/src/sage/repl/display/fancy_repr.py
index 1cfaf94c45f..50b5261bbe8 100644
--- a/src/sage/repl/display/fancy_repr.py
+++ b/src/sage/repl/display/fancy_repr.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Representations of objects
 """
diff --git a/src/sage/repl/display/formatter.py b/src/sage/repl/display/formatter.py
index 822a9edfaba..dc1e6c06024 100644
--- a/src/sage/repl/display/formatter.py
+++ b/src/sage/repl/display/formatter.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 IPython Displayhook Formatters
 
diff --git a/src/sage/repl/display/pretty_print.py b/src/sage/repl/display/pretty_print.py
index 95a5f86a520..7ecaa1bde45 100644
--- a/src/sage/repl/display/pretty_print.py
+++ b/src/sage/repl/display/pretty_print.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 The Sage pretty printer
 
diff --git a/src/sage/repl/display/util.py b/src/sage/repl/display/util.py
index a2033c69f4f..14b243ee742 100644
--- a/src/sage/repl/display/util.py
+++ b/src/sage/repl/display/util.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Utility functions for pretty-printing
 
diff --git a/src/sage/repl/image.py b/src/sage/repl/image.py
index c9b2001b016..172d1bba7cc 100644
--- a/src/sage/repl/image.py
+++ b/src/sage/repl/image.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 """
 Sage Wrapper for Bitmap Images
 
diff --git a/src/sage/repl/ipython_kernel/all_jupyter.py b/src/sage/repl/ipython_kernel/all_jupyter.py
index 37899e1c080..3e6eca3e004 100644
--- a/src/sage/repl/ipython_kernel/all_jupyter.py
+++ b/src/sage/repl/ipython_kernel/all_jupyter.py
@@ -4,6 +4,6 @@
 
 from sage.all_cmdline import *
 
-from .widgets_sagenb import (input_box, text_control, slider,
-        range_slider, checkbox, selector, input_grid, color_selector)
-from .interact import interact
+from sage.repl.ipython_kernel.widgets_sagenb import (input_box, text_control, slider,
+                                                     range_slider, checkbox, selector, input_grid, color_selector)
+from sage.repl.ipython_kernel.interact import interact
diff --git a/src/sage/repl/ipython_kernel/interact.py b/src/sage/repl/ipython_kernel/interact.py
index c9c3d627657..884fba367e8 100644
--- a/src/sage/repl/ipython_kernel/interact.py
+++ b/src/sage/repl/ipython_kernel/interact.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Interacts for the Sage Jupyter notebook
 
diff --git a/src/sage/repl/ipython_kernel/kernel.py b/src/sage/repl/ipython_kernel/kernel.py
index 72938a799ff..7ce23a83f02 100644
--- a/src/sage/repl/ipython_kernel/kernel.py
+++ b/src/sage/repl/ipython_kernel/kernel.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 The Sage ZMQ Kernel
 
@@ -108,14 +107,13 @@ def help_links(self):
         # src/bin/sage-notebook.
 
         from sage.env import SAGE_DOC_SERVER_URL
+        from sage.env import SAGE_DOC_LOCAL_PORT as port
         from sage.features.sagemath import sagemath_doc_html
 
         if SAGE_DOC_SERVER_URL:
             def doc_url(path):
                 return f'{SAGE_DOC_SERVER_URL}/{path}'
-        elif sagemath_doc_html().is_present():
-            from sage.env import SAGE_DOC_LOCAL_PORT as port
-
+        elif sagemath_doc_html().is_present() and int(port):
             def doc_url(path):
                 return f'http://127.0.0.1:{port}/{path}'
         else:
diff --git a/src/sage/repl/ipython_kernel/widgets_sagenb.py b/src/sage/repl/ipython_kernel/widgets_sagenb.py
index cedf713248a..61302dc4b7a 100644
--- a/src/sage/repl/ipython_kernel/widgets_sagenb.py
+++ b/src/sage/repl/ipython_kernel/widgets_sagenb.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Functions to construct widgets, based on the old SageNB interface.
 
diff --git a/src/sage/repl/load.py b/src/sage/repl/load.py
index b0f4a269242..2d93214cc12 100644
--- a/src/sage/repl/load.py
+++ b/src/sage/repl/load.py
@@ -10,8 +10,8 @@
 # (at your option) any later version.
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
-import os
 import base64
+from pathlib import Path
 
 from sage.cpython.string import str_to_bytes, bytes_to_str, FS_ENCODING
 
@@ -28,7 +28,7 @@ def is_loadable_filename(filename):
 
     INPUT:
 
-    - ``filename`` -- a string
+    - ``filename`` -- a string or :class:`Path` object
 
     OUTPUT:
 
@@ -46,8 +46,12 @@ def is_loadable_filename(filename):
         True
         sage: sage.repl.load.is_loadable_filename('foo.m')
         True
+
+        sage: from pathlib import Path
+        sage: sage.repl.load.is_loadable_filename(Path('foo.py'))
+        True
     """
-    ext = os.path.splitext(filename)[1].lower()
+    ext = Path(filename).suffix.lower()
     return ext in ('.py', '.pyx', '.sage', '.spyx', '.f', '.f90', '.m')
 
 
@@ -65,10 +69,10 @@ def load_cython(name):
       module.
     """
     from sage.misc.cython import cython
-    mod, dir = cython(name, compile_message=True, use_cache=True)
+    mod, dir = cython(str(name), compile_message=True, use_cache=True)
     import sys
     sys.path.append(dir)
-    return 'from {} import *'.format(mod)
+    return f'from {mod} import *'
 
 
 def load(filename, globals, attach=False):
@@ -86,12 +90,12 @@ def load(filename, globals, attach=False):
 
     INPUT:
 
-    - ``filename`` -- a string denoting a filename or URL.
+    - ``filename`` -- a string (denoting a filename or URL) or a :class:`Path` object
 
     - ``globals`` -- a string:object dictionary; the context in which
       to execute the file contents.
 
-    - ``attach`` -- a boolean (default: False); whether to add the
+    - ``attach`` -- a boolean (default: ``False``); whether to add the
       file to the list of attached files.
 
     Loading an executable Sage script from the command prompt will run whatever
@@ -138,7 +142,7 @@ def load(filename, globals, attach=False):
         sage: z
         -7
 
-    If the file is not a Cython, Python, or Sage file, a ``ValueError``
+    If the file is not a Cython, Python, or Sage file, a :class:`ValueError`
     is raised::
 
         sage: sage.repl.load.load(tmp_filename(ext=".foo"), globals())
@@ -180,7 +184,7 @@ def load(filename, globals, attach=False):
         sage: import tempfile
         sage: sage.repl.attach.reset(); reset_load_attach_path()
         sage: load_attach_path()
-        ['.']
+        [PosixPath('.')]
         sage: with tempfile.TemporaryDirectory() as t_dir:
         ....:     fname = 'test.py'
         ....:     fullpath = os.path.join(t_dir, fname)
@@ -224,31 +228,30 @@ def load(filename, globals, attach=False):
         # rest of this functions operate on filename as a str
         filename = bytes_to_str(filename, FS_ENCODING, 'surrogateescape')
 
-    filename = os.path.expanduser(filename)
-
-    if filename.lower().startswith(('http://', 'https://')):
+    if isinstance(filename, str) and filename.lower().startswith(('http://', 'https://')):
         if attach:
             # But see https://en.wikipedia.org/wiki/HTTP_ETag for how
             # we will do this.
-            # http://www.diveintopython.net/http_web_services/etags.html
+            # https://diveintopython3.net/http-web-services.html#etags
             raise NotImplementedError("you cannot attach a URL")
         from sage.misc.remote_file import get_remote_file
         filename = get_remote_file(filename, verbose=False)
 
+    filename = Path(filename).expanduser()
+
     from sage.repl.attach import load_attach_path
     for path in load_attach_path():
-        fpath = os.path.join(path, filename)
-        fpath = os.path.expanduser(fpath)
-        if os.path.isfile(fpath):
+        fpath = (path / filename).expanduser()
+        if fpath.is_file():
             break
     else:
-        raise OSError('did not find file %r to load or attach' % filename)
+        raise OSError('did not find file %r to load or attach' % str(filename))
 
-    ext = os.path.splitext(fpath)[1].lower()
+    ext = fpath.suffix.lower()
     if ext == '.py':
         if attach:
             add_attached_file(fpath)
-        with open(fpath) as f:
+        with fpath.open() as f:
             code = compile(f.read(), fpath, 'exec')
             exec(code, globals)
     elif ext == '.sage':
@@ -262,22 +265,23 @@ def load(filename, globals, attach=False):
             # See Issue 11812.
             if attach:
                 add_attached_file(fpath)
-            with open(preparse_file_named(fpath)) as f:
-                code = compile(f.read(), preparse_file_named(fpath), 'exec')
+            parsed_file = preparse_file_named(fpath)
+            with parsed_file.open() as f:
+                code = compile(f.read(), parsed_file, 'exec')
                 exec(code, globals)
         else:
             # Preparse in memory only for speed.
             if attach:
                 add_attached_file(fpath)
-            with open(fpath) as f:
+            with fpath.open() as f:
                 exec(preparse_file(f.read()) + "\n", globals)
-    elif ext == '.spyx' or ext == '.pyx':
+    elif ext in ['.spyx', '.pyx']:
         if attach:
             add_attached_file(fpath)
         exec(load_cython(fpath), globals)
-    elif ext == '.f' or ext == '.f90':
+    elif ext in ['.f', '.f90']:
         from sage.misc.inline_fortran import fortran
-        with open(fpath) as f:
+        with fpath.open() as f:
             fortran(f.read(), globals)
     elif ext == '.m':
         # Assume magma for now, though maybe .m is used by maple and
@@ -296,15 +300,13 @@ def load_wrap(filename, attach=False):
 
     INPUT:
 
-    - ``filename`` - a string; the argument to the load or attach
-      command
+    - ``filename`` -- a string or :class:`Path` object; the argument
+      to the load or attach command
 
-    - ``attach`` - a boolean (default: False); whether to attach
+    - ``attach`` -- a boolean (default: ``False``); whether to attach
       ``filename``, instead of loading it
 
-    OUTPUT:
-
-    - a string
+    OUTPUT: a string
 
     EXAMPLES::
 
@@ -316,6 +318,8 @@ def load_wrap(filename, attach=False):
         sage: m == b'foo.sage'
         True
     """
+    if isinstance(filename, Path):
+        filename = str(filename)
     # Note: In Python 3, b64encode only accepts bytes, and returns bytes.
     b64 = base64.b64encode(str_to_bytes(filename, FS_ENCODING,
                                         "surrogateescape"))
diff --git a/src/sage/repl/preparse.py b/src/sage/repl/preparse.py
index 9eadcca6fb7..63b95dbfd51 100644
--- a/src/sage/repl/preparse.py
+++ b/src/sage/repl/preparse.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 The Sage Preparser
 
@@ -237,9 +236,8 @@
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
 
-import os
 import re
-
+from pathlib import Path
 from types import SimpleNamespace
 
 from sage.repl.load import load_wrap
@@ -2192,9 +2190,8 @@ def handle_encoding_declaration(contents, out):
             out.write(line + '\n')
             return '\n'.join(lines[:num] + lines[(num + 1):])
 
-    # If we did not find any encoding hints, use utf-8. This is not in
-    # conformance with PEP 263, which says that Python files default to
-    # ascii encoding.
+    # If we did not find any encoding hints, use explicit utf-8.
+    # According to PEP 3120, this could be omitted.
     out.write("# -*- coding: utf-8 -*-\n")
     return contents
 
@@ -2204,24 +2201,36 @@ def preparse_file_named_to_stream(name, out):
     Preparse file named \code{name} (presumably a .sage file), outputting to
     stream \code{out}.
     """
-    name = os.path.abspath(name)
-    with open(name) as f:
+    name = Path(name).resolve()
+    with name.open() as f:
         contents = f.read()
     contents = handle_encoding_declaration(contents, out)
-    parsed = preparse_file(contents)
-    out.write('#' * 70 + '\n')
+    out.write('# ' + '#' * 68 + '\n')
     out.write(f'# This file was *autogenerated* from the file {name}.\n')
-    out.write('#' * 70 + '\n')
-    out.write(parsed)
+    out.write('# ' + '#' * 68 + '\n')
+    out.write(preparse_file(contents))
 
 
-def preparse_file_named(name):
+def preparse_file_named(name) -> Path:
     r"""
-    Preparse file named \code{name} (presumably a .sage file), outputting to a
-    temporary file.  Returns name of temporary file.
+    Preparse file named ``name`` (presumably a ``.sage`` file),
+    outputting to a temporary file.
+
+    This returns the temporary file as a :class:`Path` object.
+
+    EXAMPLES::
+
+        sage: from sage.repl.preparse import preparse_file_named
+        sage: tmpf = tmp_filename(ext='.sage')
+        sage: with open(tmpf, 'w') as f:
+        ....:     out = f.write("a = 2")
+        sage: preparse_file_named(tmpf)
+        PosixPath('...sage.py')
     """
     from sage.misc.temporary_file import tmp_filename
-    tmpfilename = tmp_filename(os.path.basename(name)) + '.py'
-    with open(tmpfilename, 'w') as out:
+    name = Path(name)
+    assert name.suffix == '.sage'
+    tmpfilename = Path(tmp_filename(name.stem, ext='.sage.py'))
+    with tmpfilename.open('w') as out:
         preparse_file_named_to_stream(name, out)
     return tmpfilename
diff --git a/src/sage/repl/rich_output/__init__.py b/src/sage/repl/rich_output/__init__.py
index 49e8325ba21..3a1b273112c 100644
--- a/src/sage/repl/rich_output/__init__.py
+++ b/src/sage/repl/rich_output/__init__.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 
 from .display_manager import get_display_manager
 from .pretty_print import pretty_print
diff --git a/src/sage/repl/rich_output/backend_base.py b/src/sage/repl/rich_output/backend_base.py
index 40019397733..44a9f57087b 100644
--- a/src/sage/repl/rich_output/backend_base.py
+++ b/src/sage/repl/rich_output/backend_base.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Base Class for Backends
 
diff --git a/src/sage/repl/rich_output/backend_doctest.py b/src/sage/repl/rich_output/backend_doctest.py
index 69905f7b067..570ff8955e9 100644
--- a/src/sage/repl/rich_output/backend_doctest.py
+++ b/src/sage/repl/rich_output/backend_doctest.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 """
 The backend used for doctests
 
diff --git a/src/sage/repl/rich_output/backend_emacs.py b/src/sage/repl/rich_output/backend_emacs.py
index 112650270dd..c06cc255a89 100644
--- a/src/sage/repl/rich_output/backend_emacs.py
+++ b/src/sage/repl/rich_output/backend_emacs.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Emacs sage-mode Backend for the Sage Rich Output System
 
diff --git a/src/sage/repl/rich_output/backend_ipython.py b/src/sage/repl/rich_output/backend_ipython.py
index 7f39e37bf8f..39c93cb8446 100644
--- a/src/sage/repl/rich_output/backend_ipython.py
+++ b/src/sage/repl/rich_output/backend_ipython.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 IPython Backend for the Sage Rich Output System
 
diff --git a/src/sage/repl/rich_output/buffer.py b/src/sage/repl/rich_output/buffer.py
index 10b861e846e..a0e7e435c10 100644
--- a/src/sage/repl/rich_output/buffer.py
+++ b/src/sage/repl/rich_output/buffer.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Output Buffer
 
diff --git a/src/sage/repl/rich_output/display_manager.py b/src/sage/repl/rich_output/display_manager.py
index cfece92a810..398de4a3369 100644
--- a/src/sage/repl/rich_output/display_manager.py
+++ b/src/sage/repl/rich_output/display_manager.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Display Manager
 
diff --git a/src/sage/repl/rich_output/output_basic.py b/src/sage/repl/rich_output/output_basic.py
index 03f267896e6..c690f3599ab 100644
--- a/src/sage/repl/rich_output/output_basic.py
+++ b/src/sage/repl/rich_output/output_basic.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Basic Output Types
 
diff --git a/src/sage/repl/rich_output/output_browser.py b/src/sage/repl/rich_output/output_browser.py
index 3d7cda599a1..fe58ab961e2 100644
--- a/src/sage/repl/rich_output/output_browser.py
+++ b/src/sage/repl/rich_output/output_browser.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Rich Output for the Browser
 """
diff --git a/src/sage/repl/rich_output/output_catalog.py b/src/sage/repl/rich_output/output_catalog.py
index 748941c11fc..5b27bee503c 100644
--- a/src/sage/repl/rich_output/output_catalog.py
+++ b/src/sage/repl/rich_output/output_catalog.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Catalog of all available output container types.
 
diff --git a/src/sage/repl/rich_output/output_graphics.py b/src/sage/repl/rich_output/output_graphics.py
index 010ffcb60c8..c8d6dc55ed0 100644
--- a/src/sage/repl/rich_output/output_graphics.py
+++ b/src/sage/repl/rich_output/output_graphics.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Graphics Output Types
 
diff --git a/src/sage/repl/rich_output/output_graphics3d.py b/src/sage/repl/rich_output/output_graphics3d.py
index 46ff6d67ad1..77f7020e13b 100644
--- a/src/sage/repl/rich_output/output_graphics3d.py
+++ b/src/sage/repl/rich_output/output_graphics3d.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Three-Dimensional Graphics Output Types
 
diff --git a/src/sage/repl/rich_output/output_video.py b/src/sage/repl/rich_output/output_video.py
index 3a0d718aaab..6a5914e7f8d 100644
--- a/src/sage/repl/rich_output/output_video.py
+++ b/src/sage/repl/rich_output/output_video.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Video Output Types
 
diff --git a/src/sage/repl/rich_output/preferences.py b/src/sage/repl/rich_output/preferences.py
index f26962dc29b..42fab710af4 100644
--- a/src/sage/repl/rich_output/preferences.py
+++ b/src/sage/repl/rich_output/preferences.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Display Preferences
 
diff --git a/src/sage/repl/rich_output/pretty_print.py b/src/sage/repl/rich_output/pretty_print.py
index 65d72068588..d64ac7ebeb3 100644
--- a/src/sage/repl/rich_output/pretty_print.py
+++ b/src/sage/repl/rich_output/pretty_print.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 The ``pretty_print`` command
 
diff --git a/src/sage/repl/rich_output/test_backend.py b/src/sage/repl/rich_output/test_backend.py
index f0750addb39..2496d6ee6aa 100644
--- a/src/sage/repl/rich_output/test_backend.py
+++ b/src/sage/repl/rich_output/test_backend.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Test Backend
 
diff --git a/src/sage/rings/asymptotic/misc.py b/src/sage/rings/asymptotic/misc.py
index 8117d8ede30..c33ea3e5a94 100644
--- a/src/sage/rings/asymptotic/misc.py
+++ b/src/sage/rings/asymptotic/misc.py
@@ -95,8 +95,8 @@ def extract(s):
     if type(P) is LazyImport:
         P = P._get_object()
 
-    from sage.structure.parent import is_Parent
-    if not is_Parent(P):
+    from sage.structure.parent import Parent
+    if not isinstance(P, Parent):
         raise ValueError("'%s' does not describe a parent." % (s,))
     return P
 
diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
index cb4ee0ff6b8..2530df2de00 100644
--- a/src/sage/rings/complex_arb.pyx
+++ b/src/sage/rings/complex_arb.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8
 r"""
 Arbitrary precision complex balls
 
diff --git a/src/sage/rings/continued_fraction.py b/src/sage/rings/continued_fraction.py
index 13138a999ac..012cd1ad884 100644
--- a/src/sage/rings/continued_fraction.py
+++ b/src/sage/rings/continued_fraction.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Continued fractions
 
diff --git a/src/sage/rings/continued_fraction_gosper.py b/src/sage/rings/continued_fraction_gosper.py
index 5c713ab41c7..8074a57793e 100644
--- a/src/sage/rings/continued_fraction_gosper.py
+++ b/src/sage/rings/continued_fraction_gosper.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 """
 Gosper iterator for homographic transformations
 
diff --git a/src/sage/rings/factorint.pyx b/src/sage/rings/factorint.pyx
index 3571c74bd8d..2144e6d71c7 100644
--- a/src/sage/rings/factorint.pyx
+++ b/src/sage/rings/factorint.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-*
 r"""
 Integer factorization functions
 
diff --git a/src/sage/rings/finite_rings/all.py b/src/sage/rings/finite_rings/all.py
index 5d3d3f21c73..6d8699c7b25 100644
--- a/src/sage/rings/finite_rings/all.py
+++ b/src/sage/rings/finite_rings/all.py
@@ -2,7 +2,7 @@
 Finite Fields
 """
 
-#*****************************************************************************
+# *****************************************************************************
 #       Copyright (C) 2010 David Roe 
 #                          William Stein 
 #
@@ -15,9 +15,9 @@
 #
 #  The full text of the GPL is available at:
 #
-#                  http://www.gnu.org/licenses/
-#*****************************************************************************
+#                  https://www.gnu.org/licenses/
+# *****************************************************************************
 
-from .finite_field_constructor import FiniteField
-from .conway_polynomials import conway_polynomial, exists_conway_polynomial
+from sage.rings.finite_rings.finite_field_constructor import FiniteField
+from sage.rings.finite_rings.conway_polynomials import conway_polynomial, exists_conway_polynomial
 GF = FiniteField
diff --git a/src/sage/rings/fraction_field.py b/src/sage/rings/fraction_field.py
index 32c9aed0afd..94f5bcb4b66 100644
--- a/src/sage/rings/fraction_field.py
+++ b/src/sage/rings/fraction_field.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Fraction Field of Integral Domains
 
diff --git a/src/sage/rings/function_field/all.py b/src/sage/rings/function_field/all.py
index 455fa9fe19e..b423a0d58f5 100644
--- a/src/sage/rings/function_field/all.py
+++ b/src/sage/rings/function_field/all.py
@@ -1,4 +1,4 @@
-from .constructor import FunctionField
+from sage.rings.function_field.constructor import FunctionField
 
 from sage.misc.lazy_import import lazy_import
 
diff --git a/src/sage/rings/homset.py b/src/sage/rings/homset.py
index b2f24a3800a..6e3126d7ebd 100644
--- a/src/sage/rings/homset.py
+++ b/src/sage/rings/homset.py
@@ -26,6 +26,10 @@ def is_RingHomset(H):
 
         sage: from sage.rings.homset import is_RingHomset as is_RH
         sage: is_RH(Hom(ZZ, QQ))
+        doctest:warning...
+        DeprecationWarning: the function is_RingHomset is deprecated;
+        use 'isinstance(..., RingHomset_generic)' instead
+        See https://github.com/sagemath/sage/issues/37922 for details.
         True
         sage: is_RH(ZZ)
         False
@@ -34,6 +38,8 @@ def is_RingHomset(H):
         sage: is_RH(Hom(FreeModule(ZZ,1), FreeModule(QQ,1)))                            # needs sage.modules
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37922, "the function is_RingHomset is deprecated; use 'isinstance(..., RingHomset_generic)' instead")
     return isinstance(H, RingHomset_generic)
 
 
diff --git a/src/sage/rings/imaginary_unit.py b/src/sage/rings/imaginary_unit.py
index bb29cd32630..ae78b38d6c8 100644
--- a/src/sage/rings/imaginary_unit.py
+++ b/src/sage/rings/imaginary_unit.py
@@ -1,4 +1,3 @@
-# coding: utf-8
 
 from sage.rings.number_field.number_field import GaussianField
 
diff --git a/src/sage/rings/laurent_series_ring.py b/src/sage/rings/laurent_series_ring.py
index b8bd1cf062f..8df962fe320 100644
--- a/src/sage/rings/laurent_series_ring.py
+++ b/src/sage/rings/laurent_series_ring.py
@@ -63,8 +63,12 @@ def is_LaurentSeriesRing(x):
         sage: K. = LaurentSeriesRing(QQ)
         sage: is_LaurentSeriesRing(K)
         True
+        sage: L. = LazyLaurentSeriesRing(QQ)
+        sage: is_LaurentSeriesRing(L)
+        True
     """
-    return isinstance(x, LaurentSeriesRing)
+    from sage.rings.lazy_series_ring import LazyLaurentSeriesRing
+    return isinstance(x, (LaurentSeriesRing, LazyLaurentSeriesRing))
 
 
 class LaurentSeriesRing(UniqueRepresentation, CommutativeRing):
@@ -440,6 +444,17 @@ def _element_constructor_(self, x, n=0, prec=infinity):
             1/64*I*u^10 - 1/128*u^12 - 1/256*I*u^14 + 1/512*u^16 +
             1/1024*I*u^18 + O(u^20)
 
+        Lazy series::
+
+            sage: L. = LazyLaurentSeriesRing(ZZ)
+            sage: R = LaurentSeriesRing(QQ, names='z')
+            sage: R(z^-5 + 1/(1-z))
+            z^-5 + 1 + z + z^2 + z^3 + z^4 + z^5 + z^6 + z^7 + z^8 + z^9 + z^10
+             + z^11 + z^12 + z^13 + z^14 + z^15 + z^16 + z^17 + z^18 + z^19 + O(z^20)
+            sage: L. = LazyPowerSeriesRing(QQ)
+            sage: R(5 + z - 5*z^7)
+            5 + z - 5*z^7
+
         TESTS:
 
         Check that :issue:`28993` is fixed::
@@ -489,6 +504,7 @@ def _element_constructor_(self, x, n=0, prec=infinity):
             x^-3
         """
         from sage.rings.fraction_field_element import is_FractionFieldElement
+        from sage.rings.lazy_series import LazyPowerSeries, LazyLaurentSeries
         from sage.rings.polynomial.multi_polynomial import MPolynomial
         from sage.rings.polynomial.polynomial_element import Polynomial
         from sage.structure.element import parent
@@ -525,6 +541,14 @@ def _element_constructor_(self, x, n=0, prec=infinity):
               and isinstance(x.numerator(), (Polynomial, MPolynomial))):
             x = self(x.numerator()) / self(x.denominator())
             return (x << n).add_bigoh(prec)
+        elif isinstance(x, (LazyPowerSeries, LazyLaurentSeries)):
+            if prec is infinity:
+                try:
+                    x = self.power_series_ring()(x.polynomial())
+                except ValueError:
+                    x = x.add_bigoh(self.default_prec())
+            else:
+                x = x.add_bigoh(prec)
         return self.element_class(self, x, n).add_bigoh(prec)
 
     def random_element(self, algorithm='default'):
@@ -618,6 +642,10 @@ def _coerce_map_from_(self, P):
             True
             sage: S.has_coerce_map_from(S)
             True
+            sage: S.has_coerce_map_from(LazyLaurentSeriesRing(ZZ, 't'))
+            True
+            sage: S.has_coerce_map_from(LazyPowerSeriesRing(ZZ, 't'))
+            True
 
             sage: S.has_coerce_map_from(QQ)
             False
@@ -641,6 +669,10 @@ def _coerce_map_from_(self, P):
             False
             sage: R.has_coerce_map_from(ZZ['x'])
             True
+            sage: R.has_coerce_map_from(LazyLaurentSeriesRing(ZZ, 't'))
+            True
+            sage: R.has_coerce_map_from(LazyLaurentSeriesRing(ZZ['x'], 't'))
+            True
         """
         A = self.base_ring()
         from sage.rings.polynomial.laurent_polynomial_ring_base import (
diff --git a/src/sage/rings/lazy_series.py b/src/sage/rings/lazy_series.py
index f4c46a03ca5..e49240c5a46 100644
--- a/src/sage/rings/lazy_series.py
+++ b/src/sage/rings/lazy_series.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Lazy Series
 
@@ -4746,6 +4745,9 @@ def approximate_series(self, prec, name=None):
             R = PowerSeriesRing(S.base_ring(), name=name)
             return R([self[i] for i in range(prec)]).add_bigoh(prec)
 
+    add_bigoh = approximate_series
+    O = approximate_series
+
     def polynomial(self, degree=None, name=None):
         r"""
         Return ``self`` as a Laurent polynomial if ``self`` is actually so.
@@ -6065,6 +6067,45 @@ def polynomial(self, degree=None, names=None):
             return R(self[0:m])
         return R.sum(self[0:m])
 
+    def add_bigoh(self, prec):
+        r"""
+        Return the power series of precision at most ``prec`` obtained by
+        adding `O(q^\text{prec})` to `f`, where `q` is the (tuple of)
+        variable(s).
+
+        EXAMPLES::
+
+            sage: L. = LazyPowerSeriesRing(QQ)
+            sage: f = 1 / (1 - x + y)
+            sage: f
+            1 + (x-y) + (x^2-2*x*y+y^2) + (x^3-3*x^2*y+3*x*y^2-y^3)
+             + (x^4-4*x^3*y+6*x^2*y^2-4*x*y^3+y^4)
+             + (x^5-5*x^4*y+10*x^3*y^2-10*x^2*y^3+5*x*y^4-y^5)
+             + (x^6-6*x^5*y+15*x^4*y^2-20*x^3*y^3+15*x^2*y^4-6*x*y^5+y^6)
+             + O(x,y)^7
+            sage: f3 = f.add_bigoh(3); f3
+            1 + x - y + x^2 - 2*x*y + y^2 + O(x, y)^3
+            sage: f3.parent()
+            Multivariate Power Series Ring in x, y over Rational Field
+
+            sage: R. = QQ[]
+            sage: L. = LazyPowerSeriesRing(R)
+            sage: f = 1 / (1 - t^3*x)
+            sage: f
+            1 + t^3*x + t^6*x^2 + t^9*x^3 + t^12*x^4 + t^15*x^5 + t^18*x^6 + O(x^7)
+            sage: f3 = f.add_bigoh(3); f3
+            1 + t^3*x + t^6*x^2 + O(x^3)
+            sage: f3.parent()
+            Power Series Ring in x over Univariate Polynomial Ring in t
+             over Rational Field
+        """
+        from sage.rings.power_series_ring import PowerSeriesRing
+        P = self.parent()
+        PSR = PowerSeriesRing(P.base_ring(), names=P.variable_names())
+        return PSR(self.polynomial(degree=prec-1), prec=prec)
+
+    O = add_bigoh
+
     def _floordiv_(self, other):
         r"""
         Return ``self`` floor divided by ``other``.
diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx
index 6c78460a534..bad89829a70 100644
--- a/src/sage/rings/morphism.pyx
+++ b/src/sage/rings/morphism.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Homomorphisms of rings
 
diff --git a/src/sage/rings/multi_power_series_ring.py b/src/sage/rings/multi_power_series_ring.py
index 0b34dfa003b..f2e47ccc835 100644
--- a/src/sage/rings/multi_power_series_ring.py
+++ b/src/sage/rings/multi_power_series_ring.py
@@ -246,9 +246,15 @@ def is_MPowerSeriesRing(x):
         True
         sage: is_MPowerSeriesRing(T)
         False
-
+        sage: L = LazyPowerSeriesRing(QQ, 'x')
+        sage: is_MPowerSeriesRing(L)
+        True
+        sage: L = LazyPowerSeriesRing(QQ, 'x, y')
+        sage: is_MPowerSeriesRing(L)
+        True
     """
-    return isinstance(x, MPowerSeriesRing_generic)
+    from sage.rings.lazy_series_ring import LazyPowerSeriesRing
+    return isinstance(x, (MPowerSeriesRing_generic, LazyPowerSeriesRing))
 
 
 class MPowerSeriesRing_generic(PowerSeriesRing_generic, Nonexact):
@@ -754,13 +760,13 @@ def _coerce_map_from_(self, P):
         The rings that canonically coerce to this multivariate power series
         ring are:
 
-            - this ring itself
+        - this ring itself
 
-            - a polynomial or power series ring in the same variables or a
-              subset of these variables (possibly empty), over any base
-              ring that canonically coerces into this ring
+        - a polynomial or power series ring in the same variables or a
+          subset of these variables (possibly empty), over any base
+          ring that canonically coerces into this ring
 
-            - any ring that coerces into the foreground polynomial ring of this ring
+        - any ring that coerces into the foreground polynomial ring of this ring
 
         EXAMPLES::
 
@@ -817,6 +823,10 @@ def _coerce_map_from_(self, P):
             sage: H._coerce_map_from_(PolynomialRing(ZZ,'z2,f0'))
             True
 
+            sage: L. = LazyPowerSeriesRing(QQ)
+            sage: R = PowerSeriesRing(QQ, names=('x','y','z'))
+            sage: R.has_coerce_map_from(L)
+            True
         """
         if is_MPolynomialRing(P) or is_MPowerSeriesRing(P) \
                    or is_PolynomialRing(P) or is_PowerSeriesRing(P):
@@ -846,12 +856,28 @@ def _element_constructor_(self, f, prec=None):
             sage: M._element_constructor_(p).parent()
             Multivariate Power Series Ring in t0, t1, t2, t3, t4 over
             Integer Ring
+
+            sage: L. = LazyPowerSeriesRing(QQ)
+            sage: R = PowerSeriesRing(QQ, names=('x','y','z'))
+            sage: R(1/(1-x-y), prec=3)
+            1 + x + y + x^2 + 2*x*y + y^2 + O(x, y, z)^3
+            sage: R(x + y^2)
+            x + y^2
         """
         if prec is None:
             try:
                 prec = f.prec()
             except AttributeError:
                 prec = infinity
+        from sage.rings.lazy_series import LazyPowerSeries
+        if isinstance(f, LazyPowerSeries):
+            if prec is infinity:
+                try:
+                    f = f.polynomial()
+                except ValueError:
+                    f = f.add_bigoh(self.default_prec())
+            else:
+                f = f.add_bigoh(prec)
         return self.element_class(parent=self, x=f, prec=prec)
 
     def laurent_series_ring(self):
diff --git a/src/sage/rings/number_field/all.py b/src/sage/rings/number_field/all.py
index 5c56f8cff58..73cf7750d43 100644
--- a/src/sage/rings/number_field/all.py
+++ b/src/sage/rings/number_field/all.py
@@ -1,15 +1,19 @@
 
-from .number_field import (NumberField, NumberFieldTower, CyclotomicField, QuadraticField,
-                           is_fundamental_discriminant, is_real_place)
-from .number_field_element import NumberFieldElement
+from sage.rings.number_field.number_field import (NumberField, NumberFieldTower, CyclotomicField, QuadraticField,
+                                                  is_fundamental_discriminant, is_real_place)
+from sage.rings.number_field.number_field_element import NumberFieldElement
 
-from .order import EquationOrder, GaussianIntegers, EisensteinIntegers
+from sage.rings.number_field.order import EquationOrder, GaussianIntegers, EisensteinIntegers
 
-from sage.misc.lazy_import import lazy_import as _lazy_import
+from sage.misc.lazy_import import lazy_import
 
-_lazy_import('sage.rings.number_field.totallyreal', 'enumerate_totallyreal_fields_prim')
-_lazy_import('sage.rings.number_field.totallyreal_data', 'hermite_constant')
-_lazy_import('sage.rings.number_field.totallyreal_rel', 'enumerate_totallyreal_fields_all')
-_lazy_import('sage.rings.number_field.totallyreal_rel', 'enumerate_totallyreal_fields_rel')
+lazy_import('sage.rings.number_field.totallyreal', 'enumerate_totallyreal_fields_prim')
+lazy_import('sage.rings.number_field.totallyreal_data', 'hermite_constant')
+lazy_import('sage.rings.number_field.totallyreal_rel',
+            'enumerate_totallyreal_fields_all')
+lazy_import('sage.rings.number_field.totallyreal_rel',
+            'enumerate_totallyreal_fields_rel')
 
-from .unit_group import UnitGroup
+from sage.rings.number_field.unit_group import UnitGroup
+
+del lazy_import
diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
index 4f10c8d8f13..f514bd49b26 100644
--- a/src/sage/rings/number_field/class_group.py
+++ b/src/sage/rings/number_field/class_group.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Class groups of number fields
 
diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
index 87221473348..f91b57e09cc 100644
--- a/src/sage/rings/number_field/selmer_group.py
+++ b/src/sage/rings/number_field/selmer_group.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 `p`-Selmer groups of number fields
 
diff --git a/src/sage/rings/padics/all.py b/src/sage/rings/padics/all.py
index 7014f5622d8..7ece4e00493 100644
--- a/src/sage/rings/padics/all.py
+++ b/src/sage/rings/padics/all.py
@@ -1,6 +1,6 @@
-from .factory import Zp, Zq, Zp as pAdicRing, ZpCR, ZpCA, ZpFM, ZpFP, ZpLC, ZpLF, ZqCR, ZqCA, ZqFM, ZqFP, ZpER
-from .factory import Qp, Qq, Qp as pAdicField, QpCR, QpFP, QpLC, QpLF, QqCR, QqFP, QpER
-from .factory import pAdicExtension
-from .padic_generic import local_print_mode
-from .pow_computer import PowComputer
-from .pow_computer_ext import PowComputer_ext_maker
+from sage.rings.padics.factory import Zp, Zq, Zp as pAdicRing, ZpCR, ZpCA, ZpFM, ZpFP, ZpLC, ZpLF, ZqCR, ZqCA, ZqFM, ZqFP, ZpER
+from sage.rings.padics.factory import Qp, Qq, Qp as pAdicField, QpCR, QpFP, QpLC, QpLF, QqCR, QqFP, QpER
+from sage.rings.padics.factory import pAdicExtension
+from sage.rings.padics.padic_generic import local_print_mode
+from sage.rings.padics.pow_computer import PowComputer
+from sage.rings.padics.pow_computer_ext import PowComputer_ext_maker
diff --git a/src/sage/rings/padics/misc.py b/src/sage/rings/padics/misc.py
index 984482bc39c..dfe0feee162 100644
--- a/src/sage/rings/padics/misc.py
+++ b/src/sage/rings/padics/misc.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Miscellaneous Functions
 
diff --git a/src/sage/rings/padics/padic_valuation.py b/src/sage/rings/padics/padic_valuation.py
index 7b162228fbb..2230ff9e060 100644
--- a/src/sage/rings/padics/padic_valuation.py
+++ b/src/sage/rings/padics/padic_valuation.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 `p`-adic Valuations on Number Fields and Their Subrings and Completions
 
diff --git a/src/sage/rings/padics/pow_computer_relative.pxd b/src/sage/rings/padics/pow_computer_relative.pxd
index df989768720..6e829ee2b69 100644
--- a/src/sage/rings/padics/pow_computer_relative.pxd
+++ b/src/sage/rings/padics/pow_computer_relative.pxd
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 from sage.rings.padics.pow_computer cimport PowComputer_class
 from sage.rings.polynomial.polynomial_element cimport Polynomial_generic_dense
 
diff --git a/src/sage/rings/padics/pow_computer_relative.pyx b/src/sage/rings/padics/pow_computer_relative.pyx
index 98b3a6f5fa4..e62881b2695 100644
--- a/src/sage/rings/padics/pow_computer_relative.pyx
+++ b/src/sage/rings/padics/pow_computer_relative.pyx
@@ -4,7 +4,6 @@
 # distutils: library_dirs = NTL_LIBDIR
 # distutils: extra_link_args = NTL_LIBEXTRA
 # distutils: language = c++
-# -*- coding: utf-8 -*-
 r"""
 A ``PowComputer`` for relative extensions
 
diff --git a/src/sage/rings/polynomial/binary_form_reduce.py b/src/sage/rings/polynomial/binary_form_reduce.py
index 2e8003c7ce8..8d1fd8c9852 100644
--- a/src/sage/rings/polynomial/binary_form_reduce.py
+++ b/src/sage/rings/polynomial/binary_form_reduce.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Helper functions for reduction of binary forms.
 
diff --git a/src/sage/rings/polynomial/cyclotomic.pyx b/src/sage/rings/polynomial/cyclotomic.pyx
index a7339d23604..84f85104cc3 100644
--- a/src/sage/rings/polynomial/cyclotomic.pyx
+++ b/src/sage/rings/polynomial/cyclotomic.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Fast calculation of cyclotomic polynomials
 
diff --git a/src/sage/rings/polynomial/flatten.py b/src/sage/rings/polynomial/flatten.py
index ca2a491b94d..64ab7ed99d5 100644
--- a/src/sage/rings/polynomial/flatten.py
+++ b/src/sage/rings/polynomial/flatten.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Class to flatten polynomial rings over polynomial ring
 
diff --git a/src/sage/rings/polynomial/hilbert.pyx b/src/sage/rings/polynomial/hilbert.pyx
index 439d2ed893e..198a0940b95 100644
--- a/src/sage/rings/polynomial/hilbert.pyx
+++ b/src/sage/rings/polynomial/hilbert.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Compute Hilbert series of monomial ideals
 
diff --git a/src/sage/rings/polynomial/ideal.py b/src/sage/rings/polynomial/ideal.py
index 9719c81ba41..011cb860290 100644
--- a/src/sage/rings/polynomial/ideal.py
+++ b/src/sage/rings/polynomial/ideal.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Ideals in Univariate Polynomial Rings
 
diff --git a/src/sage/rings/polynomial/msolve.py b/src/sage/rings/polynomial/msolve.py
index 47775f9bd8c..d15d498c040 100644
--- a/src/sage/rings/polynomial/msolve.py
+++ b/src/sage/rings/polynomial/msolve.py
@@ -1,4 +1,3 @@
-# coding: utf-8
 r"""
 Solution of polynomial systems using msolve
 
diff --git a/src/sage/rings/polynomial/polynomial_complex_arb.pyx b/src/sage/rings/polynomial/polynomial_complex_arb.pyx
index da1ade2edcb..311a06f64eb 100644
--- a/src/sage/rings/polynomial/polynomial_complex_arb.pyx
+++ b/src/sage/rings/polynomial/polynomial_complex_arb.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8
 r"""
 Univariate polynomials over `\CC` with Arb ball coefficients.
 
diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
index f08f810cfbf..4893670b5a7 100644
--- a/src/sage/rings/polynomial/polynomial_element.pyx
+++ b/src/sage/rings/polynomial/polynomial_element.pyx
@@ -1,4 +1,3 @@
-# coding: utf-8
 """
 Univariate polynomial base class
 
diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py
index f5cab5bbc88..f7201447019 100644
--- a/src/sage/rings/polynomial/polynomial_ring.py
+++ b/src/sage/rings/polynomial/polynomial_ring.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Univariate Polynomial Rings
 
diff --git a/src/sage/rings/power_series_poly.pyx b/src/sage/rings/power_series_poly.pyx
index e1c45ff5d51..27b1c93f7ea 100644
--- a/src/sage/rings/power_series_poly.pyx
+++ b/src/sage/rings/power_series_poly.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Power Series Methods
 
diff --git a/src/sage/rings/power_series_ring.py b/src/sage/rings/power_series_ring.py
index f4f97428011..08a6d9f2d3f 100644
--- a/src/sage/rings/power_series_ring.py
+++ b/src/sage/rings/power_series_ring.py
@@ -470,8 +470,13 @@ def is_PowerSeriesRing(R):
         False
         sage: is_PowerSeriesRing(QQ[['x']])
         True
+        sage: is_PowerSeriesRing(LazyPowerSeriesRing(QQ, 'x'))
+        True
+        sage: is_PowerSeriesRing(LazyPowerSeriesRing(QQ, 'x, y'))
+        False
     """
-    if isinstance(R, PowerSeriesRing_generic):
+    from sage.rings.lazy_series_ring import LazyPowerSeriesRing
+    if isinstance(R, (PowerSeriesRing_generic, LazyPowerSeriesRing)):
         return R.ngens() == 1
     else:
         return False
@@ -684,8 +689,8 @@ def _latex_(self):
 
     def _coerce_map_from_(self, S):
         """
-        A coercion from `S` exists, if `S` coerces into ``self``'s base ring,
-        or if `S` is a univariate polynomial or power series ring with the
+        A coercion from ``S`` exists, if ``S`` coerces into ``self``'s base ring,
+        or if ``S`` is a univariate polynomial or power series ring with the
         same variable name as self, defined over a base ring that coerces into
         ``self``'s base ring.
 
@@ -700,7 +705,8 @@ def _coerce_map_from_(self, S):
             False
             sage: A.has_coerce_map_from(ZZ[['x']])
             True
-
+            sage: A.has_coerce_map_from(LazyPowerSeriesRing(ZZ, 'x'))
+            True
         """
         if self.base_ring().has_coerce_map_from(S):
             return True
@@ -712,8 +718,8 @@ def _element_constructor_(self, f, prec=infinity, check=True):
         """
         Coerce object to this power series ring.
 
-        Returns a new instance unless the parent of f is self, in which
-        case f is returned (since f is immutable).
+        Returns a new instance unless the parent of ``f`` is ``self``, in
+        which case ``f`` is returned (since ``f`` is immutable).
 
         INPUT:
 
@@ -726,7 +732,6 @@ def _element_constructor_(self, f, prec=infinity, check=True):
         -  ``check`` -- bool (default: ``True``), whether to verify
            that the coefficients, etc., coerce in correctly.
 
-
         EXAMPLES::
 
             sage: R. = PowerSeriesRing(ZZ)
@@ -803,6 +808,14 @@ def _element_constructor_(self, f, prec=infinity, check=True):
             ...
             ValueError: prec (= -5) must be non-negative
 
+        From lazy series::
+
+            sage: L. = LazyPowerSeriesRing(QQ)
+            sage: R = PowerSeriesRing(QQ, 'x')
+            sage: R(1 / (1 + x^3))
+            1 - x^3 + x^6 - x^9 + x^12 - x^15 + x^18 + O(x^20)
+            sage: R(2 - x^2 + x^6)
+            2 - x^2 + x^6
         """
         if prec is not infinity:
             prec = integer.Integer(prec)
@@ -832,6 +845,16 @@ def _element_constructor_(self, f, prec=infinity, check=True):
                                           f.degree(f.default_variable()), check=check)
                 else:
                     raise TypeError("Can only convert series into ring with same variable name.")
+        else:
+            from sage.rings.lazy_series import LazyPowerSeries
+            if isinstance(f, LazyPowerSeries):
+                if prec is infinity:
+                    try:
+                        f = f.polynomial()
+                    except ValueError:
+                        f = f.add_bigoh(self.default_prec())
+                else:
+                    f = f.add_bigoh(prec)
         return self.element_class(self, f, prec, check=check)
 
     def construction(self):
diff --git a/src/sage/rings/puiseux_series_ring.py b/src/sage/rings/puiseux_series_ring.py
index f5e02b28f82..d63b5bcc665 100644
--- a/src/sage/rings/puiseux_series_ring.py
+++ b/src/sage/rings/puiseux_series_ring.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Puiseux Series Ring
 
diff --git a/src/sage/rings/puiseux_series_ring_element.pyx b/src/sage/rings/puiseux_series_ring_element.pyx
index 21b1cb5b70f..cb69d583e2a 100644
--- a/src/sage/rings/puiseux_series_ring_element.pyx
+++ b/src/sage/rings/puiseux_series_ring_element.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Puiseux Series Ring Element
 
diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
index 4e989f23695..971e9fc13bf 100644
--- a/src/sage/rings/real_arb.pyx
+++ b/src/sage/rings/real_arb.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8
 r"""
 Arbitrary precision real balls
 
diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
index 36f8336786c..c4c633ba42b 100644
--- a/src/sage/rings/ring.pyx
+++ b/src/sage/rings/ring.pyx
@@ -102,7 +102,6 @@ from sage.misc.superseded import deprecation
 from sage.structure.coerce cimport coercion_model
 from sage.structure.parent cimport Parent
 from sage.structure.category_object cimport check_default_category
-from sage.structure.sequence import Sequence
 from sage.misc.prandom import randint
 from sage.categories.rings import Rings
 from sage.categories.commutative_rings import CommutativeRings
@@ -426,7 +425,7 @@ cdef class Ring(ParentWithGens):
             coerce = True
 
         from sage.rings.ideal import Ideal_generic
-        from sage.structure.parent import is_Parent
+        from sage.structure.parent import Parent
         gens = args
         while isinstance(gens, (list, tuple)) and len(gens) == 1:
             first = gens[0]
@@ -445,7 +444,7 @@ cdef class Ring(ParentWithGens):
                 break
             elif isinstance(first, (list, tuple)):
                 gens = first
-            elif is_Parent(first) and self.has_coerce_map_from(first):
+            elif isinstance(first, Parent) and self.has_coerce_map_from(first):
                 gens = first.gens()  # we have a ring as argument
             else:
                 break
@@ -1263,204 +1262,6 @@ cdef class CommutativeRing(Ring):
         I = R.ideal(R(poly.list()))
         return R.quotient(I, name)
 
-    def frobenius_endomorphism(self, n=1):
-        """
-        INPUT:
-
-        - ``n`` -- a nonnegative integer (default: 1)
-
-        OUTPUT:
-
-        The `n`-th power of the absolute arithmetic Frobenius
-        endomorphism on this finite field.
-
-        EXAMPLES::
-
-            sage: K. = PowerSeriesRing(GF(5))
-            sage: Frob = K.frobenius_endomorphism(); Frob
-            Frobenius endomorphism x |--> x^5 of Power Series Ring in u
-             over Finite Field of size 5
-            sage: Frob(u)
-            u^5
-
-        We can specify a power::
-
-            sage: f = K.frobenius_endomorphism(2); f
-            Frobenius endomorphism x |--> x^(5^2) of Power Series Ring in u
-             over Finite Field of size 5
-            sage: f(1+u)
-            1 + u^25
-        """
-        from sage.rings.morphism import FrobeniusEndomorphism_generic
-        return FrobeniusEndomorphism_generic(self, n)
-
-    def derivation_module(self, codomain=None, twist=None):
-        r"""
-        Returns the module of derivations over this ring.
-
-        INPUT:
-
-        - ``codomain`` -- an algebra over this ring or a ring homomorphism
-          whose domain is this ring or ``None`` (default: ``None``); if it
-          is a morphism, the codomain of derivations will be the codomain
-          of the morphism viewed as an algebra over ``self`` through the
-          given morphism; if ``None``, the codomain will be this ring
-
-        - ``twist`` -- a morphism from this ring to ``codomain``
-          or ``None`` (default: ``None``); if ``None``, the coercion
-          map from this ring to ``codomain`` will be used
-
-        .. NOTE::
-
-            A twisted derivation with respect to `\theta` (or a
-            `\theta`-derivation for short) is an additive map `d`
-            satisfying the following axiom for all `x, y` in the domain:
-
-            .. MATH::
-
-                d(xy) = \theta(x) d(y) + d(x) y.
-
-        EXAMPLES::
-
-            sage: R. = QQ[]
-            sage: M = R.derivation_module(); M                                          # needs sage.modules
-            Module of derivations over
-             Multivariate Polynomial Ring in x, y, z over Rational Field
-            sage: M.gens()                                                              # needs sage.modules
-            (d/dx, d/dy, d/dz)
-
-        We can specify a different codomain::
-
-            sage: K = R.fraction_field()
-            sage: M = R.derivation_module(K); M                                         # needs sage.modules
-            Module of derivations
-             from Multivariate Polynomial Ring in x, y, z over Rational Field
-               to Fraction Field of
-                  Multivariate Polynomial Ring in x, y, z over Rational Field
-            sage: M.gen() / x                                                           # needs sage.modules
-            1/x*d/dx
-
-        Here is an example with a non-canonical defining morphism::
-
-            sage: ev = R.hom([QQ(0), QQ(1), QQ(2)])
-            sage: ev
-            Ring morphism:
-              From: Multivariate Polynomial Ring in x, y, z over Rational Field
-              To:   Rational Field
-              Defn: x |--> 0
-                    y |--> 1
-                    z |--> 2
-            sage: M = R.derivation_module(ev)                                           # needs sage.modules
-            sage: M                                                                     # needs sage.modules
-            Module of derivations
-             from Multivariate Polynomial Ring in x, y, z over Rational Field
-               to Rational Field
-
-        Elements in `M` acts as derivations at `(0,1,2)`::
-
-            sage: # needs sage.modules
-            sage: Dx = M.gen(0); Dx
-            d/dx
-            sage: Dy = M.gen(1); Dy
-            d/dy
-            sage: Dz = M.gen(2); Dz
-            d/dz
-            sage: f = x^2 + y^2 + z^2
-            sage: Dx(f)  # = 2*x evaluated at (0,1,2)
-            0
-            sage: Dy(f)  # = 2*y evaluated at (0,1,2)
-            2
-            sage: Dz(f)  # = 2*z evaluated at (0,1,2)
-            4
-
-        An example with a twisting homomorphism::
-
-            sage: theta = R.hom([x^2, y^2, z^2])
-            sage: M = R.derivation_module(twist=theta); M                               # needs sage.modules
-            Module of twisted derivations over Multivariate Polynomial Ring in x, y, z
-             over Rational Field (twisting morphism: x |--> x^2, y |--> y^2, z |--> z^2)
-
-        .. SEEALSO::
-
-            :meth:`derivation`
-
-        """
-        from sage.rings.derivation import RingDerivationModule
-        if codomain is None:
-            codomain = self
-        return RingDerivationModule(self, codomain, twist)
-
-    def derivation(self, arg=None, twist=None):
-        r"""
-        Return the twisted or untwisted derivation over this ring
-        specified by ``arg``.
-
-        .. NOTE::
-
-            A twisted derivation with respect to `\theta` (or a
-            `\theta`-derivation for short) is an additive map `d`
-            satisfying the following axiom for all `x, y` in the domain:
-
-            .. MATH::
-
-                d(xy) = \theta(x) d(y) + d(x) y.
-
-        INPUT:
-
-        - ``arg`` -- (optional) a generator or a list of coefficients
-          that defines the derivation
-
-        - ``twist`` -- (optional) the twisting homomorphism
-
-        EXAMPLES::
-
-            sage: R. = QQ[]
-            sage: R.derivation()                                                        # needs sage.modules
-            d/dx
-
-        In that case, ``arg`` could be a generator::
-
-            sage: R.derivation(y)                                                       # needs sage.modules
-            d/dy
-
-        or a list of coefficients::
-
-            sage: R.derivation([1,2,3])                                                 # needs sage.modules
-            d/dx + 2*d/dy + 3*d/dz
-
-        It is not possible to define derivations with respect to a
-        polynomial which is not a variable::
-
-            sage: R.derivation(x^2)                                                     # needs sage.modules
-            Traceback (most recent call last):
-            ...
-            ValueError: unable to create the derivation
-
-        Here is an example with twisted derivations::
-
-            sage: R. = QQ[]
-            sage: theta = R.hom([x^2, y^2, z^2])
-            sage: f = R.derivation(twist=theta); f                                      # needs sage.modules
-            0
-            sage: f.parent()                                                            # needs sage.modules
-            Module of twisted derivations over Multivariate Polynomial Ring in x, y, z
-             over Rational Field (twisting morphism: x |--> x^2, y |--> y^2, z |--> z^2)
-
-        Specifying a scalar, the returned twisted derivation is the
-        corresponding multiple of `\theta - id`::
-
-            sage: R.derivation(1, twist=theta)                                          # needs sage.modules
-            [x |--> x^2, y |--> y^2, z |--> z^2] - id
-            sage: R.derivation(x, twist=theta)                                          # needs sage.modules
-            x*([x |--> x^2, y |--> y^2, z |--> z^2] - id)
-
-        """
-        if isinstance(arg, (list, tuple)):
-            codomain = Sequence([self(0)] + list(arg)).universe()
-        else:
-            codomain = self
-        return self.derivation_module(codomain, twist=twist)(arg)
-
 
 cdef class IntegralDomain(CommutativeRing):
     """
diff --git a/src/sage/rings/semirings/all.py b/src/sage/rings/semirings/all.py
index b14da38328a..55e69042077 100644
--- a/src/sage/rings/semirings/all.py
+++ b/src/sage/rings/semirings/all.py
@@ -1,2 +1,2 @@
-from .non_negative_integer_semiring import NonNegativeIntegerSemiring, NN
-from .tropical_semiring import TropicalSemiring
+from sage.rings.semirings.non_negative_integer_semiring import NonNegativeIntegerSemiring, NN
+from sage.rings.semirings.tropical_semiring import TropicalSemiring
diff --git a/src/sage/rings/valuation/developing_valuation.py b/src/sage/rings/valuation/developing_valuation.py
index d7724642415..771201c444c 100644
--- a/src/sage/rings/valuation/developing_valuation.py
+++ b/src/sage/rings/valuation/developing_valuation.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Valuations on polynomial rings based on `\phi`-adic expansions
 
diff --git a/src/sage/rings/valuation/gauss_valuation.py b/src/sage/rings/valuation/gauss_valuation.py
index a69977ae4b3..a748a6463f1 100644
--- a/src/sage/rings/valuation/gauss_valuation.py
+++ b/src/sage/rings/valuation/gauss_valuation.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Gauss valuations on polynomial rings
 
diff --git a/src/sage/rings/valuation/inductive_valuation.py b/src/sage/rings/valuation/inductive_valuation.py
index 9991aaac2e1..4c438e52819 100644
--- a/src/sage/rings/valuation/inductive_valuation.py
+++ b/src/sage/rings/valuation/inductive_valuation.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Inductive valuations on polynomial rings
 
diff --git a/src/sage/rings/valuation/limit_valuation.py b/src/sage/rings/valuation/limit_valuation.py
index fa23e2c0a69..7932ac6d75f 100644
--- a/src/sage/rings/valuation/limit_valuation.py
+++ b/src/sage/rings/valuation/limit_valuation.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Valuations which are defined as limits of valuations.
 
diff --git a/src/sage/rings/valuation/mapped_valuation.py b/src/sage/rings/valuation/mapped_valuation.py
index 2c4aa42799d..5581c9bfa09 100644
--- a/src/sage/rings/valuation/mapped_valuation.py
+++ b/src/sage/rings/valuation/mapped_valuation.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Valuations which are implemented through a map to another valuation
 
diff --git a/src/sage/rings/valuation/scaled_valuation.py b/src/sage/rings/valuation/scaled_valuation.py
index 84249392e3a..ccbc4b97a02 100644
--- a/src/sage/rings/valuation/scaled_valuation.py
+++ b/src/sage/rings/valuation/scaled_valuation.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Valuations which are scaled versions of another valuation
 
diff --git a/src/sage/rings/valuation/trivial_valuation.py b/src/sage/rings/valuation/trivial_valuation.py
index ddbf9d7e1b7..6ba86ab5888 100644
--- a/src/sage/rings/valuation/trivial_valuation.py
+++ b/src/sage/rings/valuation/trivial_valuation.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Trivial valuations
 
diff --git a/src/sage/rings/valuation/valuation.py b/src/sage/rings/valuation/valuation.py
index 0121f6a6b25..863d3b423a4 100644
--- a/src/sage/rings/valuation/valuation.py
+++ b/src/sage/rings/valuation/valuation.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Discrete valuations
 
diff --git a/src/sage/rings/valuation/valuation_space.py b/src/sage/rings/valuation/valuation_space.py
index 485a622f33c..e1af286d102 100644
--- a/src/sage/rings/valuation/valuation_space.py
+++ b/src/sage/rings/valuation/valuation_space.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Spaces of valuations
 
diff --git a/src/sage/rings/valuation/value_group.py b/src/sage/rings/valuation/value_group.py
index b39eec60bdd..1b9073255da 100644
--- a/src/sage/rings/valuation/value_group.py
+++ b/src/sage/rings/valuation/value_group.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Value groups of discrete valuations
 
diff --git a/src/sage/sandpiles/examples.py b/src/sage/sandpiles/examples.py
index 980dec77036..a7615723e81 100644
--- a/src/sage/sandpiles/examples.py
+++ b/src/sage/sandpiles/examples.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Examples of Sandpile
 
diff --git a/src/sage/schemes/affine/affine_homset.py b/src/sage/schemes/affine/affine_homset.py
index b6570bd6f6d..a54d4d68c3c 100644
--- a/src/sage/schemes/affine/affine_homset.py
+++ b/src/sage/schemes/affine/affine_homset.py
@@ -261,10 +261,10 @@ def points(self, **kwds):
             may be computed partially or incorrectly.
             [(0.0, 0.0)]
         """
-        from sage.schemes.affine.affine_space import is_AffineSpace
+        from sage.schemes.affine.affine_space import AffineSpace_generic
 
         X = self.codomain()
-        if not is_AffineSpace(X) and X.base_ring() in Fields():
+        if not isinstance(X, AffineSpace_generic) and X.base_ring() in Fields():
             if hasattr(X.base_ring(), 'precision'):
                 numerical = True
                 verbose("Warning: computations in the numerical fields are inexact;points may be computed partially or incorrectly.", level=0)
@@ -436,7 +436,7 @@ def numerical_points(self, F=None, **kwds):
             ...
             ValueError: tolerance must be positive
         """
-        from sage.schemes.affine.affine_space import is_AffineSpace
+        from sage.schemes.affine.affine_space import AffineSpace_generic
         if F is None:
             F = CC
         if F not in Fields() or not hasattr(F, 'precision'):
@@ -446,7 +446,7 @@ def numerical_points(self, F=None, **kwds):
             raise TypeError('base ring must be a number field')
 
         AA = X.ambient_space().change_ring(F)
-        if not is_AffineSpace(X) and X.base_ring() in Fields():
+        if not isinstance(X, AffineSpace_generic) and X.base_ring() in Fields():
             # Then X must be a subscheme
             dim_ideal = X.defining_ideal().dimension()
             if dim_ideal != 0:  # no points
diff --git a/src/sage/schemes/affine/affine_point.py b/src/sage/schemes/affine/affine_point.py
index 00779dbb2d6..4e09c1e133a 100644
--- a/src/sage/schemes/affine/affine_point.py
+++ b/src/sage/schemes/affine/affine_point.py
@@ -372,8 +372,8 @@ def intersection_multiplicity(self, X):
             ...
             TypeError: this point must be a point on an affine subscheme
         """
-        from sage.schemes.affine.affine_space import is_AffineSpace
-        if is_AffineSpace(self.codomain()):
+        from sage.schemes.affine.affine_space import AffineSpace_generic
+        if isinstance(self.codomain(), AffineSpace_generic):
             raise TypeError("this point must be a point on an affine subscheme")
         return self.codomain().intersection_multiplicity(X, self)
 
@@ -397,8 +397,8 @@ def multiplicity(self):
             sage: Q2.multiplicity()                                                     # needs sage.libs.singular
             2
         """
-        from sage.schemes.affine.affine_space import is_AffineSpace
-        if is_AffineSpace(self.codomain()):
+        from sage.schemes.affine.affine_space import AffineSpace_generic
+        if isinstance(self.codomain(), AffineSpace_generic):
             raise TypeError("this point must be a point on an affine subscheme")
         return self.codomain().multiplicity(self)
 
diff --git a/src/sage/schemes/affine/affine_rational_point.py b/src/sage/schemes/affine/affine_rational_point.py
index 4ac17a60d79..ff0b88c31f9 100644
--- a/src/sage/schemes/affine/affine_rational_point.py
+++ b/src/sage/schemes/affine/affine_rational_point.py
@@ -54,7 +54,7 @@
 
 from sage.rings.integer_ring import ZZ
 from sage.rings.rational_field import QQ
-from sage.schemes.generic.scheme import is_Scheme
+from sage.schemes.generic.scheme import Scheme
 
 
 def enum_affine_rational_field(X, B):
@@ -108,12 +108,12 @@ def enum_affine_rational_field(X, B):
 
     - Raman Raghukul 2018: updated.
     """
-    from sage.schemes.affine.affine_space import is_AffineSpace
-    if is_Scheme(X):
-        if not is_AffineSpace(X.ambient_space()):
+    from sage.schemes.affine.affine_space import AffineSpace_generic
+    if isinstance(X, Scheme):
+        if not isinstance(X.ambient_space(), AffineSpace_generic):
             raise TypeError("ambient space must be affine space over the rational field")
         X = X(X.base_ring())
-    elif not is_AffineSpace(X.codomain().ambient_space()):
+    elif not isinstance(X.codomain().ambient_space(), AffineSpace_generic):
         raise TypeError("codomain must be affine space over the rational field")
 
     n = X.codomain().ambient_space().ngens()
@@ -215,12 +215,12 @@ def enum_affine_number_field(X, **kwds):
     B = kwds.pop('bound')
     tol = kwds.pop('tolerance', 1e-2)
     prec = kwds.pop('precision', 53)
-    from sage.schemes.affine.affine_space import is_AffineSpace
-    if is_Scheme(X):
-        if not is_AffineSpace(X.ambient_space()):
+    from sage.schemes.affine.affine_space import AffineSpace_generic
+    if isinstance(X, Scheme):
+        if not isinstance(X.ambient_space(), AffineSpace_generic):
             raise TypeError("ambient space must be affine space over a number field")
         X = X(X.base_ring())
-    elif not is_AffineSpace(X.codomain().ambient_space()):
+    elif not isinstance(X.codomain().ambient_space(), AffineSpace_generic):
         raise TypeError("codomain must be affine space over a number field")
 
     R = X.codomain().ambient_space()
@@ -289,12 +289,12 @@ def enum_affine_finite_field(X):
 
     - John Cremona and Charlie Turner (06-2010)
     """
-    from sage.schemes.affine.affine_space import is_AffineSpace
-    if is_Scheme(X):
-        if not is_AffineSpace(X.ambient_space()):
+    from sage.schemes.affine.affine_space import AffineSpace_generic
+    if isinstance(X, Scheme):
+        if not isinstance(X.ambient_space(), AffineSpace_generic):
             raise TypeError("ambient space must be affine space over a finite field")
         X = X(X.base_ring())
-    elif not is_AffineSpace(X.codomain().ambient_space()):
+    elif not isinstance(X.codomain().ambient_space(), AffineSpace_generic):
         raise TypeError("codomain must be affine space over a finite field")
 
     n = X.codomain().ambient_space().ngens()
diff --git a/src/sage/schemes/affine/affine_space.py b/src/sage/schemes/affine/affine_space.py
index 05d3c5b59e3..76316311615 100644
--- a/src/sage/schemes/affine/affine_space.py
+++ b/src/sage/schemes/affine/affine_space.py
@@ -46,12 +46,17 @@ def is_AffineSpace(x) -> bool:
 
         sage: from sage.schemes.affine.affine_space import is_AffineSpace
         sage: is_AffineSpace(AffineSpace(5, names='x'))
+        doctest:warning...
+        DeprecationWarning: The function is_AffineSpace is deprecated; use 'isinstance(..., AffineSpace_generic)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
         sage: is_AffineSpace(AffineSpace(5, GF(9, 'alpha'), names='x'))                 # needs sage.rings.finite_rings
         True
         sage: is_AffineSpace(Spec(ZZ))
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_AffineSpace is deprecated; use 'isinstance(..., AffineSpace_generic)' instead.")
     return isinstance(x, AffineSpace_generic)
 
 
diff --git a/src/sage/schemes/affine/all.py b/src/sage/schemes/affine/all.py
index 68a540a9f1f..e761ce307c9 100644
--- a/src/sage/schemes/affine/all.py
+++ b/src/sage/schemes/affine/all.py
@@ -2,7 +2,7 @@
 all.py -- export of affine to Sage
 """
 
-#*****************************************************************************
+# *****************************************************************************
 #
 #   Sage: Open Source Mathematical Software
 #
@@ -17,8 +17,8 @@
 #
 #  The full text of the GPL is available at:
 #
-#                  http://www.gnu.org/licenses/
-#*****************************************************************************
+#                  https://www.gnu.org/licenses/
+# *****************************************************************************
 
-from .affine_space import AffineSpace
-from .affine_rational_point import enum_affine_rational_field, enum_affine_finite_field
+from sage.schemes.affine.affine_space import AffineSpace
+from sage.schemes.affine.affine_rational_point import enum_affine_rational_field, enum_affine_finite_field
diff --git a/src/sage/schemes/all.py b/src/sage/schemes/all.py
index 23858c6f0c8..f5126a0dee1 100644
--- a/src/sage/schemes/all.py
+++ b/src/sage/schemes/all.py
@@ -2,7 +2,7 @@
 all.py -- export of schemes to Sage
 """
 
-#*****************************************************************************
+# *****************************************************************************
 #
 #   Sage: Open Source Mathematical Software
 #
@@ -17,31 +17,31 @@
 #
 #  The full text of the GPL is available at:
 #
-#                  http://www.gnu.org/licenses/
-#*****************************************************************************
+#                  https://www.gnu.org/licenses/
+# *****************************************************************************
 
-from .jacobians.all import *
+from sage.schemes.jacobians.all import *
 
-from .hyperelliptic_curves.all import *
+from sage.schemes.hyperelliptic_curves.all import *
 
-from .curves.all import *
+from sage.schemes.curves.all import *
 
-from .plane_conics.all import *
+from sage.schemes.plane_conics.all import *
 
-from .elliptic_curves.all import *
+from sage.schemes.elliptic_curves.all import *
 
-from .plane_quartics.all import *
+from sage.schemes.plane_quartics.all import *
 
-from .generic.all import *
+from sage.schemes.generic.all import *
 
-from .toric.all import *
+from sage.schemes.toric.all import *
 
-from .affine.all import *
+from sage.schemes.affine.all import *
 
-from .projective.all import *
+from sage.schemes.projective.all import *
 
-from .product_projective.all import *
+from sage.schemes.product_projective.all import *
 
-from .cyclic_covers.all import *
+from sage.schemes.cyclic_covers.all import *
 
-from .berkovich.all import *
+from sage.schemes.berkovich.all import *
diff --git a/src/sage/schemes/berkovich/all.py b/src/sage/schemes/berkovich/all.py
index cc7af01a057..18b4254e4a8 100644
--- a/src/sage/schemes/berkovich/all.py
+++ b/src/sage/schemes/berkovich/all.py
@@ -2,4 +2,4 @@
 all.py -- export of Berkovich spaces to all of Sage
 """
 
-from .berkovich_space import Berkovich_Cp_Affine, Berkovich_Cp_Projective
+from sage.schemes.berkovich.berkovich_space import Berkovich_Cp_Affine, Berkovich_Cp_Projective
diff --git a/src/sage/schemes/berkovich/berkovich_space.py b/src/sage/schemes/berkovich/berkovich_space.py
index 100c2807b9d..766ae7c4388 100644
--- a/src/sage/schemes/berkovich/berkovich_space.py
+++ b/src/sage/schemes/berkovich/berkovich_space.py
@@ -35,8 +35,8 @@
 from sage.schemes.berkovich.berkovich_cp_element import (Berkovich_Element_Cp_Affine,
                                                          Berkovich_Element_Cp_Projective)
 from sage.structure.parent import Parent
-from sage.schemes.affine.affine_space import is_AffineSpace
-from sage.schemes.projective.projective_space import is_ProjectiveSpace, ProjectiveSpace
+from sage.schemes.affine.affine_space import AffineSpace_generic
+from sage.schemes.projective.projective_space import ProjectiveSpace_ring, ProjectiveSpace
 from sage.structure.unique_representation import UniqueRepresentation
 from sage.categories.number_fields import NumberFields
 import sage.rings.abc
@@ -60,8 +60,13 @@ def is_Berkovich(space) -> bool:
         sage: B = Berkovich_Cp_Projective(3)
         sage: from sage.schemes.berkovich.berkovich_space import is_Berkovich
         sage: is_Berkovich(B)
+        doctest:warning...
+        DeprecationWarning: The function is_Berkovich is deprecated; use 'isinstance(..., Berkovich)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_Berkovich is deprecated; use 'isinstance(..., Berkovich)' instead.")
     return isinstance(space, Berkovich)
 
 
@@ -77,10 +82,15 @@ def is_Berkovich_Cp(space) -> bool:
     EXAMPLES::
 
         sage: B = Berkovich_Cp_Projective(3)
-        sage: from sage.schemes.berkovich.berkovich_space import is_Berkovich
-        sage: is_Berkovich(B)
+        sage: from sage.schemes.berkovich.berkovich_space import is_Berkovich_Cp
+        sage: is_Berkovich_Cp(B)
+        doctest:warning...
+        DeprecationWarning: The function is_Berkovich_Cp is deprecated; use 'isinstance(..., Berkovich_Cp)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_Berkovich_Cp is deprecated; use 'isinstance(..., Berkovich_Cp)' instead.")
     return isinstance(space, Berkovich_Cp)
 
 
@@ -433,7 +443,7 @@ def __init__(self, base, ideal=None):
                 base = Qp(base)  # change to Qpbar
             else:
                 raise ValueError("non-prime passed into Berkovich space")
-        if is_AffineSpace(base):
+        if isinstance(base, AffineSpace_generic):
             base = base.base_ring()
         if base in NumberFields():
             if ideal is None:
@@ -630,7 +640,7 @@ def __init__(self, base, ideal=None):
                 raise ValueError("non-prime passed into Berkovich space")
         if base in NumberFields() or isinstance(base, sage.rings.abc.pAdicField):
             base = ProjectiveSpace(base, 1)
-        if not is_ProjectiveSpace(base):
+        if not isinstance(base, ProjectiveSpace_ring):
             try:
                 base = ProjectiveSpace(base)
             except (TypeError, ValueError):
diff --git a/src/sage/schemes/curves/affine_curve.py b/src/sage/schemes/curves/affine_curve.py
index efbc690b543..b3ed871794f 100644
--- a/src/sage/schemes/curves/affine_curve.py
+++ b/src/sage/schemes/curves/affine_curve.py
@@ -149,7 +149,7 @@
 from sage.rings.rational_field import is_RationalField
 from sage.rings.infinity import infinity
 
-from sage.schemes.affine.affine_space import AffineSpace, is_AffineSpace
+from sage.schemes.affine.affine_space import AffineSpace, AffineSpace_generic
 from sage.schemes.affine.affine_subscheme import (AlgebraicScheme_subscheme_affine,
                                                   AlgebraicScheme_subscheme_affine_field)
 
@@ -209,7 +209,7 @@ def __init__(self, A, X):
             sage: C = Curve([x^2 - z, z - 8*x], A); C
             Affine Curve over Finite Field of size 7 defined by x^2 - z, -x + z
         """
-        if not is_AffineSpace(A):
+        if not isinstance(A, AffineSpace_generic):
             raise TypeError("A (={}) must be an affine space".format(A))
 
         Curve_generic.__init__(self, A, X)
@@ -299,7 +299,7 @@ def __init__(self, A, f):
             Affine Plane Curve over Complex Field with 53 bits of precision defined
             by x^2 + y^2
         """
-        if not (is_AffineSpace(A) and A.dimension != 2):
+        if not (isinstance(A, AffineSpace_generic) and A.dimension != 2):
             raise TypeError("Argument A (= %s) must be an affine plane." % A)
 
         super().__init__(A, [f])
@@ -464,7 +464,7 @@ def plot(self, *args, **kwds):
         A 5-nodal curve of degree 11.  This example also illustrates
         some of the optional arguments::
 
-            sage: # needs sage.plot()
+            sage: # needs sage.plot
             sage: R. = ZZ[]
             sage: C = Curve(32*x^2 - 2097152*y^11 + 1441792*y^9
             ....:            - 360448*y^7 + 39424*y^5 - 1760*y^3 + 22*y - 1)
@@ -998,7 +998,7 @@ def projection(self, indices, AS=None):
         if len(set(indices)) < len(indices):
             raise ValueError("(=%s) must be a list or tuple of distinct indices or variables" % indices)
         if AS is not None:
-            if not is_AffineSpace(AS):
+            if not isinstance(AS, AffineSpace_generic):
                 raise TypeError("(=%s) must be an affine space" % AS)
             if AS.dimension_relative() != len(indices):
                 raise TypeError("(=%s) must have dimension (=%s)" % (AS, len(indices)))
diff --git a/src/sage/schemes/curves/all.py b/src/sage/schemes/curves/all.py
index b34592457c6..848daa43470 100644
--- a/src/sage/schemes/curves/all.py
+++ b/src/sage/schemes/curves/all.py
@@ -2,7 +2,7 @@
 Plane curves
 """
 
-#*****************************************************************************
+# *****************************************************************************
 #
 #   Sage: Open Source Mathematical Software
 #
@@ -17,12 +17,11 @@
 #
 #  The full text of the GPL is available at:
 #
-#                  http://www.gnu.org/licenses/
-#*****************************************************************************
+#                  https://www.gnu.org/licenses/
+# *****************************************************************************
 
-from .constructor import Curve
-
-from .projective_curve import Hasse_bounds
+from sage.schemes.curves.constructor import Curve
+from sage.schemes.curves.projective_curve import Hasse_bounds
 
 from sage.misc.lazy_import import lazy_import
 
diff --git a/src/sage/schemes/curves/constructor.py b/src/sage/schemes/curves/constructor.py
index 3564cfd73cc..a49b2002495 100644
--- a/src/sage/schemes/curves/constructor.py
+++ b/src/sage/schemes/curves/constructor.py
@@ -46,10 +46,10 @@
 
 from sage.structure.all import Sequence
 
-from sage.schemes.generic.ambient_space import is_AmbientSpace
-from sage.schemes.generic.algebraic_scheme import is_AlgebraicScheme
-from sage.schemes.affine.affine_space import AffineSpace, is_AffineSpace
-from sage.schemes.projective.projective_space import ProjectiveSpace, is_ProjectiveSpace
+from sage.schemes.generic.ambient_space import AmbientSpace
+from sage.schemes.generic.algebraic_scheme import AlgebraicScheme
+from sage.schemes.affine.affine_space import AffineSpace, AffineSpace_generic
+from sage.schemes.projective.projective_space import ProjectiveSpace, ProjectiveSpace_ring
 from sage.schemes.plane_conics.constructor import Conic
 
 from .projective_curve import (ProjectiveCurve,
@@ -233,10 +233,10 @@ def Curve(F, A=None):
         0
     """
     if A is None:
-        if is_AmbientSpace(F) and F.dimension() == 1:
+        if isinstance(F, AmbientSpace) and F.dimension() == 1:
             return Curve(F.coordinate_ring().zero(), F)
 
-        if is_AlgebraicScheme(F):
+        if isinstance(F, AlgebraicScheme):
             return Curve(F.defining_polynomials(), F.ambient_space())
 
         if isinstance(F, (list, tuple)):
@@ -291,7 +291,7 @@ def Curve(F, A=None):
         else:
             raise TypeError("F (={}) must be a multivariate polynomial".format(F))
     else:
-        if not is_AmbientSpace(A):
+        if not isinstance(A, AmbientSpace):
             raise TypeError("ambient space must be either an affine or projective space")
         if not isinstance(F, (list, tuple)):
             F = [F]
@@ -304,7 +304,7 @@ def Curve(F, A=None):
 
     k = A.base_ring()
 
-    if is_AffineSpace(A):
+    if isinstance(A, AffineSpace_generic):
         if n == 1:
             if A.coordinate_ring().ideal(F).is_zero():
                 if isinstance(k, FiniteField):
@@ -337,7 +337,7 @@ def Curve(F, A=None):
             return AffinePlaneCurve_field(A, F)
         return AffinePlaneCurve(A, F)
 
-    elif is_ProjectiveSpace(A):
+    elif isinstance(A, ProjectiveSpace_ring):
         if n == 1:
             if A.coordinate_ring().ideal(F).is_zero():
                 if isinstance(k, FiniteField):
diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py
index 1cc7fce0906..fb1edc7d0ad 100644
--- a/src/sage/schemes/curves/projective_curve.py
+++ b/src/sage/schemes/curves/projective_curve.py
@@ -158,7 +158,7 @@
 from sage.rings.rational_field import is_RationalField
 from sage.rings.integer import Integer
 
-from sage.schemes.projective.projective_space import ProjectiveSpace, is_ProjectiveSpace
+from sage.schemes.projective.projective_space import ProjectiveSpace, ProjectiveSpace_ring
 
 from sage.schemes.projective.projective_subscheme import (AlgebraicScheme_subscheme_projective,
                                                           AlgebraicScheme_subscheme_projective_field)
@@ -215,7 +215,7 @@ def __init__(self, A, X, category=None):
             sage: loads(dumps(C)) == C
             True
         """
-        if not is_ProjectiveSpace(A):
+        if not isinstance(A, ProjectiveSpace_ring):
             raise TypeError("A (=%s) must be a projective space" % A)
 
         Curve_generic.__init__(self, A, X, category=category)
@@ -419,7 +419,7 @@ def projection(self, P=None, PS=None):
         if self.base_ring() not in Fields():
             raise TypeError("this curve must be defined over a field")
         if PS is not None:
-            if not is_ProjectiveSpace(PS):
+            if not isinstance(PS, ProjectiveSpace_ring):
                 raise TypeError("(=%s) must be a projective space" % PS)
             if PS.dimension_relative() != n - 1:
                 raise TypeError("(=%s) must have dimension (=%s)" % (PS, n - 1))
@@ -621,7 +621,7 @@ def __init__(self, A, f, category=None):
             sage: loads(dumps(C)) == C
             True
         """
-        if not (is_ProjectiveSpace(A) and A.dimension != 2):
+        if not (isinstance(A, ProjectiveSpace_ring) and A.dimension != 2):
             raise TypeError("the ambient space is not a projective plane")
 
         super().__init__(A, [f], category=category)
diff --git a/src/sage/schemes/cyclic_covers/all.py b/src/sage/schemes/cyclic_covers/all.py
index b1fcd806e7a..88b3d6b3f04 100644
--- a/src/sage/schemes/cyclic_covers/all.py
+++ b/src/sage/schemes/cyclic_covers/all.py
@@ -1 +1 @@
-from .constructor import CyclicCover
+from sage.schemes.cyclic_covers.constructor import CyclicCover
diff --git a/src/sage/schemes/elliptic_curves/all.py b/src/sage/schemes/elliptic_curves/all.py
index f4abce51a62..84f7b0d5a50 100644
--- a/src/sage/schemes/elliptic_curves/all.py
+++ b/src/sage/schemes/elliptic_curves/all.py
@@ -2,7 +2,7 @@
 Exported elliptic curves functionality
 """
 
-#*****************************************************************************
+# *****************************************************************************
 #       Copyright (C) 2005 William Stein 
 #
 #  Distributed under the terms of the GNU General Public License (GPL)
@@ -14,34 +14,35 @@
 #
 #  The full text of the GPL is available at:
 #
-#                  http://www.gnu.org/licenses/
-#*****************************************************************************
+#                  https://www.gnu.org/licenses/
+# *****************************************************************************
 
-from .constructor import (EllipticCurve,
-                         EllipticCurve_from_c4c6,
-                         EllipticCurve_from_j,
-                         EllipticCurve_from_cubic,
-                         EllipticCurves_with_good_reduction_outside_S)
+from sage.schemes.elliptic_curves.constructor import (EllipticCurve,
+                                                      EllipticCurve_from_c4c6,
+                                                      EllipticCurve_from_j,
+                                                      EllipticCurve_from_cubic,
+                                                      EllipticCurves_with_good_reduction_outside_S)
 
 from sage.misc.lazy_import import lazy_import
 lazy_import('sage.schemes.elliptic_curves.jacobian', 'Jacobian')
 
+lazy_import('sage.schemes.elliptic_curves.ell_finite_field', 'special_supersingular_curve')
+
 lazy_import('sage.schemes.elliptic_curves.ell_rational_field',
             ['cremona_curves', 'cremona_optimal_curves'])
 
-lazy_import('sage.schemes.elliptic_curves.ell_finite_field', 'special_supersingular_curve')
-
-from .cm import ( cm_orders,
-                 cm_j_invariants,
-                 cm_j_invariants_and_orders,
-                 hilbert_class_polynomial )
+from sage.schemes.elliptic_curves.cm import (cm_orders,
+                                             cm_j_invariants,
+                                             cm_j_invariants_and_orders,
+                                             hilbert_class_polynomial)
 
 lazy_import('sage.schemes.elliptic_curves.ec_database', 'elliptic_curves')
 
-from .kodaira_symbol import KodairaSymbol
+from sage.schemes.elliptic_curves.kodaira_symbol import KodairaSymbol
 
-from .ell_curve_isogeny import EllipticCurveIsogeny, isogeny_codomain_from_kernel
+from sage.schemes.elliptic_curves.ell_curve_isogeny import EllipticCurveIsogeny, isogeny_codomain_from_kernel
 
 lazy_import('sage.schemes.elliptic_curves.mod_poly', 'classical_modular_polynomial')
 
-from .heegner import heegner_points, heegner_point
+from sage.schemes.elliptic_curves.heegner import heegner_points, heegner_point
+del lazy_import
diff --git a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
index 01626ef03ea..4bd4cc6cea9 100644
--- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
@@ -204,7 +204,7 @@ cdef int lemma7(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e,
 
     if padic_square(g_of_x, p):
         mpz_clear(g_of_x)
-        return +1 # soluble
+        return +1  # soluble
 
     mpz_init_set(g_prime_of_x, x)
     mpz_mul(g_prime_of_x, a, x)
@@ -235,8 +235,8 @@ cdef int lemma7(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e,
             elif lambd+1 == mu+nu and (lambd & 1) == 0:
                 result = 1  # soluble
             elif lambd+2 == mu+nu and (lambd & 1) == 0 and g_of_x_odd_part_mod_4 == 1:
-                result = 1 # soluble
-        else: # nu <= mu
+                result = 1  # soluble
+        else:  # nu <= mu
             if lambd >= 2*nu:
                 result = 0  # undecided
             elif lambd+2 == 2*nu and g_of_x_odd_part_mod_4==1:
@@ -335,7 +335,7 @@ cdef bint Zp_soluble_siksek(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e,
         nmod_poly_set_coeff_ui(f, 4, mpz_fdiv_ui(a, pp_ui))
 
         result = 0
-        (f_factzn)[0].num = 0 # reset data struct
+        (f_factzn)[0].num = 0  # reset data struct
         qq = nmod_poly_factor(f_factzn, f)
         for i in range(f_factzn.num):
             if f_factzn.exp[i]&1:
@@ -352,7 +352,7 @@ cdef bint Zp_soluble_siksek(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e,
             for j in range(f_factzn.exp[i]>>1):
                 nmod_poly_mul(f, f, &f_factzn.p[i])
 
-        (f_factzn)[0].num = 0 # reset data struct
+        (f_factzn)[0].num = 0  # reset data struct
         nmod_poly_factor(f_factzn, f)
         has_roots = 0
         j = 0
@@ -371,13 +371,13 @@ cdef bint Zp_soluble_siksek(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e,
         mpz_init(ddd)
         mpz_init(eee)
 
-        if i == 0: # g == 1
+        if i == 0:  # g == 1
             mpz_set(aaa, a)
             mpz_set(bbb, b)
             mpz_set(ccc, c)
             mpz_set(ddd, d)
             mpz_sub_ui(eee, e, qq)
-        elif i == 1: # g == x + rr
+        elif i == 1:  # g == x + rr
             mpz_set(aaa, a)
             mpz_set(bbb, b)
             mpz_sub_ui(ccc, c, qq)
@@ -387,7 +387,7 @@ cdef bint Zp_soluble_siksek(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e,
             mpz_sub_ui(ddd, ddd, ss*2)
             mpz_set(eee,e)
             mpz_sub_ui(eee, eee, ss*rr)
-        elif i == 2: # g == x^2 + rr*x + ss
+        elif i == 2:  # g == x^2 + rr*x + ss
             mpz_sub_ui(aaa, a, qq)
             rr = nmod_poly_get_coeff_ui(f, 1)
             mpz_init(tt)
@@ -470,7 +470,7 @@ cdef bint Zp_soluble_siksek(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e,
         nmod_poly_set_coeff_ui(f, 2, mpz_fdiv_ui(c, pp_ui))
         nmod_poly_set_coeff_ui(f, 3, mpz_fdiv_ui(b, pp_ui))
         nmod_poly_set_coeff_ui(f, 4, mpz_fdiv_ui(a, pp_ui))
-        (f_factzn)[0].num = 0 # reset data struct
+        (f_factzn)[0].num = 0  # reset data struct
         nmod_poly_factor(f_factzn, f)
         has_roots = 0
         has_single_roots = 0
@@ -619,13 +619,13 @@ cdef bint Zp_soluble_siksek_large_p(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e,
         mpz_init(ddd)
         mpz_init(eee)
 
-        if i == 0: # g == 1
+        if i == 0:  # g == 1
             mpz_set(aaa, a)
             mpz_set(bbb, b)
             mpz_set(ccc, c)
             mpz_set(ddd, d)
             mpz_sub(eee, e, qq)
-        elif i == 1: # g == x + rr
+        elif i == 1:  # g == x + rr
             mpz_set(aaa, a)
             mpz_set(bbb, b)
             mpz_sub(ccc, c, qq)
@@ -639,7 +639,7 @@ cdef bint Zp_soluble_siksek_large_p(mpz_t a, mpz_t b, mpz_t c, mpz_t d, mpz_t e,
             mpz_mul(ss, ss, rr)
             mpz_sub(eee, eee, ss)
             mpz_divexact(ss, ss, rr)
-        elif i == 2: # g == x^2 + rr*x + ss
+        elif i == 2:  # g == x^2 + rr*x + ss
             mpz_sub(aaa, a, qq)
             A = Integer(f[1])
             mpz_set(rr, A.value)
diff --git a/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py b/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py
index 3dc8ea0f11e..c3cdd991e58 100644
--- a/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py
+++ b/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py
@@ -94,7 +94,7 @@
 from sage.rings.fraction_field import FractionField
 
 from sage.schemes.elliptic_curves.constructor import EllipticCurve
-from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
+from sage.schemes.elliptic_curves.ell_generic import EllipticCurve_generic
 
 from sage.schemes.elliptic_curves.weierstrass_morphism \
         import WeierstrassIsomorphism, _isomorphisms, baseWI, negation_morphism
@@ -1042,7 +1042,7 @@ def __init__(self, E, kernel, codomain=None, degree=None, model=None, check=True
                to Elliptic Curve defined by y^2 + x*y = x^3 - x^2 - 5252*x - 178837
                   over Rational Field
         """
-        if not is_EllipticCurve(E):
+        if not isinstance(E, EllipticCurve_generic):
             raise ValueError("given E is not an elliptic curve")
 
         if not isinstance(kernel, list) and kernel in E:
@@ -1854,7 +1854,7 @@ def __setup_post_isomorphism(self, codomain, model):
             codomain = compute_model(oldE2, model)
 
         else:  # codomain is not None
-            if not is_EllipticCurve(codomain):
+            if not isinstance(codomain, EllipticCurve_generic):
                 raise ValueError("given codomain is not an elliptic curve")
 
             if not oldE2.is_isomorphic(codomain):
diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
index 3efa79ff759..237c838b3d4 100644
--- a/src/sage/schemes/elliptic_curves/ell_field.py
+++ b/src/sage/schemes/elliptic_curves/ell_field.py
@@ -444,10 +444,10 @@ def is_quadratic_twist(self, other):
             sage: E1.is_isomorphic(E2)
             True
         """
-        from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
+        from sage.schemes.elliptic_curves.ell_generic import EllipticCurve_generic
         E = self
         F = other
-        if not is_EllipticCurve(E) or not is_EllipticCurve(F):
+        if not isinstance(E, EllipticCurve_generic) or not isinstance(F, EllipticCurve_generic):
             raise ValueError("arguments are not elliptic curves")
         K = E.base_ring()
         zero = K.zero()
@@ -543,10 +543,10 @@ def is_quartic_twist(self, other):
             sage: (D/12345).is_perfect_power(4)
             True
         """
-        from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
+        from sage.schemes.elliptic_curves.ell_generic import EllipticCurve_generic
         E = self
         F = other
-        if not is_EllipticCurve(E) or not is_EllipticCurve(F):
+        if not isinstance(E, EllipticCurve_generic) or not isinstance(F, EllipticCurve_generic):
             raise ValueError("arguments are not elliptic curves")
         K = E.base_ring()
         zero = K.zero()
@@ -612,10 +612,10 @@ def is_sextic_twist(self, other):
             sage: (D/12345).is_perfect_power(6)
             True
         """
-        from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
+        from sage.schemes.elliptic_curves.ell_generic import EllipticCurve_generic
         E = self
         F = other
-        if not is_EllipticCurve(E) or not is_EllipticCurve(F):
+        if not isinstance(E, EllipticCurve_generic) or not isinstance(F, EllipticCurve_generic):
             raise ValueError("arguments are not elliptic curves")
         K = E.base_ring()
         zero = K.zero()
@@ -2065,8 +2065,8 @@ def is_isogenous(self, other, field=None):
             ...
             NotImplementedError: Only implemented for isomorphic curves over general fields.
         """
-        from .ell_generic import is_EllipticCurve
-        if not is_EllipticCurve(other):
+        from .ell_generic import EllipticCurve_generic
+        if not isinstance(other, EllipticCurve_generic):
             raise ValueError("Second argument is not an Elliptic Curve.")
         if self.is_isomorphic(other):
             return True
diff --git a/src/sage/schemes/elliptic_curves/ell_finite_field.py b/src/sage/schemes/elliptic_curves/ell_finite_field.py
index f67e15b5627..5ffd2dc6c0e 100644
--- a/src/sage/schemes/elliptic_curves/ell_finite_field.py
+++ b/src/sage/schemes/elliptic_curves/ell_finite_field.py
@@ -1252,8 +1252,8 @@ def is_isogenous(self, other, field=None, proof=True):
             sage: E1.is_isogenous(E7,GF(13^30,'j'))
             False
         """
-        from .ell_generic import is_EllipticCurve
-        if not is_EllipticCurve(other):
+        from .ell_generic import EllipticCurve_generic
+        if not isinstance(other, EllipticCurve_generic):
             raise ValueError("Second argument is not an Elliptic Curve.")
         if self.is_isomorphic(other):
             return True
diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
index 4719b914bde..7354a6e325e 100644
--- a/src/sage/schemes/elliptic_curves/ell_generic.py
+++ b/src/sage/schemes/elliptic_curves/ell_generic.py
@@ -98,10 +98,15 @@ def is_EllipticCurve(x):
         sage: from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
         sage: E = EllipticCurve([1,2,3/4,7,19])
         sage: is_EllipticCurve(E)
+        doctest:warning...
+        DeprecationWarning: The function is_EllipticCurve is deprecated; use 'isinstance(..., EllipticCurve_generic)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
         sage: is_EllipticCurve(0)
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_EllipticCurve is deprecated; use 'isinstance(..., EllipticCurve_generic)' instead.")
     return isinstance(x, EllipticCurve_generic)
 
 
@@ -456,10 +461,7 @@ def __contains__(self, P):
                 P = self(P)
             except TypeError:
                 return False
-        if P.curve() == self:
-            return True
-        x, y, a = P[0], P[1], self.ainvs()
-        return y**2 + a[0]*x*y + a[2]*y == x**3 + a[1]*x**2 + a[3]*x + a[4]
+        return P.curve() == self
 
     def __call__(self, *args, **kwds):
         r"""
@@ -572,10 +574,7 @@ def __call__(self, *args, **kwds):
         P = args[0]
         if isinstance(P, groups.AdditiveAbelianGroupElement) and isinstance(P.parent(),ell_torsion.EllipticCurveTorsionSubgroup):
             return self(P.element())
-        if isinstance(args[0],
-                      (ell_point.EllipticCurvePoint_field,
-                       ell_point.EllipticCurvePoint_number_field,
-                       ell_point.EllipticCurvePoint)):
+        if isinstance(args[0], ell_point.EllipticCurvePoint):
             if P.curve() is self:
                 return P
             # check if denominator of the point contains a factor of the
@@ -2908,7 +2907,7 @@ def is_isomorphic(self, other, field=None):
             sage: E.is_isomorphic(F.change_ring(CC))
             False
         """
-        if not is_EllipticCurve(other):
+        if not isinstance(other, EllipticCurve_generic):
             return False
         if field is None:
             if self.base_ring() != other.base_ring():
diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
index b0c07df78b6..298cf9277d7 100644
--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
+++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
@@ -92,7 +92,7 @@
 
 import sage.rings.abc
 from .ell_field import EllipticCurve_field
-from .ell_generic import is_EllipticCurve
+from .ell_generic import EllipticCurve_generic
 from .ell_point import EllipticCurvePoint_number_field
 from .constructor import EllipticCurve
 from sage.rings.integer_ring import ZZ
@@ -3176,7 +3176,7 @@ def is_isogenous(self, other, proof=True, maxnorm=100):
             sage: EK.is_isogenous(EcK)      # long time (about 3.5 s)
             True
         """
-        if not is_EllipticCurve(other):
+        if not isinstance(other, EllipticCurve_generic):
             raise ValueError("Second argument is not an Elliptic Curve.")
         if self.is_isomorphic(other):
             return True
diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py
index 99e3e8c81fa..c1817dbd654 100644
--- a/src/sage/schemes/elliptic_curves/ell_point.py
+++ b/src/sage/schemes/elliptic_curves/ell_point.py
@@ -1,18 +1,15 @@
 r"""
 Points on elliptic curves
 
-The base class ``EllipticCurvePoint_field``, derived from
-``AdditiveGroupElement``, provides support for points on elliptic
-curves defined over general fields.  The derived classes
-``EllipticCurvePoint_number_field`` and
-``EllipticCurvePoint_finite_field`` provide further support for point
-on curves defined over number fields (including the rational field
+The base class :class:`EllipticCurvePoint` currently provides little
+functionality of its own.  Its derived class
+:class:`EllipticCurvePoint_field` provides support for points on
+elliptic curves over general fields.  The derived classes
+:class:`EllipticCurvePoint_number_field` and
+:class:`EllipticCurvePoint_finite_field` provide further support for
+points on curves over number fields (including the rational field
 `\QQ`) and over finite fields.
 
-The class ``EllipticCurvePoint``, which is based on
-``SchemeMorphism_point_projective_ring``, currently has little extra
-functionality.
-
 EXAMPLES:
 
 An example over `\QQ`::
@@ -107,7 +104,6 @@
 
 - Mariah Lenox (March 2011) -- Added ``tate_pairing`` and ``ate_pairing``
   functions to ``EllipticCurvePoint_finite_field`` class
-
 """
 
 # ****************************************************************************
@@ -134,6 +130,8 @@
 from sage.rings.real_mpfr import RealField
 from sage.rings.real_mpfr import RR
 import sage.groups.generic as generic
+
+from sage.structure.element import AdditiveGroupElement
 from sage.structure.sequence import Sequence
 from sage.structure.richcmp import richcmp
 
@@ -153,14 +151,41 @@
     PariError = ()
 
 
-class EllipticCurvePoint(SchemeMorphism_point_projective_ring):
+class EllipticCurvePoint(AdditiveGroupElement,
+                         SchemeMorphism_point_projective_ring):
     """
     A point on an elliptic curve.
     """
-    pass
+    def curve(self):
+        """
+        Return the curve that this point is on.
+
+        This is a synonym for :meth:`scheme`.
 
+        EXAMPLES::
 
-class EllipticCurvePoint_field(SchemeMorphism_point_abelian_variety_field):
+            sage: E = EllipticCurve('389a')
+            sage: P = E([-1, 1])
+            sage: P.curve()
+            Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field
+
+            sage: E = EllipticCurve(QQ, [1, 1])
+            sage: P = E(0, 1)
+            sage: P.scheme()
+            Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field
+            sage: P.scheme() == P.curve()
+            True
+            sage: x = polygen(ZZ, 'x')
+            sage: K. = NumberField(x^2 - 3,'a')                                      # needs sage.rings.number_field
+            sage: P = E.base_extend(K)(1, a)                                            # needs sage.rings.number_field
+            sage: P.scheme()                                                            # needs sage.rings.number_field
+            Elliptic Curve defined by y^2 = x^3 + x + 1 over Number Field in a with defining polynomial x^2 - 3
+        """
+        return self.scheme()
+
+
+class EllipticCurvePoint_field(EllipticCurvePoint,
+                               SchemeMorphism_point_abelian_variety_field):
     """
     A point on an elliptic curve over a field.  The point has coordinates
     in the base field.
@@ -275,7 +300,6 @@ def __init__(self, curve, v, check=True):
             v = (R.zero(), R.one(), R.zero())
 
         SchemeMorphism_point_abelian_variety_field.__init__(self, point_homset, v, check=check)
-        # AdditiveGroupElement.__init__(self, point_homset)
 
         self.normalize_coordinates()
 
@@ -426,39 +450,6 @@ def __pari__(self):
         else:
             return pari([0])
 
-    def scheme(self):
-        """
-        Return the scheme of this point, i.e., the curve it is on.
-        This is synonymous with :meth:`curve` which is perhaps more
-        intuitive.
-
-        EXAMPLES::
-
-            sage: E = EllipticCurve(QQ,[1,1])
-            sage: P = E(0,1)
-            sage: P.scheme()
-            Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field
-            sage: P.scheme() == P.curve()
-            True
-            sage: x = polygen(ZZ, 'x')
-            sage: K. = NumberField(x^2 - 3,'a')                                      # needs sage.rings.number_field
-            sage: P = E.base_extend(K)(1, a)                                            # needs sage.rings.number_field
-            sage: P.scheme()                                                            # needs sage.rings.number_field
-            Elliptic Curve defined by y^2 = x^3 + x + 1
-            over Number Field in a with defining polynomial x^2 - 3
-        """
-        # The following text is just not true: it applies to the class
-        # EllipticCurvePoint, which appears to be never used, but does
-        # not apply to EllipticCurvePoint_field which is simply derived
-        # from AdditiveGroupElement.
-        #
-        # "Technically, points on curves in Sage are scheme maps from
-        #  the domain Spec(F) where F is the base field of the curve to
-        #  the codomain which is the curve.  See also domain() and
-        #  codomain()."
-
-        return self.codomain()
-
     def order(self):
         r"""
         Return the order of this point on the elliptic curve.
@@ -497,19 +488,6 @@ def order(self):
 
     additive_order = order
 
-    def curve(self):
-        """
-        Return the curve that this point is on.
-
-        EXAMPLES::
-
-            sage: E = EllipticCurve('389a')
-            sage: P = E([-1,1])
-            sage: P.curve()
-            Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field
-        """
-        return self.scheme()
-
     def __bool__(self):
         """
         Return ``True`` if this is not the zero point on the curve.
diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
index ce77cdca614..44e26cb6f1f 100644
--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
+++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
@@ -52,7 +52,7 @@
 
 from . import constructor
 from . import BSD
-from .ell_generic import is_EllipticCurve
+from .ell_generic import EllipticCurve_generic
 from . import ell_modular_symbols
 from .ell_number_field import EllipticCurve_number_field
 from . import ell_point
@@ -4985,7 +4985,7 @@ def is_isogenous(self, other, proof=True, maxp=200):
             sage: E.is_isogenous(EE)
             False
         """
-        if not is_EllipticCurve(other):
+        if not isinstance(other, EllipticCurve_generic):
             raise ValueError("Second argument is not an Elliptic Curve.")
         if other.base_field() is not QQ:
             raise ValueError("If first argument is an elliptic curve over QQ then the second argument must be also.")
diff --git a/src/sage/schemes/elliptic_curves/heegner.py b/src/sage/schemes/elliptic_curves/heegner.py
index f0ad1420bcf..868f28d025d 100644
--- a/src/sage/schemes/elliptic_curves/heegner.py
+++ b/src/sage/schemes/elliptic_curves/heegner.py
@@ -5762,8 +5762,8 @@ def kolyvagin_reduction_data(E, q, first_only=True):
         sage: kolyvagin_reduction_data(EllipticCurve('2350g1'), 5, first_only=False)
         (19, 239, -311, 19, 6480, 85680)
     """
-    from .ell_generic import is_EllipticCurve
-    if not is_EllipticCurve(E):
+    from .ell_generic import EllipticCurve_generic
+    if not isinstance(E, EllipticCurve_generic):
         raise TypeError("E must be an elliptic curve")
 
     q = ZZ(q)
diff --git a/src/sage/schemes/elliptic_curves/height.py b/src/sage/schemes/elliptic_curves/height.py
index 7ddd080d5b1..920cf47b676 100644
--- a/src/sage/schemes/elliptic_curves/height.py
+++ b/src/sage/schemes/elliptic_curves/height.py
@@ -805,8 +805,8 @@ def __init__(self, E):
             ValueError: EllipticCurveCanonicalHeight class can only be created
             from an elliptic curve defined over a number field
         """
-        from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
-        if is_EllipticCurve(E):
+        from sage.schemes.elliptic_curves.ell_generic import EllipticCurve_generic
+        if isinstance(E, EllipticCurve_generic):
             self.E = E
             from sage.rings.number_field.number_field_base import NumberField
             K = E.base_ring()
diff --git a/src/sage/schemes/elliptic_curves/jacobian.py b/src/sage/schemes/elliptic_curves/jacobian.py
index fcd941b4276..9099a803afc 100644
--- a/src/sage/schemes/elliptic_curves/jacobian.py
+++ b/src/sage/schemes/elliptic_curves/jacobian.py
@@ -111,8 +111,8 @@ def Jacobian(X, **kwds):
         else:
             return Jacobian_of_equation(X, **kwds)
 
-    from sage.schemes.generic.scheme import is_Scheme
-    if is_Scheme(X) and X.dimension() == 1:
+    from sage.schemes.generic.scheme import Scheme
+    if isinstance(X, Scheme) and X.dimension() == 1:
         return Jacobian_of_curve(X, morphism=morphism, **kwds)
 
 
diff --git a/src/sage/schemes/elliptic_curves/mod_sym_num.pyx b/src/sage/schemes/elliptic_curves/mod_sym_num.pyx
index a131dc8a47c..5623f6674ac 100644
--- a/src/sage/schemes/elliptic_curves/mod_sym_num.pyx
+++ b/src/sage/schemes/elliptic_curves/mod_sym_num.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 #cdivision=False
 #cython: cdivision_warnings=False
 #cython: profile=False
@@ -97,11 +96,11 @@ this curve is positive::
 One can compute the numerical approximation to these rational numbers
 to any proven binary precision::
 
-    sage: M.approximative_value(13/17, prec=2) #abs tol 1e-4
+    sage: M.approximative_value(13/17, prec=2) # abs tol 1e-4
     -0.500003172770455
-    sage: M.approximative_value(13/17, prec=4) #abs tol 1e-6
+    sage: M.approximative_value(13/17, prec=4) # abs tol 1e-6
     -0.500000296037388
-    sage: M.approximative_value(0, sign=+1, prec=6) #abs tol 1e-8
+    sage: M.approximative_value(0, sign=+1, prec=6) # abs tol 1e-8
     0.000000000000000
 
 
@@ -330,7 +329,7 @@ cdef int proj_normalise(llong N, llong u, llong  v,
     if `\gcd(u,v,N) \not= 1`, returns 0, 0, 0.
     """
     cdef llong d, k, g, s, t, min_v, min_t, Ng, vNg
-    #verbose("       enter proj_normalise with N=%s, u=%s, v=%s"%(N,u,v),
+    # verbose("       enter proj_normalise with N=%s, u=%s, v=%s" % (N,u,v),
     #        level=5)
     if N == 1:
         uu[0] = 0
@@ -343,7 +342,7 @@ cdef int proj_normalise(llong N, llong u, llong  v,
         v = N - ((-v) % N)
     u = u % N
     v = v % N
-    #verbose("       now N=%s, u=%s, v=%s"%(N,u,v), level=5)
+    # verbose("       now N=%s, u=%s, v=%s" % (N,u,v), level=5)
     if u == 0:
         uu[0] = 0
         if llgcd(v, N) == 1:
@@ -368,7 +367,7 @@ cdef int proj_normalise(llong N, llong u, llong  v,
         d = N / g
         while llgcd(s, N) != 1:
             s = (s+d) % N
-    #verbose("       now g=%s, s=%s, t=%s"%(g,s,t), level=5)
+    # verbose("       now g=%s, s=%s, t=%s" % (g,s,t), level=5)
 
     # Multiply [u,v] by s; then [s*u,s*v] = [g,s*v] (mod N)
     u = g
@@ -390,7 +389,7 @@ cdef int proj_normalise(llong N, llong u, llong  v,
     v = min_v
     uu[0] = u
     vv[0] = v
-    #verbose("       leaving proj_normalise with s=%s, t=%s"%(u,v), level=5)
+    # verbose("       leaving proj_normalise with s=%s, t=%s" % (u,v), level=5)
     return 0
 
 
@@ -430,7 +429,7 @@ cdef int best_proj_point(llong u, llong v, llong N,
     """
     cdef llong w, p, q, Nnew, r, a, b, si
     cdef llong x0, x1, y0, y1, t0, t1, s0, s1
-    #verbose("       enter best_proj_point with N=%s, u=%s, v=%s"%(N,u,v),
+    # verbose("       enter best_proj_point with N=%s, u=%s, v=%s" % (N,u,v),
     #        level=5)
     if u == 0:
         uu[0] = 0
@@ -442,22 +441,22 @@ cdef int best_proj_point(llong u, llong v, llong N,
         return 0
 
     if llgcd(u, N) == 1:
-        w = (v * llinvmod(u, N) ) % N
+        w = (v * llinvmod(u, N)) % N
         y0 = 0
         y1 = N
         x0 = 1
         x1 = w
     elif llgcd(v, N) == 1:
-        w = (u * llinvmod(v,N) ) % N
+        w = (u * llinvmod(v, N)) % N
         y0 = N
         y1 = 0
         x0 = w
         x1 = 1
-    else: # cases like (p:q) mod p*q drop here
+    else:  # cases like (p:q) mod p*q drop here
         p = llgcd(u, N)
         q = llgcd(v, N)
         Nnew = N / p / q
-        w = ( (u/p) * llinvmod(v/q, Nnew) ) % Nnew
+        w = ((u/p) * llinvmod(v/q, Nnew)) % Nnew
         y0 = N/q
         y1 = 0
         x0 = w*p
@@ -471,13 +470,13 @@ cdef int best_proj_point(llong u, llong v, llong N,
             r = (y0-y1) / (x0-x1)
         t0 = y0 - r * x0
         t1 = y1 - r * x1
-        s0 =  t0 - x0
-        s1 =  t1 - x1
+        s0 = t0 - x0
+        s1 = t1 - x1
         if llabs(s0)+llabs(s1) < llabs(t0)+llabs(t1):
             t0 = s0
             t1 = s1
         # t is now the shortest vector on the line y + RR x
-        #verbose("     reduced vector to (%s,%s)"%(t0,t1), level=4)
+        # verbose("     reduced vector to (%s,%s)" % (t0,t1), level=4)
         y0 = x0
         y1 = x1
         x0 = t0
@@ -494,9 +493,9 @@ cdef int best_proj_point(llong u, llong v, llong N,
     else:
         # we fall here if the first two shortest vector are both
         # not permitted, here we do a search until we hit a solution.
-        #verbose("   both shortest vectors ((%s,%s) and (%s,%s)) are not "
+        # verbose("   both shortest vectors ((%s,%s) and (%s,%s)) are not "
         #        "permitted. The result is not guaranteed to "
-        #        "be best possible."%(x0, x1, y0, y1), level=3)
+        #        "be best possible." % (x0, x1, y0, y1), level=3)
         r = 2
         a = 1
         b = a
@@ -515,9 +514,9 @@ cdef int best_proj_point(llong u, llong v, llong N,
                 a = r-1
                 b = 1
                 si = b
-            t0 =  a * x0 + b * y0
-            t1 =  a * x1 + b * y1
-        #verbose("works with t = %s*x+%s*y"%(a, b), level=3)
+            t0 = a * x0 + b * y0
+            t1 = a * x1 + b * y1
+        # verbose("works with t = %s*x+%s*y" % (a, b), level=3)
         uu[0] = t0
         vv[0] = t1
         return 0
@@ -564,7 +563,7 @@ cdef class _CuspsForModularSymbolNumerical:
     It is to only to be used internally.
     """
     cdef public llong _a, _m, _width
-    cdef public llong _N_level # trac 29290 renamed
+    cdef public llong _N_level  # trac 29290 renamed
     cdef public Rational _r
 
     def __init__(self, Rational r, llong N):
@@ -584,14 +583,14 @@ cdef class _CuspsForModularSymbolNumerical:
             sage: r = _CuspsForModularSymbolNumerical(3/7,99)
         """
         cdef llong a, m, B
-        #verbose("       enter __init__ of cusps with r=%s and N=%s"%(r,N),
+        # verbose("       enter __init__ of cusps with r=%s and N=%s" % (r,N),
         #        level=5)
-        a = ( r.numerator() )
-        m = ( r.denominator() )
+        a = (r.numerator())
+        m = (r.denominator())
         a = a % m
         if 2*a > m:
             a -= m
-        self._r = Rational( (a, m) )
+        self._r = Rational((a, m))
         B = llgcd(m, N)
         self._width = N / B
         self._a = a
@@ -622,20 +621,20 @@ cdef class _CuspsForModularSymbolNumerical:
         """
         cdef llong Q, B, c, x, y
 
-        #verbose("       enter atkin_lehner for cusp r=%s"%self._r, level=5)
+        # verbose("       enter atkin_lehner for cusp r=%s" % self._r, level=5)
         Q = self._width
         B = llgcd(self._m, self._N_level)
         c = self._m / B
         if llgcd(Q, B) != 1:
             raise ValueError("This cusp is not in the Atkin-Lehner "
                              "orbit of oo.")
-        _ = llxgcd( self._a * Q, self._m, &x, &y)
+        _ = llxgcd(self._a * Q, self._m, &x, &y)
         res[0] = Q * x
         res[1] = y
         res[2] = -c * self._N_level
-        res[3] =  Q * self._a
-        #verbose("       leaving atkin_lehner with w_Q = "
-        #        "[%s, %s, %s, %s]"%(res[0], res[1], res[2], res[3]),
+        res[3] = Q * self._a
+        # verbose("       leaving atkin_lehner with w_Q = "
+        #        "[%s, %s, %s, %s]" % (res[0], res[1], res[2], res[3]),
         #        level=5)
         return 0
 
@@ -754,11 +753,13 @@ cdef class ModularSymbolNumerical:
             sage: M(12/11) # indirect doctest
             1/2
         """
-        self._ans_num =  sig_malloc( 1002 * sizeof(double) )
-        self._ans =  sig_malloc(1002 * sizeof(int) )
+        self._ans_num =  sig_malloc(1002 * sizeof(double))
+        self._ans =  sig_malloc(1002 * sizeof(int))
         if self._ans is NULL or self._ans_num is NULL:
-            if self._ans is not NULL: sig_free(self._ans)
-            if self._ans_num is not NULL: sig_free(self._ans_num)
+            if self._ans is not NULL:
+                sig_free(self._ans)
+            if self._ans_num is not NULL:
+                sig_free(self._ans_num)
             raise MemoryError("Memory.")
 
     def __init__(self, E, sign=+1):
@@ -776,11 +777,11 @@ cdef class ModularSymbolNumerical:
             sage: M(1/3, -1)
             1/6
         """
-        #verbose("       enter __init_ of modular symbols", level=5)
+        # verbose("       enter __init_ of modular symbols", level=5)
         self._E = E
         self._Epari= E.pari_mincurve()
         self._global_sign = sign
-        self._N_E = ( E.conductor() )
+        self._N_E = (E.conductor())
         self._D = -Integer(1)
         self._set_epsQs()
         self._initialise_an_coefficients()
@@ -795,7 +796,7 @@ cdef class ModularSymbolNumerical:
         # this is a bound to decide when to go directly to ioo
         # rather than using further convergents.
         # see symbol(r) where it is used
-        self._cut_val = ( E.conductor().isqrt() // 4 )
+        self._cut_val = (E.conductor().isqrt() // 4)
         if self._cut_val < 100:
             self._cut_val = 100
         # this is can be used to disable it
@@ -880,12 +881,12 @@ cdef class ModularSymbolNumerical:
         if sign == 0:
             sign = self._global_sign
 
-        #verbose("       enter __call__ of modular symbols for r=%s"
-        #        "and sign=%s and use_twist=%s"%(r,sign,use_twist), level=5)
+        # verbose("       enter __call__ of modular symbols for r=%s"
+        #        "and sign=%s and use_twist=%s" % (r,sign,use_twist), level=5)
         if isinstance(r, Rational):
             ra = r
         elif isinstance(r, Integer):
-            ra = Rational( (0,1) )
+            ra = Rational((0, 1))
         elif isinstance(r, sage.rings.infinity.PlusInfinity):
             return Rational(0)
         else:  # who knows
@@ -950,12 +951,12 @@ cdef class ModularSymbolNumerical:
         if sign == 0:
             sign = self._global_sign
 
-        #verbose("       enter approximative_value of modular symbols for r=%s,"
-        #        "sign=%s and prec=%s "%(r,sign,prec,), level=5)
+        # verbose("       enter approximative_value of modular symbols for r=%s,"
+        #        "sign=%s and prec=%s " % (r,sign,prec,), level=5)
         if isinstance(r, Rational):
             ra = r
         elif isinstance(r, Integer):
-            ra = Rational( (0,1) )
+            ra = Rational((0, 1))
         else:  # who knows
             raise ValueError("The modular symbol can be evaluated at a"
                              "rational number only.")
@@ -963,8 +964,7 @@ cdef class ModularSymbolNumerical:
             if self._D == -1:
                 self._set_up_twist()
             if self._D != 1:
-                return self._twisted_approx(ra, sign=sign,
-                prec=prec)
+                return self._twisted_approx(ra, sign=sign, prec=prec)
 
         eps = 2
         eps = eps ** (-prec)
@@ -1028,8 +1028,8 @@ cdef class ModularSymbolNumerical:
             int co, cinf, E0cinf
             RealNumber E0om1, E0om2, q
 
-        #verbose("       enter _set_bounds", level=5)
-        N = Integer( self._N_E )
+        # verbose("       enter _set_bounds", level=5)
+        N = Integer(self._N_E)
         E = self._E
         L = E.period_lattice().basis()
         self._om1 = L[0]
@@ -1041,15 +1041,15 @@ cdef class ModularSymbolNumerical:
         # find the best curve to compare it too.
         # if the curve is in the database,
         # we can compare to the X_0-optimal curve
-        isog =  E.isogeny_class()
+        isog = E.isogeny_class()
         if N <= CremonaDatabase().largest_conductor():
             E0 = E.optimal_curve()
         # otherwise, we take a "maximal" curve
         # that the worst that can happen and is sort of the
         # opposite of what we expect, but
         else:
-            ff = lambda C: C.period_lattice().complex_area()
-            E0 = min(isog.curves, key=ff)
+            E0 = min(isog.curves,
+                     key=lambda C: C.period_lattice().complex_area())
         # E0 has now conjecturally Manin constant = 1
 
         # now determine the bound for E0 coming from the
@@ -1071,13 +1071,13 @@ cdef class ModularSymbolNumerical:
         while co < 5 or p < max(100,10*delta) and p < self._lans:
             p += delta
             if p.is_prime() and N % p != 0:
-                t0 = t0.gcd( p + 1 - self._ans[p] )
+                t0 = t0.gcd(p + 1 - self._ans[p])
                 co += 1
             if (p-2).is_prime() and N % (p-2) != 0:
-                t0 = t0.gcd( (p-1)**2 - self._ans[p-2]**2 )
+                t0 = t0.gcd((p-1)**2 - self._ans[p-2]**2)
                 co += 1
         if E0.real_components() == 1:
-            t0 *= Integer(2) # slanted lattice
+            t0 *= Integer(2)  # slanted lattice
 
         # This is a not strictly necessary precaution:
         # Cremona is not always certain to have the optimal
@@ -1096,7 +1096,7 @@ cdef class ModularSymbolNumerical:
         if E0cinf == 1:
             E0om2 *= Integer(2)
 
-        maxdeg = max(max(x) for x in isog.matrix() )
+        maxdeg = max(max(x) for x in isog.matrix())
         q = self._om1 / E0om1 * maxdeg
         q_plus = q.round() / maxdeg
         q = self._om2 / E0om2 * maxdeg
@@ -1136,9 +1136,9 @@ cdef class ModularSymbolNumerical:
         #     N = E.conductor()
         #     Cu = Gamma0(N).cusps()
         #     m = E.modular_symbol()
-        #     d_plus = max( [ denominator(m(r)) for r in Cu if r != oo] )
+        #     d_plus = max([ denominator(m(r)) for r in Cu if r != oo])
         #     m = E.modular_symbol(-1)
-        #     d_minus = max( [ denominator(m(r)) for r in Cu if r != oo] )
+        #     d_minus = max([ denominator(m(r)) for r in Cu if r != oo])
         #     M = ModularSymbolNumerical(E)
         #     print(E.label(), (d_plus, d_minus), (M._t_plus, M._t_minus),
         #           (M._t_unitary_plus, M._t_unitary_plus))
@@ -1160,7 +1160,7 @@ cdef class ModularSymbolNumerical:
         cdef Integer D, ell
         cdef RealNumber qq, Db
 
-        #verbose("       enter _set_up_twist", level=5)
+        # verbose("       enter _set_up_twist", level=5)
         Et, D = self._E.minimal_quadratic_twist()
         # we now have to make sure that |D| is as small as
         # possible (the above may give a D != 1 and yet
@@ -1180,7 +1180,7 @@ cdef class ModularSymbolNumerical:
                 D = -D
             Et = self._E.quadratic_twist(D)
         self._D = D
-        verbose("  twisting by %s to get conductor %s"%(D,Et.conductor()),
+        verbose("  twisting by %s to get conductor %s" % (D, Et.conductor()),
                 level=2)
         # now set up period change
         if D != 1:
@@ -1192,14 +1192,14 @@ cdef class ModularSymbolNumerical:
             # are integers.
             if D > 0:
                 qq = self._om1 * Db/ self._Mt._om1 * 2
-                self._twist_q = Rational( (qq.round(), 2) )
+                self._twist_q = Rational((qq.round(), 2))
                 qq = self._om2 * Db/ self._Mt._om2 * 2
-                assert self._twist_q == Rational( (qq.round(),2) )
+                assert self._twist_q == Rational((qq.round(), 2))
             else:
-                qq =  self._om2 * Db/self._Mt._om1  * 2
-                self._twist_q =  Rational( (qq.round(), 2) )
+                qq = self._om2 * Db/self._Mt._om1 * 2
+                self._twist_q = Rational((qq.round(), 2))
                 qq = self._om1 * Db/self._Mt._om2 * 2
-                assert self._twist_q == Rational( ( qq.round(),2))
+                assert self._twist_q == Rational((qq.round(), 2))
 
     def _round(self, RealNumber val, int sign, int unitary):
         r"""
@@ -1232,7 +1232,7 @@ cdef class ModularSymbolNumerical:
             llong t, r
             RealNumber q, qt
 
-        #verbose("       enter _round with value=%s"%val, level=5)
+        # verbose("       enter _round with value=%s" % val, level=5)
         if sign == 1 and unitary:
             q = val/self._om1
             t = self._t_unitary_plus
@@ -1248,17 +1248,17 @@ cdef class ModularSymbolNumerical:
 
         qt = q * t
         r = qt.round()
-        res = Rational( (r, t) )
+        res = Rational((r, t))
         err = (q-res).abs()
 
         if err > 0.1:
             # the following did not work (compilation failed)
             #from warnings import warn
-            #warn(Rounded an error of %s, looks like a bug."%err,
+            #warn(Rounded an error of %s, looks like a bug." % err,
             # RuntimeWarning, stacklevel=5)
-            print ( "Warning: Rounded an error of ", err, ", looks like a bug "
-                    + "in mod_sym_num.pyx.")
-        verbose("    rounding with an error of %s"%err, level=3)
+            print ("Warning: Rounded an error of ", err, ", looks like a bug "
+                   + "in mod_sym_num.pyx.")
+        verbose("    rounding with an error of %s" % err, level=3)
         return res
 
     def _initialise_an_coefficients(self):
@@ -1272,7 +1272,7 @@ cdef class ModularSymbolNumerical:
             sage: M = E.modular_symbol(implementation="num") #indirect doctest
         """
         cdef int n
-        #verbose("       enter _initialise_an_coeffients", level=5)
+        # verbose("       enter _initialise_an_coeffients", level=5)
         n = 0
         self_ans = self._E.anlist(1000, python_ints=True)
         while n <= 1000:
@@ -1304,25 +1304,27 @@ cdef class ModularSymbolNumerical:
             sage: M._add_an_coefficients(10000)
         """
         cdef llong n
-        #verbose("       enter add_an_coeffs with T=%s"%T, level=5)
+        # verbose("       enter add_an_coeffs with T=%s" % T, level=5)
         # we artificially add 100 extra terms, to avoid calling this
         # function again with only a few new terms
         T += 100
 
         self._ans_num =  sig_realloc(self._ans_num,
-                                                (T+2)*sizeof(double))
-        self._ans =  sig_realloc(self._ans, (T+2)*sizeof(int) )
+                                               (T+2)*sizeof(double))
+        self._ans =  sig_realloc(self._ans, (T+2)*sizeof(int))
         if self._ans is NULL or self._ans_num is NULL:
-            if self._ans is not NULL: sig_free(self._ans)
-            if self._ans_num is not NULL: sig_free(self._ans_num)
+            if self._ans is not NULL:
+                sig_free(self._ans)
+            if self._ans_num is not NULL:
+                sig_free(self._ans_num)
             raise MemoryError("Memory error with coefficients.")
 
         verbose("   not enough precomputed coefficients, "
-                "adding %s"%(T - self._lans), level=3)
+                "adding %s" % (T - self._lans), level=3)
         # if we add more than 20% new values, redo it from scratch
         if 5* T > 6*self._lans:
             self_ans = self._E.anlist(T+1, python_ints=True)
-            n = self._lans # only copy new values
+            n = self._lans  # only copy new values
             while n <= T:
                 self._ans[n] = self_ans[n]
                 n += 1
@@ -1405,8 +1407,8 @@ cdef class ModularSymbolNumerical:
             sage: ms._integration_to_tau(0.3+0.01*I,1000,60) # abs tol 1e-11
             0.41268108621256428 + 0.91370544691462463*I
         """
-        #verbose("       enter _integration_to_tau with tau=%s, T=%s,"
-        #        "prec=%s"%(tau,number_of_terms,prec), level=5)
+        # verbose("       enter _integration_to_tau with tau=%s, T=%s,"
+        #        "prec=%s" % (tau,number_of_terms,prec), level=5)
         cdef ComplexNumber q, s
         cdef int n
 
@@ -1422,17 +1424,17 @@ cdef class ModularSymbolNumerical:
         q = 2 * CC.pi() * CC.gens()[0]
         q *= CC(tau)
         q = q.exp()
-        verbose("     start sum over %s terms "%number_of_terms, level=4)
+        verbose("     start sum over %s terms " % number_of_terms, level=4)
         s = CC(0)
         n = number_of_terms
         # using Horner's rule
         while n > 0:
             sig_check()
             s *= q
-            s +=  CC(self._ans[n])/n
+            s += CC(self._ans[n])/n
             n -= 1
-        s  *= q
-        #verbose("       leaving integration_to_tau with sum=%s"%s, level=5)
+        s *= q
+        # verbose("       leaving integration_to_tau with sum=%s" % s, level=5)
         return s
 
     # the version using double is 70-80 times faster it seems.
@@ -1461,11 +1463,11 @@ cdef class ModularSymbolNumerical:
             sage: from sage.schemes.elliptic_curves.mod_sym_num \
             ....: import ModularSymbolNumerical
             sage: M = ModularSymbolNumerical(EllipticCurve("17a1"))
-            sage: M._from_ioo_to_r_approx(9/13,0.01,use_partials=0) #abs tol 1e-5
+            sage: M._from_ioo_to_r_approx(9/13,0.01,use_partials=0) # abs tol 1e-5
             0.386771552192424 - 2.74574021880459*I
         """
-        #verbose("       enter integrations_to_tau_double with tau=%s,"
-        #        " T=%s"%(tau,number_of_terms), level=5)
+        # verbose("       enter integrations_to_tau_double with tau=%s,"
+        #        " T=%s" % (tau,number_of_terms), level=5)
         cdef complex q, s
         cdef int n
         #self.nc_sums += 1
@@ -1477,10 +1479,10 @@ cdef class ModularSymbolNumerical:
         if number_of_terms > self._lans:
             self._add_an_coefficients(number_of_terms)
 
-        q = complex(0,TWOPI) # 2 pi i
+        q = complex(0, TWOPI)  # 2 pi i
         q *= tau
         q = cexp(q)
-        verbose("     start sum over %s terms "%number_of_terms, level=4)
+        verbose("     start sum over %s terms " % number_of_terms, level=4)
         s = 0
         n = number_of_terms
         # using Horner's rule
@@ -1490,7 +1492,7 @@ cdef class ModularSymbolNumerical:
             s += self._ans_num[n]
             n -= 1
         s *= q
-        #verbose("       leaving integration_to_tau_double with sum=%s"%s,
+        # verbose("       leaving integration_to_tau_double with sum=%s" % s,
         #        level=5)
         return s
 
@@ -1519,11 +1521,11 @@ cdef class ModularSymbolNumerical:
             sage: from sage.schemes.elliptic_curves.mod_sym_num \
             ....: import ModularSymbolNumerical
             sage: M = ModularSymbolNumerical(EllipticCurve("37b2"))
-            sage: M._from_ioo_to_r_approx(0/1,0.01,use_partials=1) #abs tol 1e-5
+            sage: M._from_ioo_to_r_approx(0/1,0.01,use_partials=1) # abs tol 1e-5
             0.725681061936153
         """
-        #verbose("       enter partial_real_sums_double with y=%s, m=%s,"
-        #        " T=%s"%(y,m,number_of_terms), level=5)
+        # verbose("       enter partial_real_sums_double with y=%s, m=%s,"
+        #        " T=%s" % (y,m,number_of_terms), level=5)
         cdef double q, qq
         cdef int n, i
         #self.nc_sums += 1
@@ -1540,7 +1542,7 @@ cdef class ModularSymbolNumerical:
         qq = q * m
         q = exp(q)
         qq = exp(qq)
-        verbose("     start sum over %s terms "%number_of_terms, level=4)
+        verbose("     start sum over %s terms " % number_of_terms, level=4)
         i = 0
         while i < m:
             res[i] = 0
@@ -1550,7 +1552,7 @@ cdef class ModularSymbolNumerical:
         while n > 0:
             sig_check()
             res[i] *= qq
-            res[i] +=  self._ans_num[n]
+            res[i] += self._ans_num[n]
             n -= 1
             i -= 1
             if i == -1:
@@ -1560,13 +1562,13 @@ cdef class ModularSymbolNumerical:
             res[i] *= q ** i
             i += 1
         res[0] *= qq
-        #verbose("       leaving _partial_real_sums_double with result %s,"
-        #        " %s, ... %s"%(res[0], res[1], res[m-1]), level=5)
+        # verbose("       leaving _partial_real_sums_double with result %s,"
+        #        " %s, ... %s" % (res[0], res[1], res[m-1]), level=5)
         return 0
 
     def _partial_real_sums(self, RealNumber y, int m,
-                                       int number_of_terms,
-                                       int prec):
+                           int number_of_terms,
+                           int prec):
         r"""
         Given a real positive number `y` (representing
         the imaginary part of a point in the upper half
@@ -1602,8 +1604,8 @@ cdef class ModularSymbolNumerical:
              4.706713577985852e-8,
              0.0001771330855478248]
         """
-        #verbose("       enter partial_real_sums with y=%s, m=%s,"
-        #        " T=%s"%(y,m,number_of_terms), level=5)
+        # verbose("       enter partial_real_sums with y=%s, m=%s,"
+        #        " T=%s" % (y,m,number_of_terms), level=5)
         cdef RealNumber q, qq
         cdef int n, i
         #self.nc_sums += 1
@@ -1621,7 +1623,7 @@ cdef class ModularSymbolNumerical:
         qq = q * m
         q = q.exp()
         qq = qq.exp()
-        verbose("     start sum over %s terms "%number_of_terms, level=4)
+        verbose("     start sum over %s terms " % number_of_terms, level=4)
         i = 0
         res = []
         while i < m:
@@ -1642,8 +1644,8 @@ cdef class ModularSymbolNumerical:
             res[i] *= q ** i
             i += 1
         res[0] *= qq
-        #verbose("       leaving _partial_real_sums with result"
-        #        " %s, %s, ... %s"%(res[0], res[1], res[m-1]), level=5)
+        # verbose("       leaving _partial_real_sums with result"
+        #        " %s, %s, ... %s" % (res[0], res[1], res[m-1]), level=5)
         return res
 
     #================
@@ -1685,8 +1687,8 @@ cdef class ModularSymbolNumerical:
             sage: M._get_truncation_and_prec(10^(-11),10^(-2))
             (-1, -1)
         """
-        #verbose("       enter _get_truncation_and_prec with y=%s"
-        #        " and eps=%s"%(y,eps), level=5)
+        # verbose("       enter _get_truncation_and_prec with y=%s"
+        #        " and eps=%s" % (y,eps), level=5)
         # how much of the error comes from truncation and how much
         # from precision.
         DEF split_error_truncations = 0.99
@@ -1696,7 +1698,7 @@ cdef class ModularSymbolNumerical:
         cdef int T, B, T0
 
         twopiy = TWOPI
-        twopiy *=  y
+        twopiy *= y
         tt = twopiy
         tt *= split_error_truncations * eps
         tt = log(tt)
@@ -1706,7 +1708,7 @@ cdef class ModularSymbolNumerical:
         else:
             T = -1
             return T, T
-        #verbose("      now tt =%s, twopiy=%s, T=%s"%(tt,twopiy,T), level=4)
+        # verbose("      now tt =%s, twopiy=%s, T=%s" % (tt,twopiy,T), level=4)
 
         # the justification for these numbers is explained at the
         # very end of this file
@@ -1734,23 +1736,23 @@ cdef class ModularSymbolNumerical:
 
         tt -= log(A)/twopiy
         T = min(T, max((ceil(tt)), T0))
-        #verbose("    now tt =%s, twopiy=%s, T=%s"%(tt,twopiy,T), level=4)
+        # verbose("    now tt =%s, twopiy=%s, T=%s" % (tt,twopiy,T), level=4)
 
-        bb =  split_error_prec * eps
-        bb /=  T + bb
-        bb /=  2
-        bb /=  T
+        bb = split_error_prec * eps
+        bb /= T + bb
+        bb /= 2
+        bb /= T
         bb = - log(bb)/ log(2)
         B = (ceil(bb))
         B = max(B, 53)
         T = max(T, 100)
-        #verbose("       leaving _get_truncation_and_prec with T=%s,"
-        #        " B=%s"%(T,B), level=5)
+        # verbose("       leaving _get_truncation_and_prec with T=%s,"
+        #        " B=%s" % (T,B), level=5)
         return T, B
 
-# ===============
+    # ===============
 
-    @cached_method # its modified below for max eps
+    @cached_method  # its modified below for max eps
     def _kappa(self, llong m, llong z, eps=None):
         r"""
         This returns all `\kappa_{j,m}(1/\sqrt{z})` for a given
@@ -1812,7 +1814,7 @@ cdef class ModularSymbolNumerical:
             -2.265525136998248e-05,
             2.3248943281270047e-06]
         """
-        #verbose("       enter _kappa with m=%s, z=%s and eps=%s"%(m,z,eps),
+        # verbose("       enter _kappa with m=%s, z=%s and eps=%s" % (m,z,eps),
         #        level=5)
         cdef:
             int T, prec, j
@@ -1849,8 +1851,8 @@ cdef class ModularSymbolNumerical:
             raise ValueError("Too many terms > 2^31 would have to be"
                              + "summed up. Giving up.")
         T += m
-        #verbose("   precision in _kappa set to %s,"
-        #        " summing over %s terms"%(prec,T), level=3)
+        # verbose("   precision in _kappa set to %s,"
+        #        " summing over %s terms" % (prec,T), level=3)
 
         if prec > 53:
             RR = RealField(prec)
@@ -1861,14 +1863,14 @@ cdef class ModularSymbolNumerical:
             # return a python list of doubles that we cache
             res = [(res[j]) for j in range(m)]
         else:
-            ra =  sig_malloc( m * sizeof(double))
+            ra =  sig_malloc(m * sizeof(double))
             if ra is NULL:
                 raise MemoryError
             _ = self._partial_real_sums_double(y, m, T, ra)
             res = [ra[j] for j in range(m)]
             sig_free(ra)
-        #verbose("       leaving _kappa with"
-        #        " [%s, %s, ... %s]"%(res[0], res[1], res[m-1]), level=5)
+        # verbose("       leaving _kappa with"
+        #        " [%s, %s, ... %s]" % (res[0], res[1], res[m-1]), level=5)
         return res
 
     def _from_ioo_to_r_approx(self, Rational r, double eps,
@@ -1910,7 +1912,7 @@ cdef class ModularSymbolNumerical:
             sage: m = ModularSymbolNumerical(E)
             sage: m._from_ioo_to_r_approx(-1/7,0.01, use_partials=1)  # abs tol 1e-11
             6.22747859174503 - 1.48055642530800*I
-            sage: m._from_ioo_to_r_approx(-1/7,0.01, use_partials=0) #abs tol 1e-11
+            sage: m._from_ioo_to_r_approx(-1/7,0.01, use_partials=0) # abs tol 1e-11
             6.22747410432385 - 1.48055182979493*I
 
         This uses 65 bits of precision::
@@ -1918,8 +1920,8 @@ cdef class ModularSymbolNumerical:
             sage: m._from_ioo_to_r_approx(-1/7,0.0000000001) # abs tol 1e-11
             6.227531974630294568 - 1.480548268241443085*I
         """
-        #verbose("       enter _from_ioo_to_r_approx with r=%s"
-        #        " and eps=%s"%(r,eps), level=5)
+        # verbose("       enter _from_ioo_to_r_approx with r=%s"
+        #        " and eps=%s" % (r,eps), level=5)
         cdef:
             llong m, Q, epsQ, a, u
             double yy, taui
@@ -1948,49 +1950,49 @@ cdef class ModularSymbolNumerical:
         if m == 1:
             use_partials = 0
         if use_partials == 2:
-            use_partials = (prec==53) and ( m**4 < self._N_E or m < PARTIAL_LIMIT)
+            use_partials = (prec==53) and (m**4 < self._N_E or m < PARTIAL_LIMIT)
 
         if not use_partials and prec > 53:
             CC = ComplexField(prec)
             tau = CC(-Q)
             tau = tau.sqrt()
             tau = r - 1/tau/m
-            tauph = (tau * wQ[0]  + wQ[1])/(wQ[2]*tau + wQ[3])
+            tauph = (tau * wQ[0] + wQ[1])/(wQ[2]*tau + wQ[3])
             verbose("  computing integral from i*oo to %s using %s terms "
-                    "and precision %s"%(tau, T, prec),level=2)
+                    "and precision %s" % (tau, T, prec),level=2)
             int1 = self._integration_to_tau(tau, T, prec)
-            verbose("  yields %s "%int1, level=2)
+            verbose("  yields %s " % int1, level=2)
             verbose("  compute integral from %s to %s by computing an "
-                    "integral from i*oo to %s"%(r, tau, tauph),level=2)
+                    "integral from i*oo to %s" % (r, tau, tauph),level=2)
             int2 = self._integration_to_tau(tauph, T, prec)
             int2 *= -epsQ
-            verbose("  yields %s"%int2, level=2)
+            verbose("  yields %s" % int2, level=2)
             return int2 + int1
 
-        elif not use_partials: # prec = 53
+        elif not use_partials:  # prec = 53
             taui = (Q)
             taui = sqrt(taui)
-            taui =  1/taui/m
+            taui = 1/taui/m
             tauc = complex(r, taui)
-            #verbose("act on %s by [[%s,%s],[%s,%s]]"%(tauc, wQ[0],
+            # verbose("act on %s by [[%s,%s],[%s,%s]]" % (tauc, wQ[0],
             # wQ[1], wQ[2], wQ[3]), level =4)
             tauphc = (tauc * wQ[0] + wQ[1])/(wQ[2]*tauc + wQ[3])
             verbose("  computing integral from i*oo to %s using %s terms "
-                    "in fast double precision"%(tauc, T),level=2)
+                    "in fast double precision" % (tauc, T),level=2)
             int1c = self._integration_to_tau_double(tauc, T)
-            verbose("  yields %s "%int1c, level=2)
+            verbose("  yields %s " % int1c, level=2)
             verbose("  compute integral from %s to %s by computing an "
-                    "integral from i*oo to %s"%(r, tauc, tauphc),level=2)
+                    "integral from i*oo to %s" % (r, tauc, tauphc),level=2)
             int2c = self._integration_to_tau_double(tauphc, T)
             int2c *= -epsQ
-            verbose("  yields %s"%int2c, level=2)
+            verbose("  yields %s" % int2c, level=2)
             CC = ComplexField(prec)
             return CC(int2c + int1c)
 
-        else: # use_partial
+        else:  # use_partial
             verbose("  computing integral from i*oo to %s using "
                     "using partials with "
-                    "y =%s"%(r, yy), level=2)
+                    "y =%s" % (r, yy), level=2)
             ka = self._kappa(m, m*m*Q,eps/2)
             a = rc._a
             twopii = TWOPI * complex("j")
@@ -1998,23 +2000,23 @@ cdef class ModularSymbolNumerical:
             ze1 = cexp(ze1)
             u = llinvmod(Q * a, m)
             ze2 = - twopii / m * u
-            ze2 =  cexp(ze2)
+            ze2 = cexp(ze2)
             j = 0
             su = 0
             verbose("      summing up %s partial sums, having set u = %s,"
-                    " z1 =%s, z2=%s"%(m,u,ze1,ze2), level=4)
+                    " z1 =%s, z2=%s" % (m, u, ze1, ze2), level=4)
             while j < m:
                 sig_check()
-                su += ka[j] * ( (ze1 ** j) - epsQ * (ze2 ** j))
+                su += ka[j] * ((ze1 ** j) - epsQ * (ze2 ** j))
                 j += 1
             CC = ComplexField(prec)
             return CC(su)
 
     cdef _from_r_to_rr_approx_direct(self, Rational r, Rational rr,
                                      Integer epsQ, Integer epsQQ,
-                                    llong* wQ, llong* wQQ,
-                                    int T, int prec, double eps,
-                                    int use_partials=2):
+                                     llong* wQ, llong* wQQ,
+                                     int T, int prec, double eps,
+                                     int use_partials=2):
         r"""
         This is just a helper function for _from_r_to_rr_approx. In case
         the integral is evaluated directly this function is called.
@@ -2050,8 +2052,8 @@ cdef class ModularSymbolNumerical:
             int oi, j
             double x1d, x2d, sd
 
-        #verbose("       enter _from_r_to_rr_approx_direct with r=%s,"
-        #        " rr=%s,..."%(r,rr), level=5)
+        # verbose("       enter _from_r_to_rr_approx_direct with r=%s,"
+        #        " rr=%s,..." % (r,rr), level=5)
         rc = _CuspsForModularSymbolNumerical(r, self._N_E)
         m = rc._m
         a = rc._a
@@ -2062,15 +2064,15 @@ cdef class ModularSymbolNumerical:
         QQ = rrc._width
         oi = llxgcd(Q*a, m, &u, &v)
         oi = llxgcd(QQ*aa, mm, &uu, &vv)
-        #verbose("  The inverses are (u,v)=(%s,%s) and
-        # (uu,vv)=%s,%s"%(u,v,uu,vv), level=3)
+        # verbose("  The inverses are (u,v)=(%s,%s) and
+        # (uu,vv)=%s,%s" % (u,v,uu,vv), level=3)
 
         if use_partials == 2:
-            g = llgcd(Q,QQ)
+            g = llgcd(Q, QQ)
             D = Q * QQ
             D /= g
-            D *=  llabs(a*mm-aa*m)
-            use_partials = (prec==53) and ( D**4 < self._N_E or D < PARTIAL_LIMIT)
+            D *= llabs(a*mm-aa*m)
+            use_partials = (prec==53) and (D**4 < self._N_E or D < PARTIAL_LIMIT)
 
         CC = ComplexField(prec)
         if not use_partials and prec > 53:
@@ -2088,17 +2090,17 @@ cdef class ModularSymbolNumerical:
             s = 1/s
             tau0 = CC(x1, s)
             tau1 = CC(x2, s)
-            #verbose("  two points are %s and %s"%(tau0, tau1), level=3)
+            # verbose("  two points are %s and %s" % (tau0, tau1), level=3)
             verbose("   computing integral from %s to tau by computing "
-                    "the integral from i*oo to %s"%(r,tau0), level=3)
+                    "the integral from i*oo to %s" % (r, tau0), level=3)
             int1 = self._integration_to_tau(tau0, T, prec)
             int1 *= - epsQ
-            verbose("   yields %s "%int1, level=3)
+            verbose("   yields %s " % int1, level=3)
             verbose("   computing integral from tau to %s by computing "
-                    "the integral from i*oo to %s"%(rr, tau1), level=3)
+                    "the integral from i*oo to %s" % (rr, tau1), level=3)
             int2 = self._integration_to_tau(tau1, T, prec)
             int2 *= epsQQ
-            verbose("   yields %s "%int2, level=3)
+            verbose("   yields %s " % int2, level=3)
             ans = int2 + int1
         elif not use_partials:
             x1d = Q
@@ -2115,23 +2117,23 @@ cdef class ModularSymbolNumerical:
             tau0c = complex(x1d,sd)
             tau1c = complex(x2d,sd)
             verbose("   computing integral from %s to tau by computing "
-                    "the integral from i*oo to %s"%(r,
-                    tau0c),level=3)
+                    "the integral from i*oo to %s" % (r, tau0c),
+                    level=3)
             int1c = self._integration_to_tau_double(tau0c, T)
-            int1c *=  - epsQ
-            verbose("   yields %s "%int1c, level=3)
+            int1c *= -epsQ
+            verbose("   yields %s " % int1c, level=3)
             verbose("   computing integral from tau to %s by computing "
                     "the integral from i*oo to "
-                    "%s"%(rr, tau1c), level=3)
+                    "%s" % (rr, tau1c), level=3)
             int2c = self._integration_to_tau_double(tau1c, T)
             int2c *= epsQQ
-            verbose("   yields %s "%int2c, level=3)
+            verbose("   yields %s " % int2c, level=3)
             ans = int2c + int1c
-        else: # use_partials
+        else:  # use_partials
             g = llgcd(Q,QQ)
             D = Q * QQ
             D /= g
-            D *=  llabs(a*mm-aa*m)
+            D *= llabs(a*mm-aa*m)
             xi = (Q*aa*u+v*mm) * QQ /g * llsign(a*mm-aa*m)
             xixi = (QQ*a*uu+vv*m) * Q /g * llsign(aa*m-a*mm)
             z = Q * QQ * (a*mm-aa*m)**2
@@ -2143,10 +2145,10 @@ cdef class ModularSymbolNumerical:
             ze2 = cexp(ze2)
             j = 0
             su = 0
-            verbose("     summing up %s partial sums"%D, level=4)
+            verbose("     summing up %s partial sums" % D, level=4)
             while j < D:
                 sig_check()
-                su += (ze1**j * epsQQ  - ze2**j * epsQ ) * ka[j]
+                su += (ze1**j * epsQQ - ze2**j * epsQ) * ka[j]
                 j += 1
             ans = su
         return CC(ans)
@@ -2182,9 +2184,9 @@ cdef class ModularSymbolNumerical:
             sage: M = ModularSymbolNumerical(EllipticCurve("11a1"))
             sage: M._from_r_to_rr_approx(0/1,2/5,0.01) # abs tol 1e-11
             1.90381395641933 - 1.45881661693850*I
-            sage: M._from_r_to_rr_approx(0/1,2/5,0.001, "both", use_partials=0) #abs tol 1e-11
+            sage: M._from_r_to_rr_approx(0/1,2/5,0.001, "both", use_partials=0) # abs tol 1e-11
             1.90381395641931 - 1.45881661693851*I
-            sage: M._from_r_to_rr_approx(0/1,2/5,0.001, "both", use_partials=1) #abs tol 1e-11
+            sage: M._from_r_to_rr_approx(0/1,2/5,0.001, "both", use_partials=1) # abs tol 1e-11
             1.90381395641933 - 1.45881661693850*I
 
             sage: M._from_r_to_rr_approx(1/11,1/7,0.001) # abs tol 1e-11
@@ -2195,18 +2197,18 @@ cdef class ModularSymbolNumerical:
             1.26920930437008 - 2.91763323391590*I
 
             sage: M = ModularSymbolNumerical(EllipticCurve("389a1"))
-            sage: M._from_r_to_rr_approx(0/1,1/5,0.0001, "both") #abs tol 1e-5
+            sage: M._from_r_to_rr_approx(0/1,1/5,0.0001, "both") # abs tol 1e-5
             -4.98042489791268 - 6.06124058444291e-8*I
-            sage: M._from_r_to_rr_approx(1/3,1/7,0.001, "both", use_partials=0) #abs tol 1e-5
+            sage: M._from_r_to_rr_approx(1/3,1/7,0.001, "both", use_partials=0) # abs tol 1e-5
             -2.49020330904154 + 5.91520739782657*I
-            sage: M._from_r_to_rr_approx(1/3,1/7,0.0001, "both", use_partials=0) #abs tol 1e-5
+            sage: M._from_r_to_rr_approx(1/3,1/7,0.0001, "both", use_partials=0) # abs tol 1e-5
             -2.49021239793944 + 5.91521298876557*I
-            sage: M._from_r_to_rr_approx(1/3,1/7,0.0001, "both") #abs tol 1e-5
+            sage: M._from_r_to_rr_approx(1/3,1/7,0.0001, "both") # abs tol 1e-5
             -2.49021247526015 + 5.91521314939661*I
 
 
             sage: M = ModularSymbolNumerical(EllipticCurve("5077a1"))
-            sage: M._from_r_to_rr_approx(0/1, -7/3179, 0.001) #abs tol 1e-5 #long time
+            sage: M._from_r_to_rr_approx(0/1, -7/3179, 0.001) # abs tol 1e-5 # long time
             -6.22753195853020 - 5.92219314384901*I
 
             sage: E = EllipticCurve([91,127])
@@ -2225,8 +2227,8 @@ cdef class ModularSymbolNumerical:
             ComplexNumber ans, ans2
             int  T=0, prec=0, T1=0, T2=0, oi
 
-        #verbose("       enter _from_r_to_rr_approx with r=%s,"
-        #        " rr=%s, "%(r,rr), level=5)
+        # verbose("       enter _from_r_to_rr_approx with r=%s,"
+        #        " rr=%s, " % (r,rr), level=5)
         rc = _CuspsForModularSymbolNumerical(r, self._N_E)
         m = rc._m
         a = rc._a
@@ -2255,15 +2257,15 @@ cdef class ModularSymbolNumerical:
             s = sqrt(s)
             s = s * llabs(a*mm-aa*m)
             s = 1/s
-            #verbose("    direct method goes to s=%s and eps=%s"%(s,eps),
+            # verbose("    direct method goes to s=%s and eps=%s" % (s,eps),
             #        level=3)
             T, prec = self._get_truncation_and_prec(s, eps/2)
-            #verbose("    giving T=%s and prec=%s"%(T,prec), level=3)
+            # verbose("    giving T=%s and prec=%s" % (T,prec), level=3)
             if T == -1:
                 if method == "direct" or method == "both":
                     raise ValueError("Too many terms > 2^31 would have to"
                                      + " be summed up. Giving up.")
-                else: # method was None
+                else:  # method was None
                     method = "indirect"
 
         # now we compare it to the indirect integration via i*oo
@@ -2280,7 +2282,7 @@ cdef class ModularSymbolNumerical:
                 if method == "indirect" or method == "both":
                     raise ValueError("Too many terms > 2^31 would have to"
                                      + " be summed up. Giving up.")
-                else: # method was None
+                else:  # method was None
                     method = "direct"
 
         if method is None:
@@ -2295,7 +2297,7 @@ cdef class ModularSymbolNumerical:
 
         if method == "direct" or method == "both":
             verbose(" using the direct integration from %s to %s with "
-                    "%s terms to sum"%(r, rr, T), level=2)
+                    "%s terms to sum" % (r, rr, T), level=2)
             #self.nc_direct += 1
             ans = self._from_r_to_rr_approx_direct(r, rr, epsQ, epsQQ,
                                                    wQ, wQQ, T, prec, eps,
@@ -2305,20 +2307,21 @@ cdef class ModularSymbolNumerical:
 
         if method == "indirect" or method == "both":
             verbose("  using the indirect integration from %s to %s "
-                    "with %s terms to sum"%(r, rr, T1+T2), level=2)
+                    "with %s terms to sum" % (r, rr, T1+T2), level=2)
             #self.nc_indirect += 1
-            ans2 = ( self._from_ioo_to_r_approx(r, eps/2,
-                                                use_partials=use_partials)
+            ans2 = (self._from_ioo_to_r_approx(r, eps/2,
+                                               use_partials=use_partials)
                     - self._from_ioo_to_r_approx(rr, eps/2,
-                                                use_partials=use_partials) )
+                                                 use_partials=use_partials))
             if method != "both":
                 return ans2
 
         if method == "both":
-            if not use_partials:
-                assert (ans - ans2).abs() < eps, ("Bug in modular symbols. "
-                     + "The indirect and direct computation of the modular "
-                     + "symbol from %s to %s differ by too much"%(r, rr) )
+            if not use_partials and not (ans - ans2).abs() < eps:
+                txt = "Bug in modular symbols. "
+                txt += "The indirect and direct computation of the modular "
+                txt += "symbol from %s to %s differ by too much" % (r, rr)
+                raise RuntimeError(txt)
 
             return (ans + ans2)/2
 
@@ -2372,16 +2375,16 @@ cdef class ModularSymbolNumerical:
         This goes via i `\infty`::
 
             sage: M = ModularSymbolNumerical(EllipticCurve("5077a1"))
-            sage: M._transportable_approx( 0/1, -35/144, 0.001) #abs tol 1e-11
+            sage: M._transportable_approx(0/1, -35/144, 0.001) # abs tol 1e-11
             -6.22753189644996 + 3.23405342839145e-7*I
-            sage: M._from_r_to_rr_approx( 0/1, -35/144, 0.001) # abs tol 1e-10
+            sage: M._from_r_to_rr_approx(0/1, -35/144, 0.001) # abs tol 1e-10
             -6.22753204310913 - 1.31710951034592e-8*I
 
         While this one goes via 0::
 
-            sage: M._transportable_approx( 0/1, -7/31798, 0.001) #abs tol 1e-11
+            sage: M._transportable_approx(0/1, -7/31798, 0.001) # abs tol 1e-11
             -7.01577418382726e-9 - 7.40274138232394*I
-            sage: M._from_r_to_rr_approx( 0/1, -7/31798, 0.001) #abs tol 1e-5 #long time
+            sage: M._from_r_to_rr_approx(0/1, -7/31798, 0.001) # abs tol 1e-5 # long time
             -7.02253033502132e-9 - 7.40274138234031*I
         """
         cdef:
@@ -2391,8 +2394,8 @@ cdef class ModularSymbolNumerical:
             ComplexNumber tau1, tau2, int1, int2
             complex tau1c, tau2c, int1c, int2c
 
-        #verbose("       enter transportable_symbol_approx with r=%s,"
-        #        " rr=%s"%(r,rr), level=5)
+        # verbose("       enter transportable_symbol_approx with r=%s,"
+        #        " rr=%s" % (r,rr), level=5)
 
         #this finds a gamma with smallest |c|
         from sage.modular.cusps import Cusp
@@ -2401,19 +2404,19 @@ cdef class ModularSymbolNumerical:
 
         if not boo:
             raise ValueError("The cusps %s and %s are not "
-                             "Gamma_0(%s)-equivalent"%(r, rr, self._N_E))
+                             "Gamma_0(%s)-equivalent" % (r, rr, self._N_E))
 
         # now find the same for the move to 0
         c = ga[1][0]
-        r0 = - Rational( (c/self._N_E, ga[0][0]) )
+        r0 = - Rational((c/self._N_E, ga[0][0]))
         rc0 = Cusp(r0)
         _, ga0 = rc0.is_gamma0_equiv(0, self._N_E, "matrix")
 
-        if c.abs() > ga0[1][0].abs(): # better at 0
+        if c.abs() > ga0[1][0].abs():  # better at 0
             ga = ga0
             c = ga[1][0]
             eN = -self._epsQs[self._N_E]
-        else: #better at i oo
+        else:  # better at i oo
             eN = 1
 
         a = ga[0][0]
@@ -2439,26 +2442,26 @@ cdef class ModularSymbolNumerical:
             tau1 = CC(-d/c, 1/c.abs())
             # computes the integral from tau to i*oo
             verbose("   computing integral from i*oo to %s using %s terms "
-                    "and precision %s"%(tau1, T, prec), level=3)
+                    "and precision %s" % (tau1, T, prec), level=3)
             int1 = self._integration_to_tau(tau1, T, prec)
-            verbose("   yields %s "%int1, level=3)
+            verbose("   yields %s " % int1, level=3)
             tau2 = (tau1 * a + b)/(c*tau1 + d)
             verbose("   computing integral from i*oo to %s using %s terms "
-                    "and precision %s"%(tau2, T, prec), level=3)
+                    "and precision %s" % (tau2, T, prec), level=3)
             int2 = self._integration_to_tau(tau2, T, prec)
             ans = eN * (int1 - int2)
         else:
             tau1c = complex(-d/c, 1/c.abs())
             # computes the integral from tau to i*oo
             verbose("   computing integral from i*oo to %s using %s terms "
-                    "and fast double precision"%(tau1c, T), level=3)
+                    "and fast double precision" % (tau1c, T), level=3)
             int1c = self._integration_to_tau_double(tau1c, T)
-            verbose("   yields %s "%int1c, level=3)
+            verbose("   yields %s " % int1c, level=3)
             tau2c = (tau1c * a + b)/(c*tau1c + d)
             verbose("   computing integral from i*oo to %s using %s terms "
-                    "and fast double precision"%(tau2c, T), level=3)
+                    "and fast double precision" % (tau2c, T), level=3)
             int2c = self._integration_to_tau_double(tau2c, T)
-            verbose("   yields %s"%int2c, level=3)
+            verbose("   yields %s" % int2c, level=3)
             ans = eN * ComplexField(53)(int1c - int2c)
         return ans
 
@@ -2504,7 +2507,7 @@ cdef class ModularSymbolNumerical:
             sage: M._value_ioo_to_r(-9/55,-1)
             -2
         """
-        #verbose("       enter _value_ioo_to_r with r=%s, sign=%s"%(r,sign),
+        # verbose("       enter _value_ioo_to_r with r=%s, sign=%s" % (r,sign),
         #        level=5)
         cdef:
             double eps
@@ -2574,8 +2577,8 @@ cdef class ModularSymbolNumerical:
             sage: M._value_r_to_rr(7/11,14/75) # long time
             -1
         """
-        #verbose("       enter _value_r_to_rr with r=%s, rr=%s,"
-        #        " sign=%s"%(r,rr,sign), level=5)
+        # verbose("       enter _value_r_to_rr with r=%s, rr=%s,"
+        #        " sign=%s" % (r,rr,sign), level=5)
         cdef:
             double eps
             ComplexNumber la
@@ -2636,8 +2639,8 @@ cdef class ModularSymbolNumerical:
             sage: M.transportable_symbol(0/1, -7/31798, -1)
             -5
         """
-        #verbose("       enter transportable_symbol with r=%s, rr=%s,"
-        #        " sign=%s"%(r,rr,sign), level=5)
+        # verbose("       enter transportable_symbol with r=%s, rr=%s,"
+        #        " sign=%s" % (r,rr,sign), level=5)
         cdef:
             double eps
             ComplexNumber la
@@ -2690,8 +2693,8 @@ cdef class ModularSymbolNumerical:
             sage: M._symbol_non_unitary(1/19)
             5/19
         """
-        #verbose("       enter _symbol_non_unitary with r=%s,"
-        #        " sign=%s"%(r,sign), level=5)
+        # verbose("       enter _symbol_non_unitary with r=%s,"
+        #        " sign=%s" % (r,sign), level=5)
         cdef:
             llong m, B, N_ell, aell, u, N = self._N_E
             Integer ell
@@ -2728,7 +2731,7 @@ cdef class ModularSymbolNumerical:
             u += 1
         return -res/N_ell
 
-    @cached_method # one call to manin_symbol will set between 4 and 8 values in fact
+    @cached_method  # one call to manin_symbol will set between 4 and 8 values in fact
     def _manin_symbol_with_cache(self, llong u, llong v, int sign):
         r"""
         This helper function is called by manin_symbol below.
@@ -2775,8 +2778,8 @@ cdef class ModularSymbolNumerical:
             llong c, d, x, y, N = self._N_E, Mu, Mv, Qu, Qv, du=1, dv=1
             Rational r, rr, res
 
-        #verbose("       enter _manin_symbol_with_cache with u=%s, v=%s,"
-        #        " sign =%s"%(u,v,sign), level=5)
+        # verbose("       enter _manin_symbol_with_cache with u=%s, v=%s,"
+        #        " sign =%s" % (u,v,sign), level=5)
 
         if u == 0:
             verbose("   integrating from 0 to i*oo", level=3)
@@ -2793,7 +2796,7 @@ cdef class ModularSymbolNumerical:
             Qu = N/Mu
             Mv = llgcd(v,N)
             Qv = N/Mv
-            isunitary = ( llgcd(Qu,Mu) == 1 and llgcd(Qv,Mv) == 1 )
+            isunitary = (llgcd(Qu,Mu) == 1 and llgcd(Qv,Mv) == 1)
             if isunitary:  # unitary case
                 _ = best_proj_point(u, v, self._N_E, &c, &d)
             else:  # at least one of the two cusps is not unitary
@@ -2818,8 +2821,8 @@ cdef class ModularSymbolNumerical:
                         c += N/Mv
                     c = c % N
                     # now (u:v) = (c:d) with d as small as possible.
-            #verbose("   better representant on P^1: "
-            #        "(%s : %s)"%(c, d), level=3)
+            # verbose("   better representant on P^1: "
+            #        "(%s : %s)" % (c, d), level=3)
             # _, x, y = c.xgcd(d)
             _ = llxgcd(c, d, &x, &y)
             #if above != 1 or (c*v-u*d) % N != 0:
@@ -2828,15 +2831,15 @@ cdef class ModularSymbolNumerical:
             y = y % N
             # [[y -x], [c,d]] has det 1
             if c > 0:
-                rr = Rational( (y,c) )
+                rr = Rational((y, c))
             else:
-                rr = - Rational( (y, (-c)) )
+                rr = - Rational((y, -c))
             if d > 0:
-                r = -Rational( (x,d) )
+                r = -Rational((x, d))
             else:
-                r = Rational( (x, (-d)) )
+                r = Rational((x, -d))
             if isunitary:
-                verbose("   integrate between %s and %s"%(r, rr), level=3)
+                verbose("   integrate between %s and %s" % (r, rr), level=3)
                 return self._value_r_to_rr(r, rr, sign, use_partials=2)
             else:
                 if dv > 1:
@@ -2888,8 +2891,8 @@ cdef class ModularSymbolNumerical:
             sage: M.manin_symbol(-1,12)
             -1/2
         """
-        #verbose("       enter manin_symbol with u=%s, v=%s,"
-        #        " sign =%s"%(u,v,sign), level=5)
+        # verbose("       enter manin_symbol with u=%s, v=%s,"
+        #        " sign =%s" % (u,v,sign), level=5)
         cdef:
             llong un, vn
             int oi
@@ -2899,20 +2902,20 @@ cdef class ModularSymbolNumerical:
             sign = self._global_sign
 
         oi = proj_normalise(self._N_E, u, v, &un, &vn)
-        #verbose("   normalized representant on P^1: "
-        #        "(%s :%s)"%(un, vn), level=3)
+        # verbose("   normalized representant on P^1: "
+        #        "(%s :%s)" % (un, vn), level=3)
 
         # is it already in the cache ?
         c = self._cached_methods
         if "_manin_symbol_with_cache" in c:
             c = c["_manin_symbol_with_cache"]
-            if c.is_in_cache(un,vn,sign):
-                res = self._manin_symbol_with_cache(un,vn,sign)
+            if c.is_in_cache(un, vn, sign):
+                res = self._manin_symbol_with_cache(un, vn, sign)
                 return res
 
         # the actual work in now done in a helper function
         # which does the correct caching
-        res = self._manin_symbol_with_cache(un,vn,sign)
+        res = self._manin_symbol_with_cache(un, vn, sign)
 
         # using the Manin relations coming from
         # complex conjugation, the matrices S and T in SL_2
@@ -2933,11 +2936,11 @@ cdef class ModularSymbolNumerical:
         oi = proj_normalise(self._N_E, -u, v, &un, &vn)
         c.set_cache(sign*res, un, vn, sign)
 
-        # (u:v) + ( u+v:-u) +(v,-u-v) = 0
-        # is ( u+v:-u) already computed, we set the third
+        # (u:v) + (u+v:-u) +(v,-u-v) = 0
+        # is (u+v:-u) already computed, we set the third
         oi = proj_normalise(self._N_E, u+v, -u, &un, &vn)
-        if c.is_in_cache(un,vn,sign):
-            r2 = - res - c(un,vn,sign)
+        if c.is_in_cache(un, vn, sign):
+            r2 = - res - c(un, vn, sign)
 
             # (v:-u-v) = r2
             oi = proj_normalise(self._N_E, v, -u-v, &un, &vn)
@@ -2955,10 +2958,10 @@ cdef class ModularSymbolNumerical:
             oi = proj_normalise(self._N_E, -v, -u-v, &un, &vn)
             c.set_cache(sign*r2, un, vn, sign)
 
-        # is ( v,-u-v) already computed, we set ( u+v:-u)
+        # is (v,-u-v) already computed, we set (u+v:-u)
         oi = proj_normalise(self._N_E, v, -u-v, &un, &vn)
-        if c.is_in_cache(un,vn,sign):
-            r2 = - res - c(un,vn,sign)
+        if c.is_in_cache(un, vn, sign):
+            r2 = - res - c(un, vn, sign)
 
             # (u+v:-u) = r2
             oi = proj_normalise(self._N_E, u+v, -u, &un, &vn)
@@ -3013,7 +3016,7 @@ cdef class ModularSymbolNumerical:
             sage: M._evaluate(1/99999)
             -4/5
 
-            sage: M = ModularSymbolNumerical( EllipticCurve("32a1") )
+            sage: M = ModularSymbolNumerical(EllipticCurve("32a1"))
             sage: M._evaluate(3/5)
             -1/4
 
@@ -3041,7 +3044,7 @@ cdef class ModularSymbolNumerical:
             sage: M._evaluate(1/123456789012345678901234567)
             -1
         """
-        #verbose("       enter _evaluate with r=%s, sign=%s"%(r,sign),
+        # verbose("       enter _evaluate with r=%s, sign=%s" % (r,sign),
         #         level=5)
         cdef:
             llong N = self._N_E, u, v
@@ -3065,7 +3068,7 @@ cdef class ModularSymbolNumerical:
 
         B = m.gcd(N)
         Q = N // B
-        #verbose("     cusp is %s/%s of width %s"%(a,m,Q), level=4)
+        # verbose("     cusp is %s/%s of width %s" % (a,m,Q), level=4)
 
         if r == 0:
             return self._value_ioo_to_r(r, sign=sign)
@@ -3084,8 +3087,8 @@ cdef class ModularSymbolNumerical:
             if 2*y > m:
                 y -= m
             x = (1-y*a) // m
-            #verbose("     smallest xgcd is "
-            #        + " %s = %s * %s + %s * %s"%(a.gcd(m),a,y,x,m),
+            # verbose("     smallest xgcd is "
+            #        + " %s = %s * %s + %s * %s" % (a.gcd(m),a,y,x,m),
             #        level=4)
             # make the cusp -x/y unitary if possible.
             B = y.gcd(N)
@@ -3104,7 +3107,7 @@ cdef class ModularSymbolNumerical:
             v = vv
             r2 = - x/y
             verbose("  Next piece: integrate from %s to %s via the Manin"
-                    " symbol for (%s : %s)"%(r,r2,u,v), level=2)
+                    " symbol for (%s : %s)" % (r, r2, u, v), level=2)
             res = self.manin_symbol(u,v,sign=sign)
             res += self._evaluate(r2, sign=sign)
 
@@ -3165,7 +3168,7 @@ cdef class ModularSymbolNumerical:
             RealNumber val
             dict res
 
-        #verbose("       enter all_symbol with m=%s"%m, level=5)
+        # verbose("       enter all_symbol with m=%s" % m, level=5)
 
         if sign == 0:
             sign = self._global_sign
@@ -3176,7 +3179,7 @@ cdef class ModularSymbolNumerical:
         if llgcd(m,Q) > 1:
             raise NotImplementedError("Only implemented for cusps that are "
                                       "in the Atkin-Lehner orbit of oo")
-        #verbose("   compute all partial sums with denominator m=%s"%m,
+        # verbose("   compute all partial sums with denominator m=%s" % m,
         #        level=3)
         z = Q*m*m
         v = self._kappa(m, z)
@@ -3194,11 +3197,11 @@ cdef class ModularSymbolNumerical:
                     j = 0
                     resam = 0
                     while j < m:
-                        resam +=  (v[j]*(cos(twopim*j*a)
-                                   - epsQ*cos(twopim*j*astar)) )
+                        resam += (v[j]*(cos(twopim*j*a)
+                                        - epsQ*cos(twopim*j*astar)))
                         j += 1
                     val = RR(resam)
-                    res[Rational( (a,m) )] = self._round(val, 1, True)
+                    res[Rational((a, m))] = self._round(val, 1, True)
                 a += 1
         else:
             while a < m:
@@ -3207,11 +3210,11 @@ cdef class ModularSymbolNumerical:
                     j = 0
                     resam = 0
                     while j < m:
-                        resam +=  (v[j]*(sin(twopim *j *a)
-                                   + epsQ *sin(twopim*j*astar)) )
+                        resam += (v[j]*(sin(twopim *j *a)
+                                        + epsQ *sin(twopim*j*astar)))
                         j += 1
                     val = RR(resam)
-                    res[Rational( (a,m) )] = self._round(val, -1, True)
+                    res[Rational((a, m))] = self._round(val, -1, True)
                 a += 1
 
         return res
@@ -3245,8 +3248,8 @@ cdef class ModularSymbolNumerical:
         """
         cdef Integer D, Da, a
         cdef Rational res, t
-        #verbose("       enter _twisted symbol with ra=%s,
-        #        sign=%s"%(ra,sign),
+        # verbose("       enter _twisted symbol with ra=%s,
+        #        sign=%s" % (ra,sign),
         #        level=5)
         if sign == 0:
             sign = self._global_sign
@@ -3255,9 +3258,9 @@ cdef class ModularSymbolNumerical:
         D = self._D
         Da = D.abs()
         a = Integer(1)
-        res = Rational( (0,1) )
+        res = Rational((0, 1))
         s = sign * D.sign()
-        verbose("     start sum of twisted symbols with disc %s"%D, level=4)
+        verbose("     start sum of twisted symbols with disc %s" % D, level=4)
         while a < Da:
             if a.gcd(Da) == 1:
                 t = self._Mt(ra - a/Da, sign=s, use_twist=False)
@@ -3294,7 +3297,7 @@ cdef class ModularSymbolNumerical:
             sage: m._evaluate_approx(1/17,0.000001) # abs tol 1e-11
             -9.01145713605445e-10 + 7.40274134212215*I
 
-            sage: M = ModularSymbolNumerical( EllipticCurve([-12,79]) )
+            sage: M = ModularSymbolNumerical(EllipticCurve([-12,79]))
             sage: M.elliptic_curve().conductor()
             287280
             sage: M._evaluate_approx(0/1,0.01)  # abs tol 1e-11
@@ -3306,10 +3309,10 @@ cdef class ModularSymbolNumerical:
 
             sage: E = EllipticCurve("20a1")
             sage: m = E.modular_symbol_numerical()
-            sage: m(1/2)          #abs tol 1e-4
+            sage: m(1/2)          # abs tol 1e-4
             -0.166666666666667
         """
-        #verbose("       enter _evaluate_approx with r=%s, eps=%s"%(r,eps),
+        # verbose("       enter _evaluate_approx with r=%s, eps=%s" % (r,eps),
         #        level=5)
         cdef:
             llong N = self._N_E
@@ -3325,7 +3328,7 @@ cdef class ModularSymbolNumerical:
         r = a/m
         B = m.gcd(N)
         Q = N // B
-        verbose("     cusp is %s/%s of width %s"%(a,m,Q), level=4)
+        verbose("     cusp is %s/%s of width %s" % (a, m, Q), level=4)
 
         if r == 0:
             return self._from_ioo_to_r_approx(r, eps, use_partials=0)
@@ -3343,8 +3346,8 @@ cdef class ModularSymbolNumerical:
         if 2*y > m:
             y -= m
         x = (1-y*a) // m
-        #verbose("     smallest xgcd is "
-        #        + " %s = %s * %s + %s * %s"%(a.gcd(m),a,y,x,m),
+        # verbose("     smallest xgcd is "
+        #        + " %s = %s * %s + %s * %s" % (a.gcd(m),a,y,x,m),
         #        level=4)
         # make the cusp -x/y unitary if possible.
         B = y.gcd(N)
@@ -3358,7 +3361,7 @@ cdef class ModularSymbolNumerical:
         r2 = - x / y
         B = y.gcd(N)
         Q = N // B
-        if Q.gcd(N // Q) != 1: # r2 is not unitary
+        if Q.gcd(N // Q) != 1:  # r2 is not unitary
             return self._symbol_non_unitary_approx(r, eps)
 
         r2 = - x / y
@@ -3405,8 +3408,8 @@ cdef class ModularSymbolNumerical:
             sage: M._symbol_non_unitary_approx(5/38,0.1)  # abs tol 1e-11
             0.725215164486092 - 1.19349741385624*I
          """
-        #verbose("       enter _symbol_nonunitary_approx with r=%s,"
-        #        " eps=%s"%(r,eps), level=5)
+        # verbose("       enter _symbol_nonunitary_approx with r=%s,"
+        #        " eps=%s" % (r,eps), level=5)
         cdef:
             llong m, B, N_ell, aell, u, N = self._N_E
             Integer ell
@@ -3428,14 +3431,14 @@ cdef class ModularSymbolNumerical:
             aell = Integer(self._ans[ell])
         N_ell = ell + 1 - aell
         # {ell * r , r}
-        verbose("     Compute symbol {ell*r -> r} = {%s -> %s}"%(ell*r,r),
+        verbose("     Compute symbol {ell*r -> r} = {%s -> %s}" % (ell*r, r),
                 level=4)
         res = self._transportable_approx(ell * r, r, eps)
         # {(r + u)/ ell, r}
         u = Integer(0)
         while u < ell:
             r2 = (r+u) / ell
-            verbose("     Compute symbol {r2-> r} = {%s -> %s}"%(r2,r),
+            verbose("     Compute symbol {r2-> r} = {%s -> %s}" % (r2, r),
                     level=4)
             res += self._transportable_approx(r2, r, eps)
             u += 1
@@ -3476,8 +3479,8 @@ cdef class ModularSymbolNumerical:
         """
         cdef Integer D, Da, a, s, precd
         cdef RealNumber res, t
-        #verbose("       enter _twisted approx with ra=%s,
-        #        eps=%s"%(ra,eps),
+        # verbose("       enter _twisted approx with ra=%s,
+        #        eps=%s" % (ra,eps),
         #        level=5)
 
         if sign == 0:
@@ -3488,7 +3491,7 @@ cdef class ModularSymbolNumerical:
         precd = prec + euler_phi(Da).log(2,20).ceil()
         a = Integer(1)
         res = self._Mt.approximative_value(ra - a/Da, s, precd)
-        verbose("     start sum of twisted symbols with disc %s"%D, level=4)
+        verbose("     start sum of twisted symbols with disc %s" % D, level=4)
         a += 1
         while a < Da:
             if a.gcd(Da) == 1:
@@ -3685,7 +3688,7 @@ def _test_integration_via_partials(E, y, m, T):
         """
     cdef int mm = (m)
     cdef double * ra
-    ra =  sig_malloc( mm * sizeof(double))
+    ra =  sig_malloc(mm * sizeof(double))
     if ra is NULL:
         raise MemoryError
     M = ModularSymbolNumerical(E)
@@ -3695,7 +3698,7 @@ def _test_integration_via_partials(E, y, m, T):
     return res
 
 
-def _test_against_table(range_of_conductors, other_implementation="sage", list_of_cusps=[], verb=False):
+def _test_against_table(range_of_conductors, other_implementation="sage", list_of_cusps=None, verb=False):
     r"""
     This test function checks the modular symbols here against the
     ones implemented already. Note that for some curves the current
@@ -3709,9 +3712,9 @@ def _test_against_table(range_of_conductors, other_implementation="sage", list_o
 
     - ``list_of_cusps`` -- a list of rationals to be tested
 
-    - ``verb`` -- if True (default) prints the values
+    - ``verb`` -- if ``True`` (default) prints the values
 
-    OUTPUT: Boolean. If False the function also prints information.
+    OUTPUT: Boolean. If ``False`` the function also prints information.
 
     EXAMPLES::
 
@@ -3722,6 +3725,8 @@ def _test_against_table(range_of_conductors, other_implementation="sage", list_o
     """
     boo = True
     from sage.schemes.elliptic_curves.ell_rational_field import cremona_curves
+    if list_of_cusps is None:
+        list_of_cusps = []
     for C in cremona_curves(range_of_conductors):
         if verb:
             print("testing curve ", C.label())
@@ -3744,7 +3749,7 @@ def _test_against_table(range_of_conductors, other_implementation="sage", list_o
             if mr != Mr or m2r != M2r:
                 print (("B u g : curve = {}, cusp = {}, sage's symbols"
                         + "({},{}), our symbols ({}, {})").format(C.label(), r,
-                                                                  mr, m2r, Mr, M2r) )
+                                                                  mr, m2r, Mr, M2r))
                 boo = False
         M.clear_cache()
     return boo
diff --git a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx
index 60c132db2d1..8f240627e77 100644
--- a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx
+++ b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx
@@ -275,17 +275,17 @@ cdef class PeriodicRegion:
         new_data = np.zeros((m+2, n+2), self.data.dtype)
         for i in range(m):
             for j in range(n):
-                if framed[i,j]:
-                    new_data[i  , j  ] = True
-                    new_data[i-1, j  ] = True
-                    new_data[i+1, j  ] = True
-                    new_data[i  , j-1] = True
-                    new_data[i  , j+1] = True
+                if framed[i, j]:
+                    new_data[i, j] = True
+                    new_data[i - 1, j] = True
+                    new_data[i + 1, j] = True
+                    new_data[i, j - 1] = True
+                    new_data[i, j + 1] = True
                     if corners:
-                        new_data[i-1, j-1] = True
-                        new_data[i+1, j-1] = True
-                        new_data[i+1, j+1] = True
-                        new_data[i-1, j+1] = True
+                        new_data[i - 1, j - 1] = True
+                        new_data[i + 1, j - 1] = True
+                        new_data[i + 1, j + 1] = True
+                        new_data[i - 1, j + 1] = True
         return PeriodicRegion(self.w1, self.w2, unframe_data(new_data, self.full), self.full)
 
     def contract(self, corners=True):
@@ -661,7 +661,7 @@ cdef class PeriodicRegion:
             kwds['rgbcolor'] = 'red'
         for i, j, dir in self.border():
             ii, jj = i+dir, j+(1-dir)
-            L.append(line([tuple(i*dw1 + j*dw2), tuple(ii*dw1 + jj*dw2 )], **kwds))
+            L.append(line([tuple(i*dw1 + j*dw2), tuple(ii*dw1 + jj*dw2)], **kwds))
         return sum(L, F)
 
 
@@ -691,7 +691,7 @@ cdef frame_data(data, bint full=True):
         framed[:-2,-1] = data[::-1, 0]
         framed[:-2,-2] = data[::-1,-1]
     # left and right
-    framed[-2,:] = framed[ 0,:]
+    framed[-2,:] = framed[0,:]
     framed[-1,:] = framed[-3,:]
     return framed
 
@@ -701,7 +701,7 @@ cdef unframe_data(framed, bint full=True):
     borders together using the "or" operator.
     """
     framed = framed.copy()
-    framed[ 0,:] |= framed[-2,:]
+    framed[0,:] |= framed[-2,:]
     framed[-3,:] |= framed[-1,:]
     if full:
         framed[:-2,-3] |= framed[:-2,-1]
diff --git a/src/sage/schemes/elliptic_curves/weierstrass_morphism.py b/src/sage/schemes/elliptic_curves/weierstrass_morphism.py
index 878b5a78d82..30a2e4bd538 100644
--- a/src/sage/schemes/elliptic_curves/weierstrass_morphism.py
+++ b/src/sage/schemes/elliptic_curves/weierstrass_morphism.py
@@ -295,8 +295,8 @@ def _isomorphisms(E, F):
         sage: all({iso2*iso1 for iso1 in Iso} == set(Aut) for iso2 in F.isomorphisms(E))
         True
     """
-    from .ell_generic import is_EllipticCurve
-    if not is_EllipticCurve(E) or not is_EllipticCurve(F):
+    from .ell_generic import EllipticCurve_generic
+    if not isinstance(E, EllipticCurve_generic) or not isinstance(F, EllipticCurve_generic):
         raise ValueError("arguments are not elliptic curves")
 
     j = E.j_invariant()
@@ -459,13 +459,13 @@ def __init__(self, E=None, urst=None, F=None):
             sage: type(iso.degree())                                                    # needs sage.rings.finite_rings
             
         """
-        from .ell_generic import is_EllipticCurve
+        from .ell_generic import EllipticCurve_generic
 
         if E is not None:
-            if not is_EllipticCurve(E):
+            if not isinstance(E, EllipticCurve_generic):
                 raise ValueError("first argument must be an elliptic curve or None")
         if F is not None:
-            if not is_EllipticCurve(F):
+            if not isinstance(F, EllipticCurve_generic):
                 raise ValueError("third argument must be an elliptic curve or None")
         if urst is not None:
             if len(urst) != 4:
diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py
index 172256fa6a1..badd0531533 100644
--- a/src/sage/schemes/generic/algebraic_scheme.py
+++ b/src/sage/schemes/generic/algebraic_scheme.py
@@ -159,6 +159,9 @@ def is_AlgebraicScheme(x):
           x^2 + y^2
         sage: from sage.schemes.generic.algebraic_scheme import is_AlgebraicScheme
         sage: is_AlgebraicScheme(V)
+        doctest:warning...
+        DeprecationWarning: The function is_AlgebraicScheme is deprecated; use 'isinstance(..., AlgebraicScheme)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
 
     Affine space is itself not an algebraic scheme, though the closed
@@ -190,6 +193,8 @@ def is_AlgebraicScheme(x):
         sage: is_AlgebraicScheme(S)
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_AlgebraicScheme is deprecated; use 'isinstance(..., AlgebraicScheme)' instead.")
     return isinstance(x, AlgebraicScheme)
 
 
@@ -227,7 +232,7 @@ def __init__(self, A, category=None):
             sage: S.category()
             Category of schemes over Integer Ring
         """
-        if not ambient_space.is_AmbientSpace(A):
+        if not isinstance(A, ambient_space.AmbientSpace):
             raise TypeError("A (=%s) must be an ambient space")
         self.__A = A
         self.__divisor_group = {}
@@ -675,7 +680,7 @@ def _latex_(self):
              X \\text{ is defined by }\\text{no polynomials},\\text{ and }
              Y \\text{ is defined by } x - y.'
         """
-        if sage.schemes.affine.affine_space.is_AffineSpace(self.ambient_space()):
+        if isinstance(self.ambient_space(), sage.schemes.affine.affine_space.AffineSpace_generic):
             t = "affine"
         else:
             t = "projective"
@@ -709,7 +714,7 @@ def _repr_(self):
             sage: U._repr_()
             'Quasi-projective subscheme X - Y of Projective Space of dimension 2 over Integer Ring, where X is defined by:\n  (no polynomials)\nand Y is defined by:\n  x - y'
         """
-        if sage.schemes.affine.affine_space.is_AffineSpace(self.ambient_space()):
+        if isinstance(self.ambient_space(), sage.schemes.affine.affine_space.AffineSpace_generic):
             t = "affine"
         else:
             t = "projective"
diff --git a/src/sage/schemes/generic/all.py b/src/sage/schemes/generic/all.py
index b8ba9585bfa..a58cc24efd2 100644
--- a/src/sage/schemes/generic/all.py
+++ b/src/sage/schemes/generic/all.py
@@ -1,4 +1,4 @@
 # code exports
 
-from .spec import Spec
-from .hypersurface import ProjectiveHypersurface, AffineHypersurface
+from sage.schemes.generic.spec import Spec
+from sage.schemes.generic.hypersurface import ProjectiveHypersurface, AffineHypersurface
diff --git a/src/sage/schemes/generic/ambient_space.py b/src/sage/schemes/generic/ambient_space.py
index 52b3f1e0e39..6706e6adde8 100644
--- a/src/sage/schemes/generic/ambient_space.py
+++ b/src/sage/schemes/generic/ambient_space.py
@@ -25,6 +25,9 @@ def is_AmbientSpace(x):
 
         sage: from sage.schemes.generic.ambient_space import is_AmbientSpace
         sage: is_AmbientSpace(ProjectiveSpace(3, ZZ))
+        doctest:warning...
+        DeprecationWarning: The function is_AmbientSpace is deprecated; use 'isinstance(..., AmbientSpace)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
         sage: is_AmbientSpace(AffineSpace(2, QQ))
         True
@@ -32,8 +35,11 @@ def is_AmbientSpace(x):
         sage: is_AmbientSpace(P.subscheme([x + y + z]))
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_AmbientSpace is deprecated; use 'isinstance(..., AmbientSpace)' instead.")
     return isinstance(x, AmbientSpace)
 
+
 class AmbientSpace(Scheme):
     """
     Base class for ambient spaces over a ring.
diff --git a/src/sage/schemes/generic/divisor.py b/src/sage/schemes/generic/divisor.py
index c6d99b12204..d223f6278d8 100644
--- a/src/sage/schemes/generic/divisor.py
+++ b/src/sage/schemes/generic/divisor.py
@@ -48,8 +48,8 @@
 from sage.structure.formal_sum import FormalSum
 
 from .morphism import is_SchemeMorphism
-from sage.schemes.affine.affine_space import is_AffineSpace
-from sage.schemes.projective.projective_space import is_ProjectiveSpace
+from sage.schemes.affine.affine_space import AffineSpace_generic
+from sage.schemes.projective.projective_space import ProjectiveSpace_ring
 
 
 def CurvePointToIdeal(C,P):
@@ -72,7 +72,7 @@ def CurvePointToIdeal(C,P):
     m = n-1
     while m > 0 and P[m] == 0:
         m += -1
-    if is_ProjectiveSpace(A):
+    if isinstance(A, ProjectiveSpace_ring):
         a_m = P[m]
         x_m = x[m]
         for i in range(m):
@@ -81,7 +81,7 @@ def CurvePointToIdeal(C,P):
                 polys.append(x[i])
             else:
                 polys.append(a_m*x[i]-ai*x_m)
-    elif is_AffineSpace(A):
+    elif isinstance(A, AffineSpace_generic):
         for i in range(m+1):
             ai = P[i]
             if ai == 0:
@@ -121,6 +121,29 @@ def is_Divisor(x):
 class Divisor_generic(FormalSum):
     r"""
     A Divisor.
+
+    TESTS::
+
+        sage: E = EllipticCurve([1, 2])
+        sage: P = E(-1, 0)
+        sage: Q = E(1, 2)
+        sage: Pd = E.divisor(P)
+        sage: Qd = E.divisor(Q)
+        sage: Pd + Qd == Qd + Pd
+        True
+        sage: Pd != Qd
+        True
+        sage: C = EllipticCurve([2, 1])
+        sage: R = C(1, 2)
+        sage: Rd = C.divisor(R)
+        sage: Qd == Rd
+        False
+        sage: Rd == Qd
+        False
+        sage: Qd == (2 * (Qd * 1/2))
+        True
+        sage: Qd == 1/2 * Qd
+        False
     """
 
     def __init__(self, v, parent, check=True, reduce=True):
@@ -363,14 +386,15 @@ def _repr_(self):
         """
         return repr_lincomb([(tuple(I.gens()), c) for c, I in self])
 
-    def support(self):
+    def support(self) -> list:
         """
         Return the support of this divisor, which is the set of points that
         occur in this divisor with nonzero coefficients.
 
         EXAMPLES::
 
-            sage: x,y = AffineSpace(2, GF(5), names='xy').gens()
+            sage: A = AffineSpace(2, GF(5), names='xy')
+            sage: x, y = A.gens()
             sage: C = Curve(y^2 - x^9 - x)
             sage: pts = C.rational_points(); pts
             [(0, 0), (2, 2), (2, 3), (3, 1), (3, 4)]
diff --git a/src/sage/schemes/generic/divisor_group.py b/src/sage/schemes/generic/divisor_group.py
index 5dfd66a1bb9..d6a19f49d60 100644
--- a/src/sage/schemes/generic/divisor_group.py
+++ b/src/sage/schemes/generic/divisor_group.py
@@ -75,10 +75,15 @@ def is_DivisorGroup(x):
         sage: from sage.schemes.generic.divisor_group import is_DivisorGroup, DivisorGroup
         sage: Div = DivisorGroup(Spec(ZZ), base_ring=QQ)
         sage: is_DivisorGroup(Div)
+        doctest:warning...
+        DeprecationWarning: The function is_DivisorGroup is deprecated; use 'isinstance(..., DivisorGroup_generic)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
         sage: is_DivisorGroup('not a divisor')
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_DivisorGroup is deprecated; use 'isinstance(..., DivisorGroup_generic)' instead.")
     return isinstance(x, DivisorGroup_generic)
 
 
@@ -190,6 +195,36 @@ def _element_constructor_(self, x, check=True, reduce=True):
         else:
             return Divisor_generic([(self.base_ring()(1), x)], check=False, reduce=False, parent=self)
 
+    def _coerce_map_from_(self, other):
+        r"""
+        Return if there is a coercion map from ``other`` to ``self``.
+
+        There is a coercion from another divisor group if there is
+        a coercion map from the schemes and there is a coercion map from
+        the base rings.
+
+        TESTS::
+
+            sage: C = EllipticCurve([2, 1])
+            sage: E = EllipticCurve([1, 2])
+            sage: C.divisor_group()._coerce_map_from_(E.divisor_group())
+            False
+            sage: E.divisor_group()._coerce_map_from_(C.divisor_group())
+            False
+            sage: E.divisor_group()._coerce_map_from_(E.divisor_group())
+            True
+            sage: C.divisor_group()._coerce_map_from_(C.divisor_group())
+            True
+            sage: D = 1/2 * E.divisor(E(1, 2))
+            sage: D.parent()._coerce_map_from_(E.divisor_group())
+            True
+            sage: E.divisor_group()._coerce_map_from_(D.parent())
+            False
+        """
+        return (isinstance(other, DivisorGroup_generic)
+                and self.scheme().has_coerce_map_from(other.scheme())
+                and super()._coerce_map_from_(other))
+
     def scheme(self):
         r"""
         Return the scheme supporting the divisors.
diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py
index 6fca9c1e257..20d1398dcb7 100644
--- a/src/sage/schemes/generic/homset.py
+++ b/src/sage/schemes/generic/homset.py
@@ -67,12 +67,17 @@ def is_SchemeHomset(H):
           Defn: Identity map
         sage: from sage.schemes.generic.homset import is_SchemeHomset
         sage: is_SchemeHomset(f)
+        doctest:warning...
+        DeprecationWarning: The function is_SchemeHomset is deprecated; use 'isinstance(..., SchemeHomset_generic)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         False
         sage: is_SchemeHomset(f.parent())
         True
         sage: is_SchemeHomset('a string')
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_SchemeHomset is deprecated; use 'isinstance(..., SchemeHomset_generic)' instead.")
     return isinstance(H, SchemeHomset_generic)
 
 
@@ -164,7 +169,7 @@ def create_key_and_extra_args(self, X, Y, category=None, base=None,
         if base is None:
             from sage.structure.element import coercion_model
             base = coercion_model.common_parent(X.base_ring(), Y.base_ring())
-        if is_AffineScheme(base):
+        if isinstance(base, AffineScheme):
             base_spec = base
             base_ring = base.coordinate_ring()
         elif base in _CommRings:
@@ -327,7 +332,7 @@ def natural_map(self):
         """
         X = self.domain()
         Y = self.codomain()
-        if is_AffineScheme(Y) and Y.coordinate_ring() == X.base_ring():
+        if isinstance(Y, AffineScheme) and Y.coordinate_ring() == X.base_ring():
             return SchemeMorphism_structure_map(self)
         raise NotImplementedError
 
@@ -444,7 +449,7 @@ def __init__(self, X, Y, category=None, check=True, base=ZZ):
             sage: SchemeHomset_points(Spec(QQ), AffineSpace(ZZ,2))
             Set of rational points of Affine Space of dimension 2 over Rational Field
         """
-        if check and not is_AffineScheme(X):
+        if check and not isinstance(X, AffineScheme):
             raise ValueError('The domain must be an affine scheme.')
         SchemeHomset_generic.__init__(self, X, Y, category=category, check=check, base=base)
 
@@ -730,7 +735,7 @@ def value_ring(self):
             Rational Field
         """
         dom = self.domain()
-        if not is_AffineScheme(dom):
+        if not isinstance(dom, AffineScheme):
             raise ValueError("value rings are defined for affine domains only")
         return dom.coordinate_ring()
 
diff --git a/src/sage/schemes/generic/hypersurface.py b/src/sage/schemes/generic/hypersurface.py
index f4991527c78..4d39a7bfc27 100644
--- a/src/sage/schemes/generic/hypersurface.py
+++ b/src/sage/schemes/generic/hypersurface.py
@@ -34,6 +34,9 @@ def is_Hypersurface(self):
         sage: R. = ZZ[]
         sage: H = ProjectiveHypersurface(x*z + y^2)
         sage: is_Hypersurface(H)
+        doctest:warning...
+        DeprecationWarning: The function is_Hypersurface is deprecated; use 'isinstance(..., (ProjectiveHypersurface, AffineHypersurface))' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
 
     ::
@@ -48,8 +51,11 @@ def is_Hypersurface(self):
         sage: is_Hypersurface(H)
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_Hypersurface is deprecated; use 'isinstance(..., (ProjectiveHypersurface, AffineHypersurface))' instead.")
     return isinstance(self, (ProjectiveHypersurface, AffineHypersurface))
 
+
 class ProjectiveHypersurface(AlgebraicScheme_subscheme_projective):
     """
     The projective hypersurface defined by the given polynomial.
diff --git a/src/sage/schemes/generic/scheme.py b/src/sage/schemes/generic/scheme.py
index 2c0e3100c86..7d190275e8e 100644
--- a/src/sage/schemes/generic/scheme.py
+++ b/src/sage/schemes/generic/scheme.py
@@ -44,11 +44,16 @@ def is_Scheme(x):
 
         sage: from sage.schemes.generic.scheme import is_Scheme
         sage: is_Scheme(5)
+        doctest:warning...
+        DeprecationWarning: The function is_Scheme is deprecated; use 'isinstance(..., Scheme)' or categories instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         False
         sage: X = Spec(QQ)
         sage: is_Scheme(X)
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_Scheme is deprecated; use 'isinstance(..., Scheme)' or categories instead.")
     return isinstance(x, Scheme)
 
 
@@ -105,7 +110,7 @@ def __init__(self, X=None, category=None):
 
         if X is None:
             self._base_ring = ZZ
-        elif is_Scheme(X):
+        elif isinstance(X, Scheme):
             self._base_scheme = X
         elif is_SchemeMorphism(X):
             self._base_morphism = X
@@ -255,7 +260,7 @@ def __call__(self, *args):
             S = args[0]
             if S in CommutativeRings():
                 return self.point_homset(S)
-            elif is_Scheme(S):
+            elif isinstance(S, Scheme):
                 return S.Hom(self)
             elif isinstance(S, (list, tuple)):
                 args = S
@@ -331,8 +336,8 @@ def point(self, v, check=True):
             (0 : 0 : 1)
         """
         # todo: update elliptic curve stuff to take point_homset as argument
-        from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
-        if is_EllipticCurve(self):
+        from sage.schemes.elliptic_curves.ell_generic import EllipticCurve_generic
+        if isinstance(self, EllipticCurve_generic):
             try:
                 return self._point(self.point_homset(), v, check=check)
             except AttributeError:  # legacy code without point_homset
@@ -607,7 +612,7 @@ def hom(self, x, Y=None, check=True):
               Defn: Structure map
         """
         if Y is None:
-            if is_Scheme(x):
+            if isinstance(x, Scheme):
                 return self.Hom(x).natural_map()
             else:
                 raise TypeError("unable to determine codomain")
@@ -794,13 +799,19 @@ def is_AffineScheme(x):
 
         sage: from sage.schemes.generic.scheme import is_AffineScheme
         sage: is_AffineScheme(5)
+        doctest:warning...
+        DeprecationWarning: The function is_AffineScheme is deprecated; use 'isinstance(..., AffineScheme)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         False
         sage: E = Spec(QQ)
         sage: is_AffineScheme(E)
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_AffineScheme is deprecated; use 'isinstance(..., AffineScheme)' instead.")
     return isinstance(x, AffineScheme)
 
+
 class AffineScheme(UniqueRepresentation, Scheme):
     """
     Class for general affine schemes.
@@ -1212,7 +1223,7 @@ def hom(self, x, Y=None):
         from sage.categories.map import Map
         from sage.categories.rings import Rings
 
-        if is_Scheme(x):
+        if isinstance(x, Scheme):
             return self.Hom(x).natural_map()
         if Y is None and isinstance(x, Map) and x.category_for().is_subcategory(Rings()):
             # x is a morphism of Rings
diff --git a/src/sage/schemes/hyperelliptic_curves/all.py b/src/sage/schemes/hyperelliptic_curves/all.py
index 88733235129..044c97cd498 100644
--- a/src/sage/schemes/hyperelliptic_curves/all.py
+++ b/src/sage/schemes/hyperelliptic_curves/all.py
@@ -1,4 +1,5 @@
-from .constructor import HyperellipticCurve
-from .kummer_surface import KummerSurface
-from .mestre import (Mestre_conic, HyperellipticCurve_from_invariants)
-from . import monsky_washnitzer
+from sage.schemes.hyperelliptic_curves.constructor import HyperellipticCurve
+from sage.schemes.hyperelliptic_curves.kummer_surface import KummerSurface
+from sage.schemes.hyperelliptic_curves.mestre import (
+    Mestre_conic, HyperellipticCurve_from_invariants)
+from sage.schemes.hyperelliptic_curves import monsky_washnitzer
diff --git a/src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx b/src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx
index 9f9bb04d0ea..e0b0e77c568 100644
--- a/src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx
+++ b/src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx
@@ -124,7 +124,7 @@ def interval_products(M0, M1, target):
     cdef vector[ZZ_c] targ
     cdef ntl_ZZ_pContext_class c = \
         (ZZ_pContext_factory).make_c(
-        ntl_ZZ(M0.base_ring().characteristic()))
+            ntl_ZZ(M0.base_ring().characteristic()))
     cdef long dim = M0.nrows()
     sig_on()
     c.restore_c()
diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py
index c18732064d4..4834152b606 100644
--- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py
+++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py
@@ -51,8 +51,13 @@ def is_HyperellipticCurve(C):
         sage: R. = QQ[]; C = HyperellipticCurve(x^3 + x - 1); C
         Hyperelliptic Curve over Rational Field defined by y^2 = x^3 + x - 1
         sage: is_HyperellipticCurve(C)
+        doctest:warning...
+        DeprecationWarning: The function is_HyperellipticCurve is deprecated; use 'isinstance(..., HyperellipticCurve_generic)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_HyperellipticCurve is deprecated; use 'isinstance(..., HyperellipticCurve_generic)' instead.")
     return isinstance(C, HyperellipticCurve_generic)
 
 
diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py b/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py
index a5f4f63876c..88b28a4b753 100644
--- a/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py
+++ b/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py
@@ -161,9 +161,9 @@ def value_ring(self):
         """
         Return S for a homset X(T) where T = Spec(S).
         """
-        from sage.schemes.generic.scheme import is_AffineScheme
+        from sage.schemes.generic.scheme import AffineScheme
         T = self.domain()
-        if is_AffineScheme(T):
+        if isinstance(T, AffineScheme):
             return T.coordinate_ring()
         else:
             raise TypeError("domain of argument must be of the form Spec(S)")
diff --git a/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py b/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py
index 03b795a4704..753f83f8b23 100644
--- a/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py
+++ b/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py
@@ -74,9 +74,9 @@
 from sage.rings.padics.factory import Qp as pAdicField
 from sage.rings.polynomial.polynomial_element import Polynomial
 from sage.schemes.elliptic_curves.constructor import EllipticCurve
-from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
+from sage.schemes.elliptic_curves.ell_generic import EllipticCurve_generic
 from sage.schemes.hyperelliptic_curves.constructor import HyperellipticCurve
-from sage.schemes.hyperelliptic_curves.hyperelliptic_generic import is_HyperellipticCurve
+from sage.schemes.hyperelliptic_curves.hyperelliptic_generic import HyperellipticCurve_generic
 from sage.structure.element import ModuleElement
 from sage.structure.parent import Parent
 from sage.structure.richcmp import richcmp
@@ -2391,14 +2391,14 @@ def __init__(self, Q, R=None, invert_y=True):
             R = Q.base_ring()
 
         x = PolynomialRing(R, 'xx').gen()
-        if is_EllipticCurve(Q):
+        if isinstance(Q, EllipticCurve_generic):
             E = Q
             if E.a1() != 0 or E.a2() != 0:
                 raise NotImplementedError("curve must be in Weierstrass normal form")
             Q = -E.change_ring(R).defining_polynomial()(x, 0, 1)
             self._curve = E
 
-        elif is_HyperellipticCurve(Q):
+        elif isinstance(Q, HyperellipticCurve_generic):
             C = Q
             if C.hyperelliptic_polynomials()[1] != 0:
                 raise NotImplementedError("curve must be of form y^2 = Q(x)")
diff --git a/src/sage/schemes/jacobians/abstract_jacobian.py b/src/sage/schemes/jacobians/abstract_jacobian.py
index 570c5efaa76..bed9555da46 100644
--- a/src/sage/schemes/jacobians/abstract_jacobian.py
+++ b/src/sage/schemes/jacobians/abstract_jacobian.py
@@ -133,7 +133,7 @@ def __init__(self, C, category=None):
             TypeError: C (=Projective Plane Curve over Ring of integers modulo 6
             defined by x + y + z) must be defined over a field.
         """
-        if not is_Scheme(C):
+        if not isinstance(C, Scheme):
             raise TypeError("Argument (=%s) must be a scheme." % C)
         if C.base_ring() not in _Fields:
             raise TypeError("C (=%s) must be defined over a field." % C)
diff --git a/src/sage/schemes/plane_conics/all.py b/src/sage/schemes/plane_conics/all.py
index b0237ba2e7c..0ac534ebe27 100644
--- a/src/sage/schemes/plane_conics/all.py
+++ b/src/sage/schemes/plane_conics/all.py
@@ -18,4 +18,4 @@
 #
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
-from .constructor import Conic
+from sage.schemes.plane_conics.constructor import Conic
diff --git a/src/sage/schemes/plane_quartics/all.py b/src/sage/schemes/plane_quartics/all.py
index 6986f1ec1fa..1f60d332efe 100644
--- a/src/sage/schemes/plane_quartics/all.py
+++ b/src/sage/schemes/plane_quartics/all.py
@@ -1 +1 @@
-from .quartic_constructor import QuarticCurve
+from sage.schemes.plane_quartics.quartic_constructor import QuarticCurve
diff --git a/src/sage/schemes/plane_quartics/quartic_constructor.py b/src/sage/schemes/plane_quartics/quartic_constructor.py
index 37c06a1f5c9..fede02c20bd 100644
--- a/src/sage/schemes/plane_quartics/quartic_constructor.py
+++ b/src/sage/schemes/plane_quartics/quartic_constructor.py
@@ -8,7 +8,7 @@
 #                  http://www.gnu.org/licenses/
 #*****************************************************************************
 
-from sage.schemes.projective.projective_space import is_ProjectiveSpace, ProjectiveSpace
+from sage.schemes.projective.projective_space import ProjectiveSpace_ring, ProjectiveSpace
 from sage.rings.polynomial.multi_polynomial import MPolynomial
 
 from .quartic_generic import QuarticCurve_generic
@@ -59,7 +59,7 @@ def QuarticCurve(F, PP=None, check=False):
         raise ValueError("Argument F (=%s) must be a homogeneous polynomial of degree 4" % F)
 
     if PP is not None:
-        if not is_ProjectiveSpace(PP) and PP.dimension == 2:
+        if not isinstance(PP, ProjectiveSpace_ring) and PP.dimension == 2:
             raise ValueError(f"Argument PP (={PP}) must be a projective plane")
     else:
         PP = ProjectiveSpace(P)
diff --git a/src/sage/schemes/plane_quartics/quartic_generic.py b/src/sage/schemes/plane_quartics/quartic_generic.py
index ac2cdd84d82..324ec2f9b13 100644
--- a/src/sage/schemes/plane_quartics/quartic_generic.py
+++ b/src/sage/schemes/plane_quartics/quartic_generic.py
@@ -31,11 +31,17 @@ def is_QuarticCurve(C):
         sage: x,y,z = PolynomialRing(QQ, ['x','y','z']).gens()
         sage: Q = QuarticCurve(x**4 + y**4 + z**4)
         sage: is_QuarticCurve(Q)
+        doctest:warning...
+        DeprecationWarning: The function is_QuarticCurve is deprecated; use 'isinstance(..., QuarticCurve_generic)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
 
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_QuarticCurve is deprecated; use 'isinstance(..., QuarticCurve_generic)' instead.")
     return isinstance(C, QuarticCurve_generic)
 
+
 class QuarticCurve_generic(projective_curve.ProjectivePlaneCurve):
     # DRK: Note that we should check whether the curve is
 
diff --git a/src/sage/schemes/product_projective/homset.py b/src/sage/schemes/product_projective/homset.py
index b0b8655a0ec..32ccb977093 100644
--- a/src/sage/schemes/product_projective/homset.py
+++ b/src/sage/schemes/product_projective/homset.py
@@ -182,8 +182,8 @@ def points(self, **kwds):
         B = kwds.pop('bound', 0)
         X = self.codomain()
 
-        from sage.schemes.product_projective.space import is_ProductProjectiveSpaces
-        if not is_ProductProjectiveSpaces(X) and X.base_ring() in Fields():
+        from sage.schemes.product_projective.space import ProductProjectiveSpaces_ring
+        if not isinstance(X, ProductProjectiveSpaces_ring) and X.base_ring() in Fields():
             # no points
             if X.dimension() == -1:
                 return []
diff --git a/src/sage/schemes/product_projective/morphism.py b/src/sage/schemes/product_projective/morphism.py
index d5b1974164b..30874e5530e 100644
--- a/src/sage/schemes/product_projective/morphism.py
+++ b/src/sage/schemes/product_projective/morphism.py
@@ -112,8 +112,8 @@ def __init__(self, parent, polys, check=True):
 
             target = parent.codomain().ambient_space()
             dom = parent.domain().ambient_space()
-            from sage.schemes.product_projective.space import is_ProductProjectiveSpaces
-            if is_ProductProjectiveSpaces(target):
+            from sage.schemes.product_projective.space import ProductProjectiveSpaces_ring
+            if isinstance(target, ProductProjectiveSpaces_ring):
                 splitpolys = target._factors(polys)
                 for m in range(len(splitpolys)):
                     d = dom._degree(splitpolys[m][0])
diff --git a/src/sage/schemes/product_projective/point.py b/src/sage/schemes/product_projective/point.py
index 6de7cf74d7d..e930a30056b 100644
--- a/src/sage/schemes/product_projective/point.py
+++ b/src/sage/schemes/product_projective/point.py
@@ -537,8 +537,8 @@ def intersection_multiplicity(self, X):
             sage: Q.intersection_multiplicity(Y)                                        # needs sage.libs.singular
             2
         """
-        from sage.schemes.product_projective.space import is_ProductProjectiveSpaces
-        if is_ProductProjectiveSpaces(self.codomain()):
+        from sage.schemes.product_projective.space import ProductProjectiveSpaces_ring
+        if isinstance(self.codomain(), ProductProjectiveSpaces_ring):
             raise TypeError("this point must be a point on a subscheme of a product of projective spaces")
         return self.codomain().intersection_multiplicity(X, self)
 
@@ -565,8 +565,8 @@ def multiplicity(self):
             sage: Q3.multiplicity()                                                     # needs sage.libs.singular
             6
         """
-        from sage.schemes.product_projective.space import is_ProductProjectiveSpaces
-        if is_ProductProjectiveSpaces(self.codomain()):
+        from sage.schemes.product_projective.space import ProductProjectiveSpaces_ring
+        if isinstance(self.codomain(), ProductProjectiveSpaces_ring):
             raise TypeError("this point must be a point on a subscheme of a product of projective spaces")
         return self.codomain().multiplicity(self)
 
diff --git a/src/sage/schemes/product_projective/rational_point.py b/src/sage/schemes/product_projective/rational_point.py
index a4488647063..264e2a4c2d9 100644
--- a/src/sage/schemes/product_projective/rational_point.py
+++ b/src/sage/schemes/product_projective/rational_point.py
@@ -55,8 +55,8 @@
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
 
-from sage.schemes.generic.scheme import is_Scheme
-from sage.schemes.product_projective.space import is_ProductProjectiveSpaces
+from sage.schemes.generic.scheme import Scheme
+from sage.schemes.product_projective.space import ProductProjectiveSpaces_ring
 from sage.misc.lazy_import import lazy_import
 from sage.misc.mrange import xmrange
 from sage.misc.misc_c import prod
@@ -124,12 +124,12 @@ def enum_product_projective_rational_field(X, B):
          (0 : 0 : 1 , 0 : 1), (0 : 0 : 1 , 1 : 1), (0 : 1 : 0 , 0 : 1),
          (0 : 1 : 0 , 1 : 1), (1 : -1/2 : 1 , 0 : 1), (1 : -1/2 : 1 , 1 : 1)]
     """
-    if is_Scheme(X):
-        if (not is_ProductProjectiveSpaces(X.ambient_space())):
+    if isinstance(X, Scheme):
+        if not isinstance(X.ambient_space(), ProductProjectiveSpaces_ring):
             raise TypeError("ambient space must be product of projective space over the rational field")
         X = X(X.base_ring())
     else:
-        if (not is_ProductProjectiveSpaces(X.codomain().ambient_space())):
+        if not isinstance(X.codomain().ambient_space(), ProductProjectiveSpaces_ring):
             raise TypeError("codomain must be product of projective space over the rational field")
 
     R = X.codomain().ambient_space()
@@ -228,12 +228,12 @@ def enum_product_projective_number_field(X, **kwds):
     tol = kwds.pop('tolerance', 1e-2)
     prec = kwds.pop('precision', 53)
 
-    if is_Scheme(X):
-        if (not is_ProductProjectiveSpaces(X.ambient_space())):
+    if isinstance(X, Scheme):
+        if not isinstance(X.ambient_space(), ProductProjectiveSpaces_ring):
             raise TypeError("ambient space must be product of projective space over the rational field")
         X = X(X.base_ring())
     else:
-        if (not is_ProductProjectiveSpaces(X.codomain().ambient_space())):
+        if not isinstance(X.codomain().ambient_space(), ProductProjectiveSpaces_ring):
             raise TypeError("codomain must be product of projective space over the rational field")
 
     R = X.codomain().ambient_space()
@@ -284,12 +284,12 @@ def enum_product_projective_finite_field(X):
         sage: len(enum_product_projective_finite_field(X))
         36
     """
-    if is_Scheme(X):
-        if (not is_ProductProjectiveSpaces(X.ambient_space())):
+    if isinstance(X, Scheme):
+        if not isinstance(X.ambient_space(), ProductProjectiveSpaces_ring):
             raise TypeError("ambient space must be product of projective space over the rational field")
         X = X(X.base_ring())
     else:
-        if (not is_ProductProjectiveSpaces(X.codomain().ambient_space())):
+        if not isinstance(X.codomain().ambient_space(), ProductProjectiveSpaces_ring):
             raise TypeError("codomain must be product of projective space over the rational field")
 
     R = X.codomain().ambient_space()
diff --git a/src/sage/schemes/product_projective/space.py b/src/sage/schemes/product_projective/space.py
index 2b4e60905df..ea99ea00559 100644
--- a/src/sage/schemes/product_projective/space.py
+++ b/src/sage/schemes/product_projective/space.py
@@ -73,10 +73,15 @@ def is_ProductProjectiveSpaces(x):
     EXAMPLES::
 
         sage: is_ProductProjectiveSpaces(ProjectiveSpace(5, names='x'))
+        doctest:warning...
+        DeprecationWarning: The function is_ProductProjectiveSpaces is deprecated; use 'isinstance(..., ProductProjectiveSpaces_ring)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         False
         sage: is_ProductProjectiveSpaces(ProductProjectiveSpaces([1, 2, 3], ZZ, 'x'))
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_ProductProjectiveSpaces is deprecated; use 'isinstance(..., ProductProjectiveSpaces_ring)' instead.")
     return isinstance(x, ProductProjectiveSpaces_ring)
 
 
diff --git a/src/sage/schemes/projective/all.py b/src/sage/schemes/projective/all.py
index 44e92ee5f23..b9e210c8ae0 100644
--- a/src/sage/schemes/projective/all.py
+++ b/src/sage/schemes/projective/all.py
@@ -2,7 +2,7 @@
 all.py -- export of projective schemes to Sage
 """
 
-#*****************************************************************************
+# *****************************************************************************
 #
 #   Sage: Open Source Mathematical Software
 #
@@ -17,7 +17,7 @@
 #
 #  The full text of the GPL is available at:
 #
-#                  http://www.gnu.org/licenses/
-#*****************************************************************************
+#                  https://www.gnu.org/licenses/
+# *****************************************************************************
 
-from .projective_space import ProjectiveSpace, is_ProjectiveSpace
+from sage.schemes.projective.projective_space import ProjectiveSpace, is_ProjectiveSpace
diff --git a/src/sage/schemes/projective/projective_homset.py b/src/sage/schemes/projective/projective_homset.py
index 91c01a51128..5428a101364 100644
--- a/src/sage/schemes/projective/projective_homset.py
+++ b/src/sage/schemes/projective/projective_homset.py
@@ -169,9 +169,9 @@ def points(self, **kwds):
             the numerical fields are inexact;points may be computed partially or incorrectly.
             6
         """
-        from sage.schemes.projective.projective_space import is_ProjectiveSpace
+        from sage.schemes.projective.projective_space import ProjectiveSpace_ring
         X = self.codomain()
-        if not is_ProjectiveSpace(X) and X.base_ring() in Fields():
+        if not isinstance(X, ProjectiveSpace_ring) and X.base_ring() in Fields():
             if hasattr(X.base_ring(), 'precision'):
                 numerical = True
                 verbose("Warning: computations in the numerical fields are inexact;points may be computed partially or incorrectly.", level=0)
@@ -377,7 +377,7 @@ def numerical_points(self, F=None, **kwds):
             ...
             TypeError: F must be a numerical field
         """
-        from sage.schemes.projective.projective_space import is_ProjectiveSpace
+        from sage.schemes.projective.projective_space import ProjectiveSpace_ring
         if F is None:
             F = CC
         if F not in Fields() or not hasattr(F, 'precision'):
@@ -387,7 +387,7 @@ def numerical_points(self, F=None, **kwds):
             raise TypeError('base ring must be a number field')
 
         PP = X.ambient_space().change_ring(F)
-        if not is_ProjectiveSpace(X) and X.base_ring() in Fields():
+        if not isinstance(X, ProjectiveSpace_ring) and X.base_ring() in Fields():
             #Then it must be a subscheme
             dim_ideal = X.defining_ideal().dimension()
             if dim_ideal < 1: # no points
diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py
index a284ecbc585..a21c3f48e17 100644
--- a/src/sage/schemes/projective/projective_morphism.py
+++ b/src/sage/schemes/projective/projective_morphism.py
@@ -1555,8 +1555,8 @@ def wronskian_ideal(self):
         from sage.calculus.functions import jacobian
 
         dom = self.domain()
-        from sage.schemes.projective.projective_space import is_ProjectiveSpace
-        if not (is_ProjectiveSpace(dom) and is_ProjectiveSpace(self.codomain())):
+        from sage.schemes.projective.projective_space import ProjectiveSpace_ring
+        if not (isinstance(dom, ProjectiveSpace_ring) and isinstance(self.codomain(), ProjectiveSpace_ring)):
             raise NotImplementedError("not implemented for subschemes")
         N = dom.dimension_relative() + 1
         R = dom.coordinate_ring()
@@ -1791,9 +1791,9 @@ def _number_field_from_algebraics(self):
                     ((-0.6823278038280193?)*x^3 + (-13)*y^3 : (-14)*y^3)
         """
         from sage.rings.qqbar import number_field_elements_from_algebraics
-        from sage.schemes.projective.projective_space import is_ProjectiveSpace
+        from sage.schemes.projective.projective_space import ProjectiveSpace_ring
 
-        if not (is_ProjectiveSpace(self.domain()) and is_ProjectiveSpace(self.domain())):
+        if not (isinstance(self.domain(), ProjectiveSpace_ring) and isinstance(self.domain(), ProjectiveSpace_ring)):
             raise NotImplementedError("not implemented for subschemes")
 
         K_pre, C, phi = number_field_elements_from_algebraics([c for f in self
diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py
index 2f5576e6a12..6aebc66a5e6 100644
--- a/src/sage/schemes/projective/projective_point.py
+++ b/src/sage/schemes/projective/projective_point.py
@@ -1269,8 +1269,8 @@ def _number_field_from_algebraics(self):
             sage: Q[0] == T[0]
             True
         """
-        from sage.schemes.projective.projective_space import is_ProjectiveSpace
-        if not is_ProjectiveSpace(self.codomain()):
+        from sage.schemes.projective.projective_space import ProjectiveSpace_ring
+        if not isinstance(self.codomain(), ProjectiveSpace_ring):
             raise NotImplementedError("not implemented for subschemes")
 
         # Issue #23808: Keep the embedding info associated with the number field K
@@ -1368,8 +1368,8 @@ def intersection_multiplicity(self, X):
             ...
             TypeError: this point must be a point on a projective subscheme
         """
-        from sage.schemes.projective.projective_space import is_ProjectiveSpace
-        if is_ProjectiveSpace(self.codomain()):
+        from sage.schemes.projective.projective_space import ProjectiveSpace_ring
+        if isinstance(self.codomain(), ProjectiveSpace_ring):
             raise TypeError("this point must be a point on a projective subscheme")
         return self.codomain().intersection_multiplicity(X, self)
 
@@ -1393,8 +1393,8 @@ def multiplicity(self):
             sage: Q2.multiplicity()                                                     # needs sage.libs.singular
             8
         """
-        from sage.schemes.projective.projective_space import is_ProjectiveSpace
-        if is_ProjectiveSpace(self.codomain()):
+        from sage.schemes.projective.projective_space import ProjectiveSpace_ring
+        if isinstance(self.codomain(), ProjectiveSpace_ring):
             raise TypeError("this point must be a point on a projective subscheme")
         return self.codomain().multiplicity(self)
 
diff --git a/src/sage/schemes/projective/projective_rational_point.py b/src/sage/schemes/projective/projective_rational_point.py
index 8c2fa76599a..1556ab2d856 100644
--- a/src/sage/schemes/projective/projective_rational_point.py
+++ b/src/sage/schemes/projective/projective_rational_point.py
@@ -63,7 +63,7 @@
 from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF
 from sage.misc.misc_c import prod
 from sage.misc.mrange import xmrange
-from sage.schemes.generic.scheme import is_Scheme
+from sage.schemes.generic.scheme import Scheme
 from sage.parallel.ncpus import ncpus
 from sage.parallel.use_fork import p_iter_fork
 from sage.matrix.constructor import matrix
@@ -128,12 +128,12 @@ def enum_projective_rational_field(X, B):
 
     - John Cremona and Charlie Turner (06-2010)
     """
-    from sage.schemes.projective.projective_space import is_ProjectiveSpace
-    if is_Scheme(X):
-        if not is_ProjectiveSpace(X.ambient_space()):
+    from sage.schemes.projective.projective_space import ProjectiveSpace_ring
+    if isinstance(X, Scheme):
+        if not isinstance(X.ambient_space(), ProjectiveSpace_ring):
             raise TypeError("ambient space must be projective space over the rational field")
         X = X(X.base_ring())
-    elif not is_ProjectiveSpace(X.codomain().ambient_space()):
+    elif not isinstance(X.codomain().ambient_space(), ProjectiveSpace_ring):
         raise TypeError("codomain must be projective space over the rational field")
 
     n = X.codomain().ambient_space().ngens()
@@ -206,13 +206,13 @@ def enum_projective_number_field(X, **kwds):
     B = kwds.pop('bound')
     tol = kwds.pop('tolerance', 1e-2)
     prec = kwds.pop('precision', 53)
-    from sage.schemes.projective.projective_space import is_ProjectiveSpace
-    if is_Scheme(X):
-        if (not is_ProjectiveSpace(X.ambient_space())):
+    from sage.schemes.projective.projective_space import ProjectiveSpace_ring
+    if isinstance(X, Scheme):
+        if not isinstance(X.ambient_space(), ProjectiveSpace_ring):
             raise TypeError("ambient space must be projective space over a number field")
         X = X(X.base_ring())
     else:
-        if (not is_ProjectiveSpace(X.codomain().ambient_space())):
+        if not isinstance(X.codomain().ambient_space(), ProjectiveSpace_ring):
             raise TypeError("codomain must be projective space over a number field")
 
     R = X.codomain().ambient_space()
@@ -287,12 +287,12 @@ def enum_projective_finite_field(X):
 
     - John Cremona and Charlie Turner (06-2010).
     """
-    from sage.schemes.projective.projective_space import is_ProjectiveSpace
-    if is_Scheme(X):
-        if not is_ProjectiveSpace(X.ambient_space()):
+    from sage.schemes.projective.projective_space import ProjectiveSpace_ring
+    if isinstance(X, Scheme):
+        if not isinstance(X.ambient_space(), ProjectiveSpace_ring):
             raise TypeError("ambient space must be projective space over a finite")
         X = X(X.base_ring())
-    elif not is_ProjectiveSpace(X.codomain().ambient_space()):
+    elif not isinstance(X.codomain().ambient_space(), ProjectiveSpace_ring):
         raise TypeError("codomain must be projective space over a finite field")
 
     n = X.codomain().ambient_space().ngens() - 1
diff --git a/src/sage/schemes/projective/projective_space.py b/src/sage/schemes/projective/projective_space.py
index 5c55a62106e..67ddd800ecc 100644
--- a/src/sage/schemes/projective/projective_space.py
+++ b/src/sage/schemes/projective/projective_space.py
@@ -140,12 +140,17 @@ def is_ProjectiveSpace(x):
 
         sage: from sage.schemes.projective.projective_space import is_ProjectiveSpace
         sage: is_ProjectiveSpace(ProjectiveSpace(5, names='x'))
+        doctest:warning...
+        DeprecationWarning: The function is_ProjectiveSpace is deprecated; use 'isinstance(..., ProjectiveSpace_ring)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
         sage: is_ProjectiveSpace(ProjectiveSpace(5, GF(9, 'alpha'), names='x'))         # needs sage.rings.finite_rings
         True
         sage: is_ProjectiveSpace(Spec(ZZ))
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_ProjectiveSpace is deprecated; use 'isinstance(..., ProjectiveSpace_ring)' instead.")
     return isinstance(x, ProjectiveSpace_ring)
 
 
@@ -1539,7 +1544,7 @@ def veronese_embedding(self, d, CS=None, order='lex'):
         if CS is None:
             CS = ProjectiveSpace(self.base_ring(), binomial(N + d, d) - 1)
         else:
-            if not is_ProjectiveSpace(CS):
+            if not isinstance(CS, ProjectiveSpace_ring):
                 raise TypeError("(=%s) must be a projective space" % CS)
             if CS.dimension() != binomial(N + d, d) - 1:
                 raise TypeError("(=%s) has the wrong dimension to serve as the codomain space" % CS)
diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
index 3ea963e0e04..b4210db1f21 100644
--- a/src/sage/schemes/projective/projective_subscheme.py
+++ b/src/sage/schemes/projective/projective_subscheme.py
@@ -115,8 +115,8 @@ def point(self, v, check=True):
                 raise ValueError("%s not well defined in dimension > 1" % v)
             v = [1, 0]
         # todo: update elliptic curve stuff to take point_homset as argument
-        from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
-        if is_EllipticCurve(self):
+        from sage.schemes.elliptic_curves.ell_generic import EllipticCurve_generic
+        if isinstance(self, EllipticCurve_generic):
             try:
                 return self._point(self.point_homset(), v, check=check)
             except AttributeError:  # legacy code without point_homset
diff --git a/src/sage/schemes/toric/chow_group.py b/src/sage/schemes/toric/chow_group.py
index 482bd5ce81b..d11d70e135b 100644
--- a/src/sage/schemes/toric/chow_group.py
+++ b/src/sage/schemes/toric/chow_group.py
@@ -131,7 +131,7 @@
 from sage.rings.infinity import Infinity
 
 import sage.geometry.abc
-from sage.schemes.toric.variety import is_ToricVariety
+from sage.schemes.toric.variety import ToricVariety_field
 from sage.schemes.toric.divisor import is_ToricDivisor
 
 
@@ -548,7 +548,7 @@ def create_key_and_extra_args(self, toric_variety, base_ring=ZZ, check=True):
             sage: ChowGroup(P2, ZZ, check=True) == ChowGroup(P2, ZZ, check=False)   # indirect doctest
             True
         """
-        if not is_ToricVariety(toric_variety):
+        if not isinstance(toric_variety, ToricVariety_field):
             raise ValueError('first argument must be a toric variety')
 
         if base_ring not in [ZZ, QQ]:
@@ -608,7 +608,7 @@ def __init__(self, toric_variety, base_ring, check):
             sage: P2 = toric_varieties.P2()
             sage: A = ChowGroup_class(P2,ZZ,True); A
             Chow group of 2-d CPR-Fano toric variety covered by 3 affine patches
-            sage: is_ChowGroup(A)
+            sage: isinstance(A, ChowGroup_class)
             True
             sage: is_ChowCycle(A.an_element())
             True
@@ -1216,10 +1216,15 @@ def is_ChowGroup(x) -> bool:
         sage: A = P2.Chow_group()
         sage: from sage.schemes.toric.chow_group import is_ChowGroup
         sage: is_ChowGroup(A)
+        doctest:warning...
+        DeprecationWarning: The function is_ChowGroup is deprecated; use 'isinstance(..., ChowGroup_class)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         True
         sage: is_ChowGroup('Victoria')
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_ChowGroup is deprecated; use 'isinstance(..., ChowGroup_class)' instead.")
     return isinstance(x, ChowGroup_class)
 
 
diff --git a/src/sage/schemes/toric/divisor.py b/src/sage/schemes/toric/divisor.py
index a80d9a41b85..3ec4b2adb62 100644
--- a/src/sage/schemes/toric/divisor.py
+++ b/src/sage/schemes/toric/divisor.py
@@ -185,7 +185,7 @@
 from sage.schemes.generic.divisor import Divisor_generic
 from sage.schemes.generic.divisor_group import DivisorGroup_generic
 from sage.schemes.toric.divisor_class import ToricRationalDivisorClass
-from sage.schemes.toric.variety import CohomologyRing, is_ToricVariety
+from sage.schemes.toric.variety import CohomologyRing, ToricVariety_field
 from sage.structure.unique_representation import UniqueRepresentation
 from sage.structure.element import is_Vector
 
@@ -302,7 +302,7 @@ def ToricDivisor(toric_variety, arg=None, ring=None, check=True, reduce=True):
         ...
         TypeError: cannot deduce coefficient ring for [(u, u)]
     """
-    assert is_ToricVariety(toric_variety)
+    assert isinstance(toric_variety, ToricVariety_field)
 
     # First convert special arguments into lists
     # of multiplicities or (multiplicity,coordinate)
@@ -1687,7 +1687,7 @@ def __init__(self, toric_variety, base_ring):
             sage: DivisorGroup(P2, ZZ) is ToricDivisorGroup(P2, ZZ)
             False
         """
-        assert is_ToricVariety(toric_variety), str(toric_variety) + ' is not a toric variety!'
+        assert isinstance(toric_variety, ToricVariety_field), str(toric_variety) + ' is not a toric variety!'
         super().__init__(toric_variety, base_ring)
 
     def _latex_(self):
diff --git a/src/sage/schemes/toric/fano_variety.py b/src/sage/schemes/toric/fano_variety.py
index d6cbe751274..09014ce20cc 100644
--- a/src/sage/schemes/toric/fano_variety.py
+++ b/src/sage/schemes/toric/fano_variety.py
@@ -170,6 +170,9 @@ def is_CPRFanoToricVariety(x):
 
         sage: from sage.schemes.toric.fano_variety import is_CPRFanoToricVariety
         sage: is_CPRFanoToricVariety(1)
+        doctest:warning...
+        DeprecationWarning: The function is_CPRFanoToricVariety is deprecated; use 'isinstance(..., CPRFanoToricVariety_field)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         False
         sage: FTV = toric_varieties.P2()
         sage: FTV
@@ -179,6 +182,8 @@ def is_CPRFanoToricVariety(x):
         sage: is_CPRFanoToricVariety(ProjectiveSpace(2))
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_CPRFanoToricVariety is deprecated; use 'isinstance(..., CPRFanoToricVariety_field)' instead.")
     return isinstance(x, CPRFanoToricVariety_field)
 
 
@@ -1142,7 +1147,7 @@ def cartesian_product(self, other,
             sage: P1xP2.Delta_polar()
             3-d reflexive polytope in 3-d lattice N+N
         """
-        if is_CPRFanoToricVariety(other):
+        if isinstance(other, CPRFanoToricVariety_field):
             fan = self.fan().cartesian_product(other.fan())
             Delta_polar = LatticePolytope(fan.rays())
 
@@ -1314,7 +1319,7 @@ def __init__(self, P_Delta, monomial_points=None, coefficient_names=None,
               s^2*x^2 + s*t*x^2 + t^2*x^2 + s^2*x*y + s*t*x*y
               + t^2*x*y + s^2*y^2 + s*t*y^2 + t^2*y^2
         """
-        if not is_CPRFanoToricVariety(P_Delta):
+        if not isinstance(P_Delta, CPRFanoToricVariety_field):
             raise TypeError("anticanonical hypersurfaces can only be "
                             "constructed for CPR-Fano toric varieties!"
                             "\nGot: %s" % P_Delta)
@@ -1428,7 +1433,7 @@ def __init__(self, P_Delta, nef_partition,
               b1*z1*z2^2 + b2*z2^2*z4 + b5*z1*z2*z5
               + b4*z2*z4*z5 + b3*z1*z5^2 + b0*z4*z5^2
         """
-        if not is_CPRFanoToricVariety(P_Delta):
+        if not isinstance(P_Delta, CPRFanoToricVariety_field):
             raise TypeError("nef complete intersections can only be "
                             "constructed for CPR-Fano toric varieties!"
                             "\nGot: %s" % P_Delta)
diff --git a/src/sage/schemes/toric/homset.py b/src/sage/schemes/toric/homset.py
index e02d0b92078..80a879a6aed 100644
--- a/src/sage/schemes/toric/homset.py
+++ b/src/sage/schemes/toric/homset.py
@@ -166,8 +166,8 @@ def __init__(self, X, Y, category=None, check=True, base=ZZ):
                     to Rational polyhedral fan in 1-d lattice N.
         """
         SchemeHomset_generic.__init__(self, X, Y, category=category, check=check, base=base)
-        from sage.schemes.toric.variety import is_ToricVariety
-        if is_ToricVariety(X) and is_ToricVariety(Y):
+        from sage.schemes.toric.variety import ToricVariety_field
+        if isinstance(X, ToricVariety_field) and isinstance(Y, ToricVariety_field):
             self.register_conversion(MatrixSpace(ZZ, X.fan().dim(), Y.fan().dim()))
 
     def _element_constructor_(self, x, check=True):
diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
index c22f88e99fb..a7afee25f30 100644
--- a/src/sage/schemes/toric/morphism.py
+++ b/src/sage/schemes/toric/morphism.py
@@ -374,7 +374,7 @@
 from sage.geometry.cone import Cone
 from sage.geometry.fan import Fan
 
-from sage.schemes.generic.scheme import is_Scheme
+from sage.schemes.generic.scheme import Scheme
 from sage.schemes.generic.morphism import (
     is_SchemeMorphism,
     SchemeMorphism, SchemeMorphism_point, SchemeMorphism_polynomial
@@ -425,7 +425,7 @@ def __init__(self, X, coordinates, check=True):
             [1 : 2 : 3 : 4]
         """
         # Convert scheme to its set of points over the base ring
-        if is_Scheme(X):
+        if isinstance(X, Scheme):
             X = X(X.base_ring())
         super().__init__(X)
         if check:
diff --git a/src/sage/schemes/toric/sheaf/constructor.py b/src/sage/schemes/toric/sheaf/constructor.py
index 0fb0c0a34e5..3b23c4d9213 100644
--- a/src/sage/schemes/toric/sheaf/constructor.py
+++ b/src/sage/schemes/toric/sheaf/constructor.py
@@ -13,7 +13,7 @@
 #  the License, or (at your option) any later version.
 #                  https://www.gnu.org/licenses/
 # ****************************************************************************
-from sage.schemes.toric.variety import is_ToricVariety
+from sage.schemes.toric.variety import ToricVariety_field
 from sage.modules.filtered_vector_space import FilteredVectorSpace
 
 
@@ -36,7 +36,7 @@ def TangentBundle(X):
         sage: TangentBundle(dP7)
         Rank 2 bundle on 2-d CPR-Fano toric variety covered by 5 affine patches.
     """
-    if not is_ToricVariety(X):
+    if not isinstance(X, ToricVariety_field):
         raise ValueError('not a toric variety')
 
     fan = X.fan()
@@ -94,7 +94,7 @@ def TrivialBundle(X, rank=1):
         sage: I3.cohomology(weight=(0,0), dim=True)
         (3, 0, 0)
     """
-    if not is_ToricVariety(X):
+    if not isinstance(X, ToricVariety_field):
         raise ValueError('not a toric variety')
 
     base_ring = X.base_ring()
@@ -127,7 +127,7 @@ def LineBundle(X, D):
         sage: O_D.cohomology(dim=True, weight=(0,0))
         (1, 0, 0)
     """
-    if not is_ToricVariety(X):
+    if not isinstance(X, ToricVariety_field):
         raise ValueError('not a toric variety')
 
     base_ring = X.base_ring()
diff --git a/src/sage/schemes/toric/sheaf/klyachko.py b/src/sage/schemes/toric/sheaf/klyachko.py
index 4325e77f186..b6c7147140c 100644
--- a/src/sage/schemes/toric/sheaf/klyachko.py
+++ b/src/sage/schemes/toric/sheaf/klyachko.py
@@ -69,8 +69,13 @@ def is_KlyachkoBundle(X):
 
         sage: from sage.schemes.toric.sheaf.klyachko import is_KlyachkoBundle
         sage: is_KlyachkoBundle('test')
+        doctest:warning...
+        DeprecationWarning: The function is_KlyachkoBundle is deprecated; use 'isinstance(..., KlyachkoBundle_class)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_KlyachkoBundle is deprecated; use 'isinstance(..., KlyachkoBundle_class)' instead.")
     return isinstance(X, KlyachkoBundle_class)
 
 
diff --git a/src/sage/schemes/toric/variety.py b/src/sage/schemes/toric/variety.py
index 6a6a8d3252a..b978ede251d 100644
--- a/src/sage/schemes/toric/variety.py
+++ b/src/sage/schemes/toric/variety.py
@@ -351,6 +351,9 @@ def is_ToricVariety(x):
 
         sage: from sage.schemes.toric.variety import is_ToricVariety
         sage: is_ToricVariety(1)
+        doctest:warning...
+        DeprecationWarning: The function is_ToricVariety is deprecated; use 'isinstance(..., ToricVariety_field)' instead.
+        See https://github.com/sagemath/sage/issues/38022 for details.
         False
         sage: fan = FaceFan(lattice_polytope.cross_polytope(2))
         sage: P = ToricVariety(fan)
@@ -361,6 +364,8 @@ def is_ToricVariety(x):
         sage: is_ToricVariety(ProjectiveSpace(2))
         False
     """
+    from sage.misc.superseded import deprecation
+    deprecation(38022, "The function is_ToricVariety is deprecated; use 'isinstance(..., ToricVariety_field)' instead.")
     return isinstance(x, ToricVariety_field)
 
 
@@ -1339,7 +1344,7 @@ def is_isomorphic(self, another):
         """
         if self is another:
             return True
-        if not is_ToricVariety(another):
+        if not isinstance(another, ToricVariety_field):
             raise TypeError(
                 "only another toric variety can be checked for isomorphism; "
                 "got %s" % another)
diff --git a/src/sage/sets/all.py b/src/sage/sets/all.py
index 1c1a69e57a7..8cdd85ed269 100644
--- a/src/sage/sets/all.py
+++ b/src/sage/sets/all.py
@@ -1,15 +1,16 @@
 from sage.misc.lazy_import import lazy_import
 lazy_import('sage.sets.real_set', 'RealSet')
-from .set import Set
-from .integer_range import IntegerRange
-from .non_negative_integers import NonNegativeIntegers
-from .positive_integers import PositiveIntegers
-from .finite_enumerated_set import FiniteEnumeratedSet
-lazy_import('sage.sets.recursively_enumerated_set','RecursivelyEnumeratedSet')
-from .totally_ordered_finite_set import TotallyOrderedFiniteSet
-from .disjoint_union_enumerated_sets import DisjointUnionEnumeratedSets
-from .primes import Primes
-from .family import Family
-from .disjoint_set import DisjointSet
-from .condition_set import ConditionSet
-from .finite_set_maps import FiniteSetMaps
+from sage.sets.set import Set
+from sage.sets.integer_range import IntegerRange
+from sage.sets.non_negative_integers import NonNegativeIntegers
+from sage.sets.positive_integers import PositiveIntegers
+from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
+lazy_import('sage.sets.recursively_enumerated_set', 'RecursivelyEnumeratedSet')
+from sage.sets.totally_ordered_finite_set import TotallyOrderedFiniteSet
+from sage.sets.disjoint_union_enumerated_sets import DisjointUnionEnumeratedSets
+from sage.sets.primes import Primes
+from sage.sets.family import Family
+from sage.sets.disjoint_set import DisjointSet
+from sage.sets.condition_set import ConditionSet
+from sage.sets.finite_set_maps import FiniteSetMaps
+del lazy_import
diff --git a/src/sage/sets/disjoint_set.pyx b/src/sage/sets/disjoint_set.pyx
index ce44a37710a..1c2d93fea2a 100644
--- a/src/sage/sets/disjoint_set.pyx
+++ b/src/sage/sets/disjoint_set.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Disjoint-set data structure
 
diff --git a/src/sage/sets/image_set.py b/src/sage/sets/image_set.py
index c98fc8c534b..07ef2de695d 100644
--- a/src/sage/sets/image_set.py
+++ b/src/sage/sets/image_set.py
@@ -27,7 +27,7 @@
 from sage.rings.integer import Integer
 from sage.modules.free_module import FreeModule
 from sage.structure.element import Expression
-from sage.structure.parent import Parent, is_Parent
+from sage.structure.parent import Parent
 
 from .set import Set_base, Set_add_sub_operators, Set_boolean_operators
 
@@ -82,7 +82,7 @@ def __init__(self, map, domain_subset, *, category=None, is_injective=None, inve
             sage: TestSuite(Im).run(skip=['_test_an_element', '_test_pickling',
             ....:                         '_test_some_elements', '_test_elements'])
         """
-        if not is_Parent(domain_subset):
+        if not isinstance(domain_subset, Parent):
             from sage.sets.set import Set
             domain_subset = Set(domain_subset)
 
diff --git a/src/sage/sets/recursively_enumerated_set.pyx b/src/sage/sets/recursively_enumerated_set.pyx
index 183d52b8c4a..37d17dcd36f 100644
--- a/src/sage/sets/recursively_enumerated_set.pyx
+++ b/src/sage/sets/recursively_enumerated_set.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Recursively Enumerated Sets
 
@@ -1489,6 +1488,7 @@ def _imap_and_filter_none(function, iterable):
         if x is not None:
             yield x
 
+
 def search_forest_iterator(roots, children, algorithm='depth'):
     r"""
     Return an iterator on the nodes of the forest having the given
@@ -1577,6 +1577,7 @@ def search_forest_iterator(roots, children, algorithm='depth'):
         yield node
         stack.append( iter(children(node)) )
 
+
 class RecursivelyEnumeratedSet_forest(Parent):
     r"""
     The enumerated set of the nodes of the forest having the given
diff --git a/src/sage/stats/all.py b/src/sage/stats/all.py
index 3b4c8c4ff52..34b229fa8ac 100644
--- a/src/sage/stats/all.py
+++ b/src/sage/stats/all.py
@@ -1,8 +1,8 @@
 import sage.stats.distributions.catalog as distributions
 
-from .r import ttest
-from .basic_stats import (mean, mode, std, variance, median, moving_average)
-from .hmm import all as hmm
+from sage.stats.r import ttest
+from sage.stats.basic_stats import (mean, mode, std, variance, median, moving_average)
+from sage.stats.hmm import all as hmm
 
 # We lazy_import the following modules since they import numpy which
 # slows down sage startup
diff --git a/src/sage/stats/distributions/discrete_gaussian_lattice.py b/src/sage/stats/distributions/discrete_gaussian_lattice.py
index 6667b2fb5cf..85bcb47957d 100644
--- a/src/sage/stats/distributions/discrete_gaussian_lattice.py
+++ b/src/sage/stats/distributions/discrete_gaussian_lattice.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Discrete Gaussian Samplers over Lattices
 
diff --git a/src/sage/stats/distributions/discrete_gaussian_polynomial.py b/src/sage/stats/distributions/discrete_gaussian_polynomial.py
index 63c8f5b800a..47544fa91a5 100644
--- a/src/sage/stats/distributions/discrete_gaussian_polynomial.py
+++ b/src/sage/stats/distributions/discrete_gaussian_polynomial.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Discrete Gaussian Samplers for `\ZZ[x]`
 
diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx
index 9f1819efdc0..26b9ee77cd7 100644
--- a/src/sage/structure/coerce.pyx
+++ b/src/sage/structure/coerce.pyx
@@ -351,6 +351,7 @@ cpdef bint parent_is_integers(P) except -1:
         from sage.rings.integer_ring import ZZ
         return P is ZZ
 
+
 def parent_is_numerical(P):
     r"""
     Test if elements of the parent or type ``P`` can be numerically evaluated
@@ -381,6 +382,7 @@ def parent_is_numerical(P):
             return False
     return P._is_numerical()
 
+
 def parent_is_real_numerical(P):
     r"""
     Test if elements of the parent or type ``P`` can be numerically evaluated
@@ -796,7 +798,6 @@ cdef class CoercionModel:
             self._exceptions_cleared = True
         return self._exception_stack
 
-
     def explain(self, xp, yp, op=mul, int verbosity=2):
         """
         This function can be used to understand what coercions will happen
@@ -1640,7 +1641,6 @@ cdef class CoercionModel:
             S_map = None
         return R_map, S_map
 
-
     cpdef discover_coercion(self, R, S):
         """
         This actually implements the finding of coercion maps as described in
diff --git a/src/sage/structure/coerce_maps.pyx b/src/sage/structure/coerce_maps.pyx
index aabeafa6bc8..d056f426bde 100644
--- a/src/sage/structure/coerce_maps.pyx
+++ b/src/sage/structure/coerce_maps.pyx
@@ -556,6 +556,7 @@ cpdef Element _ccall_test_function(codomain, x):
     """
     return codomain(x*x*x-x)
 
+
 def test_CCallableConvertMap(domain, name=None):
     """
     For testing CCallableConvertMap_class.
diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
index 46037b048a5..bb50fbb2b9b 100644
--- a/src/sage/structure/element.pyx
+++ b/src/sage/structure/element.pyx
@@ -774,13 +774,14 @@ cdef class Element(SageObject):
         else:
             return self._parent(x)
 
-
     def subs(self, in_dict=None, **kwds):
         """
         Substitutes given generators with given values while not touching
-        other generators. This is a generic wrapper around ``__call__``.
-        The syntax is meant to be compatible with the corresponding method
-        for symbolic expressions.
+        other generators.
+
+        This is a generic wrapper around ``__call__``.  The syntax is
+        meant to be compatible with the corresponding method for
+        symbolic expressions.
 
         INPUT:
 
@@ -848,7 +849,6 @@ cdef class Element(SageObject):
         """
         return self.subs(*args, **kwds)
 
-
     def numerical_approx(self, prec=None, digits=None, algorithm=None):
         """
         Return a numerical approximation of ``self`` with ``prec`` bits
@@ -2147,6 +2147,7 @@ def is_ModuleElement(x):
     """
     return isinstance(x, ModuleElement)
 
+
 cdef class ElementWithCachedMethod(Element):
     r"""
     An element class that fully supports cached methods.
@@ -2511,6 +2512,7 @@ cdef class ModuleElementWithMutability(ModuleElement):
         """
         return self._is_immutable
 
+
 ########################################################################
 # Monoid
 ########################################################################
@@ -2521,6 +2523,7 @@ def is_MonoidElement(x):
     """
     return isinstance(x, MonoidElement)
 
+
 cdef class MonoidElement(Element):
     """
     Generic element of a monoid.
@@ -2580,6 +2583,7 @@ def is_AdditiveGroupElement(x):
     """
     return isinstance(x, AdditiveGroupElement)
 
+
 cdef class AdditiveGroupElement(ModuleElement):
     """
     Generic element of an additive group.
@@ -2600,6 +2604,7 @@ def is_MultiplicativeGroupElement(x):
     """
     return isinstance(x, MultiplicativeGroupElement)
 
+
 cdef class MultiplicativeGroupElement(MonoidElement):
     """
     Generic element of a multiplicative group.
@@ -2973,6 +2978,7 @@ def is_CommutativeRingElement(x):
     """
     return isinstance(x, CommutativeRingElement)
 
+
 cdef class CommutativeRingElement(RingElement):
     """
     Base class for elements of commutative rings.
@@ -3758,9 +3764,11 @@ cdef class Vector(ModuleElementWithMutability):
         v = [x._magma_init_(magma) for x in self.list()]
         return '%s![%s]'%(V.name(), ','.join(v))
 
+
 def is_Vector(x):
     return isinstance(x, Vector)
 
+
 cdef class Matrix(ModuleElement):
 
     cdef bint is_sparse_c(self) noexcept:
@@ -4152,16 +4160,17 @@ cdef class Matrix(ModuleElement):
         raise TypeError
 
 
-
 def is_Matrix(x):
     return isinstance(x, Matrix)
 
+
 def is_IntegralDomainElement(x):
     """
     Return ``True`` if x is of type IntegralDomainElement.
     """
     return isinstance(x, IntegralDomainElement)
 
+
 cdef class IntegralDomainElement(CommutativeRingElement):
     def is_nilpotent(self):
         return self.is_zero()
@@ -4173,15 +4182,18 @@ def is_DedekindDomainElement(x):
     """
     return isinstance(x, DedekindDomainElement)
 
+
 cdef class DedekindDomainElement(IntegralDomainElement):
     pass
 
+
 def is_PrincipalIdealDomainElement(x):
     """
     Return ``True`` if x is of type PrincipalIdealDomainElement.
     """
     return isinstance(x, PrincipalIdealDomainElement)
 
+
 cdef class PrincipalIdealDomainElement(DedekindDomainElement):
     def gcd(self, right):
         r"""
@@ -4261,12 +4273,14 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement):
 # calls up the inheritance tree.
 PY_SET_TP_NEW(EuclideanDomainElement, Element)
 
+
 def is_EuclideanDomainElement(x):
     """
     Return ``True`` if x is of type EuclideanDomainElement.
     """
     return isinstance(x, EuclideanDomainElement)
 
+
 cdef class EuclideanDomainElement(PrincipalIdealDomainElement):
 
     def degree(self):
@@ -4339,6 +4353,7 @@ def is_FieldElement(x):
     """
     return isinstance(x, FieldElement)
 
+
 cdef class FieldElement(CommutativeRingElement):
     cpdef _floordiv_(self, right):
         """
@@ -4456,19 +4471,23 @@ def is_AlgebraElement(x):
     """
     return isinstance(x, AlgebraElement)
 
+
 cdef class AlgebraElement(RingElement):
     pass
 
+
 def is_CommutativeAlgebraElement(x):
     """
     Return ``True`` if x is of type CommutativeAlgebraElement.
     """
     return isinstance(x, CommutativeAlgebraElement)
 
+
 cdef class CommutativeAlgebraElement(CommutativeRingElement):
     pass
 
-    ##############################################
+
+##############################################
 
 def is_InfinityElement(x):
     """
@@ -4485,17 +4504,18 @@ def is_InfinityElement(x):
     """
     return isinstance(x, InfinityElement)
 
+
 cdef class InfinityElement(RingElement):
     def __invert__(self):
         from sage.rings.integer_ring import ZZ
         return ZZ(0)
 
 
-#################################################################################
+###############################################################################
 #
 #  Coercion of elements
 #
-#################################################################################
+###############################################################################
 
 cpdef canonical_coercion(x, y):
     """
diff --git a/src/sage/structure/element_wrapper.pyx b/src/sage/structure/element_wrapper.pyx
index 0f0c25bdd8d..f0e9810768f 100644
--- a/src/sage/structure/element_wrapper.pyx
+++ b/src/sage/structure/element_wrapper.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Element Wrapper
 
diff --git a/src/sage/structure/factory.pyx b/src/sage/structure/factory.pyx
index 75a043250c2..12fe812c50d 100644
--- a/src/sage/structure/factory.pyx
+++ b/src/sage/structure/factory.pyx
@@ -570,6 +570,7 @@ cdef class UniqueFactory(SageObject):
 # This is used to handle old UniqueFactory pickles
 factory_unpickles = {}
 
+
 def register_factory_unpickle(name, callable):
     """
     Register a callable to handle the unpickling from an old
@@ -632,6 +633,7 @@ def register_factory_unpickle(name, callable):
     #global factory_unpickles
     factory_unpickles[name] = callable
 
+
 def generic_factory_unpickle(factory, *args):
     """
     Method used for unpickling the object.
@@ -729,6 +731,7 @@ def generic_factory_unpickle(factory, *args):
     # strip this.
     return factory(*args[1], **args[2])
 
+
 def generic_factory_reduce(self, proto):
     """
     Used to provide a ``__reduce__`` method if one does not already exist.
@@ -744,6 +747,7 @@ def generic_factory_reduce(self, proto):
     else:
         return self._factory_data[0].reduce_data(self)
 
+
 def lookup_global(name):
     """
     Used in unpickling the factory itself.
diff --git a/src/sage/structure/formal_sum.py b/src/sage/structure/formal_sum.py
index f8f9b4d16de..93f65c1f0e5 100644
--- a/src/sage/structure/formal_sum.py
+++ b/src/sage/structure/formal_sum.py
@@ -95,6 +95,12 @@ def __init__(self, x, parent=None, check=True, reduce=True):
         - ``reduce`` -- reduce (default: ``True``) if ``False``, do not
           combine common terms
 
+        .. WARNING::
+
+            Setting ``reduce`` to ``False`` can cause issues when comparing
+            equal sums where terms are not combined in the same way (e.g.
+            `2x + 3x` and `4x + 1x` will compare as not equal).
+
         EXAMPLES::
 
             sage: FormalSum([(1,2/3), (3,2/3), (-5, 7)])
@@ -230,8 +236,19 @@ def _richcmp_(self, other, op):
             True
             sage: a == 0          # 0 is coerced into a.parent()(0)
             False
+
+        TESTS::
+
+            sage: a = FormalSum([(1, 3), (2, 5)])
+            sage: b = FormalSum([(2, 5), (1, 3)])
+            sage: a == b
+            True
+            sage: b == a
+            True
         """
-        return richcmp(self._data, other._data, op)
+        self_data = [(c, x) for (x, c) in sorted(self._data, key=str)]
+        other_data = [(c, x) for (x, c) in sorted(other._data, key=str)]
+        return richcmp(self_data, other_data, op)
 
     def _neg_(self):
         """
diff --git a/src/sage/structure/indexed_generators.py b/src/sage/structure/indexed_generators.py
index 42bcecf8938..1afb2e86065 100644
--- a/src/sage/structure/indexed_generators.py
+++ b/src/sage/structure/indexed_generators.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Indexed Generators
 """
diff --git a/src/sage/structure/list_clone.pyx b/src/sage/structure/list_clone.pyx
index 8ae709adc45..533b10a43e1 100644
--- a/src/sage/structure/list_clone.pyx
+++ b/src/sage/structure/list_clone.pyx
@@ -1774,7 +1774,6 @@ def _make_int_array_clone(clas, parent, lst, needs_check, is_immutable, dic):
     return res
 
 
-
 cdef class NormalizedClonableList(ClonableList):
     """
     List with clone protocol and normal form
diff --git a/src/sage/structure/list_clone_demo.pyx b/src/sage/structure/list_clone_demo.pyx
index 0bd018f57c0..1b7118880fc 100644
--- a/src/sage/structure/list_clone_demo.pyx
+++ b/src/sage/structure/list_clone_demo.pyx
@@ -87,7 +87,6 @@ class IncreasingArrays(UniqueRepresentation, Parent):
     Element = IncreasingArray
 
 
-
 class IncreasingLists(IncreasingArrays):
     """
     A small (incomplete) parent for testing
@@ -101,6 +100,7 @@ class IncreasingLists(IncreasingArrays):
     """
     Element = IncreasingList
 
+
 cdef class IncreasingList(ClonableList):
     """
     A small extension class for testing
@@ -133,7 +133,6 @@ cdef class IncreasingList(ClonableList):
                 raise ValueError("array is not increasing")
 
 
-
 cdef class IncreasingIntArray(ClonableIntArray):
     """
     A small extension class for testing
@@ -167,6 +166,7 @@ cdef class IncreasingIntArray(ClonableIntArray):
             if self._getitem(i) >= self._getitem(i+1):
                 raise ValueError("array is not increasing")
 
+
 class IncreasingIntArrays(IncreasingArrays):
     """
     A small (incomplete) parent for testing
@@ -181,7 +181,6 @@ class IncreasingIntArrays(IncreasingArrays):
     Element = IncreasingIntArray
 
 
-
 cdef class SortedList(NormalizedClonableList):
     """
     A small extension class for testing
@@ -231,6 +230,7 @@ cdef class SortedList(NormalizedClonableList):
             if self._getitem(i) >= self._getitem(i+1):
                 raise ValueError("list is not strictly increasing")
 
+
 class SortedLists(IncreasingLists):
     """
     A small (incomplete) parent for testing
diff --git a/src/sage/structure/list_clone_timings.py b/src/sage/structure/list_clone_timings.py
index efe5d20efc7..117463eb908 100644
--- a/src/sage/structure/list_clone_timings.py
+++ b/src/sage/structure/list_clone_timings.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Performance Test for Clone Protocol
 
diff --git a/src/sage/structure/mutability.pyx b/src/sage/structure/mutability.pyx
index c61fd06c3dc..07b30013ebb 100644
--- a/src/sage/structure/mutability.pyx
+++ b/src/sage/structure/mutability.pyx
@@ -242,8 +242,9 @@ cdef class Mutability:
             self.__dict__ = state
         self._is_immutable = state['_is_immutable']
 
+
 ##########################################################################
-## Method decorators for mutating methods resp. methods that assume immutability
+# Method decorators for mutating methods resp. methods that assume immutability
 
 def require_mutable(f):
     """
diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx
index 2b579cdc60a..c775be1a023 100644
--- a/src/sage/structure/parent.pyx
+++ b/src/sage/structure/parent.pyx
@@ -148,12 +148,18 @@ def is_Parent(x):
 
         sage: from sage.structure.parent import is_Parent
         sage: is_Parent(2/3)
+        doctest:warning...
+        DeprecationWarning: the function is_Parent is deprecated;
+        use 'isinstance(..., Parent)' instead
+        See https://github.com/sagemath/sage/issues/37922 for details.
         False
         sage: is_Parent(ZZ)
         True
         sage: is_Parent(Primes())
         True
     """
+    from sage.misc.superseded import deprecation_cython
+    deprecation_cython(37922, "the function is_Parent is deprecated; use 'isinstance(..., Parent)' instead")
     return isinstance(x, Parent)
 
 
diff --git a/src/sage/structure/proof/all.py b/src/sage/structure/proof/all.py
index c006c56c36d..06295f79e80 100644
--- a/src/sage/structure/proof/all.py
+++ b/src/sage/structure/proof/all.py
@@ -35,7 +35,7 @@ def arithmetic(t=None):
         sage: proof.arithmetic()
         True
     """
-    from .proof import _proof_prefs
+    from sage.structure.proof.proof import _proof_prefs
     return _proof_prefs.arithmetic(t)
 
 
@@ -73,7 +73,7 @@ def elliptic_curve(t=None):
         sage: proof.elliptic_curve()
         True
     """
-    from .proof import _proof_prefs
+    from sage.structure.proof.proof import _proof_prefs
     return _proof_prefs.elliptic_curve(t)
 
 
@@ -111,7 +111,7 @@ def linear_algebra(t=None):
         sage: proof.linear_algebra()
         True
     """
-    from .proof import _proof_prefs
+    from sage.structure.proof.proof import _proof_prefs
     return _proof_prefs.linear_algebra(t)
 
 
@@ -148,7 +148,7 @@ def number_field(t=None):
         sage: proof.number_field()
         True
     """
-    from .proof import _proof_prefs
+    from sage.structure.proof.proof import _proof_prefs
     return _proof_prefs.number_field(t)
 
 
@@ -185,7 +185,7 @@ def polynomial(t=None):
         sage: proof.polynomial()
         True
     """
-    from .proof import _proof_prefs
+    from sage.structure.proof.proof import _proof_prefs
     return _proof_prefs.polynomial(t)
 
 
@@ -234,11 +234,11 @@ def all(t=None):
         sage: proof.number_field()
         True
     """
-    from .proof import _proof_prefs
+    from sage.structure.proof.proof import _proof_prefs
     if t is None:
         return _proof_prefs._require_proof.copy()
     for s in _proof_prefs._require_proof:
         _proof_prefs._require_proof[s] = bool(t)
 
 
-from .proof import WithProof
+from sage.structure.proof.proof import WithProof
diff --git a/src/sage/structure/sage_object.pyx b/src/sage/structure/sage_object.pyx
index b5b9f59334d..e78c0b9a8bb 100644
--- a/src/sage/structure/sage_object.pyx
+++ b/src/sage/structure/sage_object.pyx
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
 r"""
 Abstract base class for Sage objects
 """
diff --git a/src/sage/symbolic/all.py b/src/sage/symbolic/all.py
index b5a0883d202..8e1c9600409 100644
--- a/src/sage/symbolic/all.py
+++ b/src/sage/symbolic/all.py
@@ -1,14 +1,14 @@
-from .ring import SR
-from .constants import (pi, e, NaN, golden_ratio, log2, euler_gamma, catalan,
-                       khinchin, twinprime, mertens, glaisher)
-from .expression import Expression, solve_diophantine, hold
-from .callable import CallableSymbolicExpressionRing
+from sage.symbolic.ring import SR
+from sage.symbolic.constants import (pi, e, NaN, golden_ratio, log2, euler_gamma, catalan,
+                                     khinchin, twinprime, mertens, glaisher)
+from sage.symbolic.expression import Expression, solve_diophantine, hold
+from sage.symbolic.callable import CallableSymbolicExpressionRing
 
 from sage.symbolic.relation import solve, solve_mod, solve_ineq
 from sage.symbolic.assumptions import assume, forget, assumptions, assuming
 
-from .units import units
+from sage.symbolic.units import units
 
 π = pi
 
-from .operators import D
+from sage.symbolic.operators import D
diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
index 02b23d16cf4..8475ff50bd9 100644
--- a/src/sage/symbolic/expression.pyx
+++ b/src/sage/symbolic/expression.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # distutils: sources = sage/symbolic/ginac/add.cpp sage/symbolic/ginac/archive.cpp sage/symbolic/ginac/assume.cpp sage/symbolic/ginac/basic.cpp sage/symbolic/ginac/cmatcher.cpp sage/symbolic/ginac/constant.cpp sage/symbolic/ginac/context.cpp sage/symbolic/ginac/ex.cpp sage/symbolic/ginac/expair.cpp sage/symbolic/ginac/expairseq.cpp sage/symbolic/ginac/exprseq.cpp sage/symbolic/ginac/fderivative.cpp sage/symbolic/ginac/function.cpp sage/symbolic/ginac/function_info.cpp sage/symbolic/ginac/infinity.cpp sage/symbolic/ginac/infoflagbase.cpp sage/symbolic/ginac/inifcns.cpp sage/symbolic/ginac/inifcns_comb.cpp sage/symbolic/ginac/inifcns_gamma.cpp sage/symbolic/ginac/inifcns_hyperb.cpp sage/symbolic/ginac/inifcns_hyperg.cpp sage/symbolic/ginac/inifcns_nstdsums.cpp sage/symbolic/ginac/inifcns_orthopoly.cpp sage/symbolic/ginac/inifcns_trans.cpp sage/symbolic/ginac/inifcns_trig.cpp sage/symbolic/ginac/inifcns_zeta.cpp sage/symbolic/ginac/lst.cpp sage/symbolic/ginac/matrix.cpp sage/symbolic/ginac/mpoly-giac.cpp sage/symbolic/ginac/mpoly-ginac.cpp sage/symbolic/ginac/mpoly-singular.cpp sage/symbolic/ginac/mpoly.cpp sage/symbolic/ginac/mul.cpp sage/symbolic/ginac/normal.cpp sage/symbolic/ginac/numeric.cpp sage/symbolic/ginac/operators.cpp sage/symbolic/ginac/order.cpp sage/symbolic/ginac/power.cpp sage/symbolic/ginac/print.cpp sage/symbolic/ginac/pseries.cpp sage/symbolic/ginac/py_funcs.cpp sage/symbolic/ginac/registrar.cpp sage/symbolic/ginac/relational.cpp sage/symbolic/ginac/remember.cpp sage/symbolic/ginac/sum.cpp sage/symbolic/ginac/symbol.cpp sage/symbolic/ginac/templates.cpp sage/symbolic/ginac/upoly-ginac.cpp sage/symbolic/ginac/useries.cpp sage/symbolic/ginac/utils.cpp sage/symbolic/ginac/wildcard.cpp
 # distutils: language = c++
 # distutils: libraries = flint gmp SINGULAR_LIBRARIES
diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx
index 32a22e6f861..eafebf812a7 100644
--- a/src/sage/symbolic/ring.pyx
+++ b/src/sage/symbolic/ring.pyx
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 The symbolic ring
 """
diff --git a/src/sage/tensor/all.py b/src/sage/tensor/all.py
index dc52f0b09ed..e73549851e5 100644
--- a/src/sage/tensor/all.py
+++ b/src/sage/tensor/all.py
@@ -1 +1 @@
-from .modules.all import *
+from sage.tensor.modules.all import *
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/calculus_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/calculus_doctest.py
index 976b912de2a..b410c0a970d 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/calculus_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/calculus_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./calculus_doctest.sage) was *autogenerated* from ./calculus.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/combinat_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/combinat_doctest.py
index 864549d1958..07ab6b5e05e 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/combinat_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/combinat_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./combinat_doctest.sage) was *autogenerated* from ./combinat.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/domaines_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/domaines_doctest.py
index 94c50977d79..ec8a8a7564c 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/domaines_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/domaines_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./domaines_doctest.sage) was *autogenerated* from ./domaines.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/float_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/float_doctest.py
index aa3eed32f3b..b1278d744c5 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/float_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/float_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./float_doctest.sage) was *autogenerated* from ./float.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py
index bdf2f5b1e1e..7c1986c388b 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./graphique_doctest.sage) was *autogenerated* from ./graphique.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py
index c1d8fa977e5..b37cf82e9a4 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./graphtheory_doctest.sage) was *autogenerated* from ./graphtheory.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py
index dbe787aa5ff..779151e50ee 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./integration_doctest.sage) was *autogenerated* from ./integration.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py
index b01729aa7b3..800b6ff43b2 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./linalg_doctest.sage) was *autogenerated* from ./linalg.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
index 7c5b83423ea..7c9e0183efe 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 r"""
 This file (./linsolve_doctest.sage) was *autogenerated* from ./linsolve.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/lp_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/lp_doctest.py
index da89f065214..091151b2a64 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/lp_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/lp_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./lp_doctest.sage) was *autogenerated* from ./lp.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/mpoly_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/mpoly_doctest.py
index bef4a2b6c62..16fa10d03da 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/mpoly_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/mpoly_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./mpoly_doctest.sage) was *autogenerated* from ./mpoly.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/nonlinear_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/nonlinear_doctest.py
index 3a7104637ec..e66238193a6 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/nonlinear_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/nonlinear_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./nonlinear_doctest.sage) was *autogenerated* from ./nonlinear.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/numbertheory_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/numbertheory_doctest.py
index 46a4d4d2bec..dcb9d590c4e 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/numbertheory_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/numbertheory_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./numbertheory_doctest.sage) was *autogenerated* from ./numbertheory.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/polynomes_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/polynomes_doctest.py
index 86ab2edd193..c3ce123c221 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/polynomes_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/polynomes_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./polynomes_doctest.sage) was *autogenerated* from ./polynomes.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py
index 42121f2f815..5a10307b019 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./premierspas_doctest.sage) was *autogenerated* from ./premierspas.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/programmation_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/programmation_doctest.py
index 3f036d5d362..df8082ccfc6 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/programmation_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/programmation_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./programmation_doctest.sage) was *autogenerated* from ./programmation.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
index 95a6367dcee..07cae8e92b5 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./recequadiff_doctest.sage) was *autogenerated* from ./recequadiff.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/calculus_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/calculus_doctest.py
index 947f9f53a22..2f96bb6b4ae 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/calculus_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/calculus_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/calculus_doctest.sage) was *autogenerated* from ./sol/calculus.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/combinat_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/combinat_doctest.py
index 5f372f505b0..10cec032d52 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/combinat_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/combinat_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/combinat_doctest.sage) was *autogenerated* from ./sol/combinat.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/domaines_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/domaines_doctest.py
index df3eb03d8fe..14f1ef6e9b2 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/domaines_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/domaines_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/domaines_doctest.sage) was *autogenerated* from ./sol/domaines.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/float_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/float_doctest.py
index 5d5d4686ec7..fe7b6cb8505 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/float_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/float_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/float_doctest.sage) was *autogenerated* from ./sol/float.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/graphique_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/graphique_doctest.py
index a939dc4471c..2df21aa6652 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/graphique_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/graphique_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/graphique_doctest.sage) was *autogenerated* from ./sol/graphique.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/graphtheory_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/graphtheory_doctest.py
index 27013d35ae8..f32f65028af 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/graphtheory_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/graphtheory_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/graphtheory_doctest.sage) was *autogenerated* from ./sol/graphtheory.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/integration_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/integration_doctest.py
index bb9550918bf..5b7f2b71c9e 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/integration_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/integration_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/integration_doctest.sage) was *autogenerated* from ./sol/integration.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/linalg_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/linalg_doctest.py
index 7f7053fe39d..a60f0c0bf48 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/linalg_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/linalg_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/linalg_doctest.sage) was *autogenerated* from ./sol/linalg.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/linsolve_doctest.py
index e89d7c06fb5..dbc387eb92f 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/linsolve_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/linsolve_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/linsolve_doctest.sage) was *autogenerated* from ./sol/linsolve.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/lp_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/lp_doctest.py
index d60adc9dd8b..801a668b0ff 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/lp_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/lp_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/lp_doctest.sage) was *autogenerated* from ./sol/lp.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/mpoly_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/mpoly_doctest.py
index d4b92c1dfd6..d4d193475b0 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/mpoly_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/mpoly_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/mpoly_doctest.sage) was *autogenerated* from ./sol/mpoly.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/nonlinear_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/nonlinear_doctest.py
index f99860f7b9c..fc9d6607797 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/nonlinear_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/nonlinear_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/nonlinear_doctest.sage) was *autogenerated* from ./sol/nonlinear.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/numbertheory_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/numbertheory_doctest.py
index 2dbd0b018e5..593abeac92d 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/numbertheory_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/numbertheory_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/numbertheory_doctest.sage) was *autogenerated* from ./sol/numbertheory.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/polynomes_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/polynomes_doctest.py
index f8cefd2f6e8..1fc0e242d1a 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/polynomes_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/polynomes_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/polynomes_doctest.sage) was *autogenerated* from ./sol/polynomes.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/recequadiff_doctest.py
index 01d0e1bc143..b1a1739d861 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/sol/recequadiff_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/sol/recequadiff_doctest.py
@@ -1,4 +1,3 @@
-## -*- encoding: utf-8 -*-
 """
 This file (./sol/recequadiff_doctest.sage) was *autogenerated* from ./sol/recequadiff.tex,
 with sagetex.sty version 2011/05/27 v2.3.1.
diff --git a/src/sage/tests/books/judson-abstract-algebra/actions-sage-exercises.py b/src/sage/tests/books/judson-abstract-algebra/actions-sage-exercises.py
index eb93e40815f..c8ce6f5dbc3 100644
--- a/src/sage/tests/books/judson-abstract-algebra/actions-sage-exercises.py
+++ b/src/sage/tests/books/judson-abstract-algebra/actions-sage-exercises.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/actions-sage.py b/src/sage/tests/books/judson-abstract-algebra/actions-sage.py
index 98eb03fcc64..61a15a908aa 100644
--- a/src/sage/tests/books/judson-abstract-algebra/actions-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/actions-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/algcodes-sage.py b/src/sage/tests/books/judson-abstract-algebra/algcodes-sage.py
index 816ae050b95..641fc0fe6d9 100644
--- a/src/sage/tests/books/judson-abstract-algebra/algcodes-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/algcodes-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/boolean-sage.py b/src/sage/tests/books/judson-abstract-algebra/boolean-sage.py
index 2d7b13c00f7..81090c73d38 100644
--- a/src/sage/tests/books/judson-abstract-algebra/boolean-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/boolean-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/cosets-sage-exercises.py b/src/sage/tests/books/judson-abstract-algebra/cosets-sage-exercises.py
index 57ab9ff0acf..263bba7ec6a 100644
--- a/src/sage/tests/books/judson-abstract-algebra/cosets-sage-exercises.py
+++ b/src/sage/tests/books/judson-abstract-algebra/cosets-sage-exercises.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/cosets-sage.py b/src/sage/tests/books/judson-abstract-algebra/cosets-sage.py
index 028dd8cb33c..9ae427ccb6a 100644
--- a/src/sage/tests/books/judson-abstract-algebra/cosets-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/cosets-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/crypt-sage.py b/src/sage/tests/books/judson-abstract-algebra/crypt-sage.py
index 510761ddb6c..d5cf28cf5bb 100644
--- a/src/sage/tests/books/judson-abstract-algebra/crypt-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/crypt-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/cyclic-sage.py b/src/sage/tests/books/judson-abstract-algebra/cyclic-sage.py
index 5f8cd284b52..23b667fab9c 100644
--- a/src/sage/tests/books/judson-abstract-algebra/cyclic-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/cyclic-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/domains-sage.py b/src/sage/tests/books/judson-abstract-algebra/domains-sage.py
index 965fe31b21e..409b8bd6d35 100644
--- a/src/sage/tests/books/judson-abstract-algebra/domains-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/domains-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/fields-sage.py b/src/sage/tests/books/judson-abstract-algebra/fields-sage.py
index de12e97030c..410baa656d4 100644
--- a/src/sage/tests/books/judson-abstract-algebra/fields-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/fields-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/finite-sage.py b/src/sage/tests/books/judson-abstract-algebra/finite-sage.py
index d6d85490a87..749e14e350c 100644
--- a/src/sage/tests/books/judson-abstract-algebra/finite-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/finite-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/galois-sage.py b/src/sage/tests/books/judson-abstract-algebra/galois-sage.py
index b1ecf0d8d48..59960c1aee1 100644
--- a/src/sage/tests/books/judson-abstract-algebra/galois-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/galois-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/groups-sage.py b/src/sage/tests/books/judson-abstract-algebra/groups-sage.py
index 71e0ee12eba..3cdb42138a0 100644
--- a/src/sage/tests/books/judson-abstract-algebra/groups-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/groups-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/homomorph-sage-exercises.py b/src/sage/tests/books/judson-abstract-algebra/homomorph-sage-exercises.py
index 31c4f1818fe..5bc958041d3 100644
--- a/src/sage/tests/books/judson-abstract-algebra/homomorph-sage-exercises.py
+++ b/src/sage/tests/books/judson-abstract-algebra/homomorph-sage-exercises.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/homomorph-sage.py b/src/sage/tests/books/judson-abstract-algebra/homomorph-sage.py
index dbc7bca8d96..429749f280f 100644
--- a/src/sage/tests/books/judson-abstract-algebra/homomorph-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/homomorph-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/integers-sage.py b/src/sage/tests/books/judson-abstract-algebra/integers-sage.py
index 20a8228035e..6d0685963ff 100644
--- a/src/sage/tests/books/judson-abstract-algebra/integers-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/integers-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/isomorph-sage.py b/src/sage/tests/books/judson-abstract-algebra/isomorph-sage.py
index 43333ac1ea1..3d4e5701007 100644
--- a/src/sage/tests/books/judson-abstract-algebra/isomorph-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/isomorph-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/normal-sage.py b/src/sage/tests/books/judson-abstract-algebra/normal-sage.py
index 3db475d41b0..65b5f7bc313 100644
--- a/src/sage/tests/books/judson-abstract-algebra/normal-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/normal-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/permute-sage.py b/src/sage/tests/books/judson-abstract-algebra/permute-sage.py
index 625fb080a06..66e908cc056 100644
--- a/src/sage/tests/books/judson-abstract-algebra/permute-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/permute-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/poly-sage.py b/src/sage/tests/books/judson-abstract-algebra/poly-sage.py
index 0333425266d..4ed0950f79e 100644
--- a/src/sage/tests/books/judson-abstract-algebra/poly-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/poly-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/rings-sage.py b/src/sage/tests/books/judson-abstract-algebra/rings-sage.py
index 6d9571d00cd..0ad971e38db 100644
--- a/src/sage/tests/books/judson-abstract-algebra/rings-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/rings-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/sets-sage.py b/src/sage/tests/books/judson-abstract-algebra/sets-sage.py
index 0825b227669..e6acbe2a9e5 100644
--- a/src/sage/tests/books/judson-abstract-algebra/sets-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/sets-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/struct-sage.py b/src/sage/tests/books/judson-abstract-algebra/struct-sage.py
index ce825b56c3c..320d418dbf7 100644
--- a/src/sage/tests/books/judson-abstract-algebra/struct-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/struct-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py b/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py
index cd78b147ca3..6ec7e7777a0 100644
--- a/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/vect-sage-exercises.py b/src/sage/tests/books/judson-abstract-algebra/vect-sage-exercises.py
index 45786b72a36..15a880d1fd3 100644
--- a/src/sage/tests/books/judson-abstract-algebra/vect-sage-exercises.py
+++ b/src/sage/tests/books/judson-abstract-algebra/vect-sage-exercises.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/tests/books/judson-abstract-algebra/vect-sage.py b/src/sage/tests/books/judson-abstract-algebra/vect-sage.py
index 46a9bd7cb68..5aca41c8899 100644
--- a/src/sage/tests/books/judson-abstract-algebra/vect-sage.py
+++ b/src/sage/tests/books/judson-abstract-algebra/vect-sage.py
@@ -1,4 +1,3 @@
-##      -*-   coding: utf-8   -*-     ##
 ##          Sage Doctest File         ##
 #**************************************#
 #*    Generated from PreTeXt source   *#
diff --git a/src/sage/topology/all.py b/src/sage/topology/all.py
index 53b89564daa..18b553e873d 100644
--- a/src/sage/topology/all.py
+++ b/src/sage/topology/all.py
@@ -1,11 +1,11 @@
 # sage.doctest: needs sage.graphs
-from .simplicial_complex import SimplicialComplex, Simplex
+from sage.topology.simplicial_complex import SimplicialComplex, Simplex
 
-from .simplicial_complex_morphism import SimplicialComplexMorphism
+from sage.topology.simplicial_complex_morphism import SimplicialComplexMorphism
 
-from .delta_complex import DeltaComplex, delta_complexes
+from sage.topology.delta_complex import DeltaComplex, delta_complexes
 
-from .cubical_complex import CubicalComplex, cubical_complexes
+from sage.topology.cubical_complex import CubicalComplex, cubical_complexes
 
 from sage.misc.lazy_import import lazy_import
 lazy_import('sage.topology.filtered_simplicial_complex', 'FilteredSimplicialComplex')
@@ -18,3 +18,4 @@
 # # For taking care of old pickles
 # from sage.misc.persist import register_unpickle_override
 # register_unpickle_override('sage.topology.simplicial_complex_examples', 'SimplicialSurface', SimplicialComplex)
+del lazy_import
diff --git a/src/sage/topology/simplicial_complex_homset.py b/src/sage/topology/simplicial_complex_homset.py
index 255e905a990..eaad72b8905 100644
--- a/src/sage/topology/simplicial_complex_homset.py
+++ b/src/sage/topology/simplicial_complex_homset.py
@@ -77,8 +77,14 @@ def is_SimplicialComplexHomset(x) -> bool:
          in Category of finite simplicial complexes
         sage: from sage.topology.simplicial_complex_homset import is_SimplicialComplexHomset
         sage: is_SimplicialComplexHomset(H)
+        doctest:warning...
+        DeprecationWarning: the function is_SimplicialComplexHomset is deprecated;
+        use 'isinstance(..., SimplicialComplexHomset)' instead
+        See https://github.com/sagemath/sage/issues/37922 for details.
         True
     """
+    from sage.misc.superseded import deprecation
+    deprecation(37922, "the function is_SimplicialComplexHomset is deprecated; use 'isinstance(..., SimplicialComplexHomset)' instead")
     return isinstance(x, SimplicialComplexHomset)
 
 
diff --git a/src/sage/typeset/ascii_art.py b/src/sage/typeset/ascii_art.py
index 395245c0df5..55e3291c531 100644
--- a/src/sage/typeset/ascii_art.py
+++ b/src/sage/typeset/ascii_art.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 ASCII Art
 
diff --git a/src/sage/typeset/character_art.py b/src/sage/typeset/character_art.py
index d9ada8ac1c7..64151a2d3a0 100644
--- a/src/sage/typeset/character_art.py
+++ b/src/sage/typeset/character_art.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Base Class for Character-Based Art
 
diff --git a/src/sage/typeset/character_art_factory.py b/src/sage/typeset/character_art_factory.py
index 4439f7b7144..ea450c38da6 100644
--- a/src/sage/typeset/character_art_factory.py
+++ b/src/sage/typeset/character_art_factory.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Factory for Character-Based Art
 """
diff --git a/src/sage/typeset/symbols.py b/src/sage/typeset/symbols.py
index 00ddf81e63a..8265d852370 100644
--- a/src/sage/typeset/symbols.py
+++ b/src/sage/typeset/symbols.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Symbols for Character Art
 
diff --git a/src/sage/typeset/unicode_art.py b/src/sage/typeset/unicode_art.py
index d9218e1df30..9a2dbf0fb76 100644
--- a/src/sage/typeset/unicode_art.py
+++ b/src/sage/typeset/unicode_art.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 r"""
 Unicode Art
 
diff --git a/src/sage/version.py b/src/sage/version.py
index 35a9364e251..018677bbe04 100644
--- a/src/sage/version.py
+++ b/src/sage/version.py
@@ -1,5 +1,5 @@
 # Sage version information for Python scripts
 # This file is auto-generated by the sage-update-version script, do not edit!
-version = '10.4.beta6'
-date = '2024-05-12'
-banner = 'SageMath version 10.4.beta6, Release Date: 2024-05-12'
+version = '10.4.beta7'
+date = '2024-05-25'
+banner = 'SageMath version 10.4.beta7, Release Date: 2024-05-25'
diff --git a/src/sage_docbuild/ext/sage_autodoc.py b/src/sage_docbuild/ext/sage_autodoc.py
index 4e9bcef39be..d60d5efbf44 100644
--- a/src/sage_docbuild/ext/sage_autodoc.py
+++ b/src/sage_docbuild/ext/sage_autodoc.py
@@ -113,7 +113,7 @@ def identity(x: Any) -> Any:
 
 
 class _All:
-    """A special value for ``:*-members:`` that matches to any member."""
+    r"""A special value for :\*-members: that matches to any member."""
 
     def __contains__(self, item: Any) -> bool:
         return True
diff --git a/src/sage_setup/autogen/flint/README.md b/src/sage_setup/autogen/flint/README.md
index cd693904a53..2205b7ed82e 100644
--- a/src/sage_setup/autogen/flint/README.md
+++ b/src/sage_setup/autogen/flint/README.md
@@ -6,18 +6,23 @@ Cython header files in `$SAGE_ROOT/src/sage/libs/flint/`. To make the
 autogeneration
 
 1. Obtain a clone of the flint repo, eg `git clone
-   https://github.com/flintlib/flint2`
+   https://github.com/flintlib/flint`
 
-2. Checkout to the appropriate commit, eg `git checkout v2.9.0`
+2. Checkout to the appropriate commit, eg `git checkout v3.0.1`. The correct
+   version can be found in `$SAGE_ROOT/build/pkgs/flint/package-version.txt`
 
-3. Possibly adjust the content of `types.pxd.template` (which will be used to
+3. Possibly edit the docs at `$FLINT_ROOT/doc/source/*.rst` to match the
+   exposed API.txt`. For example, the docs of release `v3.0.1` was incorrect,
+   so the commit `3e2c3a3e091106a25ca9c6fba28e02f2cbcd654a` was used instead
+
+4. Possibly adjust the content of `types.pxd.template` (which will be used to
    generate types.pxd)
 
-4. Set the environment variable `FLINT_GIT_DIR`
+5. Set the environment variable `FLINT_GIT_DIR`
 
-5. Run the `flint_autogen.py` script eg `python
+6. Run the `flint_autogen.py` script e.g. `python
    $SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py`. The script writes down
-   the headers in the sage source tree `$SAGE_ROOT/src/sage/libs/flint/`.
+   the headers in the sage source tree `$SAGE_ROOT/src/sage/libs/flint/`
 
 
 Additional notes
diff --git a/src/sage_setup/autogen/flint/writer.py b/src/sage_setup/autogen/flint/writer.py
index e63d3c9bcf9..bc6069a9640 100644
--- a/src/sage_setup/autogen/flint/writer.py
+++ b/src/sage_setup/autogen/flint/writer.py
@@ -13,7 +13,7 @@
 
 import os
 import shutil
-from .env import AUTOGEN_DIR, FLINT_DOC_DIR, FLINT_INCLUDE_DIR
+from .env import AUTOGEN_DIR, FLINT_GIT_DIR, FLINT_DOC_DIR, FLINT_INCLUDE_DIR
 from .reader import extract_functions
 
 
@@ -23,7 +23,17 @@ def write_flint_cython_headers(output_dir, documentation=False):
 
     Arguments
     output_dir -- (string) path where to write the .pxd files
+
+    Requires gitpython to be installed.
     """
+    if not os.path.isdir(os.path.join(FLINT_GIT_DIR, ".git")):
+        raise ValueError(f"FLINT_GIT_DIR(={FLINT_GIT_DIR}) is not a Git repository")
+
+    import git
+    repo = git.Repo(FLINT_GIT_DIR)
+    commit = repo.head.commit
+    print(f"Generating cython headers from {commit}")
+
     header_list = []
     pxd_list = []
     for filename in os.listdir(FLINT_DOC_DIR):
@@ -66,6 +76,7 @@ def write_flint_cython_headers(output_dir, documentation=False):
         print('#' * 80, file=output)
         print('# This file is auto-generated by the script', file=output)
         print('#   SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.', file=output)
+        print('# From the commit {}'.format(commit), file=output)
         print('# Do not modify by hand! Fix and rerun the script instead.', file=output)
         print('#' * 80, file=output)
         print(file=output)
diff --git a/src/sage_setup/clean.py b/src/sage_setup/clean.py
deleted file mode 100644
index 1b00f211d75..00000000000
--- a/src/sage_setup/clean.py
+++ /dev/null
@@ -1,199 +0,0 @@
-"""
-Clean the Install Dir
-"""
-#*****************************************************************************
-#       Copyright (C) 2014      Volker Braun 
-#                     2015      Jeroen Demeyer
-#                     2017      Erik M. Bray
-#                     2020-2022 Matthias Koeppe
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#                  http://www.gnu.org/licenses/
-#*****************************************************************************
-
-
-import importlib.util
-import os
-
-from sage.misc.package_dir import SourceDistributionFilter
-from sage_setup.find import get_extensions, installed_files_by_module
-
-
-def _remove(file_set, module_base, to_remove):
-    """
-    Helper to remove files from a set of filenames.
-
-    INPUT:
-
-    - ``file_set`` -- a set of filenames.
-
-    - ``module_base`` -- string. Name of a Python package/module.
-
-    - ``to_remove`` -- list/tuple/iterable of strings. Either
-      filenames or extensions (starting with ``'.'``)
-
-    OUTPUT:
-
-    This function does not return anything. The ``file_set`` parameter
-    is modified in place.
-
-    EXAMPLES::
-
-        sage: files = set(['a/b/c.py', 'a/b/d.py', 'a/b/c.pyx'])
-        sage: from sage_setup.clean import _remove
-        sage: _remove(files, 'a.b', ['c.py', 'd.py'])
-        sage: files
-        {'a/b/c.pyx'}
-
-        sage: files = set(['a/b/c.py', 'a/b/d.py', 'a/b/c.pyx'])
-        sage: _remove(files, 'a.b.c', ['.py', '.pyx'])
-        sage: files
-        {'a/b/d.py'}
-    """
-    path = os.path.join(*module_base.split('.'))
-
-    for filename in to_remove:
-        if filename.startswith('.'):
-            filename = path + filename
-        else:
-            filename = os.path.join(path, filename)
-
-        remove = [filename]
-
-        remove.append(importlib.util.cache_from_source(filename))
-        file_set.difference_update(remove)
-
-
-def _find_stale_files(site_packages, python_packages, python_modules, ext_modules, data_files, nobase_data_files=()):
-    """
-    Find stale files
-
-    This method lists all files installed and then subtracts the ones
-    which are intentionally being installed.
-
-    EXAMPLES:
-
-    It is crucial that only truly stale files are being found, of
-    course. We check that when the doctest is being run, that is,
-    after installation, there are no stale files::
-
-        sage: # needs SAGE_SRC
-        sage: from sage.env import SAGE_SRC, SAGE_LIB, SAGE_ROOT
-        sage: from sage_setup.find import _cythonized_dir
-        sage: cythonized_dir = _cythonized_dir(SAGE_SRC)
-        sage: from sage_setup.find import find_python_sources, find_extra_files
-        sage: python_packages, python_modules, cython_modules = find_python_sources(
-        ....:     SAGE_SRC, ['sage', 'sage_setup'])
-        sage: extra_files = find_extra_files(SAGE_SRC,
-        ....:     ['sage', 'sage_setup'], cythonized_dir, [])
-        sage: from importlib.metadata import files
-        sage: for f in files('sagemath-standard'):
-        ....:     dir = os.path.dirname(str(f))
-        ....:     extra_files[dir] = extra_files.get(dir, [])
-        ....:     extra_files[dir].append(str(f))
-        sage: extra_files = list(extra_files.items())
-        sage: from sage_setup.clean import _find_stale_files
-
-    TODO: Also check extension modules::
-
-        sage: # needs SAGE_SRC
-        sage: stale_iter = _find_stale_files(SAGE_LIB, python_packages, python_modules, [], extra_files)
-        sage: from importlib.machinery import EXTENSION_SUFFIXES
-        sage: skip_extensions = tuple(EXTENSION_SUFFIXES)
-        sage: for f in stale_iter:
-        ....:     if f.endswith(skip_extensions): continue
-        ....:     if '/ext_data/' in f: continue
-        ....:     print('Found stale file: ' + f)
-    """
-
-    PYMOD_EXTS = get_extensions('source') + get_extensions('bytecode')
-    CEXTMOD_EXTS = get_extensions('extension')
-    INIT_FILES = tuple('__init__' + x for x in PYMOD_EXTS)
-
-    module_files = installed_files_by_module(site_packages, ['sage'])
-
-    for mod in python_packages:
-        try:
-            files = module_files[mod]
-        except KeyError:
-            # the source module "mod" has not been previously installed, fine.
-            continue
-        _remove(files, mod, INIT_FILES)
-    for mod in python_modules:
-        try:
-            files = module_files[mod]
-        except KeyError:
-            continue
-        _remove(files, mod, PYMOD_EXTS)
-    for ext in ext_modules:
-        mod = ext.name
-        try:
-            files = module_files[mod]
-        except KeyError:
-            continue
-        _remove(files, mod, CEXTMOD_EXTS)
-
-    # Convert data_files to a set
-    installed_files = set()
-    for dir, files in data_files:
-        for f in files:
-            installed_files.add(os.path.join(dir, os.path.basename(f)))
-    for dir, files in nobase_data_files:
-        for f in files:
-            installed_files.add(f)
-
-    for files in module_files.values():
-        for f in files:
-            if f not in installed_files:
-                yield f
-
-
-def clean_install_dir(site_packages, python_packages, python_modules, ext_modules, data_files, nobase_data_files, *,
-                      distributions=None, exclude_distributions=None):
-    """
-    Delete all modules that are **not** being installed
-
-    If you switch branches it is common to (re)move the source for an
-    already installed module. Subsequent rebuilds will leave the stale
-    module in the install directory, which can break programs that try
-    to import all modules. In particular, the Sphinx autodoc builder
-    does this and is susceptible to hard-to-reproduce failures that
-    way. Hence we must make sure to delete all stale modules.
-
-    INPUT:
-
-    - ``site_packages`` -- the root Python path where the Sage library
-      is being installed.
-
-    - ``python_packages`` -- list of pure Python packages (directories
-      with ``__init__.py``).
-
-    - ``python_modules`` -- list of pure Python modules.
-
-    - ``ext_modules`` -- list of distutils ``Extension`` classes. The
-      output of ``cythonize``.
-
-    - ``data_files`` -- a list of (installation directory, files) pairs,
-      like the ``data_files`` argument to distutils' ``setup()``. Only
-      the basename of the files is used.
-
-    - ``nobase_data_files`` -- a list of (installation directory, files)
-      pairs. The files are expected to be in a subdirectory of the
-      installation directory; the filenames are used as is.
-
-    - ``distributions`` -- (default: ``None``) if not ``None``,
-      should be a sequence or set of strings: only clean files whose
-      ``distribution`` (from a ``# sage_setup: distribution = PACKAGE``
-      directive in the file) is an element of ``distributions``.
-    """
-    distribution_filter = SourceDistributionFilter(distributions, exclude_distributions)
-    stale_file_iter = _find_stale_files(
-        site_packages, python_packages, python_modules, ext_modules, data_files, nobase_data_files)
-    for f in stale_file_iter:
-        f = os.path.join(site_packages, f)
-        if f in distribution_filter:
-            print('Cleaning up stale file: {0}'.format(f))
-            os.unlink(f)
diff --git a/src/sage_setup/command/sage_install.py b/src/sage_setup/command/sage_install.py
index abfc142eec4..052fbecc71e 100644
--- a/src/sage_setup/command/sage_install.py
+++ b/src/sage_setup/command/sage_install.py
@@ -1,5 +1,5 @@
 #########################################################
-### Install Jupyter kernel spec and clean stale files
+### Install Jupyter kernel spec
 #########################################################
 
 import os
@@ -45,71 +45,3 @@ def run(self):
         develop.run(self)
         if not self.uninstall:
             self.install_kernel_spec()
-
-
-class sage_clean(install):
-
-    all_distributions = None
-
-    def run(self):
-        t = time.time()
-        self.clean_stale_files()
-        log.info('Finished cleaning, time: %.2f seconds.' % (time.time() - t))
-
-    def clean_stale_files(self):
-        """
-        Remove stale installed files.
-
-        This removes files which are built/installed but which do not
-        exist in the Sage sources (typically because some source file
-        has been deleted). Files are removed from the build directory
-        ``build/lib-*`` and from the install directory ``site-packages``.
-        """
-        dist = self.distribution
-        cmd_build_py = self.get_finalized_command("build_py")
-        cmd_build_cython = self.get_finalized_command("build_cython")
-
-        # Determine all Python modules inside all packages
-        py_modules = []
-        ordinary_packages = []
-        for package in dist.packages:
-            package_dir = cmd_build_py.get_package_dir(package)
-            if os.path.exists(os.path.join(package_dir, '__init__.py')):
-                ordinary_packages.append(package)
-            py_modules.extend(cmd_build_py.find_package_modules(package, package_dir))
-        # modules is a list of triples (package, module, module_file).
-        # Construct the complete module name from this.
-        py_modules = ["{0}.{1}".format(*m) for m in py_modules]
-        if dist.py_modules:
-            py_modules.extend(dist.py_modules)
-
-        # Determine all files of package data and Cythonized package files
-        # example of entries of cmd_build_cython.get_cythonized_package_files():
-        #   ('sage/media', ['./sage/media/channels.pyx'])
-        data_files = cmd_build_cython.get_cythonized_package_files()
-        # examples of entries of build_py.data_files:
-        #   ('sage.libs.gap', 'sage/libs/gap', 'build/lib.macosx-10.9-x86_64-3.7/sage/libs/gap', ['sage.gaprc'])
-        #   ('sage', 'sage', 'build/lib.macosx-10.9-x86_64-3.7/sage', ['ext_data/nodoctest.py', 'ext_data/kenzo/S4.txt', ...])
-        nobase_data_files = [(src_dir, [os.path.join(src_dir, filename) for filename in filenames])
-                             for package, src_dir, build_dir, filenames in cmd_build_py.data_files]
-
-        # Clean install directory (usually, purelib and platlib are the same)
-        # and build directory.
-        output_dirs = [self.install_purelib, self.install_platlib, self.build_lib]
-        from sage_setup.clean import clean_install_dir
-        for output_dir in set(output_dirs):
-            log.info('- cleaning {0}'.format(output_dir))
-            clean_install_dir(output_dir,
-                    ordinary_packages,
-                    py_modules,
-                    dist.ext_modules,
-                    data_files,
-                    nobase_data_files,
-                    distributions=self.all_distributions)
-
-
-class sage_install_and_clean(sage_install, sage_clean):
-
-    def run(self):
-        sage_install.run(self)
-        sage_clean.run(self)
diff --git a/src/sage_setup/find.py b/src/sage_setup/find.py
index 69bad9a3ebf..8762e08ad0f 100644
--- a/src/sage_setup/find.py
+++ b/src/sage_setup/find.py
@@ -342,98 +342,6 @@ def find_extra_files(src_dir, modules, cythonized_dir, special_filenames=[], *,
     return data_files
 
 
-def installed_files_by_module(site_packages, modules=('sage',)):
-    """
-    Find all currently installed files
-
-    INPUT:
-
-    - ``site_packages`` -- string. The root Python path where the Sage
-      library is being installed. If the path doesn't exist, returns
-      an empty dictionary.
-
-    - ``modules`` -- list/tuple/iterable of strings (default:
-      ``('sage',)``). The top-level directory name(s) in
-      ``site_packages``.
-
-    OUTPUT:
-
-    A dictionary whose keys are module names (``'sage.module.foo'``)
-    and values are list of corresponding file names
-    ``['sage/module/foo.py', 'sage/module/foo.pyc']`` relative to
-    ``site_packages``.
-
-    EXAMPLES::
-
-        sage: site_packages = os.path.dirname(os.path.dirname(os.path.dirname(sage.cpython.__file__)))
-        sage: from sage_setup.find import installed_files_by_module
-        sage: files_by_module = installed_files_by_module(site_packages)
-        sage: (f,) = files_by_module['sage.structure.sage_object']; f
-        'sage/structure/sage_object...'
-        sage: (f1, f2) = sorted(files_by_module['sage.structure'])
-        sage: f1
-        'sage/structure/__init__.py'
-        sage: f2
-        'sage/structure/....pyc'
-
-    Namespace packages::
-
-        sage: files_by_module['sage.graphs.graph_decompositions']
-        set()
-
-    This takes about 30ms with warm cache::
-
-        sage: timeit('installed_files_by_module(site_packages)',       # random output
-        ....:        number=1, repeat=1)
-        1 loops, best of 1: 29.6 ms per loop
-    """
-
-    module_files = defaultdict(set)
-    module_exts = get_extensions()
-
-    def add(module, filename, dirpath):
-        # Find the longest extension that matches the filename
-        best_ext = ''
-
-        for ext in module_exts:
-            if filename.endswith(ext) and len(ext) > len(best_ext):
-                best_ext = ext
-
-        if not best_ext:
-            return
-
-        base = filename[:-len(best_ext)]
-        filename = os.path.join(dirpath, filename)
-
-        if base != '__init__':
-            module += '.' + base
-
-        module_files[module].add(filename)
-
-        cache_filename = importlib.util.cache_from_source(filename)
-        if os.path.exists(cache_filename):
-            module_files[module].add(cache_filename)
-
-    cwd = os.getcwd()
-    try:
-        os.chdir(site_packages)
-    except OSError:
-        return module_files
-    try:
-        for module in modules:
-            for dirpath, dirnames, filenames in os.walk(module):
-                module_dir = '.'.join(dirpath.split(os.path.sep))
-
-                if os.path.basename(dirpath) == '__pycache__':
-                    continue
-
-                for filename in filenames:
-                    add(module_dir, filename, dirpath)
-    finally:
-        os.chdir(cwd)
-    return module_files
-
-
 def get_extensions(type=None):
     """
     Returns the filename extensions for different types of Python module files.
diff --git a/src/tox.ini b/src/tox.ini
index ca69ed6c8bf..6e6a084b3db 100644
--- a/src/tox.ini
+++ b/src/tox.ini
@@ -21,7 +21,7 @@
 ##   in a virtual environment.
 ##
 [tox]
-envlist = doctest, coverage, startuptime, pycodestyle-minimal, relint, codespell, rst
+envlist = doctest, coverage, startuptime, pycodestyle-minimal, relint, codespell, rst, ruff-minimal
 # When adding environments above, also update the delegations in SAGE_ROOT/tox.ini
 skipsdist = true
 
@@ -259,6 +259,66 @@ description =
 deps = cython-lint
 commands = cython-lint --no-pycodestyle {posargs:{toxinidir}/sage/}
 
+[testenv:ruff]
+description =
+    check against Python style conventions
+deps = ruff
+passenv = RUFF_OUTPUT_FORMAT
+commands = ruff check {posargs:{toxinidir}/sage/}
+
+[testenv:ruff-minimal]
+description =
+    check against Sage's minimal style conventions
+deps = ruff
+# https://github.com/ChartBoost/ruff-action/issues/7#issuecomment-1887780308
+passenv = RUFF_OUTPUT_FORMAT
+# Output of currently failing, from "./sage -tox -e ruff -- --statistics":
+#
+#   3579        PLR2004 [ ] Magic value used in comparison, consider replacing `- 0.5` with a constant variable
+#   3498        I001    [*] Import block is un-sorted or un-formatted
+#   2146        F401    [*] `.PyPolyBoRi.Monomial` imported but unused
+#   1964        E741    [ ] Ambiguous variable name: `I`
+#   1676        F821    [ ] Undefined name `AA`
+#   1513        PLR0912 [ ] Too many branches (102 > 12)
+#   1159        PLR0913 [ ] Too many arguments in function definition (10 > 5)
+#    815        E402    [ ] Module level import not at top of file
+#    671        PLR0915 [ ] Too many statements (100 > 50)
+#    483        PLW2901 [ ] Outer `for` loop variable `ext` overwritten by inner `for` loop target
+#    433        PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation
+#    428        PLR0911 [ ] Too many return statements (10 > 6)
+#    404        E731    [*] Do not assign a `lambda` expression, use a `def`
+#    351        F405    [ ] `ComplexField` may be undefined, or defined from star imports
+#    306        PLR1714 [*] Consider merging multiple comparisons. Use a `set` if the elements are hashable.
+#    236        F403    [ ] `from .abelian_gps.all import *` used; unable to detect undefined names
+#    116        PLR0402 [*] Use `from matplotlib import cm` in lieu of alias
+#    111        PLW0603 [ ] Using the global statement to update `AA_0` is discouraged
+#     78        F841    [*] Local variable `B` is assigned to but never used
+#     64        E713    [*] Test for membership should be `not in`
+#     48        PLW0602 [ ] Using global for `D` but no assignment is done
+#     33        PLR1711 [*] Useless `return` statement at end of function
+#     24        E714    [*] Test for object identity should be `is not`
+#     20        PLR1701 [*] Merge `isinstance` calls
+#     17        PLW3301 [ ] Nested `max` calls can be flattened
+#     16        PLW1510 [*] `subprocess.run` without explicit `check` argument
+#     14        E721    [ ] Do not compare types, use `isinstance()`
+#     14        PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents
+#     12        F811    [*] Redefinition of unused `CompleteDiscreteValuationRings` from line 49
+#      8        PLC0414 [*] Import alias does not rename original package
+#      7        E743    [ ] Ambiguous function name: `I`
+#      7        PLE0101 [ ] Explicit return in `__init__`
+#      7        PLR0124 [ ] Name compared with itself, consider replacing `a == a`
+#      5        PLW0127 [ ] Self-assignment of variable `a`
+#      4        F541    [*] f-string without any placeholders
+#      4        PLW1508 [ ] Invalid type for environment variable default; expected `str` or `None`
+#      3        PLC3002 [ ] Lambda expression called directly. Execute the expression inline instead.
+#      2        E742    [ ] Ambiguous class name: `I`
+#      2        PLE0302 [ ] The special method `__len__` expects 1 parameter, 3 were given
+#      2        PLW0129 [ ] Asserting on a non-empty string literal will always pass
+#      1        F402    [ ] Import `factor` from line 259 shadowed by loop variable
+#      1        PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
+#
+commands = ruff check --ignore PLR2004,I001,F401,E741,F821,PLR0912,PLR0913,E402,PLR0915,PLW2901,PLR5501,PLR0911,E731,F405,PLR1714,F403,PLR0402,PLW0603,F841,E713,PLW0602,PLR1711,E714,PLR1701,PLW3301,PLW1510,E721,PLW0120,F811,PLC0414,E743,PLE0101,PLR0124,PLW0127,F541,PLW1508,PLC3002,E742,PLE0302,PLW0129,F402,PLC0208 {posargs:{toxinidir}/sage/}
+
 [flake8]
 rst-roles =
     # Sphinx
diff --git a/tox.ini b/tox.ini
index b06f4529afc..ad1dc38d11b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -148,6 +148,12 @@ passenv =
                   # Use DOCKER_BUILDKIT=0 for legacy builder
     docker:       DOCKER_BUILDKIT
     docker:       BUILDKIT_INLINE_CACHE
+    docker:       DOCKER_HOST
+                  # On macOS, the docker CLI may need $HOME to find the socket
+                  # $HOME/Library/Containers/com.docker.docker/Data/docker-cli.sock
+                  # Otherwise may get the error "Cannot connect to the Docker daemon at
+                  # unix:///var/run/docker.sock. Is the docker daemon running?"
+    docker:       HOME
                   # Set for example to "with-system-packages configured with-targets-pre with-targets"
                   # to tag intermediate images.
     docker:       DOCKER_TARGETS
@@ -198,8 +204,8 @@ setenv =
     # Whether to add the system packages needed for bootstrapping
                            EXTRA_SAGE_PACKAGES_0=_bootstrap
     nobootstrap:           EXTRA_SAGE_PACKAGES_0=
-    # local envs need HOME set, also Docker 19.03 needs HOME
-    {local,docker}: HOME={envdir}
+    # local envs need HOME set
+    local:            HOME={envdir}
     # for local envs we can guess the package system if it is not provided as a factor
     local:          SYSTEM=auto
     #
@@ -507,6 +513,7 @@ setenv =
     docker-incremental-sitepackages:                    SKIP_SYSTEM_PKG_INSTALL=no
     #
     docker-nobootstrap: BOOTSTRAP=./bootstrap -D
+    docker:           CONFIG_CONFIGURE_ARGS_ROOT=--enable-build-as-root
     ###
     ### "local" envs
     ###
@@ -722,7 +729,7 @@ commands =
     # local-homebrew
     #
     # https://docs.brew.sh/Installation
-    homebrew:      bash -c 'if [ ! -x {env:HOMEBREW}/bin/brew ]; then mkdir -p {env:HOMEBREW} && cd {env:HOMEBREW} && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 ; fi'
+    homebrew:      bash -c 'if [ ! -x {env:HOMEBREW}/bin/brew ]; then git clone --depth 1 https://github.com/Homebrew/brew {env:HOMEBREW}; fi'
     homebrew:      bash -c 'case "{env:SKIP_SYSTEM_PKG_INSTALL:}" in 1|y*|Y*);; *) export PATH="build/bin:$PATH" && PACKAGES=$(sage-get-system-packages homebrew $(sage-package list {env:SAGE_PACKAGE_LIST_ARGS}) {env:ALL_EXTRA_SAGE_PACKAGES}); {env:HOMEBREW}/bin/brew install $PACKAGES; {env:HOMEBREW}/bin/brew upgrade $PACKAGES;; esac'
     #
     # local-macports
@@ -758,7 +765,7 @@ commands =
     local:         bash -c 'if [ ! -d prefix -o -L prefix ]; then rm -f prefix; ln -sf {env:PREFIX:{envdir}/local} prefix; fi'
 
 ##commands =
-    docker:        bash -c '.ci/write-dockerfile.sh {env:SYSTEM} "{env:SAGE_PACKAGE_LIST_ARGS:}" {env:WITH_SYSTEM_SPKG} {env:IGNORE_MISSING_SYSTEM_PACKAGES} "{env:ALL_EXTRA_SAGE_PACKAGES}" > {envdir}/Dockerfile'
+    docker:        bash -c 'BUILD_TAG={env:DOCKER_TAG:$(git describe --dirty --always)} .ci/write-dockerfile.sh {env:SYSTEM} "{env:SAGE_PACKAGE_LIST_ARGS:}" {env:WITH_SYSTEM_SPKG} {env:IGNORE_MISSING_SYSTEM_PACKAGES} "{env:ALL_EXTRA_SAGE_PACKAGES}" > {envdir}/Dockerfile'
     # From https://hub.docker.com/r/multiarch/ubuntu-core/
     # configure binfmt-support on the Docker host (works locally or remotely, i.e: using boot2docker)
     docker-{arm64,armhf}:  docker run --rm --privileged multiarch/qemu-user-static:register --reset
@@ -853,7 +860,7 @@ setenv =
     #
     DEFAULT_SYSTEM_FACTORS=\
                      ubuntu-{xenial-toolchain-gcc_9,bionic-gcc_8,focal,jammy,lunar,mantic,noble} \
-                     debian-{buster-gcc_spkg,bullseye,bookworm,trixie,sid} \
+                     debian-{bullseye,bookworm,trixie,sid} \
                      linuxmint-{20.1,20.2,20.3,21,21.1,21.2,21.3} \
                      fedora-{30,31,32,33,34,35,36,37,38,39,40} \
                      centos-7-devtoolset-gcc_11 \
@@ -1090,3 +1097,23 @@ passenv  = {[sage_src]passenv}
 envdir   = {[sage_src]envdir}
 commands = {[sage_src]commands}
 allowlist_externals = {[sage_src]allowlist_externals}
+
+[testenv:ruff]
+description =
+    check against Python style conventions
+passenv  = {[sage_src]passenv}
+           # https://github.com/ChartBoost/ruff-action/issues/7#issuecomment-1887780308
+           RUFF_OUTPUT_FORMAT
+envdir   = {[sage_src]envdir}
+allowlist_externals = {[sage_src]allowlist_externals}
+commands = tox -c {toxinidir}/src/tox.ini -e {envname} -- {posargs:src/sage/}
+
+[testenv:ruff-minimal]
+description =
+    check against Sage's minimal style conventions
+passenv  = {[sage_src]passenv}
+           # https://github.com/ChartBoost/ruff-action/issues/7#issuecomment-1887780308
+           RUFF_OUTPUT_FORMAT
+envdir   = {[sage_src]envdir}
+allowlist_externals = {[sage_src]allowlist_externals}
+commands = tox -c {toxinidir}/src/tox.ini -e {envname} -- {posargs:src/sage/}