GNU bug report logs - #65317
[PATCH 1/1] gnu: Add go-1.21.

Previous Next

Package: guix-patches;

Reported by: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>

Date: Tue, 15 Aug 2023 19:54:01 UTC

Severity: normal

Tags: moreinfo, patch

Done: John Kehayias <john.kehayias <at> protonmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 65317 in the body.
You can then email your comments to 65317 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#65317; Package guix-patches. (Tue, 15 Aug 2023 19:54:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Katherine Cox-Buday <cox.katherine.e <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 15 Aug 2023 19:54:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
Subject: [PATCH 1/1] gnu: Add go-1.21.
Date: Tue, 15 Aug 2023 13:53:04 -0600
* gnu/packages/golang.scm (go-1.21): New variable.
---
 gnu/packages/golang.scm | 83 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)

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

base-commit: a4bed14c438dc0cbc1c1885a38f8409c7fef7957
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#65317; Package guix-patches. (Tue, 15 Aug 2023 22:04:01 GMT) Full text and rfc822 format available.

Message #8 received at 65317 <at> debbugs.gnu.org (full text, mbox):

From: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
To: 65317 <at> debbugs.gnu.org
Subject: Re: bug#65317: Acknowledgement ([PATCH 1/1] gnu: Add go-1.21.)
Date: Tue, 15 Aug 2023 16:03:13 -0600
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.





Information forwarded to guix-patches <at> gnu.org:
bug#65317; Package guix-patches. (Tue, 15 Aug 2023 23:22:01 GMT) Full text and rfc822 format available.

Message #11 received at 65317 <at> debbugs.gnu.org (full text, mbox):

From: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
To: 65317 <at> debbugs.gnu.org
Cc: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
Subject: [PATCH v2 1/1] gnu: Add go-1.21.
Date: Tue, 15 Aug 2023 17:20:40 -0600
* 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





