[PATCH 1/3] ARM: deprecate use of ARCH=arm for arm64 builds

Ahmad Fatoum <[email protected]>
Newsgroups org.infradead.lists.barebox
Message-ID <[email protected]>
Linux has separate arch/arm and arch/arm64, where each is built by
ARCH=arm and ARCH=arm64, respectively.

barebox has arch/arm for both, which leads to issues from time to time:

  - Ported kernel code may assume SRCARCH to differ between arm32
    and arm64[1].

  - It's not possible to determine if we are going to build for 32-bit
    ARM or 64-bit ARM before reading and normalizing the config[2].

To be able to, someday, resolve these issues, let's throw a warning
when ARCH=arm is used when it later turns out that ARCH=arm64 would
have been more correct and vice versa.

[1]: https://lore.kernel.org/barebox/[email protected]/T/#u
[2]: 92d503132efc ("Revert "MAKEALL: query CONFIG_64BIT before make instead of CONFIG_ARM64 after"")

Signed-off-by: Ahmad Fatoum <[email protected]>
---
 Documentation/migration-guides/migration-master.rst |  8 ++++++++
 arch/arm/Kconfig                                    |  7 +++++++
 arch/arm/Makefile                                   | 10 ++++++++++
 3 files changed, 25 insertions(+)
 create mode 100644 Documentation/migration-guides/migration-master.rst

diff --git a/Documentation/migration-guides/migration-master.rst b/Documentation/migration-guides/migration-master.rst
new file mode 100644
index 000000000000..455863357d1d
--- /dev/null
+++ b/Documentation/migration-guides/migration-master.rst
@@ -0,0 +1,8 @@
+:orphan:
+
+ARCH=arm64
+----------
+
+Use of ``ARCH=arm`` for 64-bit ARM builds is deprecated and now emits
+a warning. Users should change build scripts to use ``ARCH=arm64``
+instead when targetting ARMv8.
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index cb6652001546..63877c965fad 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -41,6 +41,13 @@ config ARM64
 	select ARCH_HAS_RELR
 	select ARCH_HAS_BAREBOX_MEMORY_OFFSET
 
+config ARM64_STRICT_BUILD_ARCH
+	bool
+	depends on ARM64
+	help
+	  When selected, ARCH=arm64 is required for 64-bit builds and ARCH=arm
+	  will fail.  When not selected, a deprecation warning is printed.
+
 config ARCH_TEXT_BASE
 	hex
 	default 0x00000000
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index eb4c634c42ec..edf6f7d74eb5 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -18,10 +18,20 @@ KBUILD_CPPFLAGS	+= -D__ARM__ -fno-strict-aliasing
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
 ifeq ($(CONFIG_CPU_64),y)
 KBUILD_CPPFLAGS	+=$(call cc-option,-maarch64,)
+ifneq ($(UTS_MACHINE),arm64)
+ifdef CONFIG_ARM64_STRICT_BUILD_ARCH
+$(error Deprecated use of ARCH=arm in 64-bit ARM build! Set ARCH=arm64 instead.)
+else
+$(warning Deprecated use of ARCH=arm in 64-bit ARM build! Set ARCH=arm64 instead.)
+endif
+endif
 endif
 ifeq ($(CONFIG_CPU_32),y)
 KBUILD_CPPFLAGS	+=$(call cc-option,-marm,)
 KBUILD_CPPFLAGS	+= -msoft-float
+ifeq ($(UTS_MACHINE),arm64)
+$(error Erroneous use of ARCH=arm64 in 32-bit ARM build! Set ARCH=arm instead.)
+endif
 endif
 
 ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.