From patchwork Fri Jun 25 07:21:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarah Morgensen X-Patchwork-Id: 30702 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 3F6DA27BC81; Fri, 25 Jun 2021 08:22:39 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1459527BC78 for ; Fri, 25 Jun 2021 08:22:38 +0100 (BST) Received: from localhost ([::1]:55910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwgAf-0007bP-5J for patchwork@mira.cbaines.net; Fri, 25 Jun 2021 03:22:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwgAB-00068o-Fe for guix-patches@gnu.org; Fri, 25 Jun 2021 03:22:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33206) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwgAB-0005u2-3p for guix-patches@gnu.org; Fri, 25 Jun 2021 03:22:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lwgAB-0005DD-0W for guix-patches@gnu.org; Fri, 25 Jun 2021 03:22:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49221] [PATCH 13/13] gnu: Add go-1.16. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 25 Jun 2021 07:22:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49221 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49221@debbugs.gnu.org Received: via spool by 49221-submit@debbugs.gnu.org id=B49221.162460570319918 (code B ref 49221); Fri, 25 Jun 2021 07:22:06 +0000 Received: (at 49221) by debbugs.gnu.org; 25 Jun 2021 07:21:43 +0000 Received: from localhost ([127.0.0.1]:44740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lwg9m-0005B7-7m for submit@debbugs.gnu.org; Fri, 25 Jun 2021 03:21:43 -0400 Received: from out2.migadu.com ([188.165.223.204]:12088) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lwg9d-0005AO-Tb for 49221@debbugs.gnu.org; Fri, 25 Jun 2021 03:21:34 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1624605693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JZGILPouBE39neeKn94pzk9Ux//6HfMXmuunjZ+0GaI=; b=At1EZ93UIQ2P5DmTw9ot/neYJTuwebnjhqSj2JbWCShQbBcgVk5/I6avYxct8wi8jddB2M dp81Wsb/MdkJ1AXlByJMeRYE1jQdksS8VqVFTcjTf62wEtda5w+LztqkVxiPVQ+4QcMLiY nd7jspv9P12TvqQyGdfzNOmD0HBrX0E= Date: Fri, 25 Jun 2021 00:21:06 -0700 Message-Id: <50a63395dda110ff8cc14d9e8f3516668f0c2e28.1624602942.git.iskarian@mgsn.dev> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: iskarian@mgsn.dev X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Sarah Morgensen X-ACL-Warn: , Sarah Morgensen via Guix-patches X-Patchwork-Original-From: Sarah Morgensen via Guix-patches via From: Sarah Morgensen X-getmail-retrieved-from-mailbox: Patches Add go@1.16 as a non-default go. Changes from 1.14: Use now-supported GO_LDSO configuration option for setting the interpreter. Bootstrap with gccgo on platforms which do not support go-1.4. Fix and re-enable cmd/go script tests. Fix typo in cgoldflags patch. Break out tests into "check" phase. Remove references to perl to reduce closure size by ~10%. Set GOCACHE so go doesn't attempt to access $HOME. * gnu/packages/patches/go-fix-script-tests.patch: New file. * local.mk (dist_patch_DATA): Register it. * gnu/packages/golang.scm (go-1.16): New variable. Use the patch. --- gnu/local.mk | 1 + gnu/packages/golang.scm | 158 ++++++++++++++++++ .../patches/go-fix-script-tests.patch | 18 ++ 3 files changed, 177 insertions(+) create mode 100644 gnu/packages/patches/go-fix-script-tests.patch diff --git a/gnu/local.mk b/gnu/local.mk index 24f2d9d013..59df29a72e 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1171,6 +1171,7 @@ dist_patch_DATA = \ %D%/packages/patches/gobject-introspection-absolute-shlib-path.patch \ %D%/packages/patches/gobject-introspection-cc.patch \ %D%/packages/patches/gobject-introspection-girepository.patch \ + %D%/packages/patches/go-fix-script-tests.patch \ %D%/packages/patches/go-skip-gc-test.patch \ %D%/packages/patches/go-github-com-bmatcuk-doublestar-1.3-remove-test.patch \ %D%/packages/patches/gpm-glibc-2.26.patch \ diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm index ae32e9f546..c169d573b4 100644 --- a/gnu/packages/golang.scm +++ b/gnu/packages/golang.scm @@ -45,6 +45,7 @@ (define-module (gnu packages golang) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix utils) + #:use-module ((guix build utils) #:select (alist-replace)) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix packages) @@ -54,6 +55,7 @@ #:use-module (gnu packages) #:use-module (gnu packages admin) #:use-module (gnu packages base) + #:use-module ((gnu packages bootstrap) #:select (glibc-dynamic-linker)) #:use-module (gnu packages gcc) #:use-module (gnu packages glib) #:use-module (gnu packages lua) @@ -441,6 +443,162 @@ in the style of communicating sequential processes (@dfn{CSP}).") ,@(package-native-inputs go-1.4))) (supported-systems %supported-systems))) +(define-public go-1.16 + (package + (inherit go-1.14) + (name "go") + (version "1.16.5") + (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 + "19a93p217h5xi2sgh34qzv24pkd4df0sw4fc5z6k47lspjp3vx2l")))) + (arguments + (substitute-keyword-arguments (package-arguments go-1.14) + ((#:tests? _) #t) + ((#:phases phases) + `(modify-phases ,phases + (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 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))))) + (replace 'build + (lambda* (#:key inputs outputs #:allow-other-keys) + ;; FIXME: Some of the .a files are not bit-reproducible. + ;; (Is this still true?) + (let* ((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") + (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")))))))) + (native-inputs + `(("go-fix-script-tests.patch" ,(search-patch "go-fix-script-tests.patch")) + ,@(if (not (member (%current-system) (package-supported-systems go-1.4))) + (alist-replace "go" `(,gccgo-10) (package-native-inputs go-1.14)) + (package-native-inputs go-1.14)))))) + (define-public go go-1.14) (define-public go-github-com-alsm-ioprogress diff --git a/gnu/packages/patches/go-fix-script-tests.patch b/gnu/packages/patches/go-fix-script-tests.patch new file mode 100644 index 0000000000..b29e83fef0 --- /dev/null +++ b/gnu/packages/patches/go-fix-script-tests.patch @@ -0,0 +1,18 @@ +Make library/header paths visible to cmd/go script tests, which is necessary for +cgo/gccgo tests to work correctly + +diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go +index dfaa40548e..9d0f0e9bcd 100644 +--- a/src/cmd/go/script_test.go ++++ b/src/cmd/go/script_test.go +@@ -100,6 +100,10 @@ const ( + var extraEnvKeys = []string{ + "SYSTEMROOT", // must be preserved on Windows to find DLLs; golang.org/issue/25210 + "WINDIR", // must be preserved on Windows to be able to run PowerShell command; golang.org/issue/30711 ++ "CPATH", ++ "C_INCLUDE_PATH", ++ "CPLUS_INCLUDE_PATH", ++ "LIBRARY_PATH", + "LD_LIBRARY_PATH", // must be preserved on Unix systems to find shared libraries + "CC", // don't lose user settings when invoking cgo + "GO_TESTING_GOTOOLS", // for gccgo testing