[前][次][番号順一覧][スレッド一覧]

ruby-changes:27905

From: nobu <ko1@a...>
Date: Wed, 27 Mar 2013 06:40:00 +0900 (JST)
Subject: [ruby-changes:27905] nobu:r39958 (trunk): mkmf.rb: force refererence in MAIN_DOES_NOTHING

nobu	2013-03-27 06:39:50 +0900 (Wed, 27 Mar 2013)

  New Revision: 39958

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39958

  Log:
    mkmf.rb: force refererence in MAIN_DOES_NOTHING
    
    * lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests
      to be preserved.  [ruby-core:53745] [Bug #8169]

  Modified files:
    trunk/ChangeLog
    trunk/lib/mkmf.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39957)
+++ ChangeLog	(revision 39958)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Mar 27 06:39:41 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests
+	  to be preserved.  [ruby-core:53745] [Bug #8169]
+
 Wed Mar 27 05:15:37 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (RUBY_REPLACE_TYPE): define SIGNEDNESS_OF_type same as
Index: lib/mkmf.rb
===================================================================
--- lib/mkmf.rb	(revision 39957)
+++ lib/mkmf.rb	(revision 39958)
@@ -738,16 +738,16 @@ int main() {printf("%"PRI_CONFTEST_PREFI https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L738
     decltype && try_link(<<"SRC", opt, &b) or
 #{headers}
 /*top*/
-#{MAIN_DOES_NOTHING}
 extern int t(void);
 int t(void) { #{decltype["volatile p"]}; p = (#{decltype[]})#{func}; return 0; }
+#{MAIN_DOES_NOTHING "t"}
 SRC
     call && try_link(<<"SRC", opt, &b)
 #{headers}
 /*top*/
-#{MAIN_DOES_NOTHING}
 extern int t(void);
 int t(void) { #{call}; return 0; }
+#{MAIN_DOES_NOTHING "t"}
 SRC
   end
 
@@ -757,9 +757,9 @@ SRC https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L757
     try_compile(<<"SRC", opt, &b)
 #{headers}
 /*top*/
-#{MAIN_DOES_NOTHING}
 extern int t(void);
 int t(void) { const volatile void *volatile p; p = &(&#{var})[0]; return 0; }
+#{MAIN_DOES_NOTHING "t"}
 SRC
   end
 
@@ -1142,8 +1142,8 @@ SRC https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L1142
       if try_compile(<<"SRC", opt, &b)
 #{cpp_include(headers)}
 /*top*/
-#{MAIN_DOES_NOTHING}
 int s = (char *)&((#{type}*)0)->#{member} - (char *)0;
+#{MAIN_DOES_NOTHING "s"}
 SRC
         $defs.push(format("-DHAVE_%s_%s", type.tr_cpp, member.tr_cpp))
         $defs.push(format("-DHAVE_ST_%s", member.tr_cpp)) # backward compatibility
@@ -1396,9 +1396,9 @@ SRC https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L1396
 #{cpp_include(headers)}
 /*top*/
 volatile #{type} conftestval;
-#{MAIN_DOES_NOTHING}
 extern int t(void);
 int t(void) {return (int)(1-*(conftestval#{member ? ".#{member}" : ""}));}
+#{MAIN_DOES_NOTHING "t"}
 SRC
   end
 
@@ -1409,9 +1409,9 @@ SRC https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L1409
 #{cpp_include(headers)}
 /*top*/
 volatile #{type} conftestval;
-#{MAIN_DOES_NOTHING}
 extern int t(void);
 int t(void) {return (int)(1-(conftestval#{member ? ".#{member}" : ""}));}
+#{MAIN_DOES_NOTHING "t"}
 SRC
   end
 
@@ -2419,6 +2419,12 @@ MESSAGE https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L2419
     @libdir_basename ||= config_string("libdir") {|name| name[/\A\$\(exec_prefix\)\/(.*)/, 1]} || "lib"
   end
 
+  def MAIN_DOES_NOTHING(*refs)
+    src = MAIN_DOES_NOTHING
+    src = src.sub(/\{/) {$&+refs.map {|n|"(void)#{n}; "}.join("")}
+    src
+  end
+
   extend self
   init_mkmf
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]