diff --git a/gnu/local.mk b/gnu/local.mk
index ed630041ff..76d58c8e38 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1586,8 +1586,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/john-the-ripper-jumbo-with-gcc-11.patch	\
   %D%/packages/patches/json-c-0.13-CVE-2020-12762.patch		\
   %D%/packages/patches/json-c-0.12-CVE-2020-12762.patch		\
+  %D%/packages/patches/julia-1.9-build-tweaks.patch		\
   %D%/packages/patches/julia-SOURCE_DATE_EPOCH-mtime.patch	\
-  %D%/packages/patches/julia-Use-MPFR-4.2.patch	                \
   %D%/packages/patches/libcall-ui-make-it-installable.patch	\
   %D%/packages/patches/libcamera-ipa_manager-disable-signature-verification.patch	\
   %D%/packages/patches/libcss-check-format.patch		\
diff --git a/gnu/packages/julia.scm b/gnu/packages/julia.scm
index 9668b3fd1e..5c7d900a09 100644
--- a/gnu/packages/julia.scm
+++ b/gnu/packages/julia.scm
@@ -28,6 +28,7 @@ (define-module (gnu packages julia)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix utils)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
@@ -142,412 +143,493 @@ (define-public libwhich
 (define-public julia
   (package
     (name "julia")
-    (version "1.8.3")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append
-                    "https://github.com/JuliaLang/julia/releases/download/v"
-                    version "/julia-" version ".tar.gz"))
-              (sha256
-               (base32
-                "0jf8dr5j7y8cjnr65kn38xps5h9m2qvi8g1yd8qgiip5r87ld3ad"))
-              (patches (search-patches "julia-SOURCE_DATE_EPOCH-mtime.patch"
-                                       "julia-Use-MPFR-4.2.patch"))))
+    (version "1.9.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/JuliaLang/julia/releases/download/v" version
+             "/julia-" version ".tar.gz"))
+       (sha256
+        (base32 "0788hbcr1v89crv2j3insy89lxs0zwjbxk9q73jpj4g7j26bszcd"))
+       (patches (search-patches "julia-SOURCE_DATE_EPOCH-mtime.patch"
+                                "julia-1.9-build-tweaks.patch"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:test-target "test"
-       #:modules ((ice-9 match)
-                  (guix build gnu-build-system)
-                  (guix build utils))
+     (list #:test-target "test"
+           #:modules `((ice-9 match)
+                       (guix build gnu-build-system)
+                       (guix build utils))
 
-       ;; The test suite takes many times longer than building and
-       ;; can easily fail on smaller machines when they run out of memory.
-       #:tests? ,(not (or (%current-target-system)
-                          (target-aarch64?)))
+           ;; The test suite takes many times longer than building and
+           ;; can easily fail on smaller machines when they run out of memory.
+           #:tests? (not (or (%current-target-system)
+                             (target-aarch64?)))
 
-       ;; Do not strip binaries to keep support for full backtraces.
-       ;; See https://github.com/JuliaLang/julia/issues/17831
-       #:strip-binaries? #f
+           ;; Do not strip binaries to keep support for full backtraces.
+           ;; See https://github.com/JuliaLang/julia/issues/17831
+           #:strip-binaries? #f
 
-       ;; The DSOs use $ORIGIN to refer to each other, but (guix build
-       ;; gremlin) doesn't support it yet, so skip this phase.
-       #:validate-runpath? #f
+           ;; The DSOs use $ORIGIN to refer to each other, but (guix build
+           ;; gremlin) doesn't support it yet, so skip this phase.
+           #:validate-runpath? #f
 
