Invoke gcc in a more portable fashion.
-#include <alloca.h>
 #include <string.h>
 
 #define SIZE 128*1024 // twice the largest page size
 
          (output
           (with-output-to-string (s)
             (setf proc (run-program program arguments
-                                    :environment (test-util::test-env)
                                     :output s)))))
     (unless (zerop (process-exit-code proc))
       (error "Bad exit code: ~S~%Output:~% ~S"
 
          (output
           (with-output-to-string (s)
             (setf proc (run-program program arguments
-                                    :environment (test-util::test-env)
                                     :output s)))))
     (unless (zerop (process-exit-code proc))
       (error "Bad exit code: ~S~%Output:~% ~S"
 
   ;; 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*)))
      (let ((*failures* nil))
        (test-util:report-test-status))
 
          (output
           (with-output-to-string (s)
             (setf proc (run-program program arguments
-                                    :environment (test-util::test-env)
                                     :output s)))))
     (unless (zerop (process-exit-code proc))
       (error "Bad exit code: ~S~%Output:~% ~S"
 
 (defvar *threads-to-kill*)
 (defvar *threads-to-join*)
 
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (require :sb-posix))
+
+;;; run-program on Windows doesn't have an :environment parameter,
+;;; set these globally
+(sb-posix:putenv (format nil "SBCL_MACHINE_TYPE=~A" (machine-type)))
+(sb-posix:putenv (format nil "SBCL_SOFTWARE_TYPE=~A" (software-type)))
+
 #+sb-thread
 (defun make-kill-thread (&rest args)
   (let ((thread (apply #'sb-thread:make-thread args)))
 (defun skipped-p (skipped-on)
   (sb-impl::featurep skipped-on))
 
-(defun test-env ()
-  (cons (format nil "SBCL_MACHINE_TYPE=~A" (machine-type))
-        (cons (format nil "SBCL_SOFTWARE_TYPE=~A" (software-type))
-              (posix-environ))))
-
 ;;; Repeat calling THUNK until its cumulated runtime, measured using
 ;;; GET-INTERNAL-RUN-TIME, is larger than PRECISION. Repeat this
 ;;; REPETITIONS many times and return the time one call to THUNK took
 
     (format o "void loop_forever() { while(1) ; }~%"))
   (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))
+                        "-o" "threads-foreign.so" "threads-foreign.c"))
   (sb-alien:load-shared-object (truename "threads-foreign.so"))
   (sb-alien:define-alien-routine loop-forever sb-alien:void)
   (delete-file "threads-foreign.c"))
     (assert (eq result :ok))))
 
 (with-test (:name :thread-alloca)
-  (sb-ext:run-program "/bin/sh"
+  (sb-ext:run-program "sh"
                       '("run-compiler.sh" "-sbcl-pic" "-sbcl-shared"
                         "alloca.c" "-o" "alloca.so")
-                      :environment (test-util::test-env))
-
+                      :search t)
   (load-shared-object (truename "alloca.so"))
 
   (alien-funcall (extern-alien "alloca_test" (function void)))