Opened 11 years ago

Closed 11 years ago

Last modified 7 years ago

#766 closed bug (fixed)

GHC 6.4.2 won't build on Mac OS X

Reported by: guest Owned by:
Priority: normal Milestone: 6.4.3
Component: Compiler Version: 6.4.2
Keywords: Cc:
Operating System: MacOS X Architecture: powerpc
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Problem I'm running Mac OS X Tiger (10.4.6) and trying to build GHC 6.4.2 (using GCC 4.0.1 and GHC 6.4.1) and I'm ran into a problem where certain constants (e.g., UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END) are not found, causing compilation to stop. The same issue occurred for at least one other user with GHC 6.5; unfortunately, I can't find the post again.

Solution? Tiger ships with a NetBSD partial version of the readline library in /usr. Unfortunately, this file lacks a lot of the functionality in the GNU readline and is not compatible enough.

To get around this: # Download and decompress the GNU readline library, v5.1 tarball (other version may work) # cd <readline source dir> # ./configure # make # sudo make install #Installs to /usr/lib/include and /usr/lib/bin # cd <GHC source dir> # export LDFLAGS=-L/usr/local/lib # tell linker to use GNU version of readline # export CPPFLAGS=-I/usr/local/include # tell compiler to use GNU version of readline # ./configure --disable-openal --disable-alut # Audio disabled because of unrealted bug # make # sudo make install

This should do it. Steps 7 and 8 could cause problems because the compile will look for ALL libraries in /usr/local before looking in /usr.

The compilation is successful and ghc and ghci run; however, Unfortunately, I won't be able to test the results for some time.

Follow-Up? It should be possible to detect the lack of readline through the configure process. The NetBSD bad readline.h file results in the following statements: <pre> checking for rl_erase_empty_line in -lreadline... no checking for rl_free_undo_list in -lreadline... no </pre>

The GNU readline 5.1 library results in the following statements: <pre> checking for rl_erase_empty_line in -lreadline... yes checking for rl_free_undo_list in -lreadline... yes </pre>

It may be possible to create a test in the configure file by looking at the platform and these two functions. Also, the platform-specific documentation could be updated.

Attachments (1) (1.1 KB) - added by gwright@… 11 years ago.
patch for libraries/readline/ (resolves ticket #766)

Download all attachments as: .zip

Change History (6)

comment:1 Changed 11 years ago by simonmar

Milestone: 6.4.3

Changed 11 years ago by gwright@…

Attachment: added

patch for libraries/readline/ (resolves ticket #766)

comment:2 Changed 11 years ago by gwright@…

Below is a patch that fixes the problem. It relies on the real readline defining the function rl_readline_version, which is not defined by libedit.

BTW, the bug is not that OS X's readline is broken --- OS X doesn't come with readline -- but that there is a symbolic link from /usr/lib/libreadline.dylib to /usr/lib/libedit.dylib. Libedit is an independently developed subset of readline, released under a BSD license. The evil symlink trips up anything that depends on having the real GNU readline.

--- libraries/readline/ 2006-07-05 13:41:54.000000000 -0400
+++ libraries/readline/     2006-07-05 13:09:45.000000000 -0400
@@ -41,7 +41,12 @@
   AC_CHECK_LIB(readline, readline, HaveLibReadline=YES, HaveLibReadline=NO)
-if test $HaveLibTermcap = YES && test x"$HaveLibReadline" = xYES ; then
+dnl ** is our readline really readline, or is it BSD's libedit?
+if test x"$HaveLibReadline" = xYES ; then
+  AC_CHECK_LIB(readline, rl_readline_version, ReadlineIsLibedit=NO, ReadlineIsLibedit=YES)
+if test $HaveLibTermcap = YES && test x"$HaveLibReadline" = xYES && test x"$ReadlineIsLibedit" = xNO ; then
   READLINE_LIBS="readline $LibTermcap"
@@ -50,7 +55,7 @@
-if test "$HaveLibReadline"; then
+if test x"$HaveLibReadline" = xYES && test x"$ReadlineIsLibedit" = xNO ; then
   AC_CHECK_LIB(readline, rl_erase_empty_line,
     [AC_DEFINE([HAVE_READLINE_4], [1], [Define to 1 if readline has version >= 4.0.])],
     [AC_DEFINE([HAVE_READLINE_4], [0], [Define to 1 if readline has version >= 4.0.])])

comment:3 Changed 11 years ago by guest

difficulty: UnknownEasy (1 hr)
severity: blockernormal

I neglected to mention in the previous comment that the fix was tested successfully on HEAD, checked out today (5 July 2006).

comment:4 Changed 11 years ago by simonmar

Resolution: fixed
Status: newclosed

Committed; thanks.

comment:5 Changed 7 years ago by simonmar

difficulty: Easy (1 hr)Easy (less than 1 hour)
Note: See TracTickets for help on using tickets.