[Bug 273091] lang/ghc 9.4.6 fails to build without the addition of iconv configure flags

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 13 Aug 2023 00:00:13 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273091

            Bug ID: 273091
           Summary: lang/ghc 9.4.6 fails to build without the addition of
                    iconv configure flags
           Product: Ports & Packages
           Version: Latest
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: haskell@FreeBSD.org
          Reporter: kreinholz@gmail.com
             Flags: maintainer-feedback?(haskell@FreeBSD.org)
          Assignee: haskell@FreeBSD.org

OS: FreeBSD 13.2-STABLE stable/13-bc50720b32 GENERIC amd64

What: attempted to build lang/ghc-9.4.6 from Ports with default `make config`
options

Expected result: successful build of ghc

Actual result: build fails at the stage1 bootstrap phase with the following
error message:

# cabal-configure (for _build/stage1/libraries/base/setup-config)
configure: error: iconv is required on non-Windows platforms
ExitFailure 1
Build failed.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/lang/ghc
*** Error code 1

/usr/ports/lang/ghc/work/ghc-9.4.6/_build/stage1/libraries/base/build/config.log
reveals:

configure:32566: checking for library containing iconv
configure:32597: /usr/local/bin/gcc -o conftest -iquote
/usr/ports/lang/ghc/work
/ghc-9.4.6/libraries/base  -fuse-ld=gold conftest.c -lrt  >&5
/tmp//cccRZgTs.o:conftest.c:function main: error: undefined reference to
'libico
nv_open'
/tmp//cccRZgTs.o:conftest.c:function main: error: undefined reference to
'libico
nv'
/tmp//cccRZgTs.o:conftest.c:function main: error: undefined reference to
'libico
nv_close'
collect2: error: ld returned 1 exit status
configure:32597: $? = 1
configure: failed program was:
| /* confdefs.h */

And:

configure:32597: /usr/local/bin/gcc -o conftest -iquote
/usr/ports/lang/ghc/work
/ghc-9.4.6/libraries/base  -fuse-ld=gold conftest.c -liconv  -lrt  >&5
/usr/local/bin/ld.gold: error: cannot find -liconv
/tmp//ccp8G3Is.o:conftest.c:function main: error: undefined reference to
'libico
nv_open'
/tmp//ccp8G3Is.o:conftest.c:function main: error: undefined reference to
'libico
nv'
/tmp//ccp8G3Is.o:conftest.c:function main: error: undefined reference to
'libico
nv_close'
collect2: error: ld returned 1 exit status

On my system, iconv headers and libs are installed to the standard location,
/usr/local. However, for some reason ghc's configure script fails to look for
them there. This may be similar to a problem noted by Mac OS X users attempting
to build ghc when two different versions of iconv exist on their systems,
installed in different locations.

The fix/workaround is easy: edit the Makefile and add appropriate iconv-related
configure flags:

GNU_CONFIGURE=          yes
CONFIGURE_ARGS+=        --docdir=${DOCSDIR}
--with-iconv-libraries=${LOCALBASE}/lib
--with-iconv-includes=${LOCALBASE}/include
CONFIGURE_ENV=          ALEX=/usr/bin/true HAPPY=/usr/bin/true
INSTALL_TARGET=         install-strip

After this, ghc has no problem finding iconv and the build progresses past this
error.

I thought I'd share this information in case anyone else is having difficulty
building ghc-9.4.6 or to suggest a tweak to the Makefile.

-- 
You are receiving this mail because:
You are the assignee for the bug.