From 3cba4dc7a8a6d33e133354bd2846dc1f6bc7e2f1 Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Sat, 25 Jun 2022 17:56:22 +0100
Subject: [PATCH] configure: Disable jit for cross-compilers.

It is not clear how this is going to be used with a cross-compiler since
the shared library is for the host, but the code is generated for the
target.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

ChangeLog:

	* configure: Regenerate.
	* configure.ac: Disable jit for cross-compilers.
---
 configure    | 44 ++++++++++++++++++++++++++------------------
 configure.ac | 43 +++++++++++++++++++++++++------------------
 2 files changed, 51 insertions(+), 36 deletions(-)


diff --git a/configure.ac b/configure.ac
index bf416b1705b..ec608fb263e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2174,12 +2174,21 @@ if test -d ${srcdir}/gcc; then
         # Disable jit if -enable-host-shared not specified
         # but not if building for Mingw. All code in Windows
         # is position independent code (PIC).
-        case $target in
-          *mingw*) ;;
-          *)
-          case ${add_this_lang}:${language}:${host_shared} in
-            yes:jit:no)
-	           # PR jit/64780: explicitly specify --enable-host-shared
+        # Also disable if we are building a cross-compiler.        
+	case ${add_this_lang}:${language}:${is_cross_compiler}:${host_shared}:${target} in
+	  yes:jit:yes:*:*)
+	    AC_MSG_ERROR([jit is not supported for cross-compilers])
+            add_this_lang=unsupported
+            ;;
+	   all:jit:yes:*:* )
+	    AC_MSG_WARN([jit is not supported for cross-compilers])
+            add_this_lang=unsupported
+            ;;
+          yes:jit:no:*:*mingw* | all:jit:no:*:*mingw*)
+            # Windows code is always PIC, so OK.
+            ;;
+          yes:jit:no:no:*)
+	    # PR jit/64780: explicitly specify --enable-host-shared
 	    AC_MSG_ERROR([
 Enabling language "jit" requires --enable-host-shared.
 
@@ -2190,18 +2199,16 @@ If you want to build both the jit and the regular compiler, it is often
 best to do this via two separate configure/builds, in separate
 directories, to avoid imposing the performance cost of
 --enable-host-shared on the regular compiler.])
-	            ;;
-            all:jit:no)
-	      AC_MSG_WARN([--enable-host-shared required to build $language])
-              add_this_lang=unsupported
-              ;;
-            *:jit:no)
-              # Silently disable.
-              add_this_lang=unsupported
-              ;;
-	        esac
-          ;;
-        esac
+	    ;;
+          all:jit:no:no:*)
+	    AC_MSG_WARN([--enable-host-shared required to build $language])
+            add_this_lang=unsupported
+            ;;
+	  *:jit:no:no:*)
+	    # Silently disable.
+            add_this_lang=unsupported
+            ;;
+	esac
 
         # Disable a language that is unsupported by the target.
 	case "${add_this_lang}: $unsupported_languages " in
-- 
2.24.3 (Apple Git-128)

