GNU bug report logs - #27041
MacOS 10.6: fix NS build

Previous Next

Package: emacs;

Reported by: "Charles A. Roelli" <charles <at> aurox.ch>

Date: Tue, 23 May 2017 18:58:02 UTC

Severity: normal

Merged with 27059

Done: Alan Third <alan <at> idiocy.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27041 in the body.
You can then email your comments to 27041 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#27041; Package emacs. (Tue, 23 May 2017 18:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Charles A. Roelli" <charles <at> aurox.ch>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 23 May 2017 18:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Charles A. Roelli" <charles <at> aurox.ch>
To: bug-gnu-emacs <at> gnu.org
Subject: MacOS 10.6: fix NS build
Date: Tue, 23 May 2017 20:57:04 +0200
[Message part 1 (text/plain, inline)]
Was getting these errors:

========
nsterm.h:455: error: expected ‘)’ before ‘instancetype’
nsterm.h:456: error: expected ‘)’ before ‘instancetype’
nsterm.h:460: error: expected ‘)’ before ‘instancetype’
nsterm.h:463: error: expected ‘)’ before ‘instancetype’
nsterm.h:523: error: expected ‘)’ before ‘instancetype’
nsterm.h:557: error: expected ‘)’ before ‘instancetype’
nsterm.h:592: error: expected ‘)’ before ‘instancetype’
nsterm.h:611: error: expected ‘)’ before ‘instancetype’
nsterm.h:659: error: expected ‘)’ before ‘instancetype’
nsterm.h:661: error: expected ‘)’ before ‘instancetype’
nsterm.h:663: error: expected ‘)’ before ‘instancetype’
nsterm.h:664: error: expected ‘)’ before ‘instancetype’
nsterm.h:703: error: expected ‘)’ before ‘instancetype’
nsterm.h:706: error: expected ‘)’ before ‘instancetype’
nsterm.h:710: error: expected ‘)’ before ‘instancetype’
nsterm.h:711: error: expected ‘)’ before ‘instancetype’
nsterm.h:712: error: expected ‘)’ before ‘instancetype’
nsterm.h:735: error: expected ‘)’ before ‘instancetype’
nsterm.m:6900: error: expected ‘)’ before ‘instancetype’
nsterm.m:7630: error: expected ‘)’ before ‘instancetype’
nsterm.m:7655: error: expected ‘)’ before ‘instancetype’
nsterm.m:7681: error: expected ‘)’ before ‘instancetype’
nsterm.m:7909: error: expected ‘)’ before ‘instancetype’
nsterm.m:8261: error: expected ‘)’ before ‘instancetype’
nsterm.m:8345: error: expected ‘)’ before ‘instancetype’
nsterm.m:8353: error: expected ‘)’ before ‘instancetype’
nsterm.m:8408: error: expected ‘)’ before ‘instancetype’
nsterm.m:8487: error: expected ‘)’ before ‘instancetype’
========

  CC       nsmenu.o
nsmenu.m:1496: error: expected ‘)’ before ‘NSWindowStyleMask’
nsmenu.m: In function ‘-[EmacsDialogPanel 
initWithContentRect:styleMask:backing:defer:]’:
nsmenu.m:1498: warning: conflicting types for 
‘-(id)initWithContentRect:(NSRect)contentRect styleMask:(id)aStyle 
backing:(NSBackingStoreType)backingType defer:(BOOL)flag’
/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:264: 
warning: previous declaration of 
‘-(id)initWithContentRect:(NSRect)contentRect 
styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType 
defer:(BOOL)flag’
nsmenu.m:1520: warning: assignment makes pointer from integer without a cast
nsmenu.m:1525: warning: passing argument 2 of 
‘initWithContentRect:styleMask:backing:defer:’ makes integer from 
pointer without a cast
========

This is with an LLVM/GCC that came with MacOS 10.6:

i686-apple-darwin10-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 
5658) (LLVM build 2335.15.00)
Copyright (C) 2007 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.

I've changed the source back to compile correctly (see patch).  It comes 
down to
removing the "instancetype" identifiers and reverting an 
NSWindowStyleMask to an
NSUInteger.

I also see this warning when compiling macfont.m:

