Skip to content

"Relocation out of range for SUBTRACTOR" under aarch64_apple_darwin when using Template Haskell and the external interpreter

Summary

While writing a testcase for !12191, I noticed that we get a "Relocation out of range for SUBTRACTOR" error when compiling the following module with the external interpreter under aarch64_apple_darwin.

The only other reference to this error I could find was in #24395 , but I'm not sure if this is the same or not.

I don't have access to an aarch64 machine, so I can't reduce the example any further. I imagine using lib:ghc is triggering this issue because it is too large(?) and it would also trigger with any other large library.

Steps to reproduce

Try to compile the following module:

{-# LANGUAGE MagicHash #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE LinearTypes #-}
-- | This test shows that we can reify a bunch of primitive types.
-- Additionally it acts as a golden test to ensure that we don't
-- accidentally change our output for these types.

import Control.Monad
import Data.Char
import GHC.Exts
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
import GHC.Builtin.Types.Prim (primTyCons)
import GHC.Tc.Gen.Splice (reifyName)

main :: IO ()
main = $(do let types = map reifyName primTyCons
            reified <- mapM reify types
            let stripInt [] = []
                stripInt (x:xs)
                  | isDigit x = stripInt xs
                  | otherwise = x:xs
            -- remove _[0-9]* sequences
            let stripUniques ('_':xs) = stripUniques $ stripInt xs
                stripUniques (x:xs)= x:stripUniques xs
                stripUniques [] = []
            let output = lift $ map (stripUniques . show) reified
            [| mapM_ putStrLn $output |])

You will get output like: https://gitlab.haskell.org/ghc/ghc/-/jobs/1801388

ghc-iserv: internal error: Relocation out of range for SUBTRACTOR
    (GHC version 9.9.20240307 for aarch64_apple_darwin)
    Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug
<no location info>: error: External interpreter terminated (-6)

Expected behavior

This should compile fine.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information