Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1332389pxf; Fri, 12 Mar 2021 07:19:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5/rKanvJJASk64/DE8TyDNYpiYfjj/SOiv7RTu8UzZT+byMlP19E4v1VMfKCFzKirsW69 X-Received: by 2002:a17:906:af97:: with SMTP id mj23mr9291859ejb.419.1615562341768; Fri, 12 Mar 2021 07:19:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615562341; cv=none; d=google.com; s=arc-20160816; b=UGmWxpPQtjXMITsxLPxw1b0S6PjFVns5Nyy/tRNmUf5stWX/iIUupO8+MJBeI91oWG EZBifNaikkyPd0Ey5gAi46BodXsXSRRMuweVGmYlsyRcDiqzyPqzgl/Cc0U+JoyKyuyG pjgQW8SMAQZmzyT+ohPLp3TzH2KQuduRPnauz0PG4j9YM1AjKdsAk9smIr203lWQK23n d9lVE0/VzKU45c8NUH2pwwZd7CoJ1lRYkXGl2GbXX5aPEdVXcTeWO3FjfCRFGZ4ke6wy vrgJg5RqYF/2Sy9YSmDWTvVKfUF2zStBghWnx0lUMJTB/PK5NuYhl9OzdIXZS6prs2vs E/ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=di2FogfNTrfuBKoiuiGg7kZDO4ZOULOPFSBFHn6SMqA=; b=eMyb6s7KHpBJLz8BHngR989nf8Q6kvQtrbTUGNgkVyJWejBgBtmtwowOw0QCZVi8kw TtgjAicBhJAx0ky1DyPiV1k6CsQCE77OPZ0M5l8vE8RMF1C+KGQ7/k0zFFlriqDS1THE xMuZs0aWqhAaKX86avVzgMU7i2uE/NtpbhKbs7lE2qBih1+TCJTllydhhna4BZn89X0A 0njW8vM1YpmqZ7ZssqBeMyFHdtvKA1Y/SwxfeBowdE9Hhv+dPgWHCH9+fgAOAXLgXeW0 oBfBAug3twbqx56w19YlLywJgE4lFKIvYpxOXvMyiU/JW1lmX/mej+TI9BS77YdnFyCP NBww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=OfZsvyCM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s19si4080466ejd.449.2021.03.12.07.18.28; Fri, 12 Mar 2021 07:19:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=OfZsvyCM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232009AbhCLPPR (ORCPT + 99 others); Fri, 12 Mar 2021 10:15:17 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:17932 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231519AbhCLPPO (ORCPT ); Fri, 12 Mar 2021 10:15:14 -0500 Received: from localhost.localdomain (133-32-232-101.west.xps.vectant.ne.jp [133.32.232.101]) (authenticated) by conuserg-08.nifty.com with ESMTP id 12CFELVS017750; Sat, 13 Mar 2021 00:14:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 12CFELVS017750 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1615562062; bh=di2FogfNTrfuBKoiuiGg7kZDO4ZOULOPFSBFHn6SMqA=; h=From:To:Cc:Subject:Date:From; b=OfZsvyCMX3mKwO9jjBPsMoGQ8rbioccDYnagZzsxHgq+v2QYpOfwzz8qH1gdP3StH e0o+q7MsyP9yAfusxh26ZKagb6Immiun3HxpnFKHwPxU19I7/desbsDzgYnA31WKba hd/L9E/Ehi0k3EA3en8iEOxJ1cWvuqvO81+lYDhH2OPuY3RbHKJzWZdqZjFzQuCWBH MBeW3FDPUxx4xLVCsCkfk3HkwM/SYejnJPYaGPBOCKacP5eTVvHjCRZ1hPNtuJ102K TcNuFNIfbAU7dS56GfBst2SnMHl5RiH8/KkGYUURYhyRCHdSYx3KfA0i41GxF2xzSO IRndf+RgpZ4Tw== X-Nifty-SrcIP: [133.32.232.101] From: Masahiro Yamada To: Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig Date: Sat, 13 Mar 2021 00:14:11 +0900 Message-Id: <20210312151411.101942-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the definition of CONFIG_CPU_*_ENDIAN to Kconfig, the best place for CONFIG options. I slightly simplified the test code. You can use the -P option to suppress linemarker generation. The grep command is unneeded. $ echo __XTENSA_EB__ | xtensa-linux-gcc -E - # 1 "" # 1 "" # 1 "" # 1 "" 1 $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -P - 1 Signed-off-by: Masahiro Yamada --- If I understood correctly, xtensa compilers can support either big-endian or little-endian. We cannot change it via a command option. Actually, it does not understand -mbig-endian or -mlittle-endian. (Is this correct?) $ xtensa-linux-gcc -mbig-endian /dev/null -c -o /dev/null xtensa-linux-gcc: error: unrecognized command-line option '-mbig-endian' I see -mbig-endian / -mlittle-endian in old GCC manual. https://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Xtensa-Options.html But, I cannot see them in recent gcc manuals. So, I have no idea better than checking __XTENSA_EB__ or __XTENSA_EL__. I just moved the logic to Kconfig from Makefile. arch/xtensa/Kconfig | 6 ++++++ arch/xtensa/Makefile | 9 +-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 9ad6b7b82707..37b04ccc0a7f 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -84,6 +84,12 @@ config KASAN_SHADOW_OFFSET hex default 0x6e400000 +config CPU_BIG_ENDIAN + def_bool $(success,test "$(shell,echo __XTENSA_EB__ | $(CC) -E -P -)" = 1) + +config CPU_LITTLE_ENDIAN + def_bool !CPU_BIG_ENDIAN + menu "Processor type and features" choice diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile index cf0940708702..f43c731dec89 100644 --- a/arch/xtensa/Makefile +++ b/arch/xtensa/Makefile @@ -52,14 +52,7 @@ ifneq ($(CONFIG_LD_NO_RELAX),) KBUILD_LDFLAGS := --no-relax endif -ifeq ($(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1) -CHECKFLAGS += -D__XTENSA_EB__ -KBUILD_CPPFLAGS += -DCONFIG_CPU_BIG_ENDIAN -endif -ifeq ($(shell echo __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1) -CHECKFLAGS += -D__XTENSA_EL__ -KBUILD_CPPFLAGS += -DCONFIG_CPU_LITTLE_ENDIAN -endif +CHECKFLAGS += -D $(if $(CONFIG_CPU_BIG_ENDIAN),__XTENSA_EB__,__XTENSA_EL__) vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y)) plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(platform-y)) -- 2.27.0