Please, what is the matter with the packages in ghc-6.0.1 ?
(ghc-6.0.1
installed from RPM on Red Hat Linux release 7.3 (Valhalla),
i-386 unknown
)
It does not find the library items, say List.sort,
when it `makes' under the user package in the user project
importing standard library.
This package is called docon, and it is for a contrived project
of a single small module.
Similarly, ghci -package-conf docon.conf
reports
Loading package docon ... linking ...
/home/mechvel/test/export/HSdocon.o: unknown symbol `__stginit_List_'
ghc-6.0.1: panic! (the `impossible' happened, GHC version 6.0.1):
can't load package `docon'
Please report it as a compiler bug to [EMAIL PROTECTED],
or http://sourceforge.net/projects/ghc/.
Either it loads the packages of GHC itself, or, if it deals with
the user package, the packages of GHC are somehow blocked out.
When the user project does not import List and the such, then
ghc --make -package-conf docon.conf
works
but ghci -package-conf docon.conf
still does not (probably, it still needs to load some ghc packages).
The user package is
Package {name = "docon",
import_dirs = [$e],
source_dirs = [],
library_dirs = [$e],
hs_libraries = ["HSdocon"],
extra_libraries = [],
include_dirs = [],
c_includes = [],
package_deps = [],
extra_ghc_opts = [],
extra_cc_opts = [],
extra_ld_opts = []
}
, $e is the the path to user package .hi, .o, and library directory.
I struggled with it for two days.
Then, occasionally, tried to set package_deps = ["data"]
, even though my contrived user package does not use "data".
And it started to work, to load everything needed!
Then I try package_deps = ["base"]
And here ghci -package-conf docon.conf
reports again the `panic'.
Here follows the precise data.
The file Head.hs in the `root' directory $(s) contains
module Head where import List (sort)
f = sort [1,2] :: [Int]
The file Makefile in the same directory is for creating the
package and `making' the project. So that the command
make docon
does the following in succession.
* creates a directory $(e) = $(s)/export
* makes a project by
$(ghc) $(HCFlags) --make Head -package-name docon
* creates the libraries $(e)/libHSdocon.a $(e)/HSdocon.o
with ar and ld
* creates a package docon referring to these libraries:
echo $(pack) | ghc-pkg -f $(s)/docon.conf -u
,
where $(pack) is a string for the package which Makefile sets
earlier.
The command make clear is for un-doing of all this.
Here is the precise Makefile:
----------------------------------------------------------------
ghc = /usr/bin/ghc
# edit these two ***
s = /home/mechvel/test
e = $(s)/export
RANLIB = ar -s
HCFlags = -odir $(e) -hidir $(e)
pack = Package {name = "\"docon\"", \
import_dirs = ["\"$(e)\""], \
source_dirs = [], \
library_dirs = ["\"$(e)\""], \
hs_libraries = ["\"HSdocon\""], \
extra_libraries = [], \
include_dirs = [], \
c_includes = [], \
package_deps = [], \
extra_ghc_opts = [], \
extra_cc_opts = [], \
extra_ld_opts = [] }
obj:
if [ ! -d $(e) ]; then mkdir $(e); fi
$(ghc) $(HCFlags) --make Head -package-name docon
docon: obj
rm -f $(e)/libHSdocon.a $(e)/HSdocon.o
ar -qc $(e)/libHSdocon.a $(wildcard $(e)/*.o)
$(RANLIB) $(e)/libHSdocon.a
ld -r -x --whole-archive $(e)/libHSdocon.a -o $(e)/HSdocon.o
ghc-pkg -f $(s)/docon.conf -l
echo $(pack) | ghc-pkg -f $(s)/docon.conf -u
ghc-pkg -f $(s)/docon.conf -l
clear:
ghc-pkg -f $(s)/docon.conf -r docon
rm -f $(s)/docon.conf.old
rm -rf $(e)
rm -f $(s)/log
----------------------------------------------------------------
To exclude the List library, comment out the line `import ..'
and replace the line `f = ...' with `f = True'.
Question on ghc-pkg -g
=======================
User guide for packages does not explain this precisely.
I suspect that
ghc-pkg -g
may help to replace the messy line
ld -r -x --whole-archive $(e)/libHSdocon.a -o $(e)/HSdocon.o
in the above Makefile, but cannot guess how to use here this
ghc-pkg -g.
Is it clear from the guide paragraph
4.10.4 ... `--auto-ghci-libs, -g'
?
Answer, please, to [EMAIL PROTECTED]
With kind regards,
-----------------
Serge Mechveliani
[EMAIL PROTECTED]
_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs