Opened 11 years ago

Closed 11 years ago

#39096 closed defect (fixed)

ruby portgroup: fix universal builds

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: kimuraw (kimura wataru)
Priority: Normal Milestone:
Component: ports Version: 2.1.3
Keywords: Cc: kimuraw (kimura wataru), cooljeanius (Eric Gallager)
Port:

Description

Building rb-rmagick @2.13.2_1 non-universal works fine, but with the universal variant it fails:

checking for stdint.h... no
checking for sys/types.h... no
checking for wand/MagickWand.h... no

Can't install RMagick 2.13.2. Can't find MagickWand.h.

These headers all exist; the problem is how Ruby checks for them. In ext/RMagick/mkmf.log we see the real problem:

have_header: checking for stdint.h... -------------------- no

"/usr/bin/clang -E -I. -I/opt/local/lib/ruby/1.8/x86_64-darwin12 -I/opt/local/var/macports/build/_Users_rschmidt_macports_dports_ruby_rb-rmagick/rb-rmagick/work/RMagick-2.13.2/ext/RMagick -I/opt/local/include -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/opt/local/include/ImageMagick-6  -pipe -Os -arch x86_64 -arch i386 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/opt/local/include/ImageMagick-6   conftest.c -o conftest.i"
clang: error: cannot use 'cpp-output' output with multiple -arch options
checked program was:
/* begin */
1: #include <stdint.h>
/* end */

The compiler is being called with -E, meaning pre-processor mode, but for some reason the -arch flags, which are not appropriate for use with a pre-processor, are still being supplied, causing the error.

RMagick isn't doing anything special; it's using the standard ruby have_header() check. According to the Ruby source code, have_header() calls try_cpp(), which in turn calls cpp_command(). And cpp_command() runs Config::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}", conf)—deliberately including $CFLAGS, which in MacPorts by default contains -arch flags.

The developers of Ruby seem to be aware that -arch flags should not be passed to the C pre-processor; I found an old discussion about that. But they've taken the unorthodox approach of defining a new environment variable ARCH_FLAG which they expect packagers to set, instead of including -arch flags in CFLAGS, CXXFLAGS, LDFLAGS etc.

I don't know why it's called ARCH_FLAG and not ARCH_FLAGS or what happens if multiple -arch flags are included.

In MacPorts we seem to be aware of the ARCH_FLAG variable; the ruby port already uses it to build itself, and it ensures only one -arch flag is in it by using the muniversal portgroup. But we still need a solution for other Ruby software that uses the ruby-1.0 portgroup.

Change History (5)

comment:1 Changed 11 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:2 Changed 11 years ago by kimuraw (kimura wataru)

Owner: changed from macports-tickets@… to kimuraw@…
Status: newassigned

comment:3 Changed 11 years ago by cooljeanius (Eric Gallager)

r111453 worked towards solving this

Edit: as did r111463

Last edited 11 years ago by cooljeanius (Eric Gallager) (previous) (diff)

comment:4 Changed 11 years ago by kimuraw (kimura wataru)

I added ruby-1.8 universal support to portgroup ruby at r111453 and r111463.

requirement:

  • use "ruby.setup extconf.rb" or "ruby.setup setup.rb"
  • add the following line to the Porfile.
    PortGroup muniversal 1.0

comment:5 Changed 11 years ago by kimuraw (kimura wataru)

Resolution: fixed
Status: assignedclosed

I confirmed building rb-rmagick +universal after change of r111544.

but destroot fails with the following error.

Error: org.macports.destroot for port rb-rmagick returned: /opt/local/share/
doc/rb-rmagick/userguide/ex/add_noise_GaussianNoise.jpg differs in /.../rb-r
magick/work/destroot-i386 and /.../rb-rmagick/work/destroot-x86_64 and canno
t be merged

I think this error will be solve in rb-rmagick Portfile. I close this ticket as fixed.

Note: See TracTickets for help on using tickets.