From e14b4c223813e1f5440057303f1cb053fc915e29 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Tue, 8 Aug 2023 10:52:58 +0100 Subject: [PATCH 1/3] lisa._kmod: Fix use of arch vs abi FIX The ABI (as defined by devlib) is the common currency. The "arch" is used with different meaning: * Kbuild ARCH= parameter * QEMU architecture * Alpine Linux architecture Ensure that all uses of "abi" and "arch" are as expected. --- lisa/_kmod.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisa/_kmod.py b/lisa/_kmod.py index 08f37ec1f..b01aa118f 100644 --- a/lisa/_kmod.py +++ b/lisa/_kmod.py @@ -1060,7 +1060,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): else: raise ValueError('The ABI must be specified or the ARCH make variable') - abi = abi or _kernel_arch_to_abi(arch) + abi = abi or _kernel_arch_to_abi(arch) make_vars['ARCH'] = arch build_conf = build_conf.add_src( @@ -1090,7 +1090,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): # can confuse KBuild. make_vars['CC'] = cc assert 'ARCH' in make_vars - return (make_vars, cc, arch) + return (make_vars, cc, abi) @classmethod def _make_toolchain_env(cls, toolchain_path=None, env=None): -- GitLab From 3786bcdac3f63ab95dabbcea323053b309882d20 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Tue, 8 Aug 2023 11:05:13 +0100 Subject: [PATCH 2/3] lisa._kmod: Autodetect arm-none-eabi- toolchain for armv7 FIX Autodetect both arm-none-eabi- and arm-linux-gnueabi for armv7 architecture. --- lisa/_kmod.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lisa/_kmod.py b/lisa/_kmod.py index b01aa118f..5f1b01685 100644 --- a/lisa/_kmod.py +++ b/lisa/_kmod.py @@ -1134,6 +1134,19 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): make_vars = build_conf.get('make-variables', {}) + def pick_first(toolchains): + found = [ + toolchain + for toolchain in toolchains + if shutil.which(f'{toolchain}gcc') is not None + ] + # If no toolchain is found, we pick the first one that will be used + # for clang target triplet + try: + return found[0] + except IndexError: + return toolchains[0] + if abi == LISA_HOST_ABI: toolchain = None else: @@ -1146,7 +1159,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): if abi == 'arm64': toolchain = 'aarch64-linux-gnu-' elif abi == 'armeabi': - toolchain = 'arm-linux-gnueabi-' + toolchain = pick_first(['arm-linux-gnueabi-', 'arm-none-eabi-']) elif abi == 'x86': toolchain = 'i686-linux-gnu-' else: -- GitLab From 30c67d31b936ef798c0242c2d2b98f649d565383 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Tue, 8 Aug 2023 11:13:06 +0100 Subject: [PATCH 3/3] lisa._kmod: Allow aarch64-none-elf- toolchain autodetection FIX Allow autodetection of aarch64-none-elf- toolchain. --- lisa/_kmod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisa/_kmod.py b/lisa/_kmod.py index 5f1b01685..57361583a 100644 --- a/lisa/_kmod.py +++ b/lisa/_kmod.py @@ -1157,7 +1157,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): toolchain = os.environ['CROSS_COMPILE'] except KeyError: if abi == 'arm64': - toolchain = 'aarch64-linux-gnu-' + toolchain = pick_first(['aarch64-linux-gnu-', 'aarch64-none-elf-']) elif abi == 'armeabi': toolchain = pick_first(['arm-linux-gnueabi-', 'arm-none-eabi-']) elif abi == 'x86': -- GitLab