public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH v4 00/10] Add cross-compilation support
@ 2018-07-24 19:06 Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 01/10] buildchroot: Add host buildchroot Alexander Smirnov
                   ` (9 more replies)
  0 siblings, 10 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Hi Jan,

here is the latest version of cross-compilation. Current achievements:

1. Default Isar build stays untouched :-)
2. Added ARM64 support
3. Fixed and *tested* building of ARM/ARM64 custom kernel and modules
4. I was able to build 'jailhouse-images' for QEMU ARM64

The known issues are unfortunately the same:
1. Check if target_arch = host_arch to disable cross-compilation
2. wic image depends on target buildchroot
3. Document this stuff (I've already started this)

Branch to try: asmirnov/devel

Alexander Smirnov (11):
  buildchroot: Add host buildchroot
  isar-bootstrap-helper: Add target architecture for dpkg
  build.sh: Add additional parameter
  cross-compilation: Introduce variable switch
  linux: Add ARM cross-compilation support
  isar: Add ARM64 cross-compilation support
  linux-module: Export ARCH and CROSS_COMPILE
  linux: Drop gcc from dependencies
  build.sh: Do not check deps in dpkg-buildpackage
  build.sh: Do not check deps in dpkg-buildpackage
  linux-module: Enable cross-build for testing

 meta-isar/conf/local.conf.sample                   |  5 ++++
 meta/classes/dpkg-base.bbclass                     | 19 ++++++++++--
 meta/classes/dpkg-raw.bbclass                      |  1 -
 meta/classes/dpkg.bbclass                          |  4 +--
 meta/classes/isar-bootstrap-helper.bbclass         |  5 ++++
 meta/conf/isar-bitbake.conf                        |  1 +
 .../buildchroot/buildchroot-host.bb                | 34 ++++++++++++++++++++++
 meta/recipes-devtools/buildchroot/files/build.sh   | 17 +++++++++--
 .../recipes-kernel/linux-module/files/debian/rules | 12 ++++++++
 meta/recipes-kernel/linux-module/module.inc        |  7 +++++
 meta/recipes-kernel/linux/files/build-kernel.sh    | 28 ++++++++++++++++--
 meta/recipes-kernel/linux/linux-custom.inc         |  4 +--
 12 files changed, 123 insertions(+), 14 deletions(-)
 create mode 100644 meta/recipes-devtools/buildchroot/buildchroot-host.bb

-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 01/10] buildchroot: Add host buildchroot
  2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
@ 2018-07-24 19:06 ` Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 02/10] isar-bootstrap-helper: Add target architecture for dpkg Alexander Smirnov
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Add buildchroot for host architecture.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta/conf/isar-bitbake.conf                        |  1 +
 .../buildchroot/buildchroot-host.bb                | 31 ++++++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 meta/recipes-devtools/buildchroot/buildchroot-host.bb

diff --git a/meta/conf/isar-bitbake.conf b/meta/conf/isar-bitbake.conf
index aaba96e..666c4a3 100644
--- a/meta/conf/isar-bitbake.conf
+++ b/meta/conf/isar-bitbake.conf
@@ -21,6 +21,7 @@
 WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PF}"
 DL_DIR = "${TOPDIR}/downloads"
 SSTATE_DIR ?= "${TMPDIR}/sstate-cache"
+BUILDCHROOT_HOST_DIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/buildchroot-host/rootfs"
 BUILDCHROOT_TARGET_DIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/buildchroot-target/rootfs"
 CACHE = "${TMPDIR}/cache"
 
diff --git a/meta/recipes-devtools/buildchroot/buildchroot-host.bb b/meta/recipes-devtools/buildchroot/buildchroot-host.bb
new file mode 100644
index 0000000..048998d
--- /dev/null
+++ b/meta/recipes-devtools/buildchroot/buildchroot-host.bb
@@ -0,0 +1,31 @@
+# Root filesystem for packages building
+#
+# This software is a part of ISAR.
+# Copyright (C) 2015-2018 ilbers GmbH
+
+DESCRIPTION = "Isar development filesystem for host"
+
+include buildchroot.inc
+
+BUILDCHROOT_PREINSTALL ?= "make \
+                           debhelper \
+                           autotools-dev \
+                           dpkg \
+                           locales \
+                           docbook-to-man \
+                           apt \
+                           automake \
+                           devscripts \
+                           equivs \
+                           libc6:${DISTRO_ARCH}"
+
+# Please note: this works for Stretch distro only. According to the wiki page:
+#     https://wiki.debian.org/CrossToolchains
+# Jessie doesn't contain toolchain. It should be fetched from the external
+# repository:
+#     http://emdebian.org/tools/debian/
+BUILDCHROOT_PREINSTALL_append_armhf += "binutils-arm-linux-gnueabihf \
+                                        crossbuild-essential-armhf"
+
+PARAMS = "--host-arch"
+do_build[depends] = "isar-apt:do_cache_config isar-bootstrap-host:do_bootstrap"
-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 02/10] isar-bootstrap-helper: Add target architecture for dpkg
  2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 01/10] buildchroot: Add host buildchroot Alexander Smirnov
@ 2018-07-24 19:06 ` Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 03/10] build.sh: Add additional parameter Alexander Smirnov
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

This filesystem intended for cross-compilation, so the target
architecture should be added. Otherwise dpkg won't be able to
install dependencies.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta/classes/isar-bootstrap-helper.bbclass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
index 3faee7c..d45cdd7 100644
--- a/meta/classes/isar-bootstrap-helper.bbclass
+++ b/meta/classes/isar-bootstrap-helper.bbclass
@@ -111,6 +111,11 @@ setup_root_file_system() {
         -o Dir::Etc::sourcelist="sources.list.d/isar-apt.list" \
         -o Dir::Etc::sourceparts="-" \
         -o APT::Get::List-Cleanup="0"
+    # Add multiarch for cross-target
+    if [ "${ROOTFS_ARCH}" != "${DISTRO_ARCH}" ]; then
+        sudo -E chroot "$ROOTFSDIR" /usr/bin/dpkg --add-architecture ${DISTRO_ARCH}
+        sudo -E chroot "$ROOTFSDIR" /usr/bin/apt-get update
+    fi
     sudo -E chroot "$ROOTFSDIR" \
         /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES \
             ${IMAGE_TRANSIENT_PACKAGES}
-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 03/10] build.sh: Add additional parameter
  2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 01/10] buildchroot: Add host buildchroot Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 02/10] isar-bootstrap-helper: Add target architecture for dpkg Alexander Smirnov
@ 2018-07-24 19:06 ` Alexander Smirnov
  2018-07-25  8:10   ` Henning Schild
  2018-07-25  8:14   ` Henning Schild
  2018-07-24 19:06 ` [PATCH v4 04/10] cross-compilation: Introduce variable switch Alexander Smirnov
                   ` (6 subsequent siblings)
  9 siblings, 2 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Pass target architecture as a parameter for build.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta/recipes-devtools/buildchroot/files/build.sh | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-devtools/buildchroot/files/build.sh b/meta/recipes-devtools/buildchroot/files/build.sh
