Bug #6987

have_framework can only be called once in extconf.rb

Added by Eric Hodel almost 3 years ago. Updated almost 3 years ago.

[ruby-core:47447]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
ruby -v:- Backport:

Description

=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

Associated revisions

Revision 36918
Added by Nobuyoshi Nakada almost 3 years ago

mkmf.rb: fix splitting options with an argument

  • ext/extmk.rb (extmake), lib/mkmf.rb (have_framework): fix splitting options with an argument, not using NUL as special character. [Bug #6987]

Revision 36918
Added by Nobuyoshi Nakada almost 3 years ago

mkmf.rb: fix splitting options with an argument

  • ext/extmk.rb (extmake), lib/mkmf.rb (have_framework): fix splitting options with an argument, not using NUL as special character. [Bug #6987]

History

#1 Updated by Nobuyoshi Nakada almost 3 years ago

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

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


mkmf.rb: fix splitting options with an argument

  • ext/extmk.rb (extmake), lib/mkmf.rb (have_framework): fix splitting options with an argument, not using NUL as special character. [Bug #6987]

Also available in: Atom PDF