He showed how to convince the GNU toolchain to build SBCL in a way
which supports callbacks from C code into SBCL.
+Nikodemus Siivola:
+ He provided build fixes, in particular to tame the SunOS toolchain,
+ and has fixed many (stream-related and other) bugs besides.
+
Brian Spilsbury:
He wrote Unicode-capable versions of SBCL's character, string, and
stream types and operations on them.
** OPEN and WITH-OPEN-STREAM allow opening streams with
element-type larger than ([UN]SIGNED-BYTE 32).
+changes in sbcl-0.8.9 relative to sbcl-0.8.8:
+ * The runtime build system has been tweaked to support building
+ (on SPARC/SunOS) using a C compiler which invokes Sun's own
+ assembler and linker. (thanks to Nikodemus Siivola)
+
planned incompatible changes in 0.8.x:
* (not done yet, but planned:) When the profiling interface settles
down, it might impact TRACE. They both encapsulate functions, and
echo "See the limit(1) or ulimit(1) commands and the README file."
exit 1
fi
+elif [ "$sbcl_arch" = "sparc" ]; then
+ # Test the compiler in order to see if we are building on Sun
+ # toolchain as opposed to GNU binutils, and write the appropriate
+ # FUNCDEF macro for assembler. No harm in running this on sparc-linux
+ # as well.
+ sh tools-for-build/sparc-funcdef.sh > src/runtime/sparc-funcdef.h
else
# Nothing need be done in this case, but sh syntax wants a placeholder.
echo > /dev/null
fi
-
+
echo //finishing $ltf
echo ')' >> $ltf
echo //entering make-target-1.sh
+# Use a little lisp to write LDSO stubs in correct format for the toolchain.
+echo //generating ldso-subs.S
+$SBCL_XC_HOST <<-'EOF' || exit 1
+ (load "src/cold/shared.lisp")
+ (load "tools-for-build/ldso-stubs.lisp")
+ #+cmu (ext:quit)
+ #+clisp (ext:quit)
+EOF
+
# Build the runtime system and symbol table (.nm) file.
#
# (This C build has to come after the first genesis in order to get
sbcl
sbcl.h
sbcl.nm
+sparc-funcdef.h
trymap
+++ /dev/null
-/*
- * stubs for C-linkage library functions which we need to refer to
- * from Lisp
- *
- * (But note this is only the Linux version, as per the FIXME
- * note in the BSD version in undefineds.h.)
- *
- * These stubs exist for the benefit of Lisp code that needs to refer
- * to foreign symbols when dlsym() is not available (i.e. when dumping
- * cold-sbcl.core, when we may be running in a host that's not SBCL,
- * or on platforms that don't have it at all). If the runtime is
- * dynamically linked, library functions won't be linked into it, so
- * the map file won't show them. So, we need a bunch of stubs that
- * nm(1) _can_ see.
- */
-
-/*
- * This software is part of the SBCL system. See the README file for
- * more information.
- *
- * This software is derived from the CMU CL system, which was
- * written at Carnegie Mellon University and released into the
- * public domain. The software is in the public domain and is
- * provided with absolutely no warranty. See the COPYING and CREDITS
- * files for more information.
- */
-#define LANGUAGE_ASSEMBLY
-#include "sbcl.h"
-
- .text
-
-#if defined LISP_FEATURE_X86
-
-#define LDSO_STUBIFY(fct) \
- .align 16 ; \
-.globl ldso_stub__ ## fct ; \
- .type ldso_stub__ ## fct,@function ; \
-ldso_stub__ ## fct: ; \
- jmp fct ; \
-.L ## fct ## e1: ; \
- .size ldso_stub__ ## fct,.L ## fct ## e1-ldso_stub__ ## fct ;
-
-#elif ((defined LISP_FEATURE_OSF1) && (defined LISP_FEATURE_ALPHA))
-/* osf1 has ancient cpp that doesn't do ## */
-#define LDSO_STUBIFY(fct) \
-.globl ldso_stub__/**/fct ; \
-ldso_stub__/**/fct: ; \
- jmp fct ; \
-.L/**/fct/**/e1: ;
-
-
-#elif ((defined LISP_FEATURE_LINUX) && (defined LISP_FEATURE_ALPHA))
-/* but there's no reason we need to put up with that on modern (Linux) OSes */
-#define LDSO_STUBIFY(fct) \
-.globl ldso_stub__ ## fct ; \
- .type ldso_stub__ ## fct,@function ; \
-ldso_stub__ ## fct: ; \
- jmp fct ; \
-.L ## fct ## e1: ; \
- .size ldso_stub__ ## fct,.L ## fct ## e1-ldso_stub__ ## fct ;
-
-#elif ((defined LISP_FEATURE_PPC) && (defined LISP_FEATURE_LINUX))
-#define LDSO_STUBIFY(fct) \
-.globl ldso_stub__ ## fct ; \
- .type ldso_stub__ ## fct,@function ; \
-ldso_stub__ ## fct: ; \
- b fct ; \
-.L ## fct ## e1: ; \
- .size ldso_stub__ ## fct,.L ## fct ## e1-ldso_stub__ ## fct ;
-
-#elif ((defined LISP_FEATURE_PPC) && (defined LISP_FEATURE_DARWIN))
-#define LDSO_STUBIFY(fct) @\
-.text @\
-.globl ldso_stub___ ## fct @\
-ldso_stub___ ## fct: @\
- b ldso_stub__ ## fct ## stub @\
-.symbol_stub ldso_stub__ ## fct ## stub: @\
-.indirect_symbol _ ## fct @\
- lis r11,ha16(ldso_stub__ ## fct ## $lazy_ptr) @\
- lwz r12,lo16(ldso_stub__ ## fct ## $lazy_ptr)(r11) @\
- mtctr r12 @\
- addi r11,r11,lo16(ldso_stub__ ## fct ## $lazy_ptr) @\
- bctr @\
-.lazy_symbol_pointer @\
-ldso_stub__ ## fct ## $lazy_ptr: @\
- .indirect_symbol _ ## fct @\
- .long dyld_stub_binding_helper
-
-#elif defined LISP_FEATURE_SPARC
-
- /* This is an attempt to follow DB's hint of sbcl-devel
- * 2001-09-18. -- CSR */
-#define LDSO_STUBIFY(fct) \
-.globl ldso_stub__ ## fct ; \
- .type ldso_stub__ ## fct,@function ; \
-ldso_stub__ ## fct: ; \
- sethi %hi(fct),%g1 ; \
- jmpl %g1+%lo(fct),%g0 ; \
- nop /* delay slot*/ ; \
-.L ## fct ## e1: ; \
- .size ldso_stub__ ## fct,.L ## fct ## e1-ldso_stub__ ## fct ;
-
-#elif defined LISP_FEATURE_MIPS
-
-/* KLUDGE: set up the vital fifth argument, passed on the
- stack. Do this unconditionally, even if the stub is for a
- function with few arguments: it can't hurt. We only do this for
- the fifth argument, as the first four are passed in registers
- and we apparently don't ever need to pass six arguments to a
- libc function. -- CSR, 2003-10-29 */
-
-#define LDSO_STUBIFY(fct) \
-.globl ldso_stub__ ## fct ; \
- .type ldso_stub__ ## fct,@function ; \
-ldso_stub__ ## fct: ; \
- addiu $29,-48 ; \
- sw $28,40($29) ; \
- sw $31,44($29) ; \
- lw $25,64($29) ; \
- sw $25,16($29) ; \
- la $25, fct ; \
- jalr $25 ; \
- lw $31,44($29) ; \
- lw $28,40($29) ; \
- addiu $29,48 ; \
- jr $31 ; \
-.L ## fct ## e1: ; \
- .size ldso_stub__ ## fct,.L ## fct ## e1-ldso_stub__ ## fct ;
-
-#else
-#error unsupported CPU architecture
-#endif
-
- LDSO_STUBIFY(accept)
- LDSO_STUBIFY(access)
- LDSO_STUBIFY(acos)
- LDSO_STUBIFY(acosh)
- LDSO_STUBIFY(asin)
- LDSO_STUBIFY(asinh)
- LDSO_STUBIFY(atanh)
- LDSO_STUBIFY(bind)
- LDSO_STUBIFY(cfgetispeed)
- LDSO_STUBIFY(cfgetospeed)
- LDSO_STUBIFY(cfsetispeed)
- LDSO_STUBIFY(cfsetospeed)
- LDSO_STUBIFY(chmod)
- LDSO_STUBIFY(chown)
- LDSO_STUBIFY(close)
- LDSO_STUBIFY(closedir)
- LDSO_STUBIFY(connect)
- LDSO_STUBIFY(cosh)
- LDSO_STUBIFY(creat)
-#ifndef LISP_FEATURE_DARWIN
- LDSO_STUBIFY(dlclose)
- LDSO_STUBIFY(dlerror)
- LDSO_STUBIFY(dlopen)
- LDSO_STUBIFY(dlsym)
-#endif
- LDSO_STUBIFY(dup)
- LDSO_STUBIFY(dup2)
- LDSO_STUBIFY(execve)
- LDSO_STUBIFY(exit)
- LDSO_STUBIFY(fchmod)
- LDSO_STUBIFY(fchown)
- LDSO_STUBIFY(fcntl)
- LDSO_STUBIFY(fork)
- LDSO_STUBIFY(free)
- LDSO_STUBIFY(fstat)
- LDSO_STUBIFY(fsync)
- LDSO_STUBIFY(ftruncate)
- LDSO_STUBIFY(getcwd)
- LDSO_STUBIFY(getdtablesize)
- LDSO_STUBIFY(getegid)
- LDSO_STUBIFY(getenv)
- LDSO_STUBIFY(getgid)
- LDSO_STUBIFY(gethostbyaddr)
- LDSO_STUBIFY(gethostbyname)
- LDSO_STUBIFY(gethostname)
- LDSO_STUBIFY(getitimer)
- LDSO_STUBIFY(getpagesize)
- LDSO_STUBIFY(getpeername)
- LDSO_STUBIFY(getpgrp)
- LDSO_STUBIFY(getpid)
- LDSO_STUBIFY(getppid)
- LDSO_STUBIFY(getrusage)
- LDSO_STUBIFY(getsockname)
- LDSO_STUBIFY(gettimeofday)
- LDSO_STUBIFY(getuid)
- LDSO_STUBIFY(hypot)
- LDSO_STUBIFY(ioctl)
- LDSO_STUBIFY(isatty)
- LDSO_STUBIFY(kill)
- LDSO_STUBIFY(killpg)
- LDSO_STUBIFY(link)
- LDSO_STUBIFY(listen)
- LDSO_STUBIFY(log1p)
- LDSO_STUBIFY(lseek)
- LDSO_STUBIFY(lstat)
- LDSO_STUBIFY(malloc)
- LDSO_STUBIFY(memmove)
- LDSO_STUBIFY(mkdir)
- LDSO_STUBIFY(open)
- LDSO_STUBIFY(opendir)
- LDSO_STUBIFY(pipe)
- LDSO_STUBIFY(pow)
- LDSO_STUBIFY(read)
- LDSO_STUBIFY(readdir)
- LDSO_STUBIFY(readlink)
- LDSO_STUBIFY(recv)
- LDSO_STUBIFY(rename)
- LDSO_STUBIFY(rmdir)
- LDSO_STUBIFY(select)
- LDSO_STUBIFY(send)
- LDSO_STUBIFY(setitimer)
- LDSO_STUBIFY(setpgrp)
- LDSO_STUBIFY(setsid)
-#if !defined(SVR4)
- LDSO_STUBIFY(sigsetmask)
-#endif
- LDSO_STUBIFY(sinh)
- LDSO_STUBIFY(socket)
- LDSO_STUBIFY(stat)
- LDSO_STUBIFY(strerror)
- LDSO_STUBIFY(strlen)
- LDSO_STUBIFY(symlink)
- LDSO_STUBIFY(sync)
- LDSO_STUBIFY(tanh)
- LDSO_STUBIFY(tcdrain)
- LDSO_STUBIFY(tcflow)
- LDSO_STUBIFY(tcflush)
- LDSO_STUBIFY(tcgetattr)
- LDSO_STUBIFY(tcsendbreak)
- LDSO_STUBIFY(tcsetattr)
- LDSO_STUBIFY(truncate)
- LDSO_STUBIFY(ttyname)
- LDSO_STUBIFY(tzname)
- LDSO_STUBIFY(unlink)
- LDSO_STUBIFY(utimes)
- LDSO_STUBIFY(wait3)
- LDSO_STUBIFY(write)
-
-/*
- * These aren't needed on the X86 because they're microcoded into the
- * FPU, so the Lisp VOPs can implement them directly without having to
- * call C code.
- *
- * Note: There might be some other functions in this category as well.
- * E.g. I notice tanh() and acos() in the list above.. -- WHN 2001-06-07
- */
-#if !defined LISP_FEATURE_X86
- LDSO_STUBIFY(sin)
- LDSO_STUBIFY(cos)
- LDSO_STUBIFY(tan)
- LDSO_STUBIFY(atan)
- LDSO_STUBIFY(atan2)
- LDSO_STUBIFY(exp)
- LDSO_STUBIFY(log)
- LDSO_STUBIFY(log10)
- LDSO_STUBIFY(sqrt)
-#endif
-#if defined alpha
- LDSO_STUBIFY(ieee_get_fp_control)
- LDSO_STUBIFY(ieee_set_fp_control)
-#endif
#define _ASM
-#define FUNCDEF(x) .type x,@function
+#include "sparc-funcdef.h"
#define LANGUAGE_ASSEMBLY
#include "lispregs.h"
--- /dev/null
+;;;; Generate stubs for C-linkage library functions which we need to refer to
+;;;; from Lisp.
+;;;;
+;;;; (But note this is only the Linux version, as per the FIXME
+;;;; note in the BSD version in undefineds.h.)
+;;;;
+;;;; These stubs exist for the benefit of Lisp code that needs to refer
+;;;; to foreign symbols when dlsym() is not available (i.e. when dumping
+;;;; cold-sbcl.core, when we may be running in a host that's not SBCL,
+;;;; or on platforms that don't have it at all). If the runtime is
+;;;; dynamically linked, library functions won't be linked into it, so
+;;;; the map file won't show them. So, we need a bunch of stubs that
+;;;; nm(1) _can_ see.
+;;;;
+;;;; This software is part of the SBCL system. See the README file for
+;;;; more information.
+;;;;
+;;;; This software is derived from the CMU CL system, which was
+;;;; written at Carnegie Mellon University and released into the
+;;;; public domain. The software is in the public domain and is
+;;;; provided with absolutely no warranty. See the COPYING and CREDITS
+;;;; files for more information.
+
+#!-sparc
+(defun ldso-stubify (fct str)
+ (format str "LDSO_STUBIFY(~A)~%" fct))
+
+;;; This is an attempt to follow DB's hint of sbcl-devel
+;;; 2001-09-18. -- CSR
+;;;
+;;; And an attempt to work around the Sun toolchain... --ns
+#!+sparc
+(defun ldso-stubify (fct str)
+ (apply #'format str "
+.globl ldso_stub__~A ; \
+ FUNCDEF(ldso_stub__~A) ; \
+ldso_stub__~A: ; \
+ sethi %hi(~A),%g1 ; \
+ jmpl %g1+%lo(~A),%g0 ; \
+ nop /* delay slot*/ ; \
+.L~Ae1: ; \
+ .size ldso_stub__~A,.L~Ae1-ldso_stub__~A ;~%"
+ (make-list 9 :initial-element fct)))
+
+(defvar *preludes* '("
+/* This is an automatically generated file, please do not hand-edit it.
+ * See the program tools-for-build/ldso-stubs.lisp. */
+
+#define LANGUAGE_ASSEMBLY
+#include \"sbcl.h\""
+
+#!+sparc "
+#ifdef LISP_FEATURE_SPARC
+#include \"sparc-funcdef.h\"
+#endif
+ .text"
+
+#!+x86 "
+#define LDSO_STUBIFY(fct) \
+ .align 16 ; \
+.globl ldso_stub__ ## fct ; \
+ .type ldso_stub__ ## fct,@function ; \
+ldso_stub__ ## fct: ; \
+ jmp fct ; \
+.L ## fct ## e1: ; \
+ .size ldso_stub__ ## fct,.L ## fct ## e1-ldso_stub__ ## fct ;"
+
+;;; osf1 has ancient cpp that doesn't do ##
+#!+(and osf1 alpha) "
+#define LDSO_STUBIFY(fct) \
+.globl ldso_stub__/**/fct ; \
+ldso_stub__/**/fct: ; \
+ jmp fct ; \
+.L/**/fct/**/e1: ;"
+
+;;; but there's no reason we need to put up with that on modern (Linux) OSes
+#!+(and linux alpha) "
+#define LDSO_STUBIFY(fct) \
+.globl ldso_stub__ ## fct ; \
+ .type ldso_stub__ ## fct,@function ; \
+ldso_stub__ ## fct: ; \
+ jmp fct ; \
+.L ## fct ## e1: ; \
+ .size ldso_stub__ ## fct,.L ## fct ## e1-ldso_stub__ ## fct ;"
+
+#!+(and linux ppc) "
+#define LDSO_STUBIFY(fct) \
+.globl ldso_stub__ ## fct ; \
+ .type ldso_stub__ ## fct,@function ; \
+ldso_stub__ ## fct: ; \
+ b fct ; \
+.L ## fct ## e1: ; \
+ .size ldso_stub__ ## fct,.L ## fct ## e1-ldso_stub__ ## fct ;"
+
+#!+(and darwin ppc) "
+#define LDSO_STUBIFY(fct) @\
+.text @\
+.globl ldso_stub___ ## fct @\
+ldso_stub___ ## fct: @\
+ b ldso_stub__ ## fct ## stub @\
+.symbol_stub ldso_stub__ ## fct ## stub: @\
+.indirect_symbol _ ## fct @\
+ lis r11,ha16(ldso_stub__ ## fct ## $lazy_ptr) @\
+ lwz r12,lo16(ldso_stub__ ## fct ## $lazy_ptr)(r11) @\
+ mtctr r12 @\
+ addi r11,r11,lo16(ldso_stub__ ## fct ## $lazy_ptr) @\
+ bctr @\
+.lazy_symbol_pointer @\
+ldso_stub__ ## fct ## $lazy_ptr: @\
+ .indirect_symbol _ ## fct @\
+ .long dyld_stub_binding_helper"
+
+;;; KLUDGE: set up the vital fifth argument, passed on the
+;;; stack. Do this unconditionally, even if the stub is for a
+;;; function with few arguments: it can't hurt. We only do this for
+;;; the fifth argument, as the first four are passed in registers
+;;; and we apparently don't ever need to pass six arguments to a
+;;; libc function. -- CSR, 2003-10-29
+#!+mips "
+#define LDSO_STUBIFY(fct) \
+.globl ldso_stub__ ## fct ; \
+ .type ldso_stub__ ## fct,@function ; \
+ldso_stub__ ## fct: ; \
+ addiu $29,-48 ; \
+ sw $28,40($29) ; \
+ sw $31,44($29) ; \
+ lw $25,64($29) ; \
+ sw $25,16($29) ; \
+ la $25, fct ; \
+ jalr $25 ; \
+ lw $31,44($29) ; \
+ lw $28,40($29) ; \
+ addiu $29,48 ; \
+ jr $31 ; \
+.L ## fct ## e1: ; \
+ .size ldso_stub__ ## fct,.L ## fct ## e1-ldso_stub__ ## fct ;"))
+
+(defvar *stubs* (append
+ '("accept"
+ "access"
+ "acos"
+ "acosh"
+ "asin"
+ "asinh"
+ "atanh"
+ "bind"
+ "cfgetispeed"
+ "cfgetospeed"
+ "cfsetispeed"
+ "cfsetospeed"
+ "chmod"
+ "chown"
+ "close"
+ "closedir"
+ "connect"
+ "cosh"
+ "creat"
+ "dup"
+ "dup2"
+ "execve"
+ "exit"
+ "fchmod"
+ "fchown"
+ "fcntl"
+ "fork"
+ "free"
+ "fstat"
+ "fsync"
+ "ftruncate"
+ "getcwd"
+ "getdtablesize"
+ "getegid"
+ "getenv"
+ "getgid"
+ "gethostbyaddr"
+ "gethostbyname"
+ "gethostname"
+ "getitimer"
+ "getpagesize"
+ "getpeername"
+ "getpgrp"
+ "getpid"
+ "getppid"
+ "getrusage"
+ "getsockname"
+ "gettimeofday"
+ "getuid"
+ "hypot"
+ "ioctl"
+ "isatty"
+ "kill"
+ "killpg"
+ "link"
+ "listen"
+ "log1p"
+ "lseek"
+ "lstat"
+ "malloc"
+ "memmove"
+ "mkdir"
+ "open"
+ "opendir"
+ "pipe"
+ "pow"
+ "read"
+ "readdir"
+ "readlink"
+ "recv"
+ "rename"
+ "rmdir"
+ "select"
+ "send"
+ "setitimer"
+ "setpgrp"
+ "setsid"
+ "sinh"
+ "socket"
+ "stat"
+ "strerror"
+ "strlen"
+ "symlink"
+ "sync"
+ "tanh"
+ "tcdrain"
+ "tcflow"
+ "tcflush"
+ "tcgetattr"
+ "tcsendbreak"
+ "tcsetattr"
+ "truncate"
+ "ttyname"
+ "tzname"
+ "unlink"
+ "utimes"
+ "wait3"
+ "write")
+ ;; These aren't needed on the X86 because they're microcoded into the
+ ;; FPU, so the Lisp VOPs can implement them directly without having to
+ ;; call C code.
+ ;;
+ ;; Note: There might be some other functions in this category as well.
+ ;; E.g. I notice tanh() and acos() in the list above.. -- WHN 2001-06-07
+ #!-x86
+ '("sin"
+ "cos"
+ "tan"
+ "atan"
+ "atan2"
+ "exp"
+ "log"
+ "log10"
+ "sqrt")
+ #!+alpha
+ '("ieee_get_fp_control"
+ "ieee_set_fp_control")
+ #!-darwin
+ '("dlclose"
+ "dlerror"
+ "dlopen"
+ "dlsym")
+ #!-(and sparc sunos) ;; !defined(SVR4)
+ '("sigsetmask")))
+
+(with-open-file (f "src/runtime/ldso-stubs.S" :direction :output :if-exists :supersede)
+ (assert (= (length *preludes*) 2))
+ (dolist (pre *preludes*)
+ (write-line pre f))
+ (dolist (stub *stubs*)
+ (check-type stub string)
+ (ldso-stubify stub f)))
+
--- /dev/null
+cd tools-for-build
+
+TMP=sparc-funcdef.S
+
+SUN_FUNCDEF="#define FUNCDEF(x) .type x,#function"
+GNU_FUNCDEF="#define FUNCDEF(x) .type x,@function"
+
+echo $SUN_FUNCDEF > $TMP
+# cribbed from ldso_stubs, just "some code"
+echo "
+.globl ldso_stub__printf ;
+ FUNCDEF(ldso_stub__printf) ;
+ldso_stub__printf: ;
+ sethi %hi(printf),%g1 ;
+ jmpl %g1+%lo(printf),%g0 ;
+ nop /* delay slot*/ ;
+.Lprintfe1: ;
+ .size ldso_stub__printf,.Lprintfe1-ldso_stub__printf ;" >> $TMP
+
+if $GNUMAKE sparc-funcdef.o > /dev/null 2>&1 ; then
+ echo $SUN_FUNCDEF
+else
+ echo $GNU_FUNCDEF
+fi
+rm -f $TMP
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.8.8.1"
+"0.8.8.2"