Opened 13 years ago

Closed 13 years ago

#31046 closed defect (fixed)

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

Reported by: rex4539 (Dimitris Apostolou) Owned by: skymoo (Adam Mercer)
Priority: Normal Milestone:
Component: ports Version:
Keywords: clang Cc: bharanidharan.aj@…, mf2k (Frank Schima), ryandesign (Ryan Carsten Schmidt), dgarnier (reinrag1a), jmroot (Joshua Root), kyle.tarplee@…
Port: py27-matplotlib

Description (last modified by skymoo (Adam Mercer))

: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 (4)

main.log (231.6 KB) - added by rex4539 (Dimitris Apostolou) 13 years ago.
main.2.log (194.9 KB) - added by rex4539 (Dimitris Apostolou) 13 years ago.
patch-python-1.0.tcl.diff (485 bytes) - added by skymoo (Adam Mercer) 13 years ago.
py-matplotlib-clang.patch (696 bytes) - added by howarth@… 13 years ago.
fix for clang++ compilation issue

Download all attachments as: .zip

Change History (39)

Changed 13 years ago by rex4539 (Dimitris Apostolou)

Attachment: main.log added

comment:1 Changed 13 years ago by mf2k (Frank Schima)

Owner: changed from macports-tickets@… to ram@…
Port: py27-matplotlib added

comment:2 Changed 13 years ago by skymoo (Adam Mercer)

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 13 years ago by skymoo (Adam Mercer)

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 Changed 13 years ago by rex4539 (Dimitris Apostolou)

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 13 years ago by rex4539 (Dimitris Apostolou)

Attachment: main.2.log added

comment:5 Changed 13 years ago by skymoo (Adam Mercer)

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

has duplicate, #31608

comment:6 in reply to:  4 Changed 13 years 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 13 years ago by rex4539 (Dimitris Apostolou)

Thanks, that did the dirty trick :P

comment:8 Changed 13 years ago by bharanidharan.aj@…

Thanks!! This helped..

comment:9 Changed 13 years ago by skymoo (Adam Mercer)

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 13 years 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 13 years ago by skymoo (Adam Mercer)

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

comment:12 Changed 13 years ago by mf2k (Frank Schima)

Cc: macsforever2000@… added

Cc Me!

comment:13 Changed 13 years ago by mf2k (Frank Schima)

I see this problem too.

comment:14 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added
Keywords: clang added
Resolution: fixed
Status: newclosed

comment:15 in reply to:  14 Changed 13 years ago by dgarnier (reinrag1a)

Replying to ryandesign@…:

r86622

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

comment:16 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: garnier@… added

Did you already run:

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

comment:17 Changed 13 years ago by tioguerra@…

Resolution: fixed
Status: closedreopened

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 13 years ago by dgarnier (reinrag1a)

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 13 years ago by skymoo (Adam Mercer)

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 13 years ago by ryandesign (Ryan Carsten Schmidt)

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 13 years ago by skymoo (Adam Mercer)

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

comment:22 Changed 13 years ago by skymoo (Adam Mercer)

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 13 years ago by skymoo (Adam Mercer)

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 13 years ago by skymoo (Adam Mercer)

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

comment:25 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Why make it an option?

comment:26 Changed 13 years ago by skymoo (Adam Mercer)

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 13 years ago by skymoo (Adam Mercer)

Attachment: patch-python-1.0.tcl.diff added

comment:27 Changed 13 years ago by skymoo (Adam Mercer)

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 13 years ago by jmroot (Joshua Root)

Resolution: fixed
Status: reopenedclosed

comment:29 Changed 13 years ago by howarth@…

Resolution: fixed
Status: closedreopened

Changed 13 years ago by howarth@…

Attachment: py-matplotlib-clang.patch added

fix for clang++ compilation issue

comment:30 Changed 13 years ago by skymoo (Adam Mercer)

Resolution: fixed
Status: reopenedclosed

applied in r91266, thanks

comment:31 Changed 13 years ago by kyle.tarplee@…

Resolution: fixed
Status: closedreopened

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 13 years ago by ryandesign (Ryan Carsten Schmidt)

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 13 years ago by jmroot (Joshua Root)

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 13 years 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 13 years ago by skymoo (Adam Mercer)

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.