Bug #1293: revision.h not correctly updated in common.mk
http://redmine.ruby-lang.org/issues/show/1293

Author: Charlie Savage
Status: Open, Priority: Normal
Category: core, Target version: 1.9.1
ruby -v: ruby 1.9.2dev (2009-03-15) [i386-mswin32_90]

Ok, this one took a long time to figure out.

Check out and build Ruby.  Wait a day or two.  Recheck out ruby.  Remake, re install it.

Notice that after the do-install action is run, the do-install-doc action is executed. And surprisingly, it rebuilds ruby.exe and ruby.dll.  The result is the installed versions of ruby are *older* than the built versions in win32.  For a debug build that is really annoying because the debug info files are out of date with the executables, meaning you get no symbols or source code (at least with VC2008).

Tracing through NMake, the problem lies in revision.h.  Debug output from nmake:

Sat, Mar 14 2009 15:07:04                       ./..\version.h
Sat, Mar 14 2009 15:07:04                         ./..\version.h
Sun, Mar 15 2009 01:53:50                         ./../ChangeLog
Sun, Mar 01 2009 01:32:42                         ./../tool/file2lastrev.rb
Sun, Mar 15 2009 01:52:54                       ./../revision.h
        c:\DEVELO~1\ruby\bin\ruby.exe ./../tool/file2lastrev.rb --revision.h "./.." > "./../revision.h.tmp"
        C:\Windows\system32\cmd.exe /C .\..\win32\ifchange.bat "./../revision.h" "./../revision.h.tmp"
Wed, Mar 11 2009 00:40:03                       ./../include/ruby\win32.h
Sun, Mar 15 2009 01:59:07                     version.obj

Notice the Changelog is older than revision.h.  That causes a chain reaction:

* version.obj is rebuilt
* miniruby.exe is rebuilt
* prelude.c is rebuilt
* ruby19.dll is rebuilt
* ruby.exe is rebuilt.

So let's look at the revision.h make rule:


$(srcdir)/revision.h: $(srcdir)/version.h $(srcdir)/ChangeLog $(srcdir)/tool/file2lastrev.rb $(REVISION_FORCE)
	@-$(BASERUBY) $(srcdir)/tool/file2lastrev.rb --revision.h "$(@D)" > "$@.tmp"
	@$(IFCHANGE) "$@" "$@.tmp"

On a new checkout it is highly likely ChangeLog or version.h is updated (in this case Changelog).  But IFCHANGE does not see the change, so revision.h is never updated.  Thus the rule triggers every time, even if all you are doing is running nmake do-install-doc.

Changing the rule like this fixes the issue:

$(srcdir)/revision.h: $(srcdir)/version.h $(srcdir)/ChangeLog $(srcdir)/tool/file2lastrev.rb $(REVISION_FORCE)
	@-$(BASERUBY) $(srcdir)/tool/file2lastrev.rb --revision.h "$(@D)" > "$@"


Thus always recreate revision.h if any of its prerequisites are newer.

Before the change we can use ChkMatch tool to compare the ruby executable with its debug information:

ChkMatch -c c:\Development\ruby-1.9.1\usr\bin\ruby.exe ruby.pdb
Result: Unmatched (reason: Age mismatch)

After the change:

ChkMatch -c c:\Development\ruby-1.9.1\usr\bin\ruby.exe ruby.pdb
Result: Matched

And then debugging works again.


Patch attached.


----------------------------------------
http://redmine.ruby-lang.org