Subject: [PATCH] Pass the mcmodel=medium parameter to CC via GHC

From: Peng Fan <[email-masked]>
Date: Thu, 13 Mar 2025 02:45:13 +0000

Ensure that GHC-driver builds default to mcmodel=medium, so that GHC
passes this default parameter to CC without having to add it to the
compiled project.

Commit e70d41406b5d5638b42c4d8222cd03e76bbfeb86 does not ensure that all
GHC-built object files have a default model of medium, and will raise an
R_LARCH_B26 overflow error.
---
 m4/fptools_set_c_ld_flags.m4 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/m4/fptools_set_c_ld_flags.m4 b/m4/fptools_set_c_ld_flags.m4
index 13913709c9..0fc4b0198b 100644
--- a/m4/fptools_set_c_ld_flags.m4
+++ b/m4/fptools_set_c_ld_flags.m4
@@ -105,6 +105,10 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
         $5="$$5 -D_THREAD_SAFE"
         ;;
 
+    loongarch64*linux*)
+        $2="$$2 -mcmodel=medium"
+        ;;
+
     esac
 
     AC_MSG_RESULT([done])
-- 
2.49.0