From 9cbb7f9b3a418314ffcd8f2cb0448278d2b6f812 Mon Sep 17 00:00:00 2001 From: William Harold Newman Date: Wed, 8 May 2002 19:57:23 +0000 Subject: [PATCH] 0.7.3.12: merged Pierre Mai's "load-foreign support for the OpenBSD port" patch (sbcl-devel 2002-05-08) fixed FIXME in foreign.test.sh so that bogus differences in "make" don't mess up the test bumped fasl file version, since (I think) the change in when #\_ is prepended to foreign symbols breaks old fasl files (and I certainly observe that old fasl files are broken) --- BUGS | 39 +++++++++++++++++++++++++++++++++++++ NEWS | 5 +++++ src/code/early-fasl.lisp | 6 ++++-- src/code/foreign.lisp | 8 +++++--- src/code/load.lisp | 2 +- src/compiler/generic/genesis.lisp | 4 ++-- src/compiler/x86/vm.lisp | 7 +++++-- tests/foreign.test.sh | 14 +++---------- version.lisp-expr | 2 +- 9 files changed, 65 insertions(+), 22 deletions(-) diff --git a/BUGS b/BUGS index 4286531..96b7140 100644 --- a/BUGS +++ b/BUGS @@ -1252,6 +1252,45 @@ WORKAROUND: specialized-element-type slot in the ARRAY-TYPE structure be *WILD-TYPE* for UNKNOWN-TYPE element types. +166: + Compiling + (in-package :cl-user) + (defstruct uustk) + (defmethod permanentize ((uustk uustk)) + (flet ((frob (hash-table test-for-deletion) + ) + (obj-entry.stale? (oe) + (destructuring-bind (key . datum) oe + (declare (type simple-vector key)) + (deny0 (void? datum)) + (some #'stale? key)))) + (declare (inline frob obj-entry.stale?)) + (frob (uustk.args-hash->obj-alist uustk) + #'obj-entry.stale?) + (frob (uustk.hash->memoized-objs-list uustk) + #'objs.stale?)) + (call-next-method)) + in sbcl-0.7.3.11 causes an assertion failure, + failed AVER: + "(NOT +(AND (NULL (BLOCK-SUCC B)) + (NOT (BLOCK-DELETE-P B)) + (NOT (EQ B (COMPONENT-HEAD #)))))" + +167: + In sbcl-0.7.3.11, compiling the (illegal) code + (in-package :cl-user) + (defmethod prove ((uustk uustk)) + (zap ((frob () nil)) + (frob))) + gives the (not terribly clear) error message + ; caught ERROR: + ; (during macroexpansion of (DEFMETHOD PROVE ...)) + ; can't get template for (FROB NIL NIL) + The problem seems to be that the code walker used by the DEFMETHOD + macro is unhappy with the illegal syntax in the method body, and + is giving an unclear error message. + DEFUNCT CATEGORIES OF BUGS IR1-#: These labels were used for bugs related to the old IR1 interpreter. diff --git a/NEWS b/NEWS index 6d6f336..d190480 100644 --- a/NEWS +++ b/NEWS @@ -1106,6 +1106,11 @@ changes in sbcl-0.7.4 relative to sbcl-0.7.3: * bug 147 fixed: The compiler preserves its block link/count invariants more correctly now so that it doesn't crash. (thanks to Alexey Dejneka) + * Dynamic loading of object files in OpenBSD is now supported. (thanks + to Pierre Mai) + * The fasl file format has changed again, because dynamic loading + on OpenBSD (which has non-ELF object files) motivated some cleanups + in the way that foreign symbols are transformed and passed around. planned incompatible changes in 0.7.x: * When the profiling interface settles down, maybe in 0.7.x, maybe diff --git a/src/code/early-fasl.lisp b/src/code/early-fasl.lisp index c592247..84ac9dd 100644 --- a/src/code/early-fasl.lisp +++ b/src/code/early-fasl.lisp @@ -42,7 +42,7 @@ ;;; versions which break binary compatibility. But it certainly should ;;; be incremented for release versions which break binary ;;; compatibility. -(defconstant +fasl-file-version+ 27) +(defconstant +fasl-file-version+ 28) ;;; (record of versions before 0.7.0 deleted in 0.7.1.41) ;;; 23 = sbcl-0.7.0.1 deleted no-longer-used EVAL-STACK stuff, ;;; causing changes in *STATIC-SYMBOLS*. @@ -51,7 +51,9 @@ ;;; 25 = sbcl-0.7.1.41 (and immediately preceding versions, actually) ;;; introduced new functions to check for control stack exhaustion ;;; 26 = sbcl-0.7.2.4 or so added :VARIABLE :MACRO-EXPANSION to INFO codes -;;; 27 (2002-04-08) added MIGHT-CONTAIN-OTHER-TYPES? slot to CTYPE +;;; 27: (2002-04-08) added MIGHT-CONTAIN-OTHER-TYPES? slot to CTYPE +;;; 28: (2002-05-08) new convention for foreign symbols to support +;;; dynamic loading in OpenBSD ;;; the conventional file extension for our fasl files (declaim (type simple-string *fasl-file-type*)) diff --git a/src/code/foreign.lisp b/src/code/foreign.lisp index 4bf5d7c..f6101db 100644 --- a/src/code/foreign.lisp +++ b/src/code/foreign.lisp @@ -63,7 +63,9 @@ ;;; dlsym()-based implementation of GET-DYNAMIC-FOREIGN-SYMBOL-ADDRESS ;;; and functions (e.g. LOAD-FOREIGN) which affect it. This should ;;; work on any ELF system with dlopen(3) and dlsym(3) -#-(or linux FreeBSD) +;;; It also works on OpenBSD, which isn't ELF, but is otherwise modern +;;; enough to have a fairly well working dlopen/dlsym implementation. +#-(or linux FreeBSD OpenBSD) (macrolet ((define-unsupported-fun (fun-name) `(defun ,fun-name (&rest rest) "unsupported on this system" @@ -71,7 +73,7 @@ (error 'unsupported-operator :name ',fun-name)))) (define-unsupported-fun load-1-foreign) (define-unsupported-fun load-foreign)) -#+(or linux FreeBSD) +#+(or linux FreeBSD OpenBSD) (progn ;;; flags for dlopen() @@ -113,7 +115,7 @@ *after-save-initializations*) (defvar *dso-linker* "/usr/bin/ld") -(defvar *dso-linker-options* '("-G" "-o")) +(defvar *dso-linker-options* '("-shared" "-o")) (sb-alien:define-alien-routine dlopen system-area-pointer diff --git a/src/code/load.lisp b/src/code/load.lisp index 4f30cd7..9a37fb2 100644 --- a/src/code/load.lisp +++ b/src/code/load.lisp @@ -354,7 +354,7 @@ (defun find-foreign-symbol-in-table (name table) (let ((prefixes #!+(or linux freebsd) #("" "ldso_stub__") - #!+openbsd #("" "_") + #!+openbsd #("") #!+sunos #("" "ldso_stub__"))) (declare (notinline some)) ; to suppress bug 117 bogowarning (some (lambda (prefix) diff --git a/src/compiler/generic/genesis.lisp b/src/compiler/generic/genesis.lisp index ad844cf..78230e3 100644 --- a/src/compiler/generic/genesis.lisp +++ b/src/compiler/generic/genesis.lisp @@ -1395,7 +1395,7 @@ sb!vm:fdefn-raw-addr-slot (make-random-descriptor (cold-foreign-symbol-address-as-integer - "undefined_tramp")))) + (sb!vm:extern-alien-name "undefined_tramp"))))) fdefn)))) ;;; Handle the at-cold-init-time, fset-for-static-linkage operation @@ -1420,7 +1420,7 @@ (#.sb!vm:closure-header-widetag (make-random-descriptor (cold-foreign-symbol-address-as-integer - "closure_tramp"))))) + (sb!vm:extern-alien-name "closure_tramp")))))) fdefn)) (defun initialize-static-fns () diff --git a/src/compiler/x86/vm.lisp b/src/compiler/x86/vm.lisp index 92f537d..83d0d3c 100644 --- a/src/compiler/x86/vm.lisp +++ b/src/compiler/x86/vm.lisp @@ -444,10 +444,13 @@ (immediate-constant "Immed") (noise (symbol-name (sc-name sc)))))) ;;; FIXME: Could this, and everything that uses it, be made #!+SB-SHOW? + ;;; The loader uses this to convert alien names to the form they need in ;;; the symbol table (for example, prepending an underscore). (defun extern-alien-name (name) (declare (type simple-string name)) - ;; On the X86 we don't do anything. - name) + ;; OpenBSD is non-ELF, and needs a _ prefix + #!+openbsd (concatenate 'string "_" name) + ;; The other (ELF) ports currently don't need any prefix + #!-openbsd name) diff --git a/tests/foreign.test.sh b/tests/foreign.test.sh index eaa3b4b..ee78f51 100644 --- a/tests/foreign.test.sh +++ b/tests/foreign.test.sh @@ -17,20 +17,12 @@ echo //entering foreign.test.sh testfilestem=${TMPDIR:-/tmp}/sbcl-foreign-test-$$ -# FIXME: At least on OpenBSD, the "make $testfilestem.o" puts the -# output file into the current directory, instead of the -# target directory. E.g. "make /tmp/foo.o" causes "./foo.o" to be -# created (!). Since OpenBSD doesn't support LOAD-FOREIGN, this -# doesn't matter much, since it punts with UNSUPPORTED-OPERATOR -# instead of not finding the file. But it'd be nice to straighten -# this out, if only so that sbcl-foreign-test-*.o clutter -# doesn't pile up in this directory. Maybe some time when I have -# several test machines at hand to check the behavior of different -# versions of "make"... +# Make a little shared object file to test with. echo 'int summish(int x, int y) { return 1 + x + y; }' > $testfilestem.c -make $testfilestem.o +cc -c $testfilestem.c -o $testfilestem.o ld -shared -o $testfilestem.so $testfilestem.o +# Test interaction with the shared object file. ${SBCL:-sbcl} <