Opened 6 years ago

Closed 16 months ago

#2705 closed bug (wontfix)

ghc discards version of wired-in packages

Reported by: thoughtpolice Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.10.1
Keywords: Cc: droundy@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

If you invoke ghc with something like -hide-all-packages and then run it over a file like so:

import Prelude
import System.Process

main = putStrLn "hi"

GHC will tell you:

$ ghc -hide-all-packages test1.hs 

test2.hs:1:0:
    Failed to load interface for `Prelude':
      it is a member of package base-3.0.3.0, which is hidden

But if you have a file like this which uses haskell98

module Main where
import System
import Prelude

main = do p <- getProgName
          putStrLn $ "program name is " ++ p

And try to compile it, GHC says this:

$ ghc -hide-all-packages test2.hs 

Main.hs:2:0:
    Failed to load interface for `System':
      it is a member of package haskell98, which is hidden

It does not report the version number of haskell98. There is a reason we want this: while hacking on David Roundy's build system franchise (darcs get http://darcs.net/repos/franchise/) I noticed that while the package built under GHC 6.10 (with a tweak or two,) it reported the franchise package as broken. However, when running ghc-pkg check I got this (very unhelpful) output:

$ ghc-pkg list franchise 
/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.0.20081007/./package.conf:
/Users/austinseipp/.ghc/i386-darwin-6.10.0.20081007/package.conf:
{franchise-0.0.3}
$
ghc-pkg check
package franchise-0.0.3 has missing dependencies:
$

This is the configuration file generated by franchise, for itself:

name: franchise
version: 0.0.3
license: BSD3
copyright: David Roundy
maintainer: ???
import-dirs: "/Users/austinseipp/lib/franchise-0.0.3/"
library-dirs: "/Users/austinseipp/lib/franchise-0.0.3/"
exposed-modules: Distribution.Franchise
hidden-modules: Distribution.Franchise.StringSet Distribution.Franchise.ConfigureState Distribution.Franchise.Util Distribution.Franchise.Buildable Distribution.Franchise.Ghc
hs-libraries: franchise
exposed: True
depends: haskell98, base-3.0.3.0, directory-1.0.0.2, process-1.0.1.0

The problem is:

depends: haskell98, base-3.0.3.0, directory-1.0.0.2, process-1.0.1.0

Should be:

depends: haskell98-1.0.1.0, base-3.0.3.0, directory-1.0.0.2, process-1.0.1.0

I tracked this down further by examining the source code; it seems as if franchise starts off by running 'ghc -hide-all-packages' over the source code repeatedly, gobbling up and parsing all of the 'package is hidden' errors until there are no more, and determining what packages are necessary and what version and using that as build info. But as GHC does not report the version number of haskell98, it simply emits 'depends: haskell98' and ghc-pkg reports it as broken!

Using a version of franchise with a patch of mine to show some debugging output, we can see this is the problem:

$ runghc Setup.hs configure
Configuring...
"\nDistribution/Franchise/ConfigureState.hs:66:7:\n    Could not find module `Maybe':\n      it is a member of package haskell98, which is hidden\n"
adding ["haskell98"]
"\nDistribution/Franchise/ConfigureState.hs:63:7:\n    Could not find module `System.Console.GetOpt':\n      it is a member of package base-3.0.3.0, which is hidden\n"
adding ["base-3.0.3.0"]
"\nDistribution/Franchise/ConfigureState.hs:60:7:\n    Could not find module `System.Directory':\n      it is a member of package directory-1.0.0.2, which is hidden\n"
adding ["directory-1.0.0.2"]
"\nDistribution/Franchise/Util.hs:46:7:\n    Could not find module `System.Process':\n      it is a member of package process-1.0.1.0, which is hidden\n"
adding ["process-1.0.1.0"]
Added packages haskell98 base-3.0.3.0 directory-1.0.0.2 process-1.0.1.0...
Configure successful.

Change History (9)

comment:1 Changed 6 years ago by thoughtpolice

I'll also mention that while this happens, we will likely have to resort to simply checking if there is no version tag, and if not, checking ghc-pkg output and finding the proper package version to use and emit that the configuration file we register with ghc-pkg.

It also means that until we implement this or this gets fixed, any library built with franchise that depends on haskell98 will be reported as broken by ghc-pkg (although it really probably isn't, and ghc-pkg check will be of no help.)

comment:2 Changed 6 years ago by duncan

Parsing ghc's error messages seems like a "Bad Idea"tm.

A better approach would be to steal the code out of hmake and chase import dependencies then use the information from ghc-pkg dump to map that back to package names.

I wonder how the package is actually getting registered at all. I thought that it was no longer possible to register packages with unversioned dependencies. See ticket #1837. What's going on?

comment:3 follow-up: Changed 6 years ago by thoughtpolice

Duncan,

Me and David are thinking about some ways in which we can solve the problem, since right now that particular part of the configuration code is a little weak. It works fine for right now, but of course we'll likely go with something more robust in the future.

Also, I can confirm a package with unversioned dependencies can be registered (for any dependency) with 'ghc-pkg register' without --force or any error output on the 6.10 RC1, so I'm not sure what's going on either.

(P.S. this also occurs with the ghc-prim package on 6.10.)

comment:4 in reply to: ↑ 3 Changed 6 years ago by duncan

Replying to thoughtpolice:

Also, I can confirm a package with unversioned dependencies can be registered (for any dependency) with 'ghc-pkg register' without --force or any error output on the 6.10 RC1, so I'm not sure what's going on either.

Ok, I've reopened ticket #1837.

comment:5 Changed 6 years ago by droundy

  • Cc daveroundy@… added

comment:6 Changed 6 years ago by droundy

  • Cc droundy@… added; daveroundy@… removed

comment:7 Changed 6 years ago by simonmar

  • Difficulty set to Unknown
  • Milestone set to _|_
  • Summary changed from ghc does not report haskell98's version number. to ghc discards version of wired-in packages

This will happen for any of the "wired-in" packages. The current list of wired-in packages is

ghc-prim
integer
base (the new one, not base-3.0.3.0)
rts
haskell98
syb
template-haskell
dph-seq
dph-par

For these, we internally use unversioned package Ids, because GHC needs to refer to entities in these packages without knowing their version numbers.

So I agree that technically the error message is wrong, but it's not easy to fix because we've thrown away the version information about these packages.

I agree with Duncan that parsing these error message to figure out which packages to enable is a bad idea. For instance, it told you about "base-3.0.3.0", when you probably wanted "base-4.0.0.0".

comment:8 Changed 6 years ago by claus

Does this help?

$ cat x.hs
module Main where
import System
import Prelude

main = do p <- getProgName
          putStrLn $ "program name is " ++ p

$ ghc -e ":set -v" -e ":show packages" x.hs
wired-in package base mapped to base-3.0.2.0
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0.1.0
wired-in package template-haskell mapped to template-haskell-2.2.0.0
wired-in package ndp not found.
active package flags: none
packages currently loaded:
  base
  rts

comment:9 Changed 16 months ago by thoughtpolice

  • Resolution set to wontfix
  • Status changed from new to closed
  • Type of failure set to None/Unknown

This bug is old, will probably never be fixed and is a bad idea in hindsight. Closing.

Note: See TracTickets for help on using tickets.