Skip to content

JavaScript: tuple constructors aren't always linked

In GHC.StgToJS.Linker.Linker.rtsDeps we include the following snippet in order to consider tuple constructors as roots for the linker traversal:

      , mkPrimFuns "GHC.Tuple.Prim"
          [ "(,)"
          , "(,,)"
          , "(,,,)"
          , "(,,,,)"
          , "(,,,,,)"
          , "(,,,,,,)"
          , "(,,,,,,,)"
          , "(,,,,,,,,)"
          , "(,,,,,,,,,)"
          ]

However, calling into these directly, as is needed in the definition of the MK_TUP* macros, will give an undefined symbol error at runtime:

"#define MK_TUP2(x1,x2) (h$c2(h$ghczmprimZCGHCziTupleziPrimziZ2T_con_e,(x1),(x2)))\n"

This seems to only present for Z4T and above - I assume because tuple constructors sized 2 and 3 happen to be used elsewhere in most cases.

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