New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #31046 (closed defect: fixed)

Opened 21 months ago

Last modified 14 months ago

py27-matplotlib fails to build with clang (Xcode 4.2)

Reported by: rex_4539@… Owned by: ram@…
Priority: Normal Milestone:
Component: ports Version:
Keywords: clang Cc: bharanidharan.aj@…, macsforever2000@…, ryandesign@…, garnier@…, jmr@…, kyle.tarplee@…
Port: py27-matplotlib

Description (last modified by ram@…) (diff)

:info:build In file included from src/backend_agg.cpp:9:
:info:build In file included from src/_backend_agg.h:32:
:info:build agg24/include/agg_renderer_outline_aa.h:1368:45: error: binding of reference to type 'agg::line_profile_aa' to a value of type 'const agg::line_profile_aa' drops qualifiers
:info:build         line_profile_aa& profile() { return *m_profile; }
:info:build                                             ^~~~~~~~~~
:info:build 1 error generated.
:info:build error: command '/Developer/usr/bin/clang' failed with exit status 1

Attachments

main.log (231.6 KB) - added by rex_4539@… 21 months ago.
main.2.log (194.9 KB) - added by rex_4539@… 19 months ago.
patch-python-1.0.tcl.diff (485 bytes) - added by ram@… 19 months ago.
py-matplotlib-clang.patch (696 bytes) - added by howarth@… 14 months ago.
fix for clang++ compilation issue

Change History

Changed 21 months ago by rex_4539@…

comment:1 Changed 21 months ago by macsforever2000@…

  • Owner changed from macports-tickets@… to ram@…
  • Port set to py27-matplotlib

comment:2 Changed 21 months ago by ram@…

I don't have access to Xcode-4.2, so I doubt I can look into this until it's been released to the public. You could try asking upstream? Patches are welcome.

Sorry for the delay but I've been travelling and then my machine was in for repair.

comment:3 Changed 19 months ago by ram@…

As Xcode-4.2 has been released I upgraded and py27-matplotlib built without issue. I noticed that the compiler used was still llvm-gcc-4.2 and not clang. Did you do something specific to select clang?

comment:4 follow-up: ↓ 6 Changed 19 months ago by rex_4539@…

Still fails here and seems to use Clang by default.

Even if I try force to compile with gcc with a command like:

sudo port install py27-matplotlib configure.compiler=gcc-4.2 configure.cc=gcc-4.2 configure.cxx=g++-4.2 configure.objc=cpp-4.2

Attaching new log.

Changed 19 months ago by rex_4539@…

comment:5 Changed 19 months ago by ram@…

  • Cc bharanidharan.aj@… added
  • Version 2.0.1 deleted
  • Description modified (diff)

has duplicate, #31608

comment:6 in reply to: ↑ 4 Changed 19 months ago by batesca@…

There is a quick and dirty solution to this:

cd /Developer/usr/bin/
sudo mv clang clang.temp
sudo cp llvm-gcc-4.2 clang
sudo port install py27-matplotlib
sudo mv clang.temp clang

comment:7 Changed 19 months ago by rex_4539@…

Thanks, that did the dirty trick :P

comment:8 Changed 19 months ago by bharanidharan.aj@…

Thanks!! This helped..

comment:9 follow-up: ↓ 10 Changed 19 months ago by ram@…

Just updated to matplotlib-1.1.0, does that help any?

My machine at home still runs Snow Leopard, my work machine runs Lion. I'll try to take a look at this clang issue next week.

comment:10 in reply to: ↑ 9 Changed 19 months ago by cdcapano@…

I just tried installing py27-matplotlib on a new Mac with Lion and got the same error. Xcode version is 4.2. The quick and dirty solution posted by batesca above appears to have worked for me also.

comment:11 Changed 19 months ago by ram@…

Thanks, that's good to know. I'm currently swamped at work but I hope to get to this soon.

comment:12 Changed 19 months ago by macsforever2000@…

  • Cc macsforever2000@… added

Cc Me!

comment:13 Changed 19 months ago by macsforever2000@…

