SBCL
Contents |
Run SBCL on DreamHost
If you download a SBCL from http://sbcl.sourceforge.net/, unpacked it, and run it on DreamHost, It issues :
mmap: wanted 1044480 bytes at 0x1000000, actually mapped at 0xe4a3c000 ensure_space: failed to validate 1044480 bytes at 0x01000000 (hint: Try "ulimit -a"; maybe you should increase memory limits.)
That's because on DreamHost the mmap(2) can not return a memory-addr which you wanted without the flag MAP_FIXED, I modified and compiled a x86 version for dreamhost, you can get it here:
http://kdr2.net/depot/lisp/sbcl-1.0.45.mmap-mod-x86-for-dh.zip
Download the zip file from the link above, unzip it to /path/to/sbcl, then you can run it use this command:
SBCL_HOME=/path/to/sbcl/lib/sbcl /path/to/sbcl/bin/sbcl
Like this:
[hoffa]$ SBCL_HOME=/path/to/sbcl/lib/sbcl /path/to/sbcl/bin/sbcl This is SBCL 1.0.45, 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. *
And you can puts these ENV-SETTINGS to your ~/.bashrc and ~/.bash_profile
export SBCL_HOME=/path/to/sbcl/lib/sbcl export PATH=/path/to/sbcl/bin:$PATH
raw patch
(I don't know how kdr2 patched SBCL, but the following seems to work when applied to 43a52658.)
diff --git a/src/runtime/linux-os.c b/src/runtime/linux-os.c
index e262f41..f2d8c9d 100644
--- a/src/runtime/linux-os.c
+++ b/src/runtime/linux-os.c
@@ -314,6 +314,10 @@ os_validate(os_vm_address_t addr, os_vm_size_t len)
int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
os_vm_address_t actual;
+ // removed in a3b0216 due to some concern of overmapping reserved space
+ if(addr)
+ flags|=MAP_FIXED;
+
#ifdef LISP_FEATURE_ALPHA
if (!addr) {
addr=under_2gb_free_pointer;
Pass --dynamic-space-size=200 to make.sh when building SBCL. Or pass "--dynamic-space-size 130" when starting SBCL. Otherwise it will blow a soft virtual memory limit and the server will kill your process. (Dreamhost may allow larger values. If the values are too small, your program will run out of heap memory.)
Run FastCGI WebApp Base on SBCL
After you can run SBCL on your DreamHost, you need get sb-fastcgi to build a fastcgi webapp using Common Lisp with SBCL.
get sb-fastcgi asdf-package and install it
Do not know how to install a asdf-package? see the ASDF DOC please.
write a fcgi-app using sb-fastcgi
This is a example from sb-fastcgi/test.lisp
app.lisp:
(asdf:operate 'asdf:load-op 'sb-fastcgi)
(sb-fastcgi:load-libfcgi "/path/to/sb-fastcgi/c_src/libfcgi.so")
(defun simple-app (req)
(let ((c (format nil "Content-Type: text/plain
Hello, I am a fcgi-program using Common-Lisp")))
(sb-fastcgi:fcgx-puts req c)))
(defun serve ()
(sb-fastcgi:simple-server #'simple-app))
(defun make-exe (&optional (name "sbcl.fcgi"))
(sb-ext:save-lisp-and-die name
:executable t
:purify t
:toplevel (lambda ()
(unwind-protect (serve)
(sb-ext:quit)))))
(make-exe)
Then you can run command:
sbcl --script app.lisp
to generate a executable-file named "sbcl.fcgi". Move the file sbcl.fcgi to your webdir, then change the content of the file .htaccess under the webdir to:
AddHandler fastcgi-script .fcgi Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteRule ^sbcl\.fcgi/ - [L] RewriteRule ^(.*)$ sbcl.fcgi [L]
Now, You can visit your site to run the app.