[MacPorts] #42777: gcc47/gcc48 - problem with linking some C++ python extensions (std::ostringstream)
#42777: gcc47/gcc48 - problem with linking some C++ python extensions (std::ostringstream) ----------------------+-------------------------------- Reporter: wojdyr@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.2.1 Keywords: | Port: gcc48 ----------------------+-------------------------------- I've been tracking a problem with Boost.Python extensions built using GCC from macports. Here is a minimal program that shows the problem: {{{ #include <iostream> #include <sstream> extern "C" void run() { std::ostringstream o; o << 123; std::cout << "[" << o.str() << "]\n"; } }}} It runs fine when dlopen'ed from C, but not from Python (regardless if it's system or macports or manually built Python). {{{ $ g++-mp-4.8 -c -fPIC otest.cc $ g++-mp-4.8 -bundle -undefined dynamic_lookup otest.o -o otest.so $ python -c "import ctypes; ctypes.CDLL('./otest.so').run()" [] }}} (I'm using ffi here to keep it simple, it's the same with python extension). If I replace g++-mp-4.8 with g++ when linking it works as expected: {{{ $ g++ -bundle -undefined dynamic_lookup otest.o -o otest.so $ python -c "import ctypes; ctypes.CDLL('./otest.so').run()" [123] }}} Alternatively, if I take the linking command from g++-mp-4.8: {{{ /opt/local/bin/ld -dynamic -arch x86_64 -bundle -macosx_version_min 10.6.8 -undefined dynamic_lookup -weak_reference_mismatches non-weak -undefined dynamic_lookup -o otest.so -L/opt/local/lib/gcc48/gcc/x86_64-apple- darwin10/4.8.2 -L/opt/local/lib/gcc48/gcc/x86_64-apple- darwin10/4.8.2/../../.. otest.o -lstdc++ -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem }}} and remove `-lstdc++`, it also works. I'm using OSX 10.6. This problem happens with gcc47 and gcc48 from macports, but not with GCC from xcode and clang-3.3 from macports. Is it fixable? -- Ticket URL: <https://trac.macports.org/ticket/42777> MacPorts <http://www.macports.org/> Ports system for OS X
#42777: gcc47/gcc48 - problem with linking some C++ python extensions (std::ostringstream) -----------------------+-------------------------------- Reporter: wojdyr@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.2.1 Resolution: | Keywords: Port: gcc48 | -----------------------+-------------------------------- Comment (by wojdyr@…): I've realized that ostringstream is not necessary, any stream fed with integer or float will do. For example this function: {{{ #include <iostream> extern "C" void run() { std::cout << 123 << "\n"; } }}} does not print anything when built with macports gcc and called from python. -- Ticket URL: <https://trac.macports.org/ticket/42777#comment:1> MacPorts <http://www.macports.org/> Ports system for OS X
#42777: gcc47/gcc48 - problem with linking some C++ python extensions (std::ostringstream) -----------------------+------------------- Reporter: wojdyr@… | Owner: mww@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.2.1 Resolution: | Keywords: Port: gcc48 | -----------------------+------------------- Changes (by macsforever2000@…): * cc: jeremyhu@… (added) * owner: macports-tickets@… => mww@… -- Ticket URL: <https://trac.macports.org/ticket/42777#comment:2> MacPorts <http://www.macports.org/> Ports system for OS X
#42777: gcc47/gcc48 - problem with linking some C++ python extensions (std::ostringstream) -----------------------+------------------- Reporter: wojdyr@… | Owner: mww@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.2.1 Resolution: | Keywords: Port: gcc48 | -----------------------+------------------- Comment (by macsforever2000@…): In the future, please Cc the port maintainers ({{{port info --maintainers gcc48}}}). -- Ticket URL: <https://trac.macports.org/ticket/42777#comment:3> MacPorts <http://www.macports.org/> Ports system for OS X
participants (1)
-
MacPorts