[GHC] #14994: ghc api: `load LoadAllTargets` is not idempotent

GHC ghc-devs at haskell.org
Mon Jun 11 00:40:18 UTC 2018


#14994: ghc api: `load LoadAllTargets` is not idempotent
-------------------------------------+-------------------------------------
        Reporter:  int-e             |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.6.1
       Component:  GHC API           |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by int-index):

 I tried to tackle this and couldn't reproduce — I've run the compiled
 binary and it prints `42`. Also, I've had to add `import GHC` to compile.

 With a freshly built compiler, here are the steps I took.

 Installed `ghc-paths`:

 {{{
 [nix-shell:~/Projects/ghc2]$ cabal install --with-
 compiler=`pwd`/inplace/bin/ghc-stage2 --package-
 db=`pwd`/inplace/lib/package.conf.d ghc-paths --allow-newer
 Resolving dependencies...
 Configuring ghc-paths-0.1.0.9...
 Building ghc-paths-0.1.0.9...
 Installed ghc-paths-0.1.0.9
 }}}

 Tried to build:

 {{{
 [nix-shell:~/Projects/ghc2]$ inplace/bin/ghc-stage2 T14994.hs
 [1 of 1] Compiling Main             ( T14994.hs, T14994.o )

 T14994.hs:19:13: error: Not in scope: ‘ghcMode’
    |
 19 |             ghcMode = CompManager,
    |             ^^^^^^^

 T14994.hs:20:13: error: Not in scope: ‘hscTarget’
    |
 20 |             hscTarget = HscInterpreted,
    |             ^^^^^^^^^

 T14994.hs:21:13: error: Not in scope: ‘ghcLink’
    |
 21 |             ghcLink = LinkInMemory,
    |             ^^^^^^^

 T14994.hs:22:13: error: Not in scope: ‘verbosity’
    |
 22 |             verbosity = 0
    |             ^^^^^^^^^
 }}}

 Added `import GHC`, tried to build:

 {{{
 [nix-shell:~/Projects/ghc2]$ inplace/bin/ghc-stage2 T14994.hs
 [1 of 1] Compiling Main             ( T14994.hs, T14994.o )

 T14994.hs:6:1: error:
     Could not find module ‘GHC’
     It is a member of the hidden package ‘ghc-8.5’.
     You can run ‘:set -package ghc’ to expose it.
     (Note: this unloads all the modules in the current scope.)
     Use -v to see a list of the files searched for.
 }}}

 Modified the build command by adding `-package ghc`:

 {{{
 [nix-shell:~/Projects/ghc2]$ inplace/bin/ghc-stage2 T14994.hs -package ghc
 [1 of 1] Compiling Main             ( T14994.hs, T14994.o )
 Linking T14994 ...
 }}}

 Running:

 {{{
 [nix-shell:~/Projects/ghc2]$ ./T14994
 42
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14994#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list