index 73c0889..40ba410 100644
--- a/meta/recipes-devtools/buildchroot/files/build.sh
+++ b/meta/recipes-devtools/buildchroot/files/build.sh
@@ -6,6 +6,19 @@
 
 set -e
 
+# Create human-readable names
+target_arch=$2
+
+# Notes:
+#   mk-build-deps for jessie and jtretch has different parameter name to specify
+#   host architecture.
+debian_version=$(cat /etc/debian_version | cut -c 1)
+if [ $(($debian_version)) -ge 9 ]; then
+    set_arch="--host-arch $target_arch"
+else
+    set_arch="-a $target_arch"
+fi
+
 # Go to build directory
 cd $1
 
@@ -36,7 +49,7 @@ install_cmd="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y
         -o APT::Get::List-Cleanup="0"
 
     # Install all build deps
-    mk-build-deps -t "${install_cmd}" -i -r debian/control
+    mk-build-deps $set_arch -t "${install_cmd}" -i -r debian/control
 ) 42>/dpkg.lock
 
 # If autotools files have been created, update their timestamp to
@@ -48,4 +61,4 @@ for i in configure aclocal.m4 Makefile.am Makefile.in; do
 done
 
 # Build the package
-dpkg-buildpackage
+dpkg-buildpackage -a$target_arch
-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 04/10] cross-compilation: Introduce variable switch
  2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
                   ` (2 preceding siblings ...)
  2018-07-24 19:06 ` [PATCH v4 03/10] build.sh: Add additional parameter Alexander Smirnov
@ 2018-07-24 19:06 ` Alexander Smirnov
  2018-07-25  6:56   ` Jan Kiszka
  2018-07-25  8:25   ` Henning Schild
  2018-07-24 19:06 ` [PATCH v4 05/10] linux: Add ARM cross-compilation support Alexander Smirnov
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Add variable to switch from native to cross compilation.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta-isar/conf/local.conf.sample            |  5 +++++
 meta/classes/dpkg-base.bbclass              | 19 ++++++++++++++++---
 meta/classes/dpkg-raw.bbclass               |  1 -
 meta/classes/dpkg.bbclass                   |  4 +---
 meta/recipes-kernel/linux-module/module.inc |  7 +++++++
 meta/recipes-kernel/linux/linux-custom.inc  |  2 ++
 6 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 16ef488..27b43d1 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -156,3 +156,8 @@ CONF_VERSION = "1"
 #
 # The default list of extra packages to be installed.
 IMAGE_INSTALL = "example-hello example-raw example-module"
+
+#
+# Enable cross-compilation support
+# NOTE: this works only for stretch-armhf and stretch-amd64 targets for now.
+ISAR_CROSS_COMPILE ?= "0"
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 3234234..674c0b5 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -1,6 +1,22 @@
 # This software is a part of ISAR.
 # Copyright (C) 2017 Siemens AG
 
