Collected c41c478eb9003eaa9fc8081a0039652448124f5d (and a bit
6563cd2473a309b135eb8f950adf28b9f3d8e5c2) out of ghc repository
to be removed in ghc 9.4 era.

Index: compiler/GHC/Linker/Loader.hs
--- compiler/GHC/Linker/Loader.hs.orig
+++ compiler/GHC/Linker/Loader.hs
@@ -587,12 +587,16 @@ dieWith dflags span msg = throwGhcExceptionIO (Program
 
 
 checkNonStdWay :: DynFlags -> Interp -> SrcSpan -> IO (Maybe FilePath)
-checkNonStdWay dflags interp srcspan
+checkNonStdWay _dflags interp _srcspan
   | ExternalInterp {} <- interpInstance interp = return Nothing
     -- with -fexternal-interpreter we load the .o files, whatever way
     -- they were built.  If they were built for a non-std way, then
     -- we will use the appropriate variant of the iserv binary to load them.
 
+-- #if-guard the following equations otherwise the pattern match checker will
+-- complain that they are redundant.
+#if defined(HAVE_INTERNAL_INTERPRETER)
+checkNonStdWay dflags _interp srcspan
   | hostFullWays == targetFullWays = return Nothing
     -- Only if we are compiling with the same ways as GHC is built
     -- with, can we dynamically load those object files. (see #3604)
@@ -607,8 +611,8 @@ checkNonStdWay dflags interp srcspan
                   "" -> ""
                   tag -> tag ++ "_"
 
-normalObjectSuffix :: String
-normalObjectSuffix = phaseInputExt StopLn
+    normalObjectSuffix :: String
+    normalObjectSuffix = phaseInputExt StopLn
 
 failNonStd :: DynFlags -> SrcSpan -> IO (Maybe FilePath)
 failNonStd dflags srcspan = dieWith dflags srcspan $
@@ -628,6 +632,7 @@ failNonStd dflags srcspan = dieWith dflags srcspan $
             | hostIsDynamic = text "with -dynamic"
             | hostIsProfiled = text "with -prof"
             | otherwise = text "the normal way"
+#endif
 
 getLinkDeps :: HscEnv -> HomePackageTable
             -> LoaderState
