Subject: bug#2857: GNU Emacs 22.3 for Mac missing executable

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Sun, 30 Aug 2009 18:16:56 +0900

>>>>> On Thu, 2 Apr 2009 13:39:49 +0200 (MEST), Anders Bolt-Evensen <[email-masked]> said:

> 2) I tried to install GNU Emacs 22.2 and Emacs 22.3 on Mac OS X Snow
> Leopard (beta), but the "sudo make install" command fails on both
> versions with "make[1]: *** [mac.o] Error 1 make: *** [src] Error 2"
> During the make process there are a lot of warnings (and 1 error as
> I saw) that occured. I've made a log file with the output that was
> written to the terminal during the ./configure and "make install"
> processes.

To compile Emacs 22.3 Carbon port on Mac OS X 10.6 Snow Leopard, you
need to apply the patch below and explicitly specify a compiler option
like "CC='gcc -m32' ./configure".  Snow Leopard seems to try to make a
64-bit binary by default and it is not compatible with the GUI
implementation with Carbon.

Alternatively, you can try the Carbon+AppKit port, which contains
several fixes and enhancements that have been made after the Emacs
22.3 release.
http://lists.gnu.org/archive/html/emacs-devel/2009-08/msg01309.html

				     YAMAMOTO Mitsuharu
				[email-masked]

Index: src/unexmacosx.c
===================================================================
RCS file: /sources/emacs/emacs/src/unexmacosx.c,v
retrieving revision 1.22.2.5
diff -c -p -r1.22.2.5 unexmacosx.c
*** src/unexmacosx.c	8 Jan 2008 04:29:48 -0000	1.22.2.5
--- src/unexmacosx.c	30 Aug 2009 09:01:00 -0000
*************** print_load_command_name (int lc)
*** 584,589 ****
--- 584,597 ----
        printf ("LC_UUID          ");
        break;
  #endif
+ #ifdef LC_DYLD_INFO
+     case LC_DYLD_INFO:
+       printf ("LC_DYLD_INFO     ");
+       break;
+     case LC_DYLD_INFO_ONLY:
+       printf ("LC_DYLD_INFO_ONLY");
+       break;
+ #endif
      default:
        printf ("unknown          ");
      }
*************** copy_data_segment (struct load_command *
*** 821,826 ****
--- 829,835 ----
  	       || strncmp (sectp->sectname, "__const", 16) == 0
  	       || strncmp (sectp->sectname, "__cfstring", 16) == 0
  	       || strncmp (sectp->sectname, "__gcc_except_tab", 16) == 0
+ 	       || strncmp (sectp->sectname, "__program_vars", 16) == 0
  	       || strncmp (sectp->sectname, "__objc_", 7) == 0)
  	{
  	  if (!unexec_copy (sectp->offset, old_file_offset, sectp->size))
*************** copy_twolevelhints (struct load_command 
*** 1088,1093 ****
--- 1097,1132 ----
    curr_header_offset += lc->cmdsize;
  }
  
+ #ifdef LC_DYLD_INFO
+ /* Copy a LC_DYLD_INFO(_ONLY) load command from the input file to the output
+    file, adjusting the file offset fields.  */
+ static void
+ copy_dyld_info (struct load_command *lc, long delta)
+ {
+   struct dyld_info_command *dip = (struct dyld_info_command *) lc;
+ 
+   if (dip->rebase_off > 0)
+     dip->rebase_off += delta;
+   if (dip->bind_off > 0)
+     dip->bind_off += delta;
+   if (dip->weak_bind_off > 0)
+     dip->weak_bind_off += delta;
+   if (dip->lazy_bind_off > 0)
+     dip->lazy_bind_off += delta;
+   if (dip->export_off > 0)
+     dip->export_off += delta;
+ 
+   printf ("Writing ");
+   print_load_command_name (lc->cmd);
+   printf (" command\n");
+ 
+   if (!unexec_write (curr_header_offset, lc, lc->cmdsize))
+     unexec_error ("cannot write dyld info command to header");
+ 
+   curr_header_offset += lc->cmdsize;
+ }
+ #endif
+ 
  /* Copy other kinds of load commands from the input file to the output
     file, ones that do not require adjustments of file offsets.  */
  static void
*************** dump_it ()
*** 1154,1159 ****
--- 1193,1204 ----
        case LC_TWOLEVEL_HINTS:
  	copy_twolevelhints (lca[i], linkedit_delta);
  	break;
+ #ifdef LC_DYLD_INFO
+       case LC_DYLD_INFO:
+       case LC_DYLD_INFO_ONLY:
+ 	copy_dyld_info (lca[i], linkedit_delta);
+ 	break;
+ #endif
        default:
  	copy_other (lca[i]);
  	break;
Index: src/s/darwin.h
===================================================================
RCS file: /sources/emacs/emacs/src/s/darwin.h,v
retrieving revision 1.28.2.4
diff -c -p -r1.28.2.4 darwin.h
*** src/s/darwin.h	17 Jul 2008 09:07:06 -0000	1.28.2.4
--- src/s/darwin.h	30 Aug 2009 09:01:01 -0000
*************** Boston, MA 02110-1301, USA.  */
*** 351,356 ****
--- 351,359 ----
  #define malloc unexec_malloc
  #define realloc unexec_realloc
  #define free unexec_free
+ /* Don't use posix_memalign because it is not compatible with
+    unexmacosx.c.  */
+ #undef HAVE_POSIX_MEMALIGN
  #endif
  
  /* This makes create_process in process.c save and restore signal