Forum > Windows (32/64)

Compile lazarus from beginning

<< < (3/3)

wp:
This is the basic batch file which I am running the create my FPC/main/fixes installations on Windows:

--- Code: ---set FPC_DEST_DIR=c:\Lazarus\fpc-main
set BINUTILS_DIR=C:\Lazarus\fpc_bootstrap_compiler\3.2.2\i386-win32
set BOOTSTRAP_COMPILER=%BINUTILS_DIR%\ppc386.exe
set BIN_DIR=bin\i386-win32
set FPC_BIN_DIR=%FPC_DEST_DIR%\%BIN_DIR%
set OPTIONS="-dDEBUG -gl -gw2"     

::------------------------------------------------------------------------------
:: Prepare directories
::------------------------------------------------------------------------------
mkdir %FPC_DEST_DIR%
cd %FPC_DEST_DIR%

::------------------------------------------------------------------------------
:: Clone git repository
::------------------------------------------------------------------------------
:: Use this for first installation (don't remove the '.' from the end!)
git clone https://gitlab.com/freepascal.org/fpc/source .
:: Use this for updates
::git pull --rebase

::------------------------------------------------------------------------------
:: Set Path
::------------------------------------------------------------------------------
path %BINUTILS_DIR%;%PATH%

::------------------------------------------------------------------------------
:: Preparations
::------------------------------------------------------------------------------
mkdir %FPC_DEST_DIR%
cd %FPC_DEST_DIR%
md %FPC_BIN_DIR%
copy %BINUTILS_DIR%\*.* %FPC_BIN_DIR% > nul
del /q /s %FPC_DEST_DIR%\units > nul
rmdir /s /q %FPC_DEST_DIR%\units

::------------------------------------------------------------------------------
:: Build FPC
::------------------------------------------------------------------------------
make clean all install OPT=%OPTIONS% PREFIX=%FPC_DEST_DIR% FPC=%BOOTSTRAP_COMPILER%

::------------------------------------------------------------------------------
:: Make fpc.cfg
::------------------------------------------------------------------------------
cd %FPC_DEST_DIR%
fpcmkcfg -d basepath=%FPC_DEST_DIR% -o %FPC_BIN_DIR%\fpc.cfg
--- End code ---

It is less flexible, but simpler than the script posted by thierrybo above. You have to make a few modifications to adjust it to your situations:

* Adjust the variable FPC_DEST_DIR to the directory into which you want to install FPC
* Adjust BINUTILS_DIR to the directory which contains fpc.exe and the other binary utilities of the the current FPC release version, v2.2.2 or v2.2.0. This means that in order to install FPC/main or FPC/fixes you must already have one of these releases on your disk because they are able to build the new FPC. (If you don't want to install a full FPC you can also download the binutils directory from somewhere - I don't know the exact location ATM).
* There are two occurencies of "i386-win32" in the batch - this means that this batch will install the 32-bit version of FPC. For the 64-bit version you'll have to replace this by "x86_64-win64"
* The OPTIONS in this particular file are for building the debug version of FPC. Change it accordingly if you need something else.
* The git command is shown for cloning the initial version. The URL is given for FPC/main. Replace it accordingly if you want fixes. When you later want to update your installation, comment this line out and activate the "git pull" line. Or deactivate both git lines when you made modifications of RTL/FCL sources yourself and want to rebuild FPC without interference from git updates.
* The section "Preparations" creates directories needed etc. it also deletes previously compiled units - I found this to be essential because without it the update sometimes does not work.
* The "Build FPC" block contains the only command to compile FPC and everything related. The OPT parameter is taken from the OPTIONS variable above, PREFIX defines the location where FPC will be built as given by the FPC_DEST_DIR variable, and FPC defines the compiler used for building as set up by the BINUTILS_DIR variable.
* Finally we need to write a valid fpc.cfg file which contains all these hard-coded paths. This is done by calling the fpcmkcfg utility.




nummer8:
@wp
Thank you for this very instructive explination.
I will use it and experiment with the options.

marcov:

--- Quote from: wp on November 13, 2021, 10:21:57 pm ---This is the basic batch file which I am running the create my FPC/main/fixes installations on Windows:


--- End quote ---

Here's mine (a .cmd)


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---@echo offrem A simple build script for Windows. 2018 version; switching between 32-bit and 64-bitrem nicer output due to stdout capturing. rem uncomment OS, en select if CPU has avx 1 or 2. rem Both host and target.  rem I have ivy bridge, skylake and Ryzen machines, roughly avx1 vs avx2.rem so that's why I model it that way. For the few runs I still do on older machines, I manually change the script. rem set OS=win64set OS=win32set AVX=1 rem CROSSOPTS64 is only added if 64-bit, to allow setting SIMD fpu option only for 64-bit. if %AVX% equ 1 goto:ivyrem Ryzen 5 2600 or Skylake laptopset CPUOPTS=-O2  -Opcoreavx2 -Cpcoreavx2set CPUOPTS64=-Cfavx2 set CORES=5goto donecpuopts :ivyrem Ivy Bridge i7-3770set CPUOPTS=-O2  -Opcoreavx -Cpcoreavxset CPUOPTS64=-Cfavx set CORES=5 :donecpuopts rem  ----   decode OS to cpu and compiler name. set OS_TARGET=%OS%if "%OS%"=="win32" goto:win32if "%OS%"=="win64" goto:win64 echo Unknown OS: %OS%exit /b:contosok rem A bit of a mess. A mix of configurable settings and variables mostly dependent on detected variables. set BASEDRV=c:set SRCDIR=%BASEDRV%\repo\fpcgitset PPCNAME=ppc%COMPSUFFIX%.exerem set FPCSTART=c:\fpc\3.2.2\bin\i386-win32\ppc386.exe set FPCSTART=c:\pp32rel\bin\i386-win32\ppc386.exe  rem %SRCDIR%/utils/fpcm/  for cross? x32->x64 ? set LOGDIR=%BASEDRV%\reposet INSTALLDIR=%BASEDRV%\pp%BITS%set DESTCOMPILER=%SRCDIR%/compiler/%PPCNAME%set CROSSOPTS= rem small FPC script to replace unix "time"set DUMPTIME=c:\usr\dumptime.exe if "%BITS%"=="64" set CROSSOPTS= OS_TARGET=win64 CPU_TARGET=x86_64  set OPTS=   -gw2 -godwarfsets -gl     set COMMONOPTS= COPYTREE=echo OPT="%OPTS% "  NOWPOCYCLE=1 OVERRIDEVERSIONCHECK=1 rem use only if starting compiler does not set NEWOPT= %CPUOPTS% rem === invariant part === cd /d %SRCDIR% for /f %%i in ('%FPCSTART% -iV') do set STARTINGVERSION=%%ifor /f %%i in ('%FPCSTART% -iTO') do set STARTINGOS=%%ifor /f %%i in ('%FPCSTART% -iTP') do set STARTINGARCH=%%i echo Starting compiler %STARTINGVERSION% on %STARTINGARCH%-%STARTINGOS% rem a small fpc program that dumps time, as substitute for *nix time if exist %DUMPTIME% (%DUMPTIME% set %temp%\stdbuild%BITS%.txt) echo Cleaningmake -j %CORES% RELEASE=0 %CROSSOPTS% distclean FPMAKEOPT="-T %CORES%" %COMMONOPTS% FPC=%FPCSTART% NEWOPT="%NEWOPT%"  ALLOW_WARNINGS=1 1> %LOGDIR%\cleanlog%BITS%.txt 2>&1 echo building %CPU_TARGET%-%OS%  make -j %CORES% RELEASE=0 %CROSSOPTS% all FPMAKEOPT="-T %CORES%" %COMMONOPTS% FPC=%FPCSTART% NEWOPT="%NEWOPT%"  ALLOW_WARNINGS=1 1> %LOGDIR%\buildlog%BITS%.txt 2>&1 IF %ERRORLEVEL% EQU 0 GOTO:buildOKecho build failed, skipping installationexit /b :buildOKfor /f %%i in ('%DESTCOMPILER% -iV') do set DESTVERSION=%%ifor /f %%i in ('%DESTCOMPILER% -iTO') do set DESTOS=%%ifor /f %%i in ('%DESTCOMPILER% -iTP') do set DESTARCH=%%iecho Generated compiler %DESTVERSION% on %DESTARCH%-%DESTOS% set FPCMAKENEW=%SRCDIR%/utils/fpcm/bin/%STARTINGARCH%-%STARTINGOS% REM separate install step for crossversion purposes (and under Unix sudo) FPCMAKENEW required for crossbuilding. echo installingmake install %COMMONOPTS% %CROSSOPTS% INSTALL_PREFIX=%INSTALLDIR%  FPC=%DESTCOMPILER% FPCMAKENEW=%FPCMAKENEW%/fpcmake.exe 1> %LOGDIR%\installlog%BITS%.txt   2>&1 rem otherwise %%i is parsed when if block is parsed and misses content changes inbetweensetlocal EnableDelayedExpansion if exist %DUMPTIME% (for /f "delims=#" %%i in ('%DUMPTIME% get %temp%\stdbuild%BITS%.txt') do set THETIME=%%iecho Ok, building and installing took !THETIME!) IF %ERRORLEVEL% EQU 0 GOTO:theend echo install failed!exit /b :win32set BITS=32set COMPSUFFIX=386set CPU_TARGET=i386goto:contosok :win64set BITS=64set COMPSUFFIX=x64set CPU_TARGET=x86_64set CPUOPTS=%CPUOPTS% %CPUOPTS64%goto:contosok :theend  

trev:
I've updated the Windows article for git from GitLab (and svn from GitHub). While I only very rarely use Windows (no more than half a dozen times a year), I believe what I've written is accurate, but someone may like to run their eye over it.

Navigation

[0] Message Index

[*] Previous page

Go to full version