Skip to content

Commit a932caa

Browse files
seL4: Add new compilation targets
1 parent 795bc25 commit a932caa

File tree

1 file changed

+75
-1
lines changed

1 file changed

+75
-1
lines changed

pycheribuild/config/compilation_targets.py

+75-1
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,75 @@ def base_sysroot_targets(cls, target: "CrossCompileTarget", config: "CheriConfig
761761
assert False, "No support for building RTEMS for non RISC-V targets yet"
762762

763763

764+
class Sel4TargetInfo(_ClangBasedTargetInfo):
765+
shortname: str = "sel4"
766+
767+
@property
768+
def cmake_system_name(self) -> str:
769+
return "sel4"
770+
771+
@classmethod
772+
def is_sel4(cls) -> bool:
773+
return True
774+
775+
@classmethod
776+
def is_baremetal(cls) -> bool:
777+
return True
778+
779+
@classmethod
780+
def triple_for_target(cls, target: "CrossCompileTarget", config: "CheriConfig", *, include_version: bool):
781+
return target.cpu_architecture.value + "-none-elf"
782+
783+
@property
784+
def sysroot_dir(self):
785+
return self.config.sysroot_output_root / self.config.default_morello_sdk_directory_name / (
786+
self.target.get_rootfs_target().generic_arch_suffix) / self.target_triple
787+
788+
@classmethod
789+
def _get_compiler_project(cls) -> "type[BuildLLVMMonoRepoBase]":
790+
from ..projects.cross.llvm import BuildCheriLLVM
791+
return BuildCheriLLVM
792+
793+
@property
794+
def must_link_statically(self):
795+
return True # only static linking works
796+
797+
798+
class Sel4MorelloTargetInfo(_ClangBasedTargetInfo):
799+
shortname: str = "sel4"
800+
uses_morello_llvm: bool = True
801+
802+
@property
803+
def cmake_system_name(self) -> str:
804+
return "sel4"
805+
806+
@classmethod
807+
def is_sel4(cls) -> bool:
808+
return True
809+
810+
@classmethod
811+
def is_baremetal(cls) -> bool:
812+
return True
813+
814+
@classmethod
815+
def triple_for_target(cls, target: "CrossCompileTarget", config: "CheriConfig", *, include_version: bool):
816+
return target.cpu_architecture.value + "-none-elf"
817+
818+
@property
819+
def sysroot_dir(self):
820+
return self.config.sysroot_output_root / self.config.default_morello_sdk_directory_name / (
821+
self.target.get_rootfs_target().generic_arch_suffix) / self.target_triple
822+
823+
@classmethod
824+
def _get_compiler_project(cls) -> "type[BuildLLVMMonoRepoBase]":
825+
from ..projects.cross.llvm import BuildMorelloLLVM
826+
return BuildMorelloLLVM
827+
828+
@property
829+
def must_link_statically(self):
830+
return True # only static linking works
831+
832+
764833
class BaremetalClangTargetInfo(_ClangBasedTargetInfo, metaclass=ABCMeta):
765834
@property
766835
def cmake_system_name(self) -> str:
@@ -1192,6 +1261,11 @@ class CompilationTargets(BasicCompilationTargets):
11921261
RTEMS_RISCV64 = CrossCompileTarget("riscv64", CPUArchitecture.RISCV64, RTEMSTargetInfo)
11931262
RTEMS_RISCV64_PURECAP = CrossCompileTarget("riscv64-purecap", CPUArchitecture.RISCV64, RTEMSTargetInfo,
11941263
is_cheri_purecap=True, non_cheri_target=RTEMS_RISCV64)
1264+
# seL4 targets
1265+
SEL4_RISCV64 = CrossCompileTarget("riscv64", CPUArchitecture.RISCV64, Sel4TargetInfo)
1266+
SEL4_MORELLO_NO_CHERI = CrossCompileTarget("morello-aarch64", CPUArchitecture.AARCH64,
1267+
Sel4MorelloTargetInfo)
1268+
ALL_SUPPORTED_SEL4_TARGETS = (SEL4_RISCV64, SEL4_MORELLO_NO_CHERI)
11951269

11961270
ALL_CHERIBSD_RISCV_TARGETS = (CHERIBSD_RISCV_PURECAP, CHERIBSD_RISCV_HYBRID, CHERIBSD_RISCV_NO_CHERI)
11971271
ALL_CHERIBSD_NON_MORELLO_TARGETS = (*ALL_CHERIBSD_RISCV_TARGETS, CHERIBSD_AARCH64, CHERIBSD_X86_64)
@@ -1222,7 +1296,7 @@ class CompilationTargets(BasicCompilationTargets):
12221296
ALL_SUPPORTED_CHERIBSD_AND_HOST_TARGETS = ALL_SUPPORTED_CHERIBSD_TARGETS + BasicCompilationTargets.ALL_NATIVE
12231297
ALL_FREEBSD_AND_CHERIBSD_TARGETS = ALL_SUPPORTED_CHERIBSD_TARGETS + ALL_SUPPORTED_FREEBSD_TARGETS
12241298

1225-
ALL_SUPPORTED_BAREMETAL_TARGETS = ALL_NEWLIB_TARGETS + ALL_PICOLIBC_TARGETS
1299+
ALL_SUPPORTED_BAREMETAL_TARGETS = ALL_NEWLIB_TARGETS + ALL_PICOLIBC_TARGETS + ALL_SUPPORTED_SEL4_TARGETS
12261300
ALL_SUPPORTED_RTEMS_TARGETS = (RTEMS_RISCV64, RTEMS_RISCV64_PURECAP)
12271301
ALL_SUPPORTED_CHERIBSD_AND_BAREMETAL_AND_HOST_TARGETS = \
12281302
ALL_SUPPORTED_CHERIBSD_AND_HOST_TARGETS + ALL_SUPPORTED_BAREMETAL_TARGETS

0 commit comments

Comments
 (0)