Issue #6987 has been reported by drbrain (Eric Hodel).

----------------------------------------
Bug #6987: have_framework can only be called once in extconf.rb
https://bugs.ruby-lang.org/issues/6987

Author: drbrain (Eric Hodel)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: lib
Target version: 2.0.0
ruby -v: -


=begin
Since r36437 ((|$LDFLAGS|)) will contain a NULL byte if (({have_framework})) is returned successfully.

If extconf.rb attempts to call (({have_framework})) twice to discover multiple frameworks it will now fail:

  $ cat test.rb 
  require 'mkmf'
  
  have_framework 'OpenGL'
  have_framework 'GLUT'
  
  $ make runruby
  ./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems ./test.rb
  checking for OpenGL... yes
  checking for GLUT... /Users/drbrain/Work/svn/ruby/trunk/lib/mkmf.rb:339:in `system': string contains null byte (ArgumentError)
  [???]

Since (({have_framework})) makes use of ((|$LDFLAGS|)) the NULL byte causes this exception.

Due to the TODO, I'm unsure what kind of patch should be applied.  The easiest would be:

  Index: lib/mkmf.rb
  ===================================================================
  --- lib/mkmf.rb	(revision 36915)
  +++ lib/mkmf.rb	(working copy)
  @@ -413,6 +413,7 @@ MSG
   
     def link_command(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
       librubyarg = $extmk ? $LIBRUBYARG_STATIC : "$(LIBRUBYARG)"
  +    discovered_ldflags = $LDFLAGS.gsub("\0", " ")
       conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote,
                                     'src' => "#{CONFTEST_C}",
                                     'arch_hdrdir' => $arch_hdrdir.quote,
  @@ -421,7 +422,7 @@ MSG
                                     'CPPFLAGS' => "#$CPPFLAGS",
                                     'CFLAGS' => "#$CFLAGS",
                                     'ARCH_FLAG' => "#$ARCH_FLAG",
  -                                  'LDFLAGS' => "#$LDFLAGS #{ldflags}",
  +                                  'LDFLAGS' => "#{discovered_ldflags} #{ldflags}",
                                     'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
                                     'LIBS' => "#{librubyarg} #{opt} #$LIBS")
       conf['LIBPATH'] = libpathflag(libpath.map {|s| RbConfig::expand(s.dup, conf)})

=end


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