macfont.m: In function ‘mac_font_shape_1’:
macfont.m:416: warning: ‘NSLayoutManager’ may not respond to 
‘-getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:’
macfont.m:416: warning: (Messages without a matching method signature
macfont.m:416: warning: will be assumed to return ‘id’ and accept
macfont.m:416: warning: ‘...’ as arguments.)

(some new arguments were added in the recent changes).  But this doesn't 
seem to affect functionality so I've left that change as is.


[0001-Fix-NS-build-in-MacOS-10.6.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27041; Package emacs. (Tue, 23 May 2017 19:50:02 GMT) Full text and rfc822 format available.

Message #8 received at 27041 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: "Charles A. Roelli" <charles <at> aurox.ch>
Cc: 27041 <at> debbugs.gnu.org
Subject: Re: bug#27041: MacOS 10.6: fix NS build
Date: Tue, 23 May 2017 20:49:47 +0100
On Tue, May 23, 2017 at 08:57:04PM +0200, Charles A. Roelli wrote:
> I've changed the source back to compile correctly (see patch).  It comes
> down to
> removing the "instancetype" identifiers and reverting an NSWindowStyleMask
> to an
> NSUInteger.

Hi Charles, can you try enabling the two typedefs at ~ line 67 in
nsterm.h to see if the first batch of errors go away?

I guess it’s possible the second typedef should be an NSUInteger
instead of a plain int. I just took a guess and that silenced the
errors when building under GNUstep.

> I also see this warning when compiling macfont.m:
> 
> macfont.m: In function ‘mac_font_shape_1’:
> macfont.m:416: warning: ‘NSLayoutManager’ may not respond to
> ‘-getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:’
> macfont.m:416: warning: (Messages without a matching method signature
> macfont.m:416: warning: will be assumed to return ‘id’ and accept
> macfont.m:416: warning: ‘...’ as arguments.)
> 
> (some new arguments were added in the recent changes).  But this doesn't
> seem to affect functionality so I've left that change as is.

Probably we should be using one function for recent macOS’s and
another for old ones. Yamamoto san had something to say about it, but
I’ve not had a chance to investigate:

http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00565.html

-- 
Alan Third




Merged 27041 27059. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 24 May 2017 16:59:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27041; Package emacs. (Wed, 24 May 2017 18:15:01 GMT) Full text and rfc822 format available.

Message #13 received at 27041 <at> debbugs.gnu.org (full text, mbox):

From: "Charles A. Roelli" <charles <at> aurox.ch>
To: Alan Third <alan <at> idiocy.org>
Cc: 27041 <at> debbugs.gnu.org
Subject: Re: bug#27041: MacOS 10.6: fix NS build
Date: Wed, 24 May 2017 20:13:21 +0200
Thanks for your help.

I changed the conditional to this:


#if defined(NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MAX_ALLOWED < 
MAC_OS_X_VERSION_10_7
typedef id instancetype;
typedef NSUInteger NSWindowStyleMask;
#endif


And it compiles fine without my previous changes.  Can you verify that 
this still builds with GNUstep?  If not, we can leave the 'int' instead 
of the 'NSUInteger'.


On 23/05/2017 21:49, Alan Third wrote:
> On Tue, May 23, 2017 at 08:57:04PM +0200, Charles A. Roelli wrote:
>> I've changed the source back to compile correctly (see patch).  It comes
>> down to
>> removing the "instancetype" identifiers and reverting an NSWindowStyleMask
>> to an
>> NSUInteger.
> Hi Charles, can you try enabling the two typedefs at ~ line 67 in
> nsterm.h to see if the first batch of errors go away?
>
> I guess it’s possible the second typedef should be an NSUInteger
> instead of a plain int. I just took a guess and that silenced the
> errors when building under GNUstep.
>
>> I also see this warning when compiling macfont.m:
>>
>> macfont.m: In function ‘mac_font_shape_1’:
>> macfont.m:416: warning: ‘NSLayoutManager’ may not respond to
>> ‘-getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:’
>> macfont.m:416: warning: (Messages without a matching method signature
>> macfont.m:416: warning: will be assumed to return ‘id’ and accept
>> macfont.m:416: warning: ‘...’ as arguments.)
>>
>> (some new arguments were added in the recent changes).  But this doesn't
>> seem to affect functionality so I've left that change as is.
> Probably we should be using one function for recent macOS’s and
> another for old ones. Yamamoto san had something to say about it, but
> I’ve not had a chance to investigate:
>
> http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00565.html
>





Reply sent to Alan Third <alan <at> idiocy.org>:
You have taken responsibility. (Wed, 24 May 2017 19:04:01 GMT) Full text and rfc822 format available.

Notification sent to "Charles A. Roelli" <charles <at> aurox.ch>:
bug acknowledged by developer. (Wed, 24 May 2017 19:04:02 GMT) Full text and rfc822 format available.

Message #18 received at 27041-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: "Charles A. Roelli" <charles <at> aurox.ch>
Cc: 27041-done <at> debbugs.gnu.org
Subject: Re: bug#27041: MacOS 10.6: fix NS build
Date: Wed, 24 May 2017 20:03:34 +0100
On Wed, May 24, 2017 at 08:13:21PM +0200, Charles A. Roelli wrote:
> Thanks for your help.
> 
> I changed the conditional to this:
> 
> 
> #if defined(NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MAX_ALLOWED <
> MAC_OS_X_VERSION_10_7
> typedef id instancetype;
> typedef NSUInteger NSWindowStyleMask;
> #endif
> 
> 
> And it compiles fine without my previous changes.  Can you verify that this
> still builds with GNUstep?  If not, we can leave the 'int' instead of the
> 'NSUInteger'.

It works fine on GNUstep too, so I’ve pushed the change.

FWIW, that instancetype type appears to be a built‐in and we should
probably be doing some sort of check whether the compiler supports it
natively or not. I don’t know how to go about doing that.

> > > I also see this warning when compiling macfont.m:
> > > 
> > > macfont.m: In function ‘mac_font_shape_1’:
> > > macfont.m:416: warning: ‘NSLayoutManager’ may not respond to
> > > ‘-getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:’
> > > macfont.m:416: warning: (Messages without a matching method signature
> > > macfont.m:416: warning: will be assumed to return ‘id’ and accept
> > > macfont.m:416: warning: ‘...’ as arguments.)
> > > 
> > > (some new arguments were added in the recent changes).  But this doesn't
> > > seem to affect functionality so I've left that change as is.

This warning doesn’t make much sense to me. I’ve looked up the
documentation and the new method being used has allegedly been
available since macOS 10.5.

https://developer.apple.com/reference/appkit/nslayoutmanager/1403104-getglyphsinrange

I guess if it’s working we can just ignore it.

-- 
Alan Third




Reply sent to Alan Third <alan <at> idiocy.org>:
You have taken responsibility. (Wed, 24 May 2017 19:04:02 GMT) Full text and rfc822 format available.

Notification sent to David Caldwell <david <at> porkrind.org>:
bug acknowledged by developer. (Wed, 24 May 2017 19:04:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27041; Package emacs. (Thu, 25 May 2017 02:17:02 GMT) Full text and rfc822 format available.

Message #26 received at 27041 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: 27041 <at> debbugs.gnu.org
Cc: Alan Third <alan <at> idiocy.org>, "Charles A. Roelli" <charles <at> aurox.ch>
Subject: Re: bug#27041: MacOS 10.6: fix NS build
Date: Wed, 24 May 2017 22:17:44 -0400
> FWIW, that instancetype type appears to be a built‐in and we should
> probably be doing some sort of check whether the compiler supports it
> natively or not. I don’t know how to go about doing that.

I think you should add something like this to configure.ac:

  AC_CACHE_CHECK([if the Objective C compiler supports instancetype], emacs_cv_objc_instancetype,
    AC_LANG_PUSH([Objective C])
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[- (instancetype) foo: () {return self;}]])],
                      emacs_cv_objc_instancetype=yes, emacs_cv_objc_instancetype=no)
    AC_LANG_POP([Objective C]))
  if test x$emacs_cv_objc_exceptions = xyes ; then
    AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
         [Define if ObjC compiler supports instancetype natively.])
  fi

