summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Miller <rgmiller@ornl.gov>2022-05-04 10:16:53 -0400
committerGitHub <noreply@github.com>2022-05-04 16:16:53 +0200
commit9486c76d705ecac82c7a11f343cf3671281c4283 (patch)
treee4f5a776fa93b28c554a8e5580be0351843274ba
parentdc99fe98b941fe1477928a103c16184fa016e31c (diff)
downloadspack-9486c76d705ecac82c7a11f343cf3671281c4283.tar.gz
spack-9486c76d705ecac82c7a11f343cf3671281c4283.tar.bz2
spack-9486c76d705ecac82c7a11f343cf3671281c4283.tar.xz
spack-9486c76d705ecac82c7a11f343cf3671281c4283.zip
Use gccgo to bootstrap go on aarch64 (#30350)
The go-bootstrap package doesn't work on aarch64 platforms, so the only way to build Go is to use gccgo. Also, some versions of gccgo have a bug that prevents them from compiling go (see golang/go#47771), so this patch limits gcc to versions newer than 10.4.0 or 11.3.0. Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
-rw-r--r--var/spack/repos/builtin/packages/go-bootstrap/package.py4
-rw-r--r--var/spack/repos/builtin/packages/go/package.py16
2 files changed, 17 insertions, 3 deletions
diff --git a/var/spack/repos/builtin/packages/go-bootstrap/package.py b/var/spack/repos/builtin/packages/go-bootstrap/package.py
index 2549d526a0..ec10c89ee5 100644
--- a/var/spack/repos/builtin/packages/go-bootstrap/package.py
+++ b/var/spack/repos/builtin/packages/go-bootstrap/package.py
@@ -36,8 +36,8 @@ class GoBootstrap(Package):
depends_on('git', type=('build', 'link', 'run'))
conflicts('os=monterey', msg="go-bootstrap won't build on new macOS")
- conflicts('target=aarch64:', when='platform=darwin',
- msg='Go bootstrap is too old for Apple Silicon')
+ conflicts('target=aarch64:',
+ msg="Go bootstrap doesn't support aarch64 architectures")
def patch(self):
if self.spec.satisfies('@:1.4.3'):
diff --git a/var/spack/repos/builtin/packages/go/package.py b/var/spack/repos/builtin/packages/go/package.py
index 125355e81b..f7c0fc1f41 100644
--- a/var/spack/repos/builtin/packages/go/package.py
+++ b/var/spack/repos/builtin/packages/go/package.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+import platform
import re
import llnl.util.tty as tty
@@ -130,7 +131,20 @@ class Go(Package):
provides('golang')
depends_on('git', type=('build', 'link', 'run'))
- depends_on('go-bootstrap', type='build')
+
+ # aarch64 machines (including Macs with Apple silicon) can't use
+ # go-bootstrap because it pre-dates aarch64 support in Go. These machines
+ # have to rely on Go support in gcc (which may require compiling a version
+ # of gcc with Go support just to satisfy this requirement). However,
+ # there's also a bug in some versions of GCC's Go front-end that prevents
+ # these versions from properly bootstrapping Go. (See issue #47771
+ # https://github.com/golang/go/issues/47771 ) On the 10.x branch, we need
+ # at least 10.4. On the 11.x branch, we need at least 11.3.
+
+ if platform.machine() == 'aarch64':
+ depends_on('gcc@10.4.0:10,11.3.0: languages=go', type='build')
+ else:
+ depends_on('go-bootstrap', type='build')
# https://github.com/golang/go/issues/17545
patch('time_test.patch', when='@1.6.4:1.7.4')