Issue #8169 has been updated by drbrain (Eric Hodel).

Category set to lib
Status changed from Open to Assigned
Assignee set to nobu (Nobuyoshi Nakada)


----------------------------------------
Bug #8169: mkmf generates inaccurate conftest.c test files
https://bugs.ruby-lang.org/issues/8169#change-37948

Author: edelsohn (David Edelsohn)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: lib
Target version: 
ruby -v: ruby 1.9.3p392 (2013-02-22 revision 39386) [rs6000-aix]


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/