summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-01-29 21:22:57 +0100
committerGitHub <noreply@github.com>2021-01-29 12:22:57 -0800
commit13ac7198d3f3f5b85b53a0364a2b5e67c639567b (patch)
tree703802e8d6d2f404ea0632de525cee6a22d72eae
parent0611036abdb7196d6d91a2433a35394bc2bd4ca7 (diff)
downloadspack-13ac7198d3f3f5b85b53a0364a2b5e67c639567b.tar.gz
spack-13ac7198d3f3f5b85b53a0364a2b5e67c639567b.tar.bz2
spack-13ac7198d3f3f5b85b53a0364a2b5e67c639567b.tar.xz
spack-13ac7198d3f3f5b85b53a0364a2b5e67c639567b.zip
clingo: added a package with option for bootstrapping clingo (#20652)
* clingo/clingo-bootstrap: added a package with option for bootstrapping clingo package builds in Release mode uses GCC options to link libstdc++ and libgcc statically * clingo-bootstrap: apple-clang options to bootstrap statically on darwin * clingo: fix the path of the Python interpreter In case multiple Python versions are in the same prefix (e.g. when clingo is built against an external Python), it may happen that the Python used by CMake does not match the corresponding node in the current spec. This is fixed here by defining "Python_EXECUTABLE" properly as a hint to CMake. * clingo: the commit for "spack" version has been updated.
-rw-r--r--var/spack/repos/builtin/packages/clingo-bootstrap/package.py51
-rw-r--r--var/spack/repos/builtin/packages/clingo/package.py17
2 files changed, 66 insertions, 2 deletions
diff --git a/var/spack/repos/builtin/packages/clingo-bootstrap/package.py b/var/spack/repos/builtin/packages/clingo-bootstrap/package.py
new file mode 100644
index 0000000000..06858da285
--- /dev/null
+++ b/var/spack/repos/builtin/packages/clingo-bootstrap/package.py
@@ -0,0 +1,51 @@
+# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+from spack.pkg.builtin.clingo import Clingo
+
+import spack.compilers
+
+
+class ClingoBootstrap(Clingo):
+ """Clingo with some options used for bootstrapping"""
+ variant('build_type', default='Release', values=('Release',),
+ description='CMake build type')
+
+ # CMake at version 3.16.0 or higher has the possibility to force the
+ # Python interpreter, which is crucial to build against external Python
+ # in environment where more than one interpreter is in the same prefix
+ depends_on('cmake@3.16.0:', type='build')
+
+ # On Linux we bootstrap with GCC
+ for compiler_spec in [
+ c for c in spack.compilers.supported_compilers()
+ if c != 'gcc'
+ ]:
+ conflicts('%{0}'.format(compiler_spec), when='platform=linux',
+ msg='GCC is required to bootstrap clingo on Linux')
+ conflicts('%gcc@:5.99.99', when='platform=linux',
+ msg='C++14 support is required to bootstrap clingo on Linux')
+
+ # On Darwin we bootstrap with Apple Clang
+ for compiler_spec in [
+ c for c in spack.compilers.supported_compilers()
+ if c != 'apple-clang'
+ ]:
+ conflicts('%{0}'.format(compiler_spec), when='platform=darwin',
+ msg='Apple-clang is required to bootstrap clingo on MacOS')
+
+ # Clingo needs the Python module to be usable by Spack
+ conflicts('~python', msg='Python support is required to bootstrap Spack')
+
+ def setup_build_environment(self, env):
+ if '%apple-clang platform=darwin' in self.spec:
+ opts = '-mmacosx-version-min=10.13'
+ elif '%gcc platform=linux' in self.spec:
+ opts = '-static-libstdc++ -static-libgcc -Wl,--exclude-libs,ALL'
+ else:
+ msg = 'unexpected compiler for spec "{0}"'.format(self.spec)
+ raise RuntimeError(msg)
+
+ env.set('CXXFLAGS', opts)
+ env.set('LDFLAGS', opts)
diff --git a/var/spack/repos/builtin/packages/clingo/package.py b/var/spack/repos/builtin/packages/clingo/package.py
index 3747998c77..1d6b0e7aba 100644
--- a/var/spack/repos/builtin/packages/clingo/package.py
+++ b/var/spack/repos/builtin/packages/clingo/package.py
@@ -24,7 +24,7 @@ class Clingo(CMakePackage):
maintainers = ["tgamblin"]
version('master', branch='master', submodules=True, preferred=True)
- version('spack', commit='2ab2e81bcb24f6070b7efce30a754d74ef52ee2d', submodules=True)
+ version('spack', commit='2a025667090d71b2c9dce60fe924feb6bde8f667', submodules=True)
version('5.4.0', sha256='e2de331ee0a6d254193aab5995338a621372517adcf91568092be8ac511c18f3')
version('5.3.0', sha256='b0d406d2809352caef7fccf69e8864d55e81ee84f4888b0744894977f703f976')
@@ -51,13 +51,22 @@ class Clingo(CMakePackage):
'clasp/CMakeLists.txt',
'clasp/libpotassco/CMakeLists.txt')
+ @property
+ def cmake_python_hints(self):
+ """Return standard CMake defines to ensure that the
+ current spec is the one found by CMake find_package(Python, ...)
+ """
+ return [
+ '-DPython_EXECUTABLE={0}'.format(str(self.spec['python'].command))
+ ]
+
def cmake_args(self):
try:
self.compiler.cxx14_flag
except UnsupportedCompilerFlag:
InstallError('clingo requires a C++14-compliant C++ compiler')
- return [
+ args = [
'-DCLINGO_REQUIRE_PYTHON=ON',
'-DCLINGO_BUILD_WITH_PYTHON=ON',
'-DCLINGO_BUILD_PY_SHARED=ON',
@@ -65,3 +74,7 @@ class Clingo(CMakePackage):
'-DPYCLINGO_USE_INSTALL_PREFIX=ON',
'-DCLINGO_BUILD_WITH_LUA=OFF'
]
+ if self.spec['cmake'].satisfies('@3.16.0:'):
+ args += self.cmake_python_hints
+
+ return args