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

GHC environments (v2) #3936

Merged
merged 4 commits into from
Oct 16, 2016
Merged

GHC environments (v2) #3936

merged 4 commits into from
Oct 16, 2016

Conversation

dcoutts
Copy link
Contributor

@dcoutts dcoutts commented Oct 4, 2016

New version of the ghc environments stuff, now based on the project build status infrastructure. This makes the implementation simpler and should also be much more accurate and useful.

What this really needs is testing with ghc-8.0.2. There's only so much I can do with looking at what the output would look like for older ghc versions.

Ignore the first patch, it's covered by PR #3920.

@mention-bot
Copy link

@dcoutts, thanks for your PR! By analyzing the history of the files in this pull request, we identified @luite, @23Skidoo and @christiaanb to be potential reviewers.

@dcoutts
Copy link
Contributor Author

dcoutts commented Oct 7, 2016

Updated post backpack merge

@dcoutts dcoutts changed the title WIP: GHC environments (v2) GHC environments (v2) Oct 7, 2016
@@ -65,20 +66,26 @@ ghcVersionImplInfo ver = GhcImplInfo
, flagProfAuto = v >= [7,4]
, flagPackageConf = v < [7,5]
, flagDebugInfo = v >= [7,10]
, supportsPkgEnvFiles = v >= [8,0,2] -- broken in 8.0.1, fixed in 8.0.2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: to test with current GHC 8.0.x branch you need to edit this to be

v > [8,0,1]

indeed, perhaps it should just be that anyway.

Copy link
Member

@hvr hvr Oct 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcoutts if we know the snapshot date (== committer date of the respective commit) when it was fixed, we could say e.g.

 v >= [8,0,1,20161002]

That's the current date-stamped version of my ghc-8.0.2 ppa snapshot:

$ /opt/ghc/8.0.2/bin/ghc --numeric-version
8.0.1.20161002

$ /opt/ghc/8.0.2/bin/ghc --info | grep Git
 ,("Project Git commit id","a24092ff501028ca1245b508320493f394378495")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dcoutts
Copy link
Contributor Author

dcoutts commented Oct 7, 2016

Testing appreciated. Requires a GHC 8.0.x branch from September or later.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this to get some feedback.

@@ -730,6 +736,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
&& ghcVersion < mkVersion [7,8]
then toFlag sharedLibInstallPath
else mempty,
ghcOptHideAllPackages = toFlag True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...do we want to backport this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, yes.

runProgram verbosity ghcProg ["-c", testcfile,
"-o", testofile]
runProgram verbosity ghcProg
[ "-hide-all-packages"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probably some history to this -hide-all-packages flag...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that a question?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes; what happened that prompted you to add the flag here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so the ghc behaviour with these environment files is that it uses them by default unless you're using -hide-all-packages to get a clean environment. There's a couple places in Cabal where we invoke ghc where we don't want to pick up any local environment. Most of the time doing so would be benign, but if your local environment file is borked then we still want to work, by ignoring it. So that's what these few patches do.

A test would look like making a .ghc.env file that has bogus entries and then use Cabal to do things. That's essentially the situation that provoked me to make these fixes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't tell me; write it in the code ;)

This new ghc feature was actually added in ghc 7.10 but very limited,
then extended significantly in 8.0.1 but with a severe bug for our use
case and then should be working fine in 8.0.2 onwards.

This patch adds basic support for writing .ghc.environment files. This
feature will be used later in cabal-install, but it makes sense for the
functionality to live in Cabal next to the other code that knows all
too much about GHC.

.ghc.environment file support works in ghc 8.0.2 onwards

It was actually added in ghc 7.10 but very limited, then extended
significantly in 8.0.1 but with a severe bug for our use case and
then should be working fine in 8.0.2 onwards.
When we invoke ghc in Cabal it's impostant that we control the
environment. It's already the case that ghc ignores the .ghc.env files
when we use -hide-all-packages, but there were a few places where we
were not using this.
This is most of the way there but needs testing in practice with
ghc-8.0.2.
Change the minimum version we use to decide if ghc supports .ghc.env
files. Previously we declared that it required 8.0.2, but 8.0.2 is not
out yet so this makes things hard to test.

It was fixed in the 8.0.x branch at the end of August, so if ghc
declares itself to be 8.0.1.$date from September or later, then it's ok.
@hvr
Copy link
Member

hvr commented Oct 16, 2016

I've rebased the PR branch; its conflicts where only because of the already merged #3920

@hvr hvr merged commit a088119 into master Oct 16, 2016
@dcoutts
Copy link
Contributor Author

dcoutts commented Oct 18, 2016

@23Skidoo I think we should backport c6bd1d4 for the 1.24 branch

@dcoutts dcoutts added this to the 1.24.0.1 milestone Oct 18, 2016
@23Skidoo 23Skidoo deleted the ghc-environments branch October 18, 2016 22:22
@23Skidoo
Copy link
Member

@dcoutts Sure, will do tomorrow.

@23Skidoo
Copy link
Member

@dcoutts Done, see 329f7ac.

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

Successfully merging this pull request may close these issues.

5 participants