Re: Calling Lisp from C (SBCL as a shared object) on Windows
Uģis Lācis <[email protected]> Fri, 28 Mar 2025 11:57:56 +0000
| Newsgroups | gmane.lisp.steel-bank.general |
|---|---|
| Message-ID | <GVZP280MB0602277B265A336086D7A18190A02@GVZP280MB0602.SWEP280.PROD.OUTLOOK.COM> |
Thanks! Tried it, still seems to fail the same as the second patch ...
//entering make-target-2.sh
//doing warm init - compilation phase
This is SBCL 2.5.2.161-1abc2d5f6-WIP, 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.
Initial page table:
| Immobile Objects |
Gen layout symbol code Boxed Cons Raw Code SmMix Mixed LgRaw LgCode LgMix Waste% Alloc Trig Dirty GCs Mem-age
6 549 25872 20740 0 127 0 0 0 485 0 0 0 0.2 20021376 2000000 0 0 0.0000
Tot 549 25872 20740 0 127 0 0 0 485 0 0 0 0.2 20021376 [1.9% of 1073741824 max]
[long list of Chinese symbols]
Exception Code: 00000000C0000374.
Faulting IP: 00007FFB5B4AB035.
fatal error encountered in SBCL pid 2929228304:
Exception too early in cold init, cannot continue.
Welcome to LDB, a low-level debugger for the Lisp runtime environment.
ldb> exit
Argh! lossage_handler() returned, total confusion..
real 4m34.068s
user 0m0.030s
sys 0m0.077s
-----Original Message-----
From: Stas Boukarev <[email protected]>
Sent: Friday, 28 March 2025 12:28
To: Uģis Lācis <[email protected]>
Cc: [email protected]
Subject: Re: [Sbcl-help] Calling Lisp from C (SBCL as a shared object) on Windows
Try the final patch then:
https://github.com/stassats/sbcl/commit/53654beb03cb7f7ec032d816868dcd4bd4e4bf89
On Fri, Mar 28, 2025 at 1:43 PM Uģis Lācis <[email protected]> wrote:
>
> Hi Stas,
>
> Thanks a lot for a quick reply. I tried both of your patches, but unfortunately SBCL did not want to build anymore (it seems it fails at some cross-compilation stage, if I am not mistaken). For the first patch, this is where my build process dies:
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> - ; wrote
> C:/msys64/home/ugis.lacis/sbcl_patched/obj/from-host/src/compiler/gene
> ric/genesis.fasl-tmp
> ; compilation finished in 0:00:00.966
> While evaluating the form starting at line 11, column 0
> of #P"C:/msys64/home/ugis.lacis/sbcl_patched/make-genesis-2.lisp":
>
> debugger invoked on a HOST-SB-EXT:FILE-DOES-NOT-EXIST in thread
> #<THREAD tid=16816 "main thread" RUNNING {1100BA8133}>:
> The file #P"C:/msys64/home/ugis.lacis/sbcl_patched/output/tls-init.lisp-expr"
> does not exist:
> The system cannot find the file specified.
>
> Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
>
> restarts (invokable by number or by possibly-abbreviated name):
> 0: [CREATE ] Reopen with :if-does-not-exist :create
> 1: [CONTINUE ] Retry opening.
> 2: [USE-VALUE ] Try opening a different file.
> 3: [RETRY ] Retry EVAL of current toplevel form.
> 4: Ignore error and continue loading file "C:\\msys64\\home\\ugis.lacis\\sbcl_patched\\make-genesis-2.lisp".
> 5: [ABORT ] Abort loading file "C:\\msys64\\home\\ugis.lacis\\sbcl_patched\\make-genesis-2.lisp".
> 6: [ABORT-BUILD] Abort building SBCL.
> 7: Exit debugger, returning to top level.
>
> (HOST-SB-IMPL::%OPEN-ERROR
> #P"C:/msys64/home/ugis.lacis/sbcl_patched/output/tls-init.lisp-expr" 2
> :IGNORE-THIS-ARG :ERROR) 0] //testing for consistency of first and
> second GENESIS passes
> diff: output/genesis-2: No such file or directory
> error: header files do not match between first and second GENESIS
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> -
>
> For the second patch, I get a different error:
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> -
> //entering make-target-2.sh
> //doing warm init - compilation phase
> This is SBCL 2.5.2.161-1abc2d5f6-WIP, 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.
> Initial page table:
> | Immobile Objects |
> Gen layout symbol code Boxed Cons Raw Code SmMix Mixed LgRaw LgCode LgMix Waste% Alloc Trig Dirty GCs Mem-age
> 6 549 25872 20740 0 127 0 0 0 485 0 0 0 0.2 20021088 2000000 0 0 0.0000
> Tot 549 25872 20740 0 127 0 0 0 485 0 0 0 0.2 20021088 [1.9% of 1073741824 max]
> [lot-of-chineese-symbols]
> Exception Code: 00000000C0000374.
> Faulting IP: 00007FFB5B4AB035.
> fatal error encountered in SBCL pid 1648420608:
> Exception too early in cold init, cannot continue.
>
> Welcome to LDB, a low-level debugger for the Lisp runtime environment.
> ldb>
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> -
>
>
> -----Original Message-----
> From: Stas Boukarev <[email protected]>
> Sent: Thursday, 27 March 2025 19:37
> To: Uģis Lācis <[email protected]>
> Cc: [email protected]
> Subject: Re: [Sbcl-help] Calling Lisp from C (SBCL as a shared object)
> on Windows
>
> Or rather try this
>
> On Thu, Mar 27, 2025 at 9:15 PM Stas Boukarev <[email protected]> wrote:
> >
> > Try this
> >
> > On Thu, Mar 27, 2025 at 6:07 PM Stas Boukarev <[email protected]> wrote:
> > >
> > > os_dlsym_default is probably to blame.
> > >
> > > On Thu, Mar 27, 2025 at 4:14 PM Uģis Lācis <[email protected]> wrote:
> > > >
> > > > Dear SBCL community,
> > > >
> > > >
> > > >
> > > > I am trying to use SBCL to define a LISP function I should be able to call from C. My working platform is Windows 11. I have gone through the information I could find on the topic, but can not make a basic example work. I have found discussions around this topic (with similar error traces as I am getting), but without a solution that would work for me. So what I am trying to do now:
> > > >
> > > >
> > > >
> > > > I have found an example (Re: [Sbcl-help] Calling Lisp from C (SBCL as a shared object) | Steel Bank Common Lisp) that should be working for exporting a callable LISP function.
> > > > I have saved the LISP code as-is in a “test1.lsp” file.
> > > > To check that I can produce a valid core, I do:
> > > >
> > > > sbcl.exe --script "test1.lsp" --noinform sbcl.exe --core
> > > > libsum.core
> > > >
> > > >
> > > >
> > > > After these steps I get the error, which is attached at the end of this message (I have also seen it in the thread I referenced above). I have tried these steps both in pre-built Windows installation downloaded from SBCL home page (SBCL 2.5.1) and also in compiled version from the git source (SBCL 2.5.2.155-1d476f1e0). I get the same output if I load the core as written above or via linking to compiled libsbcl.so shared library.
> > > >
> > > >
> > > >
> > > > Has anyone gotten this functionality to work on Windows? Any suggestions about how to get this working would be highly appreciated.
> > > >
> > > >
> > > >
> > > > Best wishes,
> > > > Ugis
> > > >
> > > >
> > > >
> > > > -------------------------------------
> > > >
> > > > ------------------------ ERROR
> > > > -------------------------------------
> > > > Unhandled SB-KERNEL::UNDEFINED-ALIEN-VARIABLE-ERROR in thread
> > > > #<SB-THREAD:THREAD tid=47068 "main thread" RUNNING
> > > >
> > > > {1100BA8003}>:
> > > >
> > > > Attempt to access an undefined alien variable.
> > > >
> > > >
> > > >
> > > > Backtrace for: #<SB-THREAD:THREAD tid=47068 "main thread"
> > > > RUNNING {1100BA8003}>
> > > >
> > > > 0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK
> > > > #<SB-KERNEL::UNDEFINED-ALIEN-VARIABLE-ERROR {1100B9E613}>
> > > > #<unused
> > > > argument> :QUIT T)
> > > >
> > > > 1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK*
> > > > #<SB-KERNEL::UNDEFINED-ALIEN-VARIABLE-ERROR {1100B9E613}>)
> > > >
> > > > 2: (INVOKE-DEBUGGER #<SB-KERNEL::UNDEFINED-ALIEN-VARIABLE-ERROR
> > > > {1100B9E613}>)
> > > >
> > > > 3: (ERROR SB-KERNEL::UNDEFINED-ALIEN-VARIABLE-ERROR)
> > > >
> > > > 4: (SB-KERNEL::UNDEFINED-ALIEN-VARIABLE-ERROR)
> > > >
> > > > 5: ("foreign function: #x140046D35")
> > > >
> > > > 6: ("foreign function: #x140046E00")
> > > >
> > > > 7: ((SETF SB-SYS:SAP-REF-SAP)
> > > > :INVALID-VALUE-FOR-UNESCAPED-REGISTER-STORAGE
> > > > :INVALID-VALUE-FOR-UNESCAPED-REGISTER-STORAGE
> > > > :INVALID-VALUE-FOR-UNESCAPED-REGISTER-STORAGE)
> > > >
> > > > 8: (SB-EVAL::EVAL-PROGN ((SETF (SB-SYS:SAP-REF-SAP SB-ALIEN::SAP
> > > > (/ SB-ALIEN::OFFSET SB-VM:N-BYTE-BITS)) SB-ALIEN::VALUE)
> > > > (SB-ALIEN-INTERNALS:NATURALIZE SB-ALIEN::VALUE (QUOTE
> > > > #<ALIEN-TYPE
> > > > (* T)>))) #<SB-EVAL::ENV {1100B9E1F3}>)
> > > >
> > > > 9: ((SETF SB-ALIEN-INTERNALS:%ALIEN-VALUE)
> > > > #<SB-ALIEN-INTERNALS:ALIEN-VALUE :SAP #X20010CC0 :TYPE (* T)>
> > > > #.(SB-SYS:INT-SAP #X001D0000) 0 #<ALIEN-TYPE (* T)>)
> > > >
> > > > 10: (SB-IMPL::%START-LISP)
> > > >
> > > > 11: ("foreign function: #x140046D35")
> > > >
> > > > 12: ("foreign function: #x14000A160")
> > > >
> > > > _______________________________________________
> > > > Sbcl-help mailing list
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/sbcl-help
_______________________________________________
Sbcl-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-help