[MacPorts] #39096: ruby portgroup: fix universal builds

MacPorts noreply at macports.org
Tue May 14 03:40:14 PDT 2013


#39096: ruby portgroup: fix universal builds
--------------------------+--------------------------------
 Reporter:  ryandesign@…  |      Owner:  macports-tickets@…
     Type:  defect        |     Status:  new
 Priority:  Normal        |  Milestone:
Component:  ports         |    Version:  2.1.3
 Keywords:                |       Port:
--------------------------+--------------------------------
 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.

-- 
Ticket URL: <https://trac.macports.org/ticket/39096>
MacPorts <http://www.macports.org/>
Ports system for OS X


More information about the macports-tickets mailing list