-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Porting to Allegro CL 11 / MacOS 14 / Apple silicon (M2) #13
Comments
Quick followup. The problems with numpy/ndarraytypes.h and numpy/arrayobject.h were because of a configuration error on my part (conda and brew not playing well together). Everything else remains. |
Ah, I'd love to support a case sensitive readtable! I will check and fix the issues case-sensitivity creates in about 1-2 days.
The file For the linker error, I'm hoping to find a cloud service to test py4cl2-cffi on Apple systems. As a guess, you can try dumping the py4cl-utils.o using objdump or equivalent to see if the missing symbols it complains about are actually missing. If they are, that makes me curious why things are working on linux. Perhaps, on linux, there are no complaints because the other libraries are already loaded on SBCL through |
Thanks for the quick response! I'll take a look at the linker issue tomorrow, but for now, I think you should change (format nil "CL:~A" numpy-installed-p) to be the CL:~A is not portable. |
Hi! The issue about numpy-installed-p should be fixed now. |
I have made some progress in the macos branch - the CI uses macos-14, which according to github is M1. Let me know if you can get it working to a slightly better extent. It still needs some fixes though. |
I got hold of a MacOS at 5 USD for a week from hostmyapple. I can confirm that all-but-one tests pass on this, if you pass
For reasons I'm unable to debug, on github actions:
|
How much would it cost? I’d probably be willing to buy… I’m running macOS-14 on an M2.
… On Apr 24, 2024, at 7:01 PM, Shubhamkar Ayare ***@***.***> wrote:
I got hold of a MacOS at 5 USD for a week from hostmyapple <https://www.hostmyapple.com/>. I can confirm that all-but-one tests pass on this, if you pass --dynamic-space-size 2560 or better option to SBCL.
User-6914:~ User$ sw_vers
ProductName: macOS
ProductVersion: 14.4
BuildVersion: 23E214
User-6914:~ User$ uname -a
Darwin User-6914 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:31 PST 2024; root:xnu-10063.101.15~2/RELEASE_X86_64 x86_64
For reasons I'm unable to debug, on github actions:
macos-12 (x86_64) freezes while compiling the tests.
macos-14 (arm64) crashes. I wonder if I'm making some assumptions about pointers that are true on x86_64 but not on arm64. I might also check if I can get py4cl2-cffi to work on an arm64 linux device. Beyond that, an M1 mac in the cloud looks a bit too expensive.
—
Reply to this email directly, view it on GitHub <#13 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AACWZKN7P67VBLF5XKJKYSTY7CE2NAVCNFSM6AAAAABGRYXONGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZWGM2TSOJSGQ>.
You are receiving this because you authored the thread.
|
The cheapest I see on HostMyApple is 69.99 USD/month. At those price points, I might as well buy myself an M1 or M2 in the upcoming year once I benchmark against my current i7-8750H to see if it's worth an upgrade :). I'm certain there are other options out there, but I haven't checked which turns out to be the cheapest. There are other projects I'd like to support on MacOS and not just py4cl2-cffi. Setting up a sponsor might be the best going forward. |
I’d pay $70 for the port. And I might also have other projects.
… On Apr 24, 2024, at 7:16 PM, Shubhamkar Ayare ***@***.***> wrote:
The cheapest I see on HostMyApple <https://www.hostmyapple.com/dedicated-mac-hosting> is 69.99 USD/month. At those price points, I might as well buy myself an M1 or M2 in the upcoming year once I benchmark against my current i7-8750H to see if it's worth an upgrade :).
I'm certain there are other options out there, but I haven't checked which turns out to be the cheapest. There are other projects I'd like to support on MacOS and not just py4cl2-cffi. Setting up a sponsor might be the best going forward.
—
Reply to this email directly, view it on GitHub <#13 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AACWZKJB37JZ7JYULAOYQL3Y7CGUNAVCNFSM6AAAAABGRYXONGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZWGM3TKNJQGI>.
You are receiving this because you authored the thread.
|
Alright, I'll set up a sponsor over the upcoming week or two. And will also check if py4cl2-cffi works on linux arm64 before that. |
🤙. (Which is Hawaiian for 👍).
… On Apr 24, 2024, at 7:30 PM, Shubhamkar Ayare ***@***.***> wrote:
Alright, I'll set up a sponsor over the upcoming week or two. And will also check if py4cl2-cffi works on linux arm64 before that.
—
Reply to this email directly, view it on GitHub <#13 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AACWZKJ5VZ7GV6RXNDQALODY7CIG5AVCNFSM6AAAAABGRYXONGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZWGM4TSNZQGY>.
You are receiving this because you authored the thread.
|
I just tested this on aarch64 via AnLinux (proot) on Termux on Android:
The good news is that all the tests from py4cl2-cffi-tests pass out of the box without any crashes. But that raises the concern that the crashing behavior on M1 MacOS 14 on Github Actions might be harder to debug than I initially thought. The tests themselves pass on amd64 MacOS 14 as I tried on a HostMyMac instance the other day. Consistent freezing on github actions is reported to be not very uncommon. M1 MacOS and their successors are the specific concerns then. Could you check on both ECL and SBCL if you obtain the crashing behavior on your machine too? Also, running an arm64 linux VM on M* MacOS can be another option in the meanwhile. |
Well, this is interesting. I installed SBCL, and py4cl2-cffi loads without a hitch. I couldn’t run the tests though. I tried git clone https://github.com/digikar99/py4cl2-cffi-tests in the quicklsp local-distributions directory, and got the result at the end of this message. However, this suggests a problem with Allegro CL, not py4cl2-cffi. I’ll file a bug report with them and see if they have anything to say…
This is my system, btw:
% uname -a
Darwin MacBook-Air-3.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:19:22 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8112 arm64
Thanks for your help!
Larry
* (ql:quickload "py4cl2-cffi-tests")
To load "py4cl2-cffi-tests":
Load 1 ASDF system:
py4cl2-cffi-tests
; Loading "py4cl2-cffi-tests"
.To load "array-operations":
Load 3 ASDF systems:
alexandria anaphora asdf
Install 2 Quicklisp releases:
array-operations let-plus
; Fetching #<URL "http://beta.quicklisp.org/archive/let-plus/2019-11-30/let-plus-20191130-git.tgz">
; 10.98KB
==================================================
11,247 bytes in 0.00 seconds (8301.89KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/array-operations/2023-10-21/array-operations-1.2.1.tgz">
; 369.59KB
==================================================
378,460 bytes in 0.28 seconds (1329.23KB/sec)
; Loading "array-operations"
[package anaphora]................................
[package anaphora-basic]..........................
[package anaphora-symbol].........................
[package let-plus]................................
[package array-operations/generic]................
[package array-operations/reducing]...............
[package array-operations/utilities]..............
[package array-operations/creating]...............
[package array-operations/indexing]...............
[package array-operations/displacing].............
[package array-operations/transforming]...........
[package array-operations/stacking].
To load "py4cl2-cffi-tests":
Load 1 ASDF system:
py4cl2-cffi-tests
; Loading "py4cl2-cffi-tests"
To load "dense-arrays-plus-lite":
Load 12 ASDF systems:
alexandria anaphora asdf cl-environments closer-mop
iterate let-plus optima swank trivial-backtrace
trivial-garbage uiop
Install 18 Quicklisp releases:
abstract-arrays agutil arrows asdf-flv
asdf-system-connections cl-form-types
compiler-macro-notes ctype dense-arrays
extensible-compound-types extensible-optimizing-coerce
fiveam in-nomine introspect-environment
polymorphic-functions split-sequence
trivial-package-local-nicknames trivial-types
; Fetching #<URL "http://beta.quicklisp.org/archive/trivial-package-local-nicknames/2022-02-20/trivial-package-local-nicknames-20220220-git.tgz">
; 3.74KB
==================================================
3,827 bytes in 0.00 seconds (6454.76KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/extensible-optimizing-coerce/2023-06-18/extensible-optimizing-coerce-20230618-git.tgz">
; 30.71KB
==================================================
31,446 bytes in 0.05 seconds (670.74KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/asdf-system-connections/2017-01-24/asdf-system-connections-20170124-git.tgz">
; 4.82KB
==================================================
4,933 bytes in 0.00 seconds (6823.49KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/split-sequence/2021-05-31/split-sequence-v2.0.1.tgz">
; 11.43KB
==================================================
11,705 bytes in 0.00 seconds (14306.21KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/ctype/2023-10-21/ctype-20231021-git.tgz">
; 56.50KB
==================================================
57,852 bytes in 0.12 seconds (481.46KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/polymorphic-functions/2023-06-18/polymorphic-functions-20230618-git.tgz">
; 68.22KB
==================================================
69,861 bytes in 0.14 seconds (504.02KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/trivial-types/2012-04-07/trivial-types-20120407-git.tgz">
; 3.15KB
==================================================
3,228 bytes in 0.00 seconds (6581.09KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/in-nomine/2023-06-18/in-nomine-20230618-git.tgz">
; 13.86KB
==================================================
14,194 bytes in 0.00 seconds (20875.49KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/asdf-flv/2023-10-21/asdf-flv-version-2.2.tgz">
; 2.20KB
==================================================
2,257 bytes in 0.00 seconds (2888.73KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/fiveam/2023-10-21/fiveam-20231021-git.tgz">
; 32.78KB
==================================================
33,563 bytes in 0.01 seconds (2353.95KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/compiler-macro-notes/2022-11-06/compiler-macro-notes-v0.2.1.tgz">
; 4.48KB
==================================================
4,588 bytes in 0.00 seconds (4791.95KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/introspect-environment/2022-02-20/introspect-environment-20220220-git.tgz">
; 9.47KB
==================================================
9,695 bytes in 0.00 seconds (8965.69KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/arrows/2018-10-18/arrows-20181018-git.tgz">
; 4.95KB
==================================================
5,067 bytes in 0.00 seconds (7396.48KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/agutil/2021-05-31/agutil-20210531-git.tgz">
; 6.92KB
==================================================
7,087 bytes in 0.00 seconds (6462.09KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/cl-form-types/2023-06-18/cl-form-types-20230618-git.tgz">
; 31.95KB
==================================================
32,717 bytes in 0.07 seconds (440.62KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/extensible-compound-types/2023-10-21/extensible-compound-types-20231021-git.tgz">
; 42.27KB
==================================================
43,289 bytes in 0.12 seconds (353.45KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/abstract-arrays/2023-06-18/abstract-arrays-20230618-git.tgz">
; 8.60KB
==================================================
8,806 bytes in 0.00 seconds (9357.57KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/dense-arrays/2023-06-18/dense-arrays-20230618-git.tgz">
; 42.75KB
==================================================
43,781 bytes in 0.08 seconds (510.24KB/sec)
; Loading "dense-arrays-plus-lite"
..................................................
[package symbol-munger]...........................
[package collectors-signals]......................
[package collectors]..............................
[package tcr.parse-declarations-1.0]..............
[package cl-environments.util]....................
[package cl-environments.cltl2]...................
[package cl-environments-cl].;
; caught ERROR:
; READ error during COMPILE-FILE:
;
; Symbol "TRULY-DYNAMIC-EXTENT" not found in the SB-INT package.
;
; Line: 162, Column: 44, File-Position: 4648
;
; Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /Users/hunter/quicklisp/dists/quicklisp/software/cl-environments-20211020-git/src/other/sbcl.lisp" {7008B9A423}>
debugger invoked on a UIOP/LISP-BUILD:COMPILE-FILE-ERROR in thread
#<THREAD "main thread" RUNNING {70055206B3}>:
COMPILE-FILE-ERROR while
compiling #<CL-SOURCE-FILE "cl-environments" "src" "other/sbcl">
|
OK, as soon as I sent that, I noticed that the gcc commands for SBCL and ACL differ. The ACL one is missing the -lpython3.12 at the end. When I add that manually, it compiles. I think this must be configuration issue, and am investigating further…
|
More hints:
(software-type)
"64-bit Apple macOS 12.0 (Apple Silicon)”
And it appears your code is looking for “Darwin”…
… On Apr 27, 2024, at 2:53 PM, Larry Hunter ***@***.***> wrote:
OK, as soon as I sent that, I noticed that the gcc commands for SBCL and ACL differ. The ACL one is missing the -lpython3.12 at the end. When I add that manually, it compiles. I think this must be configuration issue, and am investigating further…
|
Looking further… software-type is not exported from UIOP, but closer-common-lisp (a CLOS compatibility layer) does expose it. Possibly better to use (uiop:operating-system) which returns :macos on my machine…
Hope this is enough for a patch.
Larry
… On Apr 27, 2024, at 3:00 PM, Larry Hunter ***@***.***> wrote:
More hints:
(software-type)
"64-bit Apple macOS 12.0 (Apple Silicon)”
And it appears your code is looking for “Darwin”…
> On Apr 27, 2024, at 2:53 PM, Larry Hunter ***@***.***> wrote:
>
>
> OK, as soon as I sent that, I noticed that the gcc commands for SBCL and ACL differ. The ACL one is missing the -lpython3.12 at the end. When I add that manually, it compiles. I think this must be configuration issue, and am investigating further…
>
>
|
Okay, great! And thanks for your reports, I will issue the fixes soon.
Oh right, py4cl2-cffi-tests has a number of lisp dependencies that need more recent versions than the one's in quicklisp. Sidestepping them, you can manually compile the Until we get a new quicklisp dist, you can either use ultralisp or download the dependencies using download-dependencies. /path/to/dependencies can be either quicklisp local projects or a more temporary directory. |
Great! There was an important typo in one of those emails. (Uiop:operating-system) returns :macosx. (Note x).
Didn’t know about ultralisp, I’ll give it a try when the fixes are ready.
Larry
… On Apr 27, 2024, at 3:57 PM, Shubhamkar Ayare ***@***.***> wrote:
Okay, great! And thanks for your reports, I will issue the fixes soon.
Well, this is interesting. I installed SBCL, and py4cl2-cffi loads without a hitch. I couldn’t run the tests though. I tried git clone https://github.com/digikar99/py4cl2-cffi-tests in the quicklsp local-distributions directory, and got the result at the end of this message. However, this suggests a problem with Allegro CL, not py4cl2-cffi. I’ll file a bug report with them and see if they have anything to say…
Oh right, py4cl2-cffi-tests has a number of lisp dependencies that need more recent versions than the one's in quicklisp. Sidestepping them, you can manually compile the defpymodule forms in the py4cl2-cffi-tests/package.lisp file and see if it produces the appropriate lisp packages and functions. I will also work on modularizing the tests further to see if these dependencies can be separated out.
Until we get a new quicklisp dist, you can either use ultralisp or download the dependencies using download-dependencies <https://github.com/digikar99/download-dependencies>. /path/to/dependencies can be either quicklisp local projects or a more temporary directory.
—
Reply to this email directly, view it on GitHub <#13 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AACWZKKVEUD3DJH6BWYSI33Y7RJSPAVCNFSM6AAAAABGRYXONGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBRGI4DSMRXG4>.
You are receiving this because you authored the thread.
|
I have split the tests now. You should be able to
Same behavior on amd64 Mac. And thanks for pointing to this one! I have replaced (software-type) with (uiop:operating-system). I just discovered |
Okay, a very simple cause and fix. 44f0784: Mask all the float traps while loading numpy. Tests pass now! (This is on the macos branch. I will merge into master soon.) |
Still trying to get the initial py4cl2-cffi macOS branch to work in my environment. Two things:
1. Made a pull request to get ride of the quote in the numpy-installed-p file — it screws up case sensitive lower lisps (who don’t define T, only t).
2. Still getting problems with the compile of py4cl-numpy-utils.c not finding the right (arm64) libraries. I think this is a configuration problem. The error looks like:
py4cl2-cffi> (may-be-compile-numpy-utils-shared-object)
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I'/opt/homebrew/lib/python3.12/site-packages/numpy/core/include/' -c -Wall -Werror -fpic py4cl-numpy-utils.c && gcc -shared -o libpy4cl-numpy-utils.so py4cl-numpy-utils.o
Undefined symbols for architecture x86_64:
"_PyCapsule_GetPointer", referenced from: …
A correct invocation would look like:
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I/opt/homebrew/lib/python3.12/site-packages/numpy/core/include/ -c -Wall -Werror -fpic py4cl-utils.c && gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/lib -shared -o libpy4cl-utils.so py4cl-utils.o -lpython3.12
Which works from the command line. Looks to me as if the library path is not being included properly (or at all). I couldn’t back out your configuration logic completely, so I don’t have a specific pull request yet. Also, I think your approach for naming looks like it should be generating libpy4cl-utils.dylib, not libpy4cl-utils.so — I’m not sure why that’s not working, and I might try a case statement instead of the object dispatch approach in shared-objects.lisp file. These might be useful in tracking this down:
py4cl2-cffi> *python-ldflags*
***@***.***/Frameworks/Python.framework/Versions/3.12/lib/python3.12/config-3.12-darwin"
"-lpython3.12" "-ldl" "-framework" "CoreFoundation”)
py4cl2-cffi> (shared-library-from-ldflag *python-ldflags* (intern (uiop:operating-system)
:keyword))
"lib(-ldl -framework CoreFoundation).dylib”
Thanks again for all your help with this (and for writing it in the first place!)
Larry
|
Is the config-darwin.lisp actually loading? It should be performing the configuration correctly. Is non-NIL Otherwise, I will make the dependence unconditional. And leave it up to the (when (eq :macosx (uiop:operating-system))
(configure))
|
On Apr 29, 2024, at 6:09 PM, Shubhamkar Ayare ***@***.***> wrote:
Still getting problems with the compile of py4cl-numpy-utils.c not finding the right (arm64) libraries. I think this is a configuration problem.
Is the config-darwin.lisp actually loading? It should be performing the configuration correctly. Is non-NIL (member :darwin cl:*features*) on your system? In py4cl2-cffi.asd, "py4cl2-cffi" depends on "py4cl2-cffi/config-darwin" only when the :darwin feature is present. May be this should be changed?
I believe config-darwin is loading.
cl-user> (member :darwin cl:*features*)
(:darwin :global-vars :thread-support :swank :quicklisp :asdf3.3
:asdf3.2 :asdf3.1 :asdf3 :asdf2 :asdf :has-lockf :has-mkdtemp :acldns
:os-macosx :os-unix :asdf-unicode :package-local-nicknames
:allegro-cl-enterprise :rfc8141 :rfc6874 :rfc3986
:has-clos-fixed-index-feature :ipv6 :acl-socket :hiper-socket
:profiler :|YACC Release 0.98| :compiler :use-structs-in-compiler
:clos :atomic-subword-setf :atomic-setf :verify-car-cdr :target-mac
:dynload :dlmac :unix :macosarm64 :macosx64 :macosx :macos :arm64
:jitcode :little-endian :encapsulating-efs :double-float-random-fix
:relative-package-names :module-versions :ieee :ieee-floating-point
:conforming-ieee :ics :common-lisp :ansi-cl :draft-ansi-cl-2 :x3j13
:allegro :excl :franz-inc :allegro-version>= :allegro-version=
:new-environments :flavors :multiprocessing :use-thread-libs
:allegro-v11.0 :fixnargs :64bit :smp-macros :ssl-support
:thread-resident-symbol-trampoline)
cl-user>
NB: I prefer FIND to MEMBER in these circumstances (less consing), but doesn’t really matter.
Otherwise, I will make the dependence unconditional. And leave it up to the (uiop:operating-system) to handle it correctly at the end of config-darwin.lisp.
(when (eq :macosx (uiop:operating-system))
(configure))
This does appear to be executing. NB: I think this (and any other lop level form) should be wrapped in a (eval-when (:compile-toplevel :load-toplevel :execute) … )
(shared-library-from-ldflag python-ldflags (intern (uiop:operating-system)
:keyword))
load-python-and-libraries in shared-objects.lisp calls %shared-library-from-ldflag only when the flag name starts with -l. So, these errors should not be arising, could you confirm?
There may be a case problem here. Sometimes the flag is -L and sometime -l. Maybe that’s the problem?
Larry
|
Ah, this should be it!
The -l flag is for the library, the -L flag is for the search paths. |
But, may be no, compile and load of config-darwin.lisp should both take place before shared-objects.lisp itself. I will try but don't expect it to change anything. |
Could you manually evaluate |
You might need to pull with the |
On Apr 29, 2024, at 6:36 PM, Shubhamkar Ayare ***@***.***> wrote:
I believe config-darwin is loading.
Could you manually evaluate (py4cl2-cffi/config-darwin::configure) to see if the configuration variables are incorrect. (I assume you are at the latest commit of macos branch.)
Maybe not, actually: :Darwin is on *features* but the config-darrwin file does not seem to be getting loaded…
local-projects % git clone https://github.com/digikar99/py4cl2-cffi --branch macos
Cloning into 'py4cl2-cffi'...
remote: Enumerating objects: 1348, done.
remote: Counting objects: 100% (758/758), done.
remote: Compressing objects: 100% (226/226), done.
remote: Total 1348 (delta 569), reused 674 (delta 503), pack-reused 590
Receiving objects: 100% (1348/1348), 356.56 KiB | 1.36 MiB/s, done.
Resolving deltas: 100% (872/872), done.
local-projects % lisp
International Allegro CL Enterprise Edition
11.0 [64-bit macOS (Apple Silicon)]
Copyright (C) 1985-2023, Franz Inc., Lafayette, CA, USA. All Rights Reserved.
This development copy of Allegro CL is licensed to:
[TC22861]
Note: Allegro CL will expire in 62 days, on June 30, 2024.
; Loading /Users/hunter/quicklisp/setup.lisp
; Fast loading
; /Applications/AllegroCL64.app/Contents/Resources/code/asdf.001
;;; Installing asdf patch, version 1.
; Autoloading for class synonym-stream:
; Fast loading from bundle code/streamc.fasl.
; Fast loading from bundle code/efft-utf-8s-base.fasl.
; Fast loading from bundle code/efft-utf8-base.fasl.
; Fast loading from bundle code/efft-void.fasl.
; Fast loading from bundle code/efft-latin1-base.fasl.
; Autoloading for package "excl.osi":
; Fast loading
; /Applications/AllegroCL64.app/Contents/Resources/code/osi.fasl
; Fast loading from bundle code/fileutil.fasl.
; Fast loading from bundle code/acldns.fasl.
; Fast loading from bundle code/iodefs.fasl.
; Fast loading from bundle code/iordefs.fasl.
; Fast loading from bundle code/efmacs.fasl.
;; Optimization settings: safety 1, space 1, speed 1, debug 2,
;; compilation-speed 1.
;; For a complete description of all compiler switches given the
;; current optimization settings evaluate (explain-compiler-settings).
;;---
;; Current reader case mode: :case-sensitive-lower
cl-user(1): (ql:quickload "py4cl2-cffi")
To load "py4cl2-cffi":
Load 1 ASDF system:
py4cl2-cffi
; Loading "py4cl2-cffi"
[package bordeaux-threads]........................
[package bordeaux-threads-2]......................
[package py4cl2-cffi/config]
("Python" "3.12.3" "")
***@***.***/Frameworks/Python.framework/Versions/3.12/lib/python3.12/config-3.12-darwin"
"-lpython3.12" "-ldl" "-framework" "CoreFoundation" "")
("Python" "3.12.3" "")
***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12"
***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12"
"")
("/opt/homebrew/bin/python" "")
(""
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python312.zip"
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12"
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload"
"/opt/homebrew/lib/python3.12/site-packages" "") ......................
[package py4cl2-cffi].
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c -Wall -Werror -fpic py4cl-utils.c && gcc -shared -o libpy4cl-utils.so py4cl-utils.o
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I'/opt/homebrew/lib/python3.12/site-packages/numpy/core/include/' -c -Wall -Werror -fpic py4cl-numpy-utils.c && gcc -shared -o libpy4cl-numpy-utils.so py4cl-numpy-utils.o
Undefined symbols for architecture arm64:
"_PyCapsule_GetPointer", referenced from:
__import_array in py4cl-numpy-utils.o
"_PyCapsule_Type", referenced from:
__import_array in py4cl-numpy-utils.o
"_PyErr_Format", referenced from:
__import_array in py4cl-numpy-utils.o
__import_array in py4cl-numpy-utils.o
"_PyErr_Print", referenced from:
_import_numpy in py4cl-numpy-utils.o
"_PyErr_SetString", referenced from:
_import_numpy in py4cl-numpy-utils.o
__import_array in py4cl-numpy-utils.o
__import_array in py4cl-numpy-utils.o
__import_array in py4cl-numpy-utils.o
__import_array in py4cl-numpy-utils.o
"_PyExc_ImportError", referenced from:
_import_numpy in py4cl-numpy-utils.o
"_PyExc_RuntimeError", referenced from:
__import_array in py4cl-numpy-utils.o
"_PyImport_ImportModule", referenced from:
__import_array in py4cl-numpy-utils.o
"_PyObject_GetAttrString", referenced from:
__import_array in py4cl-numpy-utils.o
"__Py_Dealloc", referenced from:
__import_array in py4cl-numpy-utils.o
__import_array in py4cl-numpy-utils.o
__import_array in py4cl-numpy-utils.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
; While evaluating an unknown function at top level:
Error: Subprocess with command "gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I'/opt/homebrew/lib/python3.12/site-packages/numpy/core/include/' -c -Wall -Werror -fpic py4cl-numpy-utils.c && gcc -shared -o libpy4cl-numpy-utils.so py4cl-numpy-utils.o"
exited with error code 1
[condition type: subprocess-error]
Problem detected when processing
(let* ...)
inside (excl:compiler-let ...)
inside (eval-when (:compile-toplevel :load-toplevel) ...)
Restart actions (select using :continue):
0: IGNORE-ERROR-STATUS
1: retry the compilation of /Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/shared-objects.lisp
2: continue compiling
/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/shared-objects.lisp
but generate no output file
3: Retry compiling #<cl-source-file "py4cl2-cffi" "shared-objects">.
4: Continue, treating
compiling #<cl-source-file "py4cl2-cffi" "shared-objects"> as
having been successful.
5: Retry ASDF operation.
6: Retry ASDF operation after resetting the configuration.
7: Give up on "py4cl2-cffi"
8: Register local projects and try again.
9: Return to Top Level (an "abort" restart).
10: Abort entirely from this (lisp) process.
[changing package from "common-lisp-user" to "py4cl2-cffi"]
[1c] py4cl2-cffi(2): (py4cl2-cffi/config-darwin::configure)
Error: Package "py4cl2-cffi/config-darwin" not found.
[condition type: reader-error]
Problem detected when processing
(let* ...)
inside (excl:compiler-let ...)
inside (eval-when (:compile-toplevel :load-toplevel) ...)
Restart actions (select using :continue):
0: Return to Debug Level 1 (an "abort" restart).
1: IGNORE-ERROR-STATUS
2: retry the compilation of /Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/shared-objects.lisp
3: continue compiling
/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/shared-objects.lisp
but generate no output file
4: Retry compiling #<cl-source-file "py4cl2-cffi" "shared-objects">.
5: Continue, treating
compiling #<cl-source-file "py4cl2-cffi" "shared-objects"> as
having been successful.
6: Retry ASDF operation.
7: Retry ASDF operation after resetting the configuration.
8: Give up on "py4cl2-cffi"
9: Register local projects and try again.
10: Return to Top Level (an "abort" restart).
11: Abort entirely from this (lisp) process.
[2] py4cl2-cffi(3): (find :darwin cl:*features*)
:darwin
[2] py4cl2-cffi(4):
|
Okay, with 58bfb34, config-darwin should load unconditionally now. There are other errors now which I'm looking into. Between 61cc8ef and 53402f3, something changed which is leading to memory fault during (py4cl2-cffi:pystart) in the presence of numpy. |
It appears that the Let me know the output of this: (in-package :py4cl2-cffi/config-darwin)
(when (print (eq :macosx (print (uiop:operating-system))))
(configure)) |
Oh right, I haven’t download yesterday’s fixes…. Hold on. I have some meetings coming up, and won't be able to get back to this for a couple of hours. I’ll do a git update and try again then.
… On Apr 30, 2024, at 7:22 AM, Shubhamkar Ayare ***@***.***> wrote:
It appears that the (py4cl2-cffi/config-darwin::configure) function is still not being called.
Let me know the output of this:
(in-package :py4cl2-cffi/config-darwin)
(when (print (eq :macosx (print (uiop:operating-system))))
(configure))
—
Reply to this email directly, view it on GitHub <#13 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AACWZKMD7BNBS3OD5KXQ7U3Y77HNVAVCNFSM6AAAAABGRYXONGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBWGEYDEMZXGI>.
You are receiving this because you authored the thread.
|
Alright, test it whenever you are free next. Hoping it works for you! |
The good news is the latest update fixes the numpy-utils compilation problem! I still get a warning when compiling numpy-utils, but it seems to work:
ld: warning: ignoring file ***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/Python': found architecture 'arm64', required architecture 'x86_64'
Bad news is we are not done yet.
Next problem is
Error: Attempt to take the value of the unbound variable
`+python-function-reference-type-alist+'.
[condition type: unbound-variable]
Problem detected when processing
(pyforeign-funcall "Py_IncRef" :pointer pyobject-pointer)
when compiling. That’s because you evaluate it when defining the macro pyforeign-funcall. Fix this by wrapping the defconstant with eval-when:
(eval-when (:load-toplevel :compile-toplevel :execute)
(define-constant +python-function-reference-type-alist+
'(("Py_Initialize" nil)
...
("PY4CL_PyArray_FromArray" :new))
:test #'equal))
After fixing that, I get
While file-compiling
#'(:top-level-form
"/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/pythonizers.lisp"
2494)
in
#P"/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/pythonizers.lisp"
; starting at file character position 2494:
Error: t fell through a etypecase form. The valid cases were
(eql float-features::T) and list.
[condition type: case-failure]
This is a bug in float-features (where there’s a T instead of a t in the definition of the macro with-float-traps-masked. I filed a pull request to that repo.
Then, I got an error when loading the compiled pythonizers file. This one still mystifies me…
(ql:quickload "py4cl2-cffi")
To load "py4cl2-cffi":
Load 1 ASDF system:
py4cl2-cffi
; Loading "py4cl2-cffi"
[package bordeaux-threads]........................
[package bordeaux-threads-2]......
("Python" "3.12.3" "")
***@***.***/Frameworks/Python.framework/Versions/3.12/lib/python3.12/config-3.12-darwin"
"-lpython3.12" "-ldl" "-framework" "CoreFoundation" "")
***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12"
***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12"
"")
("/opt/homebrew/bin/python" "")
(""
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python312.zip"
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12"
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload"
"/opt/homebrew/lib/python3.12/site-packages" "") ................
[package py4cl2-cffi]..
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c -Wall -Werror -fpic py4cl-utils.c && gcc ***@***.***/Frameworks/Python.framework/Versions/3.12//lib' -framework CoreFoundation -shared -o libpy4cl-utils.so py4cl-utils.o -lpython3.12
......
Error: No class named: foreign-pointer.
[condition type: program-error]
It seems to have a type definition:
py4cl2-cffi> (describe 'foreign-pointer)
foreign-pointer is a tenured symbol.
It is unbound.
It is external in the cffi-sys package and exported from the cffi
package and accessible in the py4cl2-cffi package.
Its property list has these indicator/value pairs:
excl::deftype-expander #<Function (excl::deftype-expander
foreign-pointer)>
; No value
But calling
py4cl2-cffi> (find-class 'foreign-pointer)
Generates the No class named…error. Ideas?
Larry
|
|
Otherwise, I could merge the pythonize method dispatching over foreign-pointer into its default method. This would be a much portable solution. |
I believe in ACL it would be ff:foreign-pointer
(find-class 'ff:foreign-pointer)
#<standard-class foreign-functions:foreign-pointer>
See https://franz.com/support/documentation/10.1/doc/foreign-functions.htm
Larry
… On Apr 30, 2024, at 6:09 PM, Shubhamkar Ayare ***@***.***> wrote:
(find-class 'foreign-pointer)
pythonize defined in pythonizers.lisp is a generic function. One of its methods dispatches over the class corresponding to foreign-pointer. On SBCL, this is sb-sys:system-area-pointer. Could you find an equivalent class on Allegro CL? typexpand or type-expand or equivalent should be useful for this, or the Allegro CL documentation, or their support channels.
—
Reply to this email directly, view it on GitHub <#13 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AACWZKNBAWKPJUQBD67SQU3ZABTI7AVCNFSM6AAAAABGRYXONGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBXHE2DMNBTGU>.
You are receiving this because you authored the thread.
|
Sorry, outdated documentation pointer. Current version (largely the same) is here https://franz.com/support/documentation/11.0/foreign-functions.html
… On Apr 30, 2024, at 3:40 PM, Larry Hunter ***@***.***> wrote:
The good news is the latest update fixes the numpy-utils compilation problem! I still get a warning when compiling numpy-utils, but it seems to work:
ld: warning: ignoring file ***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/Python': found architecture 'arm64', required architecture 'x86_64'
Bad news is we are not done yet.
Next problem is
Error: Attempt to take the value of the unbound variable
`+python-function-reference-type-alist+'.
[condition type: unbound-variable]
Problem detected when processing
(pyforeign-funcall "Py_IncRef" :pointer pyobject-pointer)
when compiling. That’s because you evaluate it when defining the macro pyforeign-funcall. Fix this by wrapping the defconstant with eval-when:
(eval-when (:load-toplevel :compile-toplevel :execute)
(define-constant +python-function-reference-type-alist+
'(("Py_Initialize" nil)
...
("PY4CL_PyArray_FromArray" :new))
:test #'equal))
After fixing that, I get
While file-compiling
#'(:top-level-form
"/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/pythonizers.lisp"
2494)
in
#P"/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/pythonizers.lisp"
; starting at file character position 2494:
Error: t fell through a etypecase form. The valid cases were
(eql float-features::T) and list.
[condition type: case-failure]
This is a bug in float-features (where there’s a T instead of a t in the definition of the macro with-float-traps-masked. I filed a pull request to that repo.
Then, I got an error when loading the compiled pythonizers file. This one still mystifies me…
(ql:quickload "py4cl2-cffi")
To load "py4cl2-cffi":
Load 1 ASDF system:
py4cl2-cffi
; Loading "py4cl2-cffi"
[package bordeaux-threads]........................
[package bordeaux-threads-2]......
("Python" "3.12.3" "")
***@***.***/Frameworks/Python.framework/Versions/3.12/lib/python3.12/config-3.12-darwin"
"-lpython3.12" "-ldl" "-framework" "CoreFoundation" "")
***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12"
***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12"
"")
("/opt/homebrew/bin/python" "")
(""
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python312.zip"
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12"
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload"
"/opt/homebrew/lib/python3.12/site-packages" "") ................
[package py4cl2-cffi]..
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c -Wall -Werror -fpic py4cl-utils.c && gcc ***@***.***/Frameworks/Python.framework/Versions/3.12//lib' -framework CoreFoundation -shared -o libpy4cl-utils.so py4cl-utils.o -lpython3.12
......
Error: No class named: foreign-pointer.
[condition type: program-error]
It seems to have a type definition:
py4cl2-cffi> (describe 'foreign-pointer)
foreign-pointer is a tenured symbol.
It is unbound.
It is external in the cffi-sys package and exported from the cffi
package and accessible in the py4cl2-cffi package.
Its property list has these indicator/value pairs:
excl::deftype-expander #<Function (excl::deftype-expander
foreign-pointer)>
; No value
But calling
py4cl2-cffi> (find-class 'foreign-pointer)
Generates the No class named…error. Ideas?
Larry
|
This still remains.
Done.
Done. I have pushed these changes to the macos branch. Let me know if this works. |
I think there might be other places which require wrapping in eval-when too. I will check with asdf:compile-system and get back. |
Possibly. This should usually just be for top level forms that are not definitions (e.g. start def*). However, you also have to watch out for things used by macros (which evaluate at unusual times). I think there are a couple of eval-when wrappers you could get rid of….
… On Apr 30, 2024, at 7:01 PM, Shubhamkar Ayare ***@***.***> wrote:
I think there might be other places which require wrapping in eval-when too. I will check with asdf:compile-system and get back.
—
Reply to this email directly, view it on GitHub <#13 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AACWZKPKKYRE4JFDSHAXVHTZABZLFAVCNFSM6AAAAABGRYXONGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBXHE4DANZQGE>.
You are receiving this because you authored the thread.
|
Turns out the maintainer of float-features is not going to fix the bug…
… Begin forwarded message:
From: Yukari Hafner ***@***.***>
Subject: Re: [Shinmera/float-features] Fixed bug for case-sensitive lisp readers (PR #35)
Date: April 30, 2024 at 8:35:21 PM HST
To: Shinmera/float-features ***@***.***>
Cc: Larry Hunter ***@***.***>, Author ***@***.***>
Reply-To: Shinmera/float-features ***@***.***>
I've rejected all of these kinds of "fixes" for all of my libraries and will continue to do so. I have good reason to capitalise constants in code, and I'm not going to stop doing it. It is not my responsibility to cater my code to your customisations to the default environment. Just the same as I'm not going to account for changes to *read-base* even if it is "ANSI standard", I'm not going to account for changes to the read case.
|
Turns out their license is permissive enough to adapt their code to our needs with appropriate acknowledgements. |
OK, making some progress. The current macOS branch of py4cl2-cffi quickloads. After fixing case-mode bugs in clunit and iterate, I’ve gotten the tests-lite to load. But it fails immediately because calls to pystart fail with "attempt to call `system::ff-funcall' which is an undefined function.” This in turn comes from mkfifo, which calls cffi:foreign-function At this point, I am stalled. Ideas?
Larry
|
I wonder what an appropriate configuration for ASDF would be to let it use the case insensitive readtable by default, and any other custom readtable only when a user explicitly specifies so. I have also wanted package local readtables, but I don't see any good way other that dirty patching the lisp system to redefine certain core functions like read and compile. Or creating a shadowing CL package which acknowledges this. Well, I guess I can include that in peltadot - I already have a shadowing CL package there, including a shadowing compile function. About the system::ff-funcall, can you check if it's possible to cffi:foreign-funcall for any other foreign function? If that does not work, may be CFFI might need to be updated for Allegro CL. But I doubt it could be as grave as that! Certainly, other Allegro CL users must be using CFFI, so it should be up to date. PS: It will be another 2-3 days before I continue development. Some non-lisp tasks require my attention. |
Interesting. I think it’s mostly a matter of testing, rather than trying for package-local read tables (which seem heavy duty, but doable). The problems in clunit and iterate were simple and easy to find (using all caps in case-insensitive lisps is a dead giveaway). I don’t mind living with local installs of these that I fix myself, although I will submit pull requests to the repositories and see if they are more open minded than the float-features guy.
I haven’t started looking at cffi — this looks like it might be a simple config issue. I can poke around for the next few days and see what I find. I’m also doing this as a side project, I totally understand.
… On May 1, 2024, at 4:54 PM, Shubhamkar Ayare ***@***.***> wrote:
I wonder what an appropriate configuration for ASDF would be to let it use the case insensitive readtable by default, and any other custom readtable only when a user explicitly specifies so.
I have also wanted package local readtables, but I don't see any good way other that dirty patching the lisp system to redefine certain core functions like read and compile. Or creating a shadowing CL package which acknowledges this. Well, I guess I can include that in peltadot <https://gitlab.com/digikar/peltadot> - I already have a shadowing CL package there, including a shadowing compile function.
About the system::ff-funcall, can you check if it's possible to cffi:foreign-funcall for any other foreign function? If that does not work, may be CFFI might need to be updated for Allegro CL. But I doubt it could be as grave as that! Certainly, other Allegro CL users must be using CFFI, so it should be up to date.
PS: It will be another 2-3 days before I continue development. Some non-lisp tasks require my attention.
—
Reply to this email directly, view it on GitHub <#13 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AACWZKKJARW3WQTSMUEHWX3ZAGTH3AVCNFSM6AAAAABGRYXONGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBZGQ2DCMJQHA>.
You are receiving this because you authored the thread.
|
Looking more into cffi, and it does appear to be broken on Allegro 11, and it’s not a case issue. I’ve come up with a fix (I wasn’t the only person who had a problem, see cffi/cffi#381
But now we are back to the problem of apparently getting the wrong architecture somewhere in building libpy4cl-utils. I’m calling it a day, and will investigate further soon.
Unable to load foreign library (LIBPY4CL-UTILS.SO-80577).
Loading
/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.so
failed with error:
dlopen(/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.so, 0x000A): tried: ***@***.***/lib/libpy4cl-utils.so' (no such file), '/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.so' (no such file), '/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')).
[Condition of type cffi:load-foreign-library-error]
|
Next step: I’ve gotten the compiles of libpy4cl-utils and libpy4cl-numpy-utils to work from the command line. Here’s what seems to work (note -dynamiclib instead of -shared, and .dylib suffixes)
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c -Wall -Werror -fPIC py4cl-utils.c && gcc -dynamiclib -o libpy4cl-utils.dylib py4cl-utils.o
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I/opt/homebrew/lib/python3.12/site-packages/numpy/core/include -c -Wall -Werror -fPIC py4cl-numpy-utils.c && gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/lib -framework CoreFoundation -dynamiclib -o libpy4cl-numpy-utils.dylib py4cl-numpy-utils.o -lpython3.12
These dylibs load into lisp without complaint:
py4cl2-cffi> (load-foreign-library "/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.dylib")
; Foreign loading /Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.dylib.
#<foreign-library LIBPY4CL-UTILS.DYLIB-88074 "libpy4cl-utils.dylib">
py4cl2-cffi> (load-foreign-library "/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-numpy-utils.dylib")
; Foreign loading /Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-numpy-utils.dylib.
#<foreign-library
LIBPY4CL-NUMPY-UTILS.DYLIB-88662 "libpy4cl-numpy-utils.dylib">
py4cl2-cffi>
At this point, I think I need your help to figure out how to modify your config, loading and startup code to reproduce these within your system. If I load those dylibs, set *python-libraries-loaded-p* to t, and call (pystart), it fails. it calls your (load-python-and-libraries),which goes looking for the wrong files.
Python’s {sys.exec_prefix} returns ***@***.***/Frameworks/Python.framework/Versions/3.12 so it should be pretty straightforward, but I am worried about breaking backward compatibility, so I didn’t try adjusting your code myself.
I think we are getting close!
Larry
… On May 1, 2024, at 8:08 PM, Larry Hunter ***@***.***> wrote:
Looking more into cffi, and it does appear to be broken on Allegro 11, and it’s not a case issue. I’ve come up with a fix (I wasn’t the only person who had a problem, see cffi/cffi#381
But now we are back to the problem of apparently getting the wrong architecture somewhere in building libpy4cl-utils. I’m calling it a day, and will investigate further soon.
Unable to load foreign library (LIBPY4CL-UTILS.SO-80577).
Loading
/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.so
failed with error:
dlopen(/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.so, 0x000A): tried: ***@***.***/lib/libpy4cl-utils.so' (no such file), '/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.so' (no such file), '/Users/hunter/quicklisp/local-projects/py4cl2-cffi/src/libpy4cl-utils.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')).
[Condition of type cffi:load-foreign-library-error]
|
Sorry, it took me longer than expected!
To me, PLRT seem cleaner. Plus, they also allow one to use their favourite syntax modifications without bothering others. But yes, I do agree they seem heavy.
So, they did matter! Thanks a lot. I have pushed the fix in 9da26b1.
Is 9da26b1 the fix you were thinking about, or were you pointing to something else? |
The CI fix for macos/amd64 couldn't have been sillier. I had reported that I was able to get the tests to pass on macos on the amd64 VPS from HostMyMac, but the CI kept failing for amd64 macos on github actions. I have been able to get the CI pass on amd64 macos too. 9dbf4cb With that, I think the changes and fixes in the macos branch can be merged into master. I can see that the CI passes. Could you test it locally on SBCL and confirm? I'll create a separate branch for case sensitive lisp. Allegro CL can only proceed once CFFI gets fixed, right? |
On May 7, 2024, at 12:26 PM, Shubhamkar Ayare ***@***.***> wrote:
Is 9da26b1 <9da26b1> the fix you were thinking about, or were you pointing to something else?
It didn’t work, still had issues using the wrong architecture libraries:
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c -Wall -Werror -fpic py4cl-utils.c && gcc ***@***.***/Frameworks/Python.framework/Versions/3.12//lib' -framework CoreFoundation -dynamiclib -o libpy4cl-utils.dylib py4cl-utils.o -lpython3.12
ld: warning: ignoring file ***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/Python': found architecture 'arm64', required architecture 'x86_64'
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c -Wall -Werror -fpic py4cl-utils.c && gcc ***@***.***/Frameworks/Python.framework/Versions/3.12//lib' -framework CoreFoundation -dynamiclib -o libpy4cl-utils.dylib py4cl-utils.o -lpython3.12
ld: warning: ignoring file ***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/Python': found architecture 'arm64', required architecture 'x86_64'
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I'/opt/homebrew/lib/python3.12/site-packages/numpy/core/include/' -c -Wall -Werror -fpic py4cl-numpy-utils.c && gcc ***@***.***/Frameworks/Python.framework/Versions/3.12//lib' -framework CoreFoundation -dynamiclib -o libpy4cl-numpy-utils.dylib py4cl-numpy-utils.o -lpython3.12
ld: warning: ignoring file ***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/Python': found architecture 'arm64', required architecture 'x86_64'
Undefined symbols for architecture x86_64:
"_PyCapsule_GetPointer", referenced from:
__import_array in py4cl-numpy-utils.o
…
You can force the issue with
arch -arm64 gcc …
Which does work. Alternatively, maybe there’s a way to specify ***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload instead of ***@***.***/Frameworks/Python.framework/Versions/3.12//lib which might fix it more cleanly (NB: maybe also track down why the //?)
Regardless, you should probably conditionalize not to break on x86_64 machines
Larry
|
I tested on SBCL and (aside from not having networkx, which I just commented out), all the py4cl2-cffi-tests-lite pass.
The Allegro cffi fix may have life (see cffi/cffi#381). A local fix is easy enough (1 character change).
|
...
Do you mean SBCL too requires lib-dynload instead of lib? Or did it pass without the lib-dynload fix? I tried replacing lib with lib-dynload in de3dde8 but both SBCL / Mac OS 14 / arm64 and SBCL / Mac OS 13 / amd64 fail on Github Actions. In a0e015b, I'm now looking up lib-dynload first and then lib after that, expecting gcc to mind the order. Even if this does pass for you, that makes me curious when or why some systems might use lib-dynload and some others only lib? |
On May 9, 2024, at 10:34 AM, Shubhamkar Ayare ***@***.***> wrote:
Do you mean SBCL too requires lib-dynload instead of lib? Or did it pass without the lib-dynload fix?
It was a fresh install of the macOS branch. The only thing I did to the code was comment out the Networkx test, since I don’t have it. The current code seems to include the lib-dynload fix, but produces warnings that it is not found.
local-projects % rm -rf py4cl*
local-projects % git clone https://github.com/digikar99/py4cl2-cffi -b macos
Cloning into 'py4cl2-cffi'...
remote: Enumerating objects: 1445, done.
remote: Counting objects: 100% (428/428), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 1445 (delta 388), reused 370 (delta 355), pack-reused 1017
Receiving objects: 100% (1445/1445), 363.63 KiB | 2.26 MiB/s, done.
Resolving deltas: 100% (942/942), done.
local-projects % git clone https://github.com/digikar99/py4cl2-cffi-tests
Cloning into 'py4cl2-cffi-tests'...
remote: Enumerating objects: 60, done.
remote: Counting objects: 100% (60/60), done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 60 (delta 34), reused 44 (delta 18), pack-reused 0
Receiving objects: 100% (60/60), 19.58 KiB | 4.89 MiB/s, done.
Resolving deltas: 100% (34/34), done.
local-projects % # here I comment out the Networkx test...
zsh: command not found: #
local-projects % sbcl
This is SBCL 2.4.0, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (load "~/quicklisp/setup.lisp")
T
* (ql:quickload :py4cl2-cffi)
To load "py4cl2-cffi":
Load 1 ASDF system:
py4cl2-cffi
; Loading "py4cl2-cffi"
..................................................
[package py4cl2-cffi/config].
("Python" "3.12.3" "")
***@***.***/Frameworks/Python.framework/Versions/3.12/lib/python3.12/config-3.12-darwin"
"-lpython3.12" "-ldl" "-framework" "CoreFoundation" "")
("Python" "3.12.3" "")
***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12"
***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12"
"")
("/opt/homebrew/bin/python" "")
(""
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python312.zip"
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12"
***@***.***/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload"
"/opt/homebrew/lib/python3.12/site-packages"
"/opt/homebrew/Cellar/python-matplotlib/3.8.4/libexec/lib/python3.12/site-packages"
"") .....................
[package py4cl2-cffi/config-darwin]...............
[package py4cl2-cffi]..
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c -Wall -Werror -fpic py4cl-utils.c && gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/lib-dynload' ***@***.***/Frameworks/Python.framework/Versions/3.12/lib' -framework CoreFoundation -dynamiclib -o libpy4cl-utils.dylib py4cl-utils.o -lpython3.12
ld: warning: search path ***@***.***/Frameworks/Python.framework/Versions/3.12/lib-dynload' not found
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c -Wall -Werror -fpic py4cl-utils.c && gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/lib-dynload' ***@***.***/Frameworks/Python.framework/Versions/3.12/lib' -framework CoreFoundation -dynamiclib -o libpy4cl-utils.dylib py4cl-utils.o -lpython3.12
ld: warning: search path ***@***.***/Frameworks/Python.framework/Versions/3.12/lib-dynload' not found
gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 ***@***.***/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I'/opt/homebrew/lib/python3.12/site-packages/numpy/core/include/' -c -Wall -Werror -fpic py4cl-numpy-utils.c && gcc ***@***.***/Frameworks/Python.framework/Versions/3.12/lib-dynload' ***@***.***/Frameworks/Python.framework/Versions/3.12/lib' -framework CoreFoundation -dynamiclib -o libpy4cl-numpy-utils.dylib py4cl-numpy-utils.o -lpython3.12
ld: warning: search path ***@***.***/Frameworks/Python.framework/Versions/3.12/lib-dynload' not found
...........................
...................
(:PY4CL2-CFFI)
* (ql:quickload "py4cl2-cffi-tests-lite")
To load "py4cl2-cffi-tests-lite":
Load 1 ASDF system:
py4cl2-cffi-tests-lite
; Loading "py4cl2-cffi-tests-lite"
[package math]....................................
[package np]......................................
[package numpy.random]............................
[package numpy.random.bit-generator]..............
[package numpy.random.mtrand].....................
[package plt].....................................
[package py4cl2-cffi-tests].......................
.................
("py4cl2-cffi-tests-lite")
*
|
So, lib-dynload is unnecessary and we can delete it? And does it work on Allegro now after you make the CFFI fix? |
With 65111b3, MacOS specific fixes have been merged into master. Thanks a lot for your tests and reports! I have started a separate branch readtable-case with fixes pertaining to case-sensitive readtable. Merging this requires figuring out the best way to handle readtable-case and setting up the CI. |
Still having some issues, alas.
1. What you did to try to get Allegro to push :darwin onto *features* didn’t quite work. Doesn’t load config-darwin the way you have it. If I push :darwin onto *features* before quickloading py4cl2-cffi, it works.
2. Config-darwin is still trying to add the lib-dynload libraries, which causes an error. When I remove that (and the associated format argument), everything compiles. (Although I note it still shows up in *python-site-libraries*)
Those two are easy to fix. However, if I fix them manually, tests fail immediately with a locked up lisp. Best I can tell, the error happens during this call:
(raw-pyexec "sys.stdout = open('/tmp/py4cl2-cffi-output-2322', 'w')”)
The error message in lisp is
opening #P"/tmp/py4cl2-cffi-output-2322" resulted in
error: Interrupted system call [errno=4].
Odd. Doesn’t seem to be a permissions issue.
py4cl2-cffi % ls -l /tmp/py4cl2-cffi-output-2322
prw-r--r-- 1 hunter wheel 0 May 13 17:26 /tmp/py4cl2-cffi-output-2322
Wondering if you have any thoughts…
|
Should be fixed by 307a121.
I assume you are referring to the lib-dynload path not found warning. 18349a1 should fix it.
*python-site-packages-path* - this variable is being set using the information provided by python3 in the environment itself. I certainly expect there are no newlines in the pathnames.
The '#P' indicates the error must stem from a lisp code. I suspect it is from these lines of code. This is called from the (python-output-thread) call just above the line of code you pointed out. The named pipe itself is created quite early. So, this is indeed mysterious. Let me know if changing the value of *py-output-stream-pipe* and *py-error-output-stream-pipe* to some other locations help. They are set here. If so, I could move them to the config system/package. The hanging probably occurs because, normally:
So, if 2 fails, the main thread will keep waiting and that is, perhaps, what causes the lock-up. |
I just noted that cl-travis supports AllegroCL for CI. I guess I could try that here too. |
Nope, haven't been able to debug why Allegro freezes on Github Actions - most likely, I'm passing the wrong command line options, but I haven't been able to figure out what the correct ones are. I wonder if it differs from platform to platform. About m1 mac in cloud, Amazon EC2 pricing for M1 is off the charts. Scaleway, Hetzner, and HostMyApple all seem reasonable, but with their own peculiarities. The first two also offer on-demand hourly (or rather min. 24 hours) pricing at about 0.11 euro/hour (= 2.64 euro/day). HostMyApple only offers monthly plans, starting at 70 USD/month for M1 Mac. But that seems wasteful because I would never use it for an entire month, not even 15 days. The bad news might be about sponsor platforms.
|
As a happy user of py4cl2 who wants to move some large arrays around, I thought I might try porting py4cl2-cffi to Allegro CL 11 / MacOS 14 / Apple silicon (M2). I've made some progress, but also hit a dead end. I'm trying to install via quicklisp.
First issue was this error:
While file-compiling #'"An Anonymous Function"
in
#P"/Users/hunter/quicklisp/dists/quicklisp/software/py4cl2-cffi-20231021-git/src/numpy-installed-p.lisp"
; between file character positions 0 (inclusively) and 3 (exclusively):
Error: Package "CL" not found.
The file just contains "CL:T". ACL doesn't define CL, and T is defined in every package. I'm using a case sensitive lisp, so I just replaced the contents of the file with "t". Works, although I'm not sure how that file gets created, so can't completely fix things.
Next up was
Subprocess with command "gcc -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I'/Users/hunter/quicklisp/dists/quicklisp/software/py4cl2-cffi-20231021-git/src/' -c -Wall -Werror -fpic py4cl-utils.c && gcc -shared -o libpy4cl-utils.so py4cl-utils.o"
exited with error code 1
Not sure what configuration changes would be necessary to run this in the correct directory, but compiling manually after substituting the full pathname "~/quicklisp/dists/quicklisp/software/py4cl2-cffi-20231021-git/src/py4cl-utils.c" worked.
Next problem was that modern MacOS doesn't provide endian.h So, following https://stackoverflow.com/questions/20813028/endian-h-not-found-on-mac-osx/52904079#52904079 I put https://gist.github.com/dendisuhubdy/19482135d26da86cdcf442b3724e0728 into /usr/local/include/endian.h and that worked.
Next problem was that the includes of numpy/ndarraytypes.h and numpy/arrayobject.h in py4cl-utils.c failed. I used (py4cl2:raw-pyeval "np.get_include()") to discover that the files were in ~/mambaforge/lib/python3.10/site-packages/numpy/core/include" so I could fix that manually, but didn't actually fix the configuration issue.
Finally, the linker complained about a bunch of missing symbols for the arm64 architecture, and here I am out of my depth. Error is below, any suggestions much appreciated.
gcc -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.12/include/python3.12 -I'/Users/hunter/quicklisp/dists/quicklisp/software/py4cl2-cffi-20231021-git/src/' -c -Wall -Werror -fpic py4cl-utils.c && gcc -shared -o libpy4cl-utils.so py4cl-utils.o
Undefined symbols for architecture arm64:
"_PyCapsule_GetPointer", referenced from:
__import_array in py4cl-utils.o
"_PyCapsule_Type", referenced from:
__import_array in py4cl-utils.o
"_PyErr_Format", referenced from:
__import_array in py4cl-utils.o
__import_array in py4cl-utils.o
__import_array in py4cl-utils.o
__import_array in py4cl-utils.o
"_PyErr_Print", referenced from:
_import_numpy in py4cl-utils.o
"_PyErr_SetString", referenced from:
_import_numpy in py4cl-utils.o
__import_array in py4cl-utils.o
__import_array in py4cl-utils.o
__import_array in py4cl-utils.o
"_PyExc_AttributeError", referenced from:
__import_array in py4cl-utils.o
"_PyExc_ImportError", referenced from:
_import_numpy in py4cl-utils.o
"_PyExc_RuntimeError", referenced from:
__import_array in py4cl-utils.o
"_PyImport_ImportModule", referenced from:
__import_array in py4cl-utils.o
"_PyObject_GetAttrString", referenced from:
__import_array in py4cl-utils.o
"__Py_Dealloc", referenced from:
__import_array in py4cl-utils.o
__import_array in py4cl-utils.o
__import_array in py4cl-utils.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
src %
The text was updated successfully, but these errors were encountered: