[Hackage] #245: Cabal gets paths wrong in INCLUDEs

#245: Cabal gets paths wrong in INCLUDEs ----------------------------+----------------------------------------------- Reporter: guest | Owner: Type: defect | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.2.3.0 Severity: normal | Keywords: Difficulty: normal | Ghcversion: 6.8.2 Platform: | ----------------------------+----------------------------------------------- The Pugs project recently uncovered a bit of a problem with GHC 6.8.x. To quote: - {-# INCLUDE -} seems to require either a very relative or an absolute path. That is, you have to make the path listed inside an INCLUDE ('dist/build/Pugs/Embed/Parrot_hsc.h') in the file dist/build/Pugs/Embed/Parrot.hs absolute or completely relative - that is, the first line needs to look like either '{-# INCLUDE "Parrot_hsc.h" #-}' or '{-# INCLUDE "/home/gwern/bin/pugs/dist/build/Pugs/Embed/Parrot_hsc.h" #-}'. The particular problem is that 'dist/build/Pugs/Embed/Parrot_hsc.c:#include "Parrot_hsc.h"' is being translated to the (broken) 'dist/build/Pugs/Embed/Parrot.hs:{-# INCLUDE "dist/build/Pugs/Embed/Parrot_hsc.h" #-}'. The relevant files and notes can be found in the Pugs SVN repo, in src/Pugs/Embed/, and the files of interest are Haskell.hs Parrot.hsc Parrot_hsc.c Parrot_hsc.h Perl5.hs Pugs.hs -- gwern -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/245 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#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

#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: ----------------------------+----------------------------------------------- Comment (by ross@soi.city.ac.uk): There's a good reason that this feature is little used (see the Note in the description of this feature in the GHC User's Guide). Because of GHC's cross-module inlining, to do it right you'd need to treat the _hsc.h files as both includes and install-includes, to be included in the compilation of dependent packages. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/245#comment:2 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#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: ----------------------------+----------------------------------------------- Comment (by duncan): I've filed a ticket with pugs: http://dev.pugscode.org/ticket/32 -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/245#comment:3 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#245: Cabal should support hsc2hs's stub .c feature ----------------------------+----------------------------------------------- Reporter: guest | Owner: Type: defect | Status: new Priority: low | Milestone: _|_ Component: Cabal library | Version: 1.2.3.0 Severity: normal | Resolution: Keywords: | Difficulty: normal Ghcversion: 6.8.2 | Platform: ----------------------------+----------------------------------------------- Changes (by duncan): * priority: normal => low * milestone: => _|_ -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/245#comment:4 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#245: Cabal should support hsc2hs's stub .c feature ----------------------------+----------------------------------------------- Reporter: guest | Owner: Type: defect | Status: new Priority: low | Milestone: _|_ Component: Cabal library | Version: 1.2.3.0 Severity: normal | Resolution: Keywords: | Difficulty: normal Ghcversion: 6.8.2 | Platform: ----------------------------+----------------------------------------------- Comment (by dons): This breaks Tuomov's 'riot' too, http://modeemi.fi/~tuomov/riot/ where his Makefile build system compiles and links in, ghc -c -fglasgow-exts -cpp -fasm -funbox-strict-fields -fignore-asserts -cpp -DCF_CHARSET_SUPPORT -DCF_WCHAR_SUPPORT -DHAVE_WADDNWSTR -DHAVE_RESIZETERM -DGHC64 -I. -Icbits Ginsu/CWString_hsc.c -o Ginsu/CWString_hsc.o ghc -c -fglasgow-exts -cpp -fasm -funbox-strict-fields -fignore-asserts -cpp -DCF_CHARSET_SUPPORT -DCF_WCHAR_SUPPORT -DHAVE_WADDNWSTR -DHAVE_RESIZETERM -DGHC64 -I. -Icbits Curses/Curses_hsc.c -o Curses/Curses_hsc.o But with a .cabal file, we can't get those linked, leading to errors: (.text+0xc087): undefined reference to `hs_curses_acs_ulcorner' dist/build/riot/riot-tmp/Curses/Curses.o: In function `rkgA_info': (.text+0x12fd4): undefined reference to `hs_curses_color_pair' dist/build/riot/riot-tmp/Ginsu/CWString.o: In function `sdkc_info': (.text+0x24ff): undefined reference to `hs_get_mb_cur_max' collect2: ld returned 1 exit status cabal: Error: some packages failed to install: riot-1.20080618 failed during the building phase. The exception was: exit: ExitFailure 1 -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/245#comment:5 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects
participants (1)
-
Hackage