Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 88CD7C433FE for ; Fri, 14 Oct 2022 03:06:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 137E784F15; Fri, 14 Oct 2022 05:05:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de 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; secure) header.d=gmx.net header.i=@gmx.net header.b="F9JdRzrf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C26D84DD1; Fri, 14 Oct 2022 05:05:50 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C420984F11 for ; Fri, 14 Oct 2022 05:05:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1665716733; bh=mf/vUtBQzVAJngcHTC8PC2FKl3O1Lyfqh/jjx3CXH5g=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=F9JdRzrfC5wQL5U2MjM0k2XQGd7KloO7ZgWK21PG+8RLIs4zdiF6R/8VkzxKPKvfO ZGdV62xZ6s/1S7yQnv+MndpkWxi3WPRAai7pdAGD4PlPEjnzLXM+kAhBlLLmJFX1uw WPM9SU6SvEhExuDg1qavM4DtjXE0/ltu9lLhoEmg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.94] ([84.118.157.2]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MowGU-1pUuwt2js6-00qO6L; Fri, 14 Oct 2022 05:05:33 +0200 Message-ID: <1e2f9172-10a5-e471-0e0b-7aa14905de2c@gmx.de> Date: Fri, 14 Oct 2022 05:05:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [PATCH] tests: Build correct sandbox configuration on 32bit To: Michal Suchanek Cc: AKASHI Takahiro , Heiko Thiery , =?UTF-8?Q?Marek_Beh=c3=ban?= , =?UTF-8?Q?Pali_Roh=c3=a1r?= , Quentin Schulz , Samuel Holland , Simon Glass , Stefan Roese , Weijie Gao , u-boot@lists.denx.de References: <20221013202855.13904-1-msuchanek@suse.de> Content-Language: en-US From: Heinrich Schuchardt In-Reply-To: <20221013202855.13904-1-msuchanek@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:JW/4ezjo/Q7mqrkt08ruV2nTkg4z4Jdg3DW6GrFXbbxfYiRcRFq eWCCOk2MBz1PHQt+6AdfjlcQgxWRXL/ClBRFRZ0PP6m/1w2FVJjmu/vnDWK9TV1GDBZfMrd AVm1Q7EUzQWJy6JJJZT2lDOlYiKfTet/YuqolvoKyg9J/UvhWLMKBjlz/mKgUA1OnWzrVM2 fPjeQSGVW1huhxLl5UX4Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:nybgpSr8H5Y=:sJte4dpJmXriXwnvxhYfyM XmmKYMY5ZsBORSIGDh2+HDmyym0j8bgn3UFWegrRLWbnHWfqiLj+4A09lc8511wEbUbY/lrsh t1WQew9zmgn7Bzu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hx9a7XiA 7iA+ZE8qqMGgQ7kbj35YhQs2XODAWyr/BfNz9ZL8ZZcU2OUQWx5pcNq/qlpWKcb/1+vLL8o/K lvhqj2C4D6SSWl9XIWrVZzetryv7ChNkYdWeG/fOPZrY+4G/2F9XVZC3Fh58bSVpf4XtsM/6Q Ih66MwFBMjcxxZDxbZD4DAJYuTeW1Nc7wkWQafEqs3bHqEJIxp1Q0fA5ByYLiFZ7wA6ZRUeXZ 7Q3Vjz65UWOM6eZNlbD355QRZ9eIgARf4KVGt2wPOY/v+fSdCROfeDFE9PEOvNsRcx+1b4lYU 9ej218syhnReTX55Qs8Cf3t44OxvgO7SbA9VwbC24ifKVj8fwFqeED3fgZVxa83MK9OPQ9bOA bmkFvK4F7VfULmv7teNIMqt+gxY03zMPxYgaCCKVB15Dg X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean On 10/13/22 22:28, Michal Suchanek wrote: > Currently sandbox configuration defautls to 64bit and there is no > automation for building 32bit sandbox on 32bit hosts. > > cpp does not know about target specification, code needs to be compiled > to determine integer width. > > Add a test program that prints the integer width, and a make target that > aligns the sandbox configuration with the result. > > Signed-off-by: Michal Suchanek > --- > > Makefile | 6 ++++++ > doc/arch/sandbox.rst | 16 +++++++++++----- > test/py/conftest.py | 1 + > tools/Makefile | 2 ++ > tools/bits-per-long.c | 14 ++++++++++++++ > 5 files changed, 34 insertions(+), 5 deletions(-) > create mode 100644 tools/bits-per-long.c > > diff --git a/Makefile b/Makefile > index 3866cc62f9..e5463573f3 100644 > --- a/Makefile > +++ b/Makefile > @@ -2166,6 +2166,12 @@ tools-all: envtools tools ; > cross_tools: export CROSS_BUILD_TOOLS=3Dy > cross_tools: tools ; > > +PHONY +=3D set_host_bits > +set_host_bits: tools > + $(Q)sed -i -e /CONFIG_HOST_$$($(objtree)/tools/bits-per-long)BIT/d $(K= CONFIG_CONFIG) > + $(Q)sed -i -E -e "s/CONFIG_HOST_(..)BIT=3Dy/# CONFIG_HOST_\1BIT is not= set/" $(KCONFIG_CONFIG) > + $(Q)echo CONFIG_HOST_$$($(objtree)/tools/bits-per-long)BIT=3Dy >> $(KC= ONFIG_CONFIG) > + > .PHONY : CHANGELOG > CHANGELOG: > git log --no-merges U-Boot-1_1_5.. | \ > diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst > index 068d4a3be4..d751205eba 100644 > --- a/doc/arch/sandbox.rst > +++ b/doc/arch/sandbox.rst > @@ -33,9 +33,11 @@ machines. > > There are two versions of the sandbox: One using 32-bit-wide integers,= and one > using 64-bit-wide integers. The 32-bit version can be build and run on= either > -32 or 64-bit hosts by either selecting or deselecting CONFIG_SANDBOX_32= BIT; by > -default, the sandbox it built for a 32-bit host. The sandbox using 64-b= it-wide > -integers can only be built on 64-bit hosts. > +32 or 64-bit hosts by either selecting or deselecting HOST_64BIT; by > +default, the sandbox it built for a 64-bit host. The sandbox using 64-b= it-wide > +integers can only be built on 64-bit hosts. There is no automation for = ensuring > +32bit build on 32bit hosts - use ``make set_host_bits`` to adjust the s= andbox > +config. > > Note that standalone/API support is not available at present. > > @@ -51,7 +53,9 @@ Basic Operation > > To run sandbox U-Boot use something like:: > > - make sandbox_defconfig all > + make sandbox_defconfig > + make set_host_bits > + make all Thanks for addressing the problem of sandbox bitness. We should not make building the sandbox more complicated. You could integrate building set_host_bits into an existing target like u-boot.cfg:. Overall an approach with an external program is too complicated. CONFIG_HOST_32BIT and CONFIG_HOST_64BIT are used to define CONFIG_SANDBOX_BITS_PER_LONG. We could add #ifndef __LP64__ #undef SANDBOX_BITS_PER_LONG #define SANDBOX_BITS_PER_LONG 32 #endif to the top of arch/sandbox/include/asm/posix_types.h and use #if defined(CONFIG_HOST_64BIT) && defined(__LP64__) in drivers/misc/swap_case.c to solve the problem. This demonstrates that CONFIG_HOST_32BIT and CONFIG_HOST_64BIT are superfluous symbols. Eliminating them and only using __LP64__ is the right approach. @Simon: We should add sandbox_defconfig built with -m32 to our Gitlab CI testing after fixing the incompatibilities in the unit tests. > ./u-boot > > Note: If you get errors about 'sdl-config: Command not found' you may = need to > @@ -59,7 +63,9 @@ install libsdl2.0-dev or similar to get SDL support. A= lternatively you can > build sandbox without SDL (i.e. no display/keyboard support) by removi= ng > the CONFIG_SANDBOX_SDL line in include/configs/sandbox.h or using:: > > - make sandbox_defconfig all NO_SDL=3D1 > + make sandbox_defconfig > + make set_host_bits > + make all NO_SDL=3D1 > ./u-boot > > U-Boot will start on your computer, showing a sandbox emulation of the= serial > diff --git a/test/py/conftest.py b/test/py/conftest.py > index 304e93164a..3d1fd6883a 100644 > --- a/test/py/conftest.py > +++ b/test/py/conftest.py > @@ -104,6 +104,7 @@ def run_build(config, source_dir, build_dir, board_t= ype, log): > o_opt =3D '' > cmds =3D ( > ['make', o_opt, '-s', board_type + '_defconfig'], > + ['make', o_opt, '-s', 'set_host_bits'], > ['make', o_opt, '-s', '-j{}'.format(os.cpu_count())], > ) > name =3D 'make' > diff --git a/tools/Makefile b/tools/Makefile > index 34a1aa7a8b..d6b585953d 100644 > --- a/tools/Makefile > +++ b/tools/Makefile > @@ -68,6 +68,8 @@ HOSTCFLAGS_img2srec.o :=3D -pedantic > hostprogs-$(CONFIG_XWAY_SWAP_BYTES) +=3D xway-swap-bytes > HOSTCFLAGS_xway-swap-bytes.o :=3D -pedantic > > +hostprogs-y +=3D bits-per-long > + > hostprogs-y +=3D mkenvimage > mkenvimage-objs :=3D mkenvimage.o os_support.o lib/crc32.o > > diff --git a/tools/bits-per-long.c b/tools/bits-per-long.c > new file mode 100644 > index 0000000000..7630e1623f > --- /dev/null > +++ b/tools/bits-per-long.c > @@ -0,0 +1,14 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include > + > +int main(int argc, char **argv) > +{ > + unsigned long testvar =3D ~0UL; > + unsigned int i; > + > + for (i =3D 0; testvar; i++, testvar >>=3D 1) > + ; > + > + return printf("%u\n", i); return printf("%zd\n", 8 * sizeof(long)); > +} > + Please avoid empty lines at the end files. Best regards Heinrich