Skip to content

Commit

Permalink
seL4: Add new compilation targets
Browse files Browse the repository at this point in the history
  • Loading branch information
heshamelmatary committed Jul 12, 2023
1 parent 795bc25 commit a932caa
Showing 1 changed file with 75 additions and 1 deletion.
76 changes: 75 additions & 1 deletion pycheribuild/config/compilation_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,75 @@ def base_sysroot_targets(cls, target: "CrossCompileTarget", config: "CheriConfig
assert False, "No support for building RTEMS for non RISC-V targets yet"


class Sel4TargetInfo(_ClangBasedTargetInfo):
shortname: str = "sel4"

@property
def cmake_system_name(self) -> str:
return "sel4"

@classmethod
def is_sel4(cls) -> bool:
return True

@classmethod
def is_baremetal(cls) -> bool:
return True

@classmethod
def triple_for_target(cls, target: "CrossCompileTarget", config: "CheriConfig", *, include_version: bool):
return target.cpu_architecture.value + "-none-elf"

@property
def sysroot_dir(self):
return self.config.sysroot_output_root / self.config.default_morello_sdk_directory_name / (
self.target.get_rootfs_target().generic_arch_suffix) / self.target_triple

@classmethod
def _get_compiler_project(cls) -> "type[BuildLLVMMonoRepoBase]":
from ..projects.cross.llvm import BuildCheriLLVM
return BuildCheriLLVM

@property
def must_link_statically(self):
return True # only static linking works


class Sel4MorelloTargetInfo(_ClangBasedTargetInfo):
shortname: str = "sel4"
uses_morello_llvm: bool = True

@property
def cmake_system_name(self) -> str:
return "sel4"

@classmethod
def is_sel4(cls) -> bool:
return True

@classmethod
def is_baremetal(cls) -> bool:
return True

@classmethod
def triple_for_target(cls, target: "CrossCompileTarget", config: "CheriConfig", *, include_version: bool):
return target.cpu_architecture.value + "-none-elf"

@property
def sysroot_dir(self):
return self.config.sysroot_output_root / self.config.default_morello_sdk_directory_name / (
self.target.get_rootfs_target().generic_arch_suffix) / self.target_triple

@classmethod
def _get_compiler_project(cls) -> "type[BuildLLVMMonoRepoBase]":
from ..projects.cross.llvm import BuildMorelloLLVM
return BuildMorelloLLVM

@property
def must_link_statically(self):
return True # only static linking works


class BaremetalClangTargetInfo(_ClangBasedTargetInfo, metaclass=ABCMeta):
@property
def cmake_system_name(self) -> str:
Expand Down Expand Up @@ -1192,6 +1261,11 @@ class CompilationTargets(BasicCompilationTargets):
RTEMS_RISCV64 = CrossCompileTarget("riscv64", CPUArchitecture.RISCV64, RTEMSTargetInfo)
RTEMS_RISCV64_PURECAP = CrossCompileTarget("riscv64-purecap", CPUArchitecture.RISCV64, RTEMSTargetInfo,
is_cheri_purecap=True, non_cheri_target=RTEMS_RISCV64)
# seL4 targets
SEL4_RISCV64 = CrossCompileTarget("riscv64", CPUArchitecture.RISCV64, Sel4TargetInfo)
SEL4_MORELLO_NO_CHERI = CrossCompileTarget("morello-aarch64", CPUArchitecture.AARCH64,
Sel4MorelloTargetInfo)
ALL_SUPPORTED_SEL4_TARGETS = (SEL4_RISCV64, SEL4_MORELLO_NO_CHERI)

ALL_CHERIBSD_RISCV_TARGETS = (CHERIBSD_RISCV_PURECAP, CHERIBSD_RISCV_HYBRID, CHERIBSD_RISCV_NO_CHERI)
ALL_CHERIBSD_NON_MORELLO_TARGETS = (*ALL_CHERIBSD_RISCV_TARGETS, CHERIBSD_AARCH64, CHERIBSD_X86_64)
Expand Down Expand Up @@ -1222,7 +1296,7 @@ class CompilationTargets(BasicCompilationTargets):
ALL_SUPPORTED_CHERIBSD_AND_HOST_TARGETS = ALL_SUPPORTED_CHERIBSD_TARGETS + BasicCompilationTargets.ALL_NATIVE
ALL_FREEBSD_AND_CHERIBSD_TARGETS = ALL_SUPPORTED_CHERIBSD_TARGETS + ALL_SUPPORTED_FREEBSD_TARGETS

ALL_SUPPORTED_BAREMETAL_TARGETS = ALL_NEWLIB_TARGETS + ALL_PICOLIBC_TARGETS
ALL_SUPPORTED_BAREMETAL_TARGETS = ALL_NEWLIB_TARGETS + ALL_PICOLIBC_TARGETS + ALL_SUPPORTED_SEL4_TARGETS
ALL_SUPPORTED_RTEMS_TARGETS = (RTEMS_RISCV64, RTEMS_RISCV64_PURECAP)
ALL_SUPPORTED_CHERIBSD_AND_BAREMETAL_AND_HOST_TARGETS = \
ALL_SUPPORTED_CHERIBSD_AND_HOST_TARGETS + ALL_SUPPORTED_BAREMETAL_TARGETS
Expand Down

0 comments on commit a932caa

Please sign in to comment.