Project

General

Profile

Backport #8169

mkmf generates inaccurate conftest.c test files

Added by edelsohn (David Edelsohn) about 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:53745]

Description

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().


Related issues

Related to Backport193 - Backport #8216: Request of backport of fix for Bug #8169Closed04/04/2013Actions

Associated revisions

Revision 89b49d45
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 39958
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 39958
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 39958
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 39958
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 39958
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 39958
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 56f2447e
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • 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/trunk@39989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 39989
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): ensure symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 39989
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): ensure symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 39989
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): ensure symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 39989
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): ensure symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 39989
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): ensure symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 39989
Added by nobu (Nobuyoshi Nakada) about 6 years ago

mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): ensure symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]

Revision 5e17378c
Added by nagachika (Tomoyuki Chikanaga) about 6 years ago

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

Revision 40289
Added by nagachika (Tomoyuki Chikanaga) about 6 years ago

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]

Revision 3ba9e467
Added by usa (Usaku NAKAMURA) about 6 years ago

merge revision(s) 39958,39989: [Backport #8216]

    * 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_1_9_3@40715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

Updated by drbrain (Eric Hodel) about 6 years ago

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

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39958.
David, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]
#3

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk to Backport200
  • Category deleted (lib)
  • Status changed from Closed to Assigned
  • Assignee changed from nobu (Nobuyoshi Nakada) to nagachika (Tomoyuki Chikanaga)

Updated by edelsohn (David Edelsohn) about 6 years ago

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.

#5

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Tracker changed from Backport to Bug
  • Project changed from Backport200 to Ruby trunk
  • Status changed from Assigned to Open
#6

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Status changed from Open to Closed

This issue was solved with changeset r39989.
David, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


mkmf.rb: force refererence in MAIN_DOES_NOTHING

  • lib/mkmf.rb (MAIN_DOES_NOTHING): ensure symbols for tests to be preserved. [ruby-core:53745] [Bug #8169]
#7

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk to Backport200
  • Status changed from Closed to Assigned
#8

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r40289.
David, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


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]

Also available in: Atom PDF