From bd2df60f7c3f579a9c7610925c79a0e783adaa0e Mon Sep 17 00:00:00 2001 From: Cyrus Harmon Date: Thu, 3 Jun 2010 04:39:50 +0000 Subject: [PATCH] 1.0.39.3: support building on darwin x86 and x86-64 without the dlshim * x86 config -mmacosx-version-min cleanup * remove dlshim feature in make-config.sh * fix extern-alien-name and ldso naming conventions * kludge in load-cold-foreign-symbol-table to strip off the leading #\_ from the nm parsing * change dependency on ldso stubs for dlopen and friends to be #!-dlshim instead of #!-darwin * remove Config.x86-64-darwin9+ and replace with makefile conditionals * add :dlshim feature for darwin in make-config.sh and rework the darwin9+ stuff * make grovel-headers.c load genesis/config.h first so that we can use the LISP_FEATURE_xxx conditionals earlier --- NEWS | 2 ++ make-config.sh | 13 ++++++------- src/code/foreign.lisp | 9 +++++---- src/compiler/generic/genesis.lisp | 7 +++++++ src/runtime/Config.x86-64-darwin | 18 ++++++++++++++++-- src/runtime/Config.x86-64-darwin9+ | 31 ------------------------------- src/runtime/Config.x86-darwin | 18 +++++++++++++++--- src/runtime/darwin-os.c | 4 ++++ tools-for-build/grovel-headers.c | 11 ++++++----- tools-for-build/ldso-stubs.lisp | 10 +++++----- version.lisp-expr | 2 +- 11 files changed, 67 insertions(+), 58 deletions(-) delete mode 100644 src/runtime/Config.x86-64-darwin9+ diff --git a/NEWS b/NEWS index 1a17085..87c8c0e 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ changes relative to sbcl-1.0.39: * bug fix: Name conflicts between symbols passed as arguments to a single call to IMPORT no longer add multiple symbols with the same name to the package (detectable via DO-SYMBOLS). + * bug fix: support building without the dlshim on darwin x86 and x86-64 + (lp#533470). changes in sbcl-1.0.39 relative to sbcl-1.0.38: * bug fix: Backtrace from undefined function on x86 and x86-64 now show diff --git a/make-config.sh b/make-config.sh index afa9350..84b34f5 100644 --- a/make-config.sh +++ b/make-config.sh @@ -146,12 +146,11 @@ echo //setting up OS-dependent information # Under Darwin x86-64, guess whether Darwin 9+ or below. if [ "$sbcl_os" = "darwin" ] && [ "$sbcl_arch" = "x86-64" ]; then - darwin_version=`uname -r` - darwin_version_major=${DARWIN_VERSION_MAJOR:-${darwin_version%%.*}} - if (( 8 < $darwin_version_major )); then - ver9_or_above="9+" - printf ' :inode64' >> $ltf - fi + darwin_version=`uname -r` + darwin_version_major=${DARWIN_VERSION_MAJOR:-${darwin_version%%.*}} + if (( 8 < $darwin_version_major )); then + printf ' :inode64 :darwin9-or-better' >> $ltf + fi fi original_dir=`pwd` @@ -247,7 +246,7 @@ case "$sbcl_os" in fi link_or_copy $sbcl_arch-darwin-os.h target-arch-os.h link_or_copy bsd-os.h target-os.h - link_or_copy Config.$sbcl_arch-darwin$ver9_or_above Config + link_or_copy Config.$sbcl_arch-darwin Config ;; sunos) printf ' :unix' >> $ltf diff --git a/src/code/foreign.lisp b/src/code/foreign.lisp index bd89cd8..e81185d 100644 --- a/src/code/foreign.lisp +++ b/src/code/foreign.lisp @@ -16,8 +16,8 @@ (defun extern-alien-name (name) (handler-case - #!+elf (coerce name 'base-string) - #!+(or mach-o win32) (concatenate 'base-string "_" name) + #!+(or elf (and mach-o (not dlshim))) (coerce name 'base-string) + #!+(or (and mach-o dlshim) win32) (concatenate 'base-string "_" name) (error () (error "invalid external alien name: ~S" name)))) @@ -35,8 +35,9 @@ (values (or (gethash extern table) (gethash (concatenate 'base-string - #!+(and darwin (or x86 x86-64 ppc)) "_ldso_stub__" - #!-(and darwin (or x86 x86-64 ppc)) "ldso_stub__" + #!+(and mach-o dlshim) "_ldso_stub_" + #!+(and mach-o (not dlshim)) "ldso_stub__" + #!-mach-o "ldso_stub__" extern) table))))) (defun find-foreign-symbol-address (name) diff --git a/src/compiler/generic/genesis.lisp b/src/compiler/generic/genesis.lisp index 6470fda..bfea5da 100644 --- a/src/compiler/generic/genesis.lisp +++ b/src/compiler/generic/genesis.lisp @@ -1597,6 +1597,13 @@ core and return a descriptor to it." (subseq line (1+ p2))) (values (parse-integer line :end p1 :radix 16) (subseq line (1+ p2)))) + ; KLUDGE CLH 2010-05-31: on darwin, nm gives us + ;; _function but dlsym expects us to look up + ;; function, without the leading _ . Therefore, we + ;; strip it off here. + #!+(and darwin (not dlshim)) + (when (equal (char name 0) #\_) + (setf name (subseq name 1))) (multiple-value-bind (old-value found) (gethash name *cold-foreign-symbol-table*) (when (and found diff --git a/src/runtime/Config.x86-64-darwin b/src/runtime/Config.x86-64-darwin index e6fffb9..c62c343 100644 --- a/src/runtime/Config.x86-64-darwin +++ b/src/runtime/Config.x86-64-darwin @@ -9,9 +9,23 @@ # provided with absolutely no warranty. See the COPYING and CREDITS # files for more information. -CFLAGS = -g -Wall -O2 -fdollars-in-identifiers -mmacosx-version-min=10.4 +CFLAGS = -g -Wall -O2 -fdollars-in-identifiers +ifdef LISP_FEATURE_DARWIN9_OR_BETTER +CFLAGS += -mmacosx-version-min=10.5 +LINKFLAGS += -mmacosx-version-min=10.5 +else +CFLAGS += -mmacosx-version-min=10.4 LINKFLAGS += -mmacosx-version-min=10.4 -OS_SRC = bsd-os.c x86-64-bsd-os.c darwin-os.c x86-64-darwin-os.c darwin-dlshim.c darwin-langinfo.c +endif +ifdef LISP_FEATURE_INODE64 +CFLAGS += -D_DARWIN_USE_64_BIT_INODE +endif + +OS_SRC = bsd-os.c x86-64-bsd-os.c darwin-os.c x86-64-darwin-os.c darwin-langinfo.c +ifdef LISP_FEATURE_DLSHIM + OS_SRC += darwin-dlshim.c +endif + OS_LIBS = -lSystem -lc -ldl ifdef LISP_FEATURE_SB_THREAD OS_LIBS += -lpthread diff --git a/src/runtime/Config.x86-64-darwin9+ b/src/runtime/Config.x86-64-darwin9+ deleted file mode 100644 index 3da837d..0000000 --- a/src/runtime/Config.x86-64-darwin9+ +++ /dev/null @@ -1,31 +0,0 @@ -# -*- makefile -*- for the C-level run-time support for SBCL - -# 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. - -CFLAGS = -g -Wall -O2 -fdollars-in-identifiers -mmacosx-version-min=10.5 -D_DARWIN_USE_64_BIT_INODE -LINKFLAGS += -mmacosx-version-min=10.5 -OS_SRC = bsd-os.c x86-64-bsd-os.c darwin-os.c x86-64-darwin-os.c darwin-dlshim.c darwin-langinfo.c -OS_LIBS = -lSystem -lc -ldl -ifdef LISP_FEATURE_SB_THREAD - OS_LIBS += -lpthread -endif - -ASSEM_SRC = x86-64-assem.S ldso-stubs.S -ARCH_SRC = x86-64-arch.c - -LINKFLAGS += -arch x86_64 -dynamic -twolevel_namespace -bind_at_load -pagezero_size 0x100000 - -CFLAGS += -arch x86_64 -fno-omit-frame-pointer -pagezero_size 0x100000 - -GC_SRC = gencgc.c - -# Nothing to do for after-grovel-headers. -.PHONY: after-grovel-headers -after-grovel-headers: diff --git a/src/runtime/Config.x86-darwin b/src/runtime/Config.x86-darwin index ff19612..b05880e 100644 --- a/src/runtime/Config.x86-darwin +++ b/src/runtime/Config.x86-darwin @@ -9,9 +9,21 @@ # provided with absolutely no warranty. See the COPYING and CREDITS # files for more information. -CFLAGS = -arch i386 -g -Wall -O2 -fdollars-in-identifiers -mmacosx-version-min=10.4 -LINKFLAGS += -arch i386 -mmacosx-version-min=10.4 -OS_SRC = bsd-os.c x86-bsd-os.c darwin-os.c x86-darwin-os.c darwin-dlshim.c darwin-langinfo.c +CFLAGS = -arch i386 -g -Wall -O2 -fdollars-in-identifiers +LINKFLAGS += -arch i386 +ifdef LISP_FEATURE_DARWIN9_OR_BETTER +CFLAGS += -mmacosx-version-min=10.5 +LINKFLAGS += -mmacosx-version-min=10.5 +else +CFLAGS += -mmacosx-version-min=10.4 +LINKFLAGS += -mmacosx-version-min=10.4 +endif + +OS_SRC = bsd-os.c x86-bsd-os.c darwin-os.c x86-darwin-os.c darwin-langinfo.c +ifdef LISP_FEATURE_DLSHIM + OS_SRC += darwin-dlshim.c +endif + OS_LIBS = -lSystem -lc -ldl ifdef LISP_FEATURE_SB_THREAD OS_LIBS += -lpthread diff --git a/src/runtime/darwin-os.c b/src/runtime/darwin-os.c index 95de326..7bfc735 100644 --- a/src/runtime/darwin-os.c +++ b/src/runtime/darwin-os.c @@ -23,6 +23,10 @@ #include "bsd-os.h" #include +#ifndef LISP_FEATURE_DLSHIM +#include +#endif + char * os_get_runtime_executable_path(int external) { diff --git a/tools-for-build/grovel-headers.c b/tools-for-build/grovel-headers.c index 6c42bd1..2058cad 100644 --- a/tools-for-build/grovel-headers.c +++ b/tools-for-build/grovel-headers.c @@ -18,6 +18,8 @@ * more information. */ +#include "genesis/config.h" + #include #include #include @@ -34,12 +36,13 @@ #include #include #include - #ifdef __APPLE_CC__ - #include "../src/runtime/darwin-dlshim.h" + #ifdef LISP_FEATURE_DARWIN #include "../src/runtime/darwin-langinfo.h" + #endif + #ifdef LISP_FEATURE_DLSHIM + #include "../src/runtime/darwin-dlshim.h" #else #include - #include #endif #endif @@ -49,8 +52,6 @@ #include #include -#include "genesis/config.h" - #ifdef LISP_FEATURE_HPUX #include /* for TIOCGPGRP */ #endif diff --git a/tools-for-build/ldso-stubs.lisp b/tools-for-build/ldso-stubs.lisp index bbb7e9e..bff22d8 100644 --- a/tools-for-build/ldso-stubs.lisp +++ b/tools-for-build/ldso-stubs.lisp @@ -133,8 +133,8 @@ ldso_stub__ ## fct ## $lazy_ptr: @\\ #define LDSO_STUBIFY(fct) \\ .text ; \\ .align 4 ; \\ -.globl _ldso_stub___ ## fct ; \\ -_ldso_stub___ ## fct: ; \\ +.globl _ldso_stub__ ## fct ; \\ +_ldso_stub__ ## fct: ; \\ jmp L ## fct ## $stub ; \\ .section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5 ; \\ L ## fct ## $stub: ; \\ @@ -150,8 +150,8 @@ L ## fct ## $stub: ; \\ #!+(and darwin x86-64) " #define LDSO_STUBIFY(fct) \\ .align 4 ; \\ -.globl _ldso_stub___ ## fct ; \\ -_ldso_stub___ ## fct: ; \\ +.globl _ldso_stub__ ## fct ; \\ +_ldso_stub__ ## fct: ; \\ jmp _ ## fct ; \\ .L ## fct ## e1: ; " @@ -324,7 +324,7 @@ ldso_stub__ ## fct: ; \\ "unlockpt") #!+openbsd '("openpty") - #!-darwin + #!-dlshim '("dlclose" "dlerror" "dlopen" diff --git a/version.lisp-expr b/version.lisp-expr index 2fdd2ce..a24e0fc 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; 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".) -"1.0.39.2" +"1.0.39.3" -- 1.7.10.4