osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python compiled by tcc


Am 18.05.17 um 10:10 schrieb Christian Gollwitzer:
> The whole discussion reminds me of the "bumblebees can't fly" thing. 
> 
> tcc is a very small compiler (some 100kb) which supports most of C99. 

For what it's worth, I compiled Python 3.6.1 on Linux/x86 using tcc. It 
was a simple matter of cloning tcc, compiling/installing it and the doing

	CC=tcc ./configure
	make

in the Python source folder. It only failed at the final linker step, 
because the tcc linker does not understand the flags -Xlinker 
-export-dynamic.

The compilation was extremely fast, it took 5s of wall clock time and 3s 
of user time to go from the sources to the python executable.

The ./python executable generated this way does work as far as I can 
tell, however "make test" fails with an import error - module "socket" 
is not available. Additionally, after linking "python", the compilation 
went on and required a C++ compiler, which was no problem in itself, but 
of course fell back to g++  - tcc only supports pure C.

So IMHO it should be a breeze to compile a pure C Python extension into 
something which successfully runs with the gcc compiled python.

On OSX, it was not successfull, because tcc cannot yet create executable 
binaries on disk in Mach-O format, however, ibraries are possible and 
runtime-linking (JIT) works without problems.

I guess that compiling the full thing on Windows could work with CC=tcc, 
if the GNU utils arae available (Cygwin/MSYS/Linux subsystem)

	Christian