diff --git a/libtorch-ffi-helper.cabal b/libtorch-ffi-helper.cabal
new file mode 100644
--- /dev/null
+++ b/libtorch-ffi-helper.cabal
@@ -0,0 +1,23 @@
+cabal-version:       3.0
+name:                libtorch-ffi-helper
+version:             2.0.0.0
+-- The prefix(2.0) of this version("2.0.0.0") is the same as libtorch's one.
+synopsis:            Helpers for integrating libtorch-ffi with Hasktorch.
+description:         Provide macros and plugins for building libtorch-ffi of hasktorch.
+homepage:            https://github.com/hasktorch/hasktorch#readme
+license:             BSD-3-Clause
+author:              Austin Huang
+maintainer:          hasktorch@gmail.com
+copyright:           2018 Austin Huang
+category:            Codegen
+build-type:          Simple
+
+library
+ exposed-modules:     Torch.Internal.Unmanaged.Helper
+                    , GHC.NotExport.Plugin
+ hs-source-dirs: src
+ default-language: Haskell2010
+ build-depends:       base >= 4.7 && < 5
+                    , ghc >=8.5 && < 9.8
+ if os(darwin)
+   ghc-options: -optc=-Wno-int-conversion
diff --git a/src/GHC/NotExport/Plugin.hs b/src/GHC/NotExport/Plugin.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/NotExport/Plugin.hs
@@ -0,0 +1,29 @@
+{-# LANGUAGE CPP #-}
+
+module GHC.NotExport.Plugin (plugin) where
+
+#if MIN_VERSION_ghc(9,0,0)
+import GHC.Driver.Plugins
+import GHC.Types.Avail
+import GHC.Types.Name
+import GHC.Tc.Types
+import GHC.Utils.Outputable
+#else
+import GhcPlugins
+import Plugins
+import TcRnTypes
+import Avail
+#endif
+
+import Data.List (isPrefixOf)
+
+plugin :: Plugin
+plugin =
+  defaultPlugin
+    { typeCheckResultAction = notExportPlugins,
+      pluginRecompile = purePlugin
+    }
+
+notExportPlugins cmdOptions modSummary env = do
+  let updated_tcg_exports = filter (\v -> not (isPrefixOf "inline_c_ffi" ((showSDocUnsafe . ppr . nameOccName . availName) v))) $ tcg_exports env
+  return env {tcg_exports = updated_tcg_exports}
diff --git a/src/Torch/Internal/Unmanaged/Helper.hs b/src/Torch/Internal/Unmanaged/Helper.hs
new file mode 100644
--- /dev/null
+++ b/src/Torch/Internal/Unmanaged/Helper.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+
+module Torch.Internal.Unmanaged.Helper where
+
+import Foreign.Ptr
+
+foreign import ccall "wrapper" callbackHelper :: (Ptr () -> IO (Ptr ())) -> IO (FunPtr (Ptr () -> IO (Ptr ())))
+
+foreign import ccall "wrapper" callbackHelper2 :: (Ptr () -> Ptr () -> IO (Ptr ())) -> IO (FunPtr (Ptr () -> Ptr () -> IO (Ptr ())))
