From: Charlie Savage Date: 2009-03-08T08:19:23+09:00 Subject: [ruby-core:22725] [Bug #1253] Fix MSVC Build Issues Bug #1253: Fix MSVC Build Issues http://redmine.ruby-lang.org/issues/show/1253 Author: Charlie Savage Status: Open, Priority: Normal Category: core, Target version: 1.9.1 ruby -v: ruby 1.9.2dev (2009-03-06) [i386-mswin32_90] The attached patch fixes a couple of linking bugs with MSVC 2008 against head, plus does a bit of makefile cleanup. I'm happy to split the patch into multiple parts if that would make it easier to apply. The patch includes: 1. LDFLAGS not passed to extconf.rb For example, in Makefile set LDFLAGS = -libpath:c:/msvc/lib This path is not passed to exconf.rb, meaning that you can't set the path to third-party extension libraries (zlib/gdbm/readline/iconv/etc). The problem is Makefile.sub: +s,@LDFLAGS@,,;t t This should be +s,@LDFLAGS@,$(LDFLAGS),;t t 2. -link inconsistently handled. In VC, -link is a keyword that separates compiler options from linker options. Makefile.sub is consistent on how it is handled. In some cases: -link ${LDFLAGS} In other cases LDFLAGS = -link .... My view is that -link should *not* be included in LDFLAGS, and thus the patch goes with the first pattern. 3. setup.mak out of date The example compiler/link options specified in setup.mak no longer match what Makefile.sub actually does. The patch fixes this by syncing setup.mak back with Makefile.sub 4. optflags incorrect OPTFLAGS is set to -O2b2xty- which from the MSDN documentation isn't legal. It should simply be O2 (see http://msdn.microsoft.com/en-us/library/k1ack8f1.aspx). 5. warn flags For some reason, Makefile.sub turns off all compiler warnings. That seems a bit counter-productive. The patch turns them back on: !if !defined(WARNFLAGS) WARNFLAGS = -w3 -wd4996 !endif -wd4996 turns of deprecation warnings, to avoid all the silly Microsoft warning about non-iso standard replacements for strlen etc. Let me know if I should split this patch into multiple parts. ---------------------------------------- http://redmine.ruby-lang.org