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

ruby-changes:52955

From: nobu <ko1@a...>
Date: Fri, 19 Oct 2018 21:29:51 +0900 (JST)
Subject: [ruby-changes:52955] nobu:r65169 (trunk): transform_mjit_header.rb: add system_header pragma

nobu	2018-10-19 21:29:46 +0900 (Fri, 19 Oct 2018)

  New Revision: 65169

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65169

  Log:
    transform_mjit_header.rb: add system_header pragma
    
    * tool/transform_mjit_header.rb: insert GCC system_header pragma
      to get rid of errors caused by the contents included from system
      headers.

  Modified files:
    trunk/tool/transform_mjit_header.rb
Index: tool/transform_mjit_header.rb
===================================================================
--- tool/transform_mjit_header.rb	(revision 65168)
+++ tool/transform_mjit_header.rb	(revision 65169)
@@ -181,10 +181,17 @@ module MJITHeader https://github.com/ruby/ruby/blob/trunk/tool/transform_mjit_header.rb#L181
   end
 
   def self.with_code(code)
-    Tempfile.open(['', '.c'], mode: File::BINARY) do |f|
+    # for `system_header` pragma which can't be in the main file.
+    Tempfile.open(['', '.h'], mode: File::BINARY) do |f|
       f.puts code
       f.close
-      return yield(f.path)
+      Tempfile.open(['', '.c'], mode: File::BINARY) do |c|
+        c.puts <<SRC
+#include "#{f.path}"
+SRC
+        c.close
+        return yield(c.path)
+      end
     end
   end
   private_class_method :with_code
@@ -220,7 +227,11 @@ if MJITHeader.windows? # transformation https://github.com/ruby/ruby/blob/trunk/tool/transform_mjit_header.rb#L227
 end
 
 macro, code = MJITHeader.separate_macro_and_code(code) # note: this does not work on MinGW
-code_to_check = "#{code}#{macro}" # macro should not affect code again
+code_to_check = "#{<<header}#{code}#{macro}" # macro should not affect code again
+#ifdef __GNUC__
+# pragma GCC system_header
+#endif
+header
 
 if MJITHeader.conflicting_types?(code_to_check, cc, cflags)
   cflags = "#{cflags} -std=c99" # For AIX gcc

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

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