在MacOSX下编译SBCL1.0.55多线程版本出错记录+解决

作者:袖梨 2026-08-20

在Mac OSX 下编译 SBCL 1.0.55 多线程版本出错记录+解决

在MacOSX下编译SBCL1.0.55多线程版本出错记录+解决

首先从这里下载一个最新的 sbcl 1.0.55 的源代码(the source),解压,然后进去执行

sudo sh make.sh --with-sb-thread

结果出现错误,出错信息如下:

Air:sbcl-1.0.55 admin$ sudo sh make.sh --with-sb-thread

Password:

rm -f *~ *.bak *.orig #*# .#* texput.log *.fasl

rm -rf sbcl asdf "docstrings/"

rm -f sbcl.html asdf.html

rm -f contrib-docs.texi-temp

rm -f package-locks.texi-temp

rm -f variables.texinfo

rm -f sbcl.ps asdf.ps sbcl.pdf asdf.pdf html-stamp tempfiles-stamp

rm -f asdf.aux asdf.cp asdf.cps asdf.fn asdf.fns asdf.ky asdf.log asdf.pg asdf.toc asdf.tp asdf.tps asdf.vr asdf.vrs sbcl.aux sbcl.cp sbcl.cps sbcl.fn sbcl.fns sbcl.ky sbcl.log sbcl.pg sbcl.toc sbcl.tp sbcl.tps sbcl.vr sbcl.vrs

rm -f sbcl.info sbcl.info-* asdf.info

//entering make-config.sh

//ensuring the existence of output/ directory

//guessing default target CPU architecture from host architecture

//setting up CPU-architecture-dependent information

sbcl_arch="x86-64"

//initializing /Users/admin/Downloads/sbcl-1.0.55/local-target-features.lisp-expr

//setting up OS-dependent information

gcc -g -Wall -O2 -fdollars-in-identifiers -mmacosx-version-min=10.4 -arch x86_64 -fno-omit-frame-pointer -pagezero_size 0x100000 -I../src/runtime determine-endianness.c -lSystem -lc -ldl -o determine-endianness

cc1: error: unrecognized command line option "-arch"

make: * [determine-endianness] Error 1

Air:sbcl-1.0.55 admin$

