From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Charles A. Roelli" Newsgroups: gmane.emacs.bugs Subject: bug#27810: NS runtime feature detection Date: Mon, 7 Aug 2017 21:23:10 +0200 Message-ID: <5d8b81c3-9a45-d59f-8dd1-c0ccc0a19c78@aurox.ch> 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> <20170806212929.GA62061@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1502133880 12490 195.159.176.226 (7 Aug 2017 19:24:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 7 Aug 2017 19:24:40 +0000 (UTC) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cc: Anders Lindgren , 27810@debbugs.gnu.org To: Alan Third Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 07 21:24:26 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 1dendP-000265-6K for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Aug 2017 21:24:15 +0200 Original-Received: from localhost ([::1]:39033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dendV-0005lL-3a for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Aug 2017 15:24:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dendH-0005kz-Ql for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2017 15:24:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dendC-0005gn-9G for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2017 15:24:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42046) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dendB-0005gZ-PD for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2017 15:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dendB-0004UI-JM for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2017 15:24:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Charles A. Roelli" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Aug 2017 19:24:01 +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.150213380217202 (code B ref 27810); Mon, 07 Aug 2017 19:24:01 +0000 Original-Received: (at 27810) by debbugs.gnu.org; 7 Aug 2017 19:23:22 +0000 Original-Received: from localhost ([127.0.0.1]:50727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dencY-0004TO-0c for submit@debbugs.gnu.org; Mon, 07 Aug 2017 15:23:22 -0400 Original-Received: from sinyavsky.aurox.ch ([37.35.109.145]:55664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dencW-0004T6-9Z for 27810@debbugs.gnu.org; Mon, 07 Aug 2017 15:23:21 -0400 Original-Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id 35421224EB for <27810@debbugs.gnu.org>; Mon, 7 Aug 2017 19:17:38 +0000 (UTC) Authentication-Results: sinyavsky.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h= content-transfer-encoding:content-type:content-type:in-reply-to :mime-version:user-agent:date:date:message-id:from:from :references:to:subject:subject; s=dkim; t=1502133455; x= 1502997456; bh=4Em3jMU1XiHR6Uu+64FNFVZwElDr9veshauikyJP528=; b=b VETEwKD4y4IvNuM3c/eLB0qfmeAFsMYICxyxJ7QTsxBMchXvkSEbe96N00+THqBA 5RES16jtK76fVU8SJjbNn6E7RtKHaQsHp13YhFNcRsVSu+LjacKPVYgrPn5fNix+ fbXJKny7z0cirwTRHTcqRrT9DyVBRDWCqDTExiQ2Hc= X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com Original-Received: from sinyavsky.aurox.ch ([127.0.0.1]) by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UxyHqs48BgP9 for <27810@debbugs.gnu.org>; Mon, 7 Aug 2017 19:17:35 +0000 (UTC) Original-Received: from [192.168.1.120] (125.85.192.178.dynamic.wline.res.cust.swisscom.ch [178.192.85.125]) by sinyavsky.aurox.ch (Postfix) with ESMTPSA id B42F9224CF; Mon, 7 Aug 2017 19:17:35 +0000 (UTC) In-Reply-To: <20170806212929.GA62061@breton.holly.idiocy.org> 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:135547 Archived-At: On 06/08/2017 23:29, Alan Third wrote: >> 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 > }; Strange, it doesn't work here: > nsterm.h:58: error: expected ‘)’ before ‘NSScrollerStyle’ >> 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. Without it, I get this: > nsterm.m: In function ‘+[EmacsScroller scrollerWidth]’: > nsterm.m:8387: warning: ‘NSScroller’ may not respond to ‘+scrollerWidthForControlSize:scrollerStyle:’ > nsterm.m:8387: error: incompatible types in assignment I think the compiler has to verify somehow that the result of the call is a CGFloat. Casting to CGFloat gives: > nsterm.m:8387: error: pointer value used where a floating point value was expected >> 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. Maybe I'm also confused. I thought we would be able to do this, since: - At link time, the symbol is marked as a weak reference, to be resolved at runtime. - At runtime, the dynamic linker resolves the reference to the weak symbol, setting it to NULL if it isn't available. Normally the definition of the function will be found in a dynamic library that is part of macOS (as far as I understand). The Apple compiler/linker should be capable of doing this, supposedly, as long as you give the magical -Wl,-U,_symbol command line arguments to the linker. See also https://stackoverflow.com/a/34983229. >> 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? I'd like to check, but wouldn't I need to either: a) Statically link libraries Emacs depends on, or b) Include the dependent libraries in the app bundle? By the libraries Emacs depends on, I mean the ones starting with $HOME here: $ otool -L src/emacs src/emacs: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1038.36.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) $HOME/Build/SnowLeopard/lib/libjpeg.9.dylib (compatibility version 12.0.0, current version 12.0.0) $HOME/Build/SnowLeopard/lib/librsvg-2.2.dylib (compatibility version 43.0.0, current version 43.16.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11) $HOME/Build/SnowLeopard/lib/libgio-2.0.0.dylib (compatibility version 4503.0.0, current version 4503.0.0) $HOME/Build/SnowLeopard/lib/libgdk_pixbuf-2.0.0.dylib (compatibility version 3401.0.0, current version 3401.0.0) $HOME/Build/SnowLeopard/lib/libgobject-2.0.0.dylib (compatibility version 4503.0.0, current version 4503.0.0) $HOME/Build/SnowLeopard/lib/libglib-2.0.0.dylib (compatibility version 4503.0.0, current version 4503.0.0) $HOME/Build/SnowLeopard/lib/libintl.9.dylib (compatibility version 11.0.0, current version 11.4.0) $HOME/Build/SnowLeopard/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.6.0) $HOME/Build/SnowLeopard/lib/libxml2.2.dylib (compatibility version 12.0.0, current version 12.4.0) /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0) $HOME/Build/SnowLeopard/lib/libgnutls.30.dylib (compatibility version 40.0.0, current version 40.0.0) /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3) /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.44.0) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 38.0.0) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 751.63.0) Do either of these sound feasible?