I see this problem too.

comment:14 follow-up: ↓ 15 Changed 19 months ago by ryandesign@…

  • Keywords clang added
  • Cc ryandesign@… added
  • Status changed from new to closed
  • Resolution set to fixed

comment:15 in reply to: ↑ 14 Changed 19 months ago by garnier@…

Replying to ryandesign@…:

r86622

This didn't fix it for me. Still the same error.

comment:16 follow-up: ↓ 18 Changed 19 months ago by ryandesign@…

  • Cc garnier@… added

Did you already run:

sudo port clean py27-matplotlib
sudo port selfupdate
sudo port install py27-matplotlib

comment:17 Changed 19 months ago by tioguerra@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

Just ran into the same problem here. I installed MacPorts fresh. The clean+selfupdate did not fix the problem. The "quick and dirty" solution worked.

comment:18 in reply to: ↑ 16 Changed 19 months ago by garnier@…

Replying to ryandesign@…:

Did you already run:

sudo port clean py27-matplotlib
sudo port selfupdate
sudo port install py27-matplotlib

yes... and on a second machine. It makes sense that your fix doesn't work because the other workaround of setting configure.compiler=llvm-gcc-4.2 also doesn't work. However, the rename of clang to llvm-gcc-4.2 does work.

Anyway, I don't that much about the way the port file is supposed to work, but it looks like that configuration never makes it to the python setup.py build line... What I tried was to change "build.env " line and just set the CC environment variable...

build.env          CC=cc MPLIB_BASE="${prefix}" PKG_CONFIG_PATH="${python.prefix}/lib/pkgconfig/"

This works, but I think it really should be set somehow to the configure.compiler variable. I leave it to a better person to do it correctly. (And I think this implies that all external python modules have this same problem of not using the macports configured compiler.)

comment:19 Changed 19 months ago by ram@…

I believe that the compiler needs to be set using the CC environment variables, like the py-numpy port does. I am planning on updating my home machine to Lion this weekend so hopefully I'll be able to address this issue.

comment:20 Changed 19 months ago by ryandesign@…

The way py-numpy does it looks like an awful mess. Are you sure we can't just modify the python portgroup to set the CC and CXX environment variables to the correct values at pre-build time, like it already does for the CFLAGS, CXXFLAGS, etc. variables?

comment:21 Changed 19 months ago by ram@…

That looks like a much simpler approach, I take a look this weekend.

comment:22 follow-up: ↓ 23 Changed 19 months ago by ram@…

Ryan: How does the following look?

