[Haskell-cafe] Cross-compiling fails for package 'directory'

Arie Peterson ariep at xs4all.nl
Sat Aug 15 12:46:30 UTC 2015


Following <https://github.com/ku-fpg/raspberry-pi/wiki/GHC-Cross-Compiler-for-Raspberry-Pi>, I have built a cross-compiling ghc for creating programs that 
run on the raspberry pi. This ghc has built a "hello world" program that runs 
on the rpi: OK so far.

Unfortunately, building the package 'directory-1.2.3.0' with this cross-
compiler fails with the following error message:

"System/Directory/Internal.hsc:31 directive const_str cannot be handled in 
cross-compilation mode"

The offending function from System.Directory is this one:

> -- | Filename extension for executable files (including the dot if any)
> -- (usually @\"\"@ on POSIX systems and @\".exe\"@ on Windows or OS\/2).
> exeExtension :: String
> exeExtension = (#const_str EXE_EXTENSION)

Although one can imagine that the meaning of this function is tricky when 
cross-compiling, I don't think that has actually anything to do with the 
error.

The problem is that hsc2hs cannot handle this 'const_str' directive; see 
<https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/hsc2hs.html#hsc2hs_cross>. 

Now my question: how can this be fixed?

Is the failure of hsc2hs to support this directive just a matter of "not 
implemented right now", maybe by lack of importance? Or is there a fundamental 
problem?

If fixing hsc2hs is hard, could the 'directory' package perhaps choose another 
way to implement this function?



More information about the Haskell-Cafe mailing list