Skip to content

Commit

Permalink
tc_build: kernel: Add support for LoongArch
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Chancellor <[email protected]>
  • Loading branch information
nathanchance committed Jan 11, 2024
1 parent 27795e6 commit 94544e3
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions tc_build/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ def __init__(self):
super().__init__('hexagon')


class LoongArchKernelBuilder(KernelBuilder):

def __init__(self):
super().__init__('loongarch')

def build(self):
self.toolchain_version = self.get_toolchain_version()
# https://git.kernel.org/linus/4d35d6e56447a5d09ccd1c1b3a6d3783b2947670
if self.toolchain_version < (min_version := (18, 0, 0)):
tc_build.utils.print_warning(
f"LoongArch does not build with LLVM < {'.'.join(map(str, min_version))}, skipping build..."
)
return

super().build()


class MIPSKernelBuilder(KernelBuilder):

def __init__(self):
Expand Down Expand Up @@ -281,6 +298,9 @@ def __init__(self):
self.toolchain_prefix = None

def build(self):
lsm = LinuxSourceManager()
lsm.location = self.folders.source

builders = []

allconfig_capable_builders = {
Expand All @@ -293,6 +313,14 @@ def build(self):
'X86': X8664KernelBuilder,
}

# https://git.kernel.org/stable/c/ab3f300524697919f64ae920e904d0836b4057b0
# is needed to build ARCH=loongarch without disabling any
# configurations (in addition to a copy of clang > 18.0.0 but that is
# check when the build is invoked because it depends on the build of
# the compiler).
if lsm.get_version() >= (6, 6, 8):
allconfig_capable_builders['LoongArch'] = LoongArchKernelBuilder

# This is a little convoluted :/
# The overall idea here is to avoid duplicating builds, so the
# matrix consists of a series of configuration targets ("defconfig",
Expand Down Expand Up @@ -322,8 +350,6 @@ def build(self):
builder.config_targets = [config_target]
builders.append(builder)

lsm = LinuxSourceManager()
lsm.location = self.folders.source
tc_build.utils.print_info(f"Building Linux {lsm.get_kernelversion()} for profiling...")

for builder in builders:
Expand Down

0 comments on commit 94544e3

Please sign in to comment.