From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#27810: NS runtime feature detection Date: Sun, 6 Aug 2017 22:29:29 +0100 Message-ID: <20170806212929.GA62061@breton.holly.idiocy.org> References: <20170722112230.GA58424@breton.holly.idiocy.org> <20170723121701.GA3730@breton.holly.idiocy.org> <508a4930-feab-588b-0ab9-f55a10ea85ec@aurox.ch> <20170724204404.GA20189@breton.holly.idiocy.org> <20170726215746.GA59679@breton.holly.idiocy.org> <20170801220339.GA57816@breton.holly.idiocy.org> <87dde5f1-0010-584e-2dad-4f0fe932f1fa@aurox.ch> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1502055024 4177 195.159.176.226 (6 Aug 2017 21:30:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 6 Aug 2017 21:30:24 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: Anders Lindgren , 27810@debbugs.gnu.org To: "Charles A. Roelli" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 06 23:30:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1deT7i-0000Pq-FM for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Aug 2017 23:30:10 +0200 Original-Received: from localhost ([::1]:34396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1deT7o-0001Q7-12 for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Aug 2017 17:30:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1deT7g-0001MQ-8L for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 17:30:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1deT7c-0000tD-9J for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 17:30:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42362) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1deT7c-0000t6-3u for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 17:30:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1deT7b-0000pe-05 for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 17:30:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Aug 2017 21:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27810 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27810-submit@debbugs.gnu.org id=B27810.15020549803142 (code B ref 27810); Sun, 06 Aug 2017 21:30:02 +0000 Original-Received: (at 27810) by debbugs.gnu.org; 6 Aug 2017 21:29:40 +0000 Original-Received: from localhost ([127.0.0.1]:45039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1deT7E-0000oc-Ey for submit@debbugs.gnu.org; Sun, 06 Aug 2017 17:29:40 -0400 Original-Received: from mail-wr0-f175.google.com ([209.85.128.175]:37291) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1deT7C-0000oO-ON for 27810@debbugs.gnu.org; Sun, 06 Aug 2017 17:29:39 -0400 Original-Received: by mail-wr0-f175.google.com with SMTP id 33so33009351wrz.4 for <27810@debbugs.gnu.org>; Sun, 06 Aug 2017 14:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=Obmo/bWlkkRszkIw6ARrD3QXmd0Rbr4vclFk3+qLgiM=; b=dn22uwwwKMJEZD9XaWppQCbPtzPsSkcpyGVtijqvyREaS080Mct5dT6Q7iLxXrpX5f S9VGn4jlEUaKzc6doVoRLBfML9X5xfIMx2PtWiCnfuLtciJ15Vk7nG+cQsMN5nGg+Cve U0UJjTz/Ey++zwE50QT98M8sSLoKccaDGT/QLd+921f7jUO+x8cxPY21xhA5ARp2s1KT 3FuESln2gTS4dOPHpIrSvn8kiA8GYThZVAET1GEGPAV6Eo7phtE1rbCL+6uWabRLmyyD Whnmcr+6BS+4Y2dntx3EThWsDYcCxcXECCM5DcS6Z2/EJwKGG+sHmFIHWJsZ3y0rMA5u agJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=Obmo/bWlkkRszkIw6ARrD3QXmd0Rbr4vclFk3+qLgiM=; b=YpD2fSd00ZkcdXaU1mGtIy9dntPSy71JmvwbMTdzqUiTsIZZLUCIkOz0fFocGB/Rbk UiLisRYjdfm8DzNJ5AzhT7UdFBSKedoRct1FKR5PGqAv9+LsNZz+JUrZysVacka6EHWz x+3rOJVVFOv7mrGXvCBtQSv3ag44Df2LEUt/REvnwh/y9e3cA2805NaJXnBN0VCkVCxA qHOYlxnmRZpgecSDjjDg+wf/NKSyuMNwHXnQmWLxvAY9AMNFxBCEcoOjdf87ZxGnd5wo ej4uZ9YiK7BMGr+uREgHhi+kHnqCtIbhWxkhFcM72Gg/iFvJHQG42ufGsuI5HlPL/ihB 6H4w== X-Gm-Message-State: AIVw111SmOjtRAh9x0gcTigT4EzcJ84mtWB3ujutzvjdBg7bNuI09Rgs HbNPOFfLDu1ZQw== X-Received: by 10.223.171.234 with SMTP id s97mr7701827wrc.277.1502054972893; Sun, 06 Aug 2017 14:29:32 -0700 (PDT) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-01cb-bb38-cef2-8157.holly.idiocy.org. [2001:8b0:3f8:8129:1cb:bb38:cef2:8157]) by smtp.gmail.com with ESMTPSA id 76sm8781522wmm.39.2017.08.06.14.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Aug 2017 14:29:31 -0700 (PDT) Content-Disposition: inline In-Reply-To: <87dde5f1-0010-584e-2dad-4f0fe932f1fa@aurox.ch> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:135517 Archived-At: On Sun, Aug 06, 2017 at 10:29:49PM +0200, Charles A. Roelli wrote: > I ran a simple configure/compile with your patch installed, which worked > fine. > I then tried: > > ./configure --with-ns CFLAGS=-DMAC_OS_X_VERSION_MIN_REQUIRED=1060 > -DMAC_OS_X_VERSION_MAX_ALLOWED=101200 -g -O3 > > and ran into a few errors, which should be fixed with the attached > patch applied on top of yours. I've written notes on some of the > changed parts below. Thanks! These are exactly the kinds of errors I was expecting to see. > Next, in src/nsterm.h: > > +#define NSAppKitVersionNumber10_7 1138 > > New define, since it's referenced verbatim in nsterm.m:7017: Ah, I didn’t even think of that. :) > New scroll styles in 10.7+: > > +enum { > + NSScrollerStyleLegacy = 0, > + NSScrollerStyleOverlay = 1 > +}; > +typedef NSInteger NSScrollerStyle; I believe we can make this slightly neater: enum NSScrollerStyle { NSScrollerStyleLegacy = 0, NSScrollerStyleOverlay = 1 }; > Add-on to the class declaration of NSScroller (not sure if this is the > right way to do it). Otherwise the compiler errors out on compiling > the 10.7+ call to scrollerWidthForControlSize: > > +@interface NSScroller(NSObject) > ++ (CGFloat)scrollerWidthForControlSize:(NSControlSize)controlSize > scrollerStyle:(NSScrollerStyle)scrollerStyle; > +@end Strange... Are you sure this one was an error and not just a warning? We’re expecting warnings for this type of thing. > Forward declarations for functions used by macfont.m (declared as weak > imports since they won't all be available unless we're on 10.8+): > > +void CTFontDrawGlyphs(CTFontRef font, const CGGlyph *glyphs, const CGPoint > *positions, size_t count, CGContextRef context) > __attribute__((weak_import)); > +#endif > + > +#if !defined (MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MAX_ALLOWED >= > 1080 > +extern CFArrayRef CTFontCopyDefaultCascadeListForLanguages(CTFontRef font, > CFArrayRef languagePrefList) __attribute__((weak_import)); > > The compiler issued no complaints here, but the linker would not link > temacs unless the symbols were listed as permitted to be undefined, > using this in src/Makefile: > > ## System-specific LDFLAGS. > LD_SWITCH_SYSTEM= -Wl,-U,_CTFontCopyDefaultCascadeListForLanguages > -Wl,-U,_CTFontDrawGlyphs I’ve done a bit more reading up on this and I think I’ve misunderstood how this works, and probably mislead you. It seems these functions need to be declared as weak in the definition of the library they’re supposed to be in. If we declare them in the Emacs code‐base then the linker, reasonably, expects the functions to be in the Emacs code‐base. The top answer here might explain it better: https://stackoverflow.com/questions/274753/how-to-make-weak-linking-work-with-gcc I suppose this means we simply can’t guarantee perfect forward compatibility. It’s a shame, but I don’t see a way round it. > If they look okay, could you please integrate these changes into your > patch? Thanks a lot for your help on this. If you can confirm the scrollerWidthForControlSize thing, I’ll incorporate everything else. Thank you for your help. Oh, by the way, are you able to check whether the .app built on 10.6 actually runs on something higher? -- Alan Third