diff --git a/GhcFlags/Plugin.hs b/GhcFlags/Plugin.hs
--- a/GhcFlags/Plugin.hs
+++ b/GhcFlags/Plugin.hs
@@ -19,7 +19,14 @@
 import Data.List (stripPrefix)
 import Data.Time.Clock (diffTimeToPicoseconds, getCurrentTime, utctDayTime)
 import qualified GHC
+#if MIN_VERSION_GLASGOW_HASKELL(9,1,0,0)
+import qualified GHC.Plugins as GHC
+import qualified GHC.Driver.Backend as GHC
+#elif MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)
+import qualified GHC.Plugins as GHC
+#else
 import qualified GhcPlugins as GHC
+#endif
 import System.Directory (doesFileExist, removeFile, renameFile)
 import System.Environment
 import System.IO.Error (catchIOError)
@@ -64,10 +71,16 @@
       writeGhcPath path = case ghcPath of
         Just p -> writeDifferent (path <> "/.ghc.path") p
         Nothing -> pure ()
+#if MIN_VERSION_GLASGOW_HASKELL(9,5,0,0)
+      enable = GHC.backendWritesFiles $ GHC.backend dflags
+#elif MIN_VERSION_GLASGOW_HASKELL(9,2,0,0)
+      enable = GHC.backendProducesObject $ GHC.backend dflags
+#else
       enable = case GHC.hscTarget dflags of
         GHC.HscInterpreted -> False
         GHC.HscNothing -> False
         _ -> True
+#endif
 
   when enable $ liftIO $ do
     traverse_ writeGhcFlags paths
diff --git a/ghcflags.cabal b/ghcflags.cabal
--- a/ghcflags.cabal
+++ b/ghcflags.cabal
@@ -1,13 +1,13 @@
 cabal-version: 2.2
 name:          ghcflags
-version:       1.0.3
+version:       1.0.4
 synopsis:      Dump the ghc flags during compilation
 license:       BSD-2-Clause
 license-file:  LICENSE
 author:        Tseen She
 maintainer:    Tseen She
 copyright:     2019 Tseen She
-tested-with:   GHC ^>=8.4.4 || ^>=8.6.5 || ^>=8.8.3
+tested-with:   GHC ^>=8.4.4 || ^>=8.6.5 || ^>=8.8.3 || ^>=8.10.7 || ^>=9.0.2 || ^>=9.2.7 || ^>=9.4.5 || ^>=9.6.1
 category:      Building
 description:   Generate @.ghc.flags@ and @.ghc.path@ files during compilation
 
@@ -24,7 +24,7 @@
     , ghc
     , time
 
-  ghc-options:      -Wall -Werror=missing-home-modules
+  ghc-options:      -Wall -Werror=missing-home-modules -Werror=orphans
   default-language: Haskell2010
 
 library
