From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6868613252732944384 X-Received: by 2002:a5d:684b:: with SMTP id o11mr1885321wrw.101.1599826392307; Fri, 11 Sep 2020 05:13:12 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6000:8:: with SMTP id h8ls2470295wrx.3.gmail; Fri, 11 Sep 2020 05:13:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5XvryTnL74zAYj1PJd3V9KGgoatyCUKlDM0lUVQIaKT4AswwB92J4/YFZCC/6Hsnw5w+X X-Received: by 2002:adf:df05:: with SMTP id y5mr1961789wrl.39.1599826391115; Fri, 11 Sep 2020 05:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599826391; cv=none; d=google.com; s=arc-20160816; b=q47d4be+Ep0Hqc5BPb7DV1y6y85W+7HvA0v8e2hDT0V0ZWavogPpvh0s2dhMSrn7Gl id5eCUvcEHWTh4p8XqlPg1Bro1o/L5v/VsQ1TDmwNFoqGgL70tSJ3TkM2ujGfqwOJuff AmG1/jIcQhGWRtHnIa3RnwmV8rnrFqmYuXWh+WHaDLMaeCsN+cq/IdT8MMjqFjgrwgy5 2QOC3WDe34wfFdTeKug44R3olwcatA8ZRZyPhXVEoSILD1YlakX76twXe81QLnc93zrO I8kQJbHaE9WfA0fgc/s2y7DJ21U1LApRRmWt0eM0IinqqtXowF0Er1X+FghcfSWf2fUl uBmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from; bh=cQlhsoQByOOL+fDUgzG5gdPntk8FLBNVflMs5Ma6aRI=; b=MqSzjSEOHPU2e4JKWdiDP3pvkbruWA7QRFvZ4qjcyCMAsLCYMz0F1a+f0AOpmi9cTe 8kQanh2Q9JwGSo9pEqzvvJDyxmHsd1zELYep0U0IISxYusPsfaCXDWCzT2iu1xageJIG LiPnVAzYILCoKq+2xka5iL1Su7U5IsXP1WzEaAXZTlRFwrmt/EDCm244UkKPnk509Wnw AWvXQm6L3d8SFlWFVItgvIA+bssyPjvQXLDbhoV/GFSvT31tY0rx/Rc6bj4WlpAw0NR4 AXx7jVXWKSY/iVvjoAs0SlsMD9/pzht/S0eQanHTavy3A5ddlLJeU/fFTlYA2JkBTdEf Bhlg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id b1si76018wmj.1.2020.09.11.05.13.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 05:13:11 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id 08BCDARB019539 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 11 Sep 2020 14:13:10 +0200 Received: from md1f2u6c.ad001.siemens.net ([167.87.49.221]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 08BCD974012908 for ; Fri, 11 Sep 2020 14:13:10 +0200 From: Jan Kiszka To: isar-users Subject: [PATCH v2 1/4] Add compat architecture support via multiarch Date: Fri, 11 Sep 2020 14:13:06 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: iF75zR6ceuZ3 From: Jan Kiszka Allow building and installing 32-bit packages an 64-bit architectures that support this. Namely, these are amd64 and arm64 for us so far, minus stretch-amd64 which lacks crossbuild-essential-i386 in that version. Control the target architecture of a package is added via the PACKAGE_ARCH variable that defaults to DISTRO_ARCH. When set to COMPAT_DISTRO_ARCH, the package is built for i386 on amd64 and armhf on arm64. If the build environment and the target image should contain the compat arch is controlled via setting ISAR_ENABLE_COMPAT_ARCH to 1. Signed-off-by: Jan Kiszka --- meta-isar/conf/local.conf.sample | 5 +++++ meta/classes/dpkg.bbclass | 8 +++++--- meta/conf/bitbake.conf | 3 ++- meta/conf/distro/debian-common.conf | 3 +++ .../recipes-core/isar-bootstrap/isar-bootstrap.inc | 14 +++++++++++++- meta/recipes-devtools/buildchroot/buildchroot.inc | 5 +++++ meta/recipes-devtools/sdkchroot/sdkchroot.bb | 1 + 7 files changed, 34 insertions(+), 5 deletions(-) diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample index e842c129..2f82020d 100644 --- a/meta-isar/conf/local.conf.sample +++ b/meta-isar/conf/local.conf.sample @@ -175,6 +175,11 @@ IMAGE_INSTALL = "hello-isar example-raw example-module-${KERNEL_NAME} enable-fsc # Enable cross-compilation support ISAR_CROSS_COMPILE ?= "0" +# +# Uncomment to enable 32-bit compat architecture support +# NOTE: this works for amd64 and arm64 targets so far +#ISAR_ENABLE_COMPAT_ARCH ?= "1" + # # Uncomment this to enable use of cached base repository #ISAR_USE_CACHED_BASE_REPO ?= "1" diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass index acccc1f2..a24386df 100644 --- a/meta/classes/dpkg.bbclass +++ b/meta/classes/dpkg.bbclass @@ -3,16 +3,18 @@ inherit dpkg-base +PACKAGE_ARCH ?= "${DISTRO_ARCH}" + # Install build dependencies for package do_install_builddeps() { dpkg_do_mounts E="${@ isar_export_proxies(d)}" deb_dl_dir_import "${BUILDCHROOT_DIR}" sudo -E chroot ${BUILDCHROOT_DIR} /isar/deps.sh \ - ${PP}/${PPS} ${DISTRO_ARCH} --download-only + ${PP}/${PPS} ${PACKAGE_ARCH} --download-only deb_dl_dir_export "${BUILDCHROOT_DIR}" sudo -E chroot ${BUILDCHROOT_DIR} /isar/deps.sh \ - ${PP}/${PPS} ${DISTRO_ARCH} + ${PP}/${PPS} ${PACKAGE_ARCH} dpkg_undo_mounts } @@ -27,5 +29,5 @@ dpkg_runbuild() { E="${@ isar_export_proxies(d)}" export PARALLEL_MAKE="${PARALLEL_MAKE}" sudo -E chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} \ - /isar/build.sh ${PP}/${PPS} ${DISTRO_ARCH} + /isar/build.sh ${PP}/${PPS} ${PACKAGE_ARCH} } diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index d2834f53..3f136ca1 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -62,8 +62,9 @@ KERNEL_FILE ?= "vmlinuz" KERNEL_FILE_mipsel ?= "vmlinux" KERNEL_FILE_riscv64 ?= "vmlinux" -OVERRIDES = "${DISTRO_ARCH}:${MACHINE}:${DISTRO}:forcevariable" +OVERRIDES = "${DISTRO_ARCH}:${COMPAT_OVERRIDE}:${MACHINE}:${DISTRO}:forcevariable" FILESOVERRIDES = "${DISTRO_ARCH}:${MACHINE}" +COMPAT_OVERRIDE = "${@'compat-arch' if d.getVar('ISAR_ENABLE_COMPAT_ARCH') == '1' else ''}" # Setting default QEMU_ARCH variables for different DISTRO_ARCH: QEMU_ARCH_amd64 = "x86_64" diff --git a/meta/conf/distro/debian-common.conf b/meta/conf/distro/debian-common.conf index 7d681c49..582678f6 100644 --- a/meta/conf/distro/debian-common.conf +++ b/meta/conf/distro/debian-common.conf @@ -22,3 +22,6 @@ GRUB_BOOTLOADER_INSTALL_armhf = "grub-efi-arm-bin" GRUB_BOOTLOADER_INSTALL_arm64 = "grub-efi-arm64-bin" SYSLINUX_BOOTLOADER_INSTALL = "syslinux syslinux-common" + +COMPAT_DISTRO_ARCH_amd64 = "i386" +COMPAT_DISTRO_ARCH_arm64 = "armhf" diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc index da0d436b..fbfe669d 100644 --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc @@ -222,7 +222,7 @@ def get_host_release(): rel = platform.release() return rel -do_bootstrap[vardeps] += "DISTRO_APT_PREMIRRORS" +do_bootstrap[vardeps] += "DISTRO_APT_PREMIRRORS ISAR_ENABLE_COMPAT_ARCH" do_bootstrap[dirs] = "${DEPLOY_DIR_BOOTSTRAP}" do_bootstrap[depends] = "base-apt:do_cache" @@ -236,6 +236,14 @@ isar_bootstrap() { esac shift done + if [ "${ISAR_ENABLE_COMPAT_ARCH}" = "1" ]; then + if [ -z "${COMPAT_DISTRO_ARCH}" ]; then + bbfatal "${DISTRO_ARCH} does not have a compat arch" + fi + if [ "${@get_distro_suite(d, True)}-${COMPAT_DISTRO_ARCH}" = "stretch-i386" ]; then + bbfatal "compat arch build for stretch-i386 not supported" + fi + fi debootstrap_args="--verbose --variant=minbase --include=${DISTRO_BOOTSTRAP_BASE_PACKAGES}" if [ -f "${DISTRO_BOOTSTRAP_KEYRING}" ]; then debootstrap_args="$debootstrap_args --keyring=${DISTRO_BOOTSTRAP_KEYRING}" @@ -330,6 +338,10 @@ isar_bootstrap() { chroot "${ROOTFSDIR}" /usr/bin/dpkg --add-architecture ${DISTRO_ARCH} fi + if [ "${ISAR_ENABLE_COMPAT_ARCH}" = "1" ]; then + chroot "${ROOTFSDIR}" /usr/bin/dpkg --add-architecture ${COMPAT_DISTRO_ARCH} + fi + chroot "${ROOTFSDIR}" /usr/bin/apt-get update -y chroot "${ROOTFSDIR}" /usr/bin/apt-get install -y -f chroot "${ROOTFSDIR}" /usr/bin/apt-get dist-upgrade -y \ diff --git a/meta/recipes-devtools/buildchroot/buildchroot.inc b/meta/recipes-devtools/buildchroot/buildchroot.inc index b4d7b764..835968de 100644 --- a/meta/recipes-devtools/buildchroot/buildchroot.inc +++ b/meta/recipes-devtools/buildchroot/buildchroot.inc @@ -22,7 +22,12 @@ ROOTFS_CLEAN_FILES = "" ROOTFS_MANIFEST_DEPLOY_DIR = "${DEPLOY_DIR_BUILDCHROOT}" ROOTFS_FEATURES += "generate-manifest" +BUILDCHROOT_COMPAT_PREINSTALL_compat-arch = " \ + libc6:${COMPAT_DISTRO_ARCH} \ + crossbuild-essential-${COMPAT_DISTRO_ARCH}" + BUILDCHROOT_PREINSTALL_COMMON = " \ + ${BUILDCHROOT_COMPAT_PREINSTALL} \ make \ debhelper \ autotools-dev \ diff --git a/meta/recipes-devtools/sdkchroot/sdkchroot.bb b/meta/recipes-devtools/sdkchroot/sdkchroot.bb index bf3f6fb4..2bf3f5bc 100644 --- a/meta/recipes-devtools/sdkchroot/sdkchroot.bb +++ b/meta/recipes-devtools/sdkchroot/sdkchroot.bb @@ -22,6 +22,7 @@ DEPENDS += "${SDK_INSTALL}" TOOLCHAIN = "crossbuild-essential-${DISTRO_ARCH}" TOOLCHAIN_${HOST_ARCH} = "build-essential" TOOLCHAIN_i386 = "build-essential" +TOOLCHAIN_append_compat-arch = " crossbuild-essential-${COMPAT_DISTRO_ARCH}" inherit rootfs ROOTFS_ARCH = "${HOST_ARCH}" -- 2.26.2