mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
brotli extension not linked with libstdc++ on pypy3 for Linux #13
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @anthrotype on GitHub (Aug 21, 2015).
There is an issue with the Python 3-compatible pypy (aka pypy3) whereby distutils fails to use the proper C++ compiler/linker while compiling C++ extension modules (such as Brotli).
https://bitbucket.org/pypy/pypy/issues/1763/not-using-proper-c-compilers-linker-while
In the Python2.7-compatible pypy, they have fixed this by patching
distutils/unixccompiler.pyso that it usesc++as default C++ compiler instead ofcc:c6e45dfbdaHowever, they haven't ported this patch to pypy3 yet.
At behdad/fonttools, we use Brotli for WOFF2 and we test it on Travis under different python versions, including pypy3.
Because the C++ runtime library isn't being linked when compiling Brotli for pypy3, the module fails to be loaded with
undefined symbolerror.For details, see: https://github.com/behdad/fonttools/issues/339
As far as I could test, this problem only occurs on pypy3 for Linux (the Travis python setup runs on Ubuntu 12.04). On OS X, where
distutils.unixccompileris also used, I verified that brotli is compiled and imported without problems when using the same pypy3 version (2.4.0) as the one used on Travis -- but I guess it's because on OSX the nameccis just a symbolic link toclang, and the latter does the right thing.As a workaround, we currently do something like this:
While pypy developers fixes the issue, Brotli's setup.py could be modified to link with libstdc++ by default whenever
platform.python_implementation() == "PyPy" and sys.version_info[0] == 3. (I wonder if there would be portability issues if libstdc++ were linked all the time, on any python platform/version/implementation?)A second alternative would be to change the value of
UnixCCompiler.compiler_cxxvariable from the current['cc']to['c++']if running on pypy3 (exactly like in the above mentioned pypy2 patch). This is what they do in spaCy for example (I found this by chance).Now, both approaches seem to work, though I'm not sure which one is preferable.
A third approach, of course, is simply take note and wait.
Anyway, I have mentioned this on pypy's bug tracker, where I found at least two duplicate issues (#1099 and #1763) referencing the same problem.
Please let me know if anyone else has encountered the same problem.
Thanks,
Cosimo
@anthrotype commented on GitHub (Aug 22, 2015):
The issue with C++ and pypy3 has already been fixed here.
It should be available in the next pypy3 release.
I shall close this for now.