Re: Ghci dynamic linking (Was: C++ libraries and GHCI)
I've encountered the problem with weak symbols also, and filed a bug report against ghc (#). Weak symbols are used by gcc (with elf) to accommodate C++'s compilation model. In C++, it's permitted to define class methods and template code in header files. Because header files can be included in many source files, the same object code will appear in many object files. It's the linker's job to merge these definitions. There's no standard way of handling C++ linking, unfortunately, so handling weak symbols won't necessarily solve the problem for every compiler. If there will be no cross-references involving weak symbols between different .a files, such as when you have a C++ library that doesn't depend on other C++ libraries, then it should be sufficient to treat a weak defined symbol as 'defined' and a weak undefined symbol as NULL. However, I don't know if this is really a common case; most C++ code depends on libstdc++, in which case there may be multiple weak symbol definitions. --heatsink Thanks for the reply, Max. If it's not something overly complex, I'll try to hack ghc to see if I can produce a working patch... probably that symbol type can be safely ignored by ghci linker. Thanks again for your help Paolo On Wed, Sep 30, 2009 at 2:29 PM, Max Bolingbroke batterseapo...@hotmail.com wrote: (Moving to ghc-users) I'd never seen V in nm output before: The symbol is a weak object. When a weak defined symbol is linked with a normal defined symbol, the normal defined symbol is used with no error. When a weak undefined symbol is linked and the symbol is not defined, the value of the weak symbol becomes zero with no error. On some systems, uppercase indicates that a default value has been specified. _ Hotmail: Trusted email with powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141665/direct/01/___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Ghci dynamic linking (Was: C++ libraries and GHCI)
Thanks for the reply, Max. If it's not something overly complex, I'll try to hack ghc to see if I can produce a working patch... probably that symbol type can be safely ignored by ghci linker. Thanks again for your help Paolo On Wed, Sep 30, 2009 at 2:29 PM, Max Bolingbroke batterseapo...@hotmail.com wrote: (Moving to ghc-users) I'd never seen V in nm output before: The symbol is a weak object. When a weak defined symbol is linked with a normal defined symbol, the normal defined symbol is used with no error. When a weak undefined symbol is linked and the symbol is not defined, the value of the weak symbol becomes zero with no error. On some systems, uppercase indicates that a default value has been specified. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Ghci dynamic linking (Was: C++ libraries and GHCI)
(Moving to ghc-users) I'd never seen V in nm output before: The symbol is a weak object. When a weak defined symbol is linked with a normal defined symbol, the normal defined symbol is used with no error. When a weak undefined symbol is linked and the symbol is not defined, the value of the weak symbol becomes zero with no error. On some systems, uppercase indicates that a default value has been specified. Perhaps support needs to be added for this symbol type to the GHCi dynamic linker? (It would work in compiled programs b/c we call down to the system static linker in that case). Cheers, Max 2009/9/29 Paolo Losi paolo.l...@gmail.com: Hi all, I would really appreciate if anyone could give a look to the following problem. Thanks in advance!!! Paolo -- Forwarded message -- From: Paolo Losi paolo.l...@gmail.com Date: Mon, Sep 14, 2009 at 10:33 AM Subject: C++ libraries and GHCI To: glasgow-haskell-users@haskell.org Hi all, I'm working on a tentative implementation of haskell binding to libsvm [1]: http://hackage.haskell.org/package/HSvm The package includes libsvm C++ sources. While it works perfectly with ghc --make (try to install the package and compile http://bitbucket.org/pao/hsvm/raw/6cf7ca91f1e5/test/test.hs), it fails with ghci: (hsvm)(env)pa...@moltrasio:~/trash$ ghci test.hs GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Ok, modules loaded: Main. Prelude Main main Loading package syb ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package containers-0.2.0.1 ... linking ... done. Loading package HSvm-0.1.0.2.89 ... linking ... interactive: /home/paolo/trash/hsvm/lib/HSvm-0.1.0.2.89/ghc-6.10.4/HSHSvm-0.1.0.2.89.o: unknown symbol `_ZTV6Kernel' ghc: unable to load package `HSvm-0.1.0.2.89' Please note that the symbol is available in libHSHSvm-0.1.0.2.89.a $ nm HSHSvm-0.1.0.2.89.o |grep _ZTV6Kernel V _ZTV6Kernel $ nm libHSHSvm-0.1.0.2.89.a |grep _ZTV6Kernel V _ZTV6Kernel Can anyone give a look to the problem? Thanks Paolo [1] http://www.csie.ntu.edu.tw/~cjlin/libsvm/ -- Paolo Losi e-mail: pa...@enuan.com mob: +39 348 7705261 ENUAN Srl Via XX Settembre, 12 - 29100 Piacenza ___ Haskell-Cafe mailing list haskell-c...@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users