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

Reenable GHC environment file support #4433

Merged
merged 1 commit into from
May 15, 2017
Merged

Conversation

hvr
Copy link
Member

@hvr hvr commented Apr 2, 2017

This was temporarily disabled via
3033776 due to #4010
but it turns out that we can easily workaround this for
older Cabal versions.

All we need to do is inject --ghc-options=-hide-all-packages into
the flags passed to Setup.hs when an old Cabal version is detected
(this was suggested by @dcoutts in
#4010 (comment))

Luckily, -hide-all-packages is idempotent in GHC, so we can place it
anywhere on the GHC command-line as well as multiple times with the
same result.

This would close #4010

@mention-bot
Copy link

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

@hvr hvr force-pushed the pr/reenable-ghc-envs branch 2 times, most recently from ac0004e to b3af711 Compare April 2, 2017 17:39
@hvr hvr requested a review from dcoutts April 2, 2017 18:14
@@ -3001,7 +3001,13 @@ setupHsConfigureFlags (ReadyPackage elab@ElaboratedConfiguredPackage{..})
ElabComponent _ -> toFlag elabComponentId

configProgramPaths = Map.toList elabProgramPaths
configProgramArgs = Map.toList elabProgramArgs
configProgramArgs
| elabSetupScriptCliVersion < mkVersion [1,24,2]
Copy link
Member Author

@hvr hvr Apr 2, 2017

Choose a reason for hiding this comment

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

@dcoutts Fwiw, I just had to relax the upper bound to Cabal < 1.24.3, as I still ran into a problem of -hide-all-packages not being properly propagated even w/ Cabal-1.24.2 despite 329f7ac

Specifically this was with an install-plan that had build-tools: happy somewhere in its dependencies:

Extracting
/home/hvr/.cabal/packages/hackage.haskell.org/happy/1.19.5/happy-1.19.5.tar.gz
to <buildroot>/dist-newstyle/tmp/src-21625...
Updating happy.cabal with the latest revision from the index.
creating dist
creating
<buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup
/opt/ghc/bin/ghc-8.0.2 --make -fbuilding-cabal-package -odir <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup -hidir <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup -i -i<buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5 -hide-all-packages -no-user-package-db -package-db /home/hvr/.cabal/store/ghc-8.0.2/package.db -package-id Cabal-1.24.2.0 -package-id array-0.5.1.1 -package-id base-4.9.1.0 -package-id binary-0.8.3.0 -package-id bytestring-0.10.8.1 -package-id containers-0.5.7.1 -package-id deepseq-1.4.2.0 -package-id directory-1.3.0.0 -package-id filepath-1.4.1.1 -package-id ghc-prim-0.5.0.0 -package-id old-time-1.1.0.3-c5562bda5b4ce63bee0fb53328baadb160c26217b727f0eb5f496b0a52118b19 -package-id pretty-1.1.3.3 -package-id process-1.4.3.0 -package-id template-haskell-2.11.1.0 -package-id time-1.6.0.1 -package-id transformers-0.5.2.0 -package-id unix-2.7.2.1 <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup/setup.hs -o <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup/setup -threaded
[1 of 1] Compiling Main             ( <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup/setup.hs, <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup/Main.o )

<buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup/setup.hs:21:1: warning: [-Wtabs]
    Tab character found here, and in 39 further locations.
    Please use spaces instead.
Linking <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup/setup ...
<buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup/setup
configure --verbose=2 --builddir=dist --ghc
--prefix=/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f
--bindir=/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/bin
--libdir=/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/lib
--libsubdir=
--libexecdir=/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/libexec
--datadir=/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/share
--datasubdir=
--docdir=/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/share/doc
--htmldir=/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/share/doc/html
--haddockdir=/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/share/doc/html
--sysconfdir=/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/etc
--enable-library-vanilla --disable-library-profiling --enable-shared
--disable-executable-dynamic --disable-profiling --profiling-detail=default
--library-profiling-detail=default --enable-optimization --disable-debug-info
--disable-library-for-ghci --disable-split-objs --disable-executable-stripping
--disable-library-stripping --package-db=clear --package-db=global
--package-db=/home/hvr/.cabal/store/ghc-8.0.2/package.db --flags=small_base
--ipid=happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f
--dependency=base=base-4.9.1.0 --dependency=array=array-0.5.1.1
--dependency=containers=containers-0.5.7.1
--dependency=mtl=mtl-2.2.1-cd1c4da44eb0fb2a08c0e76a7721fe0be85b4039e133fb6bb879c171c32a7170
--disable-tests --disable-coverage --exact-configuration --disable-benchmarks
--with-ghc=/opt/ghc/bin/ghc-8.0.2 --with-ghc-pkg=/opt/ghc/bin/ghc-pkg-8.0.2
Configuring happy-1.19.5...
Flags chosen: small_base=True
Dependency array ==0.5.1.1: using array-0.5.1.1
Dependency base ==4.9.1.0: using base-4.9.1.0
Dependency containers ==0.5.7.1: using containers-0.5.7.1
Dependency mtl ==2.2.1: using mtl-2.2.1
Using Cabal-1.24.2.0 compiled by ghc-8.0
Using compiler: ghc-8.0.2
Using install prefix:
/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f
Binaries installed in:
/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/bin
Libraries installed in:
/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/lib
Dynamic libraries installed in:
/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/lib/x86_64-linux-ghc-8.0.2
Private binaries installed in:
/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/libexec
Data files installed in:
/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/share
Documentation installed in:
/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/share/doc
Configuration files installed in:
/home/hvr/.cabal/store/ghc-8.0.2/happy-1.19.5-ba45dddd0cf11eb0250a844bd84e735a2b57db0eedf7c251b5a64be40a124a0f/etc
No alex found
Using ar found on system at: /usr/bin/ar
No c2hs found
No cpphs found
Using gcc version 5.4.0 found on system at: /usr/bin/gcc
Using ghc version 8.0.2 given by user at: /opt/ghc/bin/ghc-8.0.2
Using ghc-pkg version 8.0.2 given by user at: /opt/ghc/bin/ghc-pkg-8.0.2
No ghcjs found
No ghcjs-pkg found
No greencard found
Using haddock version 2.17.3 found on system at:
/opt/ghc/bin/haddock-ghc-8.0.2
No happy found
Using haskell-suite found on system at: haskell-suite-dummy-location
Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy-location
No hmake found
Using hpc version 0.67 found on system at: /usr/bin/hpc
Using hsc2hs version 0.68.1 found on system at: /opt/ghc/8.0.2/bin/hsc2hs
No hscolour found
No jhc found
Using ld found on system at: /usr/bin/ld
No lhc found
No lhc-pkg found
Using pkg-config version 0.29.1 found on system at: /usr/bin/pkg-config
Using strip version 2.26 found on system at: /usr/bin/strip
Using tar found on system at: /bin/tar
No uhc found
creating
<buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup
/opt/ghc/bin/ghc-8.0.2 --make -fbuilding-cabal-package -odir <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup -hidir <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup -i -i<buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5 -hide-all-packages -no-user-package-db -package-db /home/hvr/.cabal/store/ghc-8.0.2/package.db -package-id Cabal-1.24.2.0 -package-id array-0.5.1.1 -package-id base-4.9.1.0 -package-id binary-0.8.3.0 -package-id bytestring-0.10.8.1 -package-id containers-0.5.7.1 -package-id deepseq-1.4.2.0 -package-id directory-1.3.0.0 -package-id filepath-1.4.1.1 -package-id ghc-prim-0.5.0.0 -package-id old-time-1.1.0.3-c5562bda5b4ce63bee0fb53328baadb160c26217b727f0eb5f496b0a52118b19 -package-id pretty-1.1.3.3 -package-id process-1.4.3.0 -package-id template-haskell-2.11.1.0 -package-id time-1.6.0.1 -package-id transformers-0.5.2.0 -package-id unix-2.7.2.1 <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup/setup.hs -o <buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup/setup -threaded
<buildroot>/dist-newstyle/tmp/src-21625/happy-1.19.5/dist/setup/setup
build --verbose=2 --builddir=dist
Component build order: executable 'happy'
creating dist/build
creating dist/build/autogen
Building happy-1.19.5...
/opt/ghc/bin/ghc-pkg-8.0.2 init dist/package.conf.inplace
Preprocessing executable 'happy' for happy-1.19.5...
Building executable happy...
creating dist/build/happy
creating dist/build/happy/happy-tmp
/opt/ghc/bin/ghc-8.0.2 --make -no-link -fbuilding-cabal-package -O -static -outputdir dist/build/happy/happy-tmp -odir dist/build/happy/happy-tmp -hidir dist/build/happy/happy-tmp -stubdir dist/build/happy/happy-tmp -i -idist/build/happy/happy-tmp -isrc -idist/build/autogen -Idist/build/autogen -Idist/build/happy/happy-tmp -optP-include -optPdist/build/autogen/cabal_macros.h -hide-all-packages -no-user-package-db -package-db /home/hvr/.cabal/store/ghc-8.0.2/package.db -package-db dist/package.conf.inplace -package-id array-0.5.1.1 -package-id base-4.9.1.0 -package-id containers-0.5.7.1 -package-id mtl-2.2.1-cd1c4da44eb0fb2a08c0e76a7721fe0be85b4039e133fb6bb879c171c32a7170 -XHaskell98 -XCPP -XMagicHash -XFlexibleContexts src/Main.lhs -Wall -fno-warn-type-defaults
[ 1 of 18] Compiling Target           ( src/Target.lhs, dist/build/happy/happy-tmp/Target.o )
[ 2 of 18] Compiling Paths_happy      ( dist/build/autogen/Paths_happy.hs, dist/build/happy/happy-tmp/Paths_happy.o )
[ 3 of 18] Compiling ParseMonad       ( src/ParseMonad.hs, dist/build/happy/happy-tmp/ParseMonad.o )
[ 4 of 18] Compiling NameSet          ( src/NameSet.hs, dist/build/happy/happy-tmp/NameSet.o )
[ 5 of 18] Compiling Lexer            ( src/Lexer.lhs, dist/build/happy/happy-tmp/Lexer.o )
[ 6 of 18] Compiling GenUtils         ( src/GenUtils.lhs, dist/build/happy/happy-tmp/GenUtils.o )
[ 7 of 18] Compiling AttrGrammar      ( src/AttrGrammar.lhs, dist/build/happy/happy-tmp/AttrGrammar.o )
[ 8 of 18] Compiling AttrGrammarParser ( dist/build/happy/happy-tmp/AttrGrammarParser.hs, dist/build/happy/happy-tmp/AttrGrammarParser.o )
[ 9 of 18] Compiling AbsSyn           ( src/AbsSyn.lhs, dist/build/happy/happy-tmp/AbsSyn.o )
[10 of 18] Compiling ParamRules       ( src/ParamRules.hs, dist/build/happy/happy-tmp/ParamRules.o )

src/ParamRules.hs:5:1: warning: [-Wdeprecations]
    Module ‘Control.Monad.Error’ is deprecated:
      Use Control.Monad.Except instead

src/ParamRules.hs:6:1: warning: [-Wdeprecations]
    Module ‘Control.Monad.Instances’ is deprecated:
      This module now contains no instances and will be removed in the future

src/ParamRules.hs:31:17: warning: [-Wdeprecations]
    In the use of type constructor or class ‘ErrorT’
    (imported from Control.Monad.Error, but defined in transformers-0.5.2.0:Control.Monad.Trans.Error):
    Deprecated: "Use Control.Monad.Trans.Except instead"

src/ParamRules.hs:71:10: warning: [-Wdeprecations]
    In the use of type constructor or class ‘ErrorT’
    (imported from Control.Monad.Error, but defined in transformers-0.5.2.0:Control.Monad.Trans.Error):
    Deprecated: "Use Control.Monad.Trans.Except instead"

src/ParamRules.hs:72:27: warning: [-Wdeprecations]
    In the use of ‘runErrorT’
    (imported from Control.Monad.Error, but defined in transformers-0.5.2.0:Control.Monad.Trans.Error):
    Deprecated: "Use Control.Monad.Trans.Except instead"
[11 of 18] Compiling Grammar          ( src/Grammar.lhs, dist/build/happy/happy-tmp/Grammar.o )
[12 of 18] Compiling First            ( src/First.lhs, dist/build/happy/happy-tmp/First.o )
[13 of 18] Compiling LALR             ( src/LALR.lhs, dist/build/happy/happy-tmp/LALR.o )
[14 of 18] Compiling Info             ( src/Info.lhs, dist/build/happy/happy-tmp/Info.o )
[15 of 18] Compiling ProduceCode      ( src/ProduceCode.lhs, dist/build/happy/happy-tmp/ProduceCode.o )
[16 of 18] Compiling ProduceGLRCode   ( src/ProduceGLRCode.lhs, dist/build/happy/happy-tmp/ProduceGLRCode.o )
[17 of 18] Compiling Parser           ( dist/build/happy/happy-tmp/Parser.hs, dist/build/happy/happy-tmp/Parser.o )
[18 of 18] Compiling Main             ( src/Main.lhs, dist/build/happy/happy-tmp/Main.o )
Linking...
/opt/ghc/bin/ghc-8.0.2 --make -fbuilding-cabal-package -O -static -outputdir dist/build/happy/happy-tmp -odir dist/build/happy/happy-tmp -hidir dist/build/happy/happy-tmp -stubdir dist/build/happy/happy-tmp -i -idist/build/happy/happy-tmp -isrc -idist/build/autogen -Idist/build/autogen -Idist/build/happy/happy-tmp -optP-include -optPdist/build/autogen/cabal_macros.h -hide-all-packages -no-user-package-db -package-db /home/hvr/.cabal/store/ghc-8.0.2/package.db -package-db dist/package.conf.inplace -package-id array-0.5.1.1 -package-id base-4.9.1.0 -package-id containers-0.5.7.1 -package-id mtl-2.2.1-cd1c4da44eb0fb2a08c0e76a7721fe0be85b4039e133fb6bb879c171c32a7170 -XHaskell98 -XCPP -XMagicHash -XFlexibleContexts src/Main.lhs -o dist/build/happy/happy -Wall -fno-warn-type-defaults
Linking dist/build/happy/happy ...
/opt/ghc/bin/ghc-8.0.2 -o HappyTemplate.tmp -E -cpp templates/GenericTemplate.hs
<command line>: cannot satisfy -package-id base-4.9.1.012345
    (use -v for more information)
CallStack (from HasCallStack):
  die', called at ./Distribution/Client/ProjectOrchestration.hs:781:8 in cabal-install-2.1.0.0-inplace:Distribution.Client.ProjectOrchestration

@alexbiehl
Copy link
Member

What's the status on this?

@hvr
Copy link
Member Author

hvr commented Apr 8, 2017

@alexbiehl I'm waiting for somebody to tell me whether the issue I noticed in #4433 (comment) is still an issue in Cabal-2.0 and if that's the case, for somebody to fix it :-)

