本文介绍了如何使用SBCL正确保存Common Lisp图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果要创建程序的Lisp图像,如何正确执行?有任何先决条件吗?

If I want to create a Lisp-image of my program, how do I do it properly? Are there any prerequisites? And doesn't it play nicely with QUICKLISP?

现在,如果我启动SBCL(仅预加载QUICKLISP)并保存图像,

Right now, if I start SBCL (with just QUICKLISP pre-loaded) and save the image:

(save-lisp-and-die "core")

然后尝试使用此图像再次启动SBCL

And then try to start SBCL again with this image

sbcl --core core

然后尝试做:

(ql:quickload :cl-yaclyaml)

我得到以下信息:

To load "cl-yaclyaml":
  Load 1 ASDF system:
    cl-yaclyaml
; Loading "cl-yaclyaml"
.......
debugger invoked on a SB-INT:EXTENSION-FAILURE in thread
#<THREAD "main thread" RUNNING {100322C613}>:
  Don't know how to REQUIRE sb-sprof.
See also:
  The SBCL Manual, Variable *MODULE-PROVIDER-FUNCTIONS*
  The SBCL Manual, Function REQUIRE

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY                        ] Retry completing load for #<REQUIRE-SYSTEM "sb-sprof">.
  1: [ACCEPT                       ] Continue, treating completing load for #<REQUIRE-SYSTEM "sb-sprof"> as having been successful.
  2:                                 Retry ASDF operation.
  3: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the configuration.
  4: [ABORT                        ] Give up on "cl-yaclyaml"
  5:                                 Exit debugger, returning to top level.

(SB-IMPL::REQUIRE-ERROR "Don't know how to ~S ~A." REQUIRE "sb-sprof")
0]

或者,如果我尝试:

(require 'sb-sprof)

当sbcl以保存的内核启动时,我得到相同的结果错误。如果像 sbcl 一样启动sbcl,则不会报告错误。

when sbcl is started with saved core, I get the same error. If sbcl is started just as sbcl there is no error reported.

实际上,预加载QUICKLISP不会一个问题:如果最初使用 sbcl --no-userinit --no-sysinit 调用sbcl,也会发生同样的问题。

In fact, pre-loading QUICKLISP is not a problem: the same problem happens if sbcl is called initially with sbcl --no-userinit --no-sysinit.

我做错了吗?

PS。如果我使用roswell,则 ros -L sbcl-bin -m核心运行不会以某种方式拾取图像(通过声明变量 * A *进行测试,然后保存,重新启动后就看不到)。

PS. If I use roswell, ros -L sbcl-bin -m core run somehow doesn't pick up the image (tested by declaring variable *A* before saving and not seeing it once restarted).

PS2。到目前为止,看来sbcl不提供扩展模块( SB-SPROF SB-POSIX 等。)除非在存储图像之前明确要求它们。

PS2. So far what it looks like is that sbcl does not provide extension modules (SB-SPROF, SB-POSIX, etc.) unless they are explicitly required prior saving the image.

推荐答案

感谢@jkiiski的帮助,此处提供了完整的说明和解决方案:

Thanks for the help from @jkiiski here is the full explanation and solution:


  1. SBCL使用额外的模块( SB-SPROF SB-POSIX 等),它们并不总是加载到图像中。这些模块位于 contrib 目录中,该目录位于 SBCL_HOME 环境变量指向的位置(如果已设置)或图像所在的位置(例如,在 / usr / local / lib / sbcl / 中)。

  1. SBCL uses extra modules (SB-SPROF, SB-POSIX and others) that are not always loaded into the image. These module reside in contrib directory located either where SBCL_HOME environment variable pointing (if it is set) or where the image resides (for example, in /usr/local/lib/sbcl/).

当映像时保存在另一个位置,并且如果未设置 SBCL_HOME ,SBCL将无法找到 contrib ,因此我看到的错误。

When an image is saved in another location and if SBCL_HOME is not set, SBCL won't be able to find contrib, hence the errors that I saw.

将SBCL_HOME设置为指向 contrib 位置(或复制 contrib 移至图像位置或将新图像移至 contrib 位置)即可解决此问题。

Setting SBCL_HOME to point to contrib location (or copying contrib to image location or new image to contrib location) solves the problem.

最后,关于roswell:roswell参数 -m 在特定位置搜索图像。对于SBCL( sbcl-bin ),它类似于〜/ .roswell / impls / x86-64 / linux / sbcl-bin / 1.3。 7 / dump / 。其次,SBCL的映像名称必须采用< name> .core 的形式。要启动它,请使用: ros -m< name> -L sbcl-bin运行。 (快速编辑:更好地使用 ros dump 使用罗斯韦尔向我指出来保存图像)

Finally, about roswell: roswell parameter -m searches for images in a specific location. For SBCL (sbcl-bin) it would be something like ~/.roswell/impls/x86-64/linux/sbcl-bin/1.3.7/dump/. Secondly, the image name for SBCL must have the form <name>.core. And to start it, use: ros -m <name> -L sbcl-bin run. (Quick edit: better use ros dump for saving images using roswell as it was pointed out to me)

这篇关于如何使用SBCL正确保存Common Lisp图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-07 18:04