[Hackage] #245: Cabal should support hsc2hs's stub .c feature

Hackage trac at galois.com
Thu Feb 21 14:55:28 EST 2008


#245: Cabal should support hsc2hs's stub .c feature
----------------------------+-----------------------------------------------
  Reporter:  guest          |        Owner:         
      Type:  defect         |       Status:  new    
  Priority:  normal         |    Milestone:         
 Component:  Cabal library  |      Version:  1.2.3.0
  Severity:  normal         |   Resolution:         
  Keywords:                 |   Difficulty:  normal 
Ghcversion:  6.8.2          |     Platform:         
----------------------------+-----------------------------------------------
Changes (by duncan):

  * summary:  Cabal gets paths wrong in INCLUDEs => Cabal should support
              hsc2hs's stub .c feature

Comment:

 hsc2hs has a little used feature which is that you can use `#def`
 directives to spit bits of C code into a generated .c and .h file. The
 build system is supposed to notice this .c file and compile and link it
 into the system in question. Cabal does not do this (presumably because
 nobody implementing hsc2hs support had ever seen the feature).

 Turns out that people were making use of this hsc2hs feature despite the
 lack of support in Cabal by relying on the fact that Cabal used to put
 pre-processor output into the src dirs so instead of asking for proper
 support people worked around the issue by using things like:

 {{{
 c-sources: src/Foo_hsc.c
 }}}

 and relying on Cabal to run `hsc2hs` on `src/Foo.hsc` to generate
 `src/Foo_hsc.c` before compiling any `.c` files. Of course when Cabal-1.2
 changed to put all generated files under `dist/` this workaround broke.

 The right thing obviously is for Cabal to notice the `.c` files that
 `hsc2hs` generates and to compile and link them in. There may be a problem
 with paths however since `hsc2hs` will be putting the generated `.c` file
 under `dist/build/` and `hsc2hs` embeds a '#include` to the `.h` file with
 the full `dist/build/` prefix, but we do not put `.` on the include search
 path, only `dist/build/`, so the header file should really be relative to
 that. This may require changes in hsc2hs to support properly. We got this
 working correctly for `c2hs` which does similar things, embedding relative
 links between generated files.

-- 
Ticket URL: <http://hackage.haskell.org/trac/hackage/ticket/245#comment:1>
Hackage <http://haskell.org/cabal/>
Hackage: Cabal and related projects


More information about the cabal-devel mailing list