From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6581862148598661120 X-Received: by 2002:aa7:c4d0:: with SMTP id p16-v6mr799729edr.10.1532501802608; Tue, 24 Jul 2018 23:56:42 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a50:fb0c:: with SMTP id d12-v6ls2247979edq.5.gmail; Tue, 24 Jul 2018 23:56:42 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf9BWhE46Jl1H2X/gr54kX0P8rAed25DnbBO9UFCAsAosTuxhWkbwwJ02teCFAMnEd+qpHy X-Received: by 2002:aa7:d998:: with SMTP id u24-v6mr2100327eds.5.1532501802266; Tue, 24 Jul 2018 23:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532501802; cv=none; d=google.com; s=arc-20160816; b=L7mnwqxDKY2at72arZ45LVbV5JT6TptDHvl4zAVb4dE0mTneSx2vP/5NBqAqpGfWGA iXprnl9/brauB3ANBJwdGsH86vwcTy1hZegx3i+S0NX3YP14mt45e5+S2hC8Da9373AV iGCQ6HdIdB090sADgrRhJTLF36oHurnZkfdJdRnES2NnmnBDSA7sKVzNonezz/B80Ty+ skmnJU2KOBEzh8aSv1/976SufStQjGKhd97e0yxZlBdaCFiYfHCkDzALqT6vEgpokriR hAIQoCU2tirOpch9ED48j0N/pZCuErFpK0Fjh1zCZLeGXnu4J3xgeNW+PG7Tv5cSawzg CH4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject :arc-authentication-results; bh=RQOlcCN92nN7yBY3W8mltsCgZCf6YNO44cPPh72Chcw=; b=PJup9bMNKFdhunqlGXVjDibxey03P67jMC1tokm7MF6plq5m4DiRGzWnLVQKsjSPur MPO25rwnbh4sAp9kFU6fXnjzNTEb5UilyE5E/kq85AdsugQgFD4LU6ZSZZVRdheqhz2L 4uYCFEjL7i9hN6WLYzsfaAGBt0769JnXX/VMsMRupoNdBbOwSLIosBXVuADvITP3USD/ o2i8IBkQQLePEZipLXrzNRgGDRm1uSS/akROZuf8XwvdN/h5r6GNRme2yRYvMwp05Qvy xoyvIqb1AHHXrOAXiCACkB7qRgoi/54WqbxKJFGQoWDm3kcD3v1r/hxjK1NY8/ZAqnDJ tT9g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@web.de designates 212.227.17.11 as permitted sender) smtp.mailfrom=jan.kiszka@web.de Return-Path: Received: from mout.web.de (mout.web.de. [212.227.17.11]) by gmr-mx.google.com with ESMTPS id y4-v6si125154edh.4.2018.07.24.23.56.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jul 2018 23:56:42 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@web.de designates 212.227.17.11 as permitted sender) client-ip=212.227.17.11; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@web.de designates 212.227.17.11 as permitted sender) smtp.mailfrom=jan.kiszka@web.de Received: from [192.168.1.10] ([95.157.57.47]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Leca2-1gLPM72kjm-00qV1G; Wed, 25 Jul 2018 08:56:41 +0200 Subject: Re: [PATCH v4 04/10] cross-compilation: Introduce variable switch To: Alexander Smirnov , isar-users@googlegroups.com References: <20180724190618.19155-1-asmirnov@ilbers.de> <20180724190618.19155-5-asmirnov@ilbers.de> From: Jan Kiszka Message-ID: <7cbc4933-8852-e18c-9169-10a5dde6d5c6@web.de> Date: Wed, 25 Jul 2018 08:56:41 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: <20180724190618.19155-5-asmirnov@ilbers.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:P8lI0lH3LIimW287EftxEWtq4r3Gw3+rpNAzkU/8lJmEwv6vfL2 FRVLqdUZozGoyCNHqYtMjZ7T1pTbAZ9bZCb7jVw0lD1ugGUOhbe3grg3yEUgBzPnb1vZPp6 Zdxuh1kJP0zXzC61yhUFYX2/yXclB0LL+bO0wvYpcV34UFPLpT5XFfXNu79BL932RblKF7C zAQvkw0SidGLfzC12Remg== X-UI-Out-Filterresults: notjunk:1;V01:K0:Hv1eOtRRsSM=:GYACB6NX7VE2RmKg+XEIii zdiT9Es40uR2XN6iccOm17Dph+t7AsSFXTP73jkLpAY5NWWljtJ9afzft68i9FC+Z2bB79CtM oFKeOg8amqM/bWPnYCIiFH6cKcjwMDGE++NFnyXFcEVQiR3JsCSdzN0mmVOcHyzzsQD7ypajq rCH+HzKN4aXC1rKFoRbJRLpJUO0xGNLsHLYMa116EsFA0o3iJuutZ+EtcMGfPdYpzB50mA6jW eFNVDCwN8dn4EpqbrEWua8ObIbIM9B5szM+OTPejju/ofl1WhZ4msY8/ygq1pBKDvB5T4D8yC 3UdKl1B9dRNNgYP0IdEzibbMdACzIryH4GyU0NaszxFqak1HJ62cZCHnJD57r9Stc2vJ6vdQ0 T4RJfPd3soWVN/jnoMxWjamrnadxcbPVuEKqaNOKC5CwZb9DE8XCa7XYTz+IL/uVAFI+0UitY rmF4XszhdvBWmHYaCzZzUTHA33Cd6n2r/brsz+S26JD6i5j1/ZJb0g2ibLKEk8uYxgQOY8yK1 10v0NQzS2/Ab2CybsjQ0aj08a8CFRM/evi/cCRLcp2hjsKaus3NLbP9rSGkWebdRPberwytIA gCpr72dk5ivmy3ppYUaXh0EoEq2nkb9oFGsfgvKwDHS/t1SorRmCvM43ABHEctDdGpKmzcdj6 UBZHSBAzMsSozlhs+Kzmv2obWYjdvgjZ+4nYAyixoWTDKxeepZBkzBdyeA+ROcQa6urWcv4Nq Sx2WLfMUVcanmOU78OSTdg2tBoFoHMuxebSmVN8lbHooD3Qr52ETDfNA7c1mq6dMG0uNckWNK Bye6HP+ X-TUID: drjtGE+QD9On On 2018-07-24 21:06, Alexander Smirnov wrote: > Add variable to switch from native to cross compilation. > > Signed-off-by: Alexander Smirnov > --- > 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" >