Probably you have to fix the code I put inside AC_LANG_PROGRAM([[...]]),
I don't know Objective C at all.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27041; Package emacs. (Thu, 25 May 2017 18:47:02 GMT) Full text and rfc822 format available.

Message #29 received at 27041 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: npostavs <at> users.sourceforge.net
Cc: 27041 <at> debbugs.gnu.org, "Charles A. Roelli" <charles <at> aurox.ch>
Subject: [PATCH] Check if instancetype supported in ObjC
Date: Thu, 25 May 2017 19:46:35 +0100
* configure.ac: Add check for instancetype.
* src/nsterm.h [!NATIVE_OBJC_INSTANCETYPE]: Define instancetype.
---
 configure.ac | 17 +++++++++++++++++
 src/nsterm.h | 20 +++++++++++---------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6d23b5d214..b525666a85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1980,6 +1980,23 @@ AC_DEFUN
 AC_SUBST(NS_OBJ)
 AC_SUBST(NS_OBJC_OBJ)
 
+AC_CACHE_CHECK(
+  [if the Objective C compiler supports instancetype],
+  [emacs_cv_objc_instancetype],
+  [AC_LANG_PUSH([Objective C])
+   AC_COMPILE_IFELSE(
+     [AC_LANG_SOURCE([[@interface Test
+                        + (instancetype)test;
+                        @end]])],
+     emacs_cv_objc_instancetype=yes,
+     emacs_cv_objc_instancetype=no)
+   AC_LANG_POP([Objective C])])
+
+if test x$emacs_cv_objc_instancetype = xyes ; then
+  AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
+            [Define if ObjC compiler supports instancetype natively.])
+fi
+
 HAVE_W32=no
 W32_OBJ=
 W32_LIBS=