+ISAR_CROSS_COMPILE ??= "0"
+
+# Add dependency from the correct buildchroot: host or target
+python __anonymous() {
+    mode = d.getVar('ISAR_CROSS_COMPILE', True)
+    if mode == "0":
+        dep = "buildchroot-target:do_build"
+        rootfs = d.getVar('BUILDCHROOT_TARGET_DIR', True)
+    else:
+        dep = "buildchroot-host:do_build"
+        rootfs = d.getVar('BUILDCHROOT_HOST_DIR', True)
+
+    d.setVarFlag('do_build', 'depends', dep)
+    d.setVar('BUILDCHROOT_DIR', rootfs)
+}
+
 do_adjust_git() {
     if [ -f ${S}/.git/objects/info/alternates ]; then
         sed -i ${S}/.git/objects/info/alternates \
@@ -14,9 +30,6 @@ do_adjust_git[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
 inherit patch
 addtask patch after do_adjust_git before do_build
 
-# Add dependency from buildchroot creation
-do_build[depends] = "buildchroot-target:do_build"
-
 # Add dependency between Isar recipes
 DEPENDS ?= ""
 do_build[deptask] = "do_deploy_deb"
diff --git a/meta/classes/dpkg-raw.bbclass b/meta/classes/dpkg-raw.bbclass
index 2f23eb7..28233ac 100644
--- a/meta/classes/dpkg-raw.bbclass
+++ b/meta/classes/dpkg-raw.bbclass
@@ -7,7 +7,6 @@ DEBIAN_DEPENDS ?= ""
 MAINTAINER ?= "FIXME Unknown maintainer"
 
 D = "${WORKDIR}/image/"
-BUILDCHROOT_DIR = "${BUILDCHROOT_TARGET_DIR}"
 
 # Populate folder that will be picked up as package
 do_install() {
diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
index 563b63c..ab70645 100644
--- a/meta/classes/dpkg.bbclass
+++ b/meta/classes/dpkg.bbclass
@@ -3,10 +3,8 @@
 
 inherit dpkg-base
 
-BUILDCHROOT_DIR = "${BUILDCHROOT_TARGET_DIR}"
-
 # Build package from sources using build script
 dpkg_runbuild() {
     E="${@ bb.utils.export_proxies(d)}"
-    sudo -E chroot ${BUILDCHROOT_DIR} /build.sh ${PP}/${PPS}
+    sudo -E chroot ${BUILDCHROOT_DIR} /build.sh ${PP}/${PPS} ${DISTRO_ARCH}
 }
diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc
index 3075f44..8977668 100644
--- a/meta/recipes-kernel/linux-module/module.inc
+++ b/meta/recipes-kernel/linux-module/module.inc
@@ -15,6 +15,13 @@ SRC_URI += "file://debian/"
 
 AUTOLOAD ?= "0"
 
+# Cross-compilation is not supported for default Debian kernels.
+# For example, package with kernel headers for ARM:
+#   linux-headers-armmp
+# has hard dependencies from linux-compiler-gcc-4.8-arm, what
+# conflicts with the host binaries.
+ISAR_CROSS_COMPILE = "0"
+
 inherit dpkg
 
 dpkg_runbuild_prepend() {
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index 1176b25..f7641ef 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -20,6 +20,8 @@ python() {
                              'linux-headers-' + kernel)
 }
 
+ISAR_CROSS_COMPILE = "0"
+
 inherit dpkg-base
 
 SRC_URI += "file://build-kernel.sh"
-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 05/10] linux: Add ARM cross-compilation support
  2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
                   ` (3 preceding siblings ...)
  2018-07-24 19:06 ` [PATCH v4 04/10] cross-compilation: Introduce variable switch Alexander Smirnov
@ 2018-07-24 19:06 ` Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 06/10] isar: Add ARM64 " Alexander Smirnov
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Add possibility to cross-compile ARM target.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta/recipes-kernel/linux/files/build-kernel.sh | 24 +++++++++++++++++++++---
 meta/recipes-kernel/linux/linux-custom.inc      |  4 +---
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/meta/recipes-kernel/linux/files/build-kernel.sh b/meta/recipes-kernel/linux/files/build-kernel.sh
index 1ec094e..cc137a8 100644
--- a/meta/recipes-kernel/linux/files/build-kernel.sh
+++ b/meta/recipes-kernel/linux/files/build-kernel.sh
@@ -9,6 +9,22 @@
 
 set -e
 
+host_arch=$(dpkg --print-architecture)
+target_arch=$2
+
+if [ "$host_arch" != "$target_arch" ]; then
+    case $target_arch in
+    armhf)
+        export ARCH=arm
+        export CROSS_COMPILE="arm-linux-gnueabihf-"
+        ;;
+    *)
+        echo "error: unsupported architecture ($target_arch)"
+        exit 1
+        ;;
+    esac
+fi
+
 REPACK_DIR="$1/../repack"
 REPACK_LINUX_IMAGE_DIR="${REPACK_DIR}/linux-image"
 REPACK_LINUX_HEADERS_DIR="${REPACK_DIR}/linux-headers"
@@ -29,7 +45,7 @@ if [ "${KV}" != "${PV}" ]; then
 fi
 
 rm -f .version
-make -j $(($(nproc) * 2)) deb-pkg
+KBUILD_DEBARCH=$target_arch make -j $(($(nproc) * 2)) deb-pkg
 
 rm -rf ${REPACK_DIR}
 mkdir -p ${REPACK_DIR}
@@ -49,7 +65,8 @@ dpkg-gencontrol -crepack/debian/control \
 	-DPackage="linux-image-${KERNEL_NAME}" \
 	-DSection=kernel \
 	-DPriority=required \
-	-DDepends="${KERNEL_DEBIAN_DEPENDS}"
+	-DDepends="${KERNEL_DEBIAN_DEPENDS}" \
+	-DArchitecture=$target_arch
 
 # Add Debian-like link installation to postinst
 touch ${REPACK_LINUX_IMAGE_DIR}/lib/modules/${PV}/.fresh-install
@@ -82,7 +99,8 @@ dpkg-gencontrol -crepack/debian/control \
 	-Vkernel:debarch="${KERNEL_NAME}" \
 	-DPackage="linux-headers-${KERNEL_NAME}" \
 	-DSection=kernel \
-	-DDepends="${KERNEL_HEADERS_DEBIAN_DEPENDS}"
+	-DDepends="${KERNEL_HEADERS_DEBIAN_DEPENDS}" \
+	-DArchitecture=$target_arch
 
 dpkg-deb -b ${REPACK_LINUX_IMAGE_DIR} \
 	linux-image-${KERNEL_NAME}_${PV}-1_${KERNEL_NAME}.deb
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index f7641ef..d5fc5a6 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -20,8 +20,6 @@ python() {
                              'linux-headers-' + kernel)
 }
 
-ISAR_CROSS_COMPILE = "0"
-
 inherit dpkg-base
 
 SRC_URI += "file://build-kernel.sh"
@@ -45,5 +43,5 @@ dpkg_runbuild() {
 	export KERNEL_DEBIAN_DEPENDS="${KERNEL_DEBIAN_DEPENDS}"
 	export KERNEL_HEADERS_DEBIAN_DEPENDS="${KERNEL_HEADERS_DEBIAN_DEPENDS}"
 
-	sudo -E chroot ${BUILDCHROOT_DIR} /build-kernel.sh ${PP}/${PPS}
+	sudo -E chroot ${BUILDCHROOT_DIR} /build-kernel.sh ${PP}/${PPS} ${DISTRO_ARCH}
 }
-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 06/10] isar: Add ARM64 cross-compilation support
  2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
                   ` (4 preceding siblings ...)
  2018-07-24 19:06 ` [PATCH v4 05/10] linux: Add ARM cross-compilation support Alexander Smirnov
@ 2018-07-24 19:06 ` Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 07/10] linux-module: Export ARCH and CROSS_COMPILE Alexander Smirnov
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Add possibility to cross-compile ARM64 target.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta/recipes-devtools/buildchroot/buildchroot-host.bb | 3 +++
 meta/recipes-kernel/linux/files/build-kernel.sh       | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/meta/recipes-devtools/buildchroot/buildchroot-host.bb b/meta/recipes-devtools/buildchroot/buildchroot-host.bb
index 048998d..7bdd7e0 100644
--- a/meta/recipes-devtools/buildchroot/buildchroot-host.bb
+++ b/meta/recipes-devtools/buildchroot/buildchroot-host.bb
@@ -26,6 +26,9 @@ BUILDCHROOT_PREINSTALL ?= "make \
 #     http://emdebian.org/tools/debian/
 BUILDCHROOT_PREINSTALL_append_armhf += "binutils-arm-linux-gnueabihf \
                                         crossbuild-essential-armhf"
+BUILDCHROOT_PREINSTALL_append_arm64 += "binutils-aarch64-linux-gnu \
+                                        crossbuild-essential-arm64"
+ 
 
 PARAMS = "--host-arch"
 do_build[depends] = "isar-apt:do_cache_config isar-bootstrap-host:do_bootstrap"
diff --git a/meta/recipes-kernel/linux/files/build-kernel.sh b/meta/recipes-kernel/linux/files/build-kernel.sh
index cc137a8..8b58e93 100644
--- a/meta/recipes-kernel/linux/files/build-kernel.sh
+++ b/meta/recipes-kernel/linux/files/build-kernel.sh
@@ -18,6 +18,10 @@ if [ "$host_arch" != "$target_arch" ]; then
         export ARCH=arm
         export CROSS_COMPILE="arm-linux-gnueabihf-"
         ;;
+    arm64)
+        export ARCH=arm64
+        export CROSS_COMPILE="aarch64-linux-gnu-"
+        ;;
     *)
         echo "error: unsupported architecture ($target_arch)"
         exit 1
-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 07/10] linux-module: Export ARCH and CROSS_COMPILE
  2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
                   ` (5 preceding siblings ...)
  2018-07-24 19:06 ` [PATCH v4 06/10] isar: Add ARM64 " Alexander Smirnov
