Clozure / ccl

Clozure Common Lisp
http://ccl.clozure.com
Apache License 2.0
855 stars 103 forks source link

objc is broken on BigSur #370

Open informatimago opened 3 years ago

informatimago commented 3 years ago

On BigSur, with ccl 1.12 from git:

> (com.informatimago.tools.manifest:print-bug-report-info)

LISP-IMPLEMENTATION-TYPE     "Clozure Common Lisp"
LISP-IMPLEMENTATION-VERSION  "Version 1.12 (v1.12-39-g6c1a9458) Darwinx8664"
SOFTWARE-TYPE                "Darwin"
SOFTWARE-VERSION             "20.4.0"
MACHINE-INSTANCE             "despina.home"
MACHINE-TYPE                 "x86_64"
MACHINE-VERSION              "iMac17,1"
distribution                 (:darwin :unknown "11.3.1")
uname -a                     "Darwin despina.home 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64"
*FEATURES*                   (patchwork.builder::use-cl-midi
                              cffi-features:flat-namespace cffi-features:x86-64
                              cffi-features:unix cffi-features:darwin :cffi
                              cffi-sys::flat-namespace :64-bit :bsd
                              :little-endian :swank :com.informatimago.pjb
                              :bordeaux-threads :closer-mop :thread-support
                              :uiop :split-sequence
                              :com.informatimago.common-lisp.lisp.cl-stepper
                              :cl-ppcre :newline-is-linefeed :has-ascii-code
                              :has-ascii-standard-characters :has-null :has-vt
                              :has-bell :has-escape :has-linefeed :has-return
                              :has-backspace :has-tab :has-page :has-rubout
                              :quicklisp :asdf3.3 :asdf3.2 :asdf3.1 :asdf3
                              :asdf2 :asdf :os-macosx :os-unix :asdf-unicode
                              :primary-classes :common-lisp :openmcl :ccl
                              :ccl-1.2 :ccl-1.3 :ccl-1.4 :ccl-1.5 :ccl-1.6
                              :ccl-1.7 :ccl-1.8 :ccl-1.9 :ccl-1.10 :ccl-1.11
                              :ccl-1.12 :clozure :clozure-common-lisp :ansi-cl
                              :unix :openmcl-unicode-strings :ipv6
                              :openmcl-native-threads :openmcl-partial-mop
                              :mcl-common-mop-subset :openmcl-mop-2
                              :openmcl-private-hash-tables
                              :static-conses-should-work-with-egc-in-ccl
                              :package-local-nicknames :x86-64 :x86_64
                              :x86-target :x86-host :x8664-target :x8664-host
                              :darwin-host :darwin-target :darwinx86-target
                              :darwinx8664-target :darwinx8664-host
                              :64-bit-target :64-bit-host :darwin
                              :little-endian-target :little-endian-host
                              :apple-objc :apple-objc-2.0 :hemlock
                              :objc-support :cocoa :cocoa-10.4 :cocoa-10.5
                              :cocoa-10.6 :cocoa-10.7 :cocoa-10.8 :cocoa-10.9
                              :fsbv)

; No value

[NSApplication sharedApplication] fails, the selector is not recognized:

Clozure Common Lisp Version 1.12 (v1.12-39-g6c1a9458) DarwinX8664
?  (objc:objc-message-send ns:+ns-application "sharedApplication" :id)
> Error: Objective-C runtime exception: 
>        +[NSApplication sharedApplication]: unrecognized selector sent to class 0x7fff803d1d80
> While executing: CCL::%DO-FF-CALL, in process Listener(3).
> Type cmd-. to abort, cmd-\ for a list of available restarts.
> Type :? for other options.
1 > :q
? (ccl:external-call "class_getClassMethod" 
                        :<c>lass (objc:send ns:+ns-application 'class)
                        :<sel> (objc:\@SELECTOR "sharedApplication")
                        :<m>ethod)
#<NS-NUMBER 28377 (#x7FFF23B29EE5)>
? (load #P"~/quicklisp/setup.lisp")
#P"/Users/pjb/quicklisp/setup.lisp"
?  (ql:quickload "cffi")
To load "cffi":
  Load 1 ASDF system:
    cffi
; Loading "cffi"

("cffi")
?      (cffi:defcfun (class-get-class-method "class_getClassMethod") :pointer (id :pointer) (sel :pointer))
CLASS-GET-CLASS-METHOD
?      (class-get-class-method (objc:objc-message-send ns:+ns-application "class" :<c>lass)
                             (objc:@selector "sharedApplication"))
#<NS-NUMBER 28377 (#x7FFF23B29EE5)>

Why a NS-NUMBER? It's specified to return a :pointer.

In another image, under slime, the same defcfun and class-get-class-method form return:

 #<ns-date 2001-01-01 00:00:00 +0000 (#x7FFF23B29EE5)>
informatimago commented 3 years ago

Hmm, I wonder if that wouldn't be related to an optimization in Cocoa that would represent NSNumber and NSDate as tagged pointers? But shouldn't ccl wrap them in MacPtr anyways? https://www.programmersought.com/article/14554753265/