Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1992299pxf; Sat, 13 Mar 2021 04:26:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3vGewcY3CGbn77i2dyiDmc7EBEqoIxLlfpDFm4DEaoZDhoa9itnYnuJcuhR3nWlT02HSl X-Received: by 2002:a05:6402:5211:: with SMTP id s17mr20068010edd.327.1615638395285; Sat, 13 Mar 2021 04:26:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615638395; cv=none; d=google.com; s=arc-20160816; b=K91hUXFeaBtdGhc84BsjyzElEClPES51dp9uQBMbhXrsNXC9UgkU34KWL2lPKqx3nY SLpLEll1/7G4l7gBv+lbX+YjDr/gtKmyR5fpYOE5ARCMQuDIxTPTsJFt/BCs0yDcFN/Z 9FyW5e4aQ1Q7tnGBc1DJemZTTOmU7OB2ZrVbjXtwNDUuVFaTQsU8U/ykE3SVlCdIth4s Sz8750ltjSmMppwyGE4xX1rXEUq2FB06EnU68n27JBfd/71/PADfljkrxUhNLUD804Fq 1IE9UJCq/CMo8Gg5k+TgRu9GKIOQhmWqGd++j94mL2VfPrsZSaxVr+SG+In4YRp0OG0H UJkQ== 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=YQNABWr0erz25nT0kbiVZpsc7Nb4rJN3cUE+AnMZjy4=; b=VbI5ND9V4REQ9PDP9hI0Jtc5DxzuGhmNzWFTukwF3KBxwCAnoaW/ONFzd5y3G8PDC6 bNaHbj1oiyf8zOBi0fLlSoFvg/le67xmiMsskw4PGbKipn9EqbDIj7zIXB0UBT8GNRv5 /xxiMW72QwE15UPz9ptGtwLJlFuU8n7O9UV55ND8xTsJRuzD7NBqr8hW+F8O7z2oqQcg MysYBgPE8s+dJ7k5oASKiCgaWej5su4IAPXEzfs6tR/sgIUfgqzRhpVdKr/EFdvC/Uk2 eRecdB75aMlEew8E4xJ3M5IoGr/sSF8wekZlcodrRyQs70ZSyOjl4OvtP/ILGfQpZJG5 laRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=CZGl5cld; 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 bo5si6217011edb.459.2021.03.13.04.26.08; Sat, 13 Mar 2021 04:26:35 -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=CZGl5cld; 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 S233114AbhCMMY7 (ORCPT + 99 others); Sat, 13 Mar 2021 07:24:59 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:21028 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231497AbhCMMY6 (ORCPT ); Sat, 13 Mar 2021 07:24:58 -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 12DCNhQv030190; Sat, 13 Mar 2021 21:23:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 12DCNhQv030190 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1615638224; bh=YQNABWr0erz25nT0kbiVZpsc7Nb4rJN3cUE+AnMZjy4=; h=From:To:Cc:Subject:Date:From; b=CZGl5cldEUcbzsbLII3RXAiomKw7XGz2DqgY04/kSsUsUJLoDYBz9fnyT6Y48yti/ jccFYXTsCSvUSbz3T4sksL6evS/tF4z7hNvFFKbQQadmmw1Pa743Va0YKMxe36r6Jc PMDF3JMy3bsJFyVoLmCWHQtBa0ikFID77M918ovDL4J2EHttPaub0cuGLg9pBRBls7 t+rGVzBdNxhtRP4S6iQN4PbMhzgU5A/hd26MidoatvoTxIiqKcJUFg/yIsxZpgQCOg /7Sc8gCP8LShQnAGDJftsKtLcBMKtF8ixOGRbQ34ofh1YmR+e9aTQJBNKg2cnnUBQr 72M+3mlNQeEIw== X-Nifty-SrcIP: [133.32.232.101] From: Masahiro Yamada To: Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org Cc: Masahiro Yamada , Nick Desaulniers , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig Date: Sat, 13 Mar 2021 21:23:41 +0900 Message-Id: <20210313122342.69995-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 --- Changes in v2: - more cleanups arch/xtensa/Kconfig | 6 ++++++ arch/xtensa/Makefile | 9 +-------- arch/xtensa/boot/Makefile | 4 ---- arch/xtensa/boot/boot-elf/Makefile | 6 +----- arch/xtensa/boot/boot-redboot/Makefile | 6 +----- 5 files changed, 9 insertions(+), 22 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)) diff --git a/arch/xtensa/boot/Makefile b/arch/xtensa/boot/Makefile index f6bb352f94b4..a65b7a9ebff2 100644 --- a/arch/xtensa/boot/Makefile +++ b/arch/xtensa/boot/Makefile @@ -12,10 +12,6 @@ KBUILD_CFLAGS += -fno-builtin -Iarch/$(ARCH)/boot/include HOSTFLAGS += -Iarch/$(ARCH)/boot/include -BIG_ENDIAN := $(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#") - -export BIG_ENDIAN - subdir-y := lib targets += vmlinux.bin vmlinux.bin.gz targets += uImage xipImage diff --git a/arch/xtensa/boot/boot-elf/Makefile b/arch/xtensa/boot/boot-elf/Makefile index f7c775d53012..47b9063f2c5d 100644 --- a/arch/xtensa/boot/boot-elf/Makefile +++ b/arch/xtensa/boot/boot-elf/Makefile @@ -4,11 +4,7 @@ # for more details. # -ifeq ($(BIG_ENDIAN),1) -OBJCOPY_ARGS := -O elf32-xtensa-be -else -OBJCOPY_ARGS := -O elf32-xtensa-le -endif +OBJCOPY_ARGS := -O $(if $(CONFIG_CPU_BIG_ENDIAN),elf32-xtensa-be,elf32-xtensa-le) export OBJCOPY_ARGS export CPPFLAGS_boot.lds += -P -C diff --git a/arch/xtensa/boot/boot-redboot/Makefile b/arch/xtensa/boot/boot-redboot/Makefile index 07cb24afedc2..1d1d46215b1c 100644 --- a/arch/xtensa/boot/boot-redboot/Makefile +++ b/arch/xtensa/boot/boot-redboot/Makefile @@ -4,11 +4,7 @@ # for more details. # -ifeq ($(BIG_ENDIAN),1) -OBJCOPY_ARGS := -O elf32-xtensa-be -else -OBJCOPY_ARGS := -O elf32-xtensa-le -endif +OBJCOPY_ARGS := -O $(if $(CONFIG_CPU_BIG_ENDIAN),elf32-xtensa-be,elf32-xtensa-le) LD_ARGS = -T $(srctree)/$(obj)/boot.ld -- 2.27.0