@ 2018-07-24 19:06 ` Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 08/10] linux: Drop gcc from dependencies Alexander Smirnov
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Export necessary kernel variables to be able to cross-build modules.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta/recipes-kernel/linux-module/files/debian/rules | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/meta/recipes-kernel/linux-module/files/debian/rules b/meta/recipes-kernel/linux-module/files/debian/rules
index 46cf977..95206b7 100755
--- a/meta/recipes-kernel/linux-module/files/debian/rules
+++ b/meta/recipes-kernel/linux-module/files/debian/rules
@@ -11,5 +11,17 @@ export KDIR=$(shell ls -d /lib/modules/*/build)
 
 export DEB_BUILD_OPTIONS=parallel=$(shell nproc)
 
+export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
+
+ifeq ($(DEB_HOST_GNU_CPU), arm)
+export ARCH=arm
+endif
+ifeq ($(DEB_HOST_GNU_CPU), arm64)
+export ARCH=arm64
+endif
+ifneq (,$(findstring 86,$(DEB_HOST_GNU_CPU)))
+export ARCH=x86
+endif
+
 %:
 	CFLAGS= LDFLAGS= dh $@ --parallel
-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 08/10] linux: Drop gcc from dependencies
  2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
                   ` (6 preceding siblings ...)
  2018-07-24 19:06 ` [PATCH v4 07/10] linux-module: Export ARCH and CROSS_COMPILE Alexander Smirnov
@ 2018-07-24 19:06 ` Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 09/10] build.sh: Do not check deps in dpkg-buildpackage Alexander Smirnov
  2018-07-24 19:06 ` [PATCH v4 10/10] linux-module: Enable cross-build for testing Alexander Smirnov
  9 siblings, 0 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

This dependency pulls target tools what conflicts with the host ones.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta/recipes-kernel/linux/linux-custom.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index d5fc5a6..87d4377 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -26,7 +26,7 @@ SRC_URI += "file://build-kernel.sh"
 
 KBUILD_DEPENDS ?= "libssl-dev libelf-dev bc"
 KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, kmod, linux-base (>= 4.3~)"
-KERNEL_HEADERS_DEBIAN_DEPENDS ?= "libc6, libssl1.1, gcc"
+KERNEL_HEADERS_DEBIAN_DEPENDS ?= "libc6, libssl1.1"
 
 dpkg_runbuild() {
 	# Install package builder script
-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 09/10] build.sh: Do not check deps in dpkg-buildpackage
  2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
                   ` (7 preceding siblings ...)
  2018-07-24 19:06 ` [PATCH v4 08/10] linux: Drop gcc from dependencies Alexander Smirnov
@ 2018-07-24 19:06 ` Alexander Smirnov
  2018-07-24 19:07   ` Alexander Smirnov
  2018-08-11 15:47   ` Jan Kiszka
  2018-07-24 19:06 ` [PATCH v4 10/10] linux-module: Enable cross-build for testing Alexander Smirnov
  9 siblings, 2 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov, Jan Kiszka

dpkg-buildpackage could brake the compilation. The build dependencies
are already installed at this stage, so there is no need to check them
in dpkg-buildpackage.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta/recipes-devtools/buildchroot/files/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-devtools/buildchroot/files/build.sh b/meta/recipes-devtools/buildchroot/files/build.sh
index 40ba410..aba2042 100644
--- a/meta/recipes-devtools/buildchroot/files/build.sh
+++ b/meta/recipes-devtools/buildchroot/files/build.sh
@@ -61,4 +61,4 @@ for i in configure aclocal.m4 Makefile.am Makefile.in; do
 done
 
 # Build the package
-dpkg-buildpackage -a$target_arch
+dpkg-buildpackage -a$target_arch --no-check-builddeps
-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 10/10] linux-module: Enable cross-build for testing
  2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
                   ` (8 preceding siblings ...)
  2018-07-24 19:06 ` [PATCH v4 09/10] build.sh: Do not check deps in dpkg-buildpackage Alexander Smirnov
@ 2018-07-24 19:06 ` Alexander Smirnov
  2018-07-24 19:07   ` Alexander Smirnov
  9 siblings, 1 reply; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:06 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta/recipes-kernel/linux-module/module.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc
index 8977668..c3a626e 100644
--- a/meta/recipes-kernel/linux-module/module.inc
+++ b/meta/recipes-kernel/linux-module/module.inc
@@ -20,7 +20,7 @@ AUTOLOAD ?= "0"
 #   linux-headers-armmp
 # has hard dependencies from linux-compiler-gcc-4.8-arm, what
 # conflicts with the host binaries.
-ISAR_CROSS_COMPILE = "0"
+ISAR_CROSS_COMPILE = "1"
 
 inherit dpkg
 
-- 
2.1.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 09/10] build.sh: Do not check deps in dpkg-buildpackage
  2018-07-24 19:06 ` [PATCH v4 09/10] build.sh: Do not check deps in dpkg-buildpackage Alexander Smirnov
@ 2018-07-24 19:07   ` Alexander Smirnov
  2018-08-11 15:47   ` Jan Kiszka
  1 sibling, 0 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:07 UTC (permalink / raw)
  To: isar-users; +Cc: Jan Kiszka

This one to test Jailhouse, sorry that haven't updated the header.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 10/10] linux-module: Enable cross-build for testing
  2018-07-24 19:06 ` [PATCH v4 10/10] linux-module: Enable cross-build for testing Alexander Smirnov
@ 2018-07-24 19:07   ` Alexander Smirnov
  0 siblings, 0 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-07-24 19:07 UTC (permalink / raw)
  To: isar-users

