In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to compile pypy and hippyvm on tinycolinux". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to compile pypy and hippyvm on tinycolinux.
In "releasing wordpress on. Net" we talked about the php implementation on clr, that is, phalanger, and in "pypy: a new DSL framework," we said that pypy is the real vmlangsys allinone, because it follows JIT, making extensions from the native c language unnecessary. Efficiency and ecological package can be achieved on PYPY, which is the most orthodox VM programming language system, much more orthodox than CLR,JVM: just as C is used as a high-level language to generate machine code assembly in the era of os programming after assembly, this is the relationship between py and c in the mixed language of the new era of VM and scripting. Pypy, which brings this automation process into the language system, is such a big language thinking scheme.
We also mentioned there that compared with clr,jvm, it also has a multilingual front end and a unified back end. In fact, this unified back end is a unified tool (there is no unified back end like CLR). We can implement multiple languages on the rpy tool chain by using rpy as a tool, set, and other languages at the current end. And bring more and better new effects: for example, at the end of "pypy: a new DSL framework," we mentioned that it can facilitate the mixing of py and js, using PY to generate JS in the browser on the back end.
How do you actually understand the relationship between py and rpy? Rpy is a tool and a language (static py subset). It works with py. Py+rpy is used as a meta-language system to generate other language systems. Py is the metaprogramming lang of rpy in this relationship (in fact, rpy is called by py, equivalent to lua+terra in terralang, but they are non-C and compatible PY syntax versions. Because they both use basically the same syntax So to simplify the process of inventing a new language, you can use PY+RPY to generate multiple front ends (although multiple languages are actually equal, they tend to use PY when they are used to generate new languages, because it is the main language on RPY and the main C # on class CLR). Using them to generate PYPY is tantamount to saying that PY generates itself (suppose we use cpy+rpython to generate pypy, which pypy is compatible with cpy). The whole process rpython is just a tool, which does not prevent us from getting a native pypy. That is, the generated pypy is the final jitted to c, in fact, the performance of the c based python implementation is the same as that of cpy, which is not bad at all and faster than Cpy. Generally speaking, pypy is the pypy implementation + rpy tool chain. Both the source code and the generated result are like this. We'll see next.
There is also a php implementation on pypy. As an example, let's introduce the compilation of pypy and, by the way, a multi-language implementation of hippyvm on PHP. Hippyvm is also a part of PyHyp, PyHyp is a composition of PyPy and HippyVM., a single file can contain multiple fragments of PHP and Python code, of course, this article focuses on compilation, and will not involve too much mixed content.
My environment is tinycolinux+cpy2.7.14+gcc481+php561.
Preparatory work
Because a large amount of memory is used in the compilation process, it is officially said that it will always take more than 1.5 hours for about 2.5G memory. I am using a 1G CVM, so I can only use time for space. I can only switch on 3G file memory first. However, when about 1.5G swap files are used in practice, the compilation process will be very slow, which looks like it is stuck, but it is actually stuck. The CVM with 4G memory can still enable 3G memory exchange before it is finally compiled. The temporary file generated under / tmp is not large. After all, preprocessing can take as long as it takes, but it will get stuck due to lack of memory, so this is unacceptable.
Turn on swapping memory on tinycolinux as follows:
Sudo dd if=/dev/zero of=/swapfile bs=1024k count=3072 creates a 3G exchange file sudo mkswap / swapfile
Temporarily open: sudo swapon / swapfile
Or in / etc/fstab: / swapfile none swap defaults 0 0
In addition to bootstrap py, php-cli is used in the compilation process. We use these parameters to compile. Remember to download the missing 4.x tcz pkgs and restart to take effect:
Cd Python-2.7.14 & sudo. / configure & & sudo make & & sudo make install
(the above needs to be restarted with expat2,bzip2,libffi,ssl,curses in advance)
Cd php-5.6.31 & & sudo. / configure-- enable-fpm-- enable-zip-- enable-mbstring-- with-mysql=mysqlnd-- with-mysqli=mysqlnd-- with-pdo-mysql=mysqlnd-- with-zlib-- with-gd-- with-curl-- with-jpeg-dir=/usr/local CFLAGS=-D_FILE_OFFSET_BITS=64 CXXFLAGS=-D_FILE_OFFSET_BITS=64-- enable-opcache-- with-openssl- with-openssl-dir=/usr/local/include/openssl & & sudo make & & sudo make install
(jpeg6 has no corresponding tcz in 4.x tcz mirror, so you need to download the jpeg-6b source code to-- enable-static-- enable-shared configure and compile it, because php,py 's bin and lib are used in hippy compilation. The default is / usr/local, so the figure is convenient, so you don't need to add-- prefix parameter.)
Add py support: something in cpython:get-pip.py,pycparse,hippyvm src/requires.txt
Then prepare the hippy source code, github/hippyvm/hippyvm, press readme.md to check out https://bitbucket.org/pypy/pypy/ to form an available source code structure. I have the latest source code here around February 15, 2018. Note that the default branch is selected here, and do not check out the PyHyp-related brands we mentioned above, that is, https://github.com/hippyvm/hippyvm/pypy_bridge, press its readme.md, its corresponding pypy in bitbuket's bitbucket.org/softdevteam/pypy-hippy-bridge/, it uses its modified pypy source code, this modified pypybridge also needs to modify the bridge's hippyvm/pypy_bridge.
Because prefix is not supported and the default is in-place generation, move the entire source directory to / usr/local/hippy, process the source code, move targetthispy.py to the root of hippy src, and then move the hippy in the hippy directory to src root. Move goal/targetpypystandalone.py to src root, too, so it's almost ready.
Compile
In fact, it can run without compilation, called untranslated, non-jit version. It's cpython logic, just like rpy, which is slower than normal cpy. Just python. / bin or pypyinteractive.py is fine, and what we need is the version of-Ojit
The rpython in the source directory is the tool chain. Although rpy is in the form of source code, it has always been a tool ready for use. You can think of rpy as a bunch of py tools and executing it with cpy or pypy will generate C native code (translated), which is the same reason that C projects generate exe through makefile, except that this is the build system of py. And here is the generation of compilers and language suites.
Lib_py,lib_pypy is the additional platform module supported by pypy after generation. Lib_py is pure py, and lib_pypy is the unique module supported by pypy.
All right, let's build pypy first.
Cd / usr/local/hippy
Sudo python. / rpython/bin/rpython-- continuation-Ojit targetpypystandalone.py
At the end of the long compilation process (the recompilation will not be continued because of frequent errors, so the above-- continuation), at the end, you can see that it can be divided into several steps
Annotate,rtype,pyjitpl,backendopt,stackcheckinsertion,database,source,compile,build_cffi
Under 2core 4G memory + 3G swapped memory, except that pyjitpl and stackcheckinsertion took about half an hour, the others were all within 10 minutes, and the most time-consuming was stackcheckinsertion.
The compiled pypy can delete the rpy, but it's best to keep it, because it's not big at all, as you'll see next. Because it's more clear: pypy is the fact that pypy implements + rpy.
If jit is not enabled and there is no-Ojit, then the compiled pypy is actually a normal pypy interpreter, just as untranlated's cpy runs directly (non-C, without jit) or even slower. As for rpy, you don't have to be involved by the user at the beginning and end, it only appears in the process of compiling pypy (as a tool chain to control the generation process and target pypy interpreter selection), and it only makes sense for users who use rpy to invent a new language.
Then use high-speed pypy to build hippy, which is the pypy of translated version and with jit.
Sudo pypy-c. / rpython/bin/rpython-- continuation-Ojit targetthispy.py
Thank you for your reading, the above is the content of "how to compile pypy and hippyvm on tinycolinux". After the study of this article, I believe you have a deeper understanding of how to compile pypy and hippyvm on tinycolinux. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.