Skip to content

Commit

Permalink
internal hooks to build "Racket.exe" without "libracket3m.dll"
Browse files Browse the repository at this point in the history
For now, setting `libracket-dll?` to #f in
  racket/src/worksp/gc2/make.rkt
enables that build mode.
  • Loading branch information
mflatt committed Mar 28, 2015
1 parent cae1626 commit 5fff8e2
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 39 deletions.
2 changes: 2 additions & 0 deletions racket/.gitignore
Expand Up @@ -15,6 +15,8 @@
/*.pdb
/*.ilk
/*.suo
/*.lib
/*.exp
/lib/*.pdb
/lib/*.ilk
/lib/*.suo
Expand Down
1 change: 1 addition & 0 deletions racket/src/racket/include/schthread.h
Expand Up @@ -55,6 +55,7 @@ extern "C" {
# define MZ_DLLIMPORT __declspec(dllimport)
# define MZ_DLLEXPORT __declspec(dllexport)
# if (defined(__mzscheme_private__) || defined(__MINGW32_DELAY_LOAD__) \
|| defined(MZ_NO_LIBRACKET_DLL) \
|| (defined(__CYGWIN32__) && !defined(MZ_USES_SHARED_LIB)))
# define MZ_DLLSPEC __declspec(dllexport)
# else
Expand Down
6 changes: 4 additions & 2 deletions racket/src/racket/main.c
Expand Up @@ -306,11 +306,13 @@ void load_delayed()
{
(void)SetErrorMode(SEM_FAILCRITICALERRORS);

# ifndef MZ_NO_LIBRACKET_DLL
/* Order matters: load dependencies first */
# ifndef MZ_PRECISE_GC
# ifndef MZ_PRECISE_GC
load_delayed_dll(NULL, "libmzgcxxxxxxx.dll");
# endif
# endif
load_delayed_dll(NULL, "libracket" DLL_3M_SUFFIX "xxxxxxx.dll");
# endif
record_dll_path();
# ifdef IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS
# ifdef __MINGW32__
Expand Down
96 changes: 59 additions & 37 deletions racket/src/worksp/gc2/make.rkt
Expand Up @@ -8,6 +8,11 @@
(eprintf "~a\n" s)
(system s))

;; When `use-libracket-dll?` is #f, "[G]Racket.exe" embeds the content of
;; "libracket3m.dll". The "libracket3m.dll" DLL is still created for
;; use by other parts of the build, such as MzCOM.
(define use-libracket-dll? #t)

(define backtrace-gc? #f)
(define opt-flags "/O2 /Oy-")
(define re:only #f)
Expand Down Expand Up @@ -202,14 +207,19 @@
mz-inc
"xsrc/precomp.h"
""
(string-append "/D LIBMZ_EXPORTS "
(if backtrace-gc?
"/D MZ_GC_BACKTRACE "
""))
(if backtrace-gc?
"/D MZ_GC_BACKTRACE "
"")
"mz.pch"
#f))
srcs)


(define main-c-flags
(if use-libracket-dll?
""
"/D MZ_NO_LIBRACKET_DLL "))

(try "../../racket/main.c"
(list* "../../racket/main.c"
common-deps)
Expand All @@ -218,7 +228,7 @@
mz-inc
#f
""
""
main-c-flags
#f
#t)

Expand Down Expand Up @@ -308,20 +318,21 @@
""))))
(error 'winmake "~a link failed" (if exe? "EXE" "DLL"))))))

(let ([objs (list*
"xsrc/gc2.obj"
"xsrc/mzsj86.obj"
"xsrc/foreign.obj"
(find-build-file "libracket" "gmp.obj")
(find-build-file "racket" "libffi.lib")
(append
(let ([f (and win64?
(find-build-file "libracket" "mzsj86w64.obj"))])
(if (and f (file-exists? f))
(list f)
null))
(map (lambda (n) (format "xsrc/~a.obj" n)) srcs)))])
(link-dll objs null null dll "" #f))
(define libracket-objs
(list*
"xsrc/gc2.obj"
"xsrc/mzsj86.obj"
"xsrc/foreign.obj"
(find-build-file "libracket" "gmp.obj")
(find-build-file "racket" "libffi.lib")
(append
(let ([f (and win64?
(find-build-file "libracket" "mzsj86w64.obj"))])
(if (and f (file-exists? f))
(list f)
null))
(map (lambda (n) (format "xsrc/~a.obj" n)) srcs))))
(link-dll libracket-objs null null dll "" #f)

(define (check-rc res rc)
(unless (and (file-exists? res)
Expand All @@ -333,14 +344,26 @@

(check-rc "racket.res" "../racket/racket.rc")

(let ([objs (list
"racket.res"
"xsrc/main.obj"
"../../../lib/msvc/libracket3mxxxxxxx.lib")])
(link-dll objs
'("libracket3mxxxxxxx.dll")
'("delayimp.lib")
exe "" #t))
(define (link-exe objs libs exe subsystem-flags)
(link-dll (append objs (if use-libracket-dll?
(list
"../../../lib/msvc/libracket3mxxxxxxx.lib")
libracket-objs))
(if use-libracket-dll?
'("libracket3mxxxxxxx.dll")
null)
(append libs
(if use-libracket-dll?
'("delayimp.lib")
null))
exe subsystem-flags #t))

(link-exe (list
"racket.res"
"xsrc/main.obj")
null
exe
"")
(system- "mt.exe -manifest ../racket/racket.manifest -outputresource:../../../Racket.exe;1")

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand All @@ -358,21 +381,20 @@
wx-inc
#f
""
"/DWIN32 "
(string-append
"/DWIN32 "
main-c-flags)
#f
#t)

(check-rc "gracket.res" "../gracket/gracket.rc")

(let ([objs (list
"gracket.res"
"xsrc/grmain.obj"
"../../../lib/msvc/libracket3mxxxxxxx.lib")])
(link-dll objs
'("libracket3mxxxxxxx.dll")
'("advapi32.lib"
"delayimp.lib")
"../../../lib/GRacket.exe" " /subsystem:windows" #t))
(link-exe (list
"gracket.res"
"xsrc/grmain.obj")
'("advapi32.lib")
"../../../lib/GRacket.exe"
" /subsystem:windows")
(system- "mt.exe -manifest ../gracket/gracket.manifest -outputresource:../../../lib/GRacket.exe;1")

(system- (format "~a /MT /O2 /DMZ_PRECISE_GC /I../../racket/include /I.. /c ../../racket/dynsrc/mzdyn.c /Fomzdyn3m.obj"
Expand Down

0 comments on commit 5fff8e2

Please sign in to comment.