Skip to content

cc-options do not get passed to GHC #4435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bitonic opened this issue Apr 4, 2017 · 11 comments
Open

cc-options do not get passed to GHC #4435

bitonic opened this issue Apr 4, 2017 · 11 comments

Comments

@bitonic
Copy link

bitonic commented Apr 4, 2017

cc-options currently do not get seem to get passed to GHC. It would be useful if they were, since GHC is capable of compiling C/C++ files and now it might more than before given the addition of addForeignFile in GHC 8.2, which lets users compile and link C/C++ files from TH.

@bitonic
Copy link
Author

bitonic commented Apr 4, 2017

Note that in practice one needs to put the cc options both in cc-options and in ghc-options via -optc, since inline-c is often used with hsc2hs which does get the flags from cc-options.

@bitonic
Copy link
Author

bitonic commented Apr 4, 2017

Note that the same happens for linking: extra-libraries are not passed to GHC, which makes loadDLL fail when it dlopens shared libraries referring to any of the specified extra-libraries.

@bitonic
Copy link
Author

bitonic commented Apr 4, 2017

Note that cabal even emits warnings like

Warning: Instead of 'ghc-options: -lceres ...' use 'extra-libraries:
ceres ...'

even if they do not have the same effect.

@ezyang
Copy link
Contributor

ezyang commented Apr 5, 2017

Related issue #3700

Not passing extra-libraries to GHC as -l is probably a separate bug. If this doesn't cause any regressions, we probably should do this, at the very least when other-extensions: TemplateHaskell is specified, and maybe unconditionally.

@ezyang ezyang added this to the 2.2 milestone May 7, 2017
@ezyang
Copy link
Contributor

ezyang commented May 7, 2017

@bitonic If you're interested in solving this ticket I'd be happy to advise.

@basvandijk
Copy link
Member

I just run into this today when building haskell-opencv with cabal-install. I got the following error:

<no location info>: error:
    ghc: panic! (the 'impossible' happened)
  (GHC version 8.4.4 for x86_64-unknown-linux):
	Loading temp shared object failed: 
          /run/user/1001/ghc14715_0/libghc_95.so: 
            undefined symbol: _Znwm

Note that _Znwm demangles to: operator new(unsigned long).

After adding ghc-options: -lstdc++ to opencv.cabal the build succeeded.

Note that I did get the warning:
Warning: Instead of 'ghc-options: -lstdc++' use 'extra-libraries: stdc++'

@phadej
Copy link
Collaborator

phadej commented Dec 16, 2018

For the record, haskell-opencv does specify:

    extra-libraries:   stdc++

I agree with Edward, "Unconditional passing of extra-libraries as -l flags to GHC" patch is probably easy to write (and if CI is green, to merge).

@domenkozar
Copy link
Collaborator

domenkozar commented Aug 12, 2019

It's the same issue with cxx-options: -std=c++14, it still needs ghc-options: -optc-std=c++14 when using inline-c-pp as previously mentioned.

It's going to be a bit easier in GHC 8.8: https://gitlab.haskell.org/ghc/ghc/issues/16477

@phadej
Copy link
Collaborator

phadej commented Aug 12, 2019

Is this similar problem as with ld-options as with @nh2 recently fixed?

@ulysses4ever
Copy link
Collaborator

This issue was marked high-priority a while ago. Since then, there were a number of updates around passing options between cabal and GHC. To determine whether these updates had any impact in the issue, a minimal reproducer would be helpful.

Do we have a minimal reproducer?

@ulysses4ever ulysses4ever removed this from the Considered for 3.4 milestone May 15, 2025
@phadej
Copy link
Collaborator

phadej commented May 15, 2025

#9801

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants