summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorSarah Morgensen <iskarian@mgsn.dev>2021-09-02 15:09:27 -0700
committerLeo Famulari <leo@famulari.name>2021-09-09 16:38:23 -0400
commitd36c73b8a8f52732753c11125cfb4d8bf735f8b7 (patch)
tree2c6d2d53584b132b2a547fd8419c760f7b192f68 /gnu
parent14d8413fc53aac86bd1fa4b7f94969ed62c221b6 (diff)
gnu: Add go-1.17.
* gnu/packages.golang.scm (go-1.17): New variable. Signed-off-by: Leo Famulari <leo@famulari.name>
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/golang.scm182
1 files changed, 182 insertions, 0 deletions
diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 3c151b716ec..b051ed29905 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -608,6 +608,188 @@ in the style of communicating sequential processes (@dfn{CSP}).")
608 (alist-replace "go" (list gccgo-10) (package-native-inputs go-1.14)) 608 (alist-replace "go" (list gccgo-10) (package-native-inputs go-1.14))
609 (package-native-inputs go-1.14)))))) 609 (package-native-inputs go-1.14))))))
610 610
611(define-public go-1.17
612 (package
613 (inherit go-1.16)
614 (name "go")
615 (version "1.17")
616 (source
617 (origin
618 (method git-fetch)
619 (uri (git-reference
620 (url "https://github.com/golang/go")
621 (commit (string-append "go" version))))
622 (file-name (git-file-name name version))
623 (sha256
624 (base32
625 "1psra6j95ws38mx3scc1whky8cwk32mazqs0wzzdwbs8ppl8iwl5"))))
626 (outputs '("out" "tests")) ; 'tests' contains distribution tests.
627 (arguments
628 `(#:modules ((ice-9 match)
629 (guix build gnu-build-system)
630 (guix build utils))
631 #:phases
632 (modify-phases %standard-phases
633 (replace 'configure
634 (lambda* (#:key inputs outputs #:allow-other-keys)
635 (let ((output (assoc-ref outputs "out"))
636 (loader (string-append (assoc-ref inputs "libc")
637 ,(glibc-dynamic-linker))))
638 (setenv "GOOS" "linux")
639 (setenv "GO_LDSO" loader)
640 (setenv "GOROOT" (getcwd))
641 (setenv "GOROOT_FINAL" (string-append output "/lib/go"))
642 (setenv "GOGC" "400")
643 (setenv "GOCACHE" "/tmp/go-cache"))))
644 (add-after 'unpack 'patch-source
645 (lambda* (#:key inputs outputs #:allow-other-keys)
646 (let* ((net-base (assoc-ref inputs "net-base"))
647 (tzdata-path (string-append (assoc-ref inputs "tzdata")
648 "/share/zoneinfo")))
649 ;; XXX: Remove when #49729 is merged?
650 (for-each make-file-writable (find-files "src"))
651
652 ;; Having the patch in the 'patches' field of <origin> breaks
653 ;; the 'TestServeContent' test due to the fact that
654 ;; timestamps are reset. Thus, apply it from here.
655 (invoke "patch" "-p1" "--force" "-i"
656 (assoc-ref inputs "go-skip-gc-test.patch"))
657 (invoke "patch" "-p1" "--force" "-i"
658 (assoc-ref inputs "go-fix-script-tests.patch"))
659
660 (substitute* "src/os/os_test.go"
661 (("/usr/bin") (getcwd))
662 (("/bin/sh") (which "sh")))
663
664 (substitute* "src/cmd/go/testdata/script/cgo_path_space.txt"
665 (("/bin/sh") (which "sh")))
666
667 ;; fix shebang for testar script
668 ;; note the target script is generated at build time.
669 (substitute* "misc/cgo/testcarchive/carchive_test.go"
670 (("/usr/bin/env bash") (which "bash")))
671
672 (substitute* "src/net/lookup_unix.go"
673 (("/etc/protocols")
674 (string-append net-base "/etc/protocols")))
675 (substitute* "src/net/port_unix.go"
676 (("/etc/services")
677 (string-append net-base "/etc/services")))
678 (substitute* "src/time/zoneinfo_unix.go"
679 (("/usr/share/zoneinfo/") tzdata-path)))))
680 (add-after 'patch-source 'disable-failing-tests
681 (lambda _
682 ;; Disable failing tests: these tests attempt to access
683 ;; commands or network resources which are neither available
684 ;; nor necessary for the build to succeed.
685 (for-each
686 (match-lambda
687 ((file test)
688 (let ((regex (string-append "^(func\\s+)(" test "\\()")))
689 (substitute* file
690 ((regex all before test_name)
691 (string-append before "Disabled" test_name))))))
692 '(("src/net/cgo_unix_test.go" "TestCgoLookupPort")
693 ("src/net/cgo_unix_test.go" "TestCgoLookupPortWithCancel")
694 ;; 127.0.0.1 doesn't exist
695 ("src/net/cgo_unix_test.go" "TestCgoLookupPTR")
696 ("src/net/cgo_unix_test.go" "TestCgoLookupPTRWithCancel")
697 ;; /etc/services doesn't exist
698 ("src/net/parse_test.go" "TestReadLine")
699 ;; The user's directory doesn't exist
700 ("src/os/os_test.go" "TestUserHomeDir")))
701
702 ;; These tests fail on aarch64-linux
703 (substitute* "src/cmd/dist/test.go"
704 (("t.registerHostTest\\(\"testsanitizers/msan.*") ""))))
705 (add-after 'patch-source 'enable-external-linking
706 (lambda _
707 ;; Invoke GCC to link any archives created with GCC (that is, any
708 ;; packages built using 'cgo'), because Go doesn't know how to
709 ;; handle the runpaths but GCC does. Use substitute* rather than
710 ;; a patch since these files are liable to change often.
711 ;;
712 ;; XXX: Replace with GO_EXTLINK_ENABLED=1 or similar when
713 ;; <https://github.com/golang/go/issues/31544> and/or
714 ;; <https://github.com/golang/go/issues/43525> are resolved.
715 (substitute* "src/cmd/link/internal/ld/config.go"
716 (("iscgo && externalobj") "iscgo"))
717 (substitute* '("src/cmd/nm/nm_cgo_test.go"
718 "src/cmd/dist/test.go")
719 (("^func.*?nternalLink\\(\\).*" all)
720 (string-append all "\n\treturn false\n")))))
721 (replace 'build
722 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
723 (let* ((njobs (if parallel-build? (parallel-job-count) 1)))
724 (with-directory-excursion "src"
725 (setenv "GOMAXPROCS" (number->string njobs))
726 (invoke "sh" "make.bash" "--no-banner")))))
727 (replace 'check
728 (lambda* (#:key target (tests? (not target)) (parallel-tests? #t)
729 #:allow-other-keys)
730 (let* ((njobs (if parallel-tests? (parallel-job-count) 1)))
731 (when tests?
732 (with-directory-excursion "src"
733 (setenv "GOMAXPROCS" (number->string njobs))
734 (invoke "sh" "run.bash" "--no-rebuild"))))))
735 (add-before 'install 'unpatch-perl-shebangs
736 (lambda _
737 ;; Avoid inclusion of perl in closure by rewriting references
738 ;; to perl input in sourcecode generators and test scripts
739 (substitute* (cons "src/net/http/cgi/testdata/test.cgi"
740 (find-files "src" "\\.pl$"))
741 (("^#!.*") "#!/usr/bin/env perl\n"))))
742 (replace 'install
743 (lambda* (#:key outputs #:allow-other-keys)
744 ;; Notably, we do not install archives (180M), which Go will
745 ;; happily recompile quickly (and cache) if needed, almost
746 ;; surely faster than they could be substituted.
747 ;;
748 ;; The main motivation for pre-compiled archives is to use
749 ;; libc-linked `net' or `os' packages without a C compiler,
750 ;; but on Guix a C compiler is necessary to properly link the
751 ;; final binaries anyway. Many build flags also invalidate
752 ;; these pre-compiled archives, so in practice Go often
753 ;; recompiles them anyway.
754 ;;
755 ;; Upstream is also planning to no longer install these
756 ;; archives: <https://github.com/golang/go/issues/47257>
757 ;;
758 ;; When necessary, a custom pre-compiled library package can
759 ;; be created with `#:import-path "std"' and used with
760 ;; `-pkgdir'.
761 (let* ((out (assoc-ref outputs "out"))
762 (tests (assoc-ref outputs "tests")))
763 (for-each
764 (lambda (file)
765 (copy-recursively file (string-append out "/lib/go/" file)))
766 '("lib" "VERSION" "pkg/include" "pkg/tool"))
767
768 (for-each
769 (match-lambda
770 ((file dest output)
771 ;; Copy to output/dest and symlink from output/lib/go/file.
772 (let ((file* (string-append output "/lib/go/" file))
773 (dest* (string-append output "/" dest)))
774 (copy-recursively file dest*)
775 (mkdir-p (dirname file*))
776 (symlink (string-append "../../" dest) file*))))
777 `(("bin" "bin" ,out)
778 ("src" "share/go/src" ,out)
779 ("misc" "share/go/misc" ,out)
780 ("doc" "share/doc/go/doc" ,out)
781 ("api" "share/go/api" ,tests)
782 ("test" "share/go/test" ,tests))))))
783 (add-after 'install 'install-doc-files
784 (lambda* (#:key outputs #:allow-other-keys)
785 (let ((out (assoc-ref outputs "out")))
786 (for-each
787 (lambda (file)
788 (install-file file (string-append out "/share/doc/go")))
789 '("AUTHORS" "CONTRIBUTORS" "CONTRIBUTING.md" "PATENTS"
790 "README.md" "SECURITY.md"))))))))
791 (inputs (alist-delete "gcc:lib" (package-inputs go-1.16)))))
792
611(define-public go go-1.14) 793(define-public go go-1.14)
612 794
613(define-public go-0xacab-org-leap-shapeshifter 795(define-public go-0xacab-org-leap-shapeshifter