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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 5279AC636CA for ; Sun, 18 Jul 2021 20:15:29 +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 C8DF361166 for ; Sun, 18 Jul 2021 20:15:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8DF361166 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org 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 52C3881E47; Sun, 18 Jul 2021 22:14:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="N+/jXQcs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC61A80C8A; Sun, 18 Jul 2021 22:14:48 +0200 (CEST) Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) (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 1601B8039D for ; Sun, 18 Jul 2021 22:14:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x330.google.com with SMTP id o72-20020a9d224e0000b02904bb9756274cso16043450ota.6 for ; Sun, 18 Jul 2021 13:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KQJi6P/Uvzz7PH+geCYonXxO3Y/GYStLNAIC2qCXXPE=; b=N+/jXQcsfNmXdERlcwvSzrfDtl+ehB0rg84TlQlJK2SZL4r9k8M70KCnLbh4MqfuqX 56PNKf00Q+Pecyj27sSqFLs8Kx0ZMlDkDxGqkc5AWIsaRgtMOr72PQQqCSxUs7D4kRJr 9rn/+HAHOHCpJMWmrcdODhWehPiDP3VzxRfQQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KQJi6P/Uvzz7PH+geCYonXxO3Y/GYStLNAIC2qCXXPE=; b=bHmmwFdDSEAYiQi43+L4GTMdY7URX77At1Y3MVw+MUlWMfrVeqepJIA2iTrV0BRhCu dSy8m/sGoEbV2nipXPYsnHOYBoc24R0yJT3N/yDV4xfw5DN0wb9p68HRie86W40A/xaU scikxpqnyHCY4ZyHtsXvjGJfj1DZ/UxZLBi84ic3On/zlvoh7lUaac4iSpzJwltAtkaj KPwerlwxzbdDkNpjKH5OjTvl8nHjNesbKIbCEALkPhMS9bJz0Lq47e2toCBhVitrG0bV 0wXLM+DL20C/pytyuj9nFepanPFhu5tMfIjV8Lrm4ouqZVFsGJVYKO+wusGV/ATZuxFy qNkg== X-Gm-Message-State: AOAM533BjgveIaUns3ETR/f0zjI/LOMvJJCSRmGen08LRCCnnnPc7aWO RP/GASFcY/bQUlGZ9MbjJqD1zCRdYzVRQEpj X-Google-Smtp-Source: ABdhPJz0Pix16QI1yWSd50UQqyAZaGJccKBv3KDaB2HQFoeVXOhnSA7UIDx47/vRiPp/o1g0ZJB2wA== X-Received: by 2002:a9d:903:: with SMTP id 3mr16466488otp.146.1626639283239; Sun, 18 Jul 2021 13:14:43 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id k13sm3170598otl.50.2021.07.18.13.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jul 2021 13:14:42 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Simon Glass , Bin Meng , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH v2 5/5] sandbox: Detect the host bit size automatically Date: Sun, 18 Jul 2021 14:14:26 -0600 Message-Id: <20210718201426.759240-6-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.402.g57bb445576-goog In-Reply-To: <20210718201426.759240-1-sjg@chromium.org> References: <20210718201426.759240-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 At present if you build sandbox on a 32-bit host a lot of errors are produced. This is because CONFIG_HOST_64BIT is enabled by default. It is quite annoying to have to change that manually before building sandbox. It is also quite confusing for new users. Add a way to detect the setting and add the appropriate CONFIG_HOST_64BIT=y or CONFIG_HOST_32BIT=y to the defconfig, to avoid this issue. Signed-off-by: Simon Glass --- Changes in v2: - Drop patches previously applied - Put all the packages in gcc.rst Makefile | 11 ++++++++++- arch/sandbox/Kconfig | 13 ++++++++----- scripts/kconfig/Makefile | 14 +++++++++++++- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index bc404c8f989..0257d202597 100644 --- a/Makefile +++ b/Makefile @@ -565,8 +565,17 @@ export KBUILD_DEFCONFIG KBUILD_KCONFIG config: scripts_basic outputmakefile FORCE $(Q)$(MAKE) $(build)=scripts/kconfig $@ +# If nothing is specified explicitly, detect the bit size for sandbox, +# referred to from arch/sandbox/Kconfig +# Add it to the end of the defconfig file %config: scripts_basic outputmakefile FORCE - $(Q)$(MAKE) $(build)=scripts/kconfig $@ + $(Q)if test -f $(srctree)/configs/$@ && \ + ! grep -Eq "CONFIG_HOST_(32|64)BIT=y" $(srctree)/configs/$@; then \ + echo '#include \nint main(void) { printf("CONFIG_HOST_%dBIT=y\\n", __WORDSIZE); return 0; }' \ + | gcc -x c - -o get_word_size; \ + extra=$$(./get_word_size); \ + fi; \ + $(MAKE) $(build)=scripts/kconfig EXTRA_DEFCONFIG=$$extra $@ else # =========================================================================== diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index f83282d9d56..01b2a3fcad1 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -35,12 +35,12 @@ config SYS_CONFIG_NAME choice prompt "Run sandbox on 32/64-bit host" - default HOST_64BIT + default HOST_DETECT_BIT help - Sandbox can be built on 32-bit and 64-bit hosts. - The default is to build on a 64-bit host and run - on a 64-bit host. If you want to run sandbox on - a 32-bit host, change it here. + Sandbox can be built on 32-bit and 64-bit hosts. This is generally + auto-detected but you can force a particular word size here. If you + see strange warnings about SANDBOX_BITS_PER_LONG then you may have + selected the wrong value. config HOST_32BIT bool "32-bit host" @@ -49,6 +49,9 @@ config HOST_32BIT config HOST_64BIT bool "64-bit host" +config HOST_DETECT_BIT + bool "Auto-detect bit size" + endchoice config SANDBOX_CRASH_RESET diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index d52128425ce..8e14db7ade3 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -12,6 +12,9 @@ PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \ # Set SRCARCH to .. fake this Makefile. SRCARCH := .. +# For U-Boot, EXTRA_DEFCONFIG contains a line to be added to the defconfig +# before processing. If empty, no line is added. + ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG) else @@ -92,8 +95,17 @@ else endif endif +# If EXTRA_DEFCONFIG is defined, add it to the end of the defconfig, before +# processing. This allows the caller to change a setting on the fly %_defconfig: $(obj)/conf - $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) + $(Q)defconfig="$(srctree)/arch/$(SRCARCH)/configs/$@"; \ + if [ -n "$(EXTRA_DEFCONFIG)" ]; then \ + cat $$defconfig >defconfig_tmp; \ + echo $(EXTRA_DEFCONFIG) >>defconfig_tmp; \ + $< $(silent) --defconfig=defconfig_tmp $(Kconfig); \ + else \ + $< $(silent) --defconfig=$$defconfig $(Kconfig); \ + fi # Added for U-Boot (backward compatibility) %_config: %_defconfig -- 2.32.0.402.g57bb445576-goog