Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mpfr project needed for GDB 14 #388

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pycheribuild/projects/cross/gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
MakeCommandKind,
)
from .gmp import BuildGmp
from .mpfr import BuildMpfr
from ..project import ComputedDefaultValue
from ...utils import OSInfo

Expand Down Expand Up @@ -75,7 +76,7 @@ def dependencies(cls, config: CheriConfig) -> "tuple[str, ...]":
deps = super().dependencies(config)
# For the native and native-hybrid builds gmp must be installed via ports.
if not cls.get_crosscompile_target().is_native():
deps += ("gmp",)
deps += ("gmp", "mpfr")
return deps

@classmethod
Expand All @@ -93,6 +94,7 @@ def check_system_dependencies(self) -> None:
self.check_required_system_tool("makeinfo", default="texinfo")
if self.compiling_for_host() and self.target_info.is_cheribsd():
self.check_required_pkg_config("gmp", freebsd="gmp")
self.check_required_pkg_config("mpfr", freebsd="mpfr")
self.check_required_pkg_config("expat", freebsd="expat")

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -169,6 +171,7 @@ def setup(self) -> None:
MAKEINFO="/bin/false",
)
self.configure_args.append("--with-gmp=" + str(BuildGmp.get_install_dir(self)))
self.configure_args.append("--with-mpfr=" + str(BuildMpfr.get_install_dir(self)))
# GDB > 12 only uses --with-gmp
self.configure_args.append("--with-libgmp-prefix=" + str(BuildGmp.get_install_dir(self)))
# Autoconf stupidly decides which to use based on file existence
Expand Down
5 changes: 5 additions & 0 deletions pycheribuild/projects/cross/gmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ def setup(self):
def configure(self, **kwargs):
self.run_cmd("./.bootstrap", cwd=self.source_dir)
super().configure(**kwargs)

def install(self, **kwargs):
super().install(**kwargs)
if not self.compiling_for_host():
self.delete_file(self.install_dir / "lib/libgmp.la", warn_if_missing=True)
57 changes: 57 additions & 0 deletions pycheribuild/projects/cross/mpfr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2024 John Baldwin
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

from .crosscompileproject import (
CrossCompileAutotoolsProject,
DefaultInstallDir,
GitRepository,
)
from .gmp import BuildGmp
from ...config.compilation_targets import CompilationTargets


class BuildMpfr(CrossCompileAutotoolsProject):
repository = GitRepository("https://gitlab.inria.fr/mpfr/mpfr.git")
supported_architectures = (CompilationTargets.ALL_CHERIBSD_TARGETS_WITH_HYBRID +
CompilationTargets.ALL_CHERIBSD_HYBRID_FOR_PURECAP_ROOTFS_TARGETS +
CompilationTargets.ALL_SUPPORTED_FREEBSD_TARGETS + CompilationTargets.ALL_NATIVE)
native_install_dir = DefaultInstallDir.CHERI_SDK

def check_system_dependencies(self) -> None:
super().check_system_dependencies()
# It would be nice if we could just disable building documentation, but until we can do so, missing makeinfo
# results in failing build
self.check_required_system_tool("makeinfo", default="texinfo")
if self.compiling_for_host():
self.check_required_pkg_config("gmp", freebsd="gmp")

def setup(self):
super().setup()
self.configure_args.append("--with-gmp=" + str(BuildGmp.get_install_dir(self)))