This one to test Jailhouse, sorry that haven't updated the header.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 04/10] cross-compilation: Introduce variable switch
  2018-07-24 19:06 ` [PATCH v4 04/10] cross-compilation: Introduce variable switch Alexander Smirnov
@ 2018-07-25  6:56   ` Jan Kiszka
  2018-07-25  8:25   ` Henning Schild
  1 sibling, 0 replies; 21+ messages in thread
From: Jan Kiszka @ 2018-07-25  6:56 UTC (permalink / raw)
  To: Alexander Smirnov, isar-users

On 2018-07-24 21:06, Alexander Smirnov wrote:
> Add variable to switch from native to cross compilation.
> 
> Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
> ---
>   meta-isar/conf/local.conf.sample            |  5 +++++
>   meta/classes/dpkg-base.bbclass              | 19 ++++++++++++++++---
>   meta/classes/dpkg-raw.bbclass               |  1 -
>   meta/classes/dpkg.bbclass                   |  4 +---
>   meta/recipes-kernel/linux-module/module.inc |  7 +++++++
>   meta/recipes-kernel/linux/linux-custom.inc  |  2 ++
>   6 files changed, 31 insertions(+), 7 deletions(-)
> 
> diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
> index 16ef488..27b43d1 100644
> --- a/meta-isar/conf/local.conf.sample
> +++ b/meta-isar/conf/local.conf.sample
> @@ -156,3 +156,8 @@ CONF_VERSION = "1"
>   #
>   # The default list of extra packages to be installed.
>   IMAGE_INSTALL = "example-hello example-raw example-module"
> +
> +#
> +# Enable cross-compilation support
> +# NOTE: this works only for stretch-armhf and stretch-amd64 targets for now.
> +ISAR_CROSS_COMPILE ?= "0"
> diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
> index 3234234..674c0b5 100644
> --- a/meta/classes/dpkg-base.bbclass
> +++ b/meta/classes/dpkg-base.bbclass
> @@ -1,6 +1,22 @@
>   # This software is a part of ISAR.
>   # Copyright (C) 2017 Siemens AG
>   
> +ISAR_CROSS_COMPILE ??= "0"
> +
> +# Add dependency from the correct buildchroot: host or target
> +python __anonymous() {
> +    mode = d.getVar('ISAR_CROSS_COMPILE', True)
> +    if mode == "0":
> +        dep = "buildchroot-target:do_build"
> +        rootfs = d.getVar('BUILDCHROOT_TARGET_DIR', True)
> +    else:
> +        dep = "buildchroot-host:do_build"
> +        rootfs = d.getVar('BUILDCHROOT_HOST_DIR', True)
> +
> +    d.setVarFlag('do_build', 'depends', dep)
> +    d.setVar('BUILDCHROOT_DIR', rootfs)
> +}
> +
>   do_adjust_git() {
>       if [ -f ${S}/.git/objects/info/alternates ]; then
>           sed -i ${S}/.git/objects/info/alternates \
> @@ -14,9 +30,6 @@ do_adjust_git[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
>   inherit patch
>   addtask patch after do_adjust_git before do_build
>   
> -# Add dependency from buildchroot creation
> -do_build[depends] = "buildchroot-target:do_build"
> -
>   # Add dependency between Isar recipes
>   DEPENDS ?= ""
>   do_build[deptask] = "do_deploy_deb"
> diff --git a/meta/classes/dpkg-raw.bbclass b/meta/classes/dpkg-raw.bbclass
> index 2f23eb7..28233ac 100644
> --- a/meta/classes/dpkg-raw.bbclass
> +++ b/meta/classes/dpkg-raw.bbclass
> @@ -7,7 +7,6 @@ DEBIAN_DEPENDS ?= ""
>   MAINTAINER ?= "FIXME Unknown maintainer"
>   
>   D = "${WORKDIR}/image/"
> -BUILDCHROOT_DIR = "${BUILDCHROOT_TARGET_DIR}"
>   
>   # Populate folder that will be picked up as package
>   do_install() {
> diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
> index 563b63c..ab70645 100644
> --- a/meta/classes/dpkg.bbclass
> +++ b/meta/classes/dpkg.bbclass
> @@ -3,10 +3,8 @@
>   
>   inherit dpkg-base
>   
> -BUILDCHROOT_DIR = "${BUILDCHROOT_TARGET_DIR}"
> -
>   # Build package from sources using build script
>   dpkg_runbuild() {
>       E="${@ bb.utils.export_proxies(d)}"
> -    sudo -E chroot ${BUILDCHROOT_DIR} /build.sh ${PP}/${PPS}
> +    sudo -E chroot ${BUILDCHROOT_DIR} /build.sh ${PP}/${PPS} ${DISTRO_ARCH}
>   }
> diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc
> index 3075f44..8977668 100644
> --- a/meta/recipes-kernel/linux-module/module.inc
> +++ b/meta/recipes-kernel/linux-module/module.inc
> @@ -15,6 +15,13 @@ SRC_URI += "file://debian/"
>   
>   AUTOLOAD ?= "0"
>   
> +# Cross-compilation is not supported for default Debian kernels.
> +# For example, package with kernel headers for ARM:
> +#   linux-headers-armmp
> +# has hard dependencies from linux-compiler-gcc-4.8-arm, what
> +# conflicts with the host binaries.
> +ISAR_CROSS_COMPILE = "0"

This is not the right place to control this (thus, also patch 10 is 
wrong). This belongs into the recipe that pulls in module.inc - or not, 
depending on the overall setup.

If you enable crossbuild and also build the kernel from source, modules 
must be cross-built as well. If you use a prebuilt kernel with a header 
packages for the target arch, modules must be natively built. This 
cannot be decided at the level of this include.

In the context of isar, put the disabling into example-module.bb because 
we have no test case that builds a kernel from source and uses that 
example module. If we had, example-module.bb would have to have some

ISAR_CROSS_COMPILE_testmachine = "1"

for that target.

> +
>   inherit dpkg
>   
>   dpkg_runbuild_prepend() {
> diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
> index 1176b25..f7641ef 100644
> --- a/meta/recipes-kernel/linux/linux-custom.inc
> +++ b/meta/recipes-kernel/linux/linux-custom.inc
> @@ -20,6 +20,8 @@ python() {
>                                'linux-headers-' + kernel)
>   }
>   
> +ISAR_CROSS_COMPILE = "0"
> +

Same for this one: The recipe is cross-compatible (after patch 8), it's 
just that the user of these includes has to ensure that the whole 
ensemble is consistent.

Jan

>   inherit dpkg-base
>   
>   SRC_URI += "file://build-kernel.sh"
> 


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 03/10] build.sh: Add additional parameter
  2018-07-24 19:06 ` [PATCH v4 03/10] build.sh: Add additional parameter Alexander Smirnov
@ 2018-07-25  8:10   ` Henning Schild
  2018-07-25  8:14   ` Henning Schild
  1 sibling, 0 replies; 21+ messages in thread
From: Henning Schild @ 2018-07-25  8:10 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: isar-users

Am Tue, 24 Jul 2018 22:06:11 +0300
schrieb Alexander Smirnov <asmirnov@ilbers.de>:

> Pass target architecture as a parameter for build.
> 
> Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
> ---
>  meta/recipes-devtools/buildchroot/files/build.sh | 17
> +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/recipes-devtools/buildchroot/files/build.sh
> b/meta/recipes-devtools/buildchroot/files/build.sh index
> 73c0889..40ba410 100644 ---
> a/meta/recipes-devtools/buildchroot/files/build.sh +++
> b/meta/recipes-devtools/buildchroot/files/build.sh @@ -6,6 +6,19 @@
>  
>  set -e
>  
> +# Create human-readable names
> +target_arch=$2
> +
> +# Notes:
> +#   mk-build-deps for jessie and jtretch has different parameter
> name to specify +#   host architecture.
> +debian_version=$(cat /etc/debian_version | cut -c 1)

