logo       

`panic' with packages: msg#00078

lang.haskell.glasgow.bugs

Subject: `panic' with packages

Dear GHC team,

In my previous letter I wrote about a bug-like message in
cvs ghc-6-2-branch of May 24

(the fragments of this letter are appended).

And in this situation GHC also responds badly if the user forgets
to include a package.

> cd foo
foo> ghci $pcpfoo $pcpdocon

performs correct.

And if the user forgets to include the package docon, then it
happens
foo> ghci $pcpfoo

Loading package foo ... linking ...
/home/mechvel/t/u/lib/HSfoo.o: unknown symbol `__stginit_Prelude_'
ghc-6.2.1: panic! (the `impossible' happened, GHC version 6.2.1):
can't load package `foo'
Please report it as a compiler bug to glasgow-haskell-bugs@xxxxxxxxxxx,
or http://sourceforge.net/projects/ghc/.

The package foo refers to something which is not loaded/included.
Probably, istead of writing about a bug it should report
"
/home/mechvel/t/u/lib/HSfoo.o: unknown symbol `__stginit_Prelude_'
Possible reason: some library or package is forgotten.
"


-----------------
Serge Mechveliani
mechvel@xxxxxxxx




--------------------------------------------------------------
Having docon-2.08-pre, build it under -O as install.txt
specifies.

And I write in DoCon Manual how to organize a package for the user
example program which links DoCon library and package.

1.
After installing DoCon, set the variables
setenv doconc ".../docon/source/docon.conf"
setenv pcdocon "-package-conf ${doconc}"
setenv pcpdocon "${pcdocon} -package docon"
2.
Design Makefile for creating a user package foo
by compiling the modules
u/Root.hs
u/subdir/M.hs
and putting the interfaces and libraries to the directory u/lib/
...
------------------------------------------------------------------
module Root where -- in file u/Root.hs

import DExport -- imports all entities of DoCon and many of GHC
import M (m) -- of the user project

f = (m,m)

intRoot :: Z -> Maybe Z
intRoot n = let (ps,exps) = unzip $ factor n
in
if any (not . even) exps then Nothing
else
let halfs = map (`quot` 2) exps
in
Just $ product $ zipWith power ps halfs

------------------------------------------------------------------
module M where m = True -- file u/subdir/M.hs
------------------------------------------------------------------


-- The Makefile in the directory u/ should be ------------------

ghcBinDir = /home/mechvel/ghcCVS/inst/bin
...
doconc = /home/mechvel/docon/2.08/docon/source/docon.conf
s = /home/mechvel/t/u
e = $(s)/lib

ghc = $(ghcBinDir)/ghc
ghcpkg = $(ghcBinDir)/ghc-pkg

pcdocon = -package-conf $(doconc)
pcpdocon = $(pcdocon) -package docon

RANLIB = ar -s
language = -fglasgow-exts ...
warnings = -fno-warn-overlapping-patterns ...
idirs = subdir
HCFlags = $(language) $(warnings) \
-i$(idirs) -odir $(e) -hidir $(e) -ddump-hi-diffs \
+RTS $(space) -RTS $(extraHCOpts)
space = -M55m
extraHCOpts =

pack = Package {name = "\"foo\"", \
import_dirs = ["\"$(e)\""], \
source_dirs = [], \
library_dirs = ["\"$(e)\""], \
hs_libraries = ["\"HSfoo\""], \
extra_libraries = [], \
include_dirs = [], \
c_includes = [], \
package_deps = [], \
extra_ghc_opts = [$(extraPackOpts)], \
extra_cc_opts = [], \
extra_ld_opts = [] }

extraPackOpts = $(pwarnings), $(planguage)

planguage = "\"-fglasgow-exts\"", ...
pwarnings = "\"-fno-warn-overlapping-patterns\"", ...

obj:
if [ ! -d $(e) ]; then mkdir $(e); fi
$(ghc) $(HCFlags) $(pcpdocon) --make Root -package-name foo

foo: obj
rm -f $(e)/libHSfoo.a $(e)/HSfoo.o
ar -qc $(e)/libHSfoo.a $(wildcard $(e)/*.o)
$(RANLIB) $(e)/libHSfoo.a
echo $(pack) | $(ghcpkg) -f $(s)/foo.conf -u -g
$(ghcpkg) -f $(s)/foo.conf -l

clear:
$(ghcpkg) -f $(s)/foo.conf -r foo
rm -f $(s)/foo.conf.old
rm -rf $(e)
--------------------------------------------------------------------
...

Making foo: cd .../u; make foo

Similarly as for DoCon package, arrange the variables

setenv fooc "/home/mechvel/t/u/foo.conf"
setenv pcfoo "-package-conf ${fooc}"
setenv pcpfoo "${pcfoo} -package foo"

To run intRoot from the separate directory, say foo, command

cd .../foo
ghci $pcpfoo $pcpdocon

Loading package base ... linking ... done.
...
Loading package docon ... linking ... done.
Loading package foo ... linking ... done.

Prelude> Root.intRoot 16
Just 4
...
------------------------------------------------------------


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise