minimal support for freebsd (#41434)

This commit is contained in:
Harmen Stoppels 2023-12-06 11:27:22 +01:00 committed by GitHub
parent f7fc4b201d
commit 4fc73bd7f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 94 additions and 11 deletions

View File

@ -16,6 +16,7 @@
import llnl.util.filesystem as fs import llnl.util.filesystem as fs
from llnl.util import tty from llnl.util import tty
import spack.platforms
import spack.store import spack.store
import spack.util.environment import spack.util.environment
import spack.util.executable 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. """Add a proper compiler and target to a spec used during bootstrapping.
Args: 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 # Add a compiler requirement to the root spec.
# everything but MacOS and Windows. platform = str(spack.platforms.host())
if str(spack.platforms.host()) == "darwin": if platform == "darwin":
spec_str += " %apple-clang" spec_str += " %apple-clang"
elif str(spack.platforms.host()) == "windows": elif platform == "windows":
# TODO (johnwparent): Remove version constraint when clingo patch is up # TODO (johnwparent): Remove version constraint when clingo patch is up
spec_str += " %msvc@:19.37" spec_str += " %msvc@:19.37"
else: elif platform == "linux":
spec_str += " %gcc" spec_str += " %gcc"
elif platform == "freebsd":
spec_str += " %clang"
target = archspec.cpu.host().family target = archspec.cpu.host().family
spec_str += f" target={target}" spec_str += f" target={target}"

View File

@ -5,11 +5,20 @@
from ._operating_system import OperatingSystem from ._operating_system import OperatingSystem
from .cray_backend import CrayBackend from .cray_backend import CrayBackend
from .cray_frontend import CrayFrontend from .cray_frontend import CrayFrontend
from .freebsd import FreeBSDOs
from .linux_distro import LinuxDistro from .linux_distro import LinuxDistro
from .mac_os import MacOs from .mac_os import MacOs
from .windows_os import WindowsOs 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 #: List of all the Operating Systems known to Spack
operating_systems = [LinuxDistro, MacOs, CrayFrontend, CrayBackend, WindowsOs] operating_systems = [LinuxDistro, MacOs, CrayFrontend, CrayBackend, WindowsOs, FreeBSDOs]

View File

@ -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))

View File

@ -8,6 +8,7 @@
from ._platform import Platform from ._platform import Platform
from .cray import Cray from .cray import Cray
from .darwin import Darwin from .darwin import Darwin
from .freebsd import FreeBSD
from .linux import Linux from .linux import Linux
from .test import Test from .test import Test
from .windows import Windows from .windows import Windows
@ -17,6 +18,7 @@
"Cray", "Cray",
"Darwin", "Darwin",
"Linux", "Linux",
"FreeBSD",
"Test", "Test",
"Windows", "Windows",
"platforms", "platforms",

View File

@ -10,12 +10,13 @@
from .cray import Cray from .cray import Cray
from .darwin import Darwin from .darwin import Darwin
from .freebsd import FreeBSD
from .linux import Linux from .linux import Linux
from .test import Test from .test import Test
from .windows import Windows from .windows import Windows
#: List of all the platform classes known to Spack #: 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 @llnl.util.lang.memoized

View File

@ -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"

View File

@ -50,6 +50,7 @@ class Clingo(CMakePackage):
depends_on("re2c@0.13:", type="build") 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=linux")
depends_on("bison@2.5:", type="build", when="platform=darwin") 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") depends_on("bison@2.5:", type="build", when="platform=cray")
with when("platform=windows"): with when("platform=windows"):
@ -61,8 +62,9 @@ class Clingo(CMakePackage):
depends_on("python", type=("build", "link", "run")) depends_on("python", type=("build", "link", "run"))
# Clingo 5.5.0 supports Python 3.6 or later and needs CFFI # 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("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=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") depends_on("py-cffi", type=("build", "run"), when="@5.5.0: platform=cray")
patch("python38.patch", when="@5.3:5.4.0") patch("python38.patch", when="@5.3:5.4.0")

View File

@ -105,7 +105,7 @@ class Expat(AutotoolsPackage, CMakePackage):
# `~libbsd`. # `~libbsd`.
variant( variant(
"libbsd", "libbsd",
default=sys.platform != "darwin" and sys.platform != "win32", default=sys.platform == "linux",
description="Use libbsd (for high quality randomness)", description="Use libbsd (for high quality randomness)",
) )

View File

@ -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)'

View File

@ -42,6 +42,7 @@ class Krb5(AutotoolsPackage):
) )
# This patch is applied in newer upstream releases # This patch is applied in newer upstream releases
patch("mit-krb5-1.17-static-libs.patch", level=0, when="@:1.18.9") patch("mit-krb5-1.17-static-libs.patch", level=0, when="@:1.18.9")
patch("freebsd-link.patch", when="platform=freebsd")
configure_directory = "src" configure_directory = "src"
build_directory = "src" build_directory = "src"

View File

@ -35,6 +35,8 @@ class Libbsd(AutotoolsPackage):
patch("cdefs.h.patch", when="@0.8.6 %gcc@:4") patch("cdefs.h.patch", when="@0.8.6 %gcc@:4")
patch("local-elf.h.patch", when="@:0.10 %intel") patch("local-elf.h.patch", when="@:0.10 %intel")
conflicts("platform=freebsd")
# https://gitlab.freedesktop.org/libbsd/libbsd/issues/1 # https://gitlab.freedesktop.org/libbsd/libbsd/issues/1
conflicts("platform=darwin") conflicts("platform=darwin")