aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mkmf.rb
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 /lib/mkmf.rb
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
Diffstat (limited to 'lib/mkmf.rb')
-rw-r--r--lib/mkmf.rb10
1 files changed, 7 insertions, 3 deletions
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(',')}}"