diff --git a/src/nsterm.h b/src/nsterm.h
index 8f3d92b353..f75e3759e4 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -62,15 +62,6 @@ typedef CGFloat EmacsCGFloat;
 typedef float EmacsCGFloat;
 #endif
 
-/* FIXME: instancetype is a language built-in, but older versions of
-   Clang don't support it, and I don't know if GCC supports it at all.
-   Should this be tested for in ./configure? */
-#if defined (NS_IMPL_GNUSTEP)
-    || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10
-typedef id instancetype;
-typedef NSUInteger NSWindowStyleMask;
-#endif
-
 /* ==========================================================================
 
    Trace support
@@ -365,6 +356,12 @@ char const * nstrace_fullscreen_type_name (int);
 #endif
 
 
+/* If the compiler doesn't support instancetype, map it to id. */
+#ifndef NATIVE_OBJC_INSTANCETYPE
+typedef id instancetype;
+#endif
+
+
 /* ==========================================================================
 
    NSColor, EmacsColor category.
@@ -1302,6 +1299,11 @@ extern char gnustep_base_version[];  /* version tracking */
 #define NSWindowStyleMaskUtilityWindow     NSUtilityWindowMask
 #define NSAlertStyleCritical               NSCriticalAlertStyle
 #define NSControlSizeRegular               NSRegularControlSize
+
+/* And adds NSWindowStyleMask. */
+#ifdef __OBJC__
+typedef NSUInteger NSWindowStyleMask;
+#endif
 #endif
 
 #endif	/* HAVE_NS */
-- 

Looks like this does the trick. Thanks Noam!

Charles, could you confirm this patch builds on 10.6?

-- 
Alan Third




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27041; Package emacs. (Thu, 25 May 2017 23:41:02 GMT) Full text and rfc822 format available.

Message #32 received at 27041 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Alan Third <alan <at> idiocy.org>
Cc: 27041 <at> debbugs.gnu.org, "Charles A. Roelli" <charles <at> aurox.ch>
Subject: Re: bug#27041: [PATCH] Check if instancetype supported in ObjC
Date: Thu, 25 May 2017 19:42:05 -0400
Alan Third <alan <at> idiocy.org> writes:

> --- a/configure.ac
> +++ b/configure.ac
> @@ -1980,6 +1980,23 @@ AC_DEFUN
>  AC_SUBST(NS_OBJ)
>  AC_SUBST(NS_OBJC_OBJ)
>  
> +AC_CACHE_CHECK(
> +  [if the Objective C compiler supports instancetype],
> +  [emacs_cv_objc_instancetype],
> +  [AC_LANG_PUSH([Objective C])
> +   AC_COMPILE_IFELSE(
> +     [AC_LANG_SOURCE([[@interface Test
> +                        + (instancetype)test;
> +                        @end]])],
> +     emacs_cv_objc_instancetype=yes,
> +     emacs_cv_objc_instancetype=no)
> +   AC_LANG_POP([Objective C])])
> +
> +if test x$emacs_cv_objc_instancetype = xyes ; then
> +  AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
> +            [Define if ObjC compiler supports instancetype natively.])
> +fi
> +
>  HAVE_W32=no
>  W32_OBJ=
>  W32_LIBS=

