From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7163980406052618240 X-Received: by 2002:a05:622a:230a:b0:3a5:77c3:d88c with SMTP id ck10-20020a05622a230a00b003a577c3d88cmr17047930qtb.183.1667994169846; Wed, 09 Nov 2022 03:42:49 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:620a:1588:b0:6fa:3c89:c39 with SMTP id d8-20020a05620a158800b006fa3c890c39ls10709446qkk.6.-pod-prod-gmail; Wed, 09 Nov 2022 03:42:49 -0800 (PST) X-Received: by 2002:a05:620a:ce7:b0:6fa:baf6:ce9 with SMTP id c7-20020a05620a0ce700b006fabaf60ce9mr13609695qkj.421.1667994169450; Wed, 09 Nov 2022 03:42:49 -0800 (PST) Received: by 2002:a05:620a:2946:b0:6ee:e259:e652 with SMTP id af79cd13be357-6fb040d923fms85a; Wed, 9 Nov 2022 02:32:50 -0800 (PST) X-Google-Smtp-Source: AMsMyM7qd6oblO5igURKxgBr2GTQ4ytzD3tkEt3LqZCVFYMEEp84ihL+GaEtA2C3nrflMaS1hfmI X-Received: by 2002:a05:600c:1d11:b0:3cf:7981:9a2 with SMTP id l17-20020a05600c1d1100b003cf798109a2mr32504295wms.92.1667989969714; Wed, 09 Nov 2022 02:32:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667989969; cv=pass; d=google.com; s=arc-20160816; b=AqJM2pmNz4bzHY5VjD55uaBTaxCPUqFGmXXlhlrJR7rx7jn3ZJ0ap8KBztFZ2X5C8w coEgALj53kd+3e0fv5zm35S/uXBZqAZZ8rIojZQIRLbBDa0lMUM1eu4zIJ1Ku9FM/qdc 0Xe7PcuBHJQ3qKvgGa2wQ2JYgxXTafL+3zb2ZkSwW2DyDwZ4rSrQWX2PJhiYH8PR/nWL j3QzzasiyDersJvFI4J5ReO69MRlWO7ItuRrRhZN+gIZI0XDseLb+usPvtArLj915xyU g1DfyaGUY1jj39ZA6K6psv3GybUIlv3IKYCM8RIWRpoRFDf1VJ9H3zslUd9ugetMVPTx +qfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=dJbjFWfUL+zT1i0Gnu3tqDZpUFwfzXLzLz7LqZJpNXE=; b=DADZm2cjOqSgW0nkxe4eK7v72HQ3vVN4FwhbzYPaeTjGUJVBb4KUlOpQoMvSU90Aug R/fhMFh1QJOrvJe0Q+Nz7HR+YGSSjsU5l8lFRCm6a7RnzlTZM0pWRaKR/AbQj4Gr74Bf ZxNWxce26xeFD4pK4oN/kfjG3y0dKAJjuTjwC5IfU8nwRUohzYYvmnviwpWEVL+JtbgX 0JB4RpBH1rIPXcOb8n7JH9nu/yfpFdsPvW/TaBp0aQ373cH+MzEL0xFp5kyC/fkKCSUT cKiGXfX6/BN/pNth+WYaoMbrGEqL4Zbd9Yrb7WynuHvJlY/1nJsmuKMETG8r/niLdq7M rLiw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=bsrXEycU; arc=pass (i=1 spf=pass spfdomain=siemens.com dkim=pass dkdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of stefan-koch@siemens.com designates 40.107.21.70 as permitted sender) smtp.mailfrom=stefan-koch@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2070.outbound.protection.outlook.com. [40.107.21.70]) by gmr-mx.google.com with ESMTPS id r63-20020a1c2b42000000b003cf567afb1fsi55291wmr.3.2022.11.09.02.32.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Nov 2022 02:32:49 -0800 (PST) Received-SPF: pass (google.com: domain of stefan-koch@siemens.com designates 40.107.21.70 as permitted sender) client-ip=40.107.21.70; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=bsrXEycU; arc=pass (i=1 spf=pass spfdomain=siemens.com dkim=pass dkdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of stefan-koch@siemens.com designates 40.107.21.70 as permitted sender) smtp.mailfrom=stefan-koch@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iQ9xwx2SdAGuXcZEHF9XuKfbp2+SzBxCFIJ4BhUDy8+SQdnrq9Vje+iWwDVGtbLJnF9AVOx6z8n0VcM2j/iBZGRHM4u6F2O8AdmxaDTgey1h/KgYU6wnilF+/XOf2UaV5PF4NmDyw1sL7/5/Cl+4jTXZQZ57RmTr9FWBwWaI2ZZ8GR3ZXLqslR8i1HqkzLqH6rtfyfnHl45H7WxaDhnGhef700EcVgoQNQ4w+MmIAXIsHN58aoKH3V7j2MOTd6fkNRZpcNohDInVqWy0mhG/HHBilkPQI9QwkoBWAvAqvon0rO1iDv1sdXgB2V7OhWeSmtYjz6fWV0houOGlWH1Zvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dJbjFWfUL+zT1i0Gnu3tqDZpUFwfzXLzLz7LqZJpNXE=; b=PsufSvNfJQsIyBwTJc5LgqXdNuECaGmkZdQvqRzHaIyKUJywNyX3E0WG2cXdS7/enz+SifZCCD0FAxOj1cfN5JB98bZpe2TmAar0kTe/H+H2/WVGn6W4hRB6rAtL2Xh/Lzzzk2w03wzeOk4VGPoiZSiDfgrcNVcFBaz+MaKulkIhrsXDutbRTawVLb2HaEu+eg8HuKQ4tI4e0wk6jWu1fGHfxBdyumDEdkI6Jgwe/WPkr2acI011if9KA7VswCOnZ8tBRsmvWSBBzrY8AWUx/zGmPI1dKE9qmasNGNKpMbUiYxXx01deUbI7mLGm1HpGXoF6/vRd6eM6PxWja0cT3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dJbjFWfUL+zT1i0Gnu3tqDZpUFwfzXLzLz7LqZJpNXE=; b=bsrXEycUgikVU3KaF67YZCBSK7IpvV8MLIY4kxpwmCOp3SRtwVuHhrcyN6DNhrHrUsNjBzkiKXGHjXHg4o89Jx4VsjH+Wz3DiGuTkRWuXCwGDDHRYtglzBaClD2Oh4nedJ+qR04unbraQWzAObwgL5OYrWP63ybBedsUpGJj6VscXEnFCaNGKc9BE6hwibJEyiMp8GptW8U8+kEcwcJ99jFZmfG8jzX3yg2VaqYmKNh53ILxyDa9sM0TeFn0rv/OypJdD4Fwe2fafhXox0iXM5/XuqSAjtlCzrqwoYw1VEAFhIMqgReS8h/rVtBBbdauFbet9oy9ROyo9Y/7ezYWfg== Received: from AM9PR10MB4959.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:41e::11) by AM9PR10MB4070.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:1fc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 10:32:48 +0000 Received: from AM9PR10MB4959.EURPRD10.PROD.OUTLOOK.COM ([fe80::c90f:cedc:2354:fd0d]) by AM9PR10MB4959.EURPRD10.PROD.OUTLOOK.COM ([fe80::c90f:cedc:2354:fd0d%7]) with mapi id 15.20.5791.027; Wed, 9 Nov 2022 10:32:48 +0000 From: "Koch, Stefan" To: "isar-users@googlegroups.com" CC: "Kiszka, Jan" , "Storm, Christian" , "Adler, Michael" , "Sudler, Simon" , "Koch, Stefan" Subject: [PATCH 2/3] linux-custom: Split up binaries from kernel headers to kbuild packages Thread-Topic: [PATCH 2/3] linux-custom: Split up binaries from kernel headers to kbuild packages Thread-Index: AQHY9CacrP1mA/n8bUO/arJxEzNcHg== Date: Wed, 9 Nov 2022 10:32:48 +0000 Message-ID: <20221109103238.1520091-3-stefan-koch@siemens.com> References: <20221109103238.1520091-1-stefan-koch@siemens.com> In-Reply-To: <20221109103238.1520091-1-stefan-koch@siemens.com> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.30.2 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM9PR10MB4959:EE_|AM9PR10MB4070:EE_ x-ms-office365-filtering-correlation-id: ae7353e0-0a76-4182-dbd3-08dac23dbf1e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Caf60qkhCSvySv552I+5ld3gBt/eerqCy6P511W6kzhDtHPXzn45BO31Ejv1vOICJgKXYXLdl4d80a9lATh7KfXudsokj5sp7Sb8H2b2nJQ4SUJ0XT188q8Yk2OH7uPsoJPlBeyAYnM8phU/ic9rzwZ8yxOYjjL4XFJWYW3y2lhbpd65bF+i1hQ6WGRqbBjED81ScE0Nx/bjTnc6I3Lb6UDl3U98pC7I9yxh8ZHI+eHh2YnPIidS4FGF71AMee8GCxxoLIk7z3jpgjqMJE4LuBdzEqwPWF4gnAJM0tLTZy2TfwDepXPkOU7oF1soH6VTdKf/I8LkfzLKbkZQDd0GPvbsG19Y6HQlaMknqAYvUX84m9hoqMo6qYy52QsVanhXUT2HGBnJlheZPq6ZV+embXpFjH4sRbCY+nY/6T5nXPyg5MAyVS19nMGK0Zl3jIZIa63qfacIkpChB5oHptOPtC9e1DxiP5blQXoSJepB9Q2fyA/EH2vI+TdT84erGuEVsHmuSKJt1H++CHsiMxMtLHDElOhn/Z6lJRqEGBHJiJpzCXxZ46XGhd1TUgM48aN4ZqVj0A/52WINVngm0dI+sM/ySI1W2QRo9GMhi5ZOTgFtDZAVG6fMwHcRqewvr+rGFwYqAAdjhRbFVAJxwBR9uwuDaK3penMLtzJSKOd6Df5dFWnFJQSjbG+4KM2PB2e3OEgI4VR0CBL8ah/T1flKGVoF2CG8FjMmGA79N/XiOKlU94W39QTrSlWqlbsd7jgpXhyzYrOKPvwYSKCB61msig== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR10MB4959.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(39860400002)(366004)(396003)(376002)(136003)(451199015)(6486002)(478600001)(30864003)(186003)(38100700002)(1076003)(82960400001)(122000001)(26005)(41300700001)(5660300002)(6512007)(86362001)(38070700005)(2906002)(91956017)(4326008)(8676002)(66446008)(66476007)(66946007)(76116006)(64756008)(66556008)(71200400001)(2616005)(8936002)(36756003)(6506007)(316002)(6916009)(54906003)(107886003)(83380400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?VjwkSOvemT4iz1lm+ErR3NbkzDO9Ff8IcK4gSrCnJ+m/LiYwLVBXWKo7mK?= =?iso-8859-1?Q?Zuw6o/sHMcto5tlfY0tPPT4sBAQBahHqxg4o4G4JG6wrA+RLPHrMAw95kE?= =?iso-8859-1?Q?WRLj+2ZUT2skOYpqDH8xwZ2Dld6vmt0cSBl/kqEKrsqM80K14Tp14uiclJ?= =?iso-8859-1?Q?9kkUdyb+/1zaQD38ilXdk1x/aQJG0zTQvXPCX0FOQi4R5yUVw1YxLseAGN?= =?iso-8859-1?Q?hm4tc+07kNfzD8zFfRh9Cx9iHXDB80Exc5Hftvp4fj1vIDa9+QzyBMsL9J?= =?iso-8859-1?Q?nlLDRWs4vXoTwnIjXnOeipX8MLt0MuyCMWLiyfAVPkHSMpnWsiPrDDRsYK?= =?iso-8859-1?Q?6Cj+GeAHNbytzc3c5nbVcefjJcFXx3YSDnRTEeLgSDke16gUALGPWkVY1y?= =?iso-8859-1?Q?p4cMv7ARJHXKWIM6/j+Mn2DLht70LdpfBbQ2oMV2MSN+Ku8au2IE6Yj3/f?= =?iso-8859-1?Q?fBVklYI2TPQYOBBO9mh/K+nTNgJC/9LGuiTsqVXn+j93X1/LtD5Tjiiy6P?= =?iso-8859-1?Q?p98TbaAzOh7zODBtjViIisYTAs81R+J3ORJoeE4uMJ6c+eqZhz9WdgSlw0?= =?iso-8859-1?Q?II4XRTuxHzRBrVvL2CVWCiAA3gUS9cjB2Q74BoJj3cg5wZERQS8ucuozuP?= =?iso-8859-1?Q?UAQhqiqSCuOyc/MAP6UDhEPKdCGn8FuJpdUB4WKq1Q5cZs0aOOgvlt6C2F?= =?iso-8859-1?Q?Bq62wzlNOEf7q1WhypUZN/hrDclE94BS3SXgHCYqhkn/SE/GO1TrgcPcII?= =?iso-8859-1?Q?Z9PvRdW8PsGFtLeZSfzb0pzmuaUwcKWqFu1NZf23h5oQdLzsLLvk/0aJ8j?= =?iso-8859-1?Q?l7vgDIpj/LKMh3OWDvHY/hVGL/sfzLKVcI2O6PNhv0CRD6XoMzsxZzGKGz?= =?iso-8859-1?Q?jPiUGddrT07LvClOVXlAA9/5uvcgnm7rp7L01SHLtjozaeguDf1QtIc5K8?= =?iso-8859-1?Q?TNGsuOkZUDm1t/++5LASULS9HPMLDCD5GsHsAwXaLyLQjXV8K63yCn3QXR?= =?iso-8859-1?Q?PFEshTFCD+auaSzOYj/WuXidd1jJa3GwBWM1n3sITDQlBosNgLY6655NHV?= =?iso-8859-1?Q?A18TVghnvD029mMFEm0Q+XXCw+9ReFb0Ol/9TKPQLhyFqswvsdxkI2Hgyr?= =?iso-8859-1?Q?u1xXJVs7s2+XSUip72G94j9kNPKxGd24TdlBBpqNRdhI6JlnSCKjkeW81C?= =?iso-8859-1?Q?+6CZZdkpJUegWEqHTMA9uxyE6FyZqL67pBeaSkBPNLN33nFWY15pNF0kTz?= =?iso-8859-1?Q?ehPPqz1jOhXElud7924Q8qUFvumMAgnYJ6ZbhvXLLZG2EfSz/HsqzMSU5o?= =?iso-8859-1?Q?cPbQWLSrkY2u+AhkB3oV83ZtvdROuRwicB67q5AH4HPXEJCbzub6vrm2L+?= =?iso-8859-1?Q?E19UVFeNAkq6LNdYE2APF+2vdGevcFSz1uPZH5W6AHCw5v+HeGsZ9dJ2hb?= =?iso-8859-1?Q?0JDmkDEVjhVT6c9T9J7DScOAxKNJG8b/VnkQM0hdHovd+mDvkZTg4fPbiX?= =?iso-8859-1?Q?6cDGiImxvvK0r5GmLkoR1+IDhnYcsv4moZC2fxT2GR5rfj5OAzxeOOYTD/?= =?iso-8859-1?Q?kd405ObKVux/JWT8IN+3ZnrhqdEHvwDQXb4P/fiXPBnrTGOZUepEKInauZ?= =?iso-8859-1?Q?JU5Wvy3YrcD31V9EdJiHzBloTpqjieO2dAlziMLpevEeU3lWz6kSjqiA?= =?iso-8859-1?Q?=3D=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM9PR10MB4959.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: ae7353e0-0a76-4182-dbd3-08dac23dbf1e X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2022 10:32:48.1298 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uo1ITlNeuQJ9s2jEiKaR2WtFdlfRfhNnIni9wdJQ6H3Dtsw9lZRYaSdcMUUfqWLj/GE/mVdy3SYk13H/K6dQKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR10MB4070 X-TUID: IUp1sWSPZ/++ When using a cross build this patch does introduce host and target specific kernel kbuild packages that ship the "scripts" and "tools" binaries. The kernel headers fulfill this using symlinks to point to the "scripts" and "tools" of the respective kernel kbuild package. Known from doc/custom_kernel.inc: - The kernel headers package has not supported both native and cross compilation of kernel modules when itself was cross built - Future roadmap: Generate kernel headers package for both host and target when using a cross build Known from debian kernel packages structure: - Generate a kernel headers package without binaries - Create specific kernel kbuild packages that ship the "scripts" and "tools" binaries - Using symlinks to point to the "scripts" and "tools" binaries Signed-off-by: Stefan Koch --- .../linux/files/debian/control.tmpl | 18 ++- .../linux/files/debian/isar/build.tmpl | 9 +- .../linux/files/debian/isar/common.tmpl | 7 +- .../linux/files/debian/isar/install.tmpl | 64 +++++++++-- .../linux/files/debian/rules.tmpl | 5 +- meta/recipes-kernel/linux/linux-custom.inc | 104 ++++++++++++++++-- 6 files changed, 178 insertions(+), 29 deletions(-) diff --git a/meta/recipes-kernel/linux/files/debian/control.tmpl b/meta/rec= ipes-kernel/linux/files/debian/control.tmpl index dd0b624..adac4ef 100644 --- a/meta/recipes-kernel/linux/files/debian/control.tmpl +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl @@ -26,7 +26,7 @@ Section: devel Provides: linux-kernel-headers Architecture: any Description: Linux support headers for userspace development - This package provides userspaces headers from the Linux kernel. These he= aders + This package provides userspaces headers from the Linux kernel. These hea= ders are used by the installed headers for GNU glibc and other system librarie= s. =20 Package: linux-image-${KERNEL_NAME_PROVIDED}-dbg @@ -35,3 +35,19 @@ Architecture: any Description: Linux kernel debugging symbols for @KR@ This package will come in handy if you need to debug the kernel. It provi= des all the necessary debug symbols for the kernel and its modules. + +Package: linux-kbuild-${KERNEL_NAME_PROVIDED} +Architecture: any +Depends: ${KERNEL_HEADERS_DEBIAN_DEPENDS}, ${perl:Depends}, ${shlib:Depend= s} +Description: ${KERNEL_NAME_PROVIDED} Linux kbuild scripts and tools for @K= R@ + This package provides kernel kbuild scripts and tools for @KR@ + This is useful for people who need to build external modules + +Package: linux-kbuild-${KERNEL_NAME_PROVIDED}-cross +Architecture: ${CONTROL_TARGET_ARCH} +Depends: ${KERNEL_HEADERS_DEBIAN_DEPENDS}, ${perl:Depends}, ${shlib:Depend= s} +Description: ${KERNEL_NAME_PROVIDED} Linux kbuild scripts and tools for @K= R@ + This package provides kernel kbuild scripts and tools + as ${HOST_ARCH} cross binaries for @KR@ + This is useful for those who need to cross build + external modules using ISAR's sbuild-chroot-host diff --git a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl b/meta/= recipes-kernel/linux/files/debian/isar/build.tmpl index 94cfbe0..7e2daad 100644 --- a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl +++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl @@ -13,16 +13,19 @@ do_build() { # Trace what we do here set -x =20 + # Set correct build directory for kernel or kbuild (kernel scripts and= tools) cases + build_dir=3D${KERNEL_BUILD_DIR} + # Process existing kernel configuration to make sure it is complete # (use defaults for options that were not specified) - ${MAKE} O=3D${KERNEL_BUILD_DIR} olddefconfig prepare + ${MAKE} O=3D${build_dir} olddefconfig prepare =20 # Transfer effective kernel version into control file and scripts - KR=3D$(${MAKE} O=3D${KERNEL_BUILD_DIR} -s --no-print-directory kernelr= elease) + KR=3D$(${MAKE} O=3D${build_dir} -s --no-print-directory kernelrelease) sed -i "s/@KR@/${KR}/g" ${S}/debian/control ${S}/debian/linux-image-${= KERNEL_NAME_PROVIDED}.* =20 # Build the Linux kernel - ${MAKE} O=3D${KERNEL_BUILD_DIR} ${PARALLEL_MAKE} KCFLAGS=3D"${KCFLAGS}= " + ${MAKE} O=3D${build_dir} ${PARALLEL_MAKE} KCFLAGS=3D"${KCFLAGS}" =20 # Stop tracing set +x diff --git a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl b/meta= /recipes-kernel/linux/files/debian/isar/common.tmpl index 52ebebb..55d6123 100644 --- a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl @@ -5,10 +5,14 @@ set -e =20 # Isar settings -ARCH=3D${KERNEL_ARCH} KERNEL_PKG_IMAGE=3Dlinux-image-${KERNEL_NAME_PROVIDED} KERNEL_PKG_KERN_HEADERS=3Dlinux-headers-${KERNEL_NAME_PROVIDED} KERNEL_PKG_LIBC_HEADERS=3Dlinux-libc-dev +KERNEL_PKG_KERN_KBUILD=3Dlinux-kbuild-${KERNEL_NAME_PROVIDED} + +if [ -z "${ARCH}" ]; then + ARCH=3D${KERNEL_ARCH} +fi =20 # Constants KCONF=3D.config @@ -19,6 +23,7 @@ deb_img_dir=3D${deb_top_dir}/${KERNEL_PKG_IMAGE} deb_dbg_dir=3D${deb_img_dir}-dbg deb_kern_hdr_dir=3D${deb_top_dir}/${KERNEL_PKG_KERN_HEADERS} deb_libc_hdr_dir=3D${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS} +deb_kern_kbuild_dir=3D${deb_top_dir}/${KERNEL_PKG_KERN_KBUILD} =20 # Array of packages to be generated declare -A kern_pkgs diff --git a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl b/met= a/recipes-kernel/linux/files/debian/isar/install.tmpl index 0a8645d..890a996 100644 --- a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl @@ -33,6 +33,7 @@ do_install() { # Trace what we do here set -x =20 + # Run the install steps install_image if [ "${ARCH}" !=3D "um" ]; then install_config @@ -43,6 +44,19 @@ do_install() { install_kmods install_headers =20 + if [ -d "$(dirname ${O})/build-full-kbuild-target" ]; then + # Install cross kernel scripts and tools + install_kbuild ${deb_kern_kbuild_dir}-cross build-full + + # Cleanup and install kernel scripts and tools for target arch + rm -rf ${deb_kern_kbuild_dir} + install_kbuild ${deb_kern_kbuild_dir} build-full-kbuild-target + else + # Cleanup and install kernel scripts and tools + rm -rf ${deb_kern_kbuild_dir} + install_kbuild ${deb_kern_kbuild_dir} build-full + fi + # Stop tracing set +x } @@ -168,21 +182,15 @@ kernel_headers() { mkdir -p ${destdir} mkdir -p ${deb_kern_hdr_dir}/lib/modules/${krel} =20 - (cd ${S}; find . -name 'Makefile*' -o -name 'Kconfig*' -o -name '*.pl'= ) >>${src_hdr_files} - (cd ${S}; find arch/*/include include scripts -type f -o -type l) >>${= src_hdr_files} + (cd ${S}; find . -not -path './scripts/*' -a -not -path './tools/*' -a= \( -name 'Makefile*' -o -name 'Kconfig*' -o -name '*.pl' \)) >>${src_hdr_f= iles} + (cd ${S}; find arch/*/include include -type f -o -type l) >>${src_hdr_= files} (cd ${S}; find arch/${ARCH} -name module.lds -o -name Kbuild.platforms= -o -name Platform) >>${src_hdr_files} (cd ${S}; find $(find arch/${ARCH} -name include -o -name scripts -typ= e d) -type f) >>${src_hdr_files} =20 if [ -n "${CONFIG_MODULES}" ]; then echo Module.symvers >> ${obj_hdr_files} fi - (cd ${O}; find arch/${ARCH}/include include scripts -type f) >>${obj_h= dr_files} - if [ -n "${CONFIG_STACK_VALIDATION}" ]; then - (cd ${O}; find tools/objtool -type f -executable) >>${obj_hdr_file= s} - fi - if [ -n "${CONFIG_GCC_PLUGINS}" ]; then - (cd ${O}; find scripts/gcc-plugins -name *.so -o -name gcc-common.= h) >>${obj_hdr_files} - fi + (cd ${O}; find arch/${ARCH}/include include -type f) >>${obj_hdr_files= } =20 # deploy files that were matched above tar -C ${S} -cf - -T - <${src_hdr_files} | tar -C ${destdir} -xf - @@ -191,8 +199,11 @@ kernel_headers() { # add the kernel config cp ${O}/${KCONF} ${destdir}/.config =20 - # handle kernel development tools - kernel_tools + # add symlink to scripts and tools directories + ln -sf ../../lib/linux-kbuild-${krel}/scripts ${destdir}/scripts + if [ -n "${CONFIG_STACK_VALIDATION}" ]; then + ln -sf ../../lib/linux-kbuild-${krel}/tools ${destdir}/tools + fi =20 # create symlinks ln -sf /${kernel_headers_dir} ${deb_kern_hdr_dir}/lib/modules/${krel}/= build @@ -206,4 +217,35 @@ install_headers() { kernel_headers } =20 +install_kbuild() { + kernel_kbuild_dir=3Dusr/lib/linux-kbuild-${krel} + destdir=3D${1}/${kernel_kbuild_dir} + src_kbuild_files=3D$(mktemp) + obj_kbuild_files=3D$(mktemp) + + if [ -n "${2}" ]; then + O=3D$(dirname ${O})/${2} + fi + + mkdir -p ${destdir} + + (cd ${S}; find . -path './scripts/*' -a -path './tools/*' -a \( -name = 'Makefile*' -o -name 'Kconfig*' -o -name '*.pl' \)) >>${src_kbuild_files} + (cd ${S}; find scripts -type f -o -type l) >>${src_kbuild_files} + + (cd ${O}; find scripts -type f) >>${obj_kbuild_files} + if [ -n "${CONFIG_STACK_VALIDATION}" ]; then + (cd ${O}; find tools/objtool -type f -executable) >>${obj_kbuild_f= iles} + fi + if [ -n "${CONFIG_GCC_PLUGINS}" ]; then + (cd ${O}; find scripts/gcc-plugins -name *.so -o -name gcc-common.= h) >>${obj_kbuild_files} + fi + + # deploy files that were matched above + tar -C ${S} -cf - -T - <${src_kbuild_files} | tar -C ${destdir} -xf - + tar -C ${O} -cf - -T - <${obj_kbuild_files} | tar -C ${destdir} -xf - + + # handle kernel development tools + kernel_tools +} + main install ${*} diff --git a/meta/recipes-kernel/linux/files/debian/rules.tmpl b/meta/recip= es-kernel/linux/files/debian/rules.tmpl index 8063c49..e131288 100755 --- a/meta/recipes-kernel/linux/files/debian/rules.tmpl +++ b/meta/recipes-kernel/linux/files/debian/rules.tmpl @@ -36,4 +36,7 @@ override_dh_auto_test: true =20 override_dh_strip: - unset DEB_HOST_GNU_TYPE && dh_strip -Xvmlinu --no-automatic-dbgsym + dh_strip -Xvmlinu -Xlinux-kbuild-${KERNEL_NAME_PROVIDED}-cross --no-autom= atic-dbgsym + +override_dh_shlibdeps: + dh_shlibdeps -Xlinux-kbuild-${KERNEL_NAME_PROVIDED} diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kern= el/linux/linux-custom.inc index 96f0afc..0f8ba50 100644 --- a/meta/recipes-kernel/linux/linux-custom.inc +++ b/meta/recipes-kernel/linux/linux-custom.inc @@ -74,12 +74,14 @@ TEMPLATE_VARS +=3D " \ KERNEL_ARCH \ KERNEL_DEBIAN_DEPENDS \ KERNEL_BUILD_DIR \ + KERNEL_KBUILD_DIR \ KERNEL_FILE \ KERNEL_HEADERS_DEBIAN_DEPENDS \ LINUX_VERSION_EXTENSION \ KERNEL_NAME_PROVIDED \ KERNEL_CONFIG_FRAGMENTS \ KCFLAGS \ + CONTROL_TARGET_ARCH \ " =20 inherit dpkg @@ -91,30 +93,54 @@ KCFLAGS ?=3D "-fdebug-prefix-map=3D${CURDIR}=3D." # Derive name of the kernel packages from the name of this recipe KERNEL_NAME_PROVIDED ?=3D "${@ d.getVar('PN', True).partition('linux-')[2]= }" =20 -# Make bitbake know we will be producing linux-image and linux-headers pac= kages python() { kernel_name =3D d.getVar("KERNEL_NAME_PROVIDED", True) - d.setVar('PROVIDES', 'linux-image-' + kernel_name + ' ' + \ - 'linux-headers-' + kernel_name) + distro_arch =3D d.getVar("DISTRO_ARCH", True) + host_arch =3D d.getVar("HOST_ARCH", True) + target_arch =3D "" + kbuild_depends =3D "linux-kbuild-" + kernel_name + + # For different distro and host archs + # - Set target arch (empty string disables package build) + # - Add dependency for sbuild-chroot-target + # to allow building arch specific kbuild scripts and tools + # - Set correct name of kbuild package dependency + if distro_arch !=3D host_arch: + d.appendVar("SCHROOT_DEP", " sbuild-chroot-target:do_build") + if d.getVar("ISAR_CROSS_COMPILE", True) =3D=3D "1": + target_arch =3D distro_arch + kbuild_depends =3D kbuild_depends + "-cross | " + kbuild_depen= ds + + # Set CONTROL_TARGET_ARCH + d.setVar("CONTROL_TARGET_ARCH", target_arch) + + # Make bitbake know we will be producing + # linux-image and linux-headers packages + d.setVar("PROVIDES", "linux-image-" + kernel_name + " " + \ + "linux-headers-" + kernel_name) + + # Set dependency for kbuild package + d.appendVar("KERNEL_HEADERS_DEBIAN_DEPENDS", kbuild_depends) } =20 -def get_kernel_arch(d): - distro_arch =3D d.getVar("DISTRO_ARCH") - if distro_arch in ["amd64", "i386"]: +def get_kernel_arch(d, arch=3D"DISTRO_ARCH"): + arch =3D d.getVar(arch) + if arch in ["amd64", "i386"]: kernel_arch =3D "x86" - elif distro_arch =3D=3D "arm64": + elif arch =3D=3D "arm64": kernel_arch =3D "arm64" - elif distro_arch =3D=3D "armhf": + elif arch =3D=3D "armhf": kernel_arch =3D "arm" - elif distro_arch =3D=3D "mipsel": + elif arch =3D=3D "mipsel": kernel_arch =3D "mips" - elif distro_arch =3D=3D "riscv64": + elif arch =3D=3D "riscv64": kernel_arch =3D "riscv" else: kernel_arch =3D "" return kernel_arch =20 KERNEL_ARCH ??=3D "${@get_kernel_arch(d)}" +KERNEL_HOST_ARCH ??=3D "${@get_kernel_arch(d, 'HOST_ARCH')}" =20 def config_fragments(d): fragments =3D [] @@ -157,6 +183,7 @@ do_prepare_build_prepend() { =20 # build directory for our "full" kernel build KERNEL_BUILD_DIR =3D "build-full" +KERNEL_KBUILD_DIR =3D "${KERNEL_BUILD_DIR}-kbuild" =20 def get_kernel_config_target(d): kernel_defconfig =3D d.getVar('KERNEL_DEFCONFIG', True) @@ -187,15 +214,19 @@ def get_kernel_config_fragments(d): KERNEL_CONFIG_FRAGMENTS =3D "${@get_kernel_config_fragments(d)}" =20 dpkg_configure_kernel() { + build_dir=3D"${KERNEL_BUILD_DIR}" + if [ -n "${1}" ]; then + build_dir=3D"${1}" + fi grep -q "KERNEL_CONFIG_TARGET=3D" ${S}/debian/isar/configure || cat << EOF | sed -i '/^do_configure() {/ r /dev/stdin' ${S}/debian/isar/= configure KERNEL_CONFIG_TARGET=3D"${@get_kernel_config_target(d)}" EOF =20 - rm -rf ${S}/${KERNEL_BUILD_DIR} && mkdir -p ${S}/${KERNEL_BUILD_DIR} + rm -rf ${S}/${build_dir} && mkdir -p ${S}/${build_dir} if [ -n "${KERNEL_DEFCONFIG}" ]; then if [ -e "${WORKDIR}/${KERNEL_DEFCONFIG}" ]; then - cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/${KERNEL_BUILD_DIR}/.config + cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/${build_dir}/.config fi fi =20 @@ -210,4 +241,53 @@ EOF =20 dpkg_runbuild_prepend() { dpkg_configure_kernel + + if [ "${ISAR_CROSS_COMPILE}" =3D "1" ] && [ "${HOST_ARCH}" !=3D "${DISTRO= _ARCH}" ]; then + # Create temporarily kernel schroot-target configuration + schroot_create_configs ${SCHROOT_TARGET_DIR} + + # Begin kernel schroot-target session + schroot_session=3D$(schroot -b -c ${SBUILD_CHROOT}) + + # Install build deps for schroot session + schroot -u root -r -c $schroot_session -- sh -c " \ + cd ${PP}/${PPS}; \ + mk-build-deps -i -r --host-arch ${DISTRO_ARCH} -t \"apt-get -y --no-ins= tall-recommends --allow-downgrades -o Debug::pkgProblemResolver=3Dyes\" deb= ian/control; \ + " + + # Create kernel configuration for kbuild + dpkg_configure_kernel ${KERNEL_KBUILD_DIR}-target + KERNEL_CONFIG_TARGET=3D"${@get_kernel_config_target(d)}" + + schroot -r -c $schroot_session -- sh -c " \ + cd ${PP}/${PPS}; \ + ARCH=3D${KERNEL_ARCH} make O=3D${KERNEL_KBUILD_DIR}-target ${KERNEL_CON= FIG_TARGET}; \ + " + + cd ${S} + ARCH=3D${KERNEL_ARCH} ./scripts/kconfig/merge_config.sh -m -O ${KERNEL_K= BUILD_DIR}-target/ ${KERNEL_KBUILD_DIR}-target/.config ${KERNEL_CONFIG_FRAG= MENTS} + cd - + + # Build kernel scripts and tools for target arch in a non-cross w= ay + # Cross building kernel scripts and tools would not provide them = in target architecture + schroot -r -c $schroot_session -- sh -c " \ + cd ${PP}/${PPS}; \ + ARCH=3D${KERNEL_ARCH} make O=3D${KERNEL_KBUILD_DIR}-target olddefconfig= ; \ + ARCH=3D${KERNEL_ARCH} make O=3D${KERNEL_KBUILD_DIR}-target ${PARALLEL_M= AKE} scripts; \ + if [ -d "tools/objtool" ]; then \ + echo ARCH=3D${KERNEL_ARCH} make O=3D${KERNEL_KBUILD_DIR}-target ${PARA= LLEL_MAKE} tools/objtool; \ + ARCH=3D${KERNEL_ARCH} make O=3D${KERNEL_KBUILD_DIR}-target ${PARALLEL_= MAKE} tools/objtool; \ + fi; \ + if grep -q "CONFIG_MODULES=3Dy" ${KERNEL_KBUILD_DIR}-target/.config; th= en \ + echo ARCH=3D${KERNEL_ARCH} make O=3D${KERNEL_KBUILD_DIR}-target ${PARA= LLEL_MAKE} modules_prepare; \ + ARCH=3D${KERNEL_ARCH} make O=3D${KERNEL_KBUILD_DIR}-target ${PARALLEL_= MAKE} modules_prepare; \ + fi; \ + " + + # End kernel schroot-target session + schroot -e -c $schroot_session + + # Restore kernel schroot-host configuration + schroot_create_configs + fi } --=20 2.30.2