You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempting to start a GHCi session using cabal repl fails with errors like the following:
[ 56 of 155] Compiling Data.Array.Accelerate.Pattern.Ordering ( src/Data/Array/Accelerate/Pattern/Ordering.hs, interpreted )
ghc-9.4.8: ^^ Could not load 'accelerate_buffer_byte_size', dependency unresolved. See top entry above.
<no location info>: error:
GHC.ByteCode.Linker: can't find label
During interactive linking, GHCi couldn't find the following symbol:
accelerate_buffer_byte_size
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
Function accelerate_buffer_byte_size is defined in cbits/memory.c. It is used in Array.Buffer (abridging module names for brevity), bound by function memoryByteSize, and used by functions bufferFromPtr and liftBufferData.
The Pattern modules all result in such errors. These modules are implemented using the Pattern.TH module, which imports Smart, which imports Representation.Array, which imports the above Array.Buffer module. I confirmed that the Array.Buffer module is being built before the Pattern modules.
We use Template Haskell to tell GHC which .c files need to be compiled for a particular module, rather than relying on Cabal as is traditional. Using Cabal:
loading Accelerate into GHCi only works after compiling the entire package (which defeats the purpose), presumably because the .c files are compiled last. This would often lead to errors such "can not find symbol __cmd_line_flags" etc.
Linking problems also prevented us from using Template Haskell in some locations, because GHC was unable to load the project into the interpreter to run the splices.
Note that for this fix to work in GHCi we also require modules using it to be loaded as object code.
I tried using Stack (stack repl), and it fails with the same errors.
I confirmed that the FFI in Array.Buffer (using cbits/memory.c and cbits/alloc.cpp) are the only new uses of addForeignFilePath; all other uses are in master. I confirmed that GHCi still works in master.
These new uses are probably failing due to some unfortunate interaction with Template Haskell in modules that depend on Array.Buffer. FFI and Template Haskell can be problematic!
Description
Attempting to start a GHCi session using
cabal replfails with errors like the following:Function
accelerate_buffer_byte_sizeis defined incbits/memory.c. It is used inArray.Buffer(abridging module names for brevity), bound by functionmemoryByteSize, and used by functionsbufferFromPtrandliftBufferData.The
Patternmodules all result in such errors. These modules are implemented using thePattern.THmodule, which importsSmart, which importsRepresentation.Array, which imports the aboveArray.Buffermodule. I confirmed that theArray.Buffermodule is being built before thePatternmodules.The foreign dependencies in
Array.Bufferare loaded usingaddForeignFilePath, referencing note[linking to .c files]inDebug.Internal.Flags.I tried using Stack (
stack repl), and it fails with the same errors.I confirmed that the FFI in
Array.Buffer(usingcbits/memory.candcbits/alloc.cpp) are the only new uses ofaddForeignFilePath; all other uses are inmaster. I confirmed that GHCi still works inmaster.These new uses are probably failing due to some unfortunate interaction with Template Haskell in modules that depend on
Array.Buffer. FFI and Template Haskell can be problematic!Steps to reproduce
cabal replstack replExpected behaviour
All modules should build and load.
Your environment
new-pipeline970ff19eghc-9.4.83.18.1.03.11.1Linux 7.2.3-arch1-2 x86_64)