1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2016-06-03 08:44:27 +00:00
parent ff489440dc
commit 15dba481a2
2 changed files with 13 additions and 3 deletions

View file

@ -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

View file

@ -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(',')}}"