diff --git a/_resources/port1.0/group/python-1.0.tcl b/_resources/port1.0/group/python-1.0.tcl
index 0bb872a..d095f85 100644
--- a/_resources/port1.0/group/python-1.0.tcl
+++ b/_resources/port1.0/group/python-1.0.tcl
@@ -200,6 +200,9 @@ proc python_get_defaults {var} {
 options python.add_archflags
 default python.add_archflags yes
 
+options python.set_compiler
+default python.set_compiler no
+
 pre-build {
     if {${python.add_archflags}} {
         if {[variant_exists universal] && [variant_isset universal]} {
@@ -217,6 +220,10 @@ pre-build {
                              LDFLAGS="${configure.ld_archflags}"
         }
     }
+    if {${python.add_compiler}} {
+        build.env-append CC="${configure.cc}" \
+                         CXX=${configure.cxx}"
+    }
 }
 
 options python.link_binaries python.link_binaries_suffix

Then the configure.compiler call seems to override the compilers correctly.

comment:23 in reply to: ↑ 22 Changed 19 months ago by ram@…

Replying to ram@…:

Then the configure.compiler call seems to override the compilers correctly.

Provided that python.set_compiler is set to yes

comment:24 Changed 19 months ago by ram@…

With the obvious typo fixed, it works. :-(

comment:25 Changed 19 months ago by ryandesign@…

Why make it an option?

comment:26 Changed 19 months ago by ram@…

Good point? I was thinking that there may be situations in which you didn't want to override the compiler. But thinking about it in more detail you'd need to set configure.compiler to do that, so I suppose it doesn't need to be an option.

Changed 19 months ago by ram@…

comment:27 Changed 19 months ago by ram@…

  • Cc jmr@… added

Josh: As you wrote the original python-1.0 portgroup, does the attached patch look sane to you? This allows the compiler to be overridden using configure.compiler?

comment:28 Changed 19 months ago by jmr@…

  • Status changed from reopened to closed
  • Resolution set to fixed

comment:29 Changed 14 months ago by howarth@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

Changed 14 months ago by howarth@…

fix for clang++ compilation issue

comment:30 Changed 14 months ago by ram@…

  • Status changed from reopened to closed
  • Resolution set to fixed

applied in r91266, thanks

comment:31 Changed 14 months ago by kyle.tarplee@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

I tried using your new patch and the same error happens. I have Lion and Xcode 4.3.2 It's still trying to use /Developer to find the clang compiler which does not exist. Here is the relevant portion of the error log.

:info:build /usr/bin/clang -DNDEBUG -g -O3 -Wall -arch x86_64 -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/opt/local/include -I/opt/local/include/python/opt/local -I. -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c ttconv/ttutil.cpp -o build/temp.macosx-10.7-x86_64-2.7/ttconv/ttutil.o
:info:build /usr/bin/clang++ -bundle -undefined dynamic_lookup -isysroot / -L/opt/local/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-2.7/src/_ttconv.o build/temp.macosx-10.7-x86_64-2.7/ttconv/pprdrv_tt.o build/temp.macosx-10.7-x86_64-2.7/ttconv/pprdrv_tt2.o build/temp.macosx-10.7-x86_64-2.7/ttconv/ttutil.o -L/opt/local/lib -o build/lib.macosx-10.7-x86_64-2.7/matplotlib/ttconv.so
:info:build building 'matplotlib._cntr' extension
:info:build /usr/bin/clang -DNDEBUG -g -O3 -Wall -arch x86_64 -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/opt/local/include -I/opt/local/include/python/opt/local -I. -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/cntr.c -o build/temp.macosx-10.7-x86_64-2.7/src/cntr.o
:info:build /Developer/usr/bin/clang -bundle -undefined dynamic_lookup -isysroot / -L/opt/local/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-2.7/src/cntr.o -L/opt/local/lib -o build/lib.macosx-10.7-x86_64-2.7/matplotlib/_cntr.so
:info:build unable to execute /Developer/usr/bin/clang: No such file or directory
:info:build error: command '/Developer/usr/bin/clang' failed with exit status 1
:info:build shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_python_py-matplotlib/py27-matplotlib/work/matplotlib-1.1.0" && /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 setup.py --no-user-cfg build " returned error 1
:error:build Target org.macports.build returned: shell command failed (see log for details)
:debug:build Backtrace: shell command failed (see log for details)
    while executing
"command_exec build"
    (procedure "portbuild::build_main" line 8)
    invoked from within
"$procedure $targetname"
:info:build Warning: the following items did not execute (for py27-matplotlib): org.macports.install org.macports.build org.macports.destroot
:notice:build Log for py27-matplotlib is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_python_py-matplotlib/py27-matplotlib/main.log

comment:32 Changed 14 months ago by ryandesign@…

  • Cc kyle.tarplee@… added

kyle.tarplee, remember to use WikiFormating and to preview before submitting, and to Cc yourself if you want to be notified of replies.

Have you already rebuilt python27 after upgrading to Xcode 4.3+?

comment:33 Changed 14 months ago by jmr@…

That shouldn't be necessary, as the python portgroup sets CC. The original fix from r86622 couldn't possibly have worked if it didn't.

The actual relevant portion of the log would be the build environment.

comment:34 Changed 14 months ago by kyle.tarplee@…

sudo port -n upgrade --force python27

seems to have fixed my problem. I can now upgrade this port correctly.

comment:35 Changed 14 months ago by ram@…

  • Status changed from reopened to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.