Weird interactions between FFI and Template Haskell (Linux)

Since turning on Template Haskell to make use of the refined and using its refineTH function, the compilation of my package now fails with

<no location info>: error:        

         GHC.Linker.Loader.dynLoadObjs: Loading temp shared object failed
         During interactive linking, GHCi couldn't find the following symbol:
          /tmp/ghc1148774_0/libghc_3.so: undefined symbol: lzf_decompress
        This may be due to you not asking GHCi to load extra object files,
        archives or DLLs needed by your current session.  Restart GHCi, specifying

        the missing library using the -L/path/to/object/dir and -lmissinglibname
        flags, or simply by naming the relevant files on the GHCi command line.
        Alternatively, this link failure might indicate a bug in GHCi.
        If you suspect the latter, please report this as a GHC bug:
          https://www.haskell.org/ghc/reportabug

Doing some research, it looks like this might be caused by the indirect interaction between a refineTH call and one of the foreign functions I use. I am not sure, but I have been able to isolate the issue to a particular module where the foreign functions are referenced indirectly, and I make use of refineTH.

Has anyone run into this kind of issue before? Was/is there a workaround of some sort? The tickets and issues I’ve seen covering this are all years old.

For context, I’m using stack v3.7.1 with the resolver lts-23.11 for GHC 9.8.4 on Fedora Linux 42

I was able to resolve this by splitting my FFI code into a separate package away from my TH code, that way their compilations won’t conflict