useless use of cat ... "cut -c 1 /etc/debian_version"

Henning

> +if [ $(($debian_version)) -ge 9 ]; then
> +    set_arch="--host-arch $target_arch"
> +else
> +    set_arch="-a $target_arch"
> +fi
> +
>  # Go to build directory
>  cd $1
>  
> @@ -36,7 +49,7 @@ install_cmd="apt-get -o
> Debug::pkgProblemResolver=yes --no-install-recommends -y -o
> APT::Get::List-Cleanup="0" 
>      # Install all build deps
> -    mk-build-deps -t "${install_cmd}" -i -r debian/control
> +    mk-build-deps $set_arch -t "${install_cmd}" -i -r debian/control
>  ) 42>/dpkg.lock
>  
>  # If autotools files have been created, update their timestamp to
> @@ -48,4 +61,4 @@ for i in configure aclocal.m4 Makefile.am
> Makefile.in; do done
>  
>  # Build the package
> -dpkg-buildpackage
> +dpkg-buildpackage -a$target_arch


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 03/10] build.sh: Add additional parameter
  2018-07-24 19:06 ` [PATCH v4 03/10] build.sh: Add additional parameter Alexander Smirnov
  2018-07-25  8:10   ` Henning Schild
@ 2018-07-25  8:14   ` Henning Schild
  1 sibling, 0 replies; 21+ messages in thread
From: Henning Schild @ 2018-07-25  8:14 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: isar-users

Am Tue, 24 Jul 2018 22:06:11 +0300
schrieb Alexander Smirnov <asmirnov@ilbers.de>:

> Pass target architecture as a parameter for build.
> 
> Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
> ---
>  meta/recipes-devtools/buildchroot/files/build.sh | 17
> +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/recipes-devtools/buildchroot/files/build.sh
> b/meta/recipes-devtools/buildchroot/files/build.sh index
> 73c0889..40ba410 100644 ---
> a/meta/recipes-devtools/buildchroot/files/build.sh +++
> b/meta/recipes-devtools/buildchroot/files/build.sh @@ -6,6 +6,19 @@
>  
>  set -e
>  
> +# Create human-readable names
> +target_arch=$2
> +
> +# Notes:
> +#   mk-build-deps for jessie and jtretch has different parameter
> name to specify +#   host architecture.
> +debian_version=$(cat /etc/debian_version | cut -c 1)
> +if [ $(($debian_version)) -ge 9 ]; then
> +    set_arch="--host-arch $target_arch"
> +else
> +    set_arch="-a $target_arch"
> +fi

The way i understand this patch, all callers will have to be updated as
well. Otherwise this patch (applied without the following) breaks the
build.

Henning

>  # Go to build directory
>  cd $1
>  
> @@ -36,7 +49,7 @@ install_cmd="apt-get -o
> Debug::pkgProblemResolver=yes --no-install-recommends -y -o
> APT::Get::List-Cleanup="0" 
>      # Install all build deps
> -    mk-build-deps -t "${install_cmd}" -i -r debian/control
> +    mk-build-deps $set_arch -t "${install_cmd}" -i -r debian/control
>  ) 42>/dpkg.lock
>  
>  # If autotools files have been created, update their timestamp to
> @@ -48,4 +61,4 @@ for i in configure aclocal.m4 Makefile.am
> Makefile.in; do done
>  
>  # Build the package
> -dpkg-buildpackage
> +dpkg-buildpackage -a$target_arch


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 04/10] cross-compilation: Introduce variable switch
  2018-07-24 19:06 ` [PATCH v4 04/10] cross-compilation: Introduce variable switch Alexander Smirnov
  2018-07-25  6:56   ` Jan Kiszka
@ 2018-07-25  8:25   ` Henning Schild
  2018-07-25 12:22     ` Jan Kiszka
  1 sibling, 1 reply; 21+ messages in thread
From: Henning Schild @ 2018-07-25  8:25 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: isar-users

The way i understand the whole thing is that there are two meanings of
ISAR_CROSS_COMPILE. On the image-level it enables the feature for
every package. Some packages, the ones that do not support it, disable
it for their build.

Would it be a good idea to come up with a different name for the two?

image:
 ISAR_CROSS_COMPILE_IMAGE
package:
 ISAR_CROSS_COMPILE_RECIPE ?= ISAR_CROSS_COMPILE_IMAGE

Henning

Am Tue, 24 Jul 2018 22:06:12 +0300
schrieb Alexander Smirnov <asmirnov@ilbers.de>:

> Add variable to switch from native to cross compilation.
> 
> Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
> ---
>  meta-isar/conf/local.conf.sample            |  5 +++++
>  meta/classes/dpkg-base.bbclass              | 19 ++++++++++++++++---
>  meta/classes/dpkg-raw.bbclass               |  1 -
>  meta/classes/dpkg.bbclass                   |  4 +---
>  meta/recipes-kernel/linux-module/module.inc |  7 +++++++
>  meta/recipes-kernel/linux/linux-custom.inc  |  2 ++
>  6 files changed, 31 insertions(+), 7 deletions(-)
> 
> diff --git a/meta-isar/conf/local.conf.sample
> b/meta-isar/conf/local.conf.sample index 16ef488..27b43d1 100644
> --- a/meta-isar/conf/local.conf.sample
> +++ b/meta-isar/conf/local.conf.sample
> @@ -156,3 +156,8 @@ CONF_VERSION = "1"
>  #
>  # The default list of extra packages to be installed.
>  IMAGE_INSTALL = "example-hello example-raw example-module"
> +
> +#
> +# Enable cross-compilation support
> +# NOTE: this works only for stretch-armhf and stretch-amd64 targets
> for now. +ISAR_CROSS_COMPILE ?= "0"
> diff --git a/meta/classes/dpkg-base.bbclass
> b/meta/classes/dpkg-base.bbclass index 3234234..674c0b5 100644
> --- a/meta/classes/dpkg-base.bbclass
> +++ b/meta/classes/dpkg-base.bbclass
> @@ -1,6 +1,22 @@
>  # This software is a part of ISAR.
>  # Copyright (C) 2017 Siemens AG
>  
> +ISAR_CROSS_COMPILE ??= "0"
> +
> +# Add dependency from the correct buildchroot: host or target
> +python __anonymous() {
> +    mode = d.getVar('ISAR_CROSS_COMPILE', True)
> +    if mode == "0":
> +        dep = "buildchroot-target:do_build"
> +        rootfs = d.getVar('BUILDCHROOT_TARGET_DIR', True)
> +    else:
> +        dep = "buildchroot-host:do_build"
> +        rootfs = d.getVar('BUILDCHROOT_HOST_DIR', True)
> +
> +    d.setVarFlag('do_build', 'depends', dep)
> +    d.setVar('BUILDCHROOT_DIR', rootfs)
> +}
> +
>  do_adjust_git() {
>      if [ -f ${S}/.git/objects/info/alternates ]; then
>          sed -i ${S}/.git/objects/info/alternates \
> @@ -14,9 +30,6 @@ do_adjust_git[stamp-extra-info] =
> "${DISTRO}-${DISTRO_ARCH}" inherit patch
>  addtask patch after do_adjust_git before do_build
>  
> -# Add dependency from buildchroot creation
> -do_build[depends] = "buildchroot-target:do_build"
> -
>  # Add dependency between Isar recipes
>  DEPENDS ?= ""
>  do_build[deptask] = "do_deploy_deb"
> diff --git a/meta/classes/dpkg-raw.bbclass
> b/meta/classes/dpkg-raw.bbclass index 2f23eb7..28233ac 100644
> --- a/meta/classes/dpkg-raw.bbclass
> +++ b/meta/classes/dpkg-raw.bbclass
> @@ -7,7 +7,6 @@ DEBIAN_DEPENDS ?= ""
>  MAINTAINER ?= "FIXME Unknown maintainer"
>  
>  D = "${WORKDIR}/image/"
> -BUILDCHROOT_DIR = "${BUILDCHROOT_TARGET_DIR}"
>  
>  # Populate folder that will be picked up as package
>  do_install() {
> diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
> index 563b63c..ab70645 100644
> --- a/meta/classes/dpkg.bbclass
> +++ b/meta/classes/dpkg.bbclass
> @@ -3,10 +3,8 @@
>  
>  inherit dpkg-base
>  
> -BUILDCHROOT_DIR = "${BUILDCHROOT_TARGET_DIR}"
> -
>  # Build package from sources using build script
>  dpkg_runbuild() {
>      E="${@ bb.utils.export_proxies(d)}"
> -    sudo -E chroot ${BUILDCHROOT_DIR} /build.sh ${PP}/${PPS}
> +    sudo -E chroot ${BUILDCHROOT_DIR} /build.sh ${PP}/${PPS}
> ${DISTRO_ARCH} }
> diff --git a/meta/recipes-kernel/linux-module/module.inc
> b/meta/recipes-kernel/linux-module/module.inc index 3075f44..8977668
> 100644 --- a/meta/recipes-kernel/linux-module/module.inc
> +++ b/meta/recipes-kernel/linux-module/module.inc
> @@ -15,6 +15,13 @@ SRC_URI += "file://debian/"
>  
>  AUTOLOAD ?= "0"
>  
> +# Cross-compilation is not supported for default Debian kernels.
> +# For example, package with kernel headers for ARM:
> +#   linux-headers-armmp
> +# has hard dependencies from linux-compiler-gcc-4.8-arm, what
> +# conflicts with the host binaries.
> +ISAR_CROSS_COMPILE = "0"
> +
>  inherit dpkg
>  
>  dpkg_runbuild_prepend() {
> diff --git a/meta/recipes-kernel/linux/linux-custom.inc
> b/meta/recipes-kernel/linux/linux-custom.inc index 1176b25..f7641ef
> 100644 --- a/meta/recipes-kernel/linux/linux-custom.inc
> +++ b/meta/recipes-kernel/linux/linux-custom.inc
> @@ -20,6 +20,8 @@ python() {
>                               'linux-headers-' + kernel)
>  }
>  
> +ISAR_CROSS_COMPILE = "0"
> +
>  inherit dpkg-base
>  
>  SRC_URI += "file://build-kernel.sh"


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 04/10] cross-compilation: Introduce variable switch
  2018-07-25  8:25   ` Henning Schild