I guess this should be inside 'if test "${HAVE_NS}" = yes; ...'
(although it seems harmless anyway).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27041; Package emacs. (Fri, 26 May 2017 19:26:02 GMT) Full text and rfc822 format available.

Message #35 received at 27041 <at> debbugs.gnu.org (full text, mbox):

From: "Charles A. Roelli" <charles <at> aurox.ch>
To: Alan Third <alan <at> idiocy.org>, npostavs <at> users.sourceforge.net
Cc: 27041 <at> debbugs.gnu.org
Subject: Re: [PATCH] Check if instancetype supported in ObjC
Date: Fri, 26 May 2017 21:25:02 +0200
All good.  Thanks for the help!


On 25/05/2017 20:46, Alan Third wrote:
> * configure.ac: Add check for instancetype.
> * src/nsterm.h [!NATIVE_OBJC_INSTANCETYPE]: Define instancetype.
> ---
>   configure.ac | 17 +++++++++++++++++
>   src/nsterm.h | 20 +++++++++++---------
>   2 files changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 6d23b5d214..b525666a85 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1980,6 +1980,23 @@ AC_DEFUN
>   AC_SUBST(NS_OBJ)
>   AC_SUBST(NS_OBJC_OBJ)
>   
> +AC_CACHE_CHECK(
> +  [if the Objective C compiler supports instancetype],
> +  [emacs_cv_objc_instancetype],
> +  [AC_LANG_PUSH([Objective C])
> +   AC_COMPILE_IFELSE(
> +     [AC_LANG_SOURCE([[@interface Test
> +                        + (instancetype)test;
> +                        @end]])],
> +     emacs_cv_objc_instancetype=yes,
> +     emacs_cv_objc_instancetype=no)
> +   AC_LANG_POP([Objective C])])
> +
> +if test x$emacs_cv_objc_instancetype = xyes ; then
> +  AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
> +            [Define if ObjC compiler supports instancetype natively.])
> +fi
> +
>   HAVE_W32=no
>   W32_OBJ=
>   W32_LIBS=
> diff --git a/src/nsterm.h b/src/nsterm.h
> index 8f3d92b353..f75e3759e4 100644
> --- a/src/nsterm.h
> +++ b/src/nsterm.h
> @@ -62,15 +62,6 @@ typedef CGFloat EmacsCGFloat;
>   typedef float EmacsCGFloat;
>   #endif
>   
> -/* FIXME: instancetype is a language built-in, but older versions of
> -   Clang don't support it, and I don't know if GCC supports it at all.
> -   Should this be tested for in ./configure? */
> -#if defined (NS_IMPL_GNUSTEP)
> -    || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10
> -typedef id instancetype;
> -typedef NSUInteger NSWindowStyleMask;
> -#endif
> -
>   /* ==========================================================================
>   
>      Trace support
> @@ -365,6 +356,12 @@ char const * nstrace_fullscreen_type_name (int);
>   #endif
>   
>   
> +/* If the compiler doesn't support instancetype, map it to id. */
> +#ifndef NATIVE_OBJC_INSTANCETYPE
> +typedef id instancetype;
> +#endif
> +
> +
>   /* ==========================================================================
>   
>      NSColor, EmacsColor category.
> @@ -1302,6 +1299,11 @@ extern char gnustep_base_version[];  /* version tracking */
>   #define NSWindowStyleMaskUtilityWindow     NSUtilityWindowMask
>   #define NSAlertStyleCritical               NSCriticalAlertStyle
>   #define NSControlSizeRegular               NSRegularControlSize
> +
> +/* And adds NSWindowStyleMask. */
> +#ifdef __OBJC__
> +typedef NSUInteger NSWindowStyleMask;
> +#endif
>   #endif
>   
>   #endif	/* HAVE_NS */





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 29 Jun 2017 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 358 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.