By default v8 only builds on MSVC for Windows. It also supports building with mingw, but it is not documented anywhere and I’ve lost some time finding how. So here it is, easy steps for whoever needs it.
Prerequisites
1. v8 source code (of course), in my case I used trunk.
svn checkout http://v8.googlecode.com/svn/trunk/ v8
2. scons (building tool used by v8)
http://prdownloads.sourceforge.net/scons/scons-1.3.0.win32.exe
3. mingw32 (gcc 4.x.x is required to build v8)
binutils-2.20.1-2-mingw32-bin.tar.gz
gcc-full-4.4.0-mingw32-bin-2.tar.lzma
make-3.81-20090914-mingw32-bin.tar.gz
mingwrt-3.15.2-mingw32-dev.tar.gz
mingwrt-3.15.2-mingw32-dll.tar.gz
w32api-3.13-mingw32-dev.tar.gz
You can get those from http://sourceforge.net/projects/mingw/files/.
Building v8 with mingw
1. Using the “toolchain=gcc” command line paremeter doesn’t work, so you need to modify Scons.
a) Open file C:\Python26\Lib\site-packages\scons-1.3.0\SCons\Tool\__init__.py
b) Find the line “if str(platform) == ‘win32’:”
c) Modify the tools lists to use mingw tools instead of msvc tools by default.
Should look something like this once done:
linkers = ['gnulink', 'mslink', 'ilink', 'linkloc', 'ilink32' ]
c_compilers = ['mingw', 'msvc', 'gcc', 'intelc', 'icl', 'icc', 'cc', 'bcc32' ]
cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'c++', 'bcc32' ]
assemblers = ['nasm', 'masm', 'gas', '386asm' ]
fortran_compilers = ['g77', 'gfortran', 'ifl', 'cvf', 'f95', 'f90', 'fortran']
ars = ['ar', 'mslib', 'tlib']
other_plat_tools=['msvs','midl']
2. Open a command line (cmd.exe)
3. Set you environment path (if required)
set path=c:\python26;c:\python26\scripts;c:\mingw\bin;%PATH%
4. Build v8
scons mode=debug visibility=default
note: the visibility=default parameter is required otherwise gcc generate a warning (as an error) and the build doesn’t work.
note: currently (revision 4432) only static debug mode works with mingw building, debug=release produce errors (warning as error) and so does library=shared (building dll). Will try to fix this in a next post.
Have fun with v8 😉
Hey, thanks for that. It didn’t work right away, halting at the first warning (visibility=default didn’t fix that). I had to comment out “-Werror” in the SConstruct file and now it seems to be compiling properly..
When I execute:
C:\scons mode=debug visibility=default
scons: *** No SConstruct file found.
File “C:\Python27\Scripts\..\Lib\site-packages\scons-2.3.1\SCons\Script\
Main.py”, line 916, in _main
Any idea how to fix this?
scons is the old way of building v8. You should now be using gyp. Please see https://code.google.com/p/v8/wiki/BuildingWithGYP
@nicdex,
I tried this method too. Installed Python27, MSYS, MinGW. I loaded the V8 source and gpy files (http://gyp.googlecode.com/svn/trunk build/gyp).
This was the exact steps I followed there after:
————————————————————————-
Building and testing:
Open a MinGW shell
tools/mingw-generate-makefiles.sh (re-run this any time a *.gyp* file changed, such as after updating your checkout)
make ia32.release (unfortunately -jX doesn’t seem to work here)
make ia32.release.check -j8
————————————————————————-
But when i execute “tools/mingw-generate-makefiles.sh” I get gpy.mingw file not found. Indeed this file was not present in /build/gpy/ folder. What did I miss?
I didn’t hear from you. It’s ok to say you don’t know how to do it too! :). Silence does not help 😉
Sorry message got lost in my inbox. I haven’t built v8 using mingw in a while. I have a Visual Studio license now, sorry can’t help more.