Read Development Tutorial (a.k.a Build FAQ) text version

Development Tutorial (a.k.a Build FAQ)

by Marco van de Voort March 24st 2010


Foreword to the Development Tutorial

pe version HFHV pg version PFRFHGPFSFI @releseGdevelA his pe ws reted in erly PFH times @PHHSA when s notied tht more people strted plying with the more dvned spets of the uildproess of pg like trking dily x sttusD rossompiling nd in generl trying things tht used to e only done y smll irle of ore developpers nd mye selet few on the millists nd in the vzrus projetF hings like ootstrpping new versionD relese uildingD rossompilingD prmeterising the uild proessD ttempting to port to new yes etF his is logilD euse due to @minlyA eter9s e'ortsD the uilding proess is lot more roust nd )exile then it used to eF ine the (rst version of this fq s9ve deugged speilly the rossompiling prt of the proess it moreF he hevelopment utoril ws originlly ment s the suessor of the old HFWWFx mke yle peD whih hd gotten horrily outdtedF woreoverD the si ide of the mke yle fq didn9t work in prtieF he pe ontined only step y step tretise of the si feturesD nd when something went wrong @eFgF Fppu of n old version somewhereAD users often hd no ide how to solve the prolemF o this fq is set up more s n indepth tretise of uilding pg nd relted issuesD with muh more kground informtion tht n ssist generl prolem hunting proeduresF o if you think tht this pe is too verose nd even pednti t timesD nd should e limited to the re essentilsD my nswer will eX een thereD done thtD didn9t work XEA

This tutorial is not even close to being a replacement for the real manuals. wost of it will e in the mnul

thoughD exept some of the outlook on future versionsF ry to red the tutoril entirely t lest oneD inluding prts tht re not so relevnt to youF st is ll onnetedD nd reding the prts less useful for you might help you see the igger pitureF he purpose of the fq is di'erent from the dos euse it tries to doument use ses rther thn refereneD nd lso euse it is not fully synhronized with ompiler versionF sf you hve more questionsD suggestionsD try the pg millists httpXGGwwwFfreepslForgGmillistFhtml or ir


Versioning of the faq

