Skip to content

some libraries work with runghc but not ghc

Symptom:

Code using some libraries (e.g. array, complex, list) works interpretted (runghc) and compiled (ghc). Code using some other libraries (e.g. graph, intset, map, set, tree) works interpretted, but has undefined symbols when compiled with ghc.

ghc and platform are installed on a mac mini running snow leopard from haskell-platform-2009.2.0.2-i386.dmg.

-optc-m32 -opta-m32 -optl-m32 are inserted into /Library/Frameworks/GHC.framework/Versions/Current/usr/bin/ghc-6.10.4.

Example working:

cat testarray.hs

import Data.Array main :: IO () main = do putStrLn $ show $ array (1,3) [(1,"one"),(2,"two"),(3,"three")]

runghc testarray.hs

array (1,3) [(1,"one"),(2,"two"),(3,"three")]

ghc testarray.hs

  1. /a.out

array (1,3) [(1,"one"),(2,"two"),(3,"three")]

Example failure:

cat testset.hs

import Data.Set as Set main :: IO () main = do putStrLn $ show $ Set.fromList [3..5]

runghc testset.hs

fromList [3,4,5]

ghc testset.hs

Undefined symbols:

"_containerszm0zi2zi0zi1_DataziSet_fromList_closure", referenced from:

_rBM_info in testset.o

_rBM_srt in testset.o

"_containerszm0zi2zi0zi1_DataziSet_zdf3_closure", referenced from:

_rBK_info in testset.o

_rBK_srt in testset.o

"__stginit_containerszm0zi2zi0zi1_DataziSet", referenced from:

__stginit_Main in testset.o

ld: symbol(s) not found collect2: ld returned 1 exit status

Some other info:

ghc -v shows it loading these libraries:

-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/array-0.2.0.0 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/base-4.1.0.0 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/directory-1.0.0.3 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/filepath-1.1.0.2 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/ghc-prim-0.1.0.0 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/haskell98-1.0.1.0 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/integer-0.1.0.1 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/old-locale-1.0.0.1 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/old-time-1.0.0.2 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/process-1.0.1.1 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/random-1.0.0.1 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/syb-0.1.0.1 -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/unix-2.3.2.0

Now we're getting outside my area of expertise...

It looks to me like the working libraries are in array and base, which ARE loaded by ghc, and the failing libraries are in /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/containers-0.2.0.1 which is NOT loaded by ghc.

I tried to work around it with ghc -L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/containers-0.2.0.1 testset.hs and it did NOT work.

It looks to me like all the .a files contain code for the correct architecture.

Trac metadata
Trac field Value
Version 6.10.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information