summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarmen Stoppels <me@harmenstoppels.nl>2023-12-06 11:27:22 +0100
committerGitHub <noreply@github.com>2023-12-06 10:27:22 +0000
commit4fc73bd7f33769bab7a0fe0b7b3ab6c8838f98a8 (patch)
tree617b2dca2b8da6c30e6d9062a76299338f41580b
parentf7fc4b201d78fc678ddd940254acc129a3ac42cb (diff)
downloadspack-4fc73bd7f33769bab7a0fe0b7b3ab6c8838f98a8.tar.gz
spack-4fc73bd7f33769bab7a0fe0b7b3ab6c8838f98a8.tar.bz2
spack-4fc73bd7f33769bab7a0fe0b7b3ab6c8838f98a8.tar.xz
spack-4fc73bd7f33769bab7a0fe0b7b3ab6c8838f98a8.zip
minimal support for freebsd (#41434)
-rw-r--r--lib/spack/spack/bootstrap/_common.py15
-rw-r--r--lib/spack/spack/operating_systems/__init__.py13
-rw-r--r--lib/spack/spack/operating_systems/freebsd.py15
-rw-r--r--lib/spack/spack/platforms/__init__.py2
-rw-r--r--lib/spack/spack/platforms/_functions.py3
-rw-r--r--lib/spack/spack/platforms/freebsd.py37
-rw-r--r--var/spack/repos/builtin/packages/clingo/package.py4
-rw-r--r--var/spack/repos/builtin/packages/expat/package.py2
-rw-r--r--var/spack/repos/builtin/packages/krb5/freebsd-link.patch11
-rw-r--r--var/spack/repos/builtin/packages/krb5/package.py1
-rw-r--r--var/spack/repos/builtin/packages/libbsd/package.py2
11 files changed, 94 insertions, 11 deletions
diff --git a/lib/spack/spack/bootstrap/_common.py b/lib/spack/spack/bootstrap/_common.py
index 0b8192f77f..6324e0d289 100644
--- a/lib/spack/spack/bootstrap/_common.py
+++ b/lib/spack/spack/bootstrap/_common.py
@@ -16,6 +16,7 @@ import archspec.cpu
import llnl.util.filesystem as fs
from llnl.util import tty
+import spack.platforms
import spack.store
import spack.util.environment
import spack.util.executable
@@ -206,17 +207,19 @@ def _root_spec(spec_str: str) -> str:
"""Add a proper compiler and target to a spec used during bootstrapping.
Args:
- spec_str (str): spec to be bootstrapped. Must be without compiler and target.
+ spec_str: spec to be bootstrapped. Must be without compiler and target.
"""
- # Add a proper compiler hint to the root spec. We use GCC for
- # everything but MacOS and Windows.
- if str(spack.platforms.host()) == "darwin":
+ # Add a compiler requirement to the root spec.
+ platform = str(spack.platforms.host())
+ if platform == "darwin":
spec_str += " %apple-clang"
- elif str(spack.platforms.host()) == "windows":
+ elif platform == "windows":
# TODO (johnwparent): Remove version constraint when clingo patch is up
spec_str += " %msvc@:19.37"
- else:
+ elif platform == "linux":
spec_str += " %gcc"
+ elif platform == "freebsd":
+ spec_str += " %clang"
target = archspec.cpu.host().family
spec_str += f" target={target}"
diff --git a/lib/spack/spack/operating_systems/__init__.py b/lib/spack/spack/operating_systems/__init__.py
index 7caf70324b..5f85c13a61 100644
--- a/lib/spack/spack/operating_systems/__init__.py
+++ b/lib/spack/spack/operating_systems/__init__.py
@@ -5,11 +5,20 @@
from ._operating_system import OperatingSystem
from .cray_backend import CrayBackend
from .cray_frontend import CrayFrontend
+from .freebsd import FreeBSDOs
from .linux_distro import LinuxDistro
from .mac_os import MacOs
from .windows_os import WindowsOs
-__all__ = ["OperatingSystem", "LinuxDistro", "MacOs", "CrayFrontend", "CrayBackend", "WindowsOs"]
+__all__ = [
+ "OperatingSystem",
+ "LinuxDistro",
+ "MacOs",
+ "CrayFrontend",
+ "CrayBackend",
+ "WindowsOs",
+ "FreeBSDOs",
+]
#: List of all the Operating Systems known to Spack
-operating_systems = [LinuxDistro, MacOs, CrayFrontend, CrayBackend, WindowsOs]
+operating_systems = [LinuxDistro, MacOs, CrayFrontend, CrayBackend, WindowsOs, FreeBSDOs]
diff --git a/lib/spack/spack/operating_systems/freebsd.py b/lib/spack/spack/operating_systems/freebsd.py
new file mode 100644
index 0000000000..2b99db8720
--- /dev/null
+++ b/lib/spack/spack/operating_systems/freebsd.py
@@ -0,0 +1,15 @@
+# Copyright 2013-2023 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)
+import platform as py_platform
+
+from spack.version import Version
+
+from ._operating_system import OperatingSystem
+
+
+class FreeBSDOs(OperatingSystem):
+ def __init__(self):
+ release = py_platform.release().split("-", 1)[0]
+ super().__init__("freebsd", Version(release))
diff --git a/lib/spack/spack/platforms/__init__.py b/lib/spack/spack/platforms/__init__.py
index 1a41d26971..cf4e1410bd 100644
--- a/lib/spack/spack/platforms/__init__.py
+++ b/lib/spack/spack/platforms/__init__.py
@@ -8,6 +8,7 @@ from ._functions import _host, by_name, platforms, prevent_cray_detection, reset
from ._platform import Platform
from .cray import Cray
from .darwin import Darwin
+from .freebsd import FreeBSD
from .linux import Linux
from .test import Test
from .windows import Windows
@@ -17,6 +18,7 @@ __all__ = [
"Cray",
"Darwin",
"Linux",
+ "FreeBSD",
"Test",
"Windows",
"platforms",
diff --git a/lib/spack/spack/platforms/_functions.py b/lib/spack/spack/platforms/_functions.py
index bfd035c375..b2933f64aa 100644
--- a/lib/spack/spack/platforms/_functions.py
+++ b/lib/spack/spack/platforms/_functions.py
@@ -10,12 +10,13 @@ import spack.util.environment
from .cray import Cray
from .darwin import Darwin
+from .freebsd import FreeBSD
from .linux import Linux
from .test import Test
from .windows import Windows
#: List of all the platform classes known to Spack
-platforms = [Cray, Darwin, Linux, Windows, Test]
+platforms = [Cray, Darwin, Linux, Windows, FreeBSD, Test]
@llnl.util.lang.memoized
diff --git a/lib/spack/spack/platforms/freebsd.py b/lib/spack/spack/platforms/freebsd.py
new file mode 100644
index 0000000000..a0171d11ed
--- /dev/null
+++ b/lib/spack/spack/platforms/freebsd.py
@@ -0,0 +1,37 @@
+# Copyright 2013-2023 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)
+import platform
+
+import archspec.cpu
+
+import spack.target
+from spack.operating_systems.freebsd import FreeBSDOs
+
+from ._platform import Platform
+
+
+class FreeBSD(Platform):
+ priority = 102
+
+ def __init__(self):
+ super().__init__("freebsd")
+
+ for name in archspec.cpu.TARGETS:
+ self.add_target(name, spack.target.Target(name))
+
+ # Get specific default
+ self.default = archspec.cpu.host().name
+ self.front_end = self.default
+ self.back_end = self.default
+
+ os = FreeBSDOs()
+ self.default_os = str(os)
+ self.front_os = self.default_os
+ self.back_os = self.default_os
+ self.add_operating_system(str(os), os)
+
+ @classmethod
+ def detect(cls):
+ return platform.system().lower() == "freebsd"
diff --git a/var/spack/repos/builtin/packages/clingo/package.py b/var/spack/repos/builtin/packages/clingo/package.py
index f64dc6e812..eaf4c6ad92 100644
--- a/var/spack/repos/builtin/packages/clingo/package.py
+++ b/var/spack/repos/builtin/packages/clingo/package.py
@@ -50,6 +50,7 @@ class Clingo(CMakePackage):
depends_on("re2c@0.13:", type="build")
depends_on("bison@2.5:", type="build", when="platform=linux")
depends_on("bison@2.5:", type="build", when="platform=darwin")
+ depends_on("bison@2.5:", type="build", when="platform=freebsd")
depends_on("bison@2.5:", type="build", when="platform=cray")
with when("platform=windows"):
@@ -61,8 +62,9 @@ class Clingo(CMakePackage):
depends_on("python", type=("build", "link", "run"))
# Clingo 5.5.0 supports Python 3.6 or later and needs CFFI
depends_on("python@3.6.0:", type=("build", "link", "run"), when="@5.5.0:")
- depends_on("py-cffi", type=("build", "run"), when="@5.5.0: platform=darwin")
depends_on("py-cffi", type=("build", "run"), when="@5.5.0: platform=linux")
+ depends_on("py-cffi", type=("build", "run"), when="@5.5.0: platform=darwin")
+ depends_on("py-cffi", type=("build", "run"), when="@5.5.0: platform=freebsd")
depends_on("py-cffi", type=("build", "run"), when="@5.5.0: platform=cray")
patch("python38.patch", when="@5.3:5.4.0")
diff --git a/var/spack/repos/builtin/packages/expat/package.py b/var/spack/repos/builtin/packages/expat/package.py
index c6a5fae505..45142ea1a5 100644
--- a/var/spack/repos/builtin/packages/expat/package.py
+++ b/var/spack/repos/builtin/packages/expat/package.py
@@ -105,7 +105,7 @@ class Expat(AutotoolsPackage, CMakePackage):
# `~libbsd`.
variant(
"libbsd",
- default=sys.platform != "darwin" and sys.platform != "win32",
+ default=sys.platform == "linux",
description="Use libbsd (for high quality randomness)",
)
diff --git a/var/spack/repos/builtin/packages/krb5/freebsd-link.patch b/var/spack/repos/builtin/packages/krb5/freebsd-link.patch
new file mode 100644
index 0000000000..76f49a44fd
--- /dev/null
+++ b/var/spack/repos/builtin/packages/krb5/freebsd-link.patch
@@ -0,0 +1,11 @@
+--- a/src/config/shlib.conf
++++ b/src/config/shlib.conf
+@@ -327,7 +327,7 @@ mips-*-netbsd*)
+ CC_LINK_SHARED='$(CC) $(PROG_LIBPATH) $(PROG_RPATH_FLAGS) $(CFLAGS) $(LDFLAGS)'
+ CXX_LINK_SHARED='$(CXX) $(PROG_LIBPATH) $(PROG_RPATH_FLAGS) $(CXXFLAGS) $(LDFLAGS)'
+ SHLIBEXT=.so
+- LDCOMBINE='ld -Bshareable'
++ LDCOMBINE='$(CC) -shared'
+ SHLIB_RPATH_FLAGS='--enable-new-dtags -rpath $(SHLIB_RDIRS)'
+ SHLIB_EXPFLAGS='$(SHLIB_RPATH_FLAGS) $(SHLIB_DIRS) $(SHLIB_EXPLIBS)'
+ CC_LINK_STATIC='$(CC) $(PROG_LIBPATH) $(CFLAGS) $(LDFLAGS)'
diff --git a/var/spack/repos/builtin/packages/krb5/package.py b/var/spack/repos/builtin/packages/krb5/package.py
index 84dc616066..ad1ea1cd99 100644
--- a/var/spack/repos/builtin/packages/krb5/package.py
+++ b/var/spack/repos/builtin/packages/krb5/package.py
@@ -42,6 +42,7 @@ class Krb5(AutotoolsPackage):
)
# This patch is applied in newer upstream releases
patch("mit-krb5-1.17-static-libs.patch", level=0, when="@:1.18.9")
+ patch("freebsd-link.patch", when="platform=freebsd")
configure_directory = "src"
build_directory = "src"
diff --git a/var/spack/repos/builtin/packages/libbsd/package.py b/var/spack/repos/builtin/packages/libbsd/package.py
index 070ebd7656..e31ce810cf 100644
--- a/var/spack/repos/builtin/packages/libbsd/package.py
+++ b/var/spack/repos/builtin/packages/libbsd/package.py
@@ -35,6 +35,8 @@ class Libbsd(AutotoolsPackage):
patch("cdefs.h.patch", when="@0.8.6 %gcc@:4")
patch("local-elf.h.patch", when="@:0.10 %intel")
+ conflicts("platform=freebsd")
+
# https://gitlab.freedesktop.org/libbsd/libbsd/issues/1
conflicts("platform=darwin")