@ezyang
Copy link
Contributor

ezyang commented Apr 28, 2017

Pinging @dcoutts to confirm if the relevant fixes have been merged into 1.24. It feels like they probably have not.

@hvr
Copy link
Member Author

hvr commented Apr 28, 2017

@ezyang I'm currently afraid that even Cabal 2.0 may still suffer from this; I'll try to come up with a simple way to test/reproduce this.

@alexbiehl
Copy link
Member

alexbiehl commented May 5, 2017

I noticed happy is spawning ghc in its Setup.hs. I have created a small repro (using ghc-8.0.2, but should equally well work with any other as long as there is an invalid env file for the compiler) here: https://github.com/alexbiehl/hide-all-packages-repro

This was temporarily disabled via
3033776 due to haskell#4010
but it turns out that we can easily workaround this for
older Cabal versions.

All we need to do is inject `--ghc-options=-hide-all-packages` into
the flags passed to Setup.hs
(this was suggested by @dcoutts in
haskell#4010 (comment))

Luckily, `-hide-all-packages` is idempotent in GHC, so we can place it
anywhere on the GHC command-line as well as multiple times with the
same result.

This would close haskell#4010
@hvr
Copy link
Member Author

hvr commented May 15, 2017

As discussed with @23Skidoo I'm going to merge this to master once it's green so that we can start dogfooding this a bit better and figure out if there's any other issues left (I've been using it myself so far and it didn't cause issues; coincidentally this also helped @bgamari to workaround #4514 as ghc env files currently happen to include all transitive dependencies)

PS: the PR is as green as master currently is... i.e.

"env": "GHCVER=7.4.2 SCRIPT=script CABAL_LIB_ONLY=YES TEST_OTHER_VERSIONS=YES"

fails already on master for some reason unrelated to this PR.

@hvr hvr merged commit 52a5a93 into haskell:master May 15, 2017
@hvr hvr deleted the pr/reenable-ghc-envs branch May 15, 2017 09:14
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.

ghc envs not properly ignored by new-build
5 participants