Version 16 (modified by kirsten, 11 years ago) (diff)


Building GHC on Mac OS X 10.2 in 80 Easy Steps, by Kirsten aged 26 1/52

  1. grab the HEAD off darcs, per Building/GettingTheSources (no problems here)
  2. run autoreconf (this went ok, because I had just upgraded my autoconf in order to build darcs)
  3. run ./configure
  4. oops, I only have happy 1.13, it wants happy 1.15
  5. go to the happy download page. what, no Mac OS X binary?
  6. grab the happy sources
  7. ./configure, make, make install. so far so good
  8. ./configure GHC again
  9. LOL, I need alex 2.0
  10. why isn't this integrated into the GHC build process? also, googling for just "alex" is un-useful. so is googling for "alex lexer" and "alex lexer haskell"
  11. LOL, *still* no Mac OS X binary.
  12. ./configure; make in alex
  13. have disgusting IM conversation with friend while waiting
  14. alex: "you lose at life":
    Creating a symbolic link from alex-2.0.1 to alex in /usr/local/bin failed: `/usr/local/bin/alex' already exists
    Perhaps remove `/usr/local/bin/alex' manually?
    make[2]: *** [install] Error 1
    make[1]: *** [install] Error 1
    make: *** [install] Error 1
  15. consider a career change
  16. rm /usr/local/bin/alex
  17. sudo rm /usr/local/bin/alex
  18. sudo make me a sandwich
  19. sudo make install
  20. okay, I have alex. yippee.
  21. ./configure in GHC again
  22. seems to have worked. With trembling fingers (or maybe that's just the freezing Southern California weather), type "make".
  23. OH NOEZ:
    gcc -O -DTABLES_NEXT_TO_CODE -I. -I../rts    -c mkDerivedConstants.c -o mkDerivedConstants.o
    InfoTables.h:314: illegal member declaration, missing name, found `}'
    OSThreads.h:135: #error "Threads not supported"
    OSThreads.h:141: undefined type, found `OSThreadId'
    OSThreads.h:145: illegal external declaration, missing `;' after `OSThreadProcAttr'
    OSThreads.h:145: illegal external declaration, missing `;' after `*'
    OSThreads.h:147: undefined type, found `OSThreadId'
    OSThreads.h:148: undefined type, found `OSThreadProc'
    OSThreads.h:153: undefined type, found `Condition'
    OSThreads.h:154: undefined type, found `Condition'
    OSThreads.h:155: undefined type, found `Condition'
    OSThreads.h:156: undefined type, found `Condition'
    OSThreads.h:157: undefined type, found `Condition'
    OSThreads.h:158: undefined type, found `Mutex'
    OSThreads.h:163: undefined type, found `Mutex'
    OSThreads.h:164: undefined type, found `Mutex'
    OSThreads.h:169: undefined type, found `ThreadLocalKey'
    OSThreads.h:170: undefined type, found `ThreadLocalKey'
    OSThreads.h:171: undefined type, found `ThreadLocalKey'
    Storage.h:211: undefined type, found `Mutex'
    Storage.h:212: undefined type, found `Mutex'
    ../rts/Task.h:88: undefined type, found `OSThreadId'
    ../rts/Task.h:115: undefined type, found `Condition'
    ../rts/Task.h:116: undefined type, found `Mutex'
    ../rts/Task.h:225: illegal function prototype, found `*'
    ../rts/Task.h:225: illegal function definition, found `)'
    ../rts/Task.h:235: undefined type, found `ThreadLocalKey'
    ../rts/Capability.h:74: undefined type, found `Mutex'
    ../rts/Capability.h:197: undefined type, found `Mutex'
    cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
    make[1]: *** [mkDerivedConstants.o] Error 1
    make: *** [stage1] Error 1
  24. Cry.
  25. Hmm, how old is my gcc, anyway?
    % gcc --version
    gcc (GCC) 3.1 20020420 (prerelease)
    Copyright (C) 2002 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [ yeah, no shit, Sherlock ]
  26. Will upgrading my gcc break everything? Probably. Should I do it anyway? Probably.
  27. Actually, upgrading gcc sounds about as appealing as a quadruple root canal. Maybe I can use gcc2 (2.95.2) instead.
  28. Aaaaargh, of course I'm not that lucky:
    checking for gcc... gcc2
    checking for C compiler default output file name... 
    configure: error: C compiler cannot create executables
  29. Start downloading tarball for newer gcc from: Also consider becoming religious so I can pray for it to be actually useful.
  30. Length: 31,674,171 [application/x-tar]
     2% [>                                    ] 895,686       14.36K/s    ETA 34:52
  31. Wish that parents-in-law would get the faster internets at their house.
  32. Eat breakfast.
  33. Installing gcc on a full stomach is probably better anyway (though quite possibly not). Unzip the tarball. Notice that INSTALL is a directory. That's already a bad sign.
  34. Hope that autoconf; ./configure; make; make install will just work, since I don't have the attention span for anything else.
  35. Run make.
  36. For some reason, the configure script thinks that my PPC laptop is an i386. ./configure doesn't do anything. Nor does ./configure --help.
  37. No, actually it thinks I want to build a cross-compiler. Why would I want that?
  38. Apparently the hosts to build for are controlled by the HOSTS environment variable, or maybe it's set somewhere in one of the config files. I'm not sure. Nor am I sure why I have the attention span to grovel through the sources but not to read the documentation.
  39. Try setenv HOSTS ppc
  40. make
  41. Still complains with the same message:
    * Building Apple GCC 3.3 Compiler(s) (languages = c++,c,objc,objc++) for thins *
    * ---------------------------------------------------------------------------- *
    * BUILDHOST       = Kirsten-Chevaliers-Computer.local. -- a ppc                *
    * HOSTS           = ppc  i386                                                  *
    * TARGETS         = ppc  i386                                                  *
    * SRCROOT         = /tmp/gcc3/gcc-1495                                         *
    * OBJROOT         = /tmp/gcc3/gcc-1495/obj                                     *
    * SYMROOT         = /tmp/gcc3/gcc-1495/obj/../sym                              *
    * DSTROOT         = /tmp/gcc3/gcc-1495/obj/../dst                              *
    * RC_RELEASE      =                                                            *
    * CFLAGS          = -g                                                         *
    * OPT_OVERRIDE    =                                                            *
    * NEXT_ROOT       =                                                            *
    * BUILD           = ppc                                                        *
    * BOOTSTRAP       = yes                                                        *
    * PREFIX          = /usr                                                       *
    * DO_SYMLINKS     = no                                                         *
    * ENABLE_CHECKING = --disable-checking                                         *
    * Default cc      =                                                            *
    * Curr. Hdrs.     = 3.1                                                        *
    * ---------------------------------------------------------------------------- *
    * 12/27/06 10:08:49 PST                                                        *
    ? The directory /usr/libexec/gcc/darwin/i386 is missing!!! ?
    ? Please install a compiler that generates code for i386.  ?
    make: *** [build] Error 1
  42. Try export HOSTS
  43. make
  44. Still complains.
  45. For the 65536th time in my life, consider destroying everything Turing-complete and then going out to enjoy the big room with the blue ceilings.
  46. Apparently you can also set the TARGETS environment variable. Try setting it to ppc also.
  47. ??????????????????????????????????????????
    ? Host type i386 should also be a target ?
  48. Well, maybe if I could also set the HOSTS to just ppc, that wouldn't be a problem.
  49. Use grep again (the only IDE I'll ever need) and figure out to edit the GNUmakefile to change the HOSTS = and targets = lines to obliterate any and all traces of i386. There's probably a better way. At this point I don't care.
  50. Start make again. It is, at least, convinced that it only wants to be building a ppc compiler, without any of that crazy i386 nonsense.
  51. Go back to bed.
  52. ...but not *yet*. The hell?
    + Building libiberty                     +
    + -------------------------------------- +
    + cwd = /tmp/gcc3/gcc-1495/obj/libiberty +
    + gnumake srcdir=/tmp/gcc3/gcc-1495/libiberty BUILD_PREFIX=ppc- BUILD_PREFIX_1=ppc- 'HOST_CC= cc -arch ppc -no-cpp-precomp' 'CFLA\
    GS= -g' 'GCC_CFLAGS=-no-cpp-precomp -g' 'BOOT_CFLAGS=-O2 -g -no-cpp-precomp -mdynamic-no-pic' 'CC=cc -arch ppc -arch ppc -no-cpp-\
    precomp -g'
    if [ x"" != x ] && [ ! -d pic ]; then \
      mkdir pic; \
    else true; fi
    touch stamp-picdir
    if [ x"" != x ]; then \
      cc -arch ppc -arch ppc -no-cpp-precomp -g -c -DHAVE_CONFIG_H -g -I. -I/tmp/gcc3/gcc-1495/libiberty/../include  -W -Wall -Wtradi\
    tional -pedantic  /tmp/gcc3/gcc-1495/libiberty/regex.c -o pic/regex.o; \
    else true; fi
    cc -arch ppc -arch ppc -no-cpp-precomp -g -c -DHAVE_CONFIG_H -g -I. -I/tmp/gcc3/gcc-1495/libiberty/../include  -W -Wall -Wtraditi\
    onal -pedantic /tmp/gcc3/gcc-1495/libiberty/regex.c -o regex.o
    gnumake[1]: cc: Command not found
    gnumake[1]: *** [regex.o] Error 127
    + status=2
    + command set +x
    + set +x
    * *** gnumake failed building libiberty *** *
  53. WTF is "libiberty"?
  54. Apparently, not only does it think it should be using cc instead of gcc (which are supposed to be the same anyway, no?), the PATH isn't getting exported correctly, because cc is certainly in /usr, which is in my PATH.
  55. Try setting the CC environment variable to {{{/usr/gcc}}.
  56. make. Doesn't work.
  57. make clean
  58. make. Doesn't work.
  59. Edit the makefile in the libiberty subdir: CC = gcc. Again, there's probably a better way...
  60. make. Doesn't work.
  61. make clean
  62. make. Really go back to bed.
  63. Decide for some reason to get back out of bed and leave the other warm body in it behind in order to start building gcc again. Consider whether I need psychological help.
  64. The problem is that it can't find cc in the PATH and although /usr, where cc is, SHOULD be in the PATH, it's not getting exported properly fsr.
  65. Create a symbolic link to /usr/cc in /usr/bin.
  66. Chainsaw, meet butter.
  67. make. libiberty makes it all the way through this time.
  68. NOW WHAT
    cc -arch ppc -no-cpp-precomp -g -c -no-cpp-precomp  -g -no-cpp-precomp -DHAVE_DESIGNATED_INITIALIZERS=0 -DIN_GCC   -W -Wall -Wwri\
    te-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long  -mdynamic-no-pic -DHAVE_CONFIG_H -DGE\
    NERATOR_FILE    -I. -I. -I/tmp/gcc3/gcc-1495/gcc -I/tmp/gcc3/gcc-1495/gcc/. -I/tmp/gcc3/gcc-1495/gcc/config -I/tmp/gcc3/gcc-1495/\
    gcc/../include -I/tmp/gcc3/gcc-1495/gcc/../more-hdrs \
      ./gengtype-lex.c -o gengtype-lex.o
    gengtype-lex.c:1: warning: ISO C forbids an empty source file
    cc -arch ppc -no-cpp-precomp -g -c -no-cpp-precomp  -g -no-cpp-precomp -DHAVE_DESIGNATED_INITIALIZERS=0 -DIN_GCC   -W -Wall -Wwri\
    te-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long  -mdynamic-no-pic -DHAVE_CONFIG_H -DGE\
    NERATOR_FILE    -I. -I. -I/tmp/gcc3/gcc-1495/gcc -I/tmp/gcc3/gcc-1495/gcc/. -I/tmp/gcc3/gcc-1495/gcc/config -I/tmp/gcc3/gcc-1495/\
    gcc/../include -I/tmp/gcc3/gcc-1495/gcc/../more-hdrs \
      ./gengtype-yacc.c -o gengtype-yacc.o
    cc: ./gengtype-yacc.c: No such file or directory
    cc: no input files
    gnumake[2]: *** [gengtype-yacc.o] Error 1
    gnumake[1]: *** [stage1_build] Error 2
    + status=2
    + command set +x
    + set +x
    * *** gnumake failed building compiler *** *
  69. Figure this is probably because I don't have bison and yacc installed. Consider the comical aptness of the term "yak-shaving" here.
  70. Wait a sec, I do have bison and yacc! They're under /usr! Why the hell are they under /usr, anyway, and why isn't /usr in my PATH? Actually, that was probably just because I unzipped a tarball in the wrong place at some point. I guess I'll just put them all in /usr/bin.
  71. make clean so configure can notice that bison and yacc and flex are there now. make
  72. (cd . && \
     bison  -d -o gengtype-yacc.c /tmp/gcc3/gcc-1495/gcc/gengtype-yacc.y || \
     ( rm -f gengtype-yacc.c && false ) )
    bison: /usr/share/bison.simple: No such file or directory
    gnumake[2]: *** [gengtype-yacc.c] Error 1
    gnumake[1]: *** [stage1_build] Error 2
    + status=2
    + command set +x
    + set +x
    * *** gnumake failed building compiler *** *
  73. WTH is bison.simple?
  74. Download bison.simple off the intorblags and put it in /usr/bin.
  75. Oh, it wants it to be in /usr/share. Well, sure, put it there too.
  76. It's missing another include file:
    In file included from /tmp/gcc3/gcc-1495/gcc/config/rs6000/host-darwin.c:25:
    /usr/include/sys/mman.h:62:39: mach/shared_memory_server.h: No such file or directory
    In file included from /tmp/gcc3/gcc-1495/gcc/config/rs6000/host-darwin.c:25:
    /usr/include/sys/mman.h:170: parse error before "sf_mapping_t"
    /usr/include/sys/mman.h:171: parse error before "sf_mapping_t"
    /tmp/gcc3/gcc-1495/gcc/config/rs6000/host-darwin.c: In function `segv_handler':
    /tmp/gcc3/gcc-1495/gcc/config/rs6000/host-darwin.c:66: dereferencing pointer to incomplete type
    /tmp/gcc3/gcc-1495/gcc/config/rs6000/host-darwin.c:115: dereferencing pointer to incomplete type
    /tmp/gcc3/gcc-1495/gcc/config/rs6000/host-darwin.c:115: dereferencing pointer to incomplete type
    gnumake[2]: *** [host-darwin.o] Error 1
    gnumake[1]: *** [stage1_build] Error 2
  77. What is shared_memory_server.h and why isn't there an easy way to answer the question "what is it, and to get it can I just download the file somewhere or do I have to finally give in and buy the upgrade to Mac OS 10.4?"
  78. Wait a day. Drive to the Apple store.
  79. Get told that of course I can't exchange money for the goods and services I want, because my four-year-old laptop is too old.
  80. Consider buying a PC.
  81. Post on the GHC mailing list to seek pity (or at least laughs).
  82. Per a resulting suggestion, start downloading the .dmg for gcc 3.3 off (which of course isn't google-able because of course you have to create an account and mumble mumble deep web mumble.)
  83. Be thankful that at least this one is only going to take 23 minutes to download instead of 34. Get dressed.
  84. Try to install the gcc .pkg. It says I need the December 2002 Developer Tools update too (which is of course exactly what the person on the mailing list said as well.)
  85. Start the Dec. 2002 update downloading. 6-hour download. Crie.
  86. Be grateful that at least you're not on dialup.
  87. Be grateful that at least you have First World problems rather than the other kind.