From: Nikodemus Siivola Date: Wed, 1 Sep 2010 17:21:07 +0000 (+0000) Subject: 1.0.42.20: use platform-dependent CFLAGS consistently in tests X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=01b41fdd69d197da85f86a2e4f8971f3ef9dda82;p=sbcl.git 1.0.42.20: use platform-dependent CFLAGS consistently in tests 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)." --- diff --git a/tests/foreign-stack-alignment.impure.lisp b/tests/foreign-stack-alignment.impure.lisp index 4ca957d..069c5e8 100644 --- a/tests/foreign-stack-alignment.impure.lisp +++ b/tests/foreign-stack-alignment.impure.lisp @@ -22,7 +22,7 @@ (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" @@ -43,9 +43,7 @@ ;;;; 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* @@ -54,11 +52,8 @@ ;;;; 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")) diff --git a/tests/foreign.test.sh b/tests/foreign.test.sh index 2c5d0d3..bc97a83 100644 --- a/tests/foreign.test.sh +++ b/tests/foreign.test.sh @@ -30,31 +30,7 @@ PUNT=$EXIT_TEST_WIN 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. diff --git a/tests/kill-non-lisp-thread.impure.lisp b/tests/kill-non-lisp-thread.impure.lisp index 8a4b661..29680cc 100644 --- a/tests/kill-non-lisp-thread.impure.lisp +++ b/tests/kill-non-lisp-thread.impure.lisp @@ -21,7 +21,7 @@ (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" @@ -29,13 +29,9 @@ 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")) diff --git a/tests/run-compiler.sh b/tests/run-compiler.sh new file mode 100644 index 0000000..3532fe3 --- /dev/null +++ b/tests/run-compiler.sh @@ -0,0 +1,53 @@ +#!/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 "$@" diff --git a/tests/run-tests.lisp b/tests/run-tests.lisp index d2942b1..8cb583f 100644 --- a/tests/run-tests.lisp +++ b/tests/run-tests.lisp @@ -188,6 +188,7 @@ ;; 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)))) diff --git a/tests/swap-lispobjs.impure.lisp b/tests/swap-lispobjs.impure.lisp index c3cf6f5..b3c2f49 100644 --- a/tests/swap-lispobjs.impure.lisp +++ b/tests/swap-lispobjs.impure.lisp @@ -21,7 +21,7 @@ (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" @@ -29,13 +29,10 @@ 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")) diff --git a/tests/test-util.lisp b/tests/test-util.lisp index f9ca05f..cdc422c 100644 --- a/tests/test-util.lisp +++ b/tests/test-util.lisp @@ -65,3 +65,8 @@ (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)))) diff --git a/tests/threads.impure.lisp b/tests/threads.impure.lisp index 4205a00..1dc2e04 100644 --- a/tests/threads.impure.lisp +++ b/tests/threads.impure.lisp @@ -198,14 +198,10 @@ (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") diff --git a/version.lisp-expr b/version.lisp-expr index 7a89c31..0dfe4aa 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.42.19" +"1.0.42.20"