I'm trying to compile PyPy on cygwin, and the compilation stops when python tries to open the file "externmod", which was just compiled with gcc. The problem with gcc on cygwin is that it automatically appends a '.exe' to whatever you're compiling, so even though gcc is called as gcc -shared -Wl,--enable-auto-image-base -pthread -o /tmp/usession-release-1.8/shared_cache/externmod, the output file ends up being externmod.exe regardless. So python tries to open /tmp/usession-release-1.8/shared_cache/externmod and can't find it--thus the compilation stops. Anyone know how to solve this, short of recompiling gcc? I don't want to do that.
3 Answers
I managed to compile it, after having to make quite a few changes.
- PyPy provides no configuration for Cygwin. As suggested above, I copied the Linux configuration and modified it as needed. In particular I removed the -pthread flag, and the --export-dynamic C linker flag should be --export-all-symbols. This is also where the file extensions (.exe, .dll) are specified.
- Cygwin does not implement the tm_gmtoff and tm_zone fields in the tm structure, which are a GNU extension to the POSIX standard. PyPy uses these fields to determine the time zone. I implemented workarounds. Use of these tm fields permates several files that all had to be changed.
- Under Cygwin the system call waitpid() expects a different argument type for slot 2 as what PyPy uses. I implemented a wrapper that remaps the argument.
- Under Cygwin the curses C header files are under ncurses.
You can find a patch for cygwin and instructions at http://www.tux.org/~mayer/cygwin/pypy
Comments
To answer your question, the easiest way to solve your problem is to modify init.py in pypy/translator/platform such that it points to an actual platform, instead of the 'None' that it's getting right now. In linux.py, you'll notice that there's the line `so_ext = 'so' ', which is probably what fixes the extension issue.
Note that, although the little hack of pretending cygwin is linux will work in this exact instance, there're a few road bumps later on that will get you (none that I can remember with sufficient detail to avert, unfortunately).
Edit: the relevant section of my init.py currently looks like
if sys.platform == 'cygwin':
from pypy.translator.platform.linux import Linux, Linux64
import platform
if platform.architecture()[0] == '32bit':
host_factory = Linux
else:
host_factory = Linux64
elif sys.platform.startswith('linux'):