he fq omes in two versionsD the hp t httpXGGwwwFstkFnlGmrovGuildfqFpdf one nd n rwv version t httpXGGwwwFstk he hp version is the uthortive one nd more often updtedF he rwv version is minly used to post vs to spei( topis on millists nd sgF nfortuntelyD the rwv export of v is not the stlest in the worldD so sometimes exporting to html doesn9t even sueed

· ersions HFHI nd HFHP were ontinuously updtedD oth exist in multiple versionsF · ersion HFHQ minly is n updte for the 6pgeqi nd relted diretory lyout modi(tions in IFWFSD nd improves the index nd glossry signi(ntlyF elso IFHFx topis re phsed outF · ersion HFHR is n updte for PFH nd post PFH developmentF eter hs ig plns with the uild proess @repling weui with more pg friendly solutionAD so HFHS ould e mjor updteF elso needs x tutorilsF · ersion HFHS is n updte fter some progress on ross ompilingD nd the emerging of n internl linker · ersion HFHT is n updte fter long rek due to losing the v soure s result of stolen omputerF e hp version ws yged nd reformttedD nd some updting ws doneX

gompiler version numers updted to PFPFP xew pkges strutureF sndex expnded wore IFHFIH nd g removl

· ersion HFHU is some mintenne fter PFPFR relese

ompiler version updted some PFQFx topisD whihwill e inresed in the futureF vyx IFTFP @mostly sorting of llEps index entriesA


channel #fpc, best populated in the late evenings CET.


newer uildsripts

· pdtes HFHU nd only hve minor typo (xesD nd ws relesed in the dy fter the initil HFHU version · ersion HFHV is mintenne relese fter PFRFHD v version IFTFS



Ordinary building


1 Base principles, naming, versions, requirements etc

IFI IFP ersionsD rnhesD tgs F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F equirements F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IFPFI IFPFP IFPFQ IFPFR IFPFS IFPFT IFQ IFQFI IFQFP IFQFQ IFQFR IFQFS IFQFT IFQFU IFR IFS ldX he qx linkerF rX qx rhiver F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F sX qx sssemler F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F mkeX qx mke F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F pg itselfF ppQVTD ppppD ppsprD fpF F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F yther tools F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F sntrodution F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F x wodules F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F hownloding soure vi x F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F pdting the soure vi x F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F everting x hekouts F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F ixporting @winQP usersD red this3A wore info out x F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F



ytining soure F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F

ixtension onventions F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F hiretory lyout F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IFSFI IFSFP IFSFQ nix @nd full lones like vinuxA F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F indows nd hos F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F here re my unitsc nit pth Epu F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F


he fpFfg on(gurtion (le F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IFTFI IFTFP IFTFQ IFTFR IFTFS F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F finutils pth Eph F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F finutils pre(xD ll inutils in one diretory F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F virry pth Epl F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F erosity options F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F


he order to ompile prts of pg F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F IFUFI ome interesting uild sripts F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F mrt linking F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F Q



2 Standard building

PFI glening PFIFI PFIFP PFIFQ PFP PFQ PFR F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F wke len F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F mke distlen F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F glening of rossompile uilds F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F



footstrppingX mke yle

gompiling snpshotY mke ll or mke uild PFRFI PFRFP PFRFQ PFRFR

gurrent uild proedure on winQP F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F he slow solutionX x exporting F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F he uik solutionX gyii F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F se spei( topisX instllFexe F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F utting it ll together F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F


vzrus F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F ypil prolems nd tips F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F PFTFI PFTFP PFTFQ PFTFR nnot (nd El`xxxxb F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F gyxx or other pgvEfei units not found F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F iping stderr nd stdout to the sme (leF F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F @indowsA uilding nd instll fils with invisile errors F F F F F F F F F F F F F F F F F F F F F F F F

3 Crosscompiling

QFI QFP QFQ fsi rossompiling of snpshot F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F grossompiling without rossEssemlerF QFQFI QFQFP QFR QFRFI QFRFP QFRFQ QFRFR QFRFS F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F grossompiling vzrus F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F grossompiling vzrus from windows to vinux repring diretory with vinux lirries kipping uilt in diretoriesX Ed Et stti linking F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F



snteresting ompiler nd mke(le options F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F hi'erene in pthsX Er`diretoryb F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F gyy F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F vsfhs F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F

4 Systematic problem solving for the FPC build proces

RFI RFP RFQ hetermining the prolemD inresing the verosityF gheklist eompiling F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F



5 Misc topics

SFI SFP rogrmming modelsF F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F vink ordering F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F SFPFI SFPFP SFPFQ SFPFR SFPFS Eve F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F Evy F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F Evh F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F ixmpleX pixing the preefh qu rekge with linkordering F F F F F F F F F F F F F F F F F F F F F ixmple ssX preefh R vs S pthredsXEf F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F








Part I

Ordinary building


Chapter 1

Base principles, naming, versions, requirements etc

1.1 Versions, branches, tags

oughly there re four versions tegories of pg nowX

pre-1.0 hese re versions re usully numed HFWWFx ersions efore HFWWFV don9t hve helphi feturesF sn generl these

re non supportedD ut speilly versions @HFWWFIP nd HFWWFIR sed versionsA re essentilly et9s for IFHF rowever we re tlking IH yer old ets hereD nd lot hs hngedD even during the IFHFx seriesF

1.0.x he so lled psiIHH rnhF hese versions @IFHD IFHFPD IFHFRD IFHFT nd IFHFIH A re ug(x releses of wht

is silly IFHF rowever sometimes nd helphi ompility (xes n rek kwrds ompilityF IFHFx is frozenD nd there will e no new releses or even (xesD fter IFHFIH from my PHHQD nd we strongly reommend upgrding to PFH

1.1.x/1.9.x/2.0.x his is the rnh tht yielded PFHFx seriesF st used to e lled the development rnh efore PFHDHD

ut now tht PFH is delred stleD the est nme would e PFHFx stle rnhF gompred to the IFHFx rnhD it dds most of the missing helphi fetures @dynmi rrysD interfesD defult prmetersA nd supports severl proessorsF his rnh hs multiple version numersD sine while in lph it ws lled IFIFxD while in et IFWFx nd the rel releses were lled PFHFxF his rnh is now losed D PFHFR will proly e the lst relese of the psiPHH rnh

2.1.x/2.2.x his is the rnh for the pg PFPFx seriesF win highlights re support for internl linking for windows

@winQPGwinTRGwineAF inTR nd ingi re lso newF (xesPP rnhF PFPFR is the lst of the PFPFx rnhD euse merging ws getting inresingly loursomeF hndlingD dwrf nd for newer rhitetures @speilly the TREit onesA

2.3.x/2.4.x he rnh for post PFR seriesF PFRFH ws relesed on jnuri IstD PHIH nd ontins improvements in resoure 2.5.1 his is the version in xuD the leeding edge of developmentF ome of its fetures will e merged k to PFRFxD

while others will only reh endusers when PFSFI goes golden s PFTFH or QFHFHF yne n see wht @post PFHFHA rnhes exists vi the iewv weinterfeF eleses re tgged with ivieixyz for relese xFyFzF o relese IFHFP is tgged ivieiIHP in gF hile IFHFV tgs might exist in gD there is no o0il IFHFV version D this euse reting the IFHFV relese took long timeD nd the pkge ws reuilt severl timesD while lredy downlodle vi pF feuse the ore tem ws frid ll those versions with the sme numer would rete onfusionD it ws deided to inrese the version numer for the (nl relese to IFHFIHF he version history is illustrted in the following grphX





hile IFHFx lso supports two proessors @intel xVT nd wotorol mTVkAD the IFIFx rnh ontins more fundmentlly enE gineered pproh to mke pg multi rhiteture ompilerF gurrently it looks like the (rst relese of the IFIFx rnh will support xVTD ppD erm @urus nd similr deviesA [email protected] pr @VDWAF

1.2 Requirements

e supported y nd proessor re of ourse the min requirementsF uh info n e etter gotten from the wesiteD sine the sttus hnges frequentlyF1 he pg uild proess needs ertin toolsF hile usully this is ll provided y the yD or instlled y the pg relese pkgeD s nme them here expliitely to mke it esier for people to deug uild prolemsF he min toolsX

ld he qx linkerF vinks unh of Fo nd F9s together to form lirry @Fdll or FsoA or (nished progrm @like Fexe on

windowsD extensionless on nixA

as he qx ssemlerF essemles the textform representtion in Fs or Fs (le to n Fo (leF ar needed for reting stti lirries @FA from Fo9sF tti lirries re used when uilding for smrtlinkingF make qx mkeF hetermines the order of wht to uildF foth on (le s on diretory levelF glled gmke on Bfh ppc386 or pp`proessorb in generlD preferly the lst relese versionF footstrpping from other ompilers is not relistiD

ndD to my est knowledgeD hsn9t een ttempted in yers @IFHFx timesA he (rst three re found in the pkge inutilsD the version doesn9t mtter muh s long s it is not fossilF et lest on mjor pltformsF ome pltforms pkge n old versionD eFgF ypenfh used to pkge fossils euse it still used Fout s inry formtD though s herd tht they (nlly got rid of tht in version QFRF hese utils re rrely soure of errorsD ut depend on the trget y nd gD whih omplites rossEompiling itF wke is usully otined from the sme soure s inutilsD ut pkged seprtelyF ee the seprte setion on mke elow for some ommon vetsF

1 Actually,

while writing this, I witnessed the rst working Hello world program on the Sparc V8 architecture :-)




indows users tht uild system from srthD should get the mkewQPFzip nd sldwQPFzip @or similrA (les from the seprte sudiretory of the lst relese to get the needed externl toolsF nder Mac OS X/Darwin D the inutils nd mke re prt of the epple developertoolsD whih for IHFQ re utomtilly instlled when you instll godeF pink @n open soure softwre distriution for w y A is not stritly required for pg opertionD ut most nix lirries you might need @like mysqlD nurses etA re prt of pinkF he rumour is tht in IHFR these tools were (nlly sed on reent qx versionsD

1.2.1 ld: The GNU linker.

he qx linker is the (nl step in the uilding proess of pg soure to runnle inryF es sid eforeD reent version tht supports linkersript (les is the only prerequisite for n esy rideD exept for winQPD where the linker should understnd !seE(le nd !imgeEse prmetersF @these re lso lredy supported over P yers thoughAF he supported inQP pltform s fr s uildtools re onernedD is mingwQPD not ygwinF pg n link to ygwin lirries thoughF yne ould mye use other linkers then qxD ut tht9d require reimplementing the prt tht lls the linker @this hs een done eFgF for ypenfh Fout in the IFHFx ompiler nd hrwin9s mhEy vh in PFHCAF rowever keep in mind tht the onnetion etween the ssemler nd the linker is ommonformt for the ojet (le @FoAF ghnging to linker tht uses di'erent formt might lso require di'erent ssemlerD nd in turnD di'erent ssemler might require dptions to the pg prt tht writes the ssemler odeF rowever ll these re doleD even for people tht ren9t omplete ompiler wizrdsF sf your pltform is not minstrem Bnix or windowsD try to (nd linker tht supports the !ldEsetions prmeterF he new smrtlinking will e sed on this vh prmeterF trting with pg PFIFID the ompiler lso hs linker internl for some pltforms whih is enled using EiF his internl linker links wy fsterD nd uses less memoryDspeilly when using smrtlinking2 F et the time of writing the indows pltforms @iA re supported y this internl linkerF

1.2.2 as: GNU asssembler

he ssemler must e qx @qAeD nd must e reltively reentF elly old xVT qx ssemlers might hve hidden ugs tht don9t surfe when used with gF ine qx e is typil kend ssemlerD in the pst dressing modes nd opodes tht ren9t emitted y g ould e prolemtiF en exmple of this is the ypenfh QFx seriesD where y just sustituting newer ssemler from the ports tree pg suddenly uildsD while it fils with the pkged ssemlerF e reltively reent version is lso nie euse these proly support newer xVT instrutions @iPDiQAF yn some pltforms @winQP nd xVT ivpAD pg hs n internl ssemlerD nd voids e for performne resonsF his internl ssemler is lled the inwriter in pg jrgonF he inwriter is it more thn pure ssemler thoughD sine it n lso diretly write stti lirries @BFA F hile notile with ordinry ompiles tooD the performne prolems tht the inwriter solves re minly notile when smrtlinkingF pg lso hs the ility to generte ode in ewD xewD wew nd ew @wtomA formtF rowever these ren9t freE quently testedD so your milege my vryF

1.2.3 ar: GNU archiver

he rhiver retes rhive @ FA (les out of ojet ode (les @FoAF his is minly done to redue the numer of (les involved in the linking proessD nd on disF erhive (les re often lled stti lirries euse they ontin roughly the sme ode for stti linking s the Fso @or FhvvA (les do for dynmi odeF @ Fdll nd Fso n e more thn one Fo tooAF he qx linker n diretly ess F lirriesF e n e prolem sometimesD sine the ompiler psses ll individul (les on the ommndlineF hue to eFgF smrtlinking nd this relly n e lotD nd e lrger thn the mximl llowed nr of prmeters for the yF @TRk prms is too littleD IPVk is still okA

2 About

250-275 MB as maximum amount of memory used to fully smartlink Lazarus, as opposed to +/- 1.5GB for GNU LD





make: GNU make

he uild proess of pree sl uses plin @qx mkeA mke(les tht re generted y pgmkeF pgmke genertes the wke(les from glol templte nd the wke(leFfp in eh diretoryF his wke(leFfp is simple sxs (le tht extends nd prmeterises the glol templte3 F here re plns for the future to get rid of the weui utility ll together nd reple it with more speilised own versionD ut these re still in the initil stgesF he urrent system is lso quite nie nd )exileF he urrently used mke is qx mkeD it9s ville for nerly ll pltformsF rowever there re some pltform spei( oddities listed elowF

Linux he only without muh odditiesF yf ll niesD vinux uses reltively lot qx toolsD nd less tools desending from

the originl unixF sf there is mke or mkeEpkge on vinux it is most likely qxF

*BSD he defult mke is pmke vrint whih is slightly di'erent from qx9sF he mke(le templte used y pg

isn9t omptile with pmke t this momentF @hintD hintA qx mke is instllle from the ports treeD usully s develGgmkeF hon9t forget to put the in diretory of the portsE6ips @GusrGlolGinD GusrGpkgGin etA into your pthD nd sustitute ll use of mke y gmkeF sn prtie this is no ig prolemD sine gmke is generlly ville on fh systemsD instlled s dependny of lot of development relted pkgesF

BeOS yn my instlltion @fey S ersonl iditionA oth inutils nd qx mke me with the developper kitF OS/2 s honestly don9t knowF here re iw nd ntive versionsD nd of ourse dos lsoF efik pg used to e iw

sedD ut is urrently gering towrds ntiveF s9ll hve to reserh this myself (rst XEA using n extenderD ll extenders hve to e the smeF snluding the utils XEA

Dos/Go32V2 ses htq qoQPP utilitiesF his euse pg uses the goQPvP extenderD nd for sfe nesting of progrms Netware xot even n ideF s never sw this port opertionlF win32/win64 se the mingw setD nd preferly the one distriuted with the most reent pg releseF ee elowF wince wy experienes re limited to gi s rossompiltion trgetF ome people hve eFgF xe oxes tht might llow

ootstrp pg on ingi sed hostF

Mac y gome with epple heveloper tools @whih re instlled with gode on IHFQAF sing generi nix lirries like

mysqlD nursesD postgresql et might require psxuF he sitution on winQP often onfuses peopleF his minly euse there re t lest three ville sets of the ove utils @rDldDsDmkeA tht run on indowsF eny mixing @one util from one tegoryD one from the otherA n lso led to unpreditle resultsF enywyD the three ndidtes reX

Mingw @sometimes lled mingwQPA whih is the one to useF inQP ntive tools with rel winQP feelF @driveletters nd

kslshes in pths etA referly versions distriuted with pg relesesD sine they might inlude pg spei( ritil pthesF iFgF t ertin point it turned out tht mingw tools only serhed for pitlised er vrileD nd not one spelled like th whih is ommon on x sed indows versionsF ee the winQP spei( prt of the pe on the pg wesite for more infoF

Cygwin provides mximl ompilitywith nixD nd n e seen s nix ompility lyerF pg however is relly ntive

on windowsD nd hving hlf windowsD nd hlf @ompilityA unix uild system is hrd to mintinF pg does ompile with urrent gygwin instll thoughD ut the resulting ompiler is no ygwin progrmF elso ygwin progrms need ygwinIFdll in the orret version F xote X pg n link to ygwinD however doesn9t need it for opertion @exept for the textmode shiAF eentlyD gygwin improved in ntive pth supportD if the pths re fully quli(edF wingw is still etterD ut ygwin is usle for emergeny opertionF it would e like using the winQP tools vi ine on vinux XEA

go32v2 qoQPvP is dos sedD nd used vi the dos ompility system of indowsD don9t use it with the winQP ompilerD

e ommon prolem s enountered on winQP is putting the ygwin in diretoryin the winQP serh pthF he mingw mkeFexe (nds the ygwin shellD nd tries to exeute ertin progrms with itF gygwin hs improved lot reently thoughD nd urrently this seems to work ginD t lest if everything is situted on one drive @one n reompile pg with only ygwin nd pg ommndline ompilerAF

3 which

can be found in fpc/utils/fpcm/fpcmake.ini




xote tht some other development tools @forlndD wirosoftD jvA might lso pkge mke versionF elwys put pg s the (rst diretory in the erF hue to some new developments with prllel ompiling using the pg mke(lesD make 3.80 is strongly recommended as of FPC 2.1.1 (januari 2007 and later). nix people with dul ores nd up to dte soure trees might wnt to try mke Ej PF

1.2.5 FPC itself. ppc386, ppcppc, ppcsparc, fpc.

pree sl is written primrily in itselfD in the sl dilets it supportsF his hs some onsequenes for eginning the ootstrpsF

· e norml uild of pg is pretty muh only dole with pg s strting ompilerF · footstrpping from helphi ws possile for while under ertin irumstnesD ut requires some skillD sine the mkeE (les don9t support itF helphi ompility hs een negletedD sine too mny helphi ugs popped upD nd keeping it ompille ws prolemF omewhere etween IFWFR nd IFWFT most helphi workrounds were removedF hPHHS ws never testedF he possiility with helphi s strting ompiler proly filed euse while helphi would hve een gret from n vilility pointD it ws esier to use pg euse of helphi9s ugsF · footstrpping from should possile for IFHFx versions nd erlierF IFIFx uses delphi lssesF rowever lredy quite some mstership ws required for thisD sine the ompiler is lrge progrmD nd the single dtsegment limittion of ws severeF · footstrpping from qx qg or pP is not doleF heir modi re not even lose to eing Gf omptile enoughD nd pg IFIFx nd eyond need helphi ompilityF · footstrpping though might e dole in theoryD t lest for IFHFx with some onsiderle skillF his hs never een tested thoughD sine pg is etter on nerly ll pltforms nywy for si reompiltionD nd less uggyF

he resons for these hoies elong in n dvoy doument rther thn hereF4 rowever prtilly there is one mjor disdvntgeX you need pg to uild pgD nd one mjor dvntgeX pg generlly needs muh less tools instlled to uildD ompred to eFgF qgg uildF yne lso needs only suitle ompiler inry to ootstrp pgD not even fully )edged pg instlltionF @on pltforms tht don9t ome with itD you need the qx uild tools thoughD see prgrphs oveAD nd there re essentilly no library requirementsF ith the internl linkerD in time even the qx tool requirements my dispperD llowing single ompiler inry to fully ootstrp the whole pgGvzrus projetF he (le you need to strt n ordinry snpshot uild is pp`proessorbD so ppQVT for xVTD pppp for owergF ppspr for un pr V systemsD ppxTR for xVTTR @TREit xVTA etF ill now these (les lwys hve een sttilly linkedF so there is only one vinux ompilerD one preefh ompiler etF uernelD lirry nd distriution versions don9t mtterF @exept mye mjor kernel hnges in extremeD rre ses like vinux IFHFx to PFHFxA por rossuilds to the sme proessor ut di'erent y you don9t need speil rossEompilerF ynly for rossuilding to di'erent proessors you9ll need di'erent oneF fesides thisD there is the fpc inryF his is ommon frontend to ll pp`pub ompilers on systemD one tht ompiles for the urrent rhiteture nd one tht ompiles for the restF he reson for this is tht one n use one inryD nd speify the proessor with EF o

fpc -Ppowerpc compileme.pp

will ompile ompilemeFpp using the owerg @ppppA ompiler if everything is set up orretlyF fut we9ll get into tht lter XEA he fp inry n lso e used to set ompiler versionX

fpc -V1.0 compileme.pp

will exeute the defult ompiler @pp`urrent proessorbA with EIFH su0xedF gomining with E is possileF fp Epowerp EIFH will try to run inry ppppEIFH s the rel ompilerF peilly on nix this is nieD sine only ouple of symlinks llow to swith versions esilyF gomined with msterfully reted fpFfg (le one n uild very powerful rossompiling systems tht utoselet the right trgetsF e9ll get to tht lterF

4 The

FAQ lists some reasons, but IMHO not all.





Other tools

ometimes there re other pltform dependnt toolsF wost notly the indows resoure ompiler windres to ompiler resouresripts @BFrA nd dlltool to generte importlis for pg generted hvvs so tht ertin other ompilers @wgD mingwA n use themF

1.3 Obtaining source

1.3.1 Introduction

ight fter the pg PFH releseD the pg projet hnge to use x s soure version mngment systemD for resons mostly relted to merging nd rnhingF sully when uilding snpshotD the soure is otined vi xD nd omes s lrge souretree with fpG s the root diretory of the repositoryF rowever the soure is usully lso downlodle s n rhive from the min site56 F his rhive is getting lrger eh month thoughD nd is lredy PSw zippedF e etter wy is to get the soures vi xD whih llows to upgrde soures to more reent versions inrementllyF @iFoFwF the seond timeD it only downlods hngesA

1.3.2 SVN Modules

he pg nd vzrus soure is spred out over severl x modulesX

Module fpc fpcdocs fpcprojects fpcbuild lazarus


Description The core FPC repository. Contains compiler, RTL, textmode IDE and most non visual libraries A The FPC documentation source (in L TEXand fpdoc XML format) Projects not yet suitable for distribution together with FPC are parked here. (includes IRC bot) Contains fpc and fpdocs tree as well as the install and demo dirs and a makele for release packaging. The Lazarus project (visual classes library LCL and the Lazarus IDE/RAD)

Downloading source via SVN

o hek out moduleD use the follow lineX

svn co<module>/trunk <module> # # Examples: # # FPC # svn co fpc # # fpcdocs # svn co fpcdocs # # fpcprojects (has no branches, maybe you don't need /trunk at the end) # svn co fpcprojects # # lazarus # svn co lazarus

o hek out rnhD reple trunk in the ove lines with the rnhesG`rnh nmebF iFgF to hek out the rnh (xesPRX

5 \href{}{ 6 \href{}{

development series)} (2.2.x)} (2.5.x




svn co fpc-2.4.x

pei( releses re tgged with tg tht is formted like ivieiPRH D nd n e heked out like thisX

svn co fpc-2.4.0

1.3.4 Updating the source via SVN

he dvntge of getting soure vi x is of ourse the inrementl updtingF his is very simple with xD simply use svn up xD if x is diretory where you hve heked out something eforeF http pthD (xes nd rnhes re utomtilly red from the systemF ixmplesX

svn up fpc # svn up fpc-2.4.0

1.3.5 Reverting SVN checkouts

omething new in x is revertingF sf lol edits use on)its when updting your hekoutD or if you wnt to e IHH7 sure tht there re no lol editsD you should revert your hekoutD to mke sure tht your lol opy is relly in syn with the x serverF ou should do this if you9re hving prolem tht other people on sg nd millists n9t dupliteD nd your strting ompiler is orretF ixmplesX

svn revert -R fpc

1.3.6 Exporting (win32 users, read this!)

ixporting is silly retrieving lol working opy from hekoutF ypil resons to uild in n export insted of hekout reX

· ou re doing relese uildF iFgF mking wsD desD freesd ports entries etF · ou re uilding on winQP D nd wnt to use mke instll to instll the uildD exh you wnt to instll exmplesF

he prolem on windows is tht some tools get onfused y the redEonly ttriutes set on dminstrtive (les y some x lientsF ine svn export only opies the repository9s ontentD nd not the dministrtive (lesD this is good workroundF ixporting is e'etively opyingD so this workround tkes out the sme time nd spe s mnully opying the hekoutF he formt of the export ommnd isX

svn export path\to\checkout exportdirectory


svn export d:\fpc fpcexport or svn export /usr/local/src/fpc fpc

sf the seond rgument lredy existsD x will refuse to do thisF sn tht se use !fore to fore svn to updteF

Note IX s hven9t tested this yetD ut lening the repository efore exporting ould speed up somewhtD speilly on

windowsF xote PX por faster solution see the uild triks setionF





More info about SVN

wore info out pg nd x n e found here httpXGGwwwFfreepslForgGwikiGindexFphpGxwigrtion

1.4 Extension conventions

pg de(nes some extensions tht need some lri(tionX

.o he tul ode of ompiled unit or min progrm .a he tul ode of ompiled unit or min progrm when smrtlinkingF .ppu he rest of the ompiled unit tht is not tul odeF @like informtion out diretives tht where de(ned when

ompilingD the prsed interfe etA

.s essemler ode @to e ssemled FoA generted y the ompilerF .as essemler ode in soure form @there never ws psl equivlentAF sully progrm strtup odeF .s (lesF Frst resourestring (les for interntionlistionF .$$$ temporry (lesF gn e sfely removed usully .res indows or yGP resoure (le link.res vinker sript (leF gontins whih (les mke up the inryD nd wht externl lirries re usedF @or FtA th(le tht lls the linker with the orret rgumentsF *.lrs vzrus resouresD old style *.rc esoure soure (leD to e proessed y windres to Fres

he extensions on winQP originlly endded in w @BFowD BFppwAD whih ws done to void onfusion with dos ompilers on the sme systemF rowever this hs een supereded y etter diretory struture whih ws needed for esy rossompilingD nd in the IFIFxGIFWFx rnh the extensions for winQP re renmed k to FppuGFGFo o in the pg distriution you will (nd FppuD n F nd n Fo per ompiled unitF

1.5 Directory layout

issentilly the pg lyout is quite )exileF he inry @ppQVTD ppTVk or ppppA must e le to (nd on(gurtion (leD nd tht (le n speify the restF o the lyouts desried here re the defult lyouts s instlled y the relesesD or s plnned for future relesesF @the ltter of ourse re minly the multi proessor designA he se instlltion of pg hs these min tegoriesX

binaries he se inries @fpD ppTVk nd ppppD ppsprD ppxTRA must e in the serh er of the yF sf you

exeute fpD fp must e le to (nd the other ones @ppppD ppQVT etAD lso vi the erF

fpc.cfg he inry must e le to (nd the on(gurtion(le in one of the defultlotions s spei(ed for tht yF @see

pltform dependnt setionsA

units he on(gurtion(le must de(ne the orret pth to the v nd other pkges ompiled for tht pltformnd puF

his is usully treeF grossompile units lso elong in this treeF

(binutils) he inutils @vhDeDeA hve to e in the erD or their diretory should e spei(ed in the fpFfg (le or on

the ommndline with the Eph prmeterF yn operting systems tht don9t instll the inutils y defultD these re instlled y the pg instlltion proess in the sme diretory s the min inriesD so this is usully not prolem when not rossompiling or mixing two pg instlltions @eFgF hy nd indows instlltion on one mhineAF xote tht speifying in the fpFfg (le only works when ompiling progrms y hndF hen ompiling new ompilerD the fpFfg (le is ignored y the mke(leF




fesides these there re soure treeD doumenttionDthe ompiler lolistion @lngugeA nd exmple diretoriesF rowever these re only interesting for rel relese distriution engineeringDnd don9tin)uene the workingsof the ompileritselfF his euse the ompiler hs the soure lredy in ompiled form in the FoD F nd Fppu (les in the units diretoryF he ple of the soure doesn9t relly mtterF he only thing tht needs the soure diretory for utomted proessing is lzrusD nd one n enter ny pth in vzrus9 pg soure dilogueF hen writing pths in fpFfgD some sustitutions re utomtilly doneD eFgF

$FPCTARGET is repled y the rhiteture E operting system omintion you re ompiling forF @eFgF iQVTElinuxA $FPCVERSION is repled y the version of the pg ompiler reding itD nd (nlly $FPCCPU is repled y the proessor whih the ompiler is trgetingF $FPCOS is repled y the operting systemF $FPCFULLVERSION is repled y ompiler version with n extr pthlevelF @PFRFxA $FPCDATE is repled y the urrent dteF

ine (lesystems hierhies di'er with the yD s9ll put some y spei( informtion in the following setionsF

1.5.1 Unix (and full clones like Linux)

nder nixD most diretories re reltive to the so lled pre(xF e pre(x is kind of root diretory for pkge instllingF gommon pre(xes re GusrD GusrGlolD GusrGexp nd GusrGpkg @the lst one is ommon on xetfhAF he usul onvention is tht progrms tht ome with the seEdistriution go into GusrD nd hndEompiled or hndEinstlled pkges go to GusrGlolF rowever the de(nition of seEdistriution vries with the distriution nd yF he min ide is to give root @the dministrtorA trusted users the ility to instll nd mnge less importnt pkges in GusrGlol while keeping the se system only writle for the dministrtor @groupA himselfF vinux distriutions re trditionlly more likely to instll pkges into Gusr insted of GusrGlolD ut not every distriution does thtF mn hier should list some of the onventions used on your nix versionF sf diretories re reltive to pre(xD they re noted s 6ipsGtheGrestGofGthe pthF xote tht this hs nothing to do with 6pg`xb sustitutions in fpFfgF 6ips is shellsript nottion for get ontent of environmentvrile ipsF gompiled units go into 6ipsGfpG6pgisyxGunitsG6pgeqiF nits used for rossompiling lso go into 6ipsGfpG6pgisyxGunitsG6pgeqiF

finries go into diretory 6ipsGinD however sometimes these re only symlinks to the tul (les in 6ipsGliGfpG6pgi diretory to esily swith versionsF ine the inry n (nd its own unit (les using versioned info in fpFfg when properly set upD usully the defult inry is the only thing tht needs to e swppedF he ple where on(gurtion (les re serhed on unix reX GetGfpFfgD ~GFfpFfgF 6ipsGetGfpFfg is serhed from IFWFV onwrdsF @noteY ~ mens home diretory on nixA o let9s tke 6ipsaGusrGlolD 6isyxaPFRFHD 6pggaiQVTD 6pgyafreesd nd 6pgeqiaiQVTEfreesd s n exmpleD nd see wht (le goes whereX

File(s) fpc ppc386 ppcppc rtl for i386-freebsd rtl for i386-linux rtl for powerpc-netbsd rtl for x86_64-win64

location /usr/local/bin /usr/local/bin /usr/local/bin /usr/local/lib/fpc/2.4.0/units/i386-freebsd/rtl /usr/local/lib/fpc/2.4.0/units/i386-linux/rtl /usr/local/lib/fpc/2.4.0/units/powerpc-netbsd/rtl /usr/local/lib/fpc/2.4.0/units/x86_64-win64/rtl

remarks actually symlinked to /usr/local/lib/fpc/2.4.0/ppc386 actually symlinked to /usr/local/lib/fpc/2.4.0/ppcppc (cross operating system compiling) (cross architecture and OS compiling, endianness) (cross arch, OS, wordsize)

Note: IFWEIFWFR stored lirries for ross ompiltion in 6ipsGliGfpG6pgisyxGrossG6puG6trgetF feuse ll

pltforms re now fully quli(ed with rhitetureD seprte diretory for g is no longer neessryD nd pg IFWFS nd ove store everything in 6ipsGliGfpG6pgisyxGunits nd elowF





Windows and Dos

he windows nd dos se is pretty muh the smeF ixept tht 6pgeqiaiQVTEwinQP for windowsD nd 6pgeqiaiQVTE goQPvP for dosF It is advised to avoid using spaces in directory names. While (win32) fpc can handle it, some

versions of the binutils and other tools can not (yet), or need carefully placed quotes.

foth these two yes hve spei( diretory with ll pg relted (les @inluding the doumenttion etA in themD defult is usully used to e XppD ut hs een hnged to XfpPFRFH sine PFHF s ll this pth 6sxevvhsF sully there ren9t other versions in the sme 6sxevvhs e di'erent version mens di'erent 6sxevvhsD t lest in the defult situtionF ell inries go into 6sxevvhsin6pgeqiF his diretory should e in the erF his diretory is quite fullD sine there re other tools nd utilities instlledF rowever if the trget is mrked to require VFQ omptile nming @qoQPvPD yGPAD the inry pth is not 6pgeqi @eFgF inGiQVTEgoQPvPA ut just 6pgy @eFgF inGgoQPvPAF gompiled units go into 6sxevvhsunits6pgeqi nd deeperD t lest under PFHCF gon(gurtion (les re serhed in the sme diretory s the inry @6sxevvhsin6pgeqiAD ut if environE ment vrile rywi exists lso in 7rywi7GFfpFfgF o let9s ssume 6sxevvhsaXfpPFRFH nd the defult 6pgeqiawinQP

File(s) fpc ppc386 ppcppc rtl for i386-win32 rtl for i386-linux rtl for powerpc-netbsd rtl for x86_64-win64 Cross binutils libs for i386-win32 libs for i386-linux


location c:\fpc\2.4.0\bin\i386-win32 c:\fpc\2.4.0\bin\i386-win32 c:\fpc\2.4.0\bin\i386-win32 c:\fpc\2.4.0\units\i386-win32\rtl c:\fpc\2.4.0\units\i386-linux\rtl c:\fpc\2.4.0\units\powerpc-netbsd\rtl c:\fpc\2.4.0\units\x86_64-win64/\rtl c:\fpc\2.4.0\cross c:\fpc\2.4.0\libs\i386-win32 c:\fpc\2.4.0\libs\i386-linux


(cross architecture and OS compiling) (cross operating system compiling)

(not installed by default setup) (not installed by default setup) (not installed by default setup)

Where are my units?

trting with lter versions of pg IFWFSD the fp mke(les rete diretory to store the reted unitsF he min reson for this is uilding for multiple trgets without lening in etweenF o when just uild @not instlledAD the rtl units (les re in fpGrtlGfreesdGunitsG6pgeqiF his is silly exmple of ourseD sine the v is pltform spei(D ut this hnge is systemtiD so for the v tooF

1.6 The fpc.cfg conguration le

Note: pormer versions used ppQVTFfg s on(gurtion (leF iven ltere IFHFx versions lredy support fpFfgF sn time

ppQVTFfg will e droppedD so


use fpFfgF

e orret on(gurtion (le should t lest do the follow thingsX IF @ most important A rovide the ple where to (nd the orret preompiled units for the urrent seleted operting system nd rhitetureF sn shi9s this option is usully lled xser yptionX -Fu PF sf other inutils then for the defult pltform need to e used @like in the se of rossompilingAD then fpFfg should llow the ompiler to (nd themF s don9t know wht nme shi9s typilly use for thisD ut fsxsv er or qx sv er would e ppoprite yptionX -FD QF ixtr pths where stti nd shred lirries re serhedF yften lled lirry pth yptionX -Fl RF @ minor A fy defult the ompiler shows only very little errorsD wrnings nd informtionF st9s onvenient to dd some verosity prmeters to fpFfgF yption -vihw -lF 7

7 The

warning system is currently being expanded to have more exibility.




SF @rossompilingA finutils for ross ompiling re often pre(x with [email protected] iTVTEmingQPADthis pre(x n e spei(ed using E`pre(xb prmeterD or using mke(les using fsxsvipsF yption -XP here re other interesting possiilities of fpFfgD @like interntionlised errormessgesD setting the ompiler in di'erent mode per defultD lwys to try smrtlinking etA ut these re the importnt ones for norml developmentF

Note: ueep in mind tht when using the mke(les supplied with the pg soureD the fpFfg is NOT redF his is to void prolems with two vsD the old nd the new oneD when ootstrpping the systemF

1.6.1 Unit path -Fu

he Epu se is pretty muh s desried in the diretory lyout prgrphs @IFSAD there re two things in whih the Epu ompiler option di'ers from the diretory lyout s desried eforeF sf s ppend n sterisk @BA to pthD it mens tht it should serh ll diretories elow tht diretory tooD nd tht the lyout for rossompiled units is it di'erentF e n use the diretive pggygywsvsxq to detet rossompiltionF he pg mnul hs list of other de(nes tht n e testedF

Unix: sf we ssume tht the ompiler is instlled to ips GusrGlolD nd we re using preefhGiQVT s host yD this


# This is pretty generic for OSes with *nix filesystem layout -Fu/usr/local/lib/fpc/$FPCVERSION/units/$FPCtarget/* #....or suitable for crosscompiling. Note that the /cross/ dir is not necessary # and only added as example. #ifdef FPC_CROSSCOMPILING # OS not default -> CROSS -Fu/usr/local/lib/fpc/$FPCversion/cross/$fpctarget/units/* #else #ifndef cpu86 # Processor not default -> CROSS -Fu/usr/local/lib/fpc/$FPCversion/cross/$fpctarget/units/* #else -Fu/usr/local/lib/fpc/$FPCVERSION/units/$FPCtarget/* #endif #endif

inQP nd hos instlled in XfpPFRFH

-Fuc:\fpc\2.4.0\units\$FPCtarget\* # or suitable for crosscompiling # OS not default -> CROSS -Fuc:\fpc\2.4.0\units\$fpctarget\* # win32 binutils are in the path #ifndef win32 # set path to crossutils. Assuming in one dir. -FDc:\fpc\2.4.0\bin\cross # this is not 100% safe. GNU and FPC target naming differ -XP$FPCTARGET#endif

ueep in mind tht extr pths @eFgF for own ustom pkgesA n e ddedF here is lso no reson not to use 6pgiE syx in the winQP seF st is just n exmpleF

1.6.2 Binutils path -FD

he prolems with inutils IF e only hve to set Eph if we set up for rossompilingF iither when ross ompiling to di'erent proessor or di'erent yF o we hve to determine defult y nd g somehowF




PF nder nixD there re usully spei( dirs for rossutilsD ut the ext ple nd nme di'ers with versionF inQP doesn9t hve something like tht t llF por winQP s propose n exmple lyout s desried oveF QF pg nd qx pltform nming di'er

Unix X es n exmple s tke preefh on n ordinry gF he lotion elow @GusrGlolGproessorEopertingsystemA is

where the inutils se distriution instlls ross ompiled utils y defult under preefhF rowever sometimes how pg nmes n y n di'er from how the inutils nme itF sn tht se you hve to e more veroseD whih s hve done for the se of rossompiling to windows8 F o our on(gurtion (le eomesX

#ifdef FPC_CROSSCOMPILING # other binutils if OS differs #ifdef win32 # win32 is an exception # FPC OS name : win32 Binutils OS name : mingw32 # FPC processor: i386 Binutils processor: i686 -FD/usr/local/i686-unknown-mingw32/bin #else # we hope that the fpc and binutils name match:-) -FD/usr/local/$FPCTARGET/cross #endif #else #ifndef cpu86 # other binutils if processor differs -FD/usr/local/$FPCTARGET/cross #endif #endif

inQP nd hosX retty muh the smeF rowever ontrry to nix s hven9t relly tested thisF egin s ssume pg to e instlled in XfpPFRFH Frowever the inutils re in dXinutils nd deeper nd nmed like under BfhX

#ifndef win32 # other binutils if OS differs -FDd:\binutils\$FPCTARGET\bin #else #ifndef cpu86 # other binutils if processor differs -FDd:\binutils\$FPCTARGET\bin #endif #endif

Using makeles

hen using mke(lesD one n set the Eph prmeter y pssing gyfsxhsa`pthb to mkeF his ensures tht the prmeter is pssed orretly from mke(le to mke(le @in nested diretory hierrhiesAF

1.6.3 Binutils prex, all binutils in one directory

e somewht newer ddition is the E prmeter whih sets pre(x for ll inutilsD so if you dd -XPbla-die-bla- to the fp ommndline then ll lls to s nd ld will e pre(xed with bla-die-bla- F he min reson for this is tht y defultD ross ompiled inutils re nmed `pubE`trgetbE`(lenmebDnd not just `(lenmebF hen doing ross snpshot @or yleAD setting the mke vrile fsxsvips will mke sure tht E is pssed on the right momentsF sf we ssume the inutils for ross ompiling re ll in one diretoryD the ove piee of ode eomesX

8 Lazy people simply would make a symlink from the fpc naming to the binutils naming. However being lazy is not allowed for tutorial writers.




#ifdef FPC_CROSSCOMPILING # other binutils directory if processor or target OS differs -FD/usr/local/cross/bin # set prefix to select the right ones from that directory: -XP$FPCTARGET#endif

his ssumes tht inutils nming of pltforms is the sme s pg9sF st isn9t howeverD there re few exeptionsX

Usual name (32-bit windows) i386 or x86 Sunos/Solaris PowerPC

FPC name win32 i386 sunos powerpc

Binutils name cygwin or mingw32 i386,i486,i586,i686 solaris powerpc

ppc<x> name (OS not CPU) 386 ppc

o for these trgets we would hve to mke exeptionsF @see eFgF sript ode in the fpuildGinstll repositoryD eFgF smplefg nd instllFshA

1.6.4 Library path -Fl

he lirry pth is where stti lirries @nd shred lis under unixA n e foundF hile this is very importnt for the nix pltformD the pg ompiler on windows nd dos lso n link to qgg @nd vrintsA lirriesD so pg must e le to (nd themF he lirry pth is of ourse trget nd proessor dependntF yne ouldn9t link preefhGxVT lirries to vinuxGowerp inryF o essentilly we re doing the sme trik s with the unit pthF sf the defult trgets re usedD on unix it is set to the defult diretoriesD otherwise it is set to some hierrhy where the user is supposed to instll his ross lirriesF

Unix X es n exmple s tke preefh on n ordinry gD euse most fhsD speilly on ordinry gs hve ompility vinux lirryset to run proprietry vinux progrms for whih no preefh version existsF his mode is lled the vinuxtor9 F he vinuxtor lis re usully i sed nd in GomptGlinuxG nd deeperF xetfh hs huge set of suh emultionsF enywyD here is the snippetD it ssumes the user to uild hierrhy of ross lis under GusrGlolGrosslis

#undef specialoscpu #ifndef FPC_CROSSCOMPILING #define specialoscpu # DEFAULT # libraries outside base are installed with PREFIX=/usr/local -Fl/usr/local/lib # however X stuff is installed with PREFIX=/usr/X11R6 -Fl/usr/X11R6/lib #endif #ifdef linux #ifdef cpu86 # CROSS, BUT SPECIAL, FreeBSD optionally has a Linux userland on board # for the linuxator. Usually it is some SUSE version. #define specialoscpu -Fl/compat/linux/lib -Fl/compat/linux/usr/lib -Fl/compat/linux/usr/X11R6/lib #endif #endif # libraries not existing on target by default. Reverting # to special cross directories #ifndef specialoscpu -Fl/usr/local/crosslibs/$FPCTARGET/lib -Fl/usr/local/crosslibs/$FPCTARGET/usr/lib -Fl/usr/local/crosslibs/$FPCTARGET/usr/local/lib -Fl/usr/local/crosslibs/$FPCTARGET/usr/X11R6/lib #endif

9 The

linuxator is strictly speaking an emulator. However the emulation layer is so thin (a few 10's of kbs) that there is no noticable performance loss. Since all libs are in memory twice (Linux+FreeBSD) it eats some extra memory though.




Win32 and DosX ixtly the sme ideF ome diretory with the hierrhy @dXrosslis for nowAD ut none s defultF

sf you hve suitle g equivlent @djgpp for dosD ygwin nd mingw for winQPAD you ould dd it to the spe for the defultF

#ifndef win32 # other binutils if OS differs -Fld:\crosslibs\$FPCTARGET\lib -Fld:\crosslibs\$FPCTARGET\usr\lib #etc #else #ifndef cpu86 # other binutils if processor differs # maybe somebody does a port for win32/Sparc or so. -Fld:\crosslibs\$FPCTARGET\lib -Fld:\crosslibs\$FPCTARGET\usr\lib #else # DEFAULT #endif #endif

1.6.5 Verbosity options

ellD there is not muh to tellF he defult is okD nd s never hnge it @s wrote it down elow for ompletenessAD for more info see the mnulF xote tht ny verosity setting in fpFfg n e overriden on the ommndline @eFgF for deuggingD typilly uses Ev on the mdline A

# write FPC logo lines. -l # Display Info, Warnings, Notes and Hints -viwn

1.7 The order to compile parts of FPC

kges is it of n miguous term when used in the pg projet10 F ometimes pkges refers exlusively to the seprte unit sets in the pkgesG diretory of the soure treeD sometimes it lso inludes the other seprtely ompille prts of the projet @like ompilerD rtlD flD ideD fvisionD lzrusD instller nd utilsAF sn this prgrph it9s the ltter oneF he diretory struture of the pkges hs een reorgnized strting with pg PFPFRF 11 F wost importntlyD the fpmke system now (gures out its own dependniesD so ll pkges @inluding pgv nd pA ould move to GfpGpkgesF his gret simpli(es uilding nd mintenne of the pkgesF he units of the pgv were lso regrouped into multiple pkgesF yf ourse there iss till ertin sequene one should follow when uilding pgD whih is hrdoded in the top wke(leF his euse some pkges need other pkges nd need to e uild (rstF he usul order isX IF ootstrp the ompiler @mke yleA Qx ompilerD Qx rtl PF euild the v smrtlinking QF fuild the pkges diretory inluding the pgv nd p pkgesF RF fuild the textmode shiF SF utilsG diretory inluding fpmke in utilsGfpm vzrus n e uilt fter the min uild @with or without shiAF rowever instll the min uild not uilt t ll in stndrd uild of the fp repositoryX IF demoes nd exmple diretories of pkges PF the regression testing suite @testsGA ixmples re often ompille y desending into the pkge diretory nd exeuting mke exmplesF

10 See also 11 This reorganization was made possible with improvements in the fpcmake system. However

be replaced with the fpmake/fppkg system that is already included for testing in 2.2.4+ in time, the fpcmake system will disappear, and


ome diretories re





Some interesting build scripts

ome of these priniples re used in some of the sripts used to uild relesesD test rossompiling etF

· fpGinstlllGinstllFsh is the instller sript for unixF xiely demonstrtes pltform nme @qxEbpgA onversion · fpGinstllGrossGuildrossinutils is sript to mssEuild ross inutils · fpGinstllGrossGuildrosssnpshot is n ttempt t uilding ross snpshotsF orks in prinipleD however the shred linking of mkxmlrp nd the textmode shi re troulesomeF · fpGinstllGmkepk is relese uilding sriptF st requires the trget nme @iQVTElinuxD iQVTEwinQP etA s prmeter

1.8 Smart linking

mrtlinking @ldGg doumenttion lls it ded ode elimintion A essentilly mens voiding linking of unused ode into the (nl inryF he prolem is tht the qx linker n do ded ode elimintionD ut usully @redX with gA only does this on ompiltion unit levelF sn other wordsD it still will link in the entire unit when only one (le is usedF xewer inutils use n do dedode elimintion sed on setionsD however the prolem with this is tht it ups the version requirements on inutilsD whih is prolem speilly for operting systems s lssi wyD older w y versionsD yGP etF he new form is lso not entirely stle yetF sing the old style smrtlinkingD pg irumvents this y generting Fo for eh symol in unitF o eh proedureD methodD vrile or typed onstnt gets its own Fo (leF ine this n e thousnds of Fo (les in unit @unit indows hs out PHHHHEQHHHHADnd the Fo (les re dded to n F rhive using qx eF ell together this is pretty omplited proessX IF unit is ompiled y fp to lot of ssemler soure @FsA (lesD PF tht get ssemled y lot of lls to e to generte lot of Fo (les QF tht re red gin y e to form one F (le FFFF whih is why smrtinking performne relly ene(ts from the inwriter @see ssAD whih uses pg to write the F diretly without thousnds of lls to eF fesides tightening odeD smrtlinking lso solves prolem when unit interfes to shred lirry @unix Fso or winQP FdllA nd ertin unused lls ren9t villeF en exmple would e if unit windows ontins lls dded in lter indows versions tht you don9t use for your progrm nd you work onGfor indows WVF when not smrtlinkingD the whole of unit windows would e linked inD nd the linker wouldn9t e le to (nd the lls from lter indows versions in the indows WV kernelQPFdll nd userQPFdllF fe reful when trying to guess the svings of smrtlinkingF yften people forget unit initilistion @oth of the unit in questionD nd the unit it iA nd ll the lssesD proedures nd funtions the initilistion uses re lwys linked inD nd units @even if they re unusedA re lwys initilisedD sine the ompiler n9t see tht the e'et of the initilistion on the working of the progrm is zeroF

A word of cautionX sn gD n Fo (le usully orresponds to one F or Fpp (leD so one F ontins `nb Fo9s tht orrespond

to `nb F9sF rowever under pgD when smrtlinking per unit @Fpp D FpsA the (le tht is ultimtely written is n F whih ontins lot of Fo9sF o n pg F orresponds to one unit onlyF 12 en Fo however is the sme unit s the F without smrtlinkingF e known prolem with old style smrtlinking is its memory usageF vd doesn9t mnge lot @IHHHHHCA of smll ojet (les @FoA e0ientlyD nd memory requirements inrese enormouslyF mrtlinking fully stti vzrus wsn9t possile euse it omed out on my y9 SIP wf memory limit for ordinry proessesD rough estimte of the memory needed ws IFS qfF e rule of thum for memory usge in extreme ses is etween SH nd IHH times the size of the (nl inryF st seems tht ld n do dedode elimintion nowdysD however the ompiler needs to e dopted for thisD nd there is lso some movement in hving n own internl linkerF he dvntges of this system is less memory use y vhD nd the ft tht F (les will dispper @in the new methodD the smrtlink dt is dded to the Fo (lesAF rowever no mtter how fst this eomes usleD old style smrtlinking is still needed for quite whileD for yes with inutils tht re not reent or ompleteF

12 At

least for now, developments in library generation might change this in time, but not before 2.4

Chapter 2

Standard building

he strt of the pg uildproess is ootstrpping ompilerF footstrpping the ompiler is the strt of every uild proessD euse hnges in the ompiler soure must e tived efore one n strt ompiling the lirriesF sully the ootstrp is only minor prt in n utomised snpshot or full uildF rowever some knowledge out the proess n e hndy for rossompiling purposes nd development on pg itselfF he other two typil uild proesses re uilding nd instlling snpshotD nd uilding releseF omewht less stremlined re uilding the shi nd doumenttionF fuilding vzrus on the other hnd is firly esyF por the verge userD uilding snpshot ndGor lzrus re the interesting prtsF

2.1 Cleaning

2.1.1 Make clean

sn nerly ny ple in the pg tree mke len will try to remove ompiler generted (les of snpshot or yle uildingF e mke distlen in the upper level is even it more thoroughD nd lso removes (les generted while uilding releses @zips etA xote tht the mke (les usully delete wht they generteF o if eFgF the genertion of ertin (les depends on ertin mke(le de(nes ndGor ompiler versionD mke sure tht the right ompiler nd de(nes re pssed to mkeF e good hek to see if the repository is lenD is to hek stndrd output nd Eerror of the svn updte proessF sf you see errorsD then revert the x hekoutF

2.1.2 make distclean

mke distlen is the more rigorous wy of leningF sf you experiening uild prolemsD lwys do this (rstF sf you hve snpshot sriptsD dd mke distlen in the top level dir s (rst lineF his eme lot more importnt in IFWFSD sine reent IFWFS9s store their units in seprte unitsG6fptrget hierrhyF glening efore x updte n speed up the x updte proess signi(ntlyD speilly on yes tht hve reltively slow diretory serhing @like windows nd netsdA

2.1.3 Cleaning of crosscompile builds

xote tht the len trgets of the mke(le only len for urrent 6pgeqiF o rigorously len everythingD kill ll FoD F nd Fppu (lesD nd then x updte ginD to reover the few Fo (les in the pg tree @mostly for testsuite tests relting to g linkingA

2.2 Bootstrapping: make cycle

mke yle is ootstrp of the ompilerD nd uilds the rtl nd ompiler t lest three timesF






o if you hve prolem in ny spet of uilding the pg soure tree nd you re not using the most reent relese ompilerD please try rst with the most reent relese ompilerF st is possile to speify the nme of the strting ompiler @see elowAD so sving the relese ompiler under some nme @s9ll use ppcrel from now on in this tutorilA is dvisedF

The only starting compiler that is guaranteed to work is the most recent release compiler for that series .

he mke yle proess ompiles v nd ompiler three timesX

RTL 1st ine the we strt with only the strting ompilerD new v must e uilt (rst efore we n link progrmF Compiler 1st e new ompiler is retedF rowever the new ompiler is still ompiled y the relese ompilerD so newer

optimistion nd hnges ren9t tive yet in this inryF por tht resonD oth the v nd the ompiler hve to e reuiltF

RTL 2nd o we reuild the v ndFFF Compiler 2nd the ompilerF rowever to mke sure the ompiler is deterministi @ompiles the sme progrm to the sme

exeutle eh time it is runAD the ompiler nd v re ompiledFFFFFF

RTL 3rd ginFFFF Compiler 3rd nd fter uilding the ompiler for the third time the Pnd nd Qrd ompiler re ompred to see if there

they re the smeF sf notD everything is ompiled ginF @for some rre seundry e'etsA his entire proess is run y simply type mke yle in the ompiler diretoryF sf you wnt to use n lterntive ompilerD speify it with afullGpthGtoG`ompilerbF hen using the a optionD use ompiler in the er or n solute pthD not reltive pthF sing reltive pth usully won9t work sine during the proessD the mke utility hnges diretoriesF sf you try to ootstrp without full instltionD you sometimes need to speify pgafullGpthGtoG`ompilerb edditionl ompiler options n e dded using ya`the optionsbD often used options re turning on deugginginforE mtion with lineinformtion @EglAD nd inrese the verosity level @EvAF rowever sine Ev produes lot of outputD it is wise to pipe it to (leF ome exmplesX


# go to the right directory on unix cd /fpc/fpc/compiler # go to the right directory on windows cd /d d:\repo\fpc\compiler # do an ordinary make cycle: make cycle # Use a starting compiler in the OS search PATH make cycle PP=ppcrel # use a starting compiler with (unix) absolute path # and enable line info and debugging make cycle PP=/fpc/startcompilers/ppcrel OPT=--gl # Use LOTS of verbosity in the process and redirect it to file. make cycle OPT=-va >cycle.log

2.3 Compiling a snapshot; make all or make build

wke ll is the most importnt uild proessD it essentilly uilds @ut not instllsA the generl purpose prts of the stndrd x tree @see IFUAD exept sidewys relted stu' like doumenttionD exmples nd testsF snstlling is one dditionl mke(le ommndF sn its simplest formD uild snpshot is heking out x @see IFQFQAD nd hnging to the top fpG diretory nd ll mke llF snstlling to the defult lotion is done y exeuting mke instllF

cd /fpc/fpc make all # lots of building. Think 3 minutes on a XP2000+, 10-15 minutes on a 500MHz machine. make install

1 E.g. 2 The

For the 1.9.x series, even though 1.9.6 and 1.9.8 will probably work, the only guaranteed starting compiler is 1.0.10! lines starting with # in the example below are comments. Don't enter them




# Installs the snapshot to the default location # (/usr/local/lib/fpc/$FPCVERSION and deeper probably) # # or on Windows: cd /d d:\repo\fpc make all make install COPYTREE=echo # (default is c:\pp\ and deeper)

sf you trk pg x very loselyD this is proly wht you9ll do quite oftenF rowever in some speil sesD more prmeters re neededF issentilly this is uilding snpshotF sf you trik mke instll into instlling in di'erent diretoryD the ontents of tht diretory re essentilly the snpshotF

he simplest vrition is di'erent strting ompilerF his n e done y simply entering a`ompilerb or aGfullGpthGtoG` fter the mke ll promptX

cd /fpc/devel/fpc make all PP=/my/starting/compiler # lots of building. Think 3 minutes on a XP2000+, 10-15 minutes on a 500MHz machine. make install # Installs the snapshot to the default location # (/usr/local/lib/fpc/$FPCVERSION and typically) # # or on Windows: cd /d c:\repo\fpc make all PP=ppcrel make install COPYTREE=echo # (default is c:\pp\ and deeper)

e stndrd onfusing detil when instlling snpshot is tht the trget diretory @eFgF GusrGlolGliGfpGPFRFHA depends on the version numerF sf you would follow the ove sequeneD nd the generted ompiler @sy version PFSFIA is not equl to the strting ompiler @sy version PFRFHAD then mke instll will instll into the wrong diretoryF he sme goes for windows @ XfpPFRFH FFF A his n e solved y setting the ompiler tht is generted in the mke ll step s strting ompiler to the mke instll stepF his will ensure tht the mke instll sequene gets the orret versioning infoF ine we n9t use reltive pthsD this must e full pthX

cd /fpc/devel/fpc make all PP=/my/starting/compiler/path/ppc386-someversion # # Now install using the NEW compiler for the correct version info: make install PP=/fpc/devel/fpc/compiler/ppc386 # # Installs the snapshot to the default location # (/usr/local/lib/fpc/$FPCVERSION and deeper probably) # # and for windows: cd /d c:\repo\fpc make all PP=c:\fpc\startingcompilers\ppc386-someversion # # and installing use the NEW compiler make install PP=c:\repository\fpc\compiler\ppc386

enother very ommon vrition is instlling into di'erent se diretory @6ipsAD this is done y setting vrile sxevvips to the desired diretoryX

cd /fpc/devel/fpc make all PP=/my/starting/compiler # # Stack installs packages that don't come with the package system in /usr/exp #




make install INSTALL_PREFIX=/usr/exp # # Or on Windows: # My FPC directory is on d:\pp # cd /d c:\repo\fpc make all PP=ppcrel make install INSTALL_PREFIX=d:\pp # # Or lets make a snapshot to upload to some site on some unix: # # cd /fpc/devel/fpc make all PP=/my/starting/compiler # # Make a scratch directory in /tmp # mkdir /tmp/fpc make install INSTALL_PREFIX=/tmp/fpc # # archive # cd /tmp/fpc tar cvzf /tmp/newsnapshot.tar.gz * # remove temp dir. # cd /tmp rm -rf fpc #

pinllyD dding prmeters to every ompiler ommndline is interesting tooF his n e done y dding ya9`the prmetersb9 to the ommndlineF yften used prmeters for this purpose re Ed`xxxb to de(ne vlue whih n e tested using eFgF {6sphip xxx} in the soureD nd Egl to inlude deug infoF Ev is lso often used to deug the snpshot uilding proessF sf you dd EvD pipe the output to (leD or the uilding will slow down due to the mssive mounts of output written to sreenF

Adding -gl when you are developping with FPC is a good habit, since it allows you to single step all of the FPC runtime libraries in GDB (roughly equivalent to the use debug .DCUs options in Delphi). The generated snapshot gets somewhat larger though.

cd /fpc/devel/fpc make all OPT='-gl' # lots of building. make install # Installs the snapshot to the default location # (/usr/local/lib/fpc/$FPCVERSION and deeper probably) # # or on Windows: cd c:\cvs\devel\fpc make all OPT='-va' &> d:\buildlog.log make install # # multiple parameters are passed like this: # # make all OPT=-gl -va

A word of caution: hen s uild snpshots for home useD s simply mke instll them over the old snpshotD t lest if

mke ll sueedsF sf you enounter errors during uild or instllD or even fter instll @like the notorious n9t (nd unit xxxD while it is thereAD try to remove the unitsG diretory in the pg homedirD nd reEexeute the mke instll used to instll itF his should resolve the prolemF sf not hek s muh settings s you n hek nd red hpter R




he prolem is usully used y units hnging diretories @or pkgesA in gF ine the usul proedure doesn9t len the unitsG diretoryD fter instlltion two instnes of tht unit existD whih ould led to on)itsF e good hit is to kup soure tree efore updting nd the pg instll diretory @ompiler C unitsG diretoryA efore instlling new snpshotF his just to mke sure you will hve working ompiler in se something goes wrong during uilding or instllingF his n esily e utomted using sript tht updtes E kups E uilds E instllsF ine s9m not tht fond of unix sriptingD s9ll leve tht s n exerise to the rederF

2.4 Current build procedure on win32

he sitution on winQP with urrent x is it omplexD so s deided to dedite seprte prgrph listing the proedureD omining ll the ove dtF he prolem on winQP is tht x mrkes its own on(g (les s redEonlyD whih leds to prolems with instlling exmplesD nd the p utils provided with PFH hve some unix pth `Eb windows pths troulesF wost notleD they don9t see xxxyyy s windows pthD ut they do see dXxxxyyy s windows pthF here re two solutionsD the quik one simply omits the exmplesD the slow one doesF fest is to do the slow one one in while to hve up to dte exmplesD nd for the rest use the quik solutionF he slow solution lso (xes some prolems with older versions of the mingw utilsF fesides the redEonly svn dirs prolemD there is lso prolem with istD nd some mingw inries hve prolems with the sing of er sttementsF

2.4.1 The slow solution: SVN exporting

fefore we eginD lets de(ne the diretories @my defultsA

· dXpp is the diretory where s urrently hve instlled pgD nd dXppiniQVTEwinQPis the pg dir in my 7er7F · dXfpx is the diretory where s heked out the x repositoryF s don9t uild in itF · dXfp is the diretory where s export the x repository tooF · dXfprel is the diretory ontining pg PFRFH for ootstrpping purposesF

enother importnt issueX MAKE ABSOLUTELY SURE THAT THE CYGWIN DIRECTORY IS NOT IN THE PATH!!!!!! he reson for this is tht some mingw utils strt using ygwin shFexe when foundD nd tht in turn swps

some utils from the pg delivered mingw tools to ygwin onesF henD to mke nd instll snpshotD we updte the xX

cd /d d:\ svn up fpcSVN

hen we export itX

# Cleaning improves performance, cd fpc make clean cd .. svn export --force fpcSVN fpc

xowD the uilding n strtX

cd fpc make clean all OPT='-gl' FPC=d:\fpcrel\bin\i386-win32\ppc386.exe

sf this is suessful we instllX @ll on one lineA

make install OPT='-gl' INSTALL_PREFIX=d:\pp11 UPXPROG=echo FPC=d:\fpcrel\bin\i386-win32\ppc386




ome things to notieX

· MAKE ABSOLUTELY SURE THAT THE CYGWIN DIRECTORY IS NOT IN THE PATH!!!!!! wingwGmsys n lso give prolemsD ut more rrely @see PFTFR A · he options @ya9Egl9A re pssed oth to the mke nd instll linesF his euse sometimes due to unit dependny glithes nd utilsD minor mount of ode is @reA uilt during instllF his goes for ALL uild options tht re not instlling relted · yqaeho voids ing of the resulting inriesD so tht the pg inries n e deuggedF sf you wnt s smll pg ins s possileD leve it wyD nd dd weaI to oth mke linesF xote tht ing wstes memory tht is more expensive thn diskF 3 · e dd !fore to the x export line to fore overwriting of the previous repositoryF sf uilding goes wrongD dy fter dyD try ersing the export diretory @dXfpA efore exportingF

2.4.2 The Quick solution: COPYTREE

he quik solution exploits tht the reursive opying is done using ommnd tht is only used for opying the exmplesF end updting the @instlledA exmples is not tht importnt when dily updtingD one typilly wnts to void the slow x export stepF he mke(le mro tht is used internlly in the mke(le for opying (les reursively is gyiiD we then use the sme trik s erlier to disle funtionlity y speifying the eho ommndX

make install COPYTREE=echo

2.4.3 VISTA specic topics: install.exe

ist is quite dronin in some thingsD nd there will e lot more prolems in the futureD speilly for relese engineeringF @think out temporry (les in the rootD not llowing writes in the ppdir etAF rowever there is one little goth tht lso 'ets norml uildingF his goth is tully the result of n ttempt to minimlize troule for existing instllers y utomtilly popping up eg @otherwise you would hve to do run s dmininstrtor whih is not end user friendlyAD ut it ws implemented hlfEssedF eny ii with instllD setup or updte in its nme will pop up egD utFFFF UAC prompts fail for console apps F4 he pg uild system uses qx instll @s ginstllFexeA to instll (les with proper permissionsD nd tht fils due to egF he de(nition of the prolem lso implies the solutionX IF gopy the @gAinstllFexe inry to new nme without the keywordsD s use myinstFexe PF ss qsxevvamyinstFexe to the mke ommndline X

make install GINSTALL=myinst.exe

P.s. his istGindows U prolem is (xed in PFRFH y dding mnifestF

2.4.4 Putting it all together

rere is the th(le tht s use on indowsX @the pg soure tree is in dXrepofpA

@echo on set BASEDRV=c: set SRCDIR=%BASEDRV%\repo\fpc set PPCNAME=ppc386 set FPCSTART=c:\fpc\2.4.0\bin\i386-win32\%PPCNAME%


3 4

search for keyword




set LOGDIR=%BASEDRV%\repo set INSTALLDIR=%BASEDRV%\pp11 REM some random opts. set OPTS=-gl -dSAX_HTML_DEBUG -dUSE_MINGW_GDB set COMMONOPTS=UPXPROG=echo COPYTREE=echo OPT="%OPTS%" GINSTALL=myinst.exe rem === invariant part === cd /d %SRCDIR% REM the building make clean all %COMMONOPTS% FPC=%FPCSTART% 1> %LOGDIR%\buildlog.txt 2>&1 REM separate install step for crossversion purposes (and under Unix sudo) (on one line) make install %COMMONOPTS% INSTALL_PREFIX=%INSTALLDIR% FPC=%SRCDIR%/compiler/%PPCNAME% 1> %LOGDIR%\installlog.txt 2>&1

etullyD s hve severl suh (lesD nother one for TREitD more dvned one for rossompiling to wine etF he winTR is opy tht di'ers only in xVTTREwinTR in the pth nd ppxTR insted of ppQVTF xote tht ll vriles re in the upper prt of the th(leD this mkes it esier to port it to systems nd just dpt the pthsF rving severl omputers with slightly di'erent pth nd drive lyouts ws the motivtion to write themF nfortuntelyD pure th(le is too limited to invest too muh time in itF

2.5 Lazarus

fuilding lzrus is tully pretty muh the sme s uilding snpshotD exept tht you hve to enter diretory lzrusG insted of fpGF

cd /repo/ svn update lazarus cd lazarus make all # you might want to check if the return value of make install is zero before installing. make install INSTALL_PREFIX=/usr/local #

et the moment of writing this there ws some prolem with instlling lzrusF st seems tht the mke(les ren9t entirely up to dteF s usully move the lzrus repository to GusrGlolGlzrusD nd set some symlinks to exeute the right inryFhis isn9t tht dD sine you need to sve the lzrus soure for vzrus9 opertion nywyF

2.6 Typical problems and tips

2.6.1 cannot nd -l<xxxx>

ine vzrus need to link to shred lirriesD uilding lzrus tests n spet of the pg on(gurtion tht hsn9t een tested y the prts oveF e typil error is

Linking ./lazarus /usr/libexec/elf/ld: cannot find -lglib12 lazarus.pp(334) Error: Error while linking Closing script ./

his mens tht the linkerD when uilding the (nl inryD ouldn9t (nd ligliIPF or ligliIPFsoF his is o0illy not n pg errorD sine gli is prt of quD whih elongs to the operting systemF So maybe the gtk (or a corresponding gtk-devel package) is simply not installed. here re four other possiilitiesX IF hile the pkge is instlledD the pkge mnger didn9t rete symlink tht refers the ligliFIPFsoFx to ligliIPFsoF e quik d GusrGlolGliY ln Es ligliIPFsoFP ligliIPFso would hve solved tht in this seF




PF @the tul prolem in the se oveA he diretory with the orret (le isn9t serhed for lirries y pgD euse you didn9t speify the diretory in fpFfg using EplF e mere dding of EplGusrGlolGli to GetGfpFfg solved the prolem in this seF QF ou hve {6vsxuvsf xx} in the soure somewhereD or El`xxb prmeter in some sript or mke(le tht fores pg to try to link the lirryD ut it isn9t neessry nymoreD grep is your est friend in suh sesF RF our distriution for some reson nmes it lirries di'erentlyF eginD symlinking the serhed nme to the rel nme is the solutionF

2.6.2 CONTNRS or other FCL-BASE units not found

sf the ompiler n9t (nd ontnrsD this points to prolem with the Epu pthsF st proly mens Epu ws wrongD ut the mke(les mnged to utoEdd the vD nd the ontnrs @nd other pgvEfeiA [email protected] re then the (rst unit tht n9t e foundF st n lso point to duplite Fppu (les or mixing of pg versionsF

2.6.3 Piping stderr and stdout to the same le.

iping stderr nd stdout of the weui proess to the sme (le is useful for deugging the ext sequene on eventsF his is esily done on nix using b8F nder indows this is it more omplexD ut n still e doneX

make install 1> filename.txt 2>&1

his line pipes the output of instll9s stdout to (lenmeFtxt using IbD ut redirets stderr @ PbA to stdout @8IA (rstF

2.6.4 (Windows) building and install fails with invisible errors

s suddenly hd prolems when doing mke len ll instll in one goF purther investigtion of the output showed ignored errors in mke exit linesX

make: [fpc_clean] Error 1 (ignored)

however this would led to n ll stop fter the



make: *** [fpcmade.i386-win32] Error 1

his turned out to e mingw relted prolemD (le shFexe ws left in the projet soureF enother solution would e to never use these ommnds in one goD ut sript them s seprte onesF s experimented with shFexe euse when using mke Ej P it produes wrning tht Ej funtionlity is disled if shFexe is not foundF s ssume the mke(le must e dpted to ignore ignored errors insted of ll errors somewhereF

Note: hespite the usge of mingw toolsD it is not reommended to hve the mingw diretories in the pthF ome of the

mingw tools @most notly mkeFexe when it detets shFexeA pprntly hnge ehviour upon detetion F

Chapter 3


@you need to hve red the previous hpters tooD sine they lredy ontin lot of rossompiling relted info tht s won9t duplite hereA

3.1 Basic crosscompiling of a snapshot

vet9s hve two exmplesD freesd to winQPEmingw rossompileD nd preefh to ewhTR linux oneF essume we hve the following items set up orretlyX IF gross inutils hve een ompiledD nd re instlled with 6ipsa~GrossF he orret pre(x hs een identi(ed @proly something like iTVTEmingQPEnd xVTETRElinuxEin our exmpleA PF he pg soures re in fpG QF pg ws instlled in GusrGlolGliGfpG6pgisyx nd deeper hen we exeuteX

cd ~/fpc gmake distclean # next all on one line gmake all install OS_TARGET=win32 CROSSBINDIR=~/cross/bin BINUTILSPREFIX=i686-ming32INSTALL_PREFIX=/usr/local

to uild the (rst snpshot @note tht geqi isn9t setD nd tht yeqi uses the pg pltform nming @winQPAD while fsxsvips uses the qx one @sine it is for the inutilsAF elso note tht the fsxsvips ends with dshF his is on purposeF imilrlyD for xVTTRElinux the line eomes

cd ~/fpc gmake distclean # next all on one line gmake all install CPU_TARGET=x86_64 OS_TARGET=linux CROSSBINDIR=~/cross/bin BINUTILSPREFIX=x86_64-linuxINSTALL_PREFIX=/usr/local

3.2 Crosscompiling without cross-assembler.

ometimes one doesn9t wnt to relly rossompileD just test if something like the v ompiles under trget `xbF sf this trget is on the sme rhitetureD one n try to use

gmake fpc_units OPT='-s'

he Es skips lling the ssemlerGlinker nd the use to the fpunits mke(leEtrget skips the ssemling of the v9s lodE erodeF enother suh trik is to pss eaeho or eageho to gmkeF xote tht in former @PFRFxGRFxA timesD rossompiling etween vinuxGxVT nd preefhGxVT ws possile without ross ssemlers nd linkersF his to my knowledge hsn9t een retested with newer versions of these yesF QH




3.3 Crosscompiling Lazarus

3.3.1 Crosscompiling Lazarus from windows to Linux

pirstD we need set of ross inutilsF por windowsEbother pltformsD these re on pg p ftp://freepascal.stack. nl/pub/fpc/contrib/cross/mingw/ F hownlod nd extrt them to the sme diretory s your ppQVT ompiler inryF erify their instll y running iQVTElinuxEld on the ommnd promptF eondD we need pg nd vzrus soure treesF xote tht the pg tree must e n exported treeD sine we re going to use mke instllD nd mke instll trips over x diretoriesF o fter hekout svn export the soures @see x prgrph for exmplesA xow we re going to uild nd instll pg for rossompiling @ssume pg is instlled in XfpPFRFHA

make clean make OS_TARGET=linux all make OS_TARGET=linux install INSTALL_PREFIX=c:\fpc\2.4.0

vzrus is di'erent mtter howeverD sine it uses shred lirriesF o s opied vinux lirries from my trget system nd put them in dXlinuxliF hih lirries s opied is desried in the seprte prgrph elowF fefore we relly strtD we hve to workround di'erent prolemF he ompiler still hs detetion for preEgli systems whih is esy to trip if you mke mistkeF o go into iQVTElinux rtl diretory @proly XfpPFHFRunitsiQVTElinuxrtlAnd opy prtPIFo over prtHFo so tht oth (les re in f in ft prtPIFoF xow we strt with the vzrus uildingD enter the lzrus diretory nd give

rem on one line: make OS_TARGET=linux all OPT=-gl -Fld:\fpc\linuxlib -Xr/usr/lib -FL/usr/lib/ -XLAc=c,dl,gmodule

he Egl is out dding deuginfo @good to hve trek if something goes wrongAD the pl rgument spei(es the diretory to look for the linux lirriesD nd the Er rgument mkes the linker rete the inry so tht it serhes in GusrGli for lirriesF he Epv rgument is the nme of the dynmi linkerD nd the Eve line dds two lirries @dl nd gmoduleA if li is inludedF1 his should uild vinux lzrusF rowever most likelyD it will om out missing some lirryF he solutions to tht re editing the linker (le linkFres nd rerunning ppsFsh ginD or dpting the dXfplinuxli dir with more or renmed lirriesF he link lis options @s Eve oveA re relly hndy to void repeted editingF

3.3.2 Preparing a directory with Linux libraries

por the rossompile s opied unh of (les of the trget linux distriution @nd yesD these re possily distriution nd version dependnt3AF ome of these re lso needed for the textmode shiF sf lirry (les were nmed linmeFsoFxFy on linux s renmed them to linmeFso in my indows diretoryD sine the symlinks used for tht on vinux re not esily opiedF wost of these lis re in diretories like GliD GusrGli nd mye GusrGlolGliD GusrGIITGli nd GoptGgnomeGliF lig however is in qgg instll dirD whih n e found y doing g Ev nd then look for line like

Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs

then some of the lis re in GusrGliGgEliGiRVTElinuxGQFQFSG enywyD these re the (les s opied @pgR iirAX crtbegin.o crtbeginS.o crtbeginT.o crtend.o

1 Alternately,

you can add {$linklib dl} and {$linklib gmodule} to the main lazarus sourcele lazarus.pp




crtendS.o crtn.o crti.o libgcc.a

xote tht some diretories re dupliteD with su0x @like ligmoduleEIFPFHAnd notF s need them twie euse some of the other lirries nmes the full nme @so the form li`nmebFsoFxA s n dependny nd we n9t symlink on windowsD so s simply opy itF wking mistkes with renming is not tht dD there will e hnes to (x itF wke sure ll rtB nd (le liFso re ville or generting linkFres will go wrongF sn my se ompiltion for step II will go okD ut the linker will omplin it n9t (nd ligtkFso nd euse on the trget systemD ligtk is gtk PFHD while we wnt gtkIFP for lzrus @`aHFWFPTA whih is nmed ligtkEIFPF s solve this with the so lled linkordering swith EvegtkagtkEIFP nd similrly for gdk nd gliF ee the seprte prgrph out this swith nd its limittions for more infoF

3.4 Interesting compiler and makele options

3.4.1 Skipping built in directories: -Xd

yn nix trgetsD pree sl often utomtilly psses defult lirries like Gli nd GusrGli s inlude diretories to the linkerF his n e prolem when experimenting with rossompiling @nd dul rhitetureA systemsF he prmeter Ed onvines the ompiler to not dd these diretoriesF

3.4.2 Dierence in paths: -Xr<directory>

Er on(gures where the linker should look for lirries when rossompilingF st is trnsltes to the ld !rpthElink prmeterF

3.4.3 -Xt static linking

he Et prmeter tries to link stti s muh s possile y pssing Estti to vhD the linkerF e more (nely grined ontrol over wht lirries re linked sttillyD nd whih ones re linked dynmilly n t this time only e hieved y postediting the linker linkFres (leF gompile with EsD edit linkFresD nd then run ppsFt or Fsh to resume the linking proessF


he wke(le of ompilerG llows to speify ompiler options tht re only used during the tul rossompiling stte using gyya @so not during the initil ootstrp yle tht is not rossEA

3.4.5 LIBDIR

ellows to speify dir to e used for linkingF hon9t know the ext rossEompile onsequenesD speilly if the host y needs li pth to yle @olrisD y A

Chapter 4

Systematic problem solving for the FPC build proces

he questions of people tht red the previous mke yle fq on the pg millists suggested tht the min remining prolem is wht to do if something goes wrongD nd to determine the ext use of the prolemF he usul prolems reX IF rong versions of pg for ertin jo or trying to omine ompiler nd rtl tht don9t elong together @PFQ with the PFPFx vD or trying to generte windows inries with the goQPvP inutilsAF peilly vzrus users often try to uild with too old version nywyD despite the miniml version dvise on the min vzrus siteF PF veftovers of the previous instllGuild frustrte the urrent uild proess @not deleting old diretories etD stle Fppu9s or Fo9sA fe hygieni with respet to old FppuD Fo9sD inries nd uildtrees3 QF ymitting detils tht don9t hve to e done for eh instllD @not (xing the symlink in GusrGlolGinG tht points to the rel instlltionA RF hiretory inlusion prolems @fpFfg inlusiveAF hiretories not eing serhedD or wrong ones inluded SF @windowsA rving ygwin in the erD whih uses ftl mixing of the mingw pg uild tools nd their ygwin ounterprtsF me for other development pkges tht eFgF provide mke TF @unix nd stritly not pg prolemA not instlling opertion system prts nd lirriesF wost notly the Edevel lirries on vinuxD or ports on BfhF UF @development versions onlyA rying to ompile something in diretory tht ontins (les with the sme nme s (les in the pg vsF he ompiler (nd theseD nd thinks they re the v soures tht need reompiltionF elese versions re proteted ginst this @y ompiling the v with ErA houle heking tht you re not hving these spei( ommon prolems is worth the e'ortF

4.1 Determining the problem, increasing the verbosity.

he stndrd systemti serh for the prolem strts with inresing the verosity levelD y pssing ya`swithesb fter mkeF his works when exeuting the ommndline ompiler tooF he ommonly used verosity options re

-vt @show (leserhing informtionD serhed pths etA sf you expet prolems with wht diretories re serhedD you

usully hoose this to keep the mount of logged dt downF

-va @show ll infoF ihsig rs3A

his is the ultimte soure if something goes wrongF he rest is pretty muh guess work nd experieneF he verose ompiler messges re the est soure y frD nd the only one tht llows some systemti prolem serhingF xoody expets the pnish snquisitionD ut try to nswer these questions for yourself when looking t the Ev outputF QQ




· ss the orret ompiler exeutedc · hoes the ompiler version mth with the version tht you9d expet c @ou n lso use ppQVT Ei to hek versionAF his inludes verifying the ompiler dte3 · ere the operting system nd proessor you re ompiling for orretly nmed in the outputc · ss the orret fpFfg @nme nd lotionA loded nd is it preproessed s you thinkc · ere linkerD inlude nd unit diretories orretc · sf the ompiler n9t (nd unitD does line like unit hngedD reompiling exist it higherc sf so see the seprte setion on the reompiling prolemF · sf you re using pg supplied mke(lesD keep in mind tht the fpFfg (le is ignored while uilding yle or lrger trget tht depends on yle @like mke llA edd prmeters to the mke ommndlineD set environment vrilesD or (x on(g (les @eFgF GetGldFsoFonf if it is linker diretory prolemA to (x thisF

sf you do use nested inlude(lesD is the nesting the sme wy s you expetc @ smll (lter progrm n e quite hndy to grph how inlude(les re inluded for omplex (lesA

4.2 Checklist

ome other things esily heked without extr verosity X

· @on unixA ghek the ompiler lotion with whih ppQVTF · ghek the ompiler version nd dte with ppQVT Ei · vook t your pth vrile @ eho 6er on unixD eho 7er7 on dosGwindowsAD nd hek tht the pg diretory for the trget you hoose is (rstF peilly mke sure tht

IF there is no ygwin diretory in the pth t ll @ygwin tools use nonEdos pth lyoutD nd need speil hndlingF pg9s mingw sed versions of mke nd the inutils don9t mix well with ygwin9sA PF @indowsA there is no other diretory of development tool @helphiD tfuilderD gCCA in your pthF hese n ontin own versions of ertin toolsD minly mke tht re not omptileF e mke Ev or mke !version n e useful tooF QF the er vrile is spelled in ll pitl lettersF sf you hve this prolemD orret it in the windows environment dilogue @one of the ts of ystem settingsA e th(le tht n (x this on the go for if you don9t hve permissions to (x it diretly on your work system is set a7er7 set tha set era7e7 set a RF ghek your fpFfgF s knowD you never edit tht oneD nd it hs worked lwysD ut do so nywyF uikly inserted s hve to get this working now3 hnges re esily forgottenF

4.3 Recompiling

e stndrd goth for pg newies is when the ompiler sys it n9t (nd unit xxxD while you re relly IHH7 sure it is thereD nd the diretory with tht (le is serhedF @ note X mke IHH7 sure tht this is the seD efore ontinuingA he most ommon uses reX IF @y fr the most ommonA stle Fo nd Fppu9sD or inorret settings tht inlude wrong diretoriesF @with Fppu nd Fo9sAF un mke distlen PF snluding the min soure trees into your unit serhpthF his is wrongD they should only e in your deuggerGodetools sourepth QF inlude(les nd unit nmes tht re not uniqueF




RF e di'erene in the de(nesF sf soD if you do the sme uild with ya9Ev9 nd serh for eompiling n(nished

Chapter 5

Misc topics

5.1 Programming models.

yver the lst few yersD pg hs strted to support n inresing mount of pltforms tht use the nix spei( v prtsF ome form of reorgnistion ws neessryD nd euse more proessor pltforms re in preprtion for pgD s deided to look into portility issuesD speilly reting TREit len odeD nd lignment nd endinnessF he min resons for reserhing portility for yjet sl were pree sl9s plns to port to TREits pltforms like xVTTRD prTR nd owerg qSF he term TREit len is somewht misledingD euse it is not limited to TREit rhitetures loneD ut generl priniple for writing ode in wy tht it runs on lot of proessorsF he si priniple is to only llow onversion etween ertin integer type nd pointerD nd lwys hve ertin integer type @trsntA tht is gurnteed to sle with pointer sizeF sn gD the stndrd longD or new long long type is used for thisF ine pointers ren9t generlly regrded s signedD it seems logil to pik n unsigned type to e omptile with pointerF igned or unsigned doesn9t muh mtter for ompility with g s long s integers re oded using two9s omplementD nd euse the interfe etween g nd nother lnguge is untypedF he reson to de(ne new type vong vong is simpleD to llow legy ode tht ssumes tht integer nd long re equl in size to keep on working without modi(tionF e hosen set of types is refered to in g fqs s progrmmingmodelD nd re nmed svExD vvEx or vEx with x the proessor9s wordsize in itsD typilly QP or TRF svEx mens tht sntegerD vong nd ointer re x its wideD vEx tht vong nd ointer re x its wideD nd vv tht vong vong nd ointer re x its wideF ome typil progrmming models re listed in the tle elowF gtype hr short int long long long pointer ojps yteGhrGsmllint shortint integerGlongint pointer types svQP V IT QP QP QP QP ize in model vQP vTR svTR V V V IT IT IT IT QP TR QP TR TR [email protected] [email protected] [email protected] QP TR TR vvTR V IT QP TR TR TR

· ome points in the tle need expliningX · tndrd progrmming model for urrent @intel fmilyA g proessors is svQPF ell QPEits yes use itF · he prolem with long in g ws tht there re oth lrge odeses tht expet pointer nd long to hve the sme sizeD while there re lso lrge odeses tht expet int nd long to e the sme sizeF he ompility model vvTR ws designed to keep the long`Ebint ompility y introduing new type to remin omptile with pointer @long longA · long long doesn9t exist exept in vvTRD nd oth long nd longlong don9t hve n ler equivlent in yjet sl yetF e new type would hve to e reted just like under gF ine sl hs no long`Eb ptr equivlene estlished yetD the long vs long long disussion is unimportedF st ws however deided to rete oth signed @ trsnt A nd n unsigned @trint A type tht sle with pointer size





· vQP is used s model for the winEIT ess of indows QFI · wost Bnixes use vTRD minly to onserve memory spe ompred to svTRD sine using full TREit ints is hrdly neessry nd wste of memoryF ixmplesX TREit vinuxD preefhDxetfhDypenfh · inTR uses the vvTR modelD whih ws lso known s TRF his model onserves type ompility etween long nd intD ut loses type ompility etween long nd pointer typesF eny st etween pointer nd n existing type requires modi(tionF · svTR is the esiest model to work withD sine it retins ll ompility with the muh used svQP modelD exept spei( ssumptions tht the ore types re QPEitF rowever this model is quite memoryEhungryDnd oth ode nd dt size signi(ntly inreseF ypilly used y ommeril uniesD like sfw esF · here re no dos models in the tleD sine dos doesn9t hve )t memory modelF @ pointer n9t e represented y single vlue in these modelsF htq extender models re svQP thoughF

5.2 Link ordering

trting with PFHFR some swithes were dded tht simplify deling with hnging lirry nmesF hese swithes re BETA nd my hnge or disappear t ny timeD eFgF when linker desription lnguge is implementedF hey were mostly dded to e le inventorize how useful suh system would e in prtieD mostly it is ment to del with hnges in lirry nmes nd keep relese running without repkging it efore (nl deision is mdeF hey re fie lso euse the internl linker might totlly hnge the linking kend in the ner futureF he min prolem it solves is tht with pgD nmes of lirries n e hrdoded in the pg soure in $linklib or EXTERNAL delrtionsF hile this is generlly good thing tht mkes it wy esier for the user nd voids kludges like hving to speify eh nd every lirry on the ommndline like gD it n e nnoying in times when lirrynmes go through trnsitionD nd you use distriution tht renmes lirriesF fesides the nmeD lso the order of lirries might sometimes e prolemD speilly when lirries don9t speify their dependnies orretlyF wost of these issues re with reltive lowlevel lis like ligF pg PFHFR introdues severl beta swithes to del with thisF here re three new prmetersX IF EvelinmealinmeIDlinmePFF PF Evylinmea`numerb QF Evh e limittion tht remins is tht there is no wy to llow the user to deide whih lirries re to e linked sttillyD nd whih re to e linked dynmillyF his minly for esier deployment on linux @non stndrd lisc Eb fore sttiAF enother limittion reently surfed is tht this only goes for lirriesF yjet (lesD nd their order re untouhed

5.2.1 -XLA

he (rst prmeterD EveD de(nes susitution of lirry nmeF he lis on the right side re dded to the prmeters of the linker if the li on the left side is in the list with lirries to link tht is onstruted from the soureF he right side n e emptyD nd n lso ontin the linme tht is lredy spei(ed on the leftF ixmplesX

· EveaDdl mkes sure tht lidl is dded if li is in the listD li remins in the listF · Evedla removes lidl from the list of lirries to link even if it ws {6linkli xx}9ed in the soure · EvegtkEIPagtkIPtrnsltes link to ligtkIP to serh for ligtkEIP






he prmeter vy de(nes weightF virries re sorted on weight into desending orderF hefults weight is IHHHF sf you derese the weightD it will e lower in the list with lirries to linkF his is minly useful to link ertin lirries @typilly the more lowlevel onesA in ertin orderD like eFgF with lir nd li on preefhRD or to get progrms to link tht mde mess of their dependniesF his possiility removes the need for few dEho ordering hksD nd the speil prmeter for the preefh REbS trnsition tht ws one suh kludgeD Ef ws reimplemented using this funtionlityF he ompiler hs defult weights on per trget sisF his minly mens tht li usully will e somewhere ner the endF ixmpleX


puts li efore lirries tht don9t hve weight spei(ed in linkFres @sine the defult is IHHHA

5.2.3 -XLD

he prmeter Evh simply mkes the ompiler forget the defults for weights nd lisesF his n e useful if something hnges for lirry tht hs hrdoded weightD or when uiltEin lis is not needed nymoreF

5.2.4 Example: Fixing the FreeBSD GTK breakage with linkordering

he preefh ports mintiners deided to fore lrge hnges relted to linking using litool on the ports tree in novemer PHHS @in hesxqAD ut they were not into e'et till epril PHHTF yne of sidee'ets of these hnges were renming of the qu I lirries to gtkEIPD gdkEIP nd gliEIPD where they used to e gtkIPD gdkIP nd gliIPF hese hnges 'eted ll users tht trked S nd T stleD sine they didn9t wit for mjor version trnsition to introdue thisF orts mintiners lso refused to dd few symlinks for while to ese the trnsitionsD nd pointed to g spei( tools like gtkon(g nd litoolF @these emit g ommndlinesAF wost users trk efvi y defult out of prtil purposesD nd hnging the pg inry to ll externl progrms nd to prse themD would only mke the whole proess more frgile nd hrder to supportF s myself deided to give up working on pg ports tree entries euse s relly strt wondering where s ene(ted from prtiipting in the ports tree proessF he work is immenseD nd the uses for the users re smll if suh hnges rek pkges so hrd nd reltively oftenF ine in timeD more nd more users will use either Eefvi or relese sed on Eefvi fter the hngeD in pg PFPFH s hnged the defult nme of the qu lirries to their new nmesD nd introdued linkordering swithes to keep older instlltions workingF o if you hve system from efore this hngeD nd don9t trk stleD you n workroundthis y putting the following in your fpFfg or FfpFfgX

· EvegliEIPagliIP · EvegdkEIPagdkIP · EvegtkEIPagtkIP

5.2.5 Example II: FreeBSD 4 vs 5 pthreads:-Xf

enother item is the pp`xb prmeter EfD whih signls n lternte pthreds lyoutF gurrently it only exists for preefhF yn versions PFH nd PFHFP the prmeter signls preefh SFx lipthred ehviourD nd on PFHFR it signls RFx lir ehviourF sn PFHFR the prmeter ws reimplemented on top of the linkordering routinesD so tht when ompiling for RFx lir n e used D 1 en when ompiling for preefh SFx lipthred will e linked inF elso the ordering is (xed using internl equivlents of EvyD nd the defults re lso overridle with EvhF

1 2.0.4

doesn't provide a out of the box 4.x setup anymore, though generally the functionality should be preserved.

Part II




xote tht this glossry tries to explin ompiler nd pg projet spei( jrgonD not slGhelphi in generlF

architecture oughly the proessor fmilyF xote tht for g9sD the xVT rhiteture @ll VHxVT hipsA is often misusedD

where the iQVT rhiteture @VHQVT nd higherA is mentF he g version of pg is iQVT rhitetureD nd doesn9t run on older xVT pro essorsF yther rhitetures re owerg @whih is sudivided into powerQP @aQPEitsA nd powerTR @aTREitAAD mTVk @TVHQHC in prtieAD pr UD pr VD pr W @the ltter etter known s ltr prAF ew versioning is more omplexD sine those proessors n e uilt to orderD ustomer n hoose from severl oresD nd dd modules like pD memorysystem @endinnessAD h funtionlity etF

AR he qx rhiverF gomines Fo (les into F (lesF F (les re used for smrtlinkingD though tht might hnge in the

ner futureF

AS he qx ssemlerF he kend ssemler tht is used if pg needs n externl ssemlerF assembler textul representtion of the inry mhineode tht is fed to the proessorF alias e funtion or vrile with nme tht doesn9t dhere to stndrd nme mnglingD usully for internl funtions or

foreign lnguge interfingF

binwriter he prt of pg tht diretly writes F9s nd Fo9sF ine using the inwriter elimintes exeuting e @nd

possily eAD uilding is muh fsterF he reson why it is not ville for eh pltform is tht there is no universl Fo formtF ivery inry type often hs its own Fo vrintD nd ll need speil support in pgF

branch(CVS,SVN) xormlly versions of (le in g re liner series of updtesD new version fter eh updteF his

n e thought of s the trunk of treeF rowever t ertin point you might wnt to dd n updte tht might eFgF rek kwrds ompility or tht introdues instility for some timeF he solution then is to hve two sequenes of versionsF yne with tht updte @ development series of updteAD nd one withoutF hese seprte series re the rnhes of treeF

bootstrapping is the entire proess of reting ompiler strting from nother ompiler @nother version or totlly di'erent ompilerAF ee lso make cycle Carbon e w y widgetsetGesD whih is essentilly the lensed suset of the lssi w y es tht works with w

y F

CLX e lirry from forlnd tht is it more multipltform nd should hve repled gvF rowever users styed wy

in drovesF gv is qvedD nd thus is not very usle for pgD lirry wiseF

COCOA e w y widgetsetGes written for use with yjetive gF contrib diretory e diretory in x @module fpprojetsA where some ported helphi pkges re kept @sgD ereviD

helAF his diretory is sudiretory of the projets diretoryF

Cross (cross -compiling, -linking and -assembling) qenerting inries or lirries for other operting system ndGor

proessor thn tht you re urrently working onF

(crossbinutils) inutils @ldDsDrA tht generte inries for other operting systems nd proessorsF (crossbindir) le where the rossinutils n e foundF CVS e version mngement tool used y the pg tool to mnge the pg soure ode efore my PHHS Cygwin e distriution of unix tools for windows tht tries to sty s lose to the originl nix semntisF ee lso mingw dead code elimination qgg or mye generl g jrgon for smrtlinkingF he defult ded ode elimintion of g is not

s (nely grined s pg smrtlinking thoughF

ELF inry formt of most modern unies nd unix likesF ixept for w y @see whEyA Export @lirriesA wking symols @proeduresD vrilesA ville to the outsideF @eFgF outside the unitD outside the

lirryGprogrmA @xA

FCL pree gomponent virriesF xon visul lss lirriesD provided for prtil helphi soure ompilityD t lest t non visulGqs levelF ee lso VCLF FPC


IF pree sl gompiler revF PF he fp ompiler frontend inryF

FPCMAKE util to onvert wke(leFfp to wke(le FPMAKE he suesor to fpmke nd mkeGmke(les in generl tht is supposed to render the ltter osolete in PFPF

he min fetures re more mintinle nd performnt uild system @rossompiling inlusiveA

FPPKG enother uild tool sheduled for PFP whih should llow uto downlodCompile of pkgesD it like wht the

preefh ports tree with ptEget like mdline frontend would look likeF @or portupgrdeD whih is the proper preefh pendntA (le generted y mkeskelD nd postedited with fpdeD proesses the (le nd genertes multiple doumenttion formts from it @htmlDtextD i A

FPDOC e doumenttion genertion system used y pg internllyD ut lso usle for externl useF fpdo tkes wv

GO32v2 ure hos is ITEitF pg progrms re QPEitF he progrm tht hides the ITEit nture itD nd does QPEit

hws dos memory mngement for QPEits pplitions is lled the hosEixtenderF pg uses the qx qoQP version P dos extenderF @though others re possile in theoryD like pmodeF ee mnulA (nl ode @in the inryAD the ode of will pper to e in F sf is lled on two seprte ples in D the ode will pper twie in F hile nerly nything n e )gged inlineYD some kinds of proeduresGmethods re exluded from inliningD like virtul methodsF

Inline sf proedure lls proedure D nd is )gged for inliningD then will e totlly optimised wyD nd in the

Internal linker e linker uilt in to the ompilerD s opposed to n externl linker like qx vhF pg uses n internl

linker in pg PFPC for the three windows pltforms @winQPGwinTRGwineA

Lazarus e multi widget qs eh for pree slF xot lind helphi drop in replementD ut the support of qu mkes

it usefulF et the moment of writing thisD vzrus is developing rther fstD for up to dte informtionD see their site vzrus site or qs widget lirryF trting with HFWFPV on Bnix the vgvwill use quPD winQPGTRGe on indowsD nd gron on y F e sed port is lso ville for BnixF

LCL he set of isul lsses used y vzrus nd the progrms it genertesF he vgv is generlly independnt of pltform

LD he qx linkerD whih is nerly lwys the one used y pgF Mach-O inry formt of y Ghrwin mke yle e ommnd to reuild the pg ompiler nd ore v from soureF

@ootstrpD uilding new ompiler from n olderD or other ompilerA

make all e ommnd to reuild the entire se pg soureodeF his is roughly equivlent to the snpshotsF mangling see nmemngling mingw @mingwQPDmingwTR depending on winQP or winTRA e distriution of nix tools for indows tht dpts more to the windows wy thn cygwin. Namemangling vnguges n hve di'erent nmespes tht n ontin the sme nmeD however on the linker level

there is only one nmespeF xmemngling is the proess tht mps the multiple lnguge level nmespes onto the single linker level nmespeF en exmple is eFgF the unitsystemF nits n ontin vriles with the sme nmeF y unit e ontins vrile uildfqD nd unit f does tooF xming oth uildfq would mke them lsh on the linker levelF e solution is to pre(x the vrile nme with the unitnmeF o uildfq in unit e will e lled euildfqD nd in unit f fuildfqF xmemngling is ompiler @nd EversionA spei(D nd sine the nmespe rules vry with the lnguge lso somewht lnguge spei(F en exeption is the g @not gCCA lnguge whih rely hs nmespesD nd therefore often hs little or no mnglingF he gCC nmemngling is notorious seD sine it hnges from ompiler to ompiler nd version to versionF performne nd mintinility y utomtilly rrnging firly optiml register usgeF ine this removes the need for mnully keeping trk of registers in the odegenertorDthis improves mintinility lotF

NEWRA he new improved register llotor of the IFIFx @PFHCA seriesF he new register llotor should improve ompiler

Packages is it of n miguous term when used in the pg projetF @see lso httpXGGwikiFfreepslForgGpkges

IF ometimes pkges refers exlusively to the seprte unit sets in the pkgesG diretory of the soure treeD


PF sometimes it lso inludes the other seprtely ompille prts of the projet @like ompilerD rtlD flD ideD fvisionD lzrusD instller nd utilsAD QF third desription is the helphi lnguge feture with the sme nmeD more utomted form of dynmi lirriesF sn this doument it9s usully the seond oneF

PIC @osition sndependnt godeA system for nix @BfhD vinuxA tht ensures relotility of shred lirriesD nd llows

esy minor version upgrdes of li lirries without reompiling the lirryF


IF @ipsA ple where the snpshot uilding @mke ll instllA will use s root diretory for the instlltion of the (lesF @defultX pp on windowsD GusrGlol on most uniesA he dollr sign tht is sometimes prepended is the @nixA nottion for environment or mke(le vrileD it like indowsGhy 7something7F PF @fsxsvipsA e string tht is pre(xed to the inutils when rossompilingF sully in the form proessorE [email protected] iTVTEmingwQPEA

Projects diretory diretory in g where experimentl nd independnt projets re storedF sully helphi ode ported

to pg @see ontri diretoryAD nd vzrusF

Ptrint e integer type tht hs the sme size @in itsA s the pointer typeF PtrUint is the unsigned formF egister llotor he engine tht tries to mke optiml use of the proessor registers to

void reloding from memoryF

Register parameters e lling onvention tht tries to put prmeters to proedures in registersF helphi hs register

lling onvention y defultF pg is slowly strting to support register prmeters now @thnks to xie hngesAF wost non g proessortypes lso use register prmetersF ine deemer PHHQD pg defults to this onvention on iQVT tooD for helphi ompilityFhuringthe lst months of PHHTD ug ws found in the helphi ompility of register prmetersY when proedures use more thn R prmeters @one less for methodsAD the ft tht pg pushes the prmeters in the opposite order of helphi eomes prolemF his proly will e tkled in pg PFIFI in spring PHHUF y trying to keep frequently used vriles in registers s muh s possileF pg IFHFx hd this in primitive wy sed on reserving few registers for vrilesF pg PFx hs wy more intelligent system s prt of the registerlloter sysutils unit nd pltform dependnt unitF he ystem unit lso ontins funtions tht the ompiler lls internlly to do more omplex lnguge opertions like i nd string hndlingF

Register variables en optimiztion tehnique tht voids reloding vriles from memory into the min g9s registers

RTL unime lirriesF he se set of lirries used y pgF hese inlude eFgF the ystem unitD the dos unitD the

shared linking vinking with dynmi lirries @unixX Fso shred lirriesY winQPX Fdll shred lirriesA smart linking essentilly voids linking of unused ode into the (nl inryF ee the seprte prgrph @IFVA elsewhere in

this doument for more detilsF

static linking he ordinry wy of linkingD produing one stndlone inryD though sometimes smrtlinking is lso lled

stti linkingF his might e true for gD ut pg hs two di'erent modes euse with pg the grnulrity of smrtlinking typilly is higherF

Starting compiler e ompiler tht is used to uild new ompilerF Subversion(SVN) he urrent version mngement systemF tag(CVS,SVN) e tg simply identi(es unh of di'erent (les tht elong togetherF st9s ommonly used to mrk the set

of versions tht re relesed s forml @preAreleseF iFgF the pg IFHFIH relese is tgged with ivieiIHIH etF


IF oughly the operting system nd g tht the inry must run onD typilly in gEy nottion @eFgF iQVTE freesdA here re exeptions thoughD like hos hs trget for eh extenderD nd some ompilers hve multiple trgets for indows @gX mingwD ygwinA tooF ome toolhin let the g re)et the g tht is optimised for @iQVTDiRVTD iSVT etAD some notF pg does not @ll i`xbVT pltformsD xbaQD re lled iQVTA


PF vzrus dds the widget set tooD eFgF xVTEwinQPEwinQP @iQVTC proessorD winQP yD nd winQP @qhsA widgetsetA nd xVTTREwinTREwinQP @mens TREit xVT gD winTR yD nd winQP widgetset @qhsAAF2

VCL forlnd9s lsses lirriesF ine these ontin ot winQP qs nd nonEqs lssesF the gv rougly equtes to the

non visul pgv lsses plus the visul lsses in vzrus9 vgvF

Widgetset e lirry or es for visul outputF @origintes on nix where ore drwingD nd windowing is seprtedA win32

IF he es of indows Wx nd xDPHHHD tht is roughly the sme over ll versionsF @though newer versions dd more llsAF e ut down winQP pi is ville for winQFIx nd is lled winQPsF pg doesn9t support winQPs @tullyX it ws never tested is etter desriptionA PF he pg trget for this pi QF sn vzrus it is lso the designtion for the grphil prt of the winQP pi @whih is tully lled qhsD roughly the widgetsetAF vzrus windows inries for trget winQP nd winTRD hve s widget setF

Win64 he TREit vrint of the winQP esF ery lose to winQPF wince he windows pi the moile indows versions @wineGpoketpGwindowsmoileA re sed onF xote tht nowdys

lso emedded exists whih is winQP sedD ut sed on the x kernelD so speilly with tlet gs mke sure wht you extly hveF @xUA

winNT he ommon underpinnings of xRD windows PHHH @xSA D @xSFIA DPHHQ @xSFPADist @xTAD PHHV nd U windres e resoureompiler used to turn resoure sripts into Fres (les tht n e inluded y the linkerF

2 The

fact that lazarus names the widgetset for win64 win32 doesn't mean it is some form of 32-bit emulation. The dierences were simply

too small to dene an additional target


EphD ITD IU EplD ITD IW EpuD ITD IU ErD QQ EveD QU EvhD QV EvyD QV ED IUD IV EdD QP EfD QV ErD QP EtD QP EglD PQ EldEsetionsD W EvD QQ EvtD QQ lisD RH eD WD RH rhitetureD RH eD WD RH ssemlerD RH inutilsD V fsxsv erD IT fsxsvipsD IUD RP fsxsvipsD IV inwriterD RH ootstrppingD RH rnhD RH gronD RH fgD IT [email protected] IP gvD RH gygyeD RH gyxx not foundD PW ontriD RH © gyiiD PU puVTD IU rossssemlingD RH rossindirD RH gyfsxhsD IV rossinutilsD RH rossompilingD RH rosslinkingD RH gD RH gygwinD IHD RH ded ode elimintionD RH hiretory lyoutD IR ivpD RH RR ixportD RH [email protected] IQ ixtensions @(leEAD IR pgvD RH psiIHH rnhD U (xesPH rnhD U (xesPP rnhD U pgD RH [email protected] II fpFfgD IR pgaD PQ 6pggD IS pggygywsvsxqD IUD IV 6pgheiD IS 6pgpvvisyxD IS pgweuiD IHD RI 6pgyD IS 6pgeqiD IS 6pgisyxD IS phygD RI pweuiD RI puqD RI qsxevvaD PU gmkeD IH qyQPvPD RI qoQPPD IH goQPvPD IH svQPD QT svTRD QT snlineD RI instllFexe @istAD PU sxevvipsaD PR snternl linkerD RI vzrusD RI vgvD RI vhD WD RI virry pthD IW linuxtorD IW vvTRD QT vQPD QT vTRD QT whyD RI mkeD IH mke Ej PD II mke llD RI mke yleD PH mke distlenD PP mke exmplesD PH



mke instllD PS wingwD IHD RI mingwQPD RI mingwTRD RI xmemnglingD RI xieD RI © yD PQ kgesD RI sgD RP iping stderrD PW aD PQ ppQVTD II ppQVTFfgD IT ppppD II ppsprD II ppxTRD II ipsD PR 6ipsD RP re(xD RP rojetsD RP trsntD QT trintD RP trintD QTD RP register llotorD RI egister prmetersD RP egister vrilesD RP ivieiPPPD IQ equirementsD V [email protected] IQ vD RP shred linkingD RP smrt linkingD RP strting ompilerD RP stti linkingD RP uversionD RP xD RP tgD RP trgetD RP xserD IT [email protected] IQ yqaD PU gvD RQ verosityD QQ iewv weinterfeD U idgetsetD RQ winQPD IHD RQ inTRD RQ winTRD IH wineD RQ windresD RQ winxD RQ xVTTRD II


Development Tutorial (a.k.a Build FAQ)

46 pages

Report File (DMCA)

Our content is added by our users. We aim to remove reported files within 1 working day. Please use this link to notify us:

Report this file as copyright or inappropriate