diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-03 08:44:27 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-03 08:44:27 +0000 |
commit | 15dba481a28164aea17dc59f4026e0c1bb733772 (patch) | |
tree | f9afc1d072f2be55cc02f112f74baa7e51896cca | |
parent | ff489440dcfe0d892e219be2a8104a7c45244c07 (diff) | |
download | ruby-15dba481a28164aea17dc59f4026e0c1bb733772.tar.gz |
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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/mkmf.rb | 10 |
2 files changed, 13 insertions, 3 deletions
@@ -1,3 +1,9 @@ +Fri Jun 3 17:44:25 2016 Reiner Herrmann <reiner@reiner-h.de> + + * 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 <nobu@ruby-lang.org> * 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(',')}}" |