Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB3DEC11F67 for ; Thu, 1 Jul 2021 21:55:08 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 39CDA613BA for ; Thu, 1 Jul 2021 21:55:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 39CDA613BA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B51F082C45; Thu, 1 Jul 2021 23:55:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="Jwz8NW9l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 55CB282C23; Thu, 1 Jul 2021 23:55:04 +0200 (CEST) Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 57E6882C23 for ; Thu, 1 Jul 2021 23:54:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x836.google.com with SMTP id y9so5241993qtx.9 for ; Thu, 01 Jul 2021 14:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dMf/wiKTofAz6MXuvcf1UuDQp6H5N+hxO76KGb59Hm4=; b=Jwz8NW9lXska0o+5v7M4Ss1WSi102fXyNaxTRQlf/Q5fsCGToZGc+d0l/X95Vz6r7n HI1/3p8+/FmgbxBUIEWKL/9mcIzoTlaUkEkdKp13Dt3ZX4AI4J3Ko5LyhsFuksG/KALg JnboYl8M4+SvtQPBnF8bhfgkHtg9PxwFI7ZrQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dMf/wiKTofAz6MXuvcf1UuDQp6H5N+hxO76KGb59Hm4=; b=VjJanoUz16kbdExJiVRJ9VWJ6q024tFSUWdzQ4gFSop06mge5erBSFbcmyRfJQ5AVq 6fif7p12s8lZ59/E59+fE/jmtqzvFK3fAxee6UIw3dQFH0qZNlkAhKVWoTqcCNarLUK6 dAow2yRTQd++Qi6ifFBpXi4R065AyMBLoj/GD7jp53o508IzDo+L+44TltPDdSDQrNWD J4+rDKWg7m/oerB1CgEiNWEatXs6GNVUItqyCQWDnnD4gHmpf9wvtX6OJWgYL+8DxfnP JRZ61pfFNpDDD1G0+mV56/i4SM0xio4UZLCpHMTRET98p0WbsaM0/8WmKdvUeOZ2Woip wAEg== X-Gm-Message-State: AOAM531R8Zw6zKfOgM753nc1lBzziPKgIHGfnGAB6+YLpaVc33hH34rl TVt7JfaNZEfyRQlG78IVlhzM6w== X-Google-Smtp-Source: ABdhPJxYk4w513KKpcMmIRr9Faa5jw0yOlC6DvGcAQd+v4876UBXcrS1g/5Q7r1Na3iQC6e10gMgJQ== X-Received: by 2002:ac8:430e:: with SMTP id z14mr2062884qtm.71.1625176497217; Thu, 01 Jul 2021 14:54:57 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-91af-d604-26f4-428b.res6.spectrum.com. [2603:6081:7b01:cbda:91af:d604:26f4:428b]) by smtp.gmail.com with ESMTPSA id w25sm498607qto.2.2021.07.01.14.54.56 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Jul 2021 14:54:56 -0700 (PDT) Date: Thu, 1 Jul 2021 17:54:54 -0400 From: Tom Rini To: Rasmus Villemoes Cc: u-boot@lists.denx.de, Stefan Roese , Matt Merhar , Simon Glass Subject: Re: [RFC PATCH 2/2] global-data.h: add build-time sanity check of sizeof(struct global_data) Message-ID: <20210701215454.GS9516@bill-the-cat> References: <20210518091947.63513-1-rasmus.villemoes@prevas.dk> <20210518091947.63513-3-rasmus.villemoes@prevas.dk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="PtqNwSoQId8/oDDr" Content-Disposition: inline In-Reply-To: <20210518091947.63513-3-rasmus.villemoes@prevas.dk> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean --PtqNwSoQId8/oDDr Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 18, 2021 at 11:19:47AM +0200, Rasmus Villemoes wrote: > The layout and contents of struct global_data depends on a lot of > CONFIG_* preprocessor macros, not all of which are entirely converted > to Kconfig - not to mention weird games played here and there. This > can result in one translation unit using one definition of struct > global_data while the actual layout is another. >=20 > That can be very hard to debug. But we already have a mechanism that > can help catch such bugs at build time, namely the asm-offsets > machinery which is necessary anyway to provide assembly code with the > necessary constants. So make sure that every C translation unit that > include global_data.h actually sees the same size of struct > global_data as that which was seen by the asm-offsets.c TU. >=20 > It is likely that this patch will break the build of some boards. For > example, without the patch from Matt Merhar > (https://lists.denx.de/pipermail/u-boot/2021-May/450135.html) or some > other fix, this breaks P2041RDB_defconfig: >=20 > CC arch/powerpc/lib/traps.o > AS arch/powerpc/cpu/mpc85xx/start.o > In file included from include/asm-generic/global_data.h:26, > from ./arch/powerpc/include/asm/global_data.h:109, > from include/init.h:21, > from arch/powerpc/lib/traps.c:7: > include/linux/build_bug.h:99:41: error: static assertion failed: "sizeof(= struct global_data) =3D=3D GD_SIZE" > 99 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) > | ^~~~~~~~~~~~~~ > include/linux/build_bug.h:98:34: note: in expansion of macro =E2=80=98__s= tatic_assert=E2=80=99 > 98 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARG= S__, #expr) > | ^~~~~~~~~~~~~~~ > include/asm-generic/global_data.h:470:1: note: in expansion of macro =E2= =80=98static_assert=E2=80=99 > 470 | static_assert(sizeof(struct global_data) =3D=3D GD_SIZE); > | ^~~~~~~~~~~~~ > make[1]: *** [scripts/Makefile.build:266: arch/powerpc/lib/traps.o] Error= 1 > make: *** [Makefile:1753: arch/powerpc/lib] Error 2 > make: *** Waiting for unfinished jobs.... >=20 > Signed-off-by: Rasmus Villemoes > Reviewed-by: Simon Glass Applied to u-boot/next, thanks! --=20 Tom --PtqNwSoQId8/oDDr Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmDeOa4ACgkQFHw5/5Y0 tyykpAv/frgvaZPFTKVvAfUrhUVvZvE9Bvy7FMYiBVAUGSC9U1oX2Rx7wlU0R/0y c7jaOpaWBfyorKXe8AF9IEvz5ABtuIDBJaYDGbYcFrUjgAyBG670yl9d5ZR2a6uW u0aeugZ2Wd9frrc6mB0yoEEj7JOXr39JeaHS2vNxoqBDxX0GS2QW7ze32O90Q/yV 9j3zfgs3tdVa9tIuI2TYyWDj7HU9h4xsSZdClKfKQ2Oct1ovAFNaNwNbblJ4+Xt3 0sAyhOBLRTazTV1sb4yz7fKCyL6N+JI3laZ2Gsfh8lQ7i1blZI60Gab0y9KOGQYE 2lu7Sii26LmDMPUZlrTd03xudJYPA3hwhGyvT6wjclwM1/KDCPk51hySgQzPePcF FH49UY0o7H+soinQT5pQEK5MkAO/7w0NG8/soYRzmYyIfesL8NPWIA9IuNbCZvbd 15fnntvhVGa9p4Vivv7w7Sbsy+9+0+fkEPmTp5Csg5KFHoGEs6H9R2u/td1THTtq Og6C3uid =MBc6 -----END PGP SIGNATURE----- --PtqNwSoQId8/oDDr--