BUILDING A 64-BIT EMACS ON SNOW LEOPARD
Posted on August 30, 2009, 11:46 am, by Erik Charlebois, under Uncategorized.
Steps to fix the 64-bit Emacs on Snow Leopard (configure –with-ns, make, make install):
Undef HAVE_POSIX_MEMALIGN in the #ifdef temacs part of src/s/darwin.h. posix_memalign does not call wind up calling the hooked unexec_malloc, so you wind up with incorrect free calls.
This is a personall preference, change NS_SELECTION_COLOR_DEFAULT in src/nsterm.h to something reasonable instead of crazy yellow.
I cheated on this one and cherry picked this diff for fixing temacs dumping. I figured out the __program_vars, but the dump code silently ignored the as-yet undocumented LC_DYLD_INFO and LC_DYLD_INFO_ONLY fixes.
Fix all the format mismatch warnings from gcc. Because 64-bit on OSX is LP64 (longs are 64-bit), all the places that did something like printf(”%d”, (long)1); need to be given the right format string type of %ld. This applies to %x/%lx as well. There’s also one long long spot that needs to be %llx.
This one’s a hack, not sure how the actual maintainers would want to structure it in the official code. NSPoint and NSSize use CGFloat not float, and CGFloat is double in 64-bit OSX. In nsgui.h:
#ifndef __OBJC__
typedef double CGFloat;
typedef struct _NSPoint { CGFloat x, y; } NSPoint;
typedef struct _NSSize { CGFloat width, height; } NSSize;
typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect;
#endif
#define NativeRectangle NSRect
Doesn’t affect functionality, but you can fix all the warnings for unimplemented objective-c protocols for EmacsView, EmacsToolbar, EmacsMenu, EmacsTooltip in nsterm.h.
In nsterm.h, add “CTFontRef ctfont” above CGFontRef cgfont. Core Text has replaced some of the CG text funcionality.
Fix one mismatched-size pointer comparison in menu.c (remove the excess (int)):
if ((EMACS_INT)client_data == (EMACS_INT)(&XVECTOR (menu_items)->contents[i]))
Fix all warnings generated related to Objective-C code with mismatched types or function signatures. This is done float -> CGfloat, int -> NSInteger, unsigned int -> NSUInteger.
Remove the call to PSFlush() in nsfns.m. Can’t find any docs on the existence of this function and it doesn’t exist in the Frameworks anymore. Removing it didn’t seem to break anything.
nsmenu.m line 659: change the (int) cast to a (long) cast.
Replace the setFloatValue:knobProportion deprecated calls in nsterm.m with separate calls to setDoubleValue: and setKnobProportion:.
In nsfont.m, replace the widthOfString calls that look like this…
w = [sfont widthOfString: cstr];
…with this…
NSDictionary *attrsDictionary =
[NSDictionary dictionaryWithObject:sfont
forKey:NSFontAttributeName];
w = [cstr sizeWithAttributes:attrsDictionary].width;
In nsfont.m, Add a CFRelease(font_info->ctfont) call below the CGFontRelease(font_info->cgfont).
In nsfont.m, replace the CGFontCreateWithPlatform call with:
font_info->ctfont = CTFontCreateWithPlatformFont (atsFont, 0.0f, NULL, NULL);
font_info->cgfont = CTFontCopyGraphicsFont(font_info->ctfont, NULL);
At this point, the only warnings should be related to some deprecated cstring methods (not fixing cause im not sure of what the actual encoding should be), deprecated input manager stuff (not fixing cause) and a deprecated bestRepresentationForDevice call (no idea what the intended replacement is, it should be a rule that you can’t deprecate without explaining what the migration path is). Make and make install and you should have a working 64-bit Emacs.app!