Information forwarded to guix-patches <at> gnu.org:
bug#65317; Package guix-patches. (Tue, 15 Aug 2023 23:30:02 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
To: guix-patches <at> gnu.org
Subject: Re: [bug#65317] [PATCH v2 1/1] gnu: Add go-1.21.
Date: Tue, 15 Aug 2023 17:29:29 -0600
This version solves the problem by reversing the symlinking done during 
install as suggested in https://github.com/golang/go/issues/61921. 
Instead of:

- mv bin $out/bin
- ln -s ../../bin $out/lib/go/bin

we need to do:
- mv bin $out/lib/go/
- ln -s lib/go/bin $out/bin

This is because GOROOT_FINAL no longer has the intended effect and the 
binaries are expecting binaries to be run from GOROOT which is $out/lib/go.





Added tag(s) moreinfo. Request was from Maxim Cournoyer <maxim.cournoyer <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 16 Aug 2023 15:36:01 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#65317; Package guix-patches. (Thu, 17 Aug 2023 19:42:02 GMT) Full text and rfc822 format available.

Message #19 received at 65317 <at> debbugs.gnu.org (full text, mbox):

From: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
To: 65317 <at> debbugs.gnu.org
Subject: Re: [bug#65317] [PATCH v2 1/1] gnu: Add go-1.21.
Date: Thu, 17 Aug 2023 13:40:50 -0600
On 8/15/23 5:20 PM, Katherine Cox-Buday wrote:
> * 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"))
We also need to install go.env here. See 
https://github.com/golang/go/issues/61928.

There is also some new functionality outlined in the GOTOOLCHAIN 
environment variable that we need to consider.

From https://go.dev/doc/toolchain :

"The go command can use its bundled Go toolchain as well as other 
versions that it finds in the local PATH or downloads as needed.
[...]
When GOTOOLCHAIN is set to local, the go command always runs the bundled 
Go toolchain.
[...]
When using GOTOOLCHAIN=auto or GOTOOLCHAIN=<name>+auto, the Go command 
downloads newer toolchains as needed. These toolchains are packaged as 
special modules with module path golang.org/toolchain and version 
v0.0.1-goVERSION.GOOS-GOARCH. Toolchains are downloaded like any other 
module, meaning that toolchain downloads can be proxied by setting 
GOPROXY and have their checksums checked by the Go checksum database. 
Because the specific toolchain used depends on the system’s own default 
toolchain as well as the local operating system and architecture (GOOS 
and GOARCH), it is not practical to write toolchain module checksums to 
go.sum. Instead, toolchain downloads fail for lack of verification if 
GOSUMDB=off. GOPRIVATE and GONOSUMDB patterns do not apply to the 
toolchain downloads."

I think we should leave this set to "auto" for the following reasons:

- The toolchain is now considered part of a module's dependencies, and 
it will be downloaded just like any other dependency.

- This seems to be a major stance the Go project is taking on how things 
work, and if our package doesn't perform these automatic downloads it 
will be surprising/confusing for Go developers.

- Automatic downloads do not pollute the user's path nor do they attempt 
to pollute the store.

- When our packages are built with > 1.21.0, we'll still have 
reproducible builds because any modules requiring a greater versioned 
toolchain will fail to download it due to our isolated build container 
and thus the build will fail and the packager will still have to 
reference the correct version of Go.

More details here: https://go.dev/blog/toolchain

> +
> +                  (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




Information forwarded to guix-patches <at> gnu.org:
bug#65317; Package guix-patches. (Thu, 17 Aug 2023 19:44:01 GMT) Full text and rfc822 format available.

Message #22 received at 65317 <at> debbugs.gnu.org (full text, mbox):

From: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
To: 65317 <at> debbugs.gnu.org
Cc: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
Subject: [PATCH v3 1/1] gnu: Add go-1.21.
Date: Thu, 17 Aug 2023 13:43:18 -0600
* 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..b5f2195ed5 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" "go.env" "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





Information forwarded to guix-patches <at> gnu.org:
bug#65317; Package guix-patches. (Mon, 13 Nov 2023 12:14:01 GMT) Full text and rfc822 format available.

Message #25 received at 65317 <at> debbugs.gnu.org (full text, mbox):

From: Mekeor Melire <mekeor <at> posteo.de>
To: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
Cc: 65317 <at> debbugs.gnu.org
Subject: Re: [bug#65317] [PATCH v3 1/1] gnu: Add go-1.21.
Date: Mon, 13 Nov 2023 12:05:52 +0000
This patch works for me: go-1.21 builds and runs fine. Let's get 
the patch committed!




Information forwarded to cox.katherine.e+guix <at> gmail.com, guix-patches <at> gnu.org:
bug#65317; Package guix-patches. (Wed, 22 Nov 2023 20:25:01 GMT) Full text and rfc822 format available.

Message #28 received at 65317 <at> debbugs.gnu.org (full text, mbox):

From: VÖRÖSKŐI András <voroskoi <at> gmail.com>
To: 65317 <at> debbugs.gnu.org
Cc: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>
Subject: [PATCH] gnu: Add go-1.21.
Date: Wed, 22 Nov 2023 21:21:49 +0100
From: Katherine Cox-Buday <cox.katherine.e <at> gmail.com>

* gnu/packages/golang.scm (go-1.21): New variable.

Change-Id: I7c06319c3a8a39c4d6d08964d5e1b848827f6ea0
---

Just updated to 1.21.4 and added std definition

 gnu/packages/golang.scm | 133 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 133 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 9c707e5414..28d8d3d248 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -969,6 +969,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.4")
+    (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
+                "0xp1mqjbbs53bjg00d4a37af5p1by28xnflj2xi5kchcpmlqn5nz"))))
+    (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" "go.env" "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
@@ -1011,6 +1143,7 @@ (define-public go-std-1.17 (make-go-std go-1.17))
 (define-public go-std-1.18 (make-go-std go-1.18))
 (define-public go-std-1.19 (make-go-std go-1.19))
 (define-public go-std-1.20 (make-go-std go-1.20))
+(define-public go-std-1.21 (make-go-std go-1.21))
 
 (define-public go-0xacab-org-leap-shapeshifter
   (let ((commit "0aa6226582efb8e563540ec1d3c5cfcd19200474")

base-commit: b150c546b04c9ebb09de9f2c39789221054f5eea
-- 
2.41.0





Reply sent to John Kehayias <john.kehayias <at> protonmail.com>:
You have taken responsibility. (Sun, 31 Dec 2023 20:46:02 GMT) Full text and rfc822 format available.

Notification sent to Katherine Cox-Buday <cox.katherine.e <at> gmail.com>:
bug acknowledged by developer. (Sun, 31 Dec 2023 20:46:02 GMT) Full text and rfc822 format available.

Message #33 received at 65317-done <at> debbugs.gnu.org (full text, mbox):

From: John Kehayias <john.kehayias <at> protonmail.com>
To: VÖRÖSKŐI András <voroskoi <at> gmail.com>,
 Katherine Cox-Buday <cox.katherine.e <at> gmail.com>,
 Katherine Cox-Buday <cox.katherine.e+guix <at> gmail.com>
Cc: 65317-done <at> debbugs.gnu.org
Subject: Re: [bug#65317] [PATCH] gnu: Add go-1.21.
Date: Sun, 31 Dec 2023 20:45:20 +0000
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 <at> 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





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 29 Jan 2024 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 100 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.