From 46f944bece2325c470ec64ae3f14f9f45d8bf056 Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Fri, 4 Oct 2024 20:12:07 +0000
Subject: [PATCH] compiler: fix dynamic_too_enable for targets that require
 dynamic libraries

This commit fixes dynamic_too_enable for targets whose RTS linker can
only load dynamic code.

(cherry picked from commit fc3a55917e9c6c64765f11e0703853b9eed230fe)
(cherry picked from commit ba24a6bd70c06c8e02a29cc4ca5a39488c9edfe5)
---
 compiler/GHC/Driver/Make.hs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/compiler/GHC/Driver/Make.hs b/compiler/GHC/Driver/Make.hs
index 73a981969af..aaedcd7be5b 100644
--- a/compiler/GHC/Driver/Make.hs
+++ b/compiler/GHC/Driver/Make.hs
@@ -1922,7 +1922,11 @@ enableCodeGenWhen logger tmpfs staticLife dynLife unit_env mod_graph =
     -- the linker can correctly load the object files.  This isn't necessary
     -- when using -fexternal-interpreter.
     dynamic_too_enable enable_spec ms
-      = hostIsDynamic && not hostIsProfiled && internalInterpreter &&
+      | sTargetRTSLinkerOnlySupportsSharedLibs $ settings lcl_dflags =
+          not isDynWay && not dyn_too_enabled
+            && enable_object
+      | otherwise =
+          hostIsDynamic && not hostIsProfiled && internalInterpreter &&
             not isDynWay && not isProfWay &&  not dyn_too_enabled
               && enable_object
       where
-- 
GitLab