summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-14 14:39:13 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-14 14:39:13 +0000
commit5e17378c440a5e5b1a81ff77fea5064ec438e443 (patch)
tree5c884ef39336bcdca1d77acee10127502a0684e4 /lib
parent7bc0cea739304984fa8434d1051c69595fca85c4 (diff)
merge revision(s) 39958,39989: [Backport #8169]
* lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests to be preserved. [ruby-core:53745] [Bug #8169] * lib/mkmf.rb (MAIN_DOES_NOTHING): ensure symbols for tests to be preserved. [ruby-core:53745] [Bug #8169] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/mkmf.rb27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index c0ede35474..e396fb267f 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -717,16 +717,16 @@ int main() {printf("%"PRI_CONFTEST_PREFIX"#{neg ? 'd' : 'u'}\\n", conftest_const
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
@@ -736,9 +736,9 @@ SRC
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
@@ -1120,8 +1120,8 @@ SRC
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
@@ -1374,9 +1374,9 @@ SRC
#{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
@@ -1387,9 +1387,9 @@ SRC
#{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
@@ -2388,6 +2388,19 @@ MESSAGE
end
end
+ def MAIN_DOES_NOTHING(*refs)
+ src = MAIN_DOES_NOTHING
+ unless refs.empty?
+ src = src.sub(/\{/) do
+ $& +
+ "\n if (argc > 1000000) {\n" +
+ refs.map {|n|" printf(\"%p\", &#{n});\n"}.join("") +
+ " }\n"
+ end
+ end
+ src
+ end
+
extend self
init_mkmf
@@ -2495,7 +2508,7 @@ MESSAGE
##
# A C main function which does no work
- MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || 'int main(void) {return 0;}'
+ MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || "int main(int argc, char **argv)\n{\n return 0;\n}"
UNIVERSAL_INTS = config_string('UNIVERSAL_INTS') {|s| Shellwords.shellwords(s)} ||
%w[int short long long\ long]