Macports compilation problems with CLANG (netpbm)


I’ve been struggling with this for a few days, so hopefully this post saves some people from headaches.

Some packages in macports fail to compile using CLANG.  The reasons are varied, but inline assembler is a common reason.  The trick to getting them to work is using a different compiler.  LLVM-GCC seems to be a good choice.

The macports guide for choosing compilers isn’t as clear as I would like.  After some googling, I learned that you can edit the port file using macports.

sudo port edit netpbm

This command opens the port file for that package in vi (or maybe your default editor, if different) and lets you make changes.  The compiler is set by the TCL variable ${configure.compiler} which is set thusly:

configure.compiler llvm-gcc-4.2

Once this changes is made, clean and re-attempt the port:

sudo port clean netpbm
sudo port install netpbm

And it should work.  It did for me.  At least, you can use these series of steps to try different compilers out to see which one works.

Update:

To compile the gnuradio-gruel library, it may be necessary to downgrade to boost version 1.49 if you have version 1.50 installed.  For some reason, the x86-64 version of the libraries aren’t build with the new version of boost.  Here is the trac entry.

Update 2:

While compiling the gnuradio-core package, a failure occurs.  The log entry is, unfortunately, not helpful:

:info:build make[6]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/filter'
:info:build make[5]: *** [all] Error 2

However, if you navigate to that folder and run make (as sudo, because the files are owned by macports) you get a more helpful result:

libtool: compile: /usr/bin/clang -DHAVE_CONFIG_H -I. -I../../../.. -I/opt/local/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/runtime -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/general -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/general -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/gengen -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/gengen -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/filter -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/filter -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/missing -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/reed-solomon -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/viterbi -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/io -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/g72x -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/swig -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/hier -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_science_gnuradio-core/gnuradio-core/work/gnuradio-3.3.0/gnuradio-core/src/lib/swig -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/opt/local/include -pipe -O2 -arch x86_64 -MT float_dotprod_sse.lo -MD -MP -MF .deps/float_dotprod_sse.Tpo -c float_dotprod_sse.S -fno-common -DPIC -o .libs/float_dotprod_sse.o
float_dotprod_sse.S:57:2: error: unknown directive
 .version "01.01"
 ^
make[1]: *** [float_dotprod_sse.lo] Error 1
make: *** [all] Error 2

It’s about here that you realize that you’re dealing with assembler.  Ick.  Apparently, the .version directive isn’t supported.  I tried commenting them out, but when gnuradio is finally built, I get SEGFAULTs from the filter methods.  I don’t think it’s a coincidence that we’re in the filter directory and this is the dotproduct source file.

Here, again, I tried the compiler ‘trick’.  No dice.  This time, however, the error changed:

float_dotprod_sse.S:63:suffix or operands invalid for `push'
float_dotprod_sse.S:163:suffix or operands invalid for `pop'

A quick google later, and it turns out that when you compile assembly code designed for a 32 bit machine on 64 bit, the assembler doesn’t know what to do with some of the instructions.  The solution is to add -m32 to the compile command line.

Unfortunately, all this code is compiled with -arch x86_64 (the opposite of the -m32 flag!).  If I removed -arch x86_64 and added -m32 it worked.  Now what to do?  Unfortunately, I’m stuck for now… ideas?

,

  1. #1 by david on August 14, 2012 - 5:47 pm

    Which file gives you “-arch x86_64”?
    I am trying to replace it with -m32 but i cannot find the string anywhere.
    Thanks,
    David

  2. #2 by hpux735 on August 15, 2012 - 6:03 am

    I don’t recall doing it that way. I think that macports specifies the architecture during the configure step. You could try researching how to specify the architecture within a port file.

(will not be published)

Please complete this capcha. I get almost 1000 spam comments a day! * Time limit is exhausted. Please reload CAPTCHA.