@rem @rem Wrapper for customizing a build Visual Studio 20xx C++ @rem @rem Overrides the _CL_ and _LINK_ environment variables to @rem permit making common build option changes without editing @rem the Makefile or adding additional make targets @rem @setlocal @echo off @set ARCH=SSE2 @set CLR= @set FAVOR= @set LST= @set OPT=-O2 @set ORD= @set GL= @set LTCG= @set CB2= @set LB2= @rem Check that executable not in use preventing built binary from linking @del /q *.exe @if exist *.exe echo Warning! EXE may be in use! & sleep 2 @rem main parsing loop :main @if "%1"=="asm" goto do_asm @if "%1"=="atom" goto do_atom @if "%1"=="b2" goto do_b2 @if "%1"=="clean" goto do_clean @if "%1"=="clr" goto do_clr @if "%1"=="cod" goto do_cod @if "%1"=="instr" goto do_instr @if "%1"=="ltcg" goto do_ltcg @if "%1"=="opt" goto do_opt @if "%1"=="ord" goto do_ord @if "%1"=="Od" goto do_Od @if "%1"=="od" goto do_Od @if "%1"=="O1" goto do_O1 @if "%1"=="o1" goto do_O1 @if "%1"=="O2" goto do_O2 @if "%1"=="o2" goto do_O2 @if "%1"=="IA32" goto do_IA32 @if "%1"=="ia32" goto do_IA32 @if "%1"=="SSE" goto do_SSE @if "%1"=="sse" goto do_SSE @if "%1"=="SSE2" goto do_SSE2 @if "%1"=="sse2" goto do_SSE2 @if "%1"=="AVX" goto do_AVX @if "%1"=="avx" goto do_AVX @if "%1"=="" goto launch @rem oh oh @echo unknown option %1. Fail! @goto done @rem generate .COD files, assembly listing only, no source :do_asm @set LST=-FAc @shift & goto main @rem Favor code generation for Intel Atom processor instead of the default @rem which is to favof the "big core" processors like Core 2 and Core i7. @rem This works for both 32-bit and 64-bit builds and doesn't seem to hurt @rem the performance on the big cores but definitely helps on the Atom. @rem This is not on by default simply because not supported by earlier VS. :do_atom @set FAVOR=-favor:ATOM @shift & goto main @rem select a different compiler back end C2.DLL (e.g. Intel C++, Phoenix, etc.) :do_b2 @set CB2=-B2%2 @set LB2=-B2:%2 @shift & shift & goto main @rem delete common temporary files :do_clean @del /s *.a *.o *.obj *.lst *.cod *.pdb *.pch *.pgc *.exe *.map @shift @goto main @rem generate an MSIL managed bytecode (.NET) version of the executable :do_clr @set CLR=-clr @shift & goto main @rem generate .COD files, which are full source and assembly listing files :do_cod @set LST=-FAsc @shift & goto main @rem perform a PGO instrumentation link, generates a special binary which records profile data :do_instr @set GL=-GL @set LTCG=-ltcg:pginstrument @shift & goto main @rem do Link Time Code Generation (a.k.a link time whole program optimization) :do_ltcg @set GL=-GL @set LTCG=-ltcg @shift & goto main @rem perform a PGO optimization link, presumes that an instrumentation run was already done :do_opt @set GL=-GL @set LTCG=-ltcg:pgoptimize @shift & goto main :do_ord @rem Uncomment the next line to rebuild the link ordering file. Really for my use only. @rem if not exist bochs.ord (copy helpers.ord bochs.ord & sed "s/^/?/" hotfuncs.txt | sed "s/$/@bx_cpu_c@@SIXPAVbxInstruction_c@@@Z/" >>bochs.ord) @set ORD=-order:@bochs.ord @shift & goto main @rem do not optimize, useful for debugging :do_Od @set OPT=-Od @shift & goto main @rem optimize for size (smaller code, usually slightly slower) :do_O1 @set OPT=-O1 @shift & goto main @rem optimize for performance (possibly larger code, but more aggressive inlining) :do_O2 @set OPT=-O2 @shift & goto main @rem /arch:IA32 is a new option in Visual Studio 11 to emit x86/x87 code only @rem since the default is /arch:SSE2 for both 32-bit and 64-bit compilers :do_IA32 @set ARCH=IA32 @shift & goto main @rem emit SSE compatible instructions (Pentium III, Athlon XP, and later) :do_SSE @set ARCH=SSE @shift & goto main @rem emit SSE and SSE2 compatible instructions (Pentium 4, Opteron, and later) :do_SSE2 @set ARCH=SSE2 @shift & goto main @rem emits VEX-prefixed AVX instructions and references YMM state :do_AVX @set ARCH=AVX @shift & goto main :launch @set _CL_=-D_CRT_SECURE_NO_WARNINGS %FAVOR% @set _CL_=%_CL_% -Zi -W3 -EHs-c- -MT -Gr -WL -wd4996 @set _CL_=%_CL_% -arch:%ARCH% %GL% %CLR% %CB2% %LST% @set _CL_=%_CL_% %OPT% -Oy -Oi -Ob2 -GA -GF -Gy -GS- @set _LINK_=-opt:ref -debug -map %LTCG% %ORD% %LB2% @echo Launching nmake... @echo _CL_=%_CL_% @echo _LINK_=%_LINK_% @sleep 2 @nmake /i @title Building with %ARCH% %OPT% %GL% %CLR% %CB2% %LTCG% %ORD% :done @endlocal