Ticket #4899 (new bug)

Opened 17 months ago

Last modified 4 months ago

Non-standard compile plus Template Haskell produces spurious "unknown symbol" linker error

Reported by: jepst Owned by: simonmar
Priority: low Milestone: 7.6.1
Component: Compiler Version: 7.0.1
Keywords: template link prof dynamic Cc: ppremont@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Programs that use Template Haskell fail to link when doing a "non-standard" compile. Specifically, compilations with -prof and -dynamic produce this bug, although other flags may as well; it seems that compilations that require the two-stage -osuf flag produce this bug. The error message is always "unknown symbol" but the specific symbol that is allegedly missing varies. Removing the TH block from the code makes the problem go away.

I've provided a minimal example of a program that can reproduce this bug, in the enclosed files Bug1.hs and Main.hs. A typescript demonstrating the error message is also included.

Tested on GHC 7.0.1 and 6.12.1, running under Ubuntu 10.04, both 64-bit and 32-bit. Also tested with 6.12.3 under 32-bit Windows 7.

Attachments

bug4899.zip Download (1.2 KB) - added by jepst 17 months ago.
Program demonstrating bug

Change History

Changed 17 months ago by jepst

Program demonstrating bug

Changed 16 months ago by igloo

  • milestone set to 7.2.1

Thanks for the report.

Changed 13 months ago by simonpj

  • owner set to simonmar

Jeff's script is wrong. The desired thing is

  • ghc --make Main
  • ghc --make -prof -osuf p_o -hisuf p_hi

and he wasn't doing that.

  • The error message didn't make it clear that's what to do
  • There was no mention of hisuf, which is bad

However there is something deeper wrong. When compiling a TH splice $(Foo.f 3) with -prof, we compile the byte-code non-profiled, and link against the non-profiled Foo.o. But which hi file will we use for Foo. Really we should use Foo.hi for the TH stuff and Foo.p_hi for the stuff outside TH splices. But GHC has no mechanism for two simultaneous interface files!

It probably just about works at the moment because TH only uses the types of exported symbols, which don't really vary between .p_hi and .hi files. The ice is pretty thin though.

We'd also like a better error report for when you link against a .o file that (say) was compiled with profiling. ghc: ./Bug1.o: unknown symbol era doesn't help much!

Changed 7 months ago by patrick_premont

  • cc ppremont@… added

Changed 4 months ago by igloo

  • priority changed from normal to low
  • milestone changed from 7.4.1 to 7.6.1
Note: See TracTickets for help on using tickets.