Issue #8169 has been updated by edelsohn (David Edelsohn).


The implementation of this fix does not resolve the problem as the author expects.  It generates the following example of conftest.c:

#include "ruby.h"

/*top*/
extern int t(void);
int t(void) { TLSv1_1_method(); return 0; }
int main(void) {(void)t; return 0;}

Yes, main() now references "t", but the result of "t" is cast to void, which instructs the compiler that it can be thrown away.  Therefore, the object file testcase does not reference the function TLSv1_1_method and does not test if it is present in the library.
----------------------------------------
Backport #8169: mkmf generates inaccurate conftest.c test files
https://bugs.ruby-lang.org/issues/8169#change-38007

Author: edelsohn (David Edelsohn)
Status: Assigned
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category: 
Target version: 


mkmf seems to reproduce some of the functionality of GNU Autoconf, but it can generate test files that do not correctly probe for functionality and do not produce correct results.  For example, ext/socket produces one conftest.c that looks like:

1: #include "ruby.h"
2: 
3: /*top*/
4: int main() {return 0;}1: #include "ruby.h"
2: 
3: /*top*/
4: int main() {return 0;}
5: extern int t(void);
6: int t(void) { getifaddrs(); return 0; }

When compiled to create an executable "conftest", there is no reference to function t().  Nothing forces t() to be a visible symbol in the final executable and nothing ensures that the linker preserves the function.

On systems where the linker performs garbage collection, such as AIX by default and GNU ld with --gc-sections, the reference to symbol "t" may be dropped, allowing the undefined reference to "getifaddrs" to be dropped, negating the entire purpose of the link test.

The symbol being tested must be called by / referenced by function main().


-- 
http://bugs.ruby-lang.org/