diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,6 +1,13 @@
 # Revision history for ghc-gc-hook
 
 
+## 0.2.1.0 -- 2022-06-03
+
+* Now allows the host program to use TemplateHaskell, but the GC hook cannot be
+  used inside a splice. The issue is that the `rtsConfig` symbol is not
+  available inside a TH splice, so we need to use weak symbols to make it work.
+
+
 ## 0.2.0.0 -- 2022-04-25
 
 * First version. Released on an unsuspecting world.
diff --git a/cbits/hook.c b/cbits/hook.c
--- a/cbits/hook.c
+++ b/cbits/hook.c
@@ -9,7 +9,7 @@
 	return a < b ? a : b;
 }
 
-extern RtsConfig rtsConfig;
+extern RtsConfig __attribute__((weak)) rtsConfig;
 
 // A copy of GCDetails_ with known structure that can be depended on by the Haskell code.
 struct ShadowDetails {
@@ -226,6 +226,11 @@
 		goto unlock_return_retval;
 	}
 
+	if (&rtsConfig == NULL) {
+		fprintf(stderr, "ghc-gc-hook: ERROR: rtsConfig not defined; the GC hook cannot be used from within a TemplateHaskell splice\n");
+		goto unlock_return_retval;
+	}
+
 	old_hook = rtsConfig.gcDoneHook;
 	rtsConfig.gcDoneHook = hook_callback;
 
@@ -286,3 +291,5 @@
 	mtx_unlock(&state_mutex);
 	return retval;
 }
+
+// vim: set noet sw=4 ts=4:
diff --git a/ghc-gc-hook.cabal b/ghc-gc-hook.cabal
--- a/ghc-gc-hook.cabal
+++ b/ghc-gc-hook.cabal
@@ -7,7 +7,7 @@
   information from Haskell in a bare-bones form; furthermore, it gives a small
   usability improvement for running your own function from C using the hook
   from this library.
-version:             0.2.0.0
+version:             0.2.1.0
 category:            GHC
 license:             BSD3
 license-file:        LICENSE
diff --git a/test/Main.hs b/test/Main.hs
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TemplateHaskell #-}
 module Main where
 
 import Control.Monad (forM_, when)
@@ -10,6 +11,7 @@
 
 foreign import ccall "get_my_delegate_ptr" c_get_my_delegate_ptr :: IO (Ptr ())
 
+$(return [])
 
 {-# NOINLINE invokeGCsometimes #-}
 invokeGCsometimes :: IO ()
