• [gentoo-dev] [PATCH 0/3] eclass changes for supporting dist kernel on l

    From WANG Xuerui@21:1/5 to All on Sun Dec 17 13:20:02 2023
    Hi,

    In order to make dist-kernel working for loong, I've just done some
    preliminary work to enable builds with locally-provisioned savedconfig. Properly made and maintained defconfig (ideally, across distros that
    have a LoongArch port) will come later.

    For now, with these eclass changes and trivial ebuild additions, in the
    GitHub PR [1], I've been able to produce working kernels for both
    Loongson 3A6000 (desktop) and 3C5000L (server).

    Your review and comments are welcome!

    [1]: https://github.com/gentoo/gentoo/pull/34291

    WANG Xuerui (3):
    dist-kernel-utils.eclass: support loong in dist-kernel_get_image_path
    kernel-install.eclass: support loong in kernel-install_get_qemu_arch
    kernel-build.eclass: fix KERNEL_EFI_ZBOOT not being probed on
    partially supported arches

    eclass/dist-kernel-utils.eclass | 7 +++++++
    eclass/kernel-build.eclass | 12 ++++++------
    eclass/kernel-install.eclass | 3 +++
    3 files changed, 16 insertions(+), 6 deletions(-)

    --
    2.43.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From WANG Xuerui@21:1/5 to All on Sun Dec 17 13:20:02 2023
    The several partially-supported arches (those relying on
    USE=savedconfig) directly return in src_prepare(), hence previously the CONFIG_EFI_ZBOOT probing didn't have a chance to run when building for
    those arches, leading to wrong kernel artifact path and failed
    src_install().

    Move the probing to near the end of eclass src_configure(), so the flag correctly reflects the reality in all circumstances.

    Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
    ---
    eclass/kernel-build.eclass | 12 ++++++------
    1 file changed, 6 insertions(+), 6 deletions(-)

    diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
    index 6b692dc4f9a0..7a041a8aacdf 100644
    --- a/eclass/kernel-build.eclass
    +++ b/eclass/kernel-build.eclass
    @@ -203,6 +203,12 @@ kernel-build_src_configure() {
    .config)
    fi

    + # If this is set by USE=secureboot or user config this will have an effect
    + # on the name of the output image. Set this variable to track this setting.
    + if grep -q "CONFIG_EFI_ZBOOT=y" .config; then
    + KERNEL_EFI_ZBOOT=1
    + fi
    +
    mkdir -p "${WORKDIR}"/modprep || die
    mv .config "${WORKDIR}"/modprep/ || die
    emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" olddefconfig
    @@ -456,12 +462,6 @@ kernel-build_merge_configs() {

    ./scripts/kconfig/merge_config.sh -m -r \
    .config "${merge_configs[@]}" || die
    -
    - # If this is set by USE=secureboot or user config this will have an effect
    - # on the name of the output image. Set this variable to tr
  • From WANG Xuerui@21:1/5 to All on Sun Dec 17 13:20:02 2023
    The filenames to use are taken from upstream: https://github.com/torvalds/linux/blob/v6.6/arch/loongarch/boot/Makefile.

    Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
    ---
    eclass/dist-kernel-utils.eclass | 7 +++++++
    1 file changed, 7 insertions(+)

    diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index 62750d1721a2..67cb802151b2 100644
    --- a/eclass/dist-kernel-utils.eclass
    +++ b/eclass/dist-kernel-utils.eclass
    @@ -87,6 +87,13 @@ dist-kernel_get_image_path() {
    echo arch/${ARCH}/boot/Image.gz
    fi
    ;;
    + loong)
    + if [[ ${KERNEL_EFI_ZBOOT} ]]; then
    + echo arch/loongarch/boot/vmlinuz.efi
    + else
    + echo arch/loongarch/boot/vmlinux.elf
    + fi
    + ;;
    arm)
    echo arch/arm/boot/zImage
    ;;
    --
    2.43.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to WANG Xuerui on Sun Dec 17 14:20:02 2023
    On Sun, 2023-12-17 at 20:09 +0800, WANG Xuerui wrote:
    The several partially-supported arches (those relying on
    USE=savedconfig) directly return in src_prepare(), hence previously the CONFIG_EFI_ZBOOT probing didn't have a chance to run when building for
    those arches, leading to wrong kernel artifact path and failed
    src_install().

    Move the probing to near the end of eclass src_configure(), so the flag correctly reflects the reality in all circumstances.

    Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
    ---
    eclass/kernel-build.eclass | 12 ++++++------
    1 file changed, 6 insertions(+), 6 deletions(-)

    diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
    index 6b692dc4f9a0..7a041a8aacdf 100644
    --- a/eclass/kernel-build.eclass
    +++ b/eclass/kernel-build.eclass
    @@ -203,6 +203,12 @@ kernel-build_src_configure() {
    .config)
    fi

    + # If this is set by USE=secureboot or user config this will have an effect
    + # on the name of the output image. Set this variable to track this setting.
    + if grep -q "CONFIG_EFI_ZBOOT=y" .config; then
    + KERNEL_EFI_ZBOOT=1
    + fi
    +
    mkdir -p "${WORKDIR}"/modprep || die
    mv .config "${WORKDIR}"/modprep/ || die
    emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" olddefconfig
    @@ -456,12 +462,6 @@ kernel-build_merge_configs() {

    ./scripts/kconfig/merge_config.sh -m -r \
    .config "${merge_configs[@]}" || die
    -
    - # If this is set by USE=secureboot or user config this will have an effect
    - # on the name of the output image. Set this variable to track this setting.
    - if grep -q "CONFIG_EFI_ZBOOT=y" .config; then
    - KERNEL_EFI_ZBOOT=1
    - fi
    }

    fi

    This doesn't seem correct. It won't work if KERNEL_EFI_ZBOOT is set by
    one of the merged configs.

    --
    Best regards,
    Michał Górny


    -----BEGIN PGP SIGNATURE-----

    iQFGBAABCgAwFiEEx2qEUJQJjSjMiybFY5ra4jKeJA4FAmV+820SHG1nb3JueUBn ZW50b28ub3JnAAoJEGOa2uIyniQOlUAH/1gNjDcX1pTSjL7ZLmWy93VrYWLd8wlV TfY58kLXNG5JKD/1PfLbxzb5QwynY0qkTsOAQvuY1ud90zUvMmkhB0UxhQwfiYRF tpyUoBhMlht5Oo5kIb+DKdDk4knXZ8w1xrdXMkqdnEUzV+2j6MW7W3vvGoSlyvte kF3FuXFl6zzP579cTvGWH/2RQFWgEt1xa+OBXNuzR5DRQnVMLYO2FPk2GkWZi8JG v6DioSB1G+R8C1x+DzaRaXVP/mULH9zFb27HFlMKsAxPpg3H7GqmFFkoJd1WGTSe jm5ryrAfdJMdcWY9D3DJExh0pGHrnJWxXR+Y3jjTbDOxOVXvL4y41XA=
    =6d9r
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to WANG Xuerui on Sun Dec 17 17:10:01 2023
    On Mon, 2023-12-18 at 00:02 +0800, WANG Xuerui wrote:
    On 12/17/23 21:11, Michał Górny wrote:
    On Sun, 2023-12-17 at 20:09 +0800, WANG Xuerui wrote:
    The several partially-supported arches (those relying on
    USE=savedconfig) directly return in src_prepare(), hence previously the CONFIG_EFI_ZBOOT probing didn't have a chance to run when building for those arches, leading to wrong kernel artifact path and failed src_install().

    Move the probing to near the end of eclass src_configure(), so the flag correctly reflects the reality in all circumstances.

    Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
    ---
    eclass/kernel-build.eclass | 12 ++++++------
    1 file changed, 6 insertions(+), 6 deletions(-)

    diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass index 6b692dc4f9a0..7a041a8aacdf 100644
    --- a/eclass/kernel-build.eclass
    +++ b/eclass/kernel-build.eclass
    @@ -203,6 +203,12 @@ kernel-build_src_configure() {
    .config)
    fi

    + # If this is set by USE=secureboot or user config this will have an effect
    + # on the name of the output image. Set this variable to track this setting.
    + if grep -q "CONFIG_EFI_ZBOOT=y" .config; then
    + KERNEL_EFI_ZBOOT=1
    + fi
    +
    mkdir -p "${WORKDIR}"/modprep || die
    mv .config "${WORKDIR}"/modprep/ || die
    emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" olddefconfig
    @@ -456,12 +462,6 @@ kernel-build_merge_configs() {

    ./scripts/kconfig/merge_config.sh -m -r \
    .config "${merge_configs[@]}" || die
    -
    - # If this is set by USE=secureboot or user config this will have an effect
    - # on the name of the output image. Set this variable to track this setting.
    - if grep -q "CONFIG_EFI_ZBOOT=y" .config; then
    - KERNEL_EFI_ZBOOT=1
    - fi
    }

    fi
    This doesn't seem correct. It won't work if KERNEL_EFI_ZBOOT is set by
    one of the merged configs.
    But isn't the src_configure phase building upon the config already
    merged in src_prepare? The alternative would be keeping the kernel-build_merge_configs logic intact, but then it has to be
    duplicated for every early return branch in each ebuild's src_prepare,
    which I think is too excessive...


    Ah, sorry, you're right. I didn't notice these were two different
    functions!

    --
    Best regards,
    Michał Górny


    -----BEGIN PGP SIGNATURE-----

    iQFGBAABCgAwFiEEx2qEUJQJjSjMiybFY5ra4jKeJA4FAmV/HQsSHG1nb3JueUBn ZW50b28ub3JnAAoJEGOa2uIyniQOb8QH/iwc+NoXU7EodzkGW13nm3wtV1rVqsLU OWrppcSxVJK96PwzQZ/W/DCwvAtaWBhP+Neg++5lEphtNbSFWsDqaUynH8ozWGL2 InhApBFnjaue/gD0dlE70wF5zI6X1j5idp1dBMITOvL+Z5c7/hVvWvkMqgdbhRgf zSffiHpGdHrYWz4z2YFycJeuBMbeS8HoH1fT06GWdfX4S5B+dYgwmwp8z3eH8NjL sjZav4p4vqgyCROh119D75c0UolXIlrD/oVAQfI7nILS0Beiaxkh4IFKDlTmjKef c9xEGamGTRLvr/mK5W55TF7VnZuTQ8M3vnKW9uDA2iOH7+t+v4fylZo=
    =EO4z
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)