summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-01-29 21:22:57 +0100
committerMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-05-21 19:42:12 +0200
commit0b5c5b8068be0a973d1ed37cb011bb0cbba3e763 (patch)
tree95e66d2a81bacb837d744353c48a9d5d836ac781
parentadd339cbfe357c976a912485ff075336aa575ceb (diff)
downloadspack-0b5c5b8068be0a973d1ed37cb011bb0cbba3e763.tar.gz
spack-0b5c5b8068be0a973d1ed37cb011bb0cbba3e763.tar.bz2
spack-0b5c5b8068be0a973d1ed37cb011bb0cbba3e763.tar.xz
spack-0b5c5b8068be0a973d1ed37cb011bb0cbba3e763.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 db59681d0a..c15a075731 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