File 0577-Fail-if-canonicalized-host-and-build-equals-when-cro.patch of Package erlang

From 9f4e1a352f31d700d424bf6cd137722a86630344 Mon Sep 17 00:00:00 2001
From: Rickard Green <rickard@erlang.org>
Date: Fri, 2 Jul 2021 15:25:26 +0200
Subject: [PATCH 1/2] Fail if canonicalized host and build equals when cross
 compiling

---
 HOWTO/INSTALL-CROSS.md | 12 +++++++++---
 make/configure.in      | 17 +++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/HOWTO/INSTALL-CROSS.md b/HOWTO/INSTALL-CROSS.md
index 322ff13340..f2494e6f1c 100644
--- a/HOWTO/INSTALL-CROSS.md
+++ b/HOWTO/INSTALL-CROSS.md
@@ -128,14 +128,20 @@ be built.
     $ make
 
 `<HOST>` is the host/target system that you build for. It does not have to be
-a full `CPU-VENDOR-OS` triplet, but can be. The full `CPU-VENDOR-OS` triplet
-will be created by executing `$ERL_TOP/erts/autoconf/config.sub <HOST>`. If
-`config.sub` fails, you need to be more specific.
+a full `CPU-VENDOR-OS` triplet, but can be. The full canonicalized
+`CPU-VENDOR-OS` triplet will be created by executing
+`$ERL_TOP/erts/autoconf/config.sub <HOST>`. If `config.sub` fails, you need
+to be more specific.
 
 `<BUILD>` should equal the `CPU-VENDOR-OS` triplet of the system that you
 build on. If you execute `$ERL_TOP/erts/autoconf/config.guess`, it will in
 most cases print the triplet you want to use for this.
 
+The use of `<HOST>` and `<BUILD>` values that differ will trigger cross
+compilation. Note that if `<HOST>` and `<BUILD>` differ, the canonicalized
+values of `<HOST>` and `<BUILD>` must also differ. If they do not, the
+configuration will fail.
+
 Pass the cross compilation variables as command line arguments to `configure`
 using a `<VARIABLE>=<VALUE>` syntax.
 
diff --git a/make/configure.in b/make/configure.in
index d33b6f324b..92a7542b4b 100644
--- a/make/configure.in
+++ b/make/configure.in
@@ -93,6 +93,7 @@ dnl
 
 if test "X$host" != "Xfree_source" -a "X$host" != "Xwin32"; then
     AC_CANONICAL_HOST
+    AC_CANONICAL_BUILD
 else
     host_os=$host
 fi
@@ -101,6 +102,22 @@ TARGET=$host
 AC_SUBST(TARGET)
 
 if test "$cross_compiling" = "yes"; then
+    if test "$build" = "$host"; then
+       AC_MSG_ERROR([
+           Cross compiling with the same canonicalized 'host' value
+           as the canonicalized 'build' value.
+
+           We are cross compiling since the '--host=$host_alias'
+           and the '--build=$build_alias' arguments differ. When
+           cross compiling Erlang/OTP also the canonicalized values of
+           the '--build' and the '--host' arguments *must* differ. The
+           canonicalized values of these arguments however both equals:
+           $host
+
+           You can check the canonical value by passing a value as
+           argument to the 'erts/autoconf/config.sub' script.
+         ])
+    fi
     CROSS_COMPILING=yes
 else
     CROSS_COMPILING=no
-- 
2.26.2

openSUSE Build Service is sponsored by