aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-03 08:44:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-03 08:44:27 +0000
commitddaef45c08c485596bea18e70dea880495a06584 (patch)
treef9afc1d072f2be55cc02f112f74baa7e51896cca
parent5d6de823e0170a311de60fef7a6db8f16aa4548c (diff)
downloadruby-ddaef45c08c485596bea18e70dea880495a06584.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--ChangeLog6
-rw-r--r--lib/mkmf.rb10
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 <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(',')}}"