Skip to content

Commit

Permalink
1.0.39.3: support building on darwin x86 and x86-64 without the dlshim
Browse files Browse the repository at this point in the history
  * 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
  • Loading branch information
Cyrus Harmon committed Jun 3, 2010
1 parent 46b1591 commit bd2df60
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 58 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions make-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/code/foreign.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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))))

Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions src/compiler/generic/genesis.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions src/runtime/Config.x86-64-darwin
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 0 additions & 31 deletions src/runtime/Config.x86-64-darwin9+

This file was deleted.

18 changes: 15 additions & 3 deletions src/runtime/Config.x86-darwin
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/darwin-os.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include "bsd-os.h"
#include <errno.h>

#ifndef LISP_FEATURE_DLSHIM
#include <dlfcn.h>
#endif

char *
os_get_runtime_executable_path(int external)
{
Expand Down
11 changes: 6 additions & 5 deletions tools-for-build/grovel-headers.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* more information.
*/

#include "genesis/config.h"

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
Expand All @@ -34,12 +36,13 @@
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/termios.h>
#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 <dlfcn.h>
#include <langinfo.h>
#endif
#endif

Expand All @@ -49,8 +52,6 @@
#include <signal.h>
#include <errno.h>

#include "genesis/config.h"

#ifdef LISP_FEATURE_HPUX
#include <sys/bsdtty.h> /* for TIOCGPGRP */
#endif
Expand Down
10 changes: 5 additions & 5 deletions tools-for-build/ldso-stubs.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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: ; \\
Expand All @@ -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: ; "

Expand Down Expand Up @@ -324,7 +324,7 @@ ldso_stub__ ## fct: ; \\
"unlockpt")
#!+openbsd
'("openpty")
#!-darwin
#!-dlshim
'("dlclose"
"dlerror"
"dlopen"
Expand Down
2 changes: 1 addition & 1 deletion version.lisp-expr
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit bd2df60

Please sign in to comment.