From 15dba481a28164aea17dc59f4026e0c1bb733772 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 3 Jun 2016 08:44:27 +0000 Subject: [PATCH] mkmf.rb: sort lists of source and object files * lib/mkmf.rb (create_makefile): sort lists of source and object files in generated Makefile, unless given by extconf.rb. [Fix GH-1367] Without sorting the list of object files explicitely, its order is indeterministic, because readdir() is also not deterministic. When the list of object files varies between builds, they are linked in a different order, which results in an unreproducible build. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/mkmf.rb | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f45ae2419..6e7d299f0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jun 3 17:44:25 2016 Reiner Herrmann + + * lib/mkmf.rb (create_makefile): sort lists of source and object + files in generated Makefile, unless given by extconf.rb. + [Fix GH-1367] + Thu Jun 2 21:18:10 2016 Nobuyoshi Nakada * win32/win32.c (get_special_folder): use SHGetPathFromIDListEx if diff --git a/lib/mkmf.rb b/lib/mkmf.rb index eee42d0e51..53aea8cecd 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -2205,11 +2205,15 @@ RULES RbConfig.expand(srcdir = srcprefix.dup) ext = ".#{$OBJEXT}" - orig_srcs = Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")] + orig_srcs = Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")].sort if not $objs srcs = $srcs || orig_srcs - objs = srcs.inject(Hash.new {[]}) {|h, f| h[File.basename(f, ".*") << ext] <<= f; h} - $objs = objs.keys + $objs = [] + objs = srcs.inject(Hash.new {[]}) {|h, f| + h.key?(o = File.basename(f, ".*") << ext) or $objs << o + h[o] <<= f + h + } unless objs.delete_if {|b, f| f.size == 1}.empty? dups = objs.sort.map {|b, f| "#{b[/.*\./]}{#{f.collect {|n| n[/([^.]+)\z/]}.join(',')}}"