all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Katherine Cox-Buday <cox.katherine.e@gmail.com>
To: 65317@debbugs.gnu.org
Cc: Katherine Cox-Buday <cox.katherine.e@gmail.com>
Subject: [bug#65317] [PATCH v2 1/1] gnu: Add go-1.21.
Date: Tue, 15 Aug 2023 17:20:40 -0600	[thread overview]
Message-ID: <20230815232142.79498-1-cox.katherine.e@gmail.com> (raw)
In-Reply-To: <20230815195313.46418-1-cox.katherine.e@gmail.com>

* gnu/packages/golang.scm (go-1.21): New variable.
---
 gnu/packages/golang.scm | 132 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 132 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 5a53838435..26022ea211 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -967,6 +967,138 @@ (define-public go-1.20
      ;; https://go.dev/issue/44505
      (alist-replace "go" (list go-1.17) (package-native-inputs go-1.17)))))
 
+(define-public go-1.21
+  (package
+    (inherit go-1.20)
+    (name "go")
+    (version "1.21.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/golang/go")
+                    (commit (string-append "go" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "04cpahl10i1sncymdfm0vzcj3czv6lv0axwa1sisl9cz3rdrp7hj"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments go-1.20)
+       ;; Source patching phases are broken up into discrete steps to allow
+       ;; future versions to discard individual phases without having to
+       ;; discard all source patching.
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            (delete 'skip-TestGoPathShlibGccgo-tests)
+            (delete 'patch-source)
+            (add-after 'unpack 'patch-os-tests
+              (lambda _
+                (substitute* "src/os/os_test.go"
+                  (("/usr/bin") (getcwd))
+                  (("/bin/sh") (which "sh")))))
+
+            (add-after 'unpack 'apply-patches
+              (lambda* (#:key inputs #:allow-other-keys)
+                ;; Having the patch in the 'patches' field of <origin> breaks
+                ;; the 'TestServeContent' test due to the fact that
+                ;; timestamps are reset.  Thus, apply it from here.
+                (invoke "patch" "-p1" "--force" "-i"
+                        (assoc-ref inputs "go-fix-script-tests.patch"))))
+
+            (add-after 'unpack 'patch-src/net
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let ((net-base (assoc-ref inputs "net-base")))
+                  (substitute* "src/net/lookup_unix.go"
+                    (("/etc/protocols")
+                     (string-append net-base "/etc/protocols")))
+                  (substitute* "src/net/port_unix.go"
+                    (("/etc/services")
+                     (string-append net-base "/etc/services"))))))
+
+            (add-after 'unpack 'patch-zoneinfo
+              (lambda* (#:key inputs #:allow-other-keys)
+                ;; Add the path to this specific version of tzdata's zoneinfo
+                ;; file to the top of the list to search. We don't want to
+                ;; replace any sources because it will affect how binaries
+                ;; compiled with this Go toolchain behave on non-guix
+                ;; platforms.
+                (substitute* "src/time/zoneinfo_unix.go"
+                  (("var platformZoneSources.+" all)
+                   (format #f "~a~%\"~a/share/zoneinfo\",~%"
+                           all
+                           (assoc-ref inputs "tzdata"))))))
+
+            (add-after 'unpack 'patch-cmd/go/testdata/script
+              (lambda _
+                (substitute* "src/cmd/go/testdata/script/cgo_path_space.txt"
+                  (("/bin/sh") (which "sh")))))
+
+            (add-after 'enable-external-linking 'enable-external-linking-1.21
+              (lambda _
+                ;; Invoke GCC to link any archives created with GCC (that is, any
+                ;; packages built using 'cgo'), because Go doesn't know how to
+                ;; handle the runpaths but GCC does.  Use substitute* rather than
+                ;; a patch since these files are liable to change often.
+                ;;
+                ;; XXX: Replace with GO_EXTLINK_ENABLED=1 or similar when
+                ;; <https://github.com/golang/go/issues/31544> and/or
+                ;; <https://github.com/golang/go/issues/43525> are resolved.
+                (substitute* "src/cmd/link/internal/ld/config.go"
+                  (("\\(iscgo && \\(.+\\)") "iscgo"))
+                (substitute* "src/internal/testenv/testenv.go"
+                  (("!CanInternalLink.+") "true {\n"))
+                (substitute* "src/syscall/exec_linux_test.go"
+                  (("testenv.MustHaveExecPath\\(t, \"whoami\"\\)")
+                   "t.Skipf(\"no passwd file present\")"))))
+
+            (replace 'install
+              (lambda* (#:key outputs #:allow-other-keys)
+                ;; Notably, we do not install archives (180M), which Go will
+                ;; happily recompile quickly (and cache) if needed, almost
+                ;; surely faster than they could be substituted.
+                ;;
+                ;; The main motivation for pre-compiled archives is to use
+                ;; libc-linked `net' or `os' packages without a C compiler,
+                ;; but on Guix a C compiler is necessary to properly link the
+                ;; final binaries anyway.  Many build flags also invalidate
+                ;; these pre-compiled archives, so in practice Go often
+                ;; recompiles them anyway.
+                ;;
+                ;; Upstream is also planning to no longer install these
+                ;; archives: <https://github.com/golang/go/issues/47257>
+                ;;
+                ;; When necessary, a custom pre-compiled library package can
+                ;; be created with `#:import-path "std"' and used with
+                ;; `-pkgdir'.
+                ;;
+                ;; When moving files into place, any files that come from
+                ;; GOROOT should remain in GOROOT to continue functioning. If
+                ;; they need to be referenced from some other directory, they
+                ;; need to be symlinked from GOROOT. For more information,
+                ;; please see https://github.com/golang/go/issues/61921
+                (let* ((out (assoc-ref outputs "out"))
+                       (tests (assoc-ref outputs "tests")))
+                  (for-each
+                   (lambda (file)
+                     (copy-recursively file (string-append out "/lib/go/" file)))
+                   '("bin" "lib" "VERSION" "pkg/include" "pkg/tool"))
+
+                  (symlink "lib/go/bin" (string-append out "/bin"))
+
+                  (for-each
+                   (match-lambda
+                     ((file dest output)
+                      ;; Copy to output/dest and symlink from output/lib/go/file.
+                      (let ((file* (string-append output "/lib/go/" file))
+                            (dest* (string-append output "/" dest)))
+                        (copy-recursively file dest*)
+                        (mkdir-p (dirname file*))
+                        (symlink (string-append "../../" dest) file*))))
+                   `(("src"          "share/go/src"        ,out)
+                     ("misc"         "share/go/misc"       ,out)
+                     ("doc"          "share/doc/go/doc"    ,out)
+                     ("api"          "share/go/api"        ,tests)
+                     ("test"         "share/go/test"       ,tests))))))))))))
+
 (define-public go go-1.17)
 
 (define make-go-std

base-commit: a4bed14c438dc0cbc1c1885a38f8409c7fef7957
-- 
2.41.0





  parent reply	other threads:[~2023-08-15 23:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15 19:53 [bug#65317] [PATCH 1/1] gnu: Add go-1.21 Katherine Cox-Buday
     [not found] ` <handler.65317.B.16921292097969.ack@debbugs.gnu.org>
2023-08-15 22:03   ` [bug#65317] Acknowledgement ([PATCH 1/1] gnu: Add go-1.21.) Katherine Cox-Buday
2023-08-15 23:20 ` Katherine Cox-Buday [this message]
2023-08-15 23:29   ` [bug#65317] [PATCH v2 1/1] gnu: Add go-1.21 Katherine Cox-Buday
2023-08-17 19:40   ` Katherine Cox-Buday
2023-08-17 19:43 ` [bug#65317] [PATCH v3 " Katherine Cox-Buday
2023-11-13 12:05   ` Mekeor Melire
2023-11-22 20:21 ` [bug#65317] [PATCH] " VÖRÖSKŐI András
2023-12-31 20:45 ` bug#65317: " John Kehayias via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230815232142.79498-1-cox.katherine.e@gmail.com \
    --to=cox.katherine.e@gmail.com \
    --cc=65317@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.