diff options
Diffstat (limited to 'gnu/packages/golang.scm')
-rw-r--r-- | gnu/packages/golang.scm | 690 |
1 files changed, 342 insertions, 348 deletions
diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm index ed9a32e610..30409de09d 100644 --- a/gnu/packages/golang.scm +++ b/gnu/packages/golang.scm @@ -117,10 +117,6 @@ (guix build utils) (srfi srfi-1)) #:tests? #f ; Tests are run by the all.bash script. - ,@(if (string-prefix? "aarch64-linux" (or (%current-system) - (%current-target-system))) - '(#:system "armhf-linux") - '()) #:phases (modify-phases %standard-phases (delete 'configure) @@ -235,7 +231,7 @@ (inputs `(("tzdata" ,tzdata) ("pcre" ,pcre) - ("gcc:lib" ,(canonical-package gcc) "lib"))) + ("gcc:lib" ,gcc "lib"))) (native-inputs (list pkg-config which net-base perl)) @@ -246,233 +242,9 @@ programming language designed primarily for systems programming. Go is a compiled, statically typed language in the tradition of C and C++, but adds garbage collection, various safety features, and concurrent programming features in the style of communicating sequential processes (@dfn{CSP}).") - (supported-systems '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux")) + (supported-systems '("x86_64-linux" "i686-linux" "armhf-linux")) (license license:bsd-3))) -(define-public go-1.16 - (package - (inherit go-1.4) - (name "go") - (version "1.16.15") - (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 - "0vlk0r4600ah9fg5apdd93g7i369k0rkzcgn7cs8h6qq2k6hpxjl")))) - (arguments - (substitute-keyword-arguments - (strip-keyword-arguments '(#:tests? #:system) (package-arguments go-1.4)) - ((#:phases phases) - `(modify-phases ,phases - ;; Time bomb in TLS tests: "Most of the test certificates - ;; (e.g. testRSACertificate, testRSACertificateIssuer, - ;; testRSA2048CertificateIssuer) have a not after of Jan 1 - ;; 00:00:00 2025 GMT." - ;; https://github.com/golang/go/issues/71077 - ;; https://github.com/golang/go/issues/71103 - ;; https://github.com/golang/go/issues/71104 - (add-after 'unpack 'skip-crypto-tls-tests - (lambda _ - (substitute* (list "src/crypto/tls/handshake_client_test.go" - "src/crypto/tls/handshake_server_test.go") - (("TestVerifyConnection.*" all) - (string-append all "\n t.Skip(\"golang.org/issue/71077\")\n")) - (("TestResumptionKeepsOCSPAndSCT.*" all) - (string-append all "\n t.Skip(\"golang.org/issue/71077\")\n")) - (("TestCrossVersionResume.*" all) - (string-append all "\n t.Skip(\"golang.org/issue/71077\")\n"))))) - (add-after 'unpack 'remove-unused-sourcecode-generators - (lambda _ - ;; Prevent perl from inclusion in closure through unused files - (for-each delete-file (find-files "src" "\\.pl$")))) - (replace 'prebuild - (lambda* (#:key inputs outputs #:allow-other-keys) - (let* ((gcclib (string-append (assoc-ref inputs "gcc:lib") "/lib")) - (net-base (assoc-ref inputs "net-base")) - (tzdata-path - (string-append (assoc-ref inputs "tzdata") "/share/zoneinfo"))) - - ;; 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" "-p2" "--force" "-i" - (assoc-ref inputs "go-skip-gc-test.patch")) - (invoke "patch" "-p2" "--force" "-i" - (assoc-ref inputs "go-fix-script-tests.patch")) - - (for-each make-file-writable (find-files ".")) - - (substitute* "os/os_test.go" - (("/usr/bin") (getcwd)) - (("/bin/sh") (which "sh"))) - - (substitute* "cmd/go/testdata/script/cgo_path_space.txt" - (("/bin/sh") (which "sh"))) - - ;; Add libgcc to runpath - (substitute* "cmd/link/internal/ld/lib.go" - (("!rpath.set") "true")) - (substitute* "cmd/go/internal/work/gccgo.go" - (("cgoldflags := \\[\\]string\\{\\}") - (string-append "cgoldflags := []string{" - "\"-Wl,-rpath=" gcclib "\"" - "}")) - (("\"-lgcc_s\", ") - (string-append - "\"-Wl,-rpath=" gcclib "\", \"-lgcc_s\", "))) - (substitute* "cmd/go/internal/work/gc.go" - (("ldflags = setextld\\(ldflags, compiler\\)") - (string-append - "ldflags = setextld(ldflags, compiler)\n" - "ldflags = append(ldflags, \"-r\")\n" - "ldflags = append(ldflags, \"" gcclib "\")\n"))) - - ;; Disable failing tests: these tests attempt to access - ;; commands or network resources which are neither available - ;; nor necessary for the build to succeed. - (for-each - (match-lambda - ((file regex) - (substitute* file - ((regex all before test_name) - (string-append before "Disabled" test_name))))) - '(("net/net_test.go" "(.+)(TestShutdownUnix.+)") - ("net/dial_test.go" "(.+)(TestDialTimeout.+)") - ("net/cgo_unix_test.go" "(.+)(TestCgoLookupPort.+)") - ("net/cgo_unix_test.go" "(.+)(TestCgoLookupPortWithCancel.+)") - ;; 127.0.0.1 doesn't exist - ("net/cgo_unix_test.go" "(.+)(TestCgoLookupPTR.+)") - ;; 127.0.0.1 doesn't exist - ("net/cgo_unix_test.go" "(.+)(TestCgoLookupPTRWithCancel.+)") - ;; /etc/services doesn't exist - ("net/parse_test.go" "(.+)(TestReadLine.+)") - ("os/os_test.go" "(.+)(TestHostname.+)") - ;; The user's directory doesn't exist - ("os/os_test.go" "(.+)(TestUserHomeDir.+)") - ("time/format_test.go" "(.+)(TestParseInSydney.+)") - ("time/format_test.go" "(.+)(TestParseInLocation.+)") - ("os/exec/exec_test.go" "(.+)(TestEcho.+)") - ("os/exec/exec_test.go" "(.+)(TestCommandRelativeName.+)") - ("os/exec/exec_test.go" "(.+)(TestCatStdin.+)") - ("os/exec/exec_test.go" "(.+)(TestCatGoodAndBadFile.+)") - ("os/exec/exec_test.go" "(.+)(TestExitStatus.+)") - ("os/exec/exec_test.go" "(.+)(TestPipes.+)") - ("os/exec/exec_test.go" "(.+)(TestStdinClose.+)") - ("os/exec/exec_test.go" "(.+)(TestIgnorePipeErrorOnSuccess.+)") - ("syscall/syscall_unix_test.go" "(.+)(TestPassFD\\(.+)") - ("os/exec/exec_test.go" "(.+)(TestExtraFiles/areturn.+)") - ("cmd/go/go_test.go" "(.+)(TestCoverageWithCgo.+)") - ("cmd/go/go_test.go" "(.+)(TestTwoPkgConfigs.+)") - ("os/exec/exec_test.go" "(.+)(TestOutputStderrCapture.+)") - ("os/exec/exec_test.go" "(.+)(TestExtraFiles.+)") - ("os/exec/exec_test.go" "(.+)(TestExtraFilesRace.+)") - ("net/lookup_test.go" "(.+)(TestLookupPort.+)") - ("syscall/exec_linux_test.go" - "(.+)(TestCloneNEWUSERAndRemapNoRootDisableSetgroups.+)"))) - - ;; These tests fail on aarch64-linux - (substitute* "cmd/dist/test.go" - (("t.registerHostTest\\(\"testsanitizers/msan.*") "")) - - ;; fix shebang for testar script - ;; note the target script is generated at build time. - (substitute* "../misc/cgo/testcarchive/carchive_test.go" - (("#!/usr/bin/env") (string-append "#!" (which "env")))) - - (substitute* "net/lookup_unix.go" - (("/etc/protocols") (string-append net-base "/etc/protocols"))) - (substitute* "net/port_unix.go" - (("/etc/services") (string-append net-base "/etc/services"))) - (substitute* "time/zoneinfo_unix.go" - (("/usr/share/zoneinfo/") tzdata-path))))) - (add-before 'build 'set-bootstrap-variables - (lambda* (#:key outputs inputs #:allow-other-keys) - ;; Tell the build system where to find the bootstrap Go. - (let ((go (assoc-ref inputs "go"))) - (setenv "GOROOT_BOOTSTRAP" go) - (setenv "GOGC" "400")))) - (replace 'build - (lambda* (#:key inputs outputs (parallel-build? #t) - #:allow-other-keys) - ;; FIXME: Some of the .a files are not bit-reproducible. - ;; (Is this still true?) - (let* ((njobs (if parallel-build? (parallel-job-count) 1)) - (output (assoc-ref outputs "out")) - (loader (string-append (assoc-ref inputs "libc") - ,(glibc-dynamic-linker)))) - (setenv "CC" (which "gcc")) - (setenv "GO_LDSO" loader) - (setenv "GOOS" "linux") - (setenv "GOROOT" (dirname (getcwd))) - (setenv "GOROOT_FINAL" output) - (setenv "GOCACHE" "/tmp/go-cache") - (setenv "GOMAXPROCS" (number->string njobs)) - (invoke "sh" "make.bash" "--no-banner")))) - (replace 'check - (lambda* (#:key target (tests? (not target)) (parallel-tests? #t) - #:allow-other-keys) - (let* ((njobs (if parallel-tests? (parallel-job-count) 1))) - (when tests? - (setenv "GOMAXPROCS" (number->string njobs)) - (invoke "sh" "run.bash" "--no-rebuild"))))) - (add-before 'install 'unpatch-perl-shebangs - (lambda _ - ;; Rewrite references to perl input in test scripts - (substitute* "net/http/cgi/testdata/test.cgi" - (("^#!.*") "#!/usr/bin/env perl\n")))) - (replace 'install - ;; TODO: Most of this could be factorized with Go 1.4. - (lambda* (#:key outputs #:allow-other-keys) - (let* ((output (assoc-ref outputs "out")) - (doc_out (assoc-ref outputs "doc")) - (docs (string-append doc_out "/share/doc/" ,name "-" ,version)) - (src (string-append - (assoc-ref outputs "tests") "/share/" ,name "-" ,version))) - ;; Prevent installation of the build cache, which contains - ;; store references to most of the tools used to build Go and - ;; would unnecessarily increase the size of Go's closure if it - ;; was installed. - (delete-file-recursively "../pkg/obj") - - (mkdir-p src) - (copy-recursively "../test" (string-append src "/test")) - (delete-file-recursively "../test") - (mkdir-p docs) - (copy-recursively "../api" (string-append docs "/api")) - (delete-file-recursively "../api") - (copy-recursively "../doc" (string-append docs "/doc")) - (delete-file-recursively "../doc") - - (for-each - (lambda (file) - (let* ((filein (string-append "../" file)) - (fileout (string-append docs "/" file))) - (copy-file filein fileout) - (delete-file filein))) - ;; Note the slightly different file names compared to 1.4. - '("README.md" "CONTRIBUTORS" "AUTHORS" "PATENTS" - "LICENSE" "VERSION" "CONTRIBUTING.md" "robots.txt")) - - (copy-recursively "../" output)))))))) - (native-inputs - `(,@(if (member (%current-system) (package-supported-systems go-1.4)) - `(("go" ,go-1.4)) - `(("go" ,gccgo-12))) - ("go-skip-gc-test.patch" ,(search-patch "go-skip-gc-test.patch")) - ,@(match (%current-system) - ((or "armhf-linux" "aarch64-linux") - `(("gold" ,binutils-gold))) - (_ `())) - ("go-fix-script-tests.patch" ,(search-patch "go-fix-script-tests.patch")) - ,@(package-native-inputs go-1.4))) - (supported-systems (fold delete %supported-systems - (list "powerpc-linux" "i586-gnu" "x86_64-gnu"))))) - ;; https://github.com/golang/go/wiki/MinimumRequirements#microarchitecture-support (define %go-1.17-arm-micro-architectures (list "armv5" "armv6" "armv7")) @@ -482,7 +254,6 @@ in the style of communicating sequential processes (@dfn{CSP}).") (define-public go-1.17 (package - (inherit go-1.16) (name "go") (version "1.17.13") (source @@ -496,13 +267,14 @@ in the style of communicating sequential processes (@dfn{CSP}).") (base32 "05m8gr050kagvn22lfnjrgms03l5iphd1m4v6z7yqlhn9gdp912d")))) (outputs '("out" "tests")) ; 'tests' contains distribution tests. + (build-system gnu-build-system) (arguments `(#:modules ((ice-9 match) (guix build gnu-build-system) (guix build utils)) ;; TODO: Disable the test(s) in misc/cgo/test/cgo_test.go ;; that cause segfaults in the test suite. - #:tests? ,(not (or (target-aarch64?) (target-riscv64?))) + #:tests? ,(not (or (target-arm32?) (target-riscv64?))) #:phases (modify-phases %standard-phases (replace 'configure @@ -571,30 +343,26 @@ in the style of communicating sequential processes (@dfn{CSP}).") (string-append net-base "/etc/services"))) (substitute* "src/time/zoneinfo_unix.go" (("/usr/share/zoneinfo/") tzdata-path))))) - ;; Keep this synchronized with the package inputs. - ;; Also keep syncthonized with later versions of go. - ,@(if (or (target-arm?) (target-ppc64le?)) - '((add-after 'unpack 'patch-gcc:lib - (lambda* (#:key inputs #:allow-other-keys) - (let* ((gcclib (string-append (assoc-ref inputs "gcc:lib") "/lib"))) - ;; Add libgcc to runpath - (substitute* "src/cmd/link/internal/ld/lib.go" - (("!rpath.set") "true")) - (substitute* "src/cmd/go/internal/work/gccgo.go" - (("cgoldflags := \\[\\]string\\{\\}") - (string-append "cgoldflags := []string{" - "\"-Wl,-rpath=" gcclib "\"" - "}")) - (("\"-lgcc_s\", ") - (string-append - "\"-Wl,-rpath=" gcclib "\", \"-lgcc_s\", "))) - (substitute* "src/cmd/go/internal/work/gc.go" - (("ldflags = setextld\\(ldflags, compiler\\)") - (string-append - "ldflags = setextld(ldflags, compiler)\n" - "ldflags = append(ldflags, \"-r\")\n" - "ldflags = append(ldflags, \"" gcclib "\")\n"))))))) - '()) + (add-after 'unpack 'patch-gcc:lib + (lambda* (#:key inputs #:allow-other-keys) + (let* ((gcclib (string-append (assoc-ref inputs "gcc:lib") "/lib"))) + ;; Add libgcc to runpath + (substitute* "src/cmd/link/internal/ld/lib.go" + (("!rpath.set") "true")) + (substitute* "src/cmd/go/internal/work/gccgo.go" + (("cgoldflags := \\[\\]string\\{\\}") + (string-append "cgoldflags := []string{" + "\"-Wl,-rpath=" gcclib "\"" + "}")) + (("\"-lgcc_s\", ") + (string-append + "\"-Wl,-rpath=" gcclib "\", \"-lgcc_s\", "))) + (substitute* "src/cmd/go/internal/work/gc.go" + (("ldflags = setextld\\(ldflags, compiler\\)") + (string-append + "ldflags = setextld(ldflags, compiler)\n" + "ldflags = append(ldflags, \"-r\")\n" + "ldflags = append(ldflags, \"" gcclib "\")\n")))))) ;; Backported from later versions of go to workaround 64k page sizes. ,@(if (target-ppc64le?) '((add-after 'unpack 'adjust-test-suite @@ -713,85 +481,87 @@ in the style of communicating sequential processes (@dfn{CSP}).") (install-file file (string-append out "/share/doc/go"))) '("AUTHORS" "CONTRIBUTORS" "CONTRIBUTING.md" "PATENTS" "README.md" "SECURITY.md")))))))) - (inputs (if (not (or (target-arm?) (target-ppc64le?))) - (alist-delete "gcc:lib" (package-inputs go-1.16)) - (package-inputs go-1.16))) + (inputs + `(("tzdata" ,tzdata) + ("pcre" ,pcre) + ("gcc:lib" ,gcc "lib"))) + (native-inputs + `(,@(if (member (%current-system) (package-supported-systems go-1.4)) + `(("go" ,go-1.4)) + `(("go" ,gccgo-12))) + ("go-skip-gc-test.patch" ,(search-patch "go-skip-gc-test.patch")) + ("go-fix-script-tests.patch" ,(search-patch "go-fix-script-tests.patch")) + ,@(package-native-inputs go-1.4) + ;; For plugin.test which requires "-fuse-ld=gold" + ,@(match (%current-system) + ((or "armhf-linux" "aarch64-linux") + `(("gold" ,binutils-gold))) + (_ `())))) + (home-page "https://go.dev/") + (synopsis "Compiler and libraries for Go, a statically-typed language") + (description "Go, also commonly referred to as golang, is an imperative +programming language designed primarily for systems programming. Go is a +compiled, statically typed language in the tradition of C and C++, but adds +garbage collection, various safety features, and concurrent programming features +in the style of communicating sequential processes (@dfn{CSP}).") + (supported-systems (fold delete %supported-systems + (list "powerpc-linux" "i586-gnu" "x86_64-gnu"))) (properties `((compiler-cpu-architectures ("armhf" ,@%go-1.17-arm-micro-architectures) - ("powerpc64le" ,@%go-1.17-powerpc64le-micro-architectures)))))) + ("powerpc64le" ,@%go-1.17-powerpc64le-micro-architectures)))) + (license license:bsd-3))) (define %go-1.18-x86_64-micro-architectures ;; GOAMD defaults to 'v1' so we match the default elsewhere. (list "x86-64" "x86-64-v2" "x86-64-v3" "x86-64-v4")) -(define-public go-1.18 +(define-public go-1.20 (package (inherit go-1.17) (name "go") - (version "1.18.10") - (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 - "0ph3ajfq5q8j3nd91pfb25pm21aiphc58zf7fwis0h3a6nqbdyq9")))) + (version "1.20.14") + (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 + "1aqhc23705q76dca3g0fzq98kxkhyq628s0811qgzgz4wmngsjfm")))) (arguments (substitute-keyword-arguments (package-arguments go-1.17) - ((#:phases phases) - `(modify-phases ,phases - (delete 'adjust-test-suite) - ,@(if (or (target-arm?) (target-ppc64le?)) - '((replace 'patch-gcc:lib - (lambda* (#:key inputs #:allow-other-keys) - (let* ((gcclib (string-append (assoc-ref inputs "gcc:lib") "/lib"))) - ;; Add libgcc to runpath - (substitute* "src/cmd/link/internal/ld/lib.go" - (("!rpath.set") "true")) - (substitute* "src/cmd/go/internal/work/gccgo.go" - (("cgoldflags := \\[\\]string\\{\\}") - (string-append "cgoldflags := []string{" - "\"-Wl,-rpath=" gcclib "\"" - "}")) - (("\"-lgcc_s\", ") - (string-append - "\"-Wl,-rpath=" gcclib "\", \"-lgcc_s\", "))) - (substitute* "src/cmd/go/internal/work/gc.go" - (("ldflags, err := setextld\\(ldflags, compiler\\)") - (string-append - "ldflags, err := setextld(ldflags, compiler)\n" - "ldflags = append(ldflags, \"-r\")\n" - "ldflags = append(ldflags, \"" gcclib "\")\n"))))))) - '()))))) - (properties - `((compiler-cpu-architectures - ("armhf" ,@%go-1.17-arm-micro-architectures) - ("powerpc64le" ,@%go-1.17-powerpc64le-micro-architectures) - ("x86_64" ,@%go-1.18-x86_64-micro-architectures)))))) - -(define-public go-1.19 - (package - (inherit go-1.18) - (name "go") - (version "1.19.7") - (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 - "0rrpfhv6vdwqs0jnld0iqsky5wlirir05czf34kvsf2db21nzdi9")))) - (arguments - (substitute-keyword-arguments (package-arguments go-1.18) + ((#:parallel-tests? _ #t) + (not (target-riscv64?))) + ;; TODO: Disable the test(s) in misc/cgo/test/cgo_test.go + ;; that cause segfaults in the test suite. + ((#:tests? _ (not (%current-target-system))) + (and (not (%current-target-system)) + (not (target-riscv64?)))) ((#:phases phases) #~(modify-phases #$phases + (delete 'adjust-test-suite) + (replace 'patch-gcc:lib + (lambda* (#:key inputs #:allow-other-keys) + (let* ((gcclib (string-append (assoc-ref inputs "gcc:lib") "/lib"))) + ;; Add libgcc to runpath + (substitute* "src/cmd/link/internal/ld/lib.go" + (("!rpath.set") "true")) + (substitute* "src/cmd/go/internal/work/gccgo.go" + (("cgoldflags := \\[\\]string\\{\\}") + (string-append "cgoldflags := []string{" + "\"-Wl,-rpath=" gcclib "\"" + "}")) + (("\"-lgcc_s\", ") + (string-append + "\"-Wl,-rpath=" gcclib "\", \"-lgcc_s\", "))) + (substitute* "src/cmd/go/internal/work/gc.go" + (("ldflags, err := setextld\\(ldflags, compiler\\)") + (string-append + "ldflags, err := setextld(ldflags, compiler)\n" + "ldflags = append(ldflags, \"-r\")\n" + "ldflags = append(ldflags, \"" gcclib "\")\n")))))) ;; These are recurring test failures, depending on having a new ;; enough version of gccgo. gccgo-12.2 fails with go-1.19.7. ;; https://github.com/golang/go/issues/22224 @@ -809,31 +579,68 @@ in the style of communicating sequential processes (@dfn{CSP}).") (install-file file (string-append #$output "/share/doc/go"))) '("CONTRIBUTING.md" "PATENTS" "README.md" - "SECURITY.md")))))))))) - -(define-public go-1.20 - (package - (inherit go-1.19) - (name "go") - (version "1.20.2") - (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 - "0ir0x17i9067i48ffskwlmbx1j4kfhch46zl8cwl88y23aw59qa2")))) + "SECURITY.md")))) + (add-after 'disable-failing-tests 'disable-more-tests + (lambda _ + ;; Unclear why this test fails on x86_64. + (substitute* "misc/cgo/testsanitizers/asan_test.go" + ((".*arena_fail.*") "") + ((".*asan_global1_fail.*") "")) + ;; error while loading shared libraries: libgcc_s.so.1: + ;; cannot open shared object file: No such file or directory + (for-each delete-file + '("test/fixedbugs/bug514.go" + "test/fixedbugs/issue40954.go" + "test/fixedbugs/issue42032.go" + "test/fixedbugs/issue42076.go" + "test/fixedbugs/issue51733.go")) + #$@(cond + ((target-aarch64?) + ;; https://go-review.googlesource.com/c/go/+/151303 + ;; This test is known buggy on aarch64 and is enabled and + ;; disabled upstream with some regularity. + #~((substitute* "src/plugin/plugin_test.go" + (("package plugin_test") + (string-append "// +build !linux linux,!arm64\n\n" + "package plugin_test"))) + ;; collect2: fatal error: cannot find ‘ld’ + (substitute* "src/cmd/dist/test.go" + ((".*testcshared.*") "") + ((".*testshared.*") "")))) + ((target-arm32?) + ;; https://go-review.googlesource.com/c/go/+/151303 + ;; This test is known buggy on aarch64 so we disable + ;; it on armhf also since we emulate armhf on aarch64. + #~((substitute* "src/plugin/plugin_test.go" + (("package plugin_test") + (string-append "// +build !linux linux,!arm\n\n" + "package plugin_test"))) + ;; collect2: fatal error: cannot find ‘ld’ + (substitute* "src/cmd/dist/test.go" + ((".*testcshared.*") "") + ((".*testshared.*") "")))) + ((target-riscv64?) + #~((substitute* "src/runtime/lockrank_test.go" + (("TestLockRankGenerated.*" all) + (string-append + all "\n " + "t.Skip(\"golang.org/issue/22224\")\n"))))) + (else #~())))))))) (native-inputs ;; Go 1.20 and later requires Go 1.17 as the bootstrap toolchain. ;; See 'src/cmd/dist/notgo117.go' in the source code distribution, ;; as well as the upstream discussion of this topic: ;; https://go.dev/issue/44505 ;; We continue to use gccgo-12 since it provides go-1.18. + ;; We remove gold since it causes test failures on aarch64-linux. (if (member (%current-system) (package-supported-systems go-1.4)) (alist-replace "go" (list go-1.17) (package-native-inputs go-1.17)) - (package-native-inputs go-1.17))))) + (alist-delete "gold" (package-native-inputs go-1.17)))) + (properties + `((compiler-cpu-architectures + ("armhf" ,@%go-1.17-arm-micro-architectures) + ("powerpc64le" ,@%go-1.17-powerpc64le-micro-architectures) + ("x86_64" ,@%go-1.18-x86_64-micro-architectures)))))) (define-public go-1.21 (package @@ -850,7 +657,9 @@ in the style of communicating sequential processes (@dfn{CSP}).") (base32 "0x4qdib1d3gzgz620aysi1rrg682g93710dar4ga32b0j0w5kbhj")))) (arguments - (substitute-keyword-arguments (package-arguments go-1.20) + (substitute-keyword-arguments + (strip-keyword-arguments '(#:tests?) + (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. @@ -858,6 +667,7 @@ in the style of communicating sequential processes (@dfn{CSP}).") #~(modify-phases #$phases (delete 'skip-TestGoPathShlibGccgo-tests) (delete 'patch-source) + (delete 'disable-more-tests) (add-after 'unpack 'patch-os-tests (lambda _ (substitute* "src/os/os_test.go" @@ -978,7 +788,7 @@ in the style of communicating sequential processes (@dfn{CSP}).") (define-public go-1.22 (package - (inherit go-1.21) + (inherit go-1.20) (name "go") (version "1.22.12") (source @@ -991,9 +801,159 @@ in the style of communicating sequential processes (@dfn{CSP}).") (sha256 (base32 "0f0fr92z3l3szmxf3wvh20w1sqayvd927gawdp5d44cc44pd6c0n")))) (arguments - (substitute-keyword-arguments (package-arguments go-1.21) + (substitute-keyword-arguments (package-arguments go-1.20) + ((#:parallel-tests? _ #t) + (or (not (target-riscv64?)) + (not (target-arm32?)))) ((#:phases phases) #~(modify-phases #$phases + ;; Source patching phases are broken up into discrete steps to allow + ;; future versions to discard individual phases without having to + ;; discard all source patching. + (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 'unpack 'remove-failing-test + (lambda _ + ;; This test fails with newer gcc's + ;; https://github.com/golang/go/issues/57691 + (substitute* "src/cmd/cgo/internal/testsanitizers/asan_test.go" + ((".*arena_fail.*") "")))) + + (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)))))) + + ;; Some architectures need more time for the test suite. + #$@(if (or (target-riscv64?) + (target-arm?)) + #~((add-after 'unpack 'extend-test-timeout + (lambda _ + (setenv "GO_TEST_TIMEOUT_SCALE" "10")))) + #~()) + (replace 'disable-more-tests + (lambda _ + #$@(cond + ((target-aarch64?) + ;; https://go-review.googlesource.com/c/go/+/151303 + ;; This test is known buggy on aarch64 and is enabled and + ;; disabled upstream with some regularity. + #~((substitute* "src/plugin/plugin_test.go" + (("package plugin_test") + (string-append "// +build !linux linux,!arm64\n\n" + "package plugin_test"))) + ;; These tests "run too slowly". + (substitute* "src/go/printer/printer_test.go" + ((".*go2numbers\\.input.*") "") + ((".*generics\\.input.*") "") + ((".*gobuild1\\.input.*") "")))) + (else (list #t))))) (replace 'unpatch-perl-shebangs (lambda _ ;; Avoid inclusion of perl in closure by rewriting references @@ -1008,9 +968,8 @@ in the style of communicating sequential processes (@dfn{CSP}).") (substitute* "src/cmd/cgo/internal/testsanitizers/tsan_test.go" ((".*tsan1[34].*") "")))))))) (native-inputs - ;; Go 1.22 and later requires Go 1.20 (min. 1.20.6, which we don't have) - ;; as the bootstrap toolchain. - (alist-replace "go" (list go-1.21) (package-native-inputs go-1.21))))) + ;; Go 1.22 and later requires Go 1.20 as the bootstrap toolchain. + (alist-replace "go" (list go-1.20) (package-native-inputs go-1.20))))) (define %go-1.23-arm64-micro-architectures ;; https://go.dev/wiki/MinimumRequirements#arm64 @@ -1037,6 +996,22 @@ in the style of communicating sequential processes (@dfn{CSP}).") (file-name (git-file-name name version)) (sha256 (base32 "06c5cjjqk95p16cb6p8fgqqsddc1a1kj3w2m0na5v91gvwxbd0pq")))) + (arguments + (substitute-keyword-arguments (package-arguments go-1.22) + ((#:phases phases) + #~(modify-phases #$phases + (replace 'disable-more-tests + (lambda _ + #$@(cond + ((target-aarch64?) + ;; https://go-review.googlesource.com/c/go/+/151303 + ;; This test is known buggy on aarch64 and is enabled and + ;; disabled upstream with some regularity. + #~((substitute* "src/plugin/plugin_test.go" + (("package plugin_test") + (string-append "// +build !linux linux,!arm64\n\n" + "package plugin_test"))))) + (else (list #t))))))))) (properties `((compiler-cpu-architectures ("aarch64" ,@%go-1.23-arm64-micro-architectures) @@ -1046,7 +1021,7 @@ in the style of communicating sequential processes (@dfn{CSP}).") (define-public go-1.24 (package - (inherit go-1.23) + (inherit go-1.22) (name "go") (version "1.24.3") (source @@ -1058,9 +1033,31 @@ in the style of communicating sequential processes (@dfn{CSP}).") (file-name (git-file-name name version)) (sha256 (base32 "1b24pdsxrarw22gffv85sghpgvgamafvwwrvvhmyv3hqf89m97zk")))) + (arguments + (substitute-keyword-arguments (package-arguments go-1.22) + ((#:phases phases) + #~(modify-phases #$phases + (replace 'disable-more-tests + (lambda _ + #$@(cond + ((target-aarch64?) + ;; https://go-review.googlesource.com/c/go/+/151303 + ;; This test is known buggy on aarch64 and is enabled and + ;; disabled upstream with some regularity. + #~((substitute* "src/plugin/plugin_test.go" + (("package plugin_test") + (string-append "// +build !linux linux,!arm64\n\n" + "package plugin_test"))))) + (else (list #t))))))))) (native-inputs ;; Go 1.24 and later requires Go 1.22+ as the bootstrap toolchain. - (alist-replace "go" (list go-1.22) (package-native-inputs go-1.23))))) + (alist-replace "go" (list go-1.22) (package-native-inputs go-1.22))) + (properties + `((compiler-cpu-architectures + ("aarch64" ,@%go-1.23-arm64-micro-architectures) + ("armhf" ,@%go-1.17-arm-micro-architectures) + ("powerpc64le" ,@%go-1.17-powerpc64le-micro-architectures) + ("x86_64" ,@%go-1.18-x86_64-micro-architectures)))))) ;; ;; Default Golang version used in guix/build-system/go.scm to build packages. @@ -1101,10 +1098,7 @@ in the style of communicating sequential processes (@dfn{CSP}).") (export make-go-std) ;; Make those public so they have a corresponding Cuirass job. -(define-public go-std-1.16 (make-go-std go-1.16)) (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-std-1.22 (make-go-std go-1.22)) |