看起来是 gcc 不识别 -arch 选项,看到这个错误第一直觉就是我的默认 gcc 可能需要检查一下,然后顺手搜了把,果然有人也遇到类似问题,居然当做 bug 报上去了 (https://trac.macports.org/ticket/31834),检查一下我的 gcc 设置:

Air:sbcl-1.0.55 admin$ sudo port select gcc

Password:

Available versions for gcc:

apple-gcc42

gcc42

gcc46

llvm-gcc42

mp-gcc45 (active)

none

Air:sbcl-1.0.55 admin$ sudo port select --set gcc gcc42

Password:

Selecting 'gcc42' for 'gcc' failed: could not create new link "/opt/local/bin/gcc": target "/usr/bin/gcc-4.2" doesn't exist

Air:sbcl-1.0.55 admin$

果然不出所料,默认激活的是 mp-gcc45,换成 gcc42 再试试。

ok,开始编译刷屏了,等待....

终于编译完成,没有任何错误:

real    0m45.687s

user 0m41.029s

sys 0m9.832s

The build seems to have finished successfully, including 17 (out of 17)

contributed modules. If you would like to run more extensive tests on

the new SBCL, you can try:

cd tests && sh ./run-tests.sh

(All tests should pass on x86/Linux, x86/FreeBSD4, and ppc/Darwin. On

other platforms some failures are currently expected; patches welcome

as always.)

To build documentation:

cd doc/manual && make

To install SBCL (more information in INSTALL):

sh install.sh

//build started: Fri Jan 18 06:16:44 CST 2013

//build finished: Fri Jan 18 06:22:04 CST 2013

Air:sbcl-1.0.55 admin$

看来任何时候都会有意想不到的问题,所有的环境都可能存在独一无二的不同之处。。。

最后把编译好的新的 sbcl 加载到 LispBox 时发现又出现了问题,居然是32位和64位的问题,如下:

; /Users/admin/.slime/fasl/2012-11-12/sbcl-1.0.55-darwin-x86-64/swank-source-file-cache.fasl written

; compilation finished in 0:00:00.049

; loading #P"/Users/admin/.slime/fasl/2012-11-12/sbcl-1.0.55-darwin-x86-64/swank-source-file-cache.fasl"

; compiling file "/Users/admin/LispBox-0.92/slime-2012-11-13/swank-sbcl.lisp" (written 18 JAN 2013 02:23:54 AM):

;

; compilation unit aborted

; caught 1 fatal ERROR condition

; compilation aborted after 0:00:00.005

;;

;; Error while compiling /Users/admin/LispBox-0.92/slime-2012-11-13/swank-sbcl.lisp:

;; #<SB-SYS:FD-STREAM

;; for "file /Users/admin/LispBox-0.92/sbcl-1.0.55-x86-darwin/contrib/sb-bsd-sockets/sb-bsd-sockets.fasl"

;; {1003901E43}> was compiled for implementation X86, but this is a X86-64.

;; Aborting.

;; *

再次思考,哦,很可能是因为原来拷贝到 LispBox 目录下的 sbcl 是别人编译好的 32 位的版本,那就把这次编译新下载回来的源代码目录整个拷贝到 LispBox 下,再试,ok 了,新的多线程的64位的 sbcl 终于在LispBox 里成功运行了!
最初是看到这位的帖子,还需要打一个补丁,但是我编译的时候没有打补丁
from: http://blog.sina.com.cn/s/blog_538d55be0100xjj7.html

[2013-01-30 更新] 增加特性 :SB-CORE-COMPRESSION 重新编译

今天把那个映像文件压缩功能编进去了,命令如下:

sudo sh make.sh --with-sb-core-compression

编译成功之后安装:

sudo sh install.sh

SBCL has been installed:

binary /usr/local/bin/sbcl

core and contribs in /usr/local/lib/sbcl/

然后查看特性列表,已经成功把:SB-CORE-COMPRESSION 编进去了

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.

* *features*

(:ANSI-CL :COMMON-LISP :SBCL :SB-DOC :SB-TEST :SB-LDB :SB-PACKAGE-LOCKS

:SB-UNICODE :SB-EVAL :SB-SOURCE-LOCATIONS :IEEE-FLOATING-POINT

:OS-PROVIDES-SUSECONDS-T :OS-PROVIDES-BLKSIZE-T :OS-PROVIDES-PUTWC

:OS-PROVIDES-DLADDR :OS-PROVIDES-DLOPEN :LITTLE-ENDIAN :MULTIPLY-HIGH-VOPS

:MEMORY-BARRIER-VOPS :INLINE-CONSTANTS :FLOAT-EQL-VOPS :COMPLEX-FLOAT-VOPS

:CYCLE-COUNTER :ALIEN-CALLBACKS :STACK-ALLOCATABLE-FIXED-OBJECTS

:STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-VECTORS

:STACK-ALLOCATABLE-CLOSURES :RAW-INSTANCE-INIT-VOPS

:UNWIND-TO-FRAME-AND-CALL-VOP :COMPARE-AND-SWAP-VOPS :LINKAGE-TABLE

:C-STACK-IS-CONTROL-STACK :STACK-GROWS-DOWNWARD-NOT-UPWARD :GENCGC

:UD2-BREAKPOINTS :MACH-EXCEPTION-HANDLER :DARWIN :BSD :MACH-O :UNIX

:DARWIN9-OR-BETTER :INODE64 :X86-64 :SB-CORE-COMPRESSION)

*

编译完成之后悲剧地发现,多线程支持忘加了,看来要这么编:

sudo sh make.sh --with-sb-thread --with-sb-core-compression

新版本编译完成,增加 sb-core-compression 和 sb-thread

; SYS:CONTRIB;SB-SPROF;SB-SPROF.FASL.NEWEST written

; compilation finished in 0:00:01.024

* true

real 0m46.367s

user 0m39.027s

sys 0m8.867s

The build seems to have finished successfully, including 17 (out of 17)

contributed modules. If you would like to run more extensive tests on

the new SBCL, you can try:

cd tests && sh ./run-tests.sh

(All tests should pass on x86/Linux, x86/FreeBSD4, and ppc/Darwin. On

other platforms some failures are currently expected; patches welcome

as always.)

To build documentation:

cd doc/manual && make

To install SBCL (more information in INSTALL):

sh install.sh

//build started: Wed Jan 30 06:02:14 CST 2013

//build finished: Wed Jan 30 06:08:48 CST 2013

Air:sbcl-1.0.55 admin$

先去跑跑测试用例,看看有没有失败的,用这个命令

cd tests && sh ./run-tests.sh

测试结果如下:

Finished running tests.

Status:

Expected failure: float.pure.lisp / RANGE-REDUCTION

Expected failure: debug.impure.lisp / BACKTRACE-INTERRUPTED-CONDITION-WAIT

Skipped (broken): debug.impure.lisp / (TRACE ENCAPSULATE NIL)

Skipped (broken): debug.impure.lisp / (TRACE-RECURSIVE ENCAPSULATE NIL)

Expected failure: packages.impure.lisp / USE-PACKAGE-CONFLICT-SET

Expected failure: packages.impure.lisp / IMPORT-SINGLE-CONFLICT

(2 tests skipped for this combination of platform and features)

ok

//apparent success (reached end of run-tests.sh normally)

Wed Jan 30 06:23:38 CST 2013

线程和映像压缩全部编译进去了:

* *features*

(:ANSI-CL :COMMON-LISP :SBCL :SB-DOC :SB-TEST :SB-LDB :SB-PACKAGE-LOCKS

:SB-UNICODE :SB-EVAL :SB-SOURCE-LOCATIONS :IEEE-FLOATING-POINT

:OS-PROVIDES-SUSECONDS-T :OS-PROVIDES-BLKSIZE-T :OS-PROVIDES-PUTWC

:OS-PROVIDES-DLADDR :OS-PROVIDES-DLOPEN :LITTLE-ENDIAN :MULTIPLY-HIGH-VOPS

:MEMORY-BARRIER-VOPS :INLINE-CONSTANTS :FLOAT-EQL-VOPS :COMPLEX-FLOAT-VOPS

:CYCLE-COUNTER :ALIEN-CALLBACKS :STACK-ALLOCATABLE-FIXED-OBJECTS

:STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-VECTORS

:STACK-ALLOCATABLE-CLOSURES :RAW-INSTANCE-INIT-VOPS

:UNWIND-TO-FRAME-AND-CALL-VOP :COMPARE-AND-SWAP-VOPS :LINKAGE-TABLE

:C-STACK-IS-CONTROL-STACK :STACK-GROWS-DOWNWARD-NOT-UPWARD :GENCGC

:UD2-BREAKPOINTS :MACH-EXCEPTION-HANDLER :DARWIN :BSD :MACH-O :UNIX

:DARWIN9-OR-BETTER :INODE64 :X86-64 :SB-CORE-COMPRESSION :SB-THREAD)

*

相关文章

精彩推荐