From f8aeed279b0c9dcd133b5c380e00255ac5d1faed Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 25 Apr 2017 15:42:53 -0700 Subject: [PATCH] Windows: fix 64-bit mzdyn.exp Also, make the `raco exe` tests more accommodating to uncooperative Windows configurations. --- .../tests/compiler/embed/test.rkt | 30 +++++++++++++++---- racket/src/racket/dynsrc/mkmzdyn.bat | 8 ++++- racket/src/worksp/gc2/make.rkt | 3 +- racket/src/worksp/racket/racket.vcproj | 16 +++++----- racket/src/worksp/racket/racket.vcxproj | 2 +- 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/pkgs/compiler-test/tests/compiler/embed/test.rkt b/pkgs/compiler-test/tests/compiler/embed/test.rkt index 2659443059..64b691254c 100644 --- a/pkgs/compiler-test/tests/compiler/embed/test.rkt +++ b/pkgs/compiler-test/tests/compiler/embed/test.rkt @@ -44,10 +44,23 @@ [else "bin"]) (mk-dest-bin #t))) +(define (call-with-retries thunk) + (let loop ([sleep-time 0.01]) + (with-handlers ([exn:fail:filesystem? (lambda (exn) + ;; Accommodate Windows background tasks, + ;; like anti-virus software and indexing, + ;; that can prevent an ".exe" from being deleted + (if (= sleep-time 1.0) + (raise exn) + (begin + (sleep sleep-time) + (loop (* 2 sleep-time)))))]) + (thunk)))) + (define (prepare exe src) (printf "Making ~a with ~a...\n" exe src) (when (file-exists? exe) - (delete-file exe))) + (call-with-retries (lambda () (delete-file exe))))) (define (try-one-exe exe expect mred?) (printf "Running ~a\n" exe) @@ -76,8 +89,10 @@ (test #t path (parameterize ([current-output-port out]) - (system* path)))))) - (delete-directory/files temp-home-dir) + (system* path)))))) + (call-with-retries + (lambda () + (delete-directory/files temp-home-dir))) (let ([stdout-file (build-path (find-system-path 'temp-dir) "stdout")]) (if (file-exists? stdout-file) (test expect with-input-from-file stdout-file @@ -90,7 +105,9 @@ ;; Build a distribution directory, and try that, too: (printf " ... from distribution ...\n") (when (directory-exists? dist-dir) - (delete-directory/files dist-dir)) + (call-with-retries + (lambda () + (delete-directory/files dist-dir)))) (assemble-distribution dist-dir (list exe) #:copy-collects collects) (dist-hook) (try-one-exe (build-path dist-dir @@ -98,7 +115,10 @@ dist-mred-exe dist-mz-exe)) expect mred?) - (delete-directory/files dist-dir))) + (when (directory-exists? dist-dir) + (call-with-retries + (lambda () + (delete-directory/files dist-dir)))))) (define (base-compile e) (parameterize ([current-namespace (make-base-namespace)]) diff --git a/racket/src/racket/dynsrc/mkmzdyn.bat b/racket/src/racket/dynsrc/mkmzdyn.bat index e9f31e44dc..4f0b6fac70 100644 --- a/racket/src/racket/dynsrc/mkmzdyn.bat +++ b/racket/src/racket/dynsrc/mkmzdyn.bat @@ -1,4 +1,5 @@ set BUILD_CONFIG=%1 +set PLATFORM_CONFIG=%2 if "%BUILD_CONFIG%"=="SDebug" goto asdebug if "%BUILD_CONFIG%"=="BDebug" goto asdebug @@ -11,7 +12,12 @@ cl /Od /D"_DEBUG" /RTC1 /MTd /GS /W3 -I../include -I../../worksp /c mzdyn.c :finish -lib -def:mzdyn.def -out:mzdyn.lib +set MACHTYPE=x64 +if "%PLATFORM_CONFIG%"=="Win32" goto machready +set MACHTYPE=X86 +:machready + +lib -MACHINE:%MACHTYPE% -def:mzdyn.def -out:mzdyn.lib mkdir ..\..\..\lib mkdir ..\..\..\lib\msvc diff --git a/racket/src/worksp/gc2/make.rkt b/racket/src/worksp/gc2/make.rkt index b6f09a35e1..54eda4aca4 100644 --- a/racket/src/worksp/gc2/make.rkt +++ b/racket/src/worksp/gc2/make.rkt @@ -401,7 +401,8 @@ (system- (format "~a /MT /O2 /DMZ_PRECISE_GC /I../../racket/include /I.. /c ../../racket/dynsrc/mzdyn.c /Fomzdyn3m.obj" cl.exe)) -(system- "lib.exe -def:../../racket/dynsrc/mzdyn.def -out:mzdyn3m.lib") +(system- (format "lib.exe -machine:~a -def:../../racket/dynsrc/mzdyn.def -out:mzdyn3m.lib" + (if win64? "x64" "X86"))) (define (copy-file/diff src dest) (unless (and (file-exists? dest) diff --git a/racket/src/worksp/racket/racket.vcproj b/racket/src/worksp/racket/racket.vcproj index 6461624e1c..1311c9cad9 100644 --- a/racket/src/worksp/racket/racket.vcproj +++ b/racket/src/worksp/racket/racket.vcproj @@ -60,7 +60,7 @@ /> diff --git a/racket/src/worksp/racket/racket.vcxproj b/racket/src/worksp/racket/racket.vcxproj index f4574c13b5..cacff47628 100644 --- a/racket/src/worksp/racket/racket.vcxproj +++ b/racket/src/worksp/racket/racket.vcxproj @@ -95,7 +95,7 @@ exit 1 "$(TargetPath)" -cu ..\..\racket\mkincludes.rkt "$(TargetDir)/include/" ..\..\racket .. if errorlevel 1 exit 1 cd ..\..\racket\dynsrc -call mkmzdyn.bat $(Configuration) +call mkmzdyn.bat $(Configuration) $(Platform) cd ..\..\worksp\racket addman.bat