summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-19 12:29:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-19 12:29:46 +0000
commit15d0180b6e782ce8b8fb6ab408db3cf72e183992 (patch)
treefd504f0b7923293b9b340c06c58852b0218af23a /tool
parent5fa4df0e7475dadf4bf287c214bf184d8f6fa2e4 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rw-r--r--tool/transform_mjit_header.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/tool/transform_mjit_header.rb b/tool/transform_mjit_header.rb
index 1000172352..00c25d08e8 100644
--- a/tool/transform_mjit_header.rb
+++ b/tool/transform_mjit_header.rb
@@ -181,10 +181,17 @@ module MJITHeader
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 is broken with Windows headers for now
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