From aceb11dff4b3c05d027df664986515a89be1aac6 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 10 Apr 2015 13:29:23 +0000 Subject: [PATCH] mkmf.rb: fix werror option * lib/mkmf.rb (try_compile): pass the given werror flag to try_do to check if stderr is empty. * lib/mkmf.rb (try_cflags, try_ldflags): default werror to true. * win32/Makefile.sub (WERRORFLAG): remove useless option. VC does not make warnings of unknown command option an error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ ext/date/extconf.rb | 2 +- lib/mkmf.rb | 10 +++++----- win32/Makefile.sub | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e786ae5d7..b06cdb0608 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Fri Apr 10 22:29:21 2015 Nobuyoshi Nakada + + * lib/mkmf.rb (try_compile): pass the given werror flag to try_do + to check if stderr is empty. + + * lib/mkmf.rb (try_cflags, try_ldflags): default werror to true. + + * win32/Makefile.sub (WERRORFLAG): remove useless option. VC does + not make warnings of unknown command option an error. + Fri Apr 10 19:34:24 2015 Tanaka Akira * test/ruby/test_file_exhaustive.rb: Test socket. diff --git a/ext/date/extconf.rb b/ext/date/extconf.rb index cb346dfcd9..6f479eaa26 100644 --- a/ext/date/extconf.rb +++ b/ext/date/extconf.rb @@ -1,5 +1,5 @@ require 'mkmf' -if try_cflags("-std=iso9899:1999", :werror => true) +if try_cflags("-std=iso9899:1999") $CFLAGS += " " << "-std=iso9899:1999" end create_makefile('date_core') diff --git a/lib/mkmf.rb b/lib/mkmf.rb index ba3240d0a3..eb95beb2c3 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -568,7 +568,7 @@ MSG # [+src+] a String which contains a C source # [+opt+] a String which contains compiler options def try_compile(src, opt="", *opts, &b) - with_werror(opt, *opts) {|_opt, *_opts| try_do(src, cc_command(_opt), *_opts, &b)} and + with_werror(opt, *opts) {|_opt, *| try_do(src, cc_command(_opt), *opts, &b)} and File.file?("#{CONFTEST}.#{$OBJEXT}") ensure MakeMakefile.rm_f "#{CONFTEST}*" @@ -621,8 +621,8 @@ MSG $CFLAGS = cflags unless ret end - def try_cflags(flags, *opts) - try_compile(MAIN_DOES_NOTHING, flags, *opts) + def try_cflags(flags, opts = {}) + try_compile(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts)) end def with_ldflags(flags) @@ -633,8 +633,8 @@ MSG $LDFLAGS = ldflags unless ret end - def try_ldflags(flags) - try_link(MAIN_DOES_NOTHING, flags) + def try_ldflags(flags, opts = {}) + try_link(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts)) end def try_static_assert(expr, headers = nil, opt = "", &b) diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 02ec002417..b8bd25bd31 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -208,7 +208,7 @@ WARNFLAGS = -W2 -wd4996 -we4028 -we4142 WARNFLAGS = -W2 !endif !endif -WERRORFLAG = -WX -we9002 +WERRORFLAG = -WX !if !defined(CFLAGS) CFLAGS = $(RUNTIMEFLAG) $(DEBUGFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) $(COMPILERFLAG) !endif