Patch by Josh Elsasser, lp#615499.
In his words:
"Attached is a patch which moves all the duplicated, out-of-sync C
compiler flag selection in the tests into a single wrapper script.
When passed a flag like -sbcl-pic or -sbcl-shared, the script will
decided if -fPIC or -shared/-bundle is needed based on SOFTWARE-TYPE
and MACHINE-TYPE which SBCL has passed in the environment.
I tested this on several x86 OSes and a couple PowerPC, as well as
SunOS on SPARC and OpenBSD on x86-64. For the -sbcl-pic case I have
verified that -fPIC is needed on OpenBSD-PowerPC, OpenBSD-X86-64,
SunOS-SPARC and SunOS-X86; the other cases are guesses based on the
existing reader conditionals. It is not needed on Darwin or Linux on
PowerPC, or on any x86 OSes I tested aside from SunOS.
I haven't verified that -arch x86_64 is actually needed on
Darwin-X86-64, or that something like -m64 isn't needed on other
X86-64 OSes (aside from OpenBSD)."
(output
(with-output-to-string (s)
(setf proc (run-program program arguments
- :search (not (eql #\. (char program 0)))
+ :environment (test-util::test-env)
:output s)))))
(unless (zerop (process-exit-code proc))
(error "Bad exit code: ~S~%Output:~% ~S"
;;;; fork/exec, so that no lisp is on the stack. This is our known-good
;;;; number.
-(run "cc"
- #+(and (or linux freebsd) (or x86-64 ppc mips)) "-fPIC"
- #+(and x86-64 darwin) "-arch" #+(and x86-64 darwin) "x86_64"
+(run "/bin/sh" "run-compiler.sh" "-sbcl-pic"
"stack-alignment-offset.c" "-o" "stack-alignment-offset")
(defparameter *good-offset*
;;;; Build the tool again, this time as a shared object, and load it
-(run "cc" "stack-alignment-offset.c"
- #+(and (not darwin) (or x86-64 ppc mips)) "-fPIC"
- #+(and x86-64 darwin) "-arch" #+(and x86-64 darwin) "x86_64"
- #+darwin "-bundle" #-darwin "-shared"
- "-o" "stack-alignment-offset.so")
+(run "/bin/sh" "run-compiler.sh" "-sbcl-pic" "-sbcl-shared"
+ "stack-alignment-offset.c" "-o" "stack-alignment-offset.so")
(load-shared-object (truename "stack-alignment-offset.so"))
build_so() (
echo building $1.so
- set +u
- case "`uname -m`" in
- x86_64|amd64|mips|mips64)
- CFLAGS="$CFLAGS -fPIC"
- ;;
- esac
- case "`uname`" in
- Darwin)
- SO_FLAGS="-bundle"
- if run_sbcl --eval '(sb-ext:quit :unix-status #+x86-64 0 #-x86-64 1)'; then
- CFLAGS="$CFLAGS -arch x86_64"
- fi
- ;;
- OpenBSD)
- SO_FLAGS="-shared"
- if [ "`machine -a`" = "powerpc" ]; then
- CFLAGS="$CFLAGS -fPIC"
- fi
- ;;
- *)
- SO_FLAGS="-shared"
- ;;
- esac
- cc -c $1.c -o $1.o $CFLAGS
- ld $SO_FLAGS -o $1.so $1.o
+ /bin/sh ../run-compiler.sh -sbcl-pic -sbcl-shared "$1.c" -o "$1.so"
)
# We want to bail out in case any of these Unix programs fails.
(output
(with-output-to-string (s)
(setf proc (run-program program arguments
- :search (not (eql #\. (char program 0)))
+ :environment (test-util::test-env)
:output s)))))
(unless (zerop (process-exit-code proc))
(error "Bad exit code: ~S~%Output:~% ~S"
output))
output))
-(run "cc" "-O3"
- "-I" "../src/runtime/"
- "kill-non-lisp-thread.c"
- #+(and (or linux freebsd) (or x86-64 ppc mips)) "-fPIC"
- #+(and x86-64 darwin) "-arch" #+(and x86-64 darwin) "x86_64"
- #+darwin "-bundle" #-darwin "-shared"
- "-o" "kill-non-lisp-thread.so")
+(run "/bin/sh" "run-compiler.sh" "-sbcl-pic" "-sbcl-shared"
+ "-O3" "-I" "../src/runtime/"
+ "kill-non-lisp-thread.c" "-o" "kill-non-lisp-thread.so")
(load-shared-object (truename "kill-non-lisp-thread.so"))
--- /dev/null
+#!/bin/sh
+
+platform="${SBCL_SOFTWARE_TYPE}-${SBCL_MACHINE_TYPE}"
+
+case "$platform" in
+ SunOS-*) CC=gcc ;;
+ *) CC=cc ;;
+esac
+
+args=
+case "$platform" in
+ Darwin-X86-64) args="-arch x86_64" ;;
+esac
+
+while [ $# -gt 0 ]; do
+ arg="$1"
+ new=
+ case "$arg" in
+ -sbcl-pic)
+ case "$platform" in
+ FreeBSD-X86-64) new=-fPIC ;;
+ Linux-MIPS) new=-fPIC ;;
+ Linux-X86-64) new=-fPIC ;;
+ NetBSD-PowerPC) new=-fPIC ;;
+ NetBSD-X86-64) new=-fPIC ;;
+ OpenBSD-PowerPC) new=-fPIC ;;
+ OpenBSD-X86-64) new=-fPIC ;;
+ SunOS-SPARC) new=-fPIC ;;
+ SunOS-X86) new=-fPIC ;;
+ SunOS-X86-64) new=-fPIC ;;
+ esac
+ ;;
+
+ -sbcl-shared)
+ case "$platform" in
+ Darwin-*) new=-bundle ;;
+ *) new=-shared ;;
+ esac
+ ;;
+
+ *)
+ break
+ ;;
+ esac
+
+ shift
+ if [ x"$new" != x ]; then
+ args="$args $new"
+ fi
+done
+
+echo "/ $CC $args $@"
+"$CC" $args "$@"
;; What? No SB-POSIX:EXECV?
`(let ((process (sb-ext:run-program "/bin/sh"
(list (native-namestring ,file))
+ :environment (test-util::test-env)
:output *error-output*)))
(sb-ext:quit :unix-status (process-exit-code process))))
(output
(with-output-to-string (s)
(setf proc (run-program program arguments
- :search (not (eql #\. (char program 0)))
+ :environment (test-util::test-env)
:output s)))))
(unless (zerop (process-exit-code proc))
(error "Bad exit code: ~S~%Output:~% ~S"
output))
output))
-(run "cc" "-O3"
- "-I" "../src/runtime/"
- "swap-lispobjs.c"
- #+(and (or linux freebsd) (or x86-64 ppc mips)) "-fPIC"
- #+(and x86-64 darwin) "-arch" #+(and x86-64 darwin) "x86_64"
- #+darwin "-bundle" #-darwin "-shared"
- "-o" "swap-lispobjs.so")
+(run "/bin/sh" "run-compiler.sh"
+ "-sbcl-pic" "-sbcl-shared"
+ "-O3" "-I" "../src/runtime/"
+ "swap-lispobjs.c" "-o" "swap-lispobjs.so")
(load-shared-object (truename "swap-lispobjs.so"))
(let ((*invoke-debugger-hook* *invoke-debugger-hook*))
(enable-debugger)
(invoke-debugger condition))))
+
+(defun test-env ()
+ (cons (format nil "SBCL_MACHINE_TYPE=~A" (machine-type))
+ (cons (format nil "SBCL_SOFTWARE_TYPE=~A" (software-type))
+ (posix-environ))))
(with-open-file (o "threads-foreign.c" :direction :output :if-exists :supersede)
(format o "void loop_forever() { while(1) ; }~%"))
-(sb-ext:run-program
- #-sunos "cc" #+sunos "gcc"
- (or #+(or linux freebsd sunos) '(#+x86-64 "-fPIC"
- "-shared" "-o" "threads-foreign.so" "threads-foreign.c")
- #+darwin '(#+x86-64 "-arch" #+x86-64 "x86_64"
- "-dynamiclib" "-o" "threads-foreign.so" "threads-foreign.c")
- (error "Missing shared library compilation options for this platform"))
- :search t)
+(sb-ext:run-program "/bin/sh"
+ '("run-compiler.sh" "-sbcl-pic" "-sbcl-shared"
+ "-o" "threads-foreign.so" "threads-foreign.c")
+ :environment (test-util::test-env))
(sb-alien:load-shared-object (truename "threads-foreign.so"))
(sb-alien:define-alien-routine loop-forever sb-alien:void)
(delete-file "threads-foreign.c")
;;; 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.42.19"
+"1.0.42.20"