@ 2018-07-25 12:22     ` Jan Kiszka
  0 siblings, 0 replies; 21+ messages in thread
From: Jan Kiszka @ 2018-07-25 12:22 UTC (permalink / raw)
  To: [ext] Henning Schild, Alexander Smirnov; +Cc: isar-users

On 2018-07-25 10:25, [ext] Henning Schild wrote:
> The way i understand the whole thing is that there are two meanings of
> ISAR_CROSS_COMPILE. On the image-level it enables the feature for
> every package. Some packages, the ones that do not support it, disable
> it for their build.
> 
> Would it be a good idea to come up with a different name for the two?
> 
> image:
>   ISAR_CROSS_COMPILE_IMAGE
> package:
>   ISAR_CROSS_COMPILE_RECIPE ?= ISAR_CROSS_COMPILE_IMAGE
> 

ISAR_CROSS_COMPILE has no direct relationship with images. It is a 
Variable that controls per package-generating recipe if cross 
compilation should be used.

You can set it globally, via local.conf, multiconfig settings or per 
target etc. Then those recipes who know that they are not compatible 
(unfulfilled build deps, build issues) should opt-out by overwriting the 
variable in the recipe file.

The problem comes from combinations: If recipe has a build-dependency on 
another recipe, generally only both can opt-out. But as we cannot 
foresee the combinations the user will choose when defining a target 
(which includes images), that user need to resolve any potential 
problems - e.g. by bbappend'ing ISAR_CROSS_COMPILE=0 to a recipe that 
services as build-dependency to a cross-incompatible recipe.

Jan


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 09/10] build.sh: Do not check deps in dpkg-buildpackage
  2018-07-24 19:06 ` [PATCH v4 09/10] build.sh: Do not check deps in dpkg-buildpackage Alexander Smirnov
  2018-07-24 19:07   ` Alexander Smirnov
@ 2018-08-11 15:47   ` Jan Kiszka
  2018-08-14 11:40     ` Jan Kiszka
  1 sibling, 1 reply; 21+ messages in thread
From: Jan Kiszka @ 2018-08-11 15:47 UTC (permalink / raw)
  To: Alexander Smirnov, isar-users, Maksim Osipov

On 2018-07-24 21:06, Alexander Smirnov wrote:
> dpkg-buildpackage could brake the compilation. The build dependencies
> are already installed at this stage, so there is no need to check them
> in dpkg-buildpackage.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
> ---
>   meta/recipes-devtools/buildchroot/files/build.sh | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-devtools/buildchroot/files/build.sh b/meta/recipes-devtools/buildchroot/files/build.sh
> index 40ba410..aba2042 100644
> --- a/meta/recipes-devtools/buildchroot/files/build.sh
> +++ b/meta/recipes-devtools/buildchroot/files/build.sh
> @@ -61,4 +61,4 @@ for i in configure aclocal.m4 Makefile.am Makefile.in; do
>   done
>   
>   # Build the package
> -dpkg-buildpackage -a$target_arch
> +dpkg-buildpackage -a$target_arch --no-check-builddeps
> 

Any reason why this was not part of v5 and is now not in next? It's 
still required to cross-compile packages with certain python 
dependencies, possibly more.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 09/10] build.sh: Do not check deps in dpkg-buildpackage
  2018-08-11 15:47   ` Jan Kiszka
