Skip to content

Commit 8aca3e7

Browse files
committed
merge revision(s) r49482,r49487: [Backport ruby#10821]
* lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): get rid of interference by modifying global variables in have_devel? method. [ruby-core:67962] [Bug ruby#10821] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent c4b21f7 commit 8aca3e7

File tree

5 files changed

+43
-11
lines changed

5 files changed

+43
-11
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Wed Mar 18 01:45:12 2015 Nobuyoshi Nakada <[email protected]>
2+
3+
* lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): get rid of
4+
interference by modifying global variables in have_devel? method.
5+
[ruby-core:67962] [Bug #10821]
6+
17
Wed Mar 18 00:58:43 2015 Shugo Maeda <[email protected]>
28

39
* class.c (method_entry_i, class_instance_method_list,

lib/mkmf.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,7 @@ def with_cppflags(flags)
610610
end
611611

612612
def try_cppflags(flags)
613-
with_cppflags(flags) do
614-
try_header("int main() {return 0;}")
615-
end
613+
try_header(MAIN_DOES_NOTHING, flags)
616614
end
617615

618616
def with_cflags(flags)
@@ -624,9 +622,7 @@ def with_cflags(flags)
624622
end
625623

626624
def try_cflags(flags)
627-
with_cflags(flags) do
628-
try_compile("int main() {return 0;}")
629-
end
625+
try_compile(MAIN_DOES_NOTHING, flags)
630626
end
631627

632628
def with_ldflags(flags)
@@ -638,9 +634,7 @@ def with_ldflags(flags)
638634
end
639635

640636
def try_ldflags(flags)
641-
with_ldflags(flags) do
642-
try_link("int main() {return 0;}")
643-
end
637+
try_link(MAIN_DOES_NOTHING, flags)
644638
end
645639

646640
def try_static_assert(expr, headers = nil, opt = "", &b)

test/mkmf/base.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'test/unit'
44
require 'mkmf'
55
require 'tmpdir'
6+
require_relative '../ruby/envutil'
67

78
$extout = '$(topdir)/'+RbConfig::CONFIG["EXTOUT"]
89
RbConfig::CONFIG['topdir'] = CONFIG['topdir'] = File.expand_path(CONFIG['topdir'])
@@ -49,7 +50,9 @@ def write(s)
4950
@buffer << s if @out
5051
end
5152
end
53+
end
5254

55+
module TestMkmf::Base
5356
attr_reader :stdout
5457

5558
def mkmflog(msg)
@@ -84,7 +87,7 @@ def setup
8487
@tmpdir = Dir.mktmpdir
8588
@curdir = Dir.pwd
8689
@mkmfobj = Object.new
87-
@stdout = Capture.new
90+
@stdout = TestMkmf::Capture.new
8891
Dir.chdir(@tmpdir)
8992
@quiet, Logging.quiet = Logging.quiet, true
9093
init_mkmf
@@ -127,3 +130,11 @@ def config_value(name)
127130
nil
128131
end
129132
end
133+
134+
class TestMkmf
135+
include TestMkmf::Base
136+
137+
def assert_separately(args, src, *rest)
138+
super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\n#{src}", *rest)
139+
end
140+
end

test/mkmf/test_flags.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,26 @@ def test_valid_warnflags
3131
$warnflags = warnflags
3232
$extmk = val
3333
end
34+
35+
def test_try_ldflag_invalid_opt
36+
assert_separately([], <<-'end;') #do
37+
assert(!try_ldflags("nosuch.c"), TestMkmf::MKMFLOG)
38+
assert(have_devel?, TestMkmf::MKMFLOG)
39+
end;
40+
end
41+
42+
def test_try_cflag_invalid_opt
43+
assert_separately([], <<-'end;') #do
44+
assert(!try_cflags("nosuch.c"), TestMkmf::MKMFLOG)
45+
assert(have_devel?, TestMkmf::MKMFLOG)
46+
end;
47+
end
48+
49+
def test_try_cppflag_invalid_opt
50+
assert_separately([], <<-'end;') #do
51+
assert(!try_cppflags("nosuch.c"), TestMkmf::MKMFLOG)
52+
assert(have_devel?, TestMkmf::MKMFLOG)
53+
end;
54+
end
3455
end
3556
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.5"
22
#define RUBY_RELEASE_DATE "2015-03-18"
3-
#define RUBY_PATCHLEVEL 314
3+
#define RUBY_PATCHLEVEL 315
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 3

0 commit comments

Comments
 (0)