def install(self, **kwargs):
super().install(**kwargs)
if not self.compiling_for_host():
self.delete_file(self.install_dir / "lib/libmpfr.la", warn_if_missing=True)
1 change: 1 addition & 0 deletions tests/test_argument_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def test_skip_update():
"llvm-native",
"cheribsd-riscv64-purecap",
"gmp-riscv64-hybrid-for-purecap-rootfs",
"mpfr-riscv64-hybrid-for-purecap-rootfs",
"gdb-riscv64-hybrid-for-purecap-rootfs",
"bbl-baremetal-riscv64-purecap",
"disk-image-riscv64-purecap",
Expand Down
41 changes: 37 additions & 4 deletions tests/test_target_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from pycheribuild.projects.cross.gdb import BuildGDBBase
from pycheribuild.projects.cross.gmp import BuildGmp
from pycheribuild.projects.cross.llvm import BuildCheriLLVM, BuildMorelloLLVM
from pycheribuild.projects.cross.mpfr import BuildMpfr
from pycheribuild.projects.cross.qt5 import BuildQtBase
from pycheribuild.projects.disk_image import BuildDiskImageBase
from pycheribuild.projects.project import DefaultInstallDir, Project
Expand Down Expand Up @@ -187,6 +188,7 @@ def test_build_and_run(target_name: str, expected_list: "list[str]"):
"morello-llvm-native",
"cheribsd-morello-hybrid",
"gmp-morello-hybrid",
"mpfr-morello-hybrid",
"gdb-morello-hybrid",
"disk-image-morello-hybrid",
],
Expand All @@ -199,14 +201,23 @@ def test_build_and_run(target_name: str, expected_list: "list[str]"):
"morello-llvm-native",
"cheribsd-morello-purecap",
"gmp-morello-hybrid-for-purecap-rootfs",
"mpfr-morello-hybrid-for-purecap-rootfs",
"gdb-morello-hybrid-for-purecap-rootfs",
"disk-image-morello-purecap",
],
),
pytest.param(
"run-riscv64",
True,
["qemu", "llvm-native", "cheribsd-riscv64", "gmp-riscv64", "gdb-riscv64", "disk-image-riscv64"],
[
"qemu",
"llvm-native",
"cheribsd-riscv64",
"gmp-riscv64",
"mpfr-riscv64",
"gdb-riscv64",
"disk-image-riscv64",
],
),
pytest.param(
"run-riscv64-hybrid",
Expand All @@ -216,6 +227,7 @@ def test_build_and_run(target_name: str, expected_list: "list[str]"):
"llvm-native",
"cheribsd-riscv64-hybrid",
"gmp-riscv64-hybrid",
"mpfr-riscv64-hybrid",
"gdb-riscv64-hybrid",
"bbl-baremetal-riscv64-purecap",
"disk-image-riscv64-hybrid",
Expand All @@ -229,6 +241,7 @@ def test_build_and_run(target_name: str, expected_list: "list[str]"):
"llvm-native",
"cheribsd-riscv64-purecap",
"gmp-riscv64-hybrid-for-purecap-rootfs",
"mpfr-riscv64-hybrid-for-purecap-rootfs",
"gdb-riscv64-hybrid-for-purecap-rootfs",
"bbl-baremetal-riscv64-purecap",
"disk-image-riscv64-purecap",
Expand All @@ -237,12 +250,28 @@ def test_build_and_run(target_name: str, expected_list: "list[str]"):
pytest.param(
"run-aarch64",
True,
["qemu", "llvm-native", "cheribsd-aarch64", "gmp-aarch64", "gdb-aarch64", "disk-image-aarch64"],
[
"qemu",
"llvm-native",
"cheribsd-aarch64",
"gmp-aarch64",
"mpfr-aarch64",
"gdb-aarch64",
"disk-image-aarch64",
],
),
pytest.param(
"run-amd64",
True,
["qemu", "llvm-native", "cheribsd-amd64", "gmp-amd64", "gdb-amd64", "disk-image-amd64"],
[
"qemu",
"llvm-native",
"cheribsd-amd64",
"gmp-amd64",
"mpfr-amd64",
"gdb-amd64",
"disk-image-amd64",
],
),
# Morello code won't run on QEMU (yet)
pytest.param(
Expand All @@ -253,6 +282,7 @@ def test_build_and_run(target_name: str, expected_list: "list[str]"):
"morello-llvm-native",
"cheribsd-morello-hybrid",
"gmp-morello-hybrid",
"mpfr-morello-hybrid",
"gdb-morello-hybrid",
"morello-firmware",
"disk-image-morello-hybrid",
Expand All @@ -266,6 +296,7 @@ def test_build_and_run(target_name: str, expected_list: "list[str]"):
"morello-llvm-native",
"cheribsd-morello-purecap",
"gmp-morello-hybrid-for-purecap-rootfs",
"mpfr-morello-hybrid-for-purecap-rootfs",
"gdb-morello-hybrid-for-purecap-rootfs",
"morello-firmware",
"disk-image-morello-purecap",
Expand Down Expand Up @@ -532,6 +563,7 @@ def test_riscv():
"llvm-native",
"cheribsd-riscv64",
"gmp-riscv64",
"mpfr-riscv64",
"gdb-riscv64",
"disk-image-riscv64",
]
Expand All @@ -540,6 +572,7 @@ def test_riscv():
"llvm-native",
"cheribsd-riscv64",
"gmp-riscv64",
"mpfr-riscv64",
"gdb-riscv64",
"disk-image-riscv64",
"run-riscv64",
Expand Down Expand Up @@ -697,7 +730,7 @@ def should_include_target(target: Target):
return False

# Finally, filter out dependencies of any of the above:
if issubclass(cls, BuildGmp):
if issubclass(cls, (BuildGmp, BuildMpfr)):
return False

# Otherwise this target is unexpected
Expand Down
Loading