Licho asked me to do a tutorial on how i did compile a optimized version of the engine for my Laptop, so if you use windows and want a optimized version for you CPU, you can do the same was i did:
Lets start on how its work, CPU have instruction set that make programs, code run faster, by default (in CMake) the engine is using i686 that "Pentium Pro" instruction set, is over 17 year old CPU that only support MMX, so to use the full power of your modern CPU (that have SSE, SSE2, SSE3, etc) you need to compile it your self.
It will use OMP (it will multithreaded a little, like ROAM terrain rendering, and does not desycn) to. (Optional)
First the thing you will need to download:
7z program:
http://www.7-zip.org/http://portableapps.com/apps/utilities/7-zip_portable/ (i used this portable version)
The Tarballs:
http://sourceforge.net/projects/springrts/files/springrts/spring-91.0/spring_91.0_src.tar.gz/downloadhttps://github.com/spring/mingwlibs/downloads (click in "Download as tar.gz")
https://github.com/spring/mingwlibs/tarball/master (direct link to above file)
So you will need to download the 2 files spring_91.0_src.tar.gz and spring-mingwlibs.tar.gz
CMake:
http://www.cmake.org/cmake/resources/software.htmlhttp://www.cmake.org/files/v2.8/cmake-2.8.8-win32-x86.exe (i used this one)
http://www.cmake.org/files/v2.8/cmake-2.8.8-win32-x86.zip (this one look like a
portable version, but i did not use it, so use it at your own risk)
MinGW:
http://tdm-gcc.tdragon.net/download (you need the On-Demand Installer)
http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm-gcc-webdl.exe/download (direct link to above file)
!Start
Use the 7z to "unzip/uncompress" the spring_91.0_src.tar.gz and spring-mingwlibs(some random numbers and letters).tar.gz (in 7z select the file and press "Extract") files. You will end with a spring_91.0_src.tar and spring-mingwlibs(some random numbers and letters).tar files, uncompress them to.
Now you have a "spring_91.0" folder, inside that folder, create a folder named mingwlibs and paste inside it the files of mingwlibs. So you will have spring_91.0\mingwlibs\bin; spring_91.0\mingwlibs\dll; etc...
Install MinGW, select the 32bits version, 64bits is not supported (something to do with not all librarys[ddl i think] not begin 64bits and no one wanting to compile them in 64bits; in future when someone compile them in 64bits, Auswaschbar [AF from SpringRTS i think] expect 5-10% performance boost).
Select (make sure it is marked) at least the following components:
gcc (version: MinGW Stable!)
core
g++
openmp (optional)
binutils
mingw-runtime
w32api
mingw32-make (if you have no Make installed yet)
gdb (recommended for debugging)
DO NOT USE SPACES IN DIRECTORY(s) BELOW OR YOU WILL GET ERROR.
Now install/use CMake and use cmake gui.exe, select the "source (spring_91.0 folder)" and a "build directory", press Generate, make sure that "MinGW Makefiles" and "Use default native compilers" are selected, wait it finish.
Unmark:
BUILD_spring-dedicated
BUILD_spring-headless
BUILD_spring-multithreaded
Change:
CMAKE_BUILD_TYPE
RELWITHDEBINFO to CMAKE_BUILD_TYPE
RELEASE
MARCH_FLAG
i686 to MARCH_FLAG
native (look at
http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html for more info or google "gcc march", that thing is your CPU optimization)
CMAKE_INSTALL_PREFIX
C:/Program Files (x86)/Spring to CMAKE_INSTALL_PREFIX
directory were you compile spring engine will be placed (hope no one literally place this text >.>, and do not use the same directory that was used in "build directory" above).
If you do not want OMP unmark OPENMP, it is marked by default and i let it marked cause it give performance boost too.
Press Configure and wait it finish, then press Generate and wait it finish.
Close CMake, if you did all correct you get no warning, if you did something wrong you will get a warning.
Now you will need
admin right for compiling:
Run cmd.exe (
http://en.wikipedia.org/wiki/Command_Prompt ), using cd "folder name" and press enter to go inside the folder and "cd .." and press enter to go a folder "up" (
http://coweb.cc.gatech.edu/ice-gt/339 for more info).
Go to the "build directory" you chose in Cmake and digit "mingw32-make install-spring" and press enter, WAIT A LONG TIME, when it end you will have you optimized version in the CMAKE_INSTALL_PREFIX location you did choice.
jK told me you can use "mingw32-make install-spring -jx" too, were the x
to the numbers of your CPU cores +1, so dual core
"mingw32-make install-spring -j3" , so the compile time is faster, but i did not use it, so use it at your own risk.
Now if you use Zero-K Lobby you just need to go to Documents\My Games\Spring\engine change the 91.0 folder name to "91.0 backup", and paste you folder with the optimized version in Documents\My Games\Spring\engine with the name "91.0"
You may need to copy all dll from \mingwlibs\dll to your 91.0 folder, do not really remember if it was necessary, if you get no error, do not do it.
Done it!!!!!!!!!!!
If you build give a error or desycn to NOT ask me how, i have no idea, first time i did try i got error to, i think it was cause i compiled 2 times in same folder (do not do this). Do not use space(s) in directory/path/folder(s) or you will get a error of files not found.
Only thing i know is that it worked for me and [DDM]loveu2 and we do not desycn, and it is faster, how much faster i have no idea cause we do not have a deterministic benchmark system for springrts. My CPU is a AMD Turion II P560 2.5 GHz.
SSE5 and AVX are causing descyn for some ppl, if your CPU use it, better to use another march flag from the link above that do not use these sets, in v89 and future you can use native cause SSE5 and AVX will be blocked in code, so native is safe.
I wanted to post more pics to make it easier, but do not want to use
http://imageshack.us/ , cause i fear that all pics will end up was a frog in a ice cube thing....
For more help and the oficial tutorial see:
http://springrts.com/wiki/Building_Spring_on_WindowsSomeone with a Youtube Acc, could make a video tutorail about it to, so its even easer.
Hope you like it Licho.
Dev can edit my post so it make more sense and/or look better, more structured.
updated for 91.0 - KingRaptor