From mboxrd@z Thu Jan 1 00:00:00 1970 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 C639EC433FE for ; Thu, 13 Oct 2022 20:29:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B5BBC84D60; Thu, 13 Oct 2022 22:29:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.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; unprotected) header.d=suse.de header.i=@suse.de header.b="XYNbfs3f"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="m0m/YNge"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7E1848455E; Thu, 13 Oct 2022 22:29:08 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (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 0ED1984E73 for ; Thu, 13 Oct 2022 22:29:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=msuchanek@suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id BB7761F895; Thu, 13 Oct 2022 20:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1665692941; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qsxUy1P56sVwVXAlsT8MwgkTe1Sps4Ocdu6QdQXSqpI=; b=XYNbfs3fFTFgpvVgYlggB1QLCVRCPngUm4cTpcz3PSDSMKrCzc2Hs+wNxkKUMSIbAHiFOD q18bdp3rcF+vEys/yB9PAXj77EQbbAfzrDcCv237WGKZJeE6W014gz0O+Hzfxb6GvbUFr4 kC1ER/dvVAsgKhj14P2vyl3e42odItI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1665692941; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qsxUy1P56sVwVXAlsT8MwgkTe1Sps4Ocdu6QdQXSqpI=; b=m0m/YNgenI51zJ5/iKaVPO0hKtyjA6VZMOWq6LZNtA/+PEcYgihZ07f9bmLS7vMKZLCw8x F9rcaCLLYyyZWLAw== Received: from naga.suse.cz (unknown [10.100.224.114]) by relay2.suse.de (Postfix) with ESMTP id C8BA52C141; Thu, 13 Oct 2022 20:28:59 +0000 (UTC) From: Michal Suchanek To: u-boot@lists.denx.de Cc: Michal Suchanek , AKASHI Takahiro , Heiko Thiery , Heinrich Schuchardt , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Quentin Schulz , Samuel Holland , Simon Glass , Stefan Roese , Weijie Gao Subject: [PATCH] tests: Build correct sandbox configuration on 32bit Date: Thu, 13 Oct 2022 22:28:55 +0200 Message-Id: <20221013202855.13904-1-msuchanek@suse.de> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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=y cross_tools: tools ; +PHONY += set_host_bits +set_host_bits: tools + $(Q)sed -i -e /CONFIG_HOST_$$($(objtree)/tools/bits-per-long)BIT/d $(KCONFIG_CONFIG) + $(Q)sed -i -E -e "s/CONFIG_HOST_(..)BIT=y/# CONFIG_HOST_\1BIT is not set/" $(KCONFIG_CONFIG) + $(Q)echo CONFIG_HOST_$$($(objtree)/tools/bits-per-long)BIT=y >> $(KCONFIG_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_32BIT; by -default, the sandbox it built for a 32-bit host. The sandbox using 64-bit-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-bit-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 sandbox +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 ./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. Alternatively you can build sandbox without SDL (i.e. no display/keyboard support) by removing the CONFIG_SANDBOX_SDL line in include/configs/sandbox.h or using:: - make sandbox_defconfig all NO_SDL=1 + make sandbox_defconfig + make set_host_bits + make all NO_SDL=1 ./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_type, log): o_opt = '' cmds = ( ['make', o_opt, '-s', board_type + '_defconfig'], + ['make', o_opt, '-s', 'set_host_bits'], ['make', o_opt, '-s', '-j{}'.format(os.cpu_count())], ) name = '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 := -pedantic hostprogs-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes HOSTCFLAGS_xway-swap-bytes.o := -pedantic +hostprogs-y += bits-per-long + hostprogs-y += mkenvimage mkenvimage-objs := 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 = ~0UL; + unsigned int i; + + for (i = 0; testvar; i++, testvar >>= 1) + ; + + return printf("%u\n", i); +} + -- 2.37.3