Skip to content
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

Respect ghc-options and with-gcc when compiling C sources #5440

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@syntheorem
Copy link

commented Jul 17, 2018

This fix allows users to override the C/C++ compiler, either by passing
--with-gcc to configure or adding -pgmc to ghc-options in their Cabal
file.

Tested manually with a project using C++ sources that require a more
recent version of clang than the default install (macOS). Inspected the
output of Setup.hs build -v to confirm that the correct arguments are
being passed to GHC when compiling the C++ sources.

Resolves: #4439

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • If the change is docs-only, [ci skip] is used to avoid triggering the build bots.
Respect ghc-options and with-gcc when compiling C sources
This fix allows users to override the C/C++ compiler, either by passing
--with-gcc to configure or adding -pgmc to ghc-options in their Cabal
file.

Tested manually with a project using C++ sources that require a more
recent version of clang than the default install (macOS). Inspected the
output of `Setup.hs build -v` to confirm that the correct arguments are
being passed to GHC when compiling the C++ sources.

Resolves: #4439
@angerman

This comment has been minimized.

Copy link
Collaborator

commented Jul 17, 2018

Shouldn’t this be —with-cc? Didn’t we already respect CC env vars?

@syntheorem

This comment has been minimized.

Copy link
Author

commented Jul 17, 2018

Shouldn’t this be —with-cc?

No, this is using the existing program replacement infrastructure, in which the C compiler is named gcc. So --with-gcc is the already existing option (stack uses it as well).

Didn’t we already respect CC env vars?

Possibly, if GHC itself respects those env vars. The problem is that we were calling GHC to compile C files without explicitly passing -pgmc, so GHC didn't know about any --with-gcc arguments that were passed to Setup configure.

@angerman

This comment has been minimized.

Copy link
Collaborator

commented Jul 18, 2018

Fair point on --with-gcc.

What happens if --ghc-options with -pgmc and --with-gcc is provided pointing to different ccs?

@syntheorem

This comment has been minimized.

Copy link
Author

commented Jul 18, 2018

Since --ghc-options are always passed last to GHC, they should override any previous options. So the precedence would be:

  1. --ghc-options on the command line
  2. ghc-options in the .cabal file
  3. --with-gcc
@angerman

This comment has been minimized.

Copy link
Collaborator

commented Jul 18, 2018

So I could provide --with-gcc, and end up in a situation where some other value is picked?

Should we rather WARN or even ERROR in that case?

@syntheorem

This comment has been minimized.

Copy link
Author

commented Jul 18, 2018

Sure, but that applies to any argument that Cabal passes to GHC. I think that ghc-options overriding everything is expected behavior.

Although maybe we want to warn upon ever seeing -pgmc in a .cabal file, since it seems questionable to configure it at all from there (because which program to use will depend on the system you're compiling on). Seems like a separate issue should be filed for that though.

@syntheorem

This comment has been minimized.

Copy link
Author

commented Jul 20, 2018

FYI, this is the Travis CI failure, only in the DEBUG_EXPENSIVE_ASSERTIONS build:

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.

And this is the AppVeyor failure:

Build execution time has reached the maximum allowed time for your plan (60 minutes).

Not sure that these are actionable failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.