summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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
6 files changed, 76 insertions, 9 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"