@ 2018-08-14 11:40     ` Jan Kiszka
  2018-08-14 12:39       ` Alexander Smirnov
  0 siblings, 1 reply; 21+ messages in thread
From: Jan Kiszka @ 2018-08-14 11:40 UTC (permalink / raw)
  To: Alexander Smirnov, isar-users, Maksim Osipov

On 2018-08-11 17:47, [ext] Jan Kiszka wrote:
> On 2018-07-24 21:06, Alexander Smirnov wrote:
>> dpkg-buildpackage could brake the compilation. The build dependencies
>> are already installed at this stage, so there is no need to check them
>> in dpkg-buildpackage.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
>> ---
>>   meta/recipes-devtools/buildchroot/files/build.sh | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/meta/recipes-devtools/buildchroot/files/build.sh 
>> b/meta/recipes-devtools/buildchroot/files/build.sh
>> index 40ba410..aba2042 100644
>> --- a/meta/recipes-devtools/buildchroot/files/build.sh
>> +++ b/meta/recipes-devtools/buildchroot/files/build.sh
>> @@ -61,4 +61,4 @@ for i in configure aclocal.m4 Makefile.am 
>> Makefile.in; do
>>   done
>>   # Build the package
>> -dpkg-buildpackage -a$target_arch
>> +dpkg-buildpackage -a$target_arch --no-check-builddeps
>>
> 
> Any reason why this was not part of v5 and is now not in next? It's 
> still required to cross-compile packages with certain python 
> dependencies, possibly more.
> 

Can we get this into next as well (then I would be patch-free in my 
layer)? Alex asked for an ack on this which I herewith provide.

We can possibly tune the commit message further: This changes is needed 
in order to avoid failures of dpkg-buildpackage when a package provides 
python-pip:native or python-mako:native as build-depends. ":native" 
would make the builddeps check fail while that is needed to install (via 
  mk-build-deps) the host-side version of these packages in a 
cross-build case.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 09/10] build.sh: Do not check deps in dpkg-buildpackage
  2018-08-14 11:40     ` Jan Kiszka
@ 2018-08-14 12:39       ` Alexander Smirnov
  0 siblings, 0 replies; 21+ messages in thread
From: Alexander Smirnov @ 2018-08-14 12:39 UTC (permalink / raw)
  To: Jan Kiszka, isar-users, Maksim Osipov

Hi Jan,

On 14.08.2018 14:40, Jan Kiszka wrote:
> On 2018-08-11 17:47, [ext] Jan Kiszka wrote:
>> On 2018-07-24 21:06, Alexander Smirnov wrote:
>>> dpkg-buildpackage could brake the compilation. The build dependencies
>>> are already installed at this stage, so there is no need to check them
>>> in dpkg-buildpackage.
>>>
>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>> Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
>>> ---
>>>   meta/recipes-devtools/buildchroot/files/build.sh | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/meta/recipes-devtools/buildchroot/files/build.sh 
>>> b/meta/recipes-devtools/buildchroot/files/build.sh
>>> index 40ba410..aba2042 100644
>>> --- a/meta/recipes-devtools/buildchroot/files/build.sh
>>> +++ b/meta/recipes-devtools/buildchroot/files/build.sh
>>> @@ -61,4 +61,4 @@ for i in configure aclocal.m4 Makefile.am 
>>> Makefile.in; do
>>>   done
>>>   # Build the package
>>> -dpkg-buildpackage -a$target_arch
>>> +dpkg-buildpackage -a$target_arch --no-check-builddeps
>>>
>>
>> Any reason why this was not part of v5 and is now not in next? It's 
>> still required to cross-compile packages with certain python 
>> dependencies, possibly more.
>>
> 
> Can we get this into next as well (then I would be patch-free in my 
> layer)? Alex asked for an ack on this which I herewith provide.
> 
> We can possibly tune the commit message further: This changes is needed 
> in order to avoid failures of dpkg-buildpackage when a package provides 
> python-pip:native or python-mako:native as build-depends. ":native" 
> would make the builddeps check fail while that is needed to install (via 
>   mk-build-deps) the host-side version of these packages in a 
> cross-build case.

I'm already formatting the patch to resend it. Started test build.

Alex

> 
> Jan
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2018-08-14 12:39 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-24 19:06 [PATCH v4 00/10] Add cross-compilation support Alexander Smirnov
2018-07-24 19:06 ` [PATCH v4 01/10] buildchroot: Add host buildchroot Alexander Smirnov
2018-07-24 19:06 ` [PATCH v4 02/10] isar-bootstrap-helper: Add target architecture for dpkg Alexander Smirnov
2018-07-24 19:06 ` [PATCH v4 03/10] build.sh: Add additional parameter Alexander Smirnov
2018-07-25  8:10   ` Henning Schild
2018-07-25  8:14   ` Henning Schild
2018-07-24 19:06 ` [PATCH v4 04/10] cross-compilation: Introduce variable switch Alexander Smirnov
2018-07-25  6:56   ` Jan Kiszka
2018-07-25  8:25   ` Henning Schild
2018-07-25 12:22     ` Jan Kiszka
2018-07-24 19:06 ` [PATCH v4 05/10] linux: Add ARM cross-compilation support Alexander Smirnov
2018-07-24 19:06 ` [PATCH v4 06/10] isar: Add ARM64 " Alexander Smirnov
2018-07-24 19:06 ` [PATCH v4 07/10] linux-module: Export ARCH and CROSS_COMPILE Alexander Smirnov
2018-07-24 19:06 ` [PATCH v4 08/10] linux: Drop gcc from dependencies Alexander Smirnov
2018-07-24 19:06 ` [PATCH v4 09/10] build.sh: Do not check deps in dpkg-buildpackage Alexander Smirnov
2018-07-24 19:07   ` Alexander Smirnov
2018-08-11 15:47   ` Jan Kiszka
2018-08-14 11:40     ` Jan Kiszka
2018-08-14 12:39       ` Alexander Smirnov
2018-07-24 19:06 ` [PATCH v4 10/10] linux-module: Enable cross-build for testing Alexander Smirnov
2018-07-24 19:07   ` Alexander Smirnov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox