diff mbox series

[bug#65317,1/1] gnu: Add go-1.21.

Message ID 20230815195313.46418-1-cox.katherine.e@gmail.com
State New
Headers show
Series [bug#65317,1/1] gnu: Add go-1.21. | expand

Commit Message

Katherine Cox-Buday Aug. 15, 2023, 7:53 p.m. UTC
* gnu/packages/golang.scm (go-1.21): New variable.
---
 gnu/packages/golang.scm | 83 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)


base-commit: a4bed14c438dc0cbc1c1885a38f8409c7fef7957

Comments

Katherine Cox-Buday Aug. 15, 2023, 10:03 p.m. UTC | #1
It looks like as written this suffers from 
https://github.com/golang/go/issues/61921 (relevant code here: 
https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/golang.scm?h=master#n671). 
I'm trying to figure out what the correct course of action is for Guix.
John Kehayias Dec. 31, 2023, 8:45 p.m. UTC | #2
Hi all,

On Wed, Nov 22, 2023 at 09:21 PM, VÖRÖSKŐI András wrote:

> From: Katherine Cox-Buday <cox.katherine.e@gmail.com>
>
> * gnu/packages/golang.scm (go-1.21): New variable.
>

Thanks for your patience and hard work here Katherine! I'm no expert on
go but the packaging (and helpful comments!) looked good to me and it
built and ran locally. I just did a minor reformatting of a comment or
two and (finally!) pushed as 37c33eb0d4f0baecd5f7c7b251b32f78fcfa6641

Thanks again!

> Change-Id: I7c06319c3a8a39c4d6d08964d5e1b848827f6ea0
> ---
>
> Just updated to 1.21.4 and added std definition
>

I split off the adding of the standard library as
c314115dd054c000116dfc4a75df8e1a5e56e715 and gave a co-author line to
András, thanks for the contribution!

While I saw go has 1.21.5 and so I tested that it built locally and
pushed that update as 19f5302d136783d861b42107ae5e2920bbd769d9.

Thanks again everyone!

John
diff mbox series

Patch

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 5a53838435..bd2fc4d5d5 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -967,6 +967,89 @@  (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\")"))))))))))
+
 (define-public go go-1.17)
 
 (define make-go-std