Linker problem with HPC and TemplateHaskell

Hi, I'm getting the following error message when compiling a Yesod application (which uses Template Haskell rather a lot) with -fhpc: /usr/bin/ld: ./Foundation.dyn_o: relocation R_X86_64_PC32 against undefined symbol `_hpc_tickboxes_Settings_hpc' can not be used when making a shared object; recompile with -fPIC Steps to reproduce: 1. Run 'yesod init' to make a new scaffold. Call it 'testsite' and select 'simple' for no database. 2. Run: cd testsite sed Settings.hs -i -e 's/staticRoot conf.*/staticRoot conf = "foo"/' # GHC doesn't like this line ghc --make app/main.hs -XTemplateHaskell -XCPP -XOverloadedStrings -XMultiParamTypeClasses -XTypeFamilies -fhpc -O1 Running the ghc line again completes successfully. It seems that there is a missing ./Settings.dyn_o in the gcc command line that ghc calls, the first time through. It's there the second time so the link succeeds. No idea what that might mean. It's not a problem at -O0. I'm using 7.8.3 so this might be fixed now. Not sure what else might help! Any advice gratefully received. Cheers, David

Sounds like a bug. File a ticket? If you can see if you can repro on GHC HEAD that would also be helpful. Edward Excerpts from David Turner's message of 2014-12-19 16:24:25 -0500:
Hi,
I'm getting the following error message when compiling a Yesod application (which uses Template Haskell rather a lot) with -fhpc:
/usr/bin/ld: ./Foundation.dyn_o: relocation R_X86_64_PC32 against undefined symbol `_hpc_tickboxes_Settings_hpc' can not be used when making a shared object; recompile with -fPIC
Steps to reproduce:
1. Run 'yesod init' to make a new scaffold. Call it 'testsite' and select 'simple' for no database. 2. Run:
cd testsite sed Settings.hs -i -e 's/staticRoot conf.*/staticRoot conf = "foo"/' # GHC doesn't like this line ghc --make app/main.hs -XTemplateHaskell -XCPP -XOverloadedStrings -XMultiParamTypeClasses -XTypeFamilies -fhpc -O1
Running the ghc line again completes successfully.
It seems that there is a missing ./Settings.dyn_o in the gcc command line that ghc calls, the first time through. It's there the second time so the link succeeds. No idea what that might mean.
It's not a problem at -O0.
I'm using 7.8.3 so this might be fixed now.
Not sure what else might help! Any advice gratefully received.
Cheers,
David

Ok, I've opened https://ghc.haskell.org/trac/ghc/ticket/9909
I won't be able to repro on HEAD in the near future, I'm afraid.
Many thanks,
On 19 December 2014 at 21:32, Edward Z. Yang
Sounds like a bug. File a ticket? If you can see if you can repro on GHC HEAD that would also be helpful.
Edward
Excerpts from David Turner's message of 2014-12-19 16:24:25 -0500:
Hi,
I'm getting the following error message when compiling a Yesod application (which uses Template Haskell rather a lot) with -fhpc:
/usr/bin/ld: ./Foundation.dyn_o: relocation R_X86_64_PC32 against undefined symbol `_hpc_tickboxes_Settings_hpc' can not be used when making a shared object; recompile with -fPIC
Steps to reproduce:
1. Run 'yesod init' to make a new scaffold. Call it 'testsite' and select 'simple' for no database. 2. Run:
cd testsite sed Settings.hs -i -e 's/staticRoot conf.*/staticRoot conf = "foo"/' # GHC doesn't like this line ghc --make app/main.hs -XTemplateHaskell -XCPP -XOverloadedStrings -XMultiParamTypeClasses -XTypeFamilies -fhpc -O1
Running the ghc line again completes successfully.
It seems that there is a missing ./Settings.dyn_o in the gcc command line that ghc calls, the first time through. It's there the second time so the link succeeds. No idea what that might mean.
It's not a problem at -O0.
I'm using 7.8.3 so this might be fixed now.
Not sure what else might help! Any advice gratefully received.
Cheers,
David

Turns out this was already a known issue:
https://ghc.haskell.org/trac/ghc/ticket/9762 and a fix is now on the
way for 7.10.1. In the meantime, adding -fomit-interface-pragmas works
for me.
Thanks,
David
On 19 December 2014 at 21:58, David Turner
Ok, I've opened https://ghc.haskell.org/trac/ghc/ticket/9909
I won't be able to repro on HEAD in the near future, I'm afraid.
Many thanks,
On 19 December 2014 at 21:32, Edward Z. Yang
wrote: Sounds like a bug. File a ticket? If you can see if you can repro on GHC HEAD that would also be helpful.
Edward
Excerpts from David Turner's message of 2014-12-19 16:24:25 -0500:
Hi,
I'm getting the following error message when compiling a Yesod application (which uses Template Haskell rather a lot) with -fhpc:
/usr/bin/ld: ./Foundation.dyn_o: relocation R_X86_64_PC32 against undefined symbol `_hpc_tickboxes_Settings_hpc' can not be used when making a shared object; recompile with -fPIC
Steps to reproduce:
1. Run 'yesod init' to make a new scaffold. Call it 'testsite' and select 'simple' for no database. 2. Run:
cd testsite sed Settings.hs -i -e 's/staticRoot conf.*/staticRoot conf = "foo"/' # GHC doesn't like this line ghc --make app/main.hs -XTemplateHaskell -XCPP -XOverloadedStrings -XMultiParamTypeClasses -XTypeFamilies -fhpc -O1
Running the ghc line again completes successfully.
It seems that there is a missing ./Settings.dyn_o in the gcc command line that ghc calls, the first time through. It's there the second time so the link succeeds. No idea what that might mean.
It's not a problem at -O0.
I'm using 7.8.3 so this might be fixed now.
Not sure what else might help! Any advice gratefully received.
Cheers,
David
participants (2)
-
David Turner
-
Edward Z. Yang