Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#4068 closed bug (invalid)

GHC 6.12.2 on Mac OS X from GHC-6.12.2-i386.pkg fails with "Undefined symbols: "_iconv_close", referenced from: _hs_iconv_close in libHSbase-4.2.0.1.a(iconv.o) ..."

Reported by: thorkilnaur Owned by:
Priority: high Milestone: 6.12.3
Component: Compiler Version: 6.12.2
Keywords: Cc:
Operating System: MacOS X Architecture: x86
Type of failure: Compile-time crash Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

With

$ uname -a
Darwin thorkil-naurs-intel-mac-mini.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.2
$

installed from http://haskell.org/ghc/dist/6.12.2/GHC-6.12.2-i386.pkg:

$ cat t1.hs 
import System.IO
main
  = putStrLn "Hello GHC-6.12.2 2010-May-13 13.30"
$ ghc --make t1.hs
[1 of 1] Compiling Main             ( t1.hs, t1.o )
Linking t1 ...
Undefined symbols:
  "_iconv_close", referenced from:
      _hs_iconv_close in libHSbase-4.2.0.1.a(iconv.o)
  "_iconv", referenced from:
      _hs_iconv in libHSbase-4.2.0.1.a(iconv.o)
  "_iconv_open", referenced from:
      _hs_iconv_open in libHSbase-4.2.0.1.a(iconv.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
$ 

Looking at the installed libiconv:

$ nm /opt/local/lib/libiconv.a | grep iconv
/opt/local/lib/libiconv.a(iconv.o):
00018c60 D __libiconv_version
00018920 T _iconv_canonicalize
00015f20 T _libiconv
00015f80 T _libiconv_close
00017930 T _libiconv_open
00018150 T _libiconv_open_into
00015fa0 T _libiconvctl
000161e0 T _libiconvlist
/opt/local/lib/libiconv.a(localcharset.o):
/opt/local/lib/libiconv.a(relocatable.o):
000000f0 T _libiconv_relocate
00000000 T _libiconv_set_relocation_prefix
$ 

Further, in /opt/local/include/iconv.h:

#ifndef LIBICONV_PLUG
#define iconv_open libiconv_open
#endif
extern iconv_t iconv_open (const char* tocode, const char* fromcode);

So there is some trickery going on with respect to the names of functions from libiconv, but it is not clear to me how to resolve this.

Best regards
Thorkil

Change History (9)

comment:1 Changed 4 years ago by thorkilnaur

Building a fresh GHC 6.12.2 from http://haskell.org/ghc/dist/6.12.2/ghc-6.12.2-src.tar.bz2, found:

$ nm /Users/thorkilnaur/tn/GHC/unpack/ghc-6.12.2/libraries/base/dist-install/build/libHSbase-4.2.0.1.a 2>&1 | grep iconv
...
/Users/thorkilnaur/tn/GHC/unpack/ghc-6.12.2/libraries/base/dist-install/build/libHSbase-4.2.0.1.a(iconv.o):
00000010 T _hs_iconv
00000020 T _hs_iconv_close
00000000 T _hs_iconv_open
         U _libiconv
         U _libiconv_close
         U _libiconv_open
$

As opposed to the result for the GHC 6.12.2 from http://haskell.org/ghc/dist/6.12.2/GHC-6.12.2-i386.pkg:

$ nm /Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.2/base-4.2.0.1/libHSbase-4.2.0.1.a 2>&1 | grep iconv
...
/Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.2/base-4.2.0.1/libHSbase-4.2.0.1.a(iconv.o):
00000010 T _hs_iconv
00000020 T _hs_iconv_close
00000000 T _hs_iconv_open
         U _iconv
         U _iconv_close
         U _iconv_open
$

Using the freshly built version of the library, the problem disappears.

Best regards
Thorkil

comment:2 Changed 4 years ago by igloo

  • Milestone set to 6.12.3
  • Priority changed from normal to high

I suspect this is a mismatch between the library the installer was compiled against, and the one it is being used with:

ian-lynaghs-macbook-pro:~ ian$ nm /usr/lib/libiconv.dylib | grep iconv_close
0000b8e8 T _iconv_close
0000fe45 T _libiconv_close
ian-lynaghs-macbook-pro:~ ian$ nm /opt/local/lib/libiconv.dylib | grep iconv_close
00016d40 T _libiconv_close

comment:3 Changed 4 years ago by thorkilnaur

Thanks, Ian. I had overlooked /usr/lib/libiconv.*. So I tried to port deactivate libiconv the MacPorts version of this library (/opt/local/lib/libiconv.*), and then the problem likewise disappeared.

I'll leave the ticket open for you to handle as you wish: From my perspective, there is nothing further to do.

Best regards
Thorkil

comment:4 Changed 4 years ago by igloo

  • Owner set to igloo

comment:5 Changed 4 years ago by igloo

  • Resolution set to invalid
  • Status changed from new to closed

I'm not sure there's anything we can do here, so I'm closing the ticket. If anyone has any suggestions on how we can improve the situation, please reopen it.

comment:6 Changed 3 years ago by maeder

an easy solution is to add "-L/usr/lib" to ghc's command line see
http://www.mail-archive.com/glasgow-haskell-users@haskell.org/msg18950.html

comment:7 Changed 3 years ago by maeder

  • Owner igloo deleted
  • Resolution invalid deleted
  • Status changed from closed to new

I reopen this ticket. Having no idea how to fix it is no reason to close on open issue. In the above thread Lato points out that it is impossible to link against two different libiconvs. So let's at least discuss (document) the situation here.

comment:8 Changed 3 years ago by igloo

  • Resolution set to invalid
  • Status changed from new to closed

As far as I can see, this is not a GHC bug. The problem is that code is getting compiled against one iconv library, but then linked against another (incompatible) iconv library.

comment:9 Changed 3 years ago by maeder

  • Type of failure changed from Other to Compile-time crash

Yet, why is iconv listed at all under "extra-libraries:" for the base package on Macs but not under linux? I suppose the bits of base using iconv could be linked statically into libHSbase-4.2.0.x.a

Note: See TracTickets for help on using tickets.