-       #:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (add-after 'unpack 'prepare-deps
-           (lambda* (#:key inputs #:allow-other-keys)
-             ;; needed by libwhich
-             (setenv "LD_LIBRARY_PATH"
-                     (string-join (map (lambda (pkg)
-                                         (string-append (assoc-ref inputs pkg)
-                                                        "/lib"))
-                                       '("curl" "dsfmt"
-                                         "gmp" "lapack"
-                                         "libssh2" "libnghttp2" "libgit2"
-                                         "libblastrampoline"
-                                         "mbedtls" "mpfr"
-                                         "openblas" "openlibm" "pcre2"
-                                         "suitesparse" "gfortran:lib"))
-                                  ":"))))
-         ;; FIXME: Building the documentation requires Julia packages that
-         ;; would be downloaded from the Internet.  We should build them in a
-         ;; separate build phase.
-         (add-after 'unpack 'disable-documentation
-           (lambda _
-             (substitute* "Makefile"
-               (("(install: .*) \\$\\(BUILDROOT\\)/doc/_build/html/en/index.html" _ line)
-                (string-append line "\n"))
-               (("src ui doc deps")
-                "src ui deps"))))
-         (add-after 'unpack 'activate-gnu-source-for-loader
-           (lambda _
-             (substitute* "cli/Makefile"
-               (("LOADER_CFLAGS =") "LOADER_CFLAGS = -D_GNU_SOURCE"))))
-         ;; libquadmath is not available on all architectures.
-         ;; https://github.com/JuliaLang/julia/issues/41613
-         (add-after 'unpack 'make-libquadmath-optional
-           (lambda _
-             (substitute* "base/Makefile"
-               (("libquadmath,0") "libquadmath,0,ALLOW_FAILURE"))))
-         (add-before 'check 'set-home
-           ;; Some tests require a home directory to be set.
-           (lambda _ (setenv "HOME" "/tmp")))
-         (add-before 'build 'fix-include-and-link-paths
-           (lambda* (#:key inputs #:allow-other-keys)
-             ;; The REPL must be linked with libuv.
-             (substitute* "cli/Makefile"
-               (("JLDFLAGS \\+= ")
-                (string-append "JLDFLAGS += "
-                               (assoc-ref inputs "libuv")
-                               "/lib/libuv.so ")))))
-         (add-before 'build 'replace-default-shell
-           (lambda* (#:key inputs #:allow-other-keys)
-             (substitute* "base/client.jl"
-               (("/bin/sh") (search-input-file inputs "/bin/sh")))))
-         (add-before 'build 'shared-objects-paths
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let ((jlpath
-                    (lambda (pkgname)
-                      (string-append
-                       "stdlib/" pkgname "_jll/src/" pkgname "_jll.jl")))
-                   (from
-                    (lambda (libname)
-                      (string-append "const " libname " = .*\\.so")))
-                   (to
-                    (lambda* (pkg libname #:optional libname_jl)
+           #:phases
+           #~(modify-phases %standard-phases
+               (delete 'configure)
+               (add-after 'unpack 'prepare-deps
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   ;; needed by libwhich
+                   (match inputs
+                     (((labels . directories) ...)
+                      (set-path-environment-variable
+                       "LD_LIBRARY_PATH"
+                       '("lib") directories)))))
+               (add-before 'check 'set-home
+                 ;; Some tests require a home directory to be set.
+                 (lambda _
+                   (setenv "HOME" "/tmp")))
+               (add-before 'build 'fix-include-and-link-paths
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   ;; The REPL must be linked with libuv.
+                   (substitute* "cli/Makefile"
+                     (("JLDFLAGS \\+= ")
+                      (string-append "JLDFLAGS += "
+                                     (search-input-file inputs
+                                                        "/lib/libuv.so") " ")))))
+               (add-before 'build 'fix-nested-dlopen
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (substitute* "Make.inc"
+                     ;; See the patch comment for the explanation, *must* be updated
+                     ;; when updating julia.
+                     (("GUIX_LIBUTF8PROC")
+                      (search-input-file inputs "/lib/libutf8proc.a")))
+                   (substitute* "Makefile"
+                     ;; See the patch comment for the explanation, *must* be updated
+                     ;; when updating julia.
+                     (("GUIX_LIBCHOLMOD")
+                      (search-input-file inputs "/lib/libcholmod.so"))
+                     (("GUIX_LIBSPQR")
+                      (search-input-file inputs "/lib/libspqr.so"))
+                     (("GUIX_LIBSC")
+                      (search-input-file inputs
+                                         "/lib/libsuitesparseconfig.so"))
+                     (("GUIX_LIBUMFPACK")
+                      (search-input-file inputs "/lib/libumfpack.so")))))
+               (add-before 'build 'replace-default-shell
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (substitute* "base/client.jl"
+                     (("/bin/sh")
+                      (search-input-file inputs "/bin/sh")))))
+               (add-before 'build 'shared-objects-paths
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (let ((jlpath (lambda (pkgname)
+                                   (string-append "stdlib/" pkgname
+                                                  "_jll/src/" pkgname
+                                                  "_jll.jl")))
+                         (jlbasepath (lambda (pkgname)
+                                       (string-append "base/" pkgname
+                                                      ".jl")))
+                         (tolib (lambda (libname)
+                                  (search-input-file inputs
+                                                     (string-append
+                                                      "/lib/" libname
+                                                      ".so"))))
+                         (toquotedlib (lambda (libname)
+                                        (define file
+                                          (string-append "/lib/"
+                                                         libname
+                                                         ".so"))
+                                        (string-append "\""
+                                                       (search-input-file
+                                                        inputs file)
+                                                       "\"")))
+                         (from (lambda (libname)
+                                 (string-append "const " libname
+                                                " = .*\\.so")))
+                         (to (lambda* (libname #:optional libname_jl)
+                               (define file
+                                 (string-append "/lib/" libname ".so"))
+
+                               (string-append "const "
+                                              (or libname_jl libname)
+                                              " = \""
+                                              (search-input-file
+                                               inputs file)))))
+                     (substitute* "src/jitlayers.cpp"
+                       (("libatomic.so")
+                        (search-input-file inputs "/lib/libatomic.so")))
+                     (substitute* (list (jlbasepath "linking")
+                                        (jlpath "LLD"))
+                       (("\"lld\"")
+                        (string-append "\""
+                                       (search-input-file inputs
+                                                          "/bin/lld")
+                                       "\"")))
+                     (substitute* (jlbasepath "pcre")
+                       (("libpcre2-8")
+                        (tolib "libpcre2-8")))
+                     (substitute* (jlbasepath "gmp")
+                       (("libgmp.so.10")
+                        (tolib "libgmp")))
+                     (substitute* (jlbasepath "mpfr")
+                       (("libmpfr.so.6")
+                        (tolib "libmpfr")))
+                     (substitute* (jlbasepath "irrationals")
+                       ((":libmpfr")
+                        (toquotedlib "libmpfr")))
+                     (substitute* "stdlib/Random/src/generation.jl"
+                       ((":libmpfr")
+                        (toquotedlib "libmpfr")))
+                     (substitute* "stdlib/Printf/src/Printf.jl"
+                       (("\"libmpfr\"")
+                        (toquotedlib "libmpfr")))
+                     (substitute* "stdlib/Random/src/DSFMT.jl"
+                       ((":libdSFMT")
+                        (toquotedlib "libdSFMT")))
+                     (for-each (lambda (file)
+                                 (substitute* file
+                                   ((":libgit2")
+                                    (toquotedlib "libgit2"))))
+                               (find-files "stdlib/LibGit2/" "\\.jl$"))
+                     (substitute* (jlpath "CompilerSupportLibraries")
+                       (((from "libgomp"))
+                        (to "libgomp"))
+                       (((from "libgfortran"))
+                        (string-append
+                         "const libgfortran = string(\""
+                         (search-input-file inputs
+                                            "/lib/libgfortran.so"))))
+                     (substitute* (jlpath "dSFMT")
+                       (((from "libdSFMT"))
+                        (to "libdSFMT")))
+                     (substitute* (jlpath "GMP")
+                       (((from "libgmp"))
+                        (to "libgmp"))
+                       (((from "libgmpxx"))
+                        (to "libgmpxx")))
+                     (substitute* (jlpath "libLLVM")
+                       (((from "libLLVM"))
+                        (to "libLLVM")))
+                     (substitute* (jlbasepath "binaryplatforms")
+                       (("libLLVM-14jl")
+                        (tolib "libLLVM-14jl")))
+                     (substitute* (jlpath "LibCURL")
+                       (((from "libcurl"))
+                        (to "libcurl")))
+                     (substitute* (jlpath "LibGit2")
+                       (((from "libgit2"))
+                        (to "libgit2")))
+                     (substitute* (jlpath "LibSSH2")
+                       (((from "libssh2"))
+                        (to "libssh2")))
+                     (substitute* (jlpath "LibUV")
+                       (((from "libuv"))
+                        (to "libuv")))
+                     (substitute* (jlpath "LibUnwind")
+                       (((from "libunwind"))
+                        (to "libunwind")))
+                     (substitute* (jlpath "MPFR")
+                       (((from "libmpfr"))
+                        (to "libmpfr")))
+                     (substitute* (jlpath "MbedTLS")
+                       (((from "libmbedcrypto"))
+                        (to "libmbedcrypto"))
+                       (((from "libmbedtls"))
+                        (to "libmbedtls"))
+                       (((from "libmbedx509"))
+                        (to "libmbedx509")))
+                     (substitute* (jlpath "nghttp2")
+                       (((from "libnghttp2"))
+                        (to "libnghttp2")))
+                     (substitute* (jlpath "OpenBLAS")
+                       (("libgfortran.so")
+                        (tolib "libgfortran"))
+                       (((from "libopenblas"))
+                        #$@(if (target-x86-64?)
+                               `((to "libopenblas64_" "libopenblas"))
+                               `((to "libopenblas")))))
+                     (substitute* (jlpath "OpenLibm")
+                       (((from "libopenlibm"))
+                        (to "libopenlibm")))
+                     (substitute* (jlpath "PCRE2")
+                       (((from "libpcre2_8"))
+                        (to "libpcre2-8" "libpcre2_8")))
+                     (substitute* (jlpath "SuiteSparse")
+                       (((from "libamd"))
+                        (to "libamd"))
+                       (((from "libbtf"))
+                        (to "libbtf"))
+                       (((from "libcamd"))
+                        (to "libcamd"))
+                       (((from "libccolamd"))
+                        (to "libccolamd"))
+                       (((from "libcholmod"))
+                        (to "libcholmod"))
+                       (((from "libcolamd"))
+                        (to "libcolamd"))
+                       (((from "libklu"))
+                        (to "libklu"))
+                       (((from "libldl"))
+                        (to "libldl"))
+                       (((from "librbio"))
+                        (to "librbio"))
+                       (((from "libspqr"))
+                        (to "libspqr"))
+                       (((from "libsuitesparse"))
+                        (to "libsuitesparse"))
+                       (((from "libsuitesparseconfig"))
+                        (to "libsuitesparseconfig"))
+                       (((from "libumfpack"))
+                        (to "libumfpack")))
+                     (substitute* (jlpath "Zlib")
+                       (((from "libz"))
+                        (to "libz")))
+                     (substitute* (jlpath "libblastrampoline")
+                       (("libblastrampoline\\.so")
+                        (search-input-file inputs
+                                           "/lib/libblastrampoline.so"))))))
+               (add-before 'build 'use-ssl-cert-file
+                 (lambda _
+                   ;; We must adapt MozillaCACerts to use SSL_CERT_FILE.
+                   (substitute* "stdlib/MozillaCACerts_jll/src/MozillaCACerts_jll.jl"
+                     (("global cacert = .*")
                       (string-append
-                       "const " (or libname_jl libname)  " = \""
-                       (assoc-ref inputs pkg) "/lib/" libname ".so"))))
-               (substitute* (jlpath "CompilerSupportLibraries")
-                 (((from "libgfortran"))
-                  (string-append "const libgfortran = string(\""
-                                 (search-input-file inputs "/lib/libgfortran.so"))))
-               (substitute* (jlpath "dSFMT")
-                 (((from "libdSFMT")) (to "dsfmt" "libdSFMT")))
-               (substitute* (jlpath "GMP")
-                 (((from "libgmp")) (to "gmp" "libgmp"))
-                 (((from "libgmpxx")) (to "gmp" "libgmpxx")))
-               (substitute* (jlpath "libLLVM")
-                 (((from "libLLVM")) (to "llvm" "libLLVM")))
-               (substitute* (jlpath "LibCURL")
-                 (((from "libcurl")) (to "curl" "libcurl")))
-               (substitute* (jlpath "LibGit2")
-                 (((from "libgit2")) (to "libgit2" "libgit2")))
-               (substitute* (jlpath "LibSSH2")
-                 (((from "libssh2")) (to "libssh2" "libssh2")))
-               (substitute* (jlpath "LibUV")
-                 (((from "libuv")) (to "libuv" "libuv")))
-               (substitute* (jlpath "LibUnwind")
-                 (((from "libunwind")) (to "libunwind" "libunwind")))
-               (substitute* (jlpath "MPFR")
-                 (((from "libmpfr")) (to "mpfr" "libmpfr")))
-               (substitute* (jlpath "MbedTLS")
-                 (((from "libmbedcrypto")) (to "mbedtls" "libmbedcrypto"))
-                 (((from "libmbedtls")) (to "mbedtls" "libmbedtls"))
-                 (((from "libmbedx509")) (to "mbedtls" "libmbedx509")))
-               (substitute* (jlpath "nghttp2")
-                 (((from "libnghttp2")) (to "libnghttp2" "libnghttp2")))
-               (substitute* (jlpath "OpenBLAS")
-                 (((from "libopenblas"))
-                  ,@(if (target-x86-64?)
-                      `((to "openblas" "libopenblas64_" "libopenblas"))
-                      `((to "openblas" "libopenblas")))))
-               (substitute* (jlpath "OpenLibm")
-                 (((from "libopenlibm")) (to "openlibm" "libopenlibm")))
-               (substitute* (jlpath "PCRE2")
-                 (((from "libpcre2_8")) (to "pcre2" "libpcre2-8" "libpcre2_8")))
-               (substitute* (jlpath "SuiteSparse")
-                 (((from "libamd")) (to "suitesparse" "libamd"))
-                 (((from "libbtf")) (to "suitesparse" "libbtf"))
-                 (((from "libcamd")) (to "suitesparse" "libcamd"))
-                 (((from "libccolamd")) (to "suitesparse" "libccolamd"))
-                 (((from "libcholmod")) (to "suitesparse" "libcholmod"))
-                 (((from "libcolamd")) (to "suitesparse" "libcolamd"))
-                 (((from "libklu")) (to "suitesparse" "libklu"))
-                 (((from "libldl")) (to "suitesparse" "libldl"))
-                 (((from "librbio")) (to "suitesparse" "librbio"))
-                 (((from "libspqr")) (to "suitesparse" "libspqr"))
-                 (((from "libsuitesparse")) (to "suitesparse" "libsuitesparse"))
-                 (((from "libsuitesparseconfig"))
-                  (to "suitesparse" "libsuitesparseconfig"))
-                 (((from "libumfpack")) (to "suitesparse" "libumfpack")))
-               (substitute* (jlpath "Zlib")
-                 (((from "libz")) (to "zlib" "libz")))
-               (substitute* (jlpath "libblastrampoline")
-                 (("libblastrampoline\\.so")
-                  (search-input-file inputs "/lib/libblastrampoline.so"))))))
-         (add-before 'build 'use-ssl-cert-file
-           (lambda _
-             ;; We must adapt MozillaCACerts to use SSL_CERT_FILE.
-             (substitute* "stdlib/MozillaCACerts_jll/src/MozillaCACerts_jll.jl"
-               (("global cacert = .*")
-                (string-append
-                  "global cacert = get(ENV, \"SSL_CERT_FILE\","
-                  ;; our fallback location.
-                  "\"/etc/ssl/certs/ca-certificates.crt\")\n")))))
-         (add-after 'unpack 'enable-parallel-tests
-           (lambda* (#:key parallel-tests? #:allow-other-keys)
-             (when parallel-tests?
-               (setenv "JULIA_TEST_USE_MULTIPLE_WORKERS" "true"))))
-         (add-after 'unpack 'adjust-test-suite
-           (lambda* (#:key inputs #:allow-other-keys)
-             (substitute* "test/spawn.jl"
-               (("shcmd = `sh`") (string-append "shcmd = `" (which "sh") "`")))
-             ;; Some tests only check to see if the input is the correct version.
-             (substitute* "stdlib/PCRE2_jll/test/runtests.jl"
-               (("10.40.0") ,(package-version (this-package-input "pcre2"))))
-             (substitute* "stdlib/MbedTLS_jll/test/runtests.jl"
-               (("2.28.0") ,(package-version (this-package-input "mbedtls"))))
-             (substitute* "stdlib/MPFR_jll/test/runtests.jl"
-               (("4.1.0") ,(package-version (this-package-input "mpfr"))))
-             (substitute* "stdlib/GMP_jll/test/runtests.jl"
-               (("6.2.1") ,(package-version (this-package-input "gmp"))))
-             (substitute* "stdlib/LibGit2_jll/test/runtests.jl"
-               (("1.3.0") ,(package-version (this-package-input "libgit2"))))
-             (substitute* "stdlib/nghttp2_jll/test/runtests.jl"
-               (("1.48.0") ,(package-version (this-package-input "libnghttp2"))))
-             (substitute* "stdlib/Zlib_jll/test/runtests.jl"
-               (("1.2.12") ,(package-version (this-package-input "zlib"))))
-             (substitute* "stdlib/SuiteSparse_jll/test/runtests.jl"
-               (("5010") ,(string-replace-substring
-                            (version-major+minor
-                              (package-version
-                                (this-package-input "suitesparse"))) "." "0")))))
-         (add-before 'check 'disable-broken-tests
-           (lambda _
-             ;; disabling REPL tests because they require a stdin
-             ;; There are some read-only precompile issues in the 1.6 series.
-             ;; https://github.com/JuliaLang/julia/pull/41614
-             ;; https://github.com/JuliaLang/julia/issues/41156
-             (substitute* "test/choosetests.jl"
-               (("\"cmdlineargs\",") "")
-               (("\"precompile\",") ""))
-             ;; Dates/io tests fail on master when networking is unavailable
-             ;; https://github.com/JuliaLang/julia/issues/34655
-             (substitute* "stdlib/Dates/test/io.jl"
-               (("using Dates") "import Dates
+                       "global cacert = get(ENV, \"SSL_CERT_FILE\","
+                       ;; our fallback location.
+                       "\"/etc/ssl/certs/ca-certificates.crt\")\n")))))
+               (add-after 'unpack 'enable-parallel-tests
+                 (lambda* (#:key parallel-tests? #:allow-other-keys)
+                   (when parallel-tests?
+                     (setenv "JULIA_TEST_USE_MULTIPLE_WORKERS" "true"))))
+               (add-after 'unpack 'adjust-test-suite
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (substitute* "test/spawn.jl"
+                     (("shcmd = `sh`")
+                      (string-append "shcmd = `"
+                                     (which "sh") "`")))
+
+                   ;; Some tests only check to see if the input is the correct version.
+                   (substitute* "stdlib/PCRE2_jll/test/runtests.jl"
+                     (("10\\.42\\.0")
+                      #$(package-version (this-package-input "pcre2"))))
+                   (substitute* "stdlib/MbedTLS_jll/test/runtests.jl"
+                     (("2\\.28\\.2")
+                      #$(package-version (this-package-input "mbedtls-apache"))))
+                   (substitute* "stdlib/MPFR_jll/test/runtests.jl"
+                     (("4\\.1\\.1")
+                      #$(package-version (this-package-input "mpfr"))))
+                   (substitute* "stdlib/GMP_jll/test/runtests.jl"
+                     (("6\\.2\\.1")
+                      #$(package-version (this-package-input "gmp"))))
+                   (substitute* "stdlib/LibGit2_jll/test/runtests.jl"
+                     (("1\\.5\\.0")
+                      #$(package-version (this-package-input "libgit2"))))
+                   (substitute* "stdlib/nghttp2_jll/test/runtests.jl"
+                     (("1\\.48\\.0")
+                      #$(package-version (this-package-input "nghttp2"))))
+                   (substitute* "stdlib/Zlib_jll/test/runtests.jl"
+                     (("1\\.2\\.13")
+                      #$(package-version (this-package-input "zlib"))))
+                   (substitute* "stdlib/SuiteSparse_jll/test/runtests.jl"
+                     (("5010")
+                      #$(string-replace-substring
+                         (version-major+minor
+                          (package-version
+                           (this-package-input "suitesparse"))) "." "0")))))
+               (add-before 'check 'disable-broken-tests
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   ;; disabling REPL tests because they require a stdin
+                   ;; There are some read-only precompile issues in the 1.6 series.
+                   ;; https://github.com/JuliaLang/julia/pull/41614
+                   ;; https://github.com/JuliaLang/julia/issues/41156
+                   (substitute* "test/choosetests.jl"
+                     (("\"cmdlineargs\",")
+                      "")
+                     (("\"precompile\",")
+                      ""))
+                   ;; Distributed test with remote execution
+                   (substitute* "usr/share/julia/stdlib/v1.9/Distributed/test/distributed_exec.jl"
+                     (("using Test,")
+                      "exit()\n"))
+                   ;; Dates/io tests fail on master when networking is unavailable
+                   ;; https://github.com/JuliaLang/julia/issues/34655
+                   (substitute* "stdlib/Dates/test/io.jl"
+                     (("using Dates")
+                      "import Dates
 using Dates: @dateformat_str, Date, DateTime, DateFormat, Time"))
-             ;; julia embeds a certificate, we are not doing that
-             (substitute* "stdlib/MozillaCACerts_jll/test/runtests.jl"
-               (("@test isfile\\(MozillaCACerts_jll.cacert\\)")
-                "@test_broken isfile(MozillaCACerts_jll.cacert)"))
-             ;; since certificate is not present some tests are failing in network option
-             (substitute* "usr/share/julia/stdlib/v1.8/NetworkOptions/test/runtests.jl"
-               (("@test isfile\\(bundled_ca_roots\\(\\)\\)")
-                "@test_broken isfile(bundled_ca_roots())")
-               (("@test ispath\\(ca_roots_path\\(\\)\\)")
-                "@test_broken ispath(ca_roots_path())")
-               (("@test ca_roots_path\\(\\) \\!= bundled_ca_roots\\(\\)")
-                "@test_broken ca_roots_path() != bundled_ca_roots()"))
-             ;; WARNING: failed to select UTF-8 encoding, using ASCII
-             ;; Using 'setlocale' doesn't affect the test failures.
-             ;(setlocale LC_ALL "en_US.utf8")
-             ;(setenv "LC_ALL" "en_US.utf8")
-             (substitute* "test/cmdlineargs.jl"
-               (("test v\\[3") "test_broken v[3")
-               (("test isempty\\(v\\[3") "test_broken isempty(v[3"))
-             ;; These test(s) randomly fails because they depend on CPU.
-             (substitute* "test/math.jl"
-               ;; @test_broken cannot be used because if the test randomly
-               ;; passes, then it also raises an error.
-               (("@test isinf\\(log1p\\(-one\\(T\\)\\)\\)")
-                " "))
+                   ;; julia embeds a certificate, we are not doing that
+                   (substitute* "stdlib/MozillaCACerts_jll/test/runtests.jl"
+                     (("@test isfile\\(MozillaCACerts_jll.cacert\\)")
+                      "@test_broken isfile(MozillaCACerts_jll.cacert)"))
+                   ;; since certificate is not present some tests are failing in network option
+                   (substitute* "usr/share/julia/stdlib/v1.9/NetworkOptions/test/runtests.jl"
+                     (("@test isfile\\(bundled_ca_roots\\(\\)\\)")
+                      "@test_broken isfile(bundled_ca_roots())")
+                     (("@test ispath\\(ca_roots_path\\(\\)\\)")
+                      "@test_broken ispath(ca_roots_path())")
+                     (("@test ca_roots_path\\(\\) \\!= bundled_ca_roots\\(\\)")
+                      "@test_broken ca_roots_path() != bundled_ca_roots()"))
+                   ;; WARNING: failed to select UTF-8 encoding, using ASCII
+                   ;; Using 'setlocale' doesn't affect the test failures.
+                   ;; (setlocale LC_ALL "en_US.utf8")
+                   ;; (setenv "LC_ALL" "en_US.utf8")
+                   (substitute* "test/cmdlineargs.jl"
+                     (("test v\\[3")
+                      "test_broken v[3")
+                     (("test isempty\\(v\\[3")
+                      "test_broken isempty(v[3"))
+                   ;; These test(s) randomly fails because they depend on CPU.
+                   (substitute* "test/math.jl"
+                     ;; @test_broken cannot be used because if the test randomly
+                     ;; passes, then it also raises an error.
+                     (("@test isinf\\(log1p\\(-one\\(T\\)\\)\\)")
+                      " "))
 
-             ;; These are new test failures for 1.8:
-             ;; This test passes on some architectures and fails on others.
-             (substitute* "stdlib/LinearAlgebra/test/lu.jl"
-               (("@test String") "@test_skip String"))
+                   ;; These are new test failures for 1.8:
+                   ;; This test passes on some architectures and fails on others.
+                   (substitute* "stdlib/LinearAlgebra/test/lu.jl"
+                     (("@test String")
+                      "@test_skip String"))
 
-             (substitute* "stdlib/InteractiveUtils/test/runtests.jl"
-               (("@test !occursin\\(\"Environment")
-                "@test_broken !occursin(\"Environment")
-               (("@test  occursin\\(\"Environment")
-                "@test_broken  occursin(\"Environment"))
-             (substitute* "usr/share/julia/stdlib/v1.8/Statistics/test/runtests.jl"
-               (("@test cov\\(A") "@test_skip cov(A")
-               (("@test isfinite") "@test_skip isfinite"))
-             ;; LoadError: SuiteSparse threads test failed with nthreads == 4
-             (substitute* "usr/share/julia/stdlib/v1.8/SuiteSparse/test/runtests.jl"
-               (("Base\\.USE_GPL_LIBS") "false"))
-             ;; Got exception outside of a @test
-             ;; LinearAlgebra.LAPACKException(16)
-             ;; eliminate all the test bits.
-             (substitute* "stdlib/LinearAlgebra/test/schur.jl"
-               (("f = schur\\(A, B\\)") "f = schur(A, A)")
-               (("@test f\\.Q\\*f\\.S\\*f\\.Z'.*") "\n")
-               (("@test f\\.Q\\*f\\.T\\*f\\.Z'.*") "\n"))
-             (substitute* "test/threads.jl"
-               (("@test success") "@test_broken success"))))
-         ;; Doesn't this just mean they weren't linked correctly?
-         (add-after 'install 'symlink-missing-libraries
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (link
-                      (lambda (pkgname pred)
-                        (map (lambda (file)
-                               (unless (file-exists?
-                                         (string-append out "/lib/julia/"
-                                                        (basename file)))
-                                 (symlink file (string-append out "/lib/julia/"
-                                                              (basename file)))))
-                        (find-files (string-append (assoc-ref inputs pkgname)
-                                                   "/lib") pred)))))
-               (link "libunwind" "libunwind\\.so")
-               (link "llvm" "libLLVM-13jl\\.so")
-               (link "utf8proc" "libutf8proc\\.so")
-               (link "zlib" "libz\\.so"))))
-         (add-after 'install 'make-wrapper
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (bin (string-append out "/bin"))
-                    (program "julia"))
-               (with-directory-excursion bin
-                 (wrap-program program
-                   `("JULIA_LOAD_PATH" ":" prefix
-                     ("" "$JULIA_LOAD_PATH"))
-                   `("JULIA_DEPOT_PATH" ":" prefix
-                     ("" "$JULIA_DEPOT_PATH"))))))))
-       #:make-flags
-       (list
-        "VERBOSE=1" ;; more helpful logging of what make is doing
-        (string-append "prefix=" (assoc-ref %outputs "out"))
+                   (substitute* "usr/share/julia/stdlib/v1.9/Statistics/test/runtests.jl"
+                     (("@test cov\\(A")
+                      "@test_skip cov(A")
+                     (("@test isfinite")
+                      "@test_skip isfinite"))
+                   ;; LoadError: SuiteSparse threads test failed with nthreads == 4
+                   (substitute* "usr/share/julia/stdlib/v1.9/SuiteSparse/test/runtests.jl"
+                     (("Base\\.USE_GPL_LIBS")
+                      "false"))
+                   ;; Got exception outside of a @test
+                   ;; LinearAlgebra.LAPACKException(16)
+                   ;; eliminate all the test bits.
+                   (substitute* "stdlib/LinearAlgebra/test/schur.jl"
+                     (("f = schur\\(A, B\\)")
+                      "f = schur(A, A)")
+                     (("@test f\\.Q\\*f\\.S\\*f\\.Z'.*")
+                      "\n")
+                     (("@test f\\.Q\\*f\\.T\\*f\\.Z'.*")
+                      "\n"))))
+               ;; Doesn't this just mean they weren't linked correctly?
+               (add-after 'install 'symlink-missing-libraries
+                 (lambda* (#:key inputs outputs #:allow-other-keys)
+                   (let* ((out (assoc-ref outputs "out"))
+                          (link (lambda (pkgname pred)
+                                  (map (lambda (file)
+                                         (unless (file-exists? (string-append
+                                                                out
+                                                                "/lib/julia/"
+                                                                (basename
+                                                                 file)))
+                                           (symlink file
+                                                    (string-append
+                                                     out
+                                                     "/lib/julia/"
+                                                     (basename file)))))
+                                       (find-files (string-append (assoc-ref
+                                                                   inputs
+                                                                   pkgname)
+                                                                  "/lib") pred)))))
+                     (link "libunwind-julia" "libunwind\\.so")
+                     (link "llvm" "libLLVM-14jl\\.so")
+                     (link "gmp" "libgmp\\.so.10")
+                     (link "mpfr" "libmpfr\\.so.6")
+                     (link "zlib" "libz\\.so"))))
+               (add-after 'install 'make-wrapper
+                 (lambda* (#:key inputs outputs #:allow-other-keys)
+                   (let* ((out (assoc-ref outputs "out"))
+                          (bin (string-append out "/bin"))
+                          (program "julia"))
+                     (with-directory-excursion bin
+                       (wrap-program program
+                         `("JULIA_LOAD_PATH" ":" prefix
+                           ("" "$JULIA_LOAD_PATH"))
+                         `("JULIA_DEPOT_PATH" ":" prefix
+                           ("" "$JULIA_DEPOT_PATH"))))))))
 
-         ;; Passing the MARCH or JULIA_CPU_TARGET flag is necessary to build
-         ;; binary substitutes for the supported architectures.  See also
-         ;; https://docs.julialang.org/en/v1/devdocs/sysimg/#Specifying-multiple-system-image-targets
-         ,(match (or (%current-target-system)
-                     (%current-system))
-                 ("x86_64-linux"
-                  ;; These are the flags that upstream uses for their binaries.
-                  "JULIA_CPU_TARGET=generic;generic,-cx16,clone_all;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)")
-                 ("i686-linux" "MARCH=pentium4")
-                 ("armhf-linux" "JULIA_CPU_TARGET=armv7-a,neon")
-                 ("powerpc64le-linux" "JULIA_CPU_TARGET=pwr8")
-                 ;; Prevent errors when querying this package on unsupported
-                 ;; platforms, e.g. when running "guix package --search="
-                 ;; and also of targeting the builder's architecture.
-                 (_ "JULIA_CPU_TARGET=generic"))
+           #:make-flags
+           #~(list (string-append "prefix="
+                                  (assoc-ref %outputs "out"))
 
-         "CONFIG_SHELL=bash -x"     ; needed to build bundled libraries
-         "USE_BINARYBUILDER=0"
-         ;; list (and order!) of "USE_SYSTEM_*" is here:
-         ;; https://github.com/JuliaLang/julia/blob/v1.8.2/Make.inc
-         "USE_SYSTEM_CSL=1"
-         "USE_SYSTEM_LLVM=1"
-         "USE_SYSTEM_LIBUNWIND=1"
-         "USE_SYSTEM_PCRE=1"
-         "USE_SYSTEM_OPENLIBM=1"
-         "USE_SYSTEM_DSFMT=1"
-         "USE_SYSTEM_LIBBLASTRAMPOLINE=1"
-         "USE_SYSTEM_BLAS=1"
-         "USE_SYSTEM_LAPACK=1"
-         "USE_SYSTEM_GMP=1"
-         "USE_SYSTEM_MPFR=1"
-         "USE_SYSTEM_LIBSUITESPARSE=1"
-         "USE_SYSTEM_LIBUV=1"
-         "USE_SYSTEM_UTF8PROC=1"
-         "USE_SYSTEM_MBEDTLS=1"
-         "USE_SYSTEM_LIBSSH2=1"
-         "USE_SYSTEM_NGHTTP2=1"
-         "USE_SYSTEM_CURL=1"
-         "USE_SYSTEM_LIBGIT2=1"
-         "USE_SYSTEM_PATCHELF=1"
-         "USE_SYSTEM_LIBWHICH=1"
-         "USE_SYSTEM_ZLIB=1"
-         "USE_SYSTEM_P7ZIP=1"
+                   ;; Passing the MARCH or JULIA_CPU_TARGET flag is necessary to build
+                   ;; binary substitutes for the supported architectures.  See also
+                   ;; https://docs.julialang.org/en/v1/devdocs/sysimg/#Specifying-multiple-system-image-targets
+                   #$(match (or (%current-target-system)
+                                (%current-system))
+                       ("x86_64-linux"
+                        ;; These are the flags that upstream uses for their binaries.
+                        "JULIA_CPU_TARGET=generic;generic,-cx16,clone_all;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)")
+                       ("i686-linux" "MARCH=pentium4")
+                       ("armhf-linux"
+                        "JULIA_CPU_TARGET=armv7-a,neon")
+                       ("powerpc64le-linux"
+                        "JULIA_CPU_TARGET=pwr8")
+                       ;; Prevent errors when querying this package on unsupported
+                       ;; platforms, e.g. when running "guix package --search="
+                       ;; and also of targeting the builder's architecture.
+                       (_ "JULIA_CPU_TARGET=generic"))
 
-         "USE_LLVM_SHLIB=1"
+                   "CONFIG_SHELL=bash -x" ;needed to build bundled libraries
+                   (string-append "CC="
+                                  #$(cc-for-target))
 
-         "NO_GIT=1"             ; build from release tarball.
-         "USE_GPL_LIBS=1"       ; proudly
+                   #$@(if (target-x86-64?)
+                          `("USE_BLAS64=1"
+                            "LIBBLAS=-lopenblas64_"
+                            "LIBBLASNAME=libopenblas64_")
+                          `("USE_BLAS64=0" "LIBBLAS=-lopenblas"
+                            "LIBBLASNAME=libopenblas"))
 
-         ,@(if (target-x86-64?)
-             `("USE_BLAS64=1"
-               "LIBBLAS=-lopenblas64_"
-               "LIBBLASNAME=libopenblas64_")
-             `("USE_BLAS64=0"
-               "LIBBLAS=-lopenblas"
-               "LIBBLASNAME=libopenblas"))
-
-         (string-append "UTF8PROC_INC="
-                        (assoc-ref %build-inputs "utf8proc")
-                        "/include")
-         ;; Make.inc expects a static library for libuv.
-         (string-append "LIBUV="
-                        (assoc-ref %build-inputs "libuv")
-                        "/lib/libuv.a")
-         (string-append "LIBUV_INC="
-                        (assoc-ref %build-inputs "libuv")
-                        "/include"))))
-    (inputs
-     `(("bash-minimal" ,bash-minimal)
-       ("coreutils" ,coreutils) ; for bindings to "mkdir" and the like
-       ("curl" ,curl-ssh)
-       ("gfortran" ,gfortran)
-       ;; required for libgcc_s.so
-       ("gfortran:lib" ,gfortran "lib")
-       ("gmp" ,gmp)
-       ("lapack" ,lapack)
-       ("libblastrampoline" ,libblastrampoline)
-       ("libgit2" ,libgit2-1.3)
-       ("libnghttp2" ,nghttp2 "lib")
-       ("libssh2" ,libssh2)
-       ("libunwind" ,libunwind-julia)
-       ("libuv" ,libuv-julia)
-       ("llvm" ,llvm-julia)
-       ("mbedtls" ,mbedtls-lts)
-       ("mpfr" ,mpfr)
-       ,@(if (target-x86-64?)
-             `(("openblas" ,openblas-ilp64))
-             `(("openblas" ,openblas)))
-       ("openlibm" ,openlibm)
-       ("p7zip" ,p7zip)
-       ("pcre2" ,pcre2)
-       ("suitesparse" ,suitesparse)
-       ("utf8proc" ,utf8proc-2.7.0)
-       ("wget" ,wget)
-       ("which" ,which)
-       ("zlib" ,zlib)
-       ;; Find dependencies versions here:
-       ;; https://raw.githubusercontent.com/JuliaLang/julia/v1.6.0/deps/Versions.make
-       ("dsfmt" ,dsfmt)
-       ("libwhich" ,libwhich)))
-    (native-inputs
-     `(("openssl" ,openssl)
-       ("perl" ,perl)
-       ("patchelf" ,patchelf)
-       ("pkg-config" ,pkg-config)
-       ("python" ,python)))
+                   (string-append "UTF8PROC_INC="
+                                  (assoc-ref %build-inputs "utf8proc")
+                                  "/include")
+                   ;; Make.inc expects a static library for libuv.
+                   (string-append "LIBUV="
+                                  (search-input-file %build-inputs
+                                                     "/lib/libuv.a"))
+                   (string-append "LIBUV_INC="
+                                  (dirname
+                                   (search-input-file
+                                    %build-inputs "/include/uv.h"))))))
+    (inputs (list coreutils             ;for bindings to "mkdir" and the like
+                  curl-ssh
+                  gfortran
+                  `(,gfortran "lib")              ;required for libgcc_s.so
+                  gmp
+                  lapack
+                  libblastrampoline
+                  libgit2-1.5
+                  `(,nghttp2 "lib")
+                  libssh2
+                  libunwind-julia
+                  libuv-julia
+                  llvm-14-julia
+                  lld-14
+                  mbedtls-apache
+                  mpfr
+                  (if (target-x86-64?) openblas-ilp64 openblas)
+                  openlibm
+                  p7zip
+                  pcre2
+                  suitesparse
+                  utf8proc-2.7.0
+                  wget
+                  which
+                  zlib
+                  ;; Find dependencies versions here:
+                  ;; https://raw.githubusercontent.com/JuliaLang/julia/v1.6.0/deps/Versions.make
+                  dsfmt
+                  libwhich))
+    (native-inputs (list openssl perl patchelf pkg-config python))
     (native-search-paths
-      (list (search-path-specification
-              (variable "JULIA_LOAD_PATH")
-              (files (list "share/julia/loadpath/")))
-            (search-path-specification
-              (variable "JULIA_DEPOT_PATH")
-              (files (list "share/julia/")))
-            $SSL_CERT_FILE))
+     (list (search-path-specification
+            (variable "JULIA_LOAD_PATH")
+            (files (list "share/julia/loadpath/")))
+           (search-path-specification
+            (variable "JULIA_DEPOT_PATH")
+            (files (list "share/julia/")))
+           $SSL_CERT_FILE))
     ;; Julia only officially supports some of our platforms:
     ;; https://julialang.org/downloads/#supported_platforms
     (supported-systems '("i686-linux" "x86_64-linux" "aarch64-linux"))
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index fd2e815fe0..671aee059e 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2016, 2018 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
-;;; Copyright © 2015, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015, 2017-2021, 2024 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
 ;;; Copyright © 2016, 2018, 2019, 2020, 2021, 2023 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
@@ -2264,22 +2264,36 @@ (define-public wllvm
 LLVM bitcode files.")
     (license license:expat)))
 
-(define-public llvm-julia
+(define-public llvm-14-julia
   (package
-    (inherit llvm-13)
+    (inherit llvm-14)
+    (version "14.0.6-3-julia")
+    (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference (url "https://github.com/JuliaLang/llvm-project")
+                            (commit "julia-14.0.6-3")))
+        (file-name (git-file-name "llvm-project-julia" "14.0.6-3"))
+        (sha256
+          (base32
+            "16ynl9g4paksvglk6asfxdr15gy21bzvsjdkqb1msbcnkz2x610x"))))
     (arguments
-     (substitute-keyword-arguments (package-arguments llvm-13)
-       ((#:configure-flags flags ''())
+     (substitute-keyword-arguments (package-arguments llvm-14)
+       ((#:configure-flags flags
+         ''())
+        ; FIXME: I think we should basically duplicate
+        ; https://github.com/JuliaLang/julia/blob/master/deps/llvm.mk
         #~(cons* "-DLLVM_BUILD_LLVM_DYLIB=ON"
                  "-DLLVM_LINK_LLVM_DYLIB=ON"
-                 ;; "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=NVPTX"
-                 "-DLLVM_VERSION_SUFFIX:STRING=jl"  ; Perhaps not needed.
-                 #$(string-append "-DLLVM_TARGETS_TO_BUILD="
+                 "-DLLVM_SHLIB_SYMBOL_VERSION:STRING=JL_LLVM_14.0"
+                 "-DLLVM_VERSION_SUFFIX:STRING=jl" ;Perhaps not needed.
+                 #$(string-append "-DLLVM_TARGETS_TO_BUILD=NVPTX;AMDGPU;"
                                   (system->llvm-target))
-                 (delete "-DBUILD_SHARED_LIBS:BOOL=TRUE" #$flags)))
-       ((#:build-type _) "Release")))
-    (properties `((hidden? . #t)
-                  ,@(package-properties llvm-13)))))
+                 (delete "-DBUILD_SHARED_LIBS:BOOL=TRUE"
+                         #$flags)))
+       ((#:build-type _)
+        "Release")))
+    (properties `((hidden? . #t) ,@(package-properties llvm-14)))))
 
 (define llvm-cling
   ;; To determine which version of LLVM a given release of Cling should use,
diff --git a/gnu/packages/patches/julia-1.9-build-tweaks.patch b/gnu/packages/patches/julia-1.9-build-tweaks.patch
new file mode 100644
index 0000000000..25f220b012
--- /dev/null
+++ b/gnu/packages/patches/julia-1.9-build-tweaks.patch
@@ -0,0 +1,152 @@
+Adjust the Julia 1.9 build system to unbundle libraries and otherwise fix things
+here and there.
+
+diff --git a/Make.inc b/Make.inc
+index 5bbb52617a..7e1215a2de 100644
+--- a/Make.inc
++++ b/Make.inc
+@@ -40,33 +40,39 @@ OPENBLAS_USE_THREAD:=1
+ # Flags for using libraries available on the system instead of building them.
+ # Please read the notes around usage of SYSTEM flags in README.md
+ # Issues resulting from use of SYSTEM versions will generally not be accepted.
+-USE_SYSTEM_CSL:=0
+-USE_SYSTEM_LLVM:=0
+-USE_SYSTEM_LIBUNWIND:=0
++USE_SYSTEM_CSL:=1
++USE_SYSTEM_LLVM:=1
++USE_SYSTEM_LIBUNWIND:=1
+ DISABLE_LIBUNWIND:=0
+-USE_SYSTEM_PCRE:=0
++USE_SYSTEM_PCRE:=1
+ USE_SYSTEM_LIBM:=0
+-USE_SYSTEM_OPENLIBM:=0
++USE_SYSTEM_OPENLIBM:=1
+ UNTRUSTED_SYSTEM_LIBM:=0
+-USE_SYSTEM_DSFMT:=0
+-USE_SYSTEM_LIBBLASTRAMPOLINE:=0
+-USE_SYSTEM_BLAS:=0
+-USE_SYSTEM_LAPACK:=0
+-USE_SYSTEM_GMP:=0
+-USE_SYSTEM_MPFR:=0
+-USE_SYSTEM_LIBSUITESPARSE:=0
+-USE_SYSTEM_LIBUV:=0
+-USE_SYSTEM_UTF8PROC:=0
+-USE_SYSTEM_MBEDTLS:=0
+-USE_SYSTEM_LIBSSH2:=0
+-USE_SYSTEM_NGHTTP2:=0
+-USE_SYSTEM_CURL:=0
+-USE_SYSTEM_LIBGIT2:=0
+-USE_SYSTEM_PATCHELF:=0
+-USE_SYSTEM_LIBWHICH:=0
+-USE_SYSTEM_ZLIB:=0
+-USE_SYSTEM_P7ZIP:=0
+-USE_SYSTEM_LLD:=0
++USE_SYSTEM_DSFMT:=1
++USE_SYSTEM_LIBBLASTRAMPOLINE:=1
++USE_SYSTEM_BLAS:=1
++USE_SYSTEM_LAPACK:=1
++USE_SYSTEM_GMP:=1
++USE_SYSTEM_MPFR:=1
++USE_SYSTEM_LIBSUITESPARSE:=1
++USE_SYSTEM_LIBUV:=1
++USE_SYSTEM_UTF8PROC:=1
++USE_SYSTEM_MBEDTLS:=1
++USE_SYSTEM_LIBSSH2:=1
++USE_SYSTEM_NGHTTP2:=1
++USE_SYSTEM_CURL:=1
++USE_SYSTEM_LIBGIT2:=1
++USE_SYSTEM_PATCHELF:=1
++USE_SYSTEM_LIBWHICH:=1
++USE_SYSTEM_ZLIB:=1
++USE_SYSTEM_P7ZIP:=1
++USE_SYSTEM_LLD:=1
++
++# Guix override
++USE_INTEL_JITEVENTS:=0
++USE_PERF_JITEVENTS:=0
++USE_BINARYBUILDER:=0
++
+ 
+ # Link to the LLVM shared library
+ USE_LLVM_SHLIB := 1
+@@ -1124,7 +1130,8 @@ else
+ endif
+ 
+ ifeq ($(USE_SYSTEM_UTF8PROC), 1)
+-  LIBUTF8PROC := -lutf8proc
++  # Point to the static lib in Guix
++  LIBUTF8PROC := GUIX_LIBUTF8PROC
+   UTF8PROC_INC := $(LOCALBASE)/include
+ else
+   LIBUTF8PROC := $(build_libdir)/libutf8proc.a
+diff --git a/Makefile b/Makefile
+index ef0ade09e2..6b9177df60 100644
+--- a/Makefile
++++ b/Makefile
+@@ -11,7 +11,8 @@ all: debug release
+ # sort is used to remove potential duplicates
+ DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_private_libdir) $(build_libexecdir) $(build_includedir) $(build_includedir)/julia $(build_sysconfdir)/julia $(build_datarootdir)/julia $(build_datarootdir)/julia/stdlib $(build_man1dir))
+ ifneq ($(BUILDROOT),$(JULIAHOME))
+-BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/flisp src/support src/clangsa cli doc deps stdlib test test/clangsa test/embedding test/gcext test/llvmpasses)
++# FIXME: do not build doc yet
++BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/flisp src/support src/clangsa cli deps stdlib test test/clangsa test/embedding test/gcext test/llvmpasses)
+ BUILDDIRMAKE := $(addsuffix /Makefile,$(BUILDDIRS)) $(BUILDROOT)/sysimage.mk
+ DIRS := $(DIRS) $(BUILDDIRS)
+ $(BUILDDIRMAKE): | $(BUILDDIRS)
+@@ -64,6 +65,16 @@ julia-deps: | $(DIRS) $(build_datarootdir)/julia/base $(build_datarootdir)/julia
+ # `julia-stdlib` depends on `julia-deps` so that the fake JLL stdlibs can copy in their Artifacts.toml files.
+ julia-stdlib: | $(DIRS) julia-deps
+ 	@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/stdlib
++	# These files are checked-out during the build phase, but need to be fixed
++	# before the actual build, therefore we sed with a variable we'll fix before
++	# the build phase. It's twisted but it's the only working way I could find.
++	# The " are important to avoid double substitution when doing 'make' then
++	# 'make check'.
++	sed -i 's|"libcholmod"|"GUIX_LIBCHOLMOD"|' usr/share/julia/stdlib/v1.9/SparseArrays/src/solvers/cholmod.jl
++	sed -i 's|:libsuitesparseconfig|"GUIX_LIBSC"|' usr/share/julia/stdlib/v1.9/SparseArrays/src/solvers/cholmod.jl
++	sed -i 's|:libcholmod|"GUIX_LIBCHOLMOD"|' usr/share/julia/stdlib/v1.9/SparseArrays/src/solvers/LibSuiteSparse.jl
++	sed -i 's|:libspqr|"GUIX_LIBSPQR"|' usr/share/julia/stdlib/v1.9/SparseArrays/src/solvers/LibSuiteSparse.jl
++	sed -i 's|:libumfpack|"GUIX_LIBUMFPACK"|' usr/share/julia/stdlib/v1.9/SparseArrays/src/solvers/LibSuiteSparse.jl
+ 
+ julia-base: julia-deps $(build_sysconfdir)/julia/startup.jl $(build_man1dir)/julia.1 $(build_datarootdir)/julia/julia-config.jl
+ 	@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/base
+@@ -236,7 +247,9 @@ define stringreplace
+ endef
+ 
+ 
+-install: $(build_depsbindir)/stringreplace $(BUILDROOT)/doc/_build/html/en/index.html
++# Guix FIXME: building the doc requires internet. We should build them in a
++# separate build phase.
++install: $(build_depsbindir)/stringreplace # $(BUILDROOT)/doc/_build/html/en/index.html
+ 	@$(MAKE) $(QUIET_MAKE) $(JULIA_BUILD_MODE)
+ 	@for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir) $(private_libexecdir); do \
+ 		mkdir -p $(DESTDIR)$$subdir; \
+diff --git a/base/Makefile b/base/Makefile
+index 0ea0359c8c..9cee86aeec 100644
+--- a/base/Makefile
++++ b/base/Makefile
+@@ -239,7 +239,10 @@ endif
+ ifneq (,$(LIBGFORTRAN_VERSION))
+ $(eval $(call symlink_system_library,CSL,libgfortran,$(LIBGFORTRAN_VERSION)))
+ endif
+-$(eval $(call symlink_system_library,CSL,libquadmath,0))
++
++# libquadmath is not available on all architectures.
++# https://github.com/JuliaLang/julia/issues/41613
++$(eval $(call symlink_system_library,CSL,libquadmath,0,ALLOW_FAILURE))
+ $(eval $(call symlink_system_library,CSL,libstdc++,6))
+ # We allow libssp, libatomic and libgomp to fail as they are not available on all systems
+ $(eval $(call symlink_system_library,CSL,libssp,0,ALLOW_FAILURE))
+diff --git a/cli/Makefile b/cli/Makefile
+index 7ba238e0de..6540f6384a 100644
+--- a/cli/Makefile
++++ b/cli/Makefile
+@@ -7,7 +7,7 @@ include $(JULIAHOME)/deps/llvm-ver.make
+ 
+ HEADERS := $(addprefix $(SRCDIR)/,jl_exports.h loader.h) $(addprefix $(JULIAHOME)/src/,julia_fasttls.h support/platform.h support/dirpath.h jl_exported_data.inc jl_exported_funcs.inc)
+ 
+-LOADER_CFLAGS = $(JCFLAGS) -I$(BUILDROOT)/src -I$(JULIAHOME)/src -I$(JULIAHOME)/src/support -I$(build_includedir) -ffreestanding
++LOADER_CFLAGS = -D_GNU_SOURCE $(JCFLAGS) -I$(BUILDROOT)/src -I$(JULIAHOME)/src -I$(JULIAHOME)/src/support -I$(build_includedir) -ffreestanding
+ LOADER_LDFLAGS = $(JLDFLAGS) -ffreestanding -L$(build_shlibdir) -L$(build_libdir)
+ 
+ ifeq ($(OS),WINNT)
diff --git a/gnu/packages/patches/julia-Use-MPFR-4.2.patch b/gnu/packages/patches/julia-Use-MPFR-4.2.patch
deleted file mode 100644
index 73a395c89e..0000000000
--- a/gnu/packages/patches/julia-Use-MPFR-4.2.patch
+++ /dev/null
@@ -1,228 +0,0 @@
-This patch backports part of Julia upstream commit:
-
-    1e5fdb29f8858f3244f6aff116ee12e4c8247f3a
-    Author:     Simon Byrne <simon.byrne@gmail.com>
-    AuthorDate: Tue Jan 10 14:52:36 2023 -0800
-    Commit:     GitHub <noreply@github.com>
-    CommitDate: Tue Jan 10 17:52:36 2023 -0500
-
-    update MPFR to 4.2.0 (#48165)
-
-    Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
-
-    6 files changed, 112 insertions(+), 79 deletions(-)
-    base/mpfr.jl                     | 34 ++++++++++++++--
-    deps/checksums/mpfr              | 68 ++++++++++++++++----------------
-    deps/mpfr.version                |  2 +-
-    stdlib/MPFR_jll/Project.toml     |  2 +-
-    stdlib/MPFR_jll/test/runtests.jl |  2 +-
-    test/math.jl                     | 83 +++++++++++++++++++++-------------------
-
-
-diff -ur julia-1.8.3-orig/base/mpfr.jl julia-1.8.3-patch/base/mpfr.jl
---- julia-1.8.3-orig/base/mpfr.jl	2023-04-13 17:50:58.394891391 +0200
-+++ julia-1.8.3-patch/base/mpfr.jl	2023-04-13 20:42:52.551833467 +0200
-@@ -16,7 +16,8 @@
-         cosh, sinh, tanh, sech, csch, coth, acosh, asinh, atanh, lerpi,
-         cbrt, typemax, typemin, unsafe_trunc, floatmin, floatmax, rounding,
-         setrounding, maxintfloat, widen, significand, frexp, tryparse, iszero,
--        isone, big, _string_n, decompose
-+        isone, big, _string_n, decompose, minmax,
-+        sinpi, cospi, sincospi, sind, cosd, tand, asind, acosd, atand
- 
- import ..Rounding: rounding_raw, setrounding_raw
- 
-@@ -745,7 +746,7 @@
- end
- 
- # Functions for which NaN results are converted to DomainError, following Base
--for f in (:sin, :cos, :tan, :sec, :csc, :acos, :asin, :atan, :acosh, :asinh, :atanh)
-+for f in (:sin, :cos, :tan, :sec, :csc, :acos, :asin, :atan, :acosh, :asinh, :atanh, :sinpi, :cospi)
-     @eval begin
-         function ($f)(x::BigFloat)
-             isnan(x) && return x
-@@ -756,6 +757,7 @@
-         end
-     end
- end
-+sincospi(x::BigFloat) = (sinpi(x), cospi(x))
- 
- function atan(y::BigFloat, x::BigFloat)
-     z = BigFloat()
-@@ -763,6 +765,32 @@
-     return z
- end
- 
-+# degree functions
-+for f in (:sin, :cos, :tan)
-+    @eval begin
-+        function ($(Symbol(f,:d)))(x::BigFloat)
-+            isnan(x) && return x
-+            z = BigFloat()
-+            ccall(($(string(:mpfr_,f,:u)), :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Culong, MPFRRoundingMode), z, x, 360, ROUNDING_MODE[])
-+            isnan(z) && throw(DomainError(x, "NaN result for non-NaN input."))
-+            return z
-+        end
-+        function ($(Symbol(:a,f,:d)))(x::BigFloat)
-+            isnan(x) && return x
-+            z = BigFloat()
-+            ccall(($(string(:mpfr_a,f,:u)), :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Culong, MPFRRoundingMode), z, x, 360, ROUNDING_MODE[])
-+            isnan(z) && throw(DomainError(x, "NaN result for non-NaN input."))
-+            return z
-+        end
-+    end
-+end
-+function atand(y::BigFloat, x::BigFloat)
-+    z = BigFloat()
-+    ccall((:mpfr_atan2u, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Ref{BigFloat}, Culong, MPFRRoundingMode), z, y, x, 360, ROUNDING_MODE[])
-+    return z
-+end
-+
-+
- # Utility functions
- ==(x::BigFloat, y::BigFloat) = ccall((:mpfr_equal_p, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}), x, y) != 0
- <=(x::BigFloat, y::BigFloat) = ccall((:mpfr_lessequal_p, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}), x, y) != 0
-@@ -1018,7 +1046,7 @@
-     isfinite(x) || return string(Float64(x))
-     _prettify_bigfloat(string_mpfr(x, fmt))
- end
--_string(x::BigFloat) = _string(x, "%.Re")
-+_string(x::BigFloat) = _string(x, "%Re")
- _string(x::BigFloat, k::Integer) = _string(x, "%.$(k)Re")
- 
- string(b::BigFloat) = _string(b)
-diff -ur julia-1.8.3-orig/test/math.jl julia-1.8.3-patch/test/math.jl
---- julia-1.8.3-orig/test/math.jl	2023-04-13 17:50:58.382891276 +0200
-+++ julia-1.8.3-patch/test/math.jl	2023-04-13 21:13:55.377279761 +0200
-@@ -411,47 +411,51 @@
-     @test rad2deg(pi + (pi/3)*im) ≈ 180 + 60im
- end
- 
-+# ensure zeros are signed the same
-+⩲(x,y) = typeof(x) == typeof(y) && x == y && signbit(x) == signbit(y)
-+⩲(x::Tuple, y::Tuple) = length(x) == length(y) && all(map(⩲,x,y))
-+
- @testset "degree-based trig functions" begin
--    @testset "$T" for T = (Float32,Float64,Rational{Int})
-+    @testset "$T" for T = (Float32,Float64,Rational{Int},BigFloat)
-         fT = typeof(float(one(T)))
-         fTsc = typeof( (float(one(T)), float(one(T))) )
-         for x = -400:40:400
--            @test sind(convert(T,x))::fT ≈ convert(fT,sin(pi/180*x)) atol=eps(deg2rad(convert(fT,x)))
--            @test cosd(convert(T,x))::fT ≈ convert(fT,cos(pi/180*x)) atol=eps(deg2rad(convert(fT,x)))
-+            @test sind(convert(T,x))::fT ≈ sin(pi*convert(fT,x)/180) atol=eps(deg2rad(convert(fT,x)))
-+            @test cosd(convert(T,x))::fT ≈ cos(pi*convert(fT,x)/180) atol=eps(deg2rad(convert(fT,x)))
- 
-             s,c = sincosd(convert(T,x))
--            @test s::fT ≈ convert(fT,sin(pi/180*x)) atol=eps(deg2rad(convert(fT,x)))
--            @test c::fT ≈ convert(fT,cos(pi/180*x)) atol=eps(deg2rad(convert(fT,x)))
-+            @test s::fT ≈ sin(pi*convert(fT,x)/180) atol=eps(deg2rad(convert(fT,x)))
-+            @test c::fT ≈ cos(pi*convert(fT,x)/180) atol=eps(deg2rad(convert(fT,x)))
-         end
-         @testset "sind" begin
--            @test sind(convert(T,0.0))::fT === zero(fT)
--            @test sind(convert(T,180.0))::fT === zero(fT)
--            @test sind(convert(T,360.0))::fT === zero(fT)
--            T != Rational{Int} && @test sind(convert(T,-0.0))::fT === -zero(fT)
--            @test sind(convert(T,-180.0))::fT === -zero(fT)
--            @test sind(convert(T,-360.0))::fT === -zero(fT)
-+            @test sind(convert(T,0.0))::fT ⩲ zero(fT)
-+            @test sind(convert(T,180.0))::fT ⩲ zero(fT)
-+            @test sind(convert(T,360.0))::fT ⩲ zero(fT)
-+            T != Rational{Int} && @test sind(convert(T,-0.0))::fT ⩲ -zero(fT)
-+            @test sind(convert(T,-180.0))::fT ⩲ -zero(fT)
-+            @test sind(convert(T,-360.0))::fT ⩲ -zero(fT)
-             if T <: AbstractFloat
-                 @test isnan(sind(T(NaN)))
-             end
-         end
-         @testset "cosd" begin
--            @test cosd(convert(T,90))::fT === zero(fT)
--            @test cosd(convert(T,270))::fT === zero(fT)
--            @test cosd(convert(T,-90))::fT === zero(fT)
--            @test cosd(convert(T,-270))::fT === zero(fT)
-+            @test cosd(convert(T,90))::fT ⩲ zero(fT)
-+            @test cosd(convert(T,270))::fT ⩲ zero(fT)
-+            @test cosd(convert(T,-90))::fT ⩲ zero(fT)
-+            @test cosd(convert(T,-270))::fT ⩲ zero(fT)
-             if T <: AbstractFloat
-                 @test isnan(cosd(T(NaN)))
-             end
-         end
-         @testset "sincosd" begin
--            @test sincosd(convert(T,-360))::fTsc === ( -zero(fT),  one(fT) )
--            @test sincosd(convert(T,-270))::fTsc === (   one(fT), zero(fT) )
--            @test sincosd(convert(T,-180))::fTsc === ( -zero(fT), -one(fT) )
--            @test sincosd(convert(T, -90))::fTsc === (  -one(fT), zero(fT) )
--            @test sincosd(convert(T,   0))::fTsc === (  zero(fT),  one(fT) )
--            @test sincosd(convert(T,  90))::fTsc === (   one(fT), zero(fT) )
--            @test sincosd(convert(T, 180))::fTsc === (  zero(fT), -one(fT) )
--            @test sincosd(convert(T, 270))::fTsc === (  -one(fT), zero(fT) )
-+            @test sincosd(convert(T,-360))::fTsc ⩲ ( -zero(fT),  one(fT) )
-+            @test sincosd(convert(T,-270))::fTsc ⩲ (   one(fT), zero(fT) )
-+            @test sincosd(convert(T,-180))::fTsc ⩲ ( -zero(fT), -one(fT) )
-+            @test sincosd(convert(T, -90))::fTsc ⩲ (  -one(fT), zero(fT) )
-+            @test sincosd(convert(T,   0))::fTsc ⩲ (  zero(fT),  one(fT) )
-+            @test sincosd(convert(T,  90))::fTsc ⩲ (   one(fT), zero(fT) )
-+            @test sincosd(convert(T, 180))::fTsc ⩲ (  zero(fT), -one(fT) )
-+            @test sincosd(convert(T, 270))::fTsc ⩲ (  -one(fT), zero(fT) )
-             if T <: AbstractFloat
-                 @test_throws DomainError sincosd(T(Inf))
-                 @test all(isnan.(sincosd(T(NaN))))
-@@ -463,22 +467,22 @@
-             "sincospi" => (x->sincospi(x)[1], x->sincospi(x)[2])
-         )
-             @testset "pi * $x" for x = -3:0.3:3
--                @test sinpi(convert(T,x))::fT ≈ convert(fT,sin(pi*x)) atol=eps(pi*convert(fT,x))
--                @test cospi(convert(T,x))::fT ≈ convert(fT,cos(pi*x)) atol=eps(pi*convert(fT,x))
-+                @test sinpi(convert(T,x))::fT ≈ sin(pi*convert(fT,x)) atol=eps(pi*convert(fT,x))
-+                @test cospi(convert(T,x))::fT ≈ cos(pi*convert(fT,x)) atol=eps(pi*convert(fT,x))
-             end
- 
--            @test sinpi(convert(T,0.0))::fT === zero(fT)
--            @test sinpi(convert(T,1.0))::fT === zero(fT)
--            @test sinpi(convert(T,2.0))::fT === zero(fT)
--            T != Rational{Int} && @test sinpi(convert(T,-0.0))::fT === -zero(fT)
--            @test sinpi(convert(T,-1.0))::fT === -zero(fT)
--            @test sinpi(convert(T,-2.0))::fT === -zero(fT)
-+            @test sinpi(convert(T,0.0))::fT ⩲ zero(fT)
-+            @test sinpi(convert(T,1.0))::fT ⩲ zero(fT)
-+            @test sinpi(convert(T,2.0))::fT ⩲ zero(fT)
-+            T != Rational{Int} && @test sinpi(convert(T,-0.0))::fT ⩲ -zero(fT)
-+            @test sinpi(convert(T,-1.0))::fT ⩲ -zero(fT)
-+            @test sinpi(convert(T,-2.0))::fT ⩲ -zero(fT)
-             @test_throws DomainError sinpi(convert(T,Inf))
- 
--            @test cospi(convert(T,0.5))::fT === zero(fT)
--            @test cospi(convert(T,1.5))::fT === zero(fT)
--            @test cospi(convert(T,-0.5))::fT === zero(fT)
--            @test cospi(convert(T,-1.5))::fT === zero(fT)
-+            @test cospi(convert(T,0.5))::fT ⩲ zero(fT)
-+            @test cospi(convert(T,1.5))::fT ⩲ zero(fT)
-+            @test cospi(convert(T,-0.5))::fT ⩲ zero(fT)
-+            @test cospi(convert(T,-1.5))::fT ⩲ zero(fT)
-             @test_throws DomainError cospi(convert(T,Inf))
-         end
-         @testset "Check exact values" begin
-@@ -489,8 +493,8 @@
-             @test sincospi(one(T)/convert(T,6))[1] == 0.5
-             @test_throws DomainError sind(convert(T,Inf))
-             @test_throws DomainError cosd(convert(T,Inf))
--            T != Float32 && @test cospi(one(T)/convert(T,3)) == 0.5
--            T != Float32 && @test sincospi(one(T)/convert(T,3))[2] == 0.5
-+            fT == Float64 && @test isapprox(cospi(one(T)/convert(T,3)), 0.5)
-+            fT == Float64 && @test isapprox(sincospi(one(T)/convert(T,3))[2], 0.5)
-             T == Rational{Int} && @test sinpi(5//6) == 0.5
-             T == Rational{Int} && @test sincospi(5//6)[1] == 0.5
-         end
-@@ -538,8 +542,8 @@
-             end
-         end
-     end
--    @test @inferred(sinc(0//1)) === 1.0
--    @test @inferred(cosc(0//1)) === -0.0
-+    @test @inferred(sinc(0//1)) ⩲ 1.0
-+    @test @inferred(cosc(0//1)) ⩲ -0.0
- 
-     # test right before/after thresholds of Taylor series
-     @test sinc(0.001) ≈ 0.999998355066745 rtol=1e-15
