options.pas 186 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482
  1. {
  2. Copyright (c) 1998-2008 by Florian Klaempfl and Peter Vreman
  3. Reads command line options and config files
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit options;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cfileutl,cclasses,versioncmp,
  22. globtype,globals,verbose,systems,cpuinfo,comprsrc;
  23. Type
  24. TOption=class
  25. FirstPass,
  26. ParaLogo,
  27. NoPressEnter,
  28. FPCHelpLines,
  29. LogoWritten,
  30. ABISetExplicitly,
  31. FPUSetExplicitly,
  32. CPUSetExplicitly,
  33. OptCPUSetExplicitly: boolean;
  34. FileLevel : longint;
  35. QuickInfo : string;
  36. FPCBinaryPath: string;
  37. ParaIncludeCfgPath,
  38. ParaIncludePath,
  39. ParaUnitPath,
  40. ParaObjectPath,
  41. ParaLibraryPath,
  42. ParaFrameworkPath,
  43. parapackagepath : TSearchPathList;
  44. paranamespaces : TCmdStrList;
  45. ParaAlignment : TAlignmentInfo;
  46. parapackages : tfphashobjectlist;
  47. paratarget : tsystem;
  48. paratargetasm : tasm;
  49. paratargetdbg : tdbg;
  50. LinkTypeSetExplicitly : boolean;
  51. LinkerSetExplicitly : boolean;
  52. Constructor Create;
  53. Destructor Destroy;override;
  54. procedure WriteLogo;
  55. procedure WriteInfo (More: string);
  56. procedure WriteHelpPages;
  57. procedure WriteQuickInfo;
  58. procedure IllegalPara(const opt:TCmdStr);
  59. procedure UnsupportedPara(const opt:TCmdStr);
  60. procedure IgnoredPara(const opt:TCmdStr);
  61. function Unsetbool(var Opts:TCmdStr; Pos: Longint; const FullPara: TCmdStr; RequireBoolPara: Boolean):boolean;
  62. procedure interpret_option(const opt :TCmdStr;ispara:boolean);
  63. procedure Interpret_envvar(const envname : TCmdStr);
  64. procedure Interpret_file(const filename : TPathStr);
  65. procedure Read_Parameters;
  66. procedure parsecmd(cmd:TCmdStr);
  67. procedure TargetOptions(def:boolean);
  68. procedure CheckOptionsCompatibility;
  69. procedure ForceStaticLinking;
  70. protected
  71. MacVersionSet: boolean;
  72. IdfVersionSet: boolean;
  73. processorstr: TCmdStr;
  74. function ParseMacVersionMin(out minversion, invalidateversion: tversion; const compvarname, value: string; ios: boolean): boolean;
  75. procedure MaybeSetDefaultMacVersionMacro;
  76. {$ifdef XTENSA}
  77. function ParseVersionStr(out ver: longint; const compvarname, value: string): boolean;
  78. procedure MaybeSetIdfVersionMacro;
  79. {$endif}
  80. {$ifdef llvm}
  81. procedure LLVMEnableSanitizers(sanitizers: TCmdStr);
  82. {$endif llvm}
  83. procedure VerifyTargetProcessor;
  84. end;
  85. TOptionClass=class of toption;
  86. var
  87. coption : TOptionClass;
  88. procedure read_arguments(cmd:TCmdStr);
  89. implementation
  90. uses
  91. widestr,
  92. charset,
  93. SysUtils,
  94. version,
  95. cutils,cmsgs,
  96. comphook,
  97. symtable,scanner,rabase,
  98. symconst,
  99. {$ifdef llvm}
  100. { override supported optimizer transformations at the compiler level }
  101. llvminfo,
  102. {$endif llvm}
  103. dirparse,
  104. pkgutil;
  105. const
  106. page_size = 24;
  107. page_width = 80;
  108. var
  109. option : toption;
  110. read_configfile, { read config file, set when a cfgfile is found }
  111. disable_configfile : boolean;
  112. fpcdir,
  113. ppccfg,
  114. param_file : string; { file to compile specified on the commandline }
  115. {****************************************************************************
  116. Options not supported on all platforms
  117. ****************************************************************************}
  118. const
  119. { gprof (requires implementation of g_profilecode in the code generator) }
  120. supported_targets_pg = [system_i386_linux,system_x86_64_linux,system_mipseb_linux,system_mipsel_linux,system_arm_linux]
  121. + [system_i386_win32]
  122. + [system_powerpc_darwin,system_x86_64_darwin]
  123. + [system_i386_GO32V2]
  124. + [system_i386_freebsd]
  125. + [system_i386_netbsd]
  126. + [system_i386_wdosx]
  127. + [system_riscv32_linux,system_riscv64_linux]
  128. + [system_aarch64_linux];
  129. suppported_targets_x_smallr = systems_linux + systems_solaris + systems_android
  130. + systems_openbsd
  131. + [system_i386_haiku,system_x86_64_haiku]
  132. + [system_i386_beos]
  133. + [system_m68k_amiga];
  134. {****************************************************************************
  135. Defines
  136. ****************************************************************************}
  137. procedure set_default_link_type;
  138. begin
  139. undef_system_macro('FPC_LINK_SMART');
  140. def_system_macro('FPC_LINK_STATIC');
  141. undef_system_macro('FPC_LINK_DYNAMIC');
  142. init_settings.globalswitches:=init_settings.globalswitches+[cs_link_static];
  143. init_settings.globalswitches:=init_settings.globalswitches-[cs_link_shared,cs_link_smart];
  144. {$ifdef AIX}
  145. init_settings.globalswitches:=init_settings.globalswitches+[cs_link_native];
  146. {$endif}
  147. end;
  148. procedure set_endianess_macros;
  149. begin
  150. { endian define }
  151. case target_info.endian of
  152. endian_little :
  153. begin
  154. def_system_macro('ENDIAN_LITTLE');
  155. def_system_macro('FPC_LITTLE_ENDIAN');
  156. undef_system_macro('ENDIAN_BIG');
  157. undef_system_macro('FPC_BIG_ENDIAN');
  158. end;
  159. endian_big :
  160. begin
  161. def_system_macro('ENDIAN_BIG');
  162. def_system_macro('FPC_BIG_ENDIAN');
  163. undef_system_macro('ENDIAN_LITTLE');
  164. undef_system_macro('FPC_LITTLE_ENDIAN');
  165. end;
  166. end;
  167. end;
  168. {****************************************************************************
  169. Toption
  170. ****************************************************************************}
  171. procedure StopOptions(err:longint);
  172. begin
  173. if assigned(Option) then
  174. begin
  175. Option.free;
  176. Option:=nil;
  177. end;
  178. raise ECompilerAbortSilent.Create;
  179. end;
  180. function is_identifier(const s: TCmdStr): boolean;
  181. var
  182. i: longint;
  183. begin
  184. result:=false;
  185. if (s='') or not (s[1] in ['A'..'Z','a'..'z','_']) then
  186. exit;
  187. for i:=2 to length(s) do
  188. if not (s[I] in ['A'..'Z','a'..'z','0'..'9','_']) then
  189. exit;
  190. result:=true;
  191. end;
  192. procedure Toption.WriteLogo;
  193. var
  194. msg : TMsgStr;
  195. p : pchar;
  196. begin
  197. if not LogoWritten then
  198. begin
  199. msg:=MessageStr(option_logo);
  200. p:=pchar(msg);
  201. while assigned(p) do
  202. Comment(V_Normal,GetMsgLine(p));
  203. LogoWritten:= true;
  204. end;
  205. end;
  206. procedure Toption.WriteInfo (More: string);
  207. var
  208. msg_str: TMsgStr;
  209. p : pchar;
  210. hs,hs1,hs3,s : TCmdStr;
  211. J: longint;
  212. xmloutput: Text;
  213. const
  214. NewLineStr = '$\n';
  215. OSTargetsPlaceholder = '$OSTARGETS';
  216. CPUListPlaceholder = '$INSTRUCTIONSETS';
  217. FPUListPlaceholder = '$FPUINSTRUCTIONSETS';
  218. ABIListPlaceholder = '$ABITARGETS';
  219. OptListPlaceholder = '$OPTIMIZATIONS';
  220. WPOListPlaceholder = '$WPOPTIMIZATIONS';
  221. AsmModeListPlaceholder = '$ASMMODES';
  222. ControllerListPlaceholder = '$CONTROLLERTYPES';
  223. FeatureListPlaceholder = '$FEATURELIST';
  224. ModeSwitchListPlaceholder = '$MODESWITCHES';
  225. CodeGenerationBackendPlaceholder = '$CODEGENERATIONBACKEND';
  226. LLVMVersionPlaceholder = '$LLVMVERSIONS';
  227. procedure SplitLine (var OrigString: TCmdStr; const Placeholder: TCmdStr;
  228. out RemainderString: TCmdStr);
  229. var
  230. I: longint;
  231. HS2: TCmdStr;
  232. begin
  233. RemainderString := '';
  234. if OrigString = '' then
  235. Exit;
  236. repeat
  237. I := Pos (NewLineStr, OrigString);
  238. if I > 0 then
  239. begin
  240. HS2 := Copy (OrigString, 1, Pred (I));
  241. { Stop if this line contains the placeholder for list replacement }
  242. if Pos (Placeholder, HS2) > 0 then
  243. begin
  244. RemainderString := Copy (OrigString, I + Length (NewLineStr),
  245. Length (OrigString) - I - Length (NewLineStr));
  246. { Special case - NewLineStr at the end of the line }
  247. if RemainderString = '' then
  248. RemainderString := NewLineStr;
  249. OrigString := HS2;
  250. Exit;
  251. end;
  252. Comment (V_Normal, HS2);
  253. Delete (OrigString, 1, Pred (I) + Length (NewLineStr));
  254. end;
  255. until I = 0;
  256. if (OrigString <> '') and (Pos (Placeholder, OrigString) = 0) then
  257. Comment (V_Normal, OrigString);
  258. end;
  259. procedure ListOSTargets (OrigString: TCmdStr);
  260. var
  261. target : tsystem;
  262. begin
  263. SplitLine (OrigString, OSTargetsPlaceholder, HS3);
  264. for target:=low(tsystem) to high(tsystem) do
  265. if assigned(targetinfos[target]) then
  266. begin
  267. hs1:=targetinfos[target]^.shortname;
  268. if OrigString = '' then
  269. Comment (V_Normal, hs1)
  270. else
  271. begin
  272. hs := OrigString;
  273. hs1:=hs1 + ': ' + targetinfos[target]^.name;
  274. if tf_under_development in targetinfos[target]^.flags then
  275. hs1:=hs1+' {*}';
  276. Replace(hs,OSTargetsPlaceholder,hs1);
  277. Comment(V_Normal,hs);
  278. end;
  279. end;
  280. end;
  281. procedure ListOSTargetsXML;
  282. var
  283. target : tsystem;
  284. begin
  285. WriteLn(xmloutput,' <ostargets>');
  286. for target:=low(tsystem) to high(tsystem) do
  287. if assigned(targetinfos[target]) then
  288. begin
  289. Write(xmloutput,' <ostarget shortname="',targetinfos[target]^.shortname,'" name="',targetinfos[target]^.name,'"');
  290. if tf_under_development in targetinfos[target]^.flags then
  291. Write(' experimental="1"');
  292. WriteLn('/>');
  293. end;
  294. WriteLn(xmloutput,' </ostargets>');
  295. end;
  296. procedure ListCPUInstructionSets (OrigString: TCmdStr);
  297. var
  298. cpu : tcputype;
  299. begin
  300. SplitLine (OrigString, CPUListPlaceholder, HS3);
  301. hs1:='';
  302. for cpu:=low(tcputype) to high(tcputype) do
  303. begin
  304. if (OrigString = '') then
  305. begin
  306. if CPUTypeStr [CPU] <> '' then
  307. Comment (V_Normal, CPUTypeStr [CPU]);
  308. end
  309. else
  310. begin
  311. if length(hs1+cputypestr[cpu])>70 then
  312. begin
  313. hs:=OrigString;
  314. HS1 := HS1 + ',';
  315. Replace(hs,CPUListPlaceholder,hs1);
  316. Comment(V_Normal,hs);
  317. hs1:=''
  318. end
  319. else if hs1<>'' then
  320. hs1:=hs1+',';
  321. if cputypestr[cpu]<>'' then
  322. hs1:=hs1+cputypestr[cpu];
  323. end;
  324. end;
  325. if (OrigString <> '') and (hs1 <> '') then
  326. begin
  327. hs:=OrigString;
  328. Replace(hs,CPUListPlaceholder,hs1);
  329. Comment(V_Normal,hs);
  330. hs1:=''
  331. end;
  332. end;
  333. procedure ListCPUInstructionSetsXML;
  334. var
  335. cpu : tcputype;
  336. begin
  337. WriteLn(xmloutput,' <cpuinstructionsets>');
  338. for cpu:=low(tcputype) to high(tcputype) do
  339. if CPUTypeStr [CPU] <> '' then
  340. WriteLn(xmloutput,' <cpuinstructionset name="',CPUTypeStr [CPU], '"/>');
  341. WriteLn(xmloutput,' </cpuinstructionsets>');
  342. end;
  343. procedure ListFPUInstructionSets (OrigString: TCmdStr);
  344. var
  345. fpu : tfputype;
  346. begin
  347. SplitLine (OrigString, FPUListPlaceholder, HS3);
  348. hs1:='';
  349. for fpu:=low(tfputype) to high(tfputype) do
  350. begin
  351. if (OrigString = '') then
  352. begin
  353. if FPUTypeStr [FPU] <> '' then
  354. Comment (V_Normal, FPUTypeStr [FPU]);
  355. end
  356. else
  357. begin
  358. if length(hs1+fputypestr[fpu])>70 then
  359. begin
  360. hs:=OrigString;
  361. HS1 := HS1 + ',';
  362. Replace(hs,FPUListPlaceholder,hs1);
  363. Comment(V_Normal,hs);
  364. hs1:=''
  365. end
  366. else if hs1<>'' then
  367. hs1:=hs1+',';
  368. if fputypestr[fpu]<>'' then
  369. hs1:=hs1+fputypestr[fpu];
  370. end;
  371. end;
  372. if (OrigString <> '') and (hs1 <> '') then
  373. begin
  374. hs:=OrigString;
  375. Replace(hs,FPUListPlaceholder,hs1);
  376. Comment(V_Normal,hs);
  377. hs1:=''
  378. end;
  379. end;
  380. procedure ListFPUInstructionSetsXML;
  381. var
  382. fpu : tfputype;
  383. begin
  384. WriteLn(xmloutput,' <fpuinstructionsets>');
  385. for fpu:=low(tfputype) to high(tfputype) do
  386. if FPUTypeStr [fpu] <> '' then
  387. WriteLn(xmloutput,' <cpuinstructionset name="',FPUTypeStr [fpu], '"/>');
  388. WriteLn(xmloutput,' </fpuinstructionsets>');
  389. end;
  390. procedure ListABITargets (OrigString: TCmdStr);
  391. var
  392. abi : tabi;
  393. begin
  394. SplitLine (OrigString, ABIListPlaceholder, HS3);
  395. for abi:=low(abi) to high(abi) do
  396. begin
  397. if not abiinfo[abi].supported then
  398. continue;
  399. hs1:=abiinfo[abi].name;
  400. if hs1<>'' then
  401. begin
  402. if OrigString = '' then
  403. Comment (V_Normal, HS1)
  404. else
  405. begin
  406. hs:=OrigString;
  407. Replace(hs,ABIListPlaceholder,hs1);
  408. Comment(V_Normal,hs);
  409. end;
  410. end;
  411. end;
  412. end;
  413. procedure ListABITargetsXML;
  414. var
  415. abi : tabi;
  416. begin
  417. WriteLn(xmloutput,' <abis>');
  418. for abi:=low(abi) to high(abi) do
  419. begin
  420. if not abiinfo[abi].supported then
  421. continue;
  422. if abiinfo[abi].name<>'' then;
  423. WriteLn(xmloutput,' <abi name="',abiinfo[abi].name, '"/>');
  424. end;
  425. WriteLn(xmloutput,' </abis>');
  426. end;
  427. procedure ListOptimizations (OrigString: TCmdStr);
  428. var
  429. opt : toptimizerswitch;
  430. begin
  431. SplitLine (OrigString, OptListPlaceholder, HS3);
  432. for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
  433. begin
  434. if opt in supported_optimizerswitches then
  435. begin
  436. hs1:=OptimizerSwitchStr[opt];
  437. if hs1<>'' then
  438. begin
  439. if OrigString = '' then
  440. Comment (V_Normal, hs1)
  441. else
  442. begin
  443. hs:=OrigString;
  444. Replace(hs,OptListPlaceholder,hs1);
  445. Comment(V_Normal,hs);
  446. end;
  447. end;
  448. end;
  449. end;
  450. end;
  451. procedure ListOptimizationsXML;
  452. var
  453. opt: toptimizerswitch;
  454. begin
  455. WriteLn(xmloutput,' <optimizations>');
  456. for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
  457. if OptimizerSwitchStr[opt]<>'' then
  458. WriteLn(xmloutput,' <optimization name="',OptimizerSwitchStr[opt],'"/>');
  459. WriteLn(xmloutput,' </optimizations>');
  460. end;
  461. procedure ListWPOptimizations (OrigString: TCmdStr);
  462. var
  463. wpopt: twpoptimizerswitch;
  464. begin
  465. SplitLine (OrigString, WPOListPlaceholder, HS3);
  466. for wpopt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  467. begin
  468. { currently all whole program optimizations are platform-independent
  469. if opt in supported_wpoptimizerswitches then
  470. }
  471. begin
  472. hs1:=WPOptimizerSwitchStr[wpopt];
  473. if hs1<>'' then
  474. begin
  475. if OrigString = '' then
  476. Comment (V_Normal, hs1)
  477. else
  478. begin
  479. hs:=OrigString;
  480. Replace(hs,WPOListPlaceholder,hs1);
  481. Comment(V_Normal,hs);
  482. end;
  483. end;
  484. end;
  485. end;
  486. end;
  487. procedure ListWPOptimizationsXML;
  488. var
  489. wpopt: twpoptimizerswitch;
  490. begin
  491. WriteLn(xmloutput,' <wpoptimizations>');
  492. for wpopt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  493. if WPOptimizerSwitchStr[wpopt]<>'' then
  494. WriteLn(xmloutput,' <wpoptimization name="',WPOptimizerSwitchStr[wpopt],'"/>');
  495. WriteLn(xmloutput,' </wpoptimizations>');
  496. end;
  497. procedure ListAsmModes (OrigString: TCmdStr);
  498. var
  499. asmmode : tasmmode;
  500. begin
  501. SplitLine (OrigString, AsmModeListPlaceholder, HS3);
  502. for asmmode:=low(tasmmode) to high(tasmmode) do
  503. if assigned(asmmodeinfos[asmmode]) then
  504. begin
  505. hs1:=asmmodeinfos[asmmode]^.idtxt;
  506. if hs1<>'' then
  507. begin
  508. if OrigString = '' then
  509. Comment (V_Normal, hs1)
  510. else
  511. begin
  512. hs:=OrigString;
  513. Replace(hs,AsmModeListPlaceholder,hs1);
  514. Comment(V_Normal,hs);
  515. end;
  516. end;
  517. end;
  518. end;
  519. procedure ListAsmModesXML;
  520. var
  521. asmmode : tasmmode;
  522. begin
  523. WriteLn(xmloutput,' <asmmodes>');
  524. for asmmode:=low(tasmmode) to high(tasmmode) do
  525. if assigned(asmmodeinfos[asmmode]) then
  526. WriteLn(xmloutput,' <asmmode name="',asmmodeinfos[asmmode]^.idtxt,'"/>');
  527. WriteLn(xmloutput,' </asmmodes>');
  528. end;
  529. procedure ListControllerTypes (OrigString: TCmdStr);
  530. var
  531. controllertype : tcontrollertype;
  532. begin
  533. {$PUSH}
  534. {$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
  535. if (ControllerSupport) then
  536. begin
  537. SplitLine (OrigString, ControllerListPlaceholder, HS3);
  538. hs1:='';
  539. for controllertype:=low(tcontrollertype) to high(tcontrollertype) do
  540. begin
  541. if (OrigString = '') then
  542. begin
  543. if Embedded_Controllers [ControllerType].ControllerTypeStr <> '' then
  544. Comment (V_Normal, Embedded_Controllers [ControllerType].ControllerTypeStr);
  545. end
  546. else
  547. begin
  548. if length(hs1+embedded_controllers[controllertype].ControllerTypeStr)
  549. >70 then
  550. begin
  551. hs:=OrigString;
  552. HS1 := HS1 + ',';
  553. Replace(hs,ControllerListPlaceholder,hs1);
  554. Comment(V_Normal,hs);
  555. hs1:=''
  556. end
  557. else if hs1<>'' then
  558. hs1:=hs1+',';
  559. if embedded_controllers[controllertype].ControllerTypeStr<>'' then
  560. hs1:=hs1+embedded_controllers[controllertype].ControllerTypeStr;
  561. end;
  562. end;
  563. if (OrigString <> '') and (hs1<>'') then
  564. begin
  565. hs:=OrigString;
  566. Replace(hs,ControllerListPlaceholder,hs1);
  567. Comment(V_Normal,hs);
  568. hs1:=''
  569. end;
  570. end;
  571. {$POP}
  572. end;
  573. procedure ListControllerTypesXML;
  574. var
  575. controllertype : tcontrollertype;
  576. begin
  577. {$PUSH}
  578. {$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
  579. if (ControllerSupport) then
  580. begin
  581. WriteLn(xmloutput,' <controllertypes>');
  582. for controllertype:=low(tcontrollertype) to high(tcontrollertype) do
  583. if embedded_controllers[controllertype].ControllerTypeStr<>'' then
  584. WriteLn(xmloutput,' <controllertype name="',embedded_controllers[controllertype].ControllerTypeStr,
  585. '" controllerunit="',embedded_controllers[controllertype].controllerunitstr, '"/>');
  586. WriteLn(xmloutput,' </controllertypes>');
  587. end;
  588. {$POP}
  589. end;
  590. procedure ListFeatures (OrigString: TCmdStr);
  591. var
  592. Feature: TFeature;
  593. begin
  594. SplitLine (OrigString, FeatureListPlaceholder, HS3);
  595. HS1 := '';
  596. for Feature := Low (TFeature) to High (TFeature) do
  597. begin
  598. if (OrigString = '') then
  599. begin
  600. if FeatureStr [Feature] <> '' then
  601. Comment (V_Normal, FeatureStr [Feature]);
  602. end
  603. else
  604. begin
  605. if Length (HS1 + FeatureStr [Feature]) > 70 then
  606. begin
  607. HS := OrigString;
  608. HS1 := HS1 + ',';
  609. Replace (HS, FeatureListPlaceholder, HS1);
  610. Comment (V_Normal, HS);
  611. HS1 := ''
  612. end
  613. else if HS1 <> '' then
  614. HS1 := HS1 + ',';
  615. if FeatureStr [Feature] <> '' then
  616. HS1 := HS1 + FeatureStr [Feature];
  617. end;
  618. end;
  619. if (OrigString <> '') and (HS1 <> '') then
  620. begin
  621. HS := OrigString;
  622. Replace (HS, FeatureListPlaceholder, HS1);
  623. Comment (V_Normal, HS);
  624. HS1 := ''
  625. end;
  626. end;
  627. procedure ListFeaturesXML;
  628. var
  629. Feature: TFeature;
  630. begin
  631. WriteLn(xmloutput,' <features>');
  632. for Feature := Low (TFeature) to High (TFeature) do
  633. if FeatureStr [Feature] <> '' then
  634. WriteLn(xmloutput,' <feature name="',FeatureStr [Feature],'"/>');
  635. WriteLn(xmloutput,' </features>');
  636. end;
  637. procedure ListModeswitches (OrigString: TCmdStr);
  638. var
  639. Modeswitch: TModeswitch;
  640. begin
  641. SplitLine (OrigString, ModeswitchListPlaceholder, HS3);
  642. HS1 := '';
  643. for Modeswitch := Low (TModeswitch) to High (TModeswitch) do
  644. begin
  645. if (OrigString = '') then
  646. begin
  647. if ModeswitchStr [Modeswitch] <> '' then
  648. Comment (V_Normal, ModeswitchStr [Modeswitch]);
  649. end
  650. else
  651. begin
  652. if Length (HS1 + ModeswitchStr [Modeswitch]) > 60 then
  653. begin
  654. HS := OrigString;
  655. HS1 := HS1 + ',';
  656. Replace (HS, ModeswitchListPlaceholder, HS1);
  657. Comment (V_Normal, HS);
  658. HS1 := ''
  659. end
  660. else if HS1 <> '' then
  661. HS1 := HS1 + ',';
  662. if ModeswitchStr [Modeswitch] <> '' then
  663. HS1 := HS1 + ModeswitchStr [Modeswitch];
  664. end;
  665. end;
  666. if (OrigString <> '') and (HS1 <> '') then
  667. begin
  668. HS := OrigString;
  669. Replace (HS, ModeswitchListPlaceholder, HS1);
  670. Comment (V_Normal, HS);
  671. HS1 := ''
  672. end;
  673. end;
  674. procedure ListModeswitchesXML;
  675. var
  676. Modeswitch: TModeswitch;
  677. begin
  678. WriteLn(xmloutput,' <modeswitches>');
  679. for Modeswitch:=Low(TModeswitch) to High(TModeswitch) do
  680. if ModeswitchStr [Modeswitch]<>'' then
  681. WriteLn(xmloutput,' <modeswitch name="',ModeswitchStr [Modeswitch],'"/>');
  682. WriteLn(xmloutput,' </modeswitches>');
  683. end;
  684. procedure ListCodeGenerationBackend (OrigString: TCmdStr);
  685. begin
  686. SplitLine (OrigString, CodeGenerationBackendPlaceholder, HS3);
  687. hs1:=cgbackend2str[cgbackend];
  688. if OrigString = '' then
  689. Comment (V_Normal, hs1)
  690. else
  691. begin
  692. hs:=OrigString;
  693. Replace(hs,CodeGenerationBackendPlaceholder,hs1);
  694. Comment(V_Normal,hs);
  695. end;
  696. end;
  697. procedure ListCodeGenerationBackendXML;
  698. begin
  699. WriteLn(xmloutput,' <codegeneratorbackend>',cgbackend2str[cgbackend],'</codegeneratorbackend>');
  700. end;
  701. procedure ListLLVMVersions (OrigString: TCmdStr);
  702. {$ifdef LLVM}
  703. var
  704. llvmversion : tllvmversion;
  705. {$endif LLVM}
  706. begin
  707. {$ifdef LLVM}
  708. SplitLine (OrigString, LLVMVersionPlaceholder, HS3);
  709. for llvmversion:=low(llvmversion) to high(llvmversion) do
  710. begin
  711. hs1:=llvmversionstr[llvmversion];
  712. if hs1<>'' then
  713. begin
  714. if OrigString = '' then
  715. Comment (V_Normal, hs1)
  716. else
  717. begin
  718. hs:=OrigString;
  719. Replace(hs,LLVMVersionPlaceholder,hs1);
  720. Comment(V_Normal,hs);
  721. end;
  722. end;
  723. end;
  724. {$else LLVM}
  725. Comment (V_Normal, '')
  726. {$endif LLVM}
  727. end;
  728. procedure ListLLVMVersionsXML;
  729. {$ifdef LLVM}
  730. var
  731. llvmversion : tllvmversion;
  732. {$endif LLVM}
  733. begin
  734. {$ifdef LLVM}
  735. WriteLn(xmloutput,' <llvmversions>');
  736. for llvmversion:=Low(tllvmversion) to High(tllvmversion) do
  737. if llvmversionstr[llvmversion]<>'' then
  738. WriteLn(xmloutput,' <llvmversion name="',llvmversionstr[llvmversion],'"/>');
  739. WriteLn(xmloutput,' </llvmversions>');
  740. {$endif LLVM}
  741. end;
  742. begin
  743. if More = '' then
  744. begin
  745. msg_str:=MessageStr(option_info);
  746. p:=pchar(msg_str);
  747. while assigned(p) do
  748. begin
  749. s:=GetMsgLine(p);
  750. { list permitted values for certain options }
  751. if pos(OSTargetsPlaceholder,s)>0 then
  752. ListOSTargets (S)
  753. else if pos(CPUListPlaceholder,s)>0 then
  754. ListCPUInstructionSets (S)
  755. else if pos(FPUListPlaceholder,s)>0 then
  756. ListFPUInstructionSets (S)
  757. else if pos(ABIListPlaceholder,s)>0 then
  758. ListABITargets (S)
  759. else if pos(OptListPlaceholder,s)>0 then
  760. ListOptimizations (S)
  761. else if pos(WPOListPlaceholder,s)>0 then
  762. ListWPOptimizations (S)
  763. else if Pos (ModeswitchListPlaceholder, S) > 0 then
  764. ListModeswitches (S)
  765. else if pos(AsmModeListPlaceholder,s)>0 then
  766. ListAsmModes (S)
  767. else if pos(ControllerListPlaceholder,s)>0 then
  768. ListControllerTypes (S)
  769. else if pos(FeatureListPlaceholder,s)>0 then
  770. ListFeatures (S)
  771. else if pos(CodeGenerationBackendPlaceholder,s)>0 then
  772. ListCodeGenerationBackend (S)
  773. else if pos(LLVMVersionPlaceholder,s)>0 then
  774. ListLLVMVersions (s)
  775. else
  776. Comment(V_Normal,s);
  777. end;
  778. end
  779. else if Copy(More,1,1) = 'x' then
  780. begin
  781. Assign(xmloutput,Copy(More,2,length(More)-1));
  782. Rewrite(xmloutput);
  783. WriteLn(xmloutput,'<?xml version="1.0" encoding="utf-8"?>');
  784. WriteLn(xmloutput,'<fpcoutput>');
  785. WriteLn(xmloutput,' <info>');
  786. ListOSTargetsXML;
  787. ListCPUInstructionSetsXML;
  788. ListFPUInstructionSetsXML;
  789. ListABITargetsXML;
  790. ListOptimizationsXML;
  791. ListWPOptimizationsXML;
  792. ListModeswitchesXML;
  793. ListAsmModesXML;
  794. ListControllerTypesXML;
  795. ListFeaturesXML;
  796. ListCodeGenerationBackendXML;
  797. ListLLVMVersionsXML;
  798. WriteLn(xmloutput,' </info>');
  799. WriteLn(xmloutput,'</fpcoutput>');
  800. Close(xmloutput);
  801. end
  802. else
  803. begin
  804. J := 1;
  805. while J <= Length (More) do
  806. begin
  807. if J > 1 then
  808. Comment(V_Normal,''); (* Put empty line between multiple sections *)
  809. case More [J] of
  810. 'a': ListABITargets ('');
  811. 'b': Comment(V_Normal, cgbackend2str[cgbackend]);
  812. 'c': ListCPUInstructionSets ('');
  813. 'f': ListFPUInstructionSets ('');
  814. 'i': ListAsmModes ('');
  815. {$ifdef LLVM}
  816. 'l': ListLLVMVersions ('');
  817. {$endif LLVM}
  818. 'm': ListModeswitches ('');
  819. 'o': ListOptimizations ('');
  820. 'r': ListFeatures ('');
  821. 't': ListOSTargets ('');
  822. 'u': ListControllerTypes ('');
  823. 'w': ListWPOptimizations ('');
  824. else
  825. IllegalPara ('-i' + More);
  826. end;
  827. Inc (J);
  828. end;
  829. end;
  830. StopOptions(0);
  831. end;
  832. procedure Toption.WriteHelpPages;
  833. function PadEnd(s:string;i:longint):string;
  834. begin
  835. if length(s) >= i then
  836. S := S + ' '
  837. else
  838. while (length(s)<i) do
  839. s:=s+' ';
  840. PadEnd:=s;
  841. end;
  842. var
  843. lastident,
  844. j,outline,
  845. ident,
  846. HelpLineHeight,
  847. lines : longint;
  848. show : boolean;
  849. opt : string[32];
  850. input,
  851. HelpLine,
  852. s : string;
  853. p : pchar;
  854. msg_str: TMsgStr;
  855. begin
  856. WriteLogo;
  857. Lines:=4;
  858. if FPCHelpLines then
  859. Message1(option_usage,FixFileName(FPCBinaryPath))
  860. else
  861. Message1(option_usage,FixFileName(system.paramstr(0)));
  862. lastident:=0;
  863. msg_str:=MessageStr(option_help_pages);
  864. p:=pchar(msg_str);
  865. while assigned(p) do
  866. begin
  867. { get a line and reset }
  868. s:=GetMsgLine(p);
  869. ident:=0;
  870. show:=false;
  871. { parse options }
  872. case s[1] of
  873. 'F': if FPCHelpLines then
  874. Show := true;
  875. {$ifdef UNITALIASES}
  876. 'a',
  877. {$endif}
  878. {$ifdef EXTDEBUG}
  879. 'e',
  880. {$endif EXTDEBUG}
  881. {$ifdef i386}
  882. '3',
  883. {$endif}
  884. {$ifdef x86_64}
  885. '4',
  886. {$endif}
  887. {$ifdef m68k}
  888. '6',
  889. {$endif}
  890. {$ifdef i8086}
  891. '8',
  892. {$endif}
  893. {$ifdef aarch64}
  894. 'a',
  895. {$endif}
  896. {$ifdef arm}
  897. 'A',
  898. {$endif}
  899. {$ifdef mipsel}
  900. 'm',
  901. {$endif}
  902. {$ifdef mipseb}
  903. 'M',
  904. {$endif}
  905. {$ifdef powerpc}
  906. 'P',
  907. {$endif}
  908. {$ifdef powerpc64}
  909. 'p',
  910. {$endif}
  911. {$ifdef sparc}
  912. 'S',
  913. {$endif}
  914. {$ifdef sparc64}
  915. 's',
  916. {$endif}
  917. {$ifdef riscv32}
  918. 'R',
  919. {$endif}
  920. {$ifdef riscv64}
  921. 'r',
  922. {$endif}
  923. {$ifdef avr}
  924. 'V',
  925. {$endif}
  926. {$ifdef jvm}
  927. 'J',
  928. {$endif}
  929. {$ifdef llvm}
  930. 'L',
  931. {$endif}
  932. {$ifdef xtensa}
  933. 'x',
  934. {$endif}
  935. {$ifdef z80}
  936. 'Z',
  937. {$endif}
  938. {$ifdef wasm32}
  939. 'W',
  940. {$endif}
  941. {$ifdef loongarch64}
  942. 'l',
  943. {$endif}
  944. '*' : show:=true;
  945. end;
  946. if show then
  947. begin
  948. case s[2] of
  949. 'g',
  950. {$ifdef Unix}
  951. 'L',
  952. {$endif}
  953. {$ifdef os2}
  954. 'O',
  955. {$endif}
  956. '*' : show:=true;
  957. else
  958. show:=false;
  959. end;
  960. end;
  961. { now we may show the message or not }
  962. if show then
  963. begin
  964. case s[3] of
  965. '0' : begin
  966. ident:=0;
  967. outline:=0;
  968. end;
  969. '1' : begin
  970. ident:=2;
  971. outline:=7;
  972. end;
  973. '2' : begin
  974. ident:=6;
  975. outline:=11;
  976. end;
  977. '3' : begin
  978. ident:=9;
  979. outline:=11;
  980. end;
  981. else
  982. internalerror(2013112906);
  983. end;
  984. j:=pos('_',s);
  985. opt:=Copy(s,4,j-4);
  986. if opt='*' then
  987. opt:=''
  988. else
  989. if (opt=' ') or (opt[1]='@') then
  990. opt:=PadEnd(opt,outline)
  991. else
  992. opt:=PadEnd('-'+opt,outline);
  993. if (ident=0) and (lastident<>0) then
  994. begin
  995. Comment(V_Normal,'');
  996. inc(Lines);
  997. end;
  998. HelpLine := PadEnd('',ident)+opt+Copy(s,j+1,255);
  999. if HelpLine = '' then
  1000. HelpLineHeight := 1
  1001. else
  1002. HelpLineHeight := Succ (CharLength (HelpLine) div Page_Width);
  1003. { page full ? }
  1004. if (lines + HelpLineHeight >= page_size - 1) then
  1005. begin
  1006. if not NoPressEnter then
  1007. begin
  1008. Message(option_help_press_enter);
  1009. readln(input);
  1010. if upper(input)='Q' then
  1011. StopOptions(0);
  1012. end;
  1013. lines:=0;
  1014. end;
  1015. Comment(V_Normal,HelpLine);
  1016. LastIdent:=Ident;
  1017. Inc (Lines, HelpLineHeight);
  1018. end;
  1019. end;
  1020. StopOptions(0);
  1021. end;
  1022. procedure Toption.IllegalPara(const opt:TCmdStr);
  1023. begin
  1024. Message1(option_illegal_para,opt);
  1025. Message(option_help_pages_para);
  1026. StopOptions(1);
  1027. end;
  1028. procedure toption.UnsupportedPara(const opt: TCmdStr);
  1029. begin
  1030. Message1(option_unsupported_target,opt);
  1031. StopOptions(1);
  1032. end;
  1033. procedure toption.IgnoredPara(const opt: TCmdStr);
  1034. begin
  1035. Message1(option_ignored_target,opt);
  1036. end;
  1037. procedure toption.ForceStaticLinking;
  1038. begin
  1039. def_system_macro('FPC_LINK_STATIC');
  1040. undef_system_macro('FPC_LINK_SMART');
  1041. undef_system_macro('FPC_LINK_DYNAMIC');
  1042. include(init_settings.globalswitches,cs_link_static);
  1043. exclude(init_settings.globalswitches,cs_link_smart);
  1044. exclude(init_settings.globalswitches,cs_link_shared);
  1045. LinkTypeSetExplicitly:=true;
  1046. end;
  1047. function toption.ParseMacVersionMin(out minversion, invalidateversion: tversion; const compvarname, value: string; ios: boolean): boolean;
  1048. function subval(start,maxlen: longint; out stop: longint): string;
  1049. var
  1050. i: longint;
  1051. begin
  1052. result:='';
  1053. i:=start;
  1054. while (i<=length(value)) and
  1055. (value[i] in ['0'..'9']) do
  1056. inc(i);
  1057. { sufficient amount of digits? }
  1058. if (i=start) or
  1059. (i-start>maxlen) then
  1060. exit;
  1061. result:=copy(value,start,i-start);
  1062. stop:=i;
  1063. end;
  1064. var
  1065. temp,
  1066. compvarvalue,
  1067. versionstr: string[15];
  1068. major, minor, patch: cardinal;
  1069. i, err: longint;
  1070. osx_minor_two_digits: boolean;
  1071. begin
  1072. invalidateversion.invalidate;
  1073. versionstr:=value;
  1074. MacVersionSet:=false;
  1075. { check whether the value is a valid version number }
  1076. if value='' then
  1077. begin
  1078. undef_system_macro(compvarname);
  1079. exit(true);
  1080. end;
  1081. { major version number }
  1082. compvarvalue:=subval(1,2,i);
  1083. { not enough digits -> invalid }
  1084. if compvarvalue='' then
  1085. exit(false);
  1086. { already end of string -> invalid }
  1087. if (i>=length(value)) or
  1088. (value[i]<>'.') then
  1089. exit(false);
  1090. val(compvarvalue,major,err);
  1091. if err<>0 then
  1092. exit(false);
  1093. { minor version number }
  1094. temp:=subval(i+1,2,i);
  1095. if temp='' then
  1096. exit(false);
  1097. val(temp,minor,err);
  1098. if err<>0 then
  1099. exit(false);
  1100. { on Mac OS X, the minor version number was originally limited to 1 digit;
  1101. with 10.10 the format changed and two digits were also supported; on iOS,
  1102. the minor version number always takes up two digits }
  1103. osx_minor_two_digits:=false;
  1104. if not ios then
  1105. begin
  1106. { if the minor version number is two digits on OS X (the case since
  1107. OS X 10.10), we also have to add two digits for the patch level}
  1108. if length(temp)=2 then
  1109. osx_minor_two_digits:=true;
  1110. end
  1111. { the minor version number always takes up two digits on iOS }
  1112. else if length(temp)=1 then
  1113. temp:='0'+temp;
  1114. compvarvalue:=compvarvalue+temp;
  1115. { optional patch level }
  1116. patch:=0;
  1117. if i<=length(value) then
  1118. begin
  1119. if value[i]<>'.' then
  1120. exit(false);
  1121. temp:=subval(i+1,2,i);
  1122. if temp='' then
  1123. exit(false);
  1124. { there's only room for a single digit patch level in the version macro
  1125. for Mac OS X. gcc sets it to zero if there are more digits, but that
  1126. seems worse than clamping to 9 (don't declare as invalid like with
  1127. minor version number, because there is a precedent like 10.4.11).
  1128. As of OS X 10.10 there are two digits for the patch level
  1129. }
  1130. if not ios and
  1131. not osx_minor_two_digits then
  1132. begin
  1133. if length(temp)<>1 then
  1134. temp:='9';
  1135. end
  1136. else
  1137. begin
  1138. { on iOS, the patch level is always two digits }
  1139. if length(temp)=1 then
  1140. temp:='0'+temp;
  1141. end;
  1142. compvarvalue:=compvarvalue+temp;
  1143. { must be the end }
  1144. if i<=length(value) then
  1145. exit(false);
  1146. val(temp,patch,err);
  1147. if err<>0 then
  1148. exit(false);
  1149. end
  1150. else if not ios and
  1151. not osx_minor_two_digits then
  1152. begin
  1153. compvarvalue:=compvarvalue+'0';
  1154. versionstr:=versionstr+'.0'
  1155. end
  1156. else
  1157. begin
  1158. compvarvalue:=compvarvalue+'00';
  1159. { command line versions still only use one 0 though }
  1160. versionstr:=versionstr+'.0'
  1161. end;
  1162. minversion.init(versionstr,major,minor,patch);
  1163. set_system_compvar(compvarname,compvarvalue);
  1164. MacVersionSet:=true;
  1165. result:=true;
  1166. end;
  1167. {$ifdef XTENSA}
  1168. function TOption.ParseVersionStr(out ver: longint;
  1169. const compvarname, value: string): boolean;
  1170. function subval(start,maxlen: longint; out stop: longint): string;
  1171. var
  1172. i: longint;
  1173. begin
  1174. result:='';
  1175. i:=start;
  1176. while (i<=length(value)) and
  1177. (value[i] in ['0'..'9']) do
  1178. inc(i);
  1179. { sufficient amount of digits? }
  1180. if (i=start) or
  1181. (i-start>maxlen) then
  1182. exit;
  1183. result:=copy(value,start,i-start);
  1184. stop:=i;
  1185. end;
  1186. var
  1187. temp,
  1188. compvarvalue: string[15];
  1189. i: longint;
  1190. begin
  1191. Result:=false;
  1192. IdfVersionSet:=false;
  1193. emptystr:='';
  1194. { check whether the value is a valid version number }
  1195. if value='' then
  1196. begin
  1197. undef_system_macro(compvarname);
  1198. exit(true);
  1199. end;
  1200. { major version number }
  1201. compvarvalue:=subval(1,2,i);
  1202. { not enough digits -> invalid }
  1203. if compvarvalue='' then
  1204. exit(false);
  1205. { already end of string -> invalid }
  1206. if (i>=length(value)) or
  1207. (value[i]<>'.') then
  1208. exit(false);
  1209. { minor version number }
  1210. temp:=subval(i+1,2,i);
  1211. if temp='' then
  1212. exit(false);
  1213. if length(temp)=1 then
  1214. temp:='0'+temp;
  1215. compvarvalue:=compvarvalue+temp;
  1216. { patch level }
  1217. if i<=length(value) then
  1218. begin
  1219. if value[i]<>'.' then
  1220. exit(false);
  1221. temp:=subval(i+1,2,i);
  1222. if temp='' then
  1223. exit(false);
  1224. if length(temp)=1 then
  1225. temp:='0'+temp;
  1226. compvarvalue:=compvarvalue+temp;
  1227. { must be the end }
  1228. if i<=length(value) then
  1229. exit(false);
  1230. end
  1231. else
  1232. begin
  1233. compvarvalue:=compvarvalue+'00';
  1234. end;
  1235. val(compvarvalue,idf_version,i);
  1236. if i=0 then
  1237. begin
  1238. set_system_compvar(compvarname,compvarvalue);
  1239. IdfVersionSet:=true;
  1240. result:=true;
  1241. end;
  1242. end;
  1243. {$endif XTENSA}
  1244. procedure TOption.MaybeSetDefaultMacVersionMacro;
  1245. var
  1246. envstr: ansistring;
  1247. begin
  1248. if not(target_info.system in systems_darwin) then
  1249. exit;
  1250. if MacVersionSet then
  1251. exit;
  1252. { check for deployment target set via environment variable }
  1253. if not(target_info.system in [system_i386_iphonesim,system_arm_ios,system_aarch64_ios,system_x86_64_iphonesim,system_aarch64_iphonesim]) then
  1254. begin
  1255. envstr:=GetEnvironmentVariable('MACOSX_DEPLOYMENT_TARGET');
  1256. if envstr<>'' then
  1257. if not ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED',envstr,false) then
  1258. Message1(option_invalid_macosx_deployment_target,envstr)
  1259. else
  1260. begin
  1261. {$ifdef llvm}
  1262. { We only support libunwind as part of libsystem, which happened in Mac OS X 10.6 }
  1263. if MacOSXVersionMin.relationto(10,6,0)<0 then
  1264. Message1(option_invalid_macosx_deployment_target,envstr);
  1265. {$endif}
  1266. exit;
  1267. end;
  1268. end
  1269. else
  1270. begin
  1271. envstr:=GetEnvironmentVariable('IPHONEOS_DEPLOYMENT_TARGET');
  1272. if envstr<>'' then
  1273. if not ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED',envstr,true) then
  1274. Message1(option_invalid_iphoneos_deployment_target,envstr)
  1275. else
  1276. exit;
  1277. end;
  1278. { nothing specified -> defaults }
  1279. case target_info.system of
  1280. system_powerpc_darwin:
  1281. begin
  1282. if not ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED','10.3.0',false) then
  1283. internalerror(2022090910);
  1284. end;
  1285. system_powerpc64_darwin:
  1286. begin
  1287. if not ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED','10.4.0',false) then
  1288. internalerror(2022090911);
  1289. end;
  1290. system_i386_darwin,
  1291. system_x86_64_darwin:
  1292. begin
  1293. if not ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED','10.8.0',false) then
  1294. internalerror(2022090912);
  1295. end;
  1296. system_arm_ios,
  1297. system_i386_iphonesim:
  1298. begin
  1299. if not ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED','9.0.0',false) then
  1300. internalerror(2022090913);
  1301. end;
  1302. system_aarch64_ios,
  1303. system_x86_64_iphonesim:
  1304. begin
  1305. if not ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED','9.0.0',false) then
  1306. internalerror(2022090914);
  1307. end;
  1308. system_aarch64_iphonesim:
  1309. begin
  1310. if not ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED','14.0.0',false) then
  1311. internalerror(2023032201);
  1312. end;
  1313. system_aarch64_darwin:
  1314. begin
  1315. if not ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED','11.0.0',false) then
  1316. internalerror(2022090915);
  1317. end
  1318. else
  1319. internalerror(2012031001);
  1320. end;
  1321. end;
  1322. {$ifdef llvm}
  1323. procedure TOption.LLVMEnableSanitizers(sanitizers: TCmdStr);
  1324. var
  1325. sanitizer: TCMdStr;
  1326. begin
  1327. sanitizer:=GetToken(sanitizers,',');
  1328. repeat
  1329. case sanitizer of
  1330. 'address':
  1331. include(init_settings.moduleswitches,cs_sanitize_address);
  1332. else
  1333. IllegalPara(sanitizer);
  1334. end;
  1335. sanitizer:=GetToken(sanitizers,',');
  1336. until sanitizer='';
  1337. end;
  1338. {$endif}
  1339. {$ifdef XTENSA}
  1340. procedure TOption.MaybeSetIdfVersionMacro;
  1341. begin
  1342. if not(target_info.system=system_xtensa_freertos) then
  1343. exit;
  1344. if IdfVersionSet then
  1345. exit;
  1346. { nothing specified -> defaults }
  1347. case current_settings.controllertype of
  1348. ct_esp8266:
  1349. begin
  1350. set_system_compvar('IDF_VERSION','30300');
  1351. idf_version:=30300;
  1352. end;
  1353. ct_esp32:
  1354. begin
  1355. set_system_compvar('IDF_VERSION','40200');
  1356. idf_version:=40200;
  1357. end;
  1358. else
  1359. begin
  1360. set_system_compvar('IDF_VERSION','00000');
  1361. idf_version:=0;
  1362. end;
  1363. end;
  1364. end;
  1365. {$endif XTENSA}
  1366. procedure TOption.VerifyTargetProcessor;
  1367. begin
  1368. { no custom target processor specified -> ok }
  1369. if processorstr='' then
  1370. exit;
  1371. { custom target processor specified -> verify it's the one we support }
  1372. if upcase(processorstr)<>upcase(target_cpu_string) then
  1373. Message1(option_invalid_target_architecture,processorstr);
  1374. end;
  1375. function Toption.Unsetbool(var Opts:TCmdStr; Pos: Longint; const FullPara: TCmdStr; RequireBoolPara: boolean):boolean;
  1376. { checks if the character after pos in Opts is a + or a - and returns resp.
  1377. false or true. If it is another character (or none), it also returns false }
  1378. begin
  1379. UnsetBool := false;
  1380. if Length(Opts)>Pos then
  1381. begin
  1382. inc(Pos);
  1383. UnsetBool := Opts[Pos] = '-';
  1384. if Opts[Pos] in ['-','+']then
  1385. delete(Opts,Pos,1)
  1386. else if RequireBoolPara then
  1387. IllegalPara(FullPara);
  1388. end;
  1389. end;
  1390. procedure TOption.interpret_option(const opt:TCmdStr;ispara:boolean);
  1391. var
  1392. code : integer;
  1393. c : char;
  1394. {$ifdef cpucapabilities}
  1395. cf : tcpuflags;
  1396. cpuflagsstr,
  1397. extrasettings,
  1398. {$endif cpucapabilities}
  1399. more : TCmdStr;
  1400. major,minor : longint;
  1401. error : integer;
  1402. j,l , deletepos: longint;
  1403. d,s : TCmdStr;
  1404. hs : TCmdStr;
  1405. unicodemapping : punicodemap;
  1406. includecapability: Boolean;
  1407. {$ifdef llvm}
  1408. disable: boolean;
  1409. {$endif}
  1410. begin
  1411. if opt='' then
  1412. exit;
  1413. { only parse define,undef,target,verbosity,link etc options the firsttime
  1414. -Us must now also be first-passed to avoid rejection of -Sf options
  1415. earlier in command line }
  1416. if firstpass and
  1417. not(
  1418. (opt[1]='-') and
  1419. (
  1420. ((length(opt)>1) and (opt[2] in ['i','d','v','T','u','n','X','l','U'])) or
  1421. ((length(opt)>3) and (opt[2]='F') and (opt[3]='e')) or
  1422. ((length(opt)>2) and (opt[2]='C') and (opt[3] in ['a','b','f','p'])) or
  1423. ((length(opt)>3) and (opt[2]='W') and (opt[3] in ['m','p']))
  1424. )
  1425. ) then
  1426. exit;
  1427. Message1(option_handling_option,opt);
  1428. case opt[1] of
  1429. '-' :
  1430. begin
  1431. more:=Copy(opt,3,2147483647);
  1432. if firstpass then
  1433. Message1(option_interpreting_firstpass_option,opt)
  1434. else
  1435. Message1(option_interpreting_option,opt);
  1436. case opt[2] of
  1437. '?' :
  1438. begin
  1439. if (More <> '') and (More [1] = 'F') then
  1440. begin
  1441. FPCHelpLines := true;
  1442. Delete (More, 1, 1);
  1443. FPCBinaryPath := More;
  1444. end;
  1445. WriteHelpPages;
  1446. end;
  1447. 'a' :
  1448. begin
  1449. include(init_settings.globalswitches,cs_asm_leave);
  1450. j:=1;
  1451. while j<=length(more) do
  1452. begin
  1453. case more[j] of
  1454. '5' :
  1455. if (target_info.system in systems_all_windows+systems_nativent-[system_i8086_win16])
  1456. or (target_info.cpu in [cpu_mipseb, cpu_mipsel]) then
  1457. begin
  1458. if UnsetBool(More, j, opt, false) then
  1459. exclude(init_settings.globalswitches,cs_asm_pre_binutils_2_25)
  1460. else
  1461. include(init_settings.globalswitches,cs_asm_pre_binutils_2_25);
  1462. end
  1463. else
  1464. IllegalPara(opt);
  1465. 'l' :
  1466. include(init_settings.globalswitches,cs_asm_source);
  1467. 'r' :
  1468. include(init_settings.globalswitches,cs_asm_regalloc);
  1469. 'R' :
  1470. include(init_settings.globalswitches,cs_asm_rtti_source);
  1471. 't' :
  1472. include(init_settings.globalswitches,cs_asm_tempalloc);
  1473. 'n' :
  1474. include(init_settings.globalswitches,cs_asm_nodes);
  1475. { -ao option must be the last, everything behind it is passed directly to
  1476. external assembler, it is ignored if internal assembler is used. }
  1477. 'o' :
  1478. begin
  1479. asmextraopt:=copy(more,j+1,length(more)-j);
  1480. break;
  1481. end;
  1482. 'p' :
  1483. begin
  1484. exclude(init_settings.globalswitches,cs_asm_leave);
  1485. if UnsetBool(More, 0, opt, false) then
  1486. exclude(init_settings.globalswitches,cs_asm_pipe)
  1487. else
  1488. include(init_settings.globalswitches,cs_asm_pipe);
  1489. end;
  1490. '-' :
  1491. init_settings.globalswitches:=init_settings.globalswitches -
  1492. [cs_asm_leave, cs_asm_source,cs_asm_regalloc, cs_asm_tempalloc,
  1493. cs_asm_nodes, cs_asm_pipe];
  1494. else
  1495. IllegalPara(opt);
  1496. end;
  1497. inc(j);
  1498. end;
  1499. end;
  1500. 'A' :
  1501. begin
  1502. if CompareText(More,'DEFAULT') = 0 then
  1503. paratargetasm:=as_default
  1504. else
  1505. paratargetasm:=find_asm_by_string(More);
  1506. if paratargetasm=as_none then
  1507. IllegalPara(opt);
  1508. end;
  1509. 'b' :
  1510. begin
  1511. // Message1(option_obsolete_switch,'-b');
  1512. if UnsetBool(More,0,opt,false) then
  1513. begin
  1514. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_browser];
  1515. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_local_browser];
  1516. end
  1517. else
  1518. begin
  1519. init_settings.moduleswitches:=init_settings.moduleswitches+[cs_browser];
  1520. end;
  1521. if More<>'' then
  1522. if (More='l') or (More='l+') then
  1523. init_settings.moduleswitches:=init_settings.moduleswitches+[cs_local_browser]
  1524. else if More='l-' then
  1525. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_local_browser]
  1526. else
  1527. IllegalPara(opt);
  1528. end;
  1529. 'B' :
  1530. do_build:=not UnSetBool(more,0,opt,true);
  1531. 'C' :
  1532. begin
  1533. j:=1;
  1534. while j<=length(more) do
  1535. begin
  1536. case more[j] of
  1537. '3' :
  1538. If UnsetBool(More, j, opt, false) then
  1539. exclude(init_settings.localswitches,cs_ieee_errors)
  1540. Else
  1541. include(init_settings.localswitches,cs_ieee_errors);
  1542. 'a' :
  1543. begin
  1544. s:=upper(copy(more,j+1,length(more)-j));
  1545. if not(SetAbiType(s,target_info.abi)) then
  1546. IllegalPara(opt);
  1547. ABISetExplicitly:=true;
  1548. break;
  1549. end;
  1550. 'b' :
  1551. begin
  1552. if UnsetBool(More, j, opt, false) then
  1553. target_info.endian:=endian_little
  1554. else
  1555. target_info.endian:=endian_big;
  1556. set_endianess_macros;
  1557. end;
  1558. 'c' :
  1559. begin
  1560. if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),init_settings.defproccall) then
  1561. IllegalPara(opt);
  1562. break;
  1563. end;
  1564. {$ifdef cpufpemu}
  1565. 'e' :
  1566. begin
  1567. If UnsetBool(More, j, opt, false) then
  1568. exclude(init_settings.moduleswitches,cs_fp_emulation)
  1569. Else
  1570. include(init_settings.moduleswitches,cs_fp_emulation);
  1571. end;
  1572. {$endif cpufpemu}
  1573. 'E' :
  1574. If UnsetBool(More, j, opt, false) then
  1575. exclude(init_settings.localswitches,cs_check_fpu_exceptions)
  1576. Else
  1577. include(init_settings.localswitches,cs_check_fpu_exceptions);
  1578. 'f' :
  1579. begin
  1580. s:=upper(copy(more,j+1,length(more)-j));
  1581. if not(SetFpuType(s,init_settings.fputype)) then
  1582. IllegalPara(opt);
  1583. FPUSetExplicitly:=True;
  1584. break;
  1585. end;
  1586. 'F' :
  1587. begin
  1588. if not SetMinFPConstPrec(copy(more,j+1,length(more)-j),init_settings.minfpconstprec) then
  1589. IllegalPara(opt);
  1590. break;
  1591. end;
  1592. 'g' :
  1593. begin
  1594. if tf_no_pic_supported in target_info.flags then
  1595. begin
  1596. { consume a possible '-' coming after it }
  1597. UnsetBool(More, j, opt, false);
  1598. message(scan_w_pic_ignored);
  1599. end
  1600. else if UnsetBool(More, j, opt, false) then
  1601. exclude(init_settings.moduleswitches,cs_create_pic)
  1602. else
  1603. include(init_settings.moduleswitches,cs_create_pic);
  1604. end;
  1605. 'h' :
  1606. begin
  1607. l:=pos(',',copy(more,j+1,length(more)-j));
  1608. if l=0 then
  1609. l:=length(more)-j+1;
  1610. val(copy(more,j+1,l-1),heapsize,code);
  1611. if (code<>0)
  1612. {$ifdef AVR}
  1613. or (heapsize<32)
  1614. {$else AVR}
  1615. or (heapsize<1024)
  1616. {$endif AVR}
  1617. then
  1618. IllegalPara(opt)
  1619. else if l<=length(more)-j then
  1620. begin
  1621. val(copy(more,j+l+1,length(more)),maxheapsize,code);
  1622. if code<>0 then
  1623. IllegalPara(opt)
  1624. else if (maxheapsize<heapsize) then
  1625. begin
  1626. message(scan_w_heapmax_lessthan_heapmin);
  1627. maxheapsize:=heapsize;
  1628. end;
  1629. end;
  1630. break;
  1631. end;
  1632. 'i' :
  1633. If UnsetBool(More, j, opt, false) then
  1634. exclude(init_settings.localswitches,cs_check_io)
  1635. else
  1636. include(init_settings.localswitches,cs_check_io);
  1637. {$ifdef arm}
  1638. 'I' :
  1639. begin
  1640. if (upper(copy(more,j+1,length(more)-j))='THUMB') and
  1641. { does selected CPU really understand thumb? }
  1642. (init_settings.cputype in cpu_has_thumb) then
  1643. init_settings.instructionset:=is_thumb
  1644. else if upper(copy(more,j+1,length(more)-j))='ARM' then
  1645. init_settings.instructionset:=is_arm
  1646. else
  1647. IllegalPara(opt);
  1648. break;
  1649. end;
  1650. {$endif arm}
  1651. {$ifdef llvm}
  1652. 'l':
  1653. begin
  1654. l:=j+1;
  1655. while l<=length(More) do
  1656. begin
  1657. case More[l] of
  1658. 'f':
  1659. begin
  1660. delete(More,1,l);
  1661. disable:=Unsetbool(More,length(More)-1,opt,false);
  1662. case More of
  1663. 'lto':
  1664. begin
  1665. if not disable then
  1666. begin
  1667. include(init_settings.moduleswitches,cs_lto);
  1668. LTOExt:='.bc';
  1669. end
  1670. else
  1671. exclude(init_settings.moduleswitches,cs_lto);
  1672. end;
  1673. 'ltonosystem':
  1674. begin
  1675. if not disable then
  1676. begin
  1677. include(init_settings.globalswitches,cs_lto_nosystem);
  1678. end
  1679. else
  1680. exclude(init_settings.globalswitches,cs_lto_nosystem);
  1681. end;
  1682. else if More.StartsWith('sanitize=') then
  1683. begin
  1684. delete(More,1,length('sanitize='));
  1685. LLVMEnableSanitizers(more);
  1686. end
  1687. else
  1688. begin
  1689. IllegalPara(opt);
  1690. end;
  1691. end;
  1692. l:=length(more)+1;
  1693. end;
  1694. 'v':
  1695. begin
  1696. init_settings.llvmversion:=llvmversion2enum(copy(More,l+1,length(More)));
  1697. if init_settings.llvmversion=llvmver_invalid then
  1698. begin
  1699. IllegalPara(opt);
  1700. end;
  1701. l:=length(More)+1;
  1702. end
  1703. else
  1704. begin
  1705. IllegalPara(opt);
  1706. end;
  1707. end;
  1708. end;
  1709. j:=l;
  1710. end;
  1711. {$endif llvm}
  1712. 'n' :
  1713. If UnsetBool(More, j, opt, false) then
  1714. exclude(init_settings.globalswitches,cs_link_nolink)
  1715. Else
  1716. include(init_settings.globalswitches,cs_link_nolink);
  1717. 'N' :
  1718. If UnsetBool(More, j, opt, false) then
  1719. exclude(init_settings.localswitches,cs_check_low_addr_load)
  1720. Else
  1721. include(init_settings.localswitches,cs_check_low_addr_load);
  1722. 'o' :
  1723. If UnsetBool(More, j, opt, false) then
  1724. exclude(init_settings.localswitches,cs_check_overflow)
  1725. Else
  1726. include(init_settings.localswitches,cs_check_overflow);
  1727. 'O' :
  1728. If UnsetBool(More, j, opt, false) then
  1729. exclude(init_settings.localswitches,cs_check_ordinal_size)
  1730. Else
  1731. include(init_settings.localswitches,cs_check_ordinal_size);
  1732. 'p' :
  1733. begin
  1734. s:=upper(copy(more,j+1,length(more)-j));
  1735. {$ifdef cpucapabilities}
  1736. { find first occurrence of + or - }
  1737. deletepos:=PosCharset(['+','-'],s);
  1738. if deletepos<>0 then
  1739. begin
  1740. extrasettings:=Copy(s,deletepos,Length(s));
  1741. Delete(s,deletepos,Length(s));
  1742. end
  1743. else
  1744. extrasettings:='';
  1745. {$endif cpucapabilities}
  1746. if not(Setcputype(s,init_settings)) then
  1747. IllegalPara(opt);
  1748. {$ifdef cpucapabilities}
  1749. while extrasettings<>'' do
  1750. begin
  1751. Delete(extrasettings,1,1);
  1752. includecapability:=true;
  1753. deletepos:=PosCharset(['+','-'],extrasettings);
  1754. if deletepos<>0 then
  1755. begin
  1756. includecapability:=extrasettings[deletepos]='+';
  1757. s:=Copy(extrasettings,1,deletepos-1);
  1758. Delete(extrasettings,1,deletepos-1);
  1759. end
  1760. else
  1761. begin
  1762. s:=extrasettings;
  1763. extrasettings:='';
  1764. end;
  1765. for cf in tcpuflags do
  1766. begin
  1767. Str(cf,cpuflagsstr);
  1768. { expect that the cpuflagsstr i.e. the enum as well contains _HAS_ }
  1769. if Pos('_HAS_',cpuflagsstr)<>0 then
  1770. { get rid of prefix including _HAS_ }
  1771. Delete(cpuflagsstr,1,Pos('_HAS_',cpuflagsstr)+4)
  1772. else
  1773. Internalerror(2021110601);
  1774. if s=cpuflagsstr then
  1775. begin
  1776. if includecapability then
  1777. Include(cpu_capabilities[init_settings.cputype],cf)
  1778. else
  1779. Exclude(cpu_capabilities[init_settings.cputype],cf);
  1780. s:='';
  1781. break;
  1782. end;
  1783. end;
  1784. if s<>'' then
  1785. IllegalPara(opt);
  1786. end;
  1787. {$endif cpucapabilities}
  1788. CPUSetExplicitly:=true;
  1789. break;
  1790. end;
  1791. 'P':
  1792. begin
  1793. delete(more,1,1);
  1794. case upper(copy(more,1,pos('=',more)-1)) of
  1795. 'PACKSET':
  1796. begin
  1797. delete(more,1,pos('=',more));
  1798. case more of
  1799. '0','DEFAULT','NORMAL':
  1800. init_settings.setalloc:=0;
  1801. '1','2','4','8':
  1802. init_settings.setalloc:=StrToInt(more);
  1803. else
  1804. IllegalPara(opt);
  1805. end
  1806. end;
  1807. 'PACKENUM':
  1808. begin
  1809. delete(more,1,pos('=',more));
  1810. case more of
  1811. '0','DEFAULT','NORMAL':
  1812. init_settings.packenum:=4;
  1813. '1','2','4':
  1814. init_settings.packenum:=StrToInt(more);
  1815. else
  1816. IllegalPara(opt);
  1817. end;
  1818. end;
  1819. 'PACKRECORD':
  1820. begin
  1821. delete(more,1,pos('=',more));
  1822. case more of
  1823. '0','DEFAULT','NORMAL':
  1824. init_settings.packrecords:=default_settings.packrecords;
  1825. '1','2','4','8','16','32':
  1826. init_settings.packrecords:=StrToInt(more);
  1827. else
  1828. IllegalPara(opt);
  1829. end;
  1830. end
  1831. else
  1832. IllegalPara(opt);
  1833. end;
  1834. end;
  1835. 'r' :
  1836. If UnsetBool(More, j, opt, false) then
  1837. exclude(init_settings.localswitches,cs_check_range)
  1838. Else
  1839. include(init_settings.localswitches,cs_check_range);
  1840. 'R' :
  1841. If UnsetBool(More, j, opt, false) then
  1842. begin
  1843. exclude(init_settings.localswitches,cs_check_range);
  1844. exclude(init_settings.localswitches,cs_check_object);
  1845. end
  1846. Else
  1847. begin
  1848. include(init_settings.localswitches,cs_check_range);
  1849. include(init_settings.localswitches,cs_check_object);
  1850. end;
  1851. 's' :
  1852. begin
  1853. val(copy(more,j+1,length(more)-j),stacksize,code);
  1854. if (code<>0)
  1855. {$ifdef cpu16bitaddr}
  1856. or (stacksize>=65521)
  1857. {$else cpu16bitaddr}
  1858. or (stacksize>=67107840)
  1859. {$endif cpu16bitaddr}
  1860. or (stacksize<1024) then
  1861. IllegalPara(opt);
  1862. break;
  1863. end;
  1864. 't' :
  1865. If UnsetBool(More, j, opt, false) then
  1866. exclude(init_settings.localswitches,cs_check_stack)
  1867. Else
  1868. include(init_settings.localswitches,cs_check_stack);
  1869. 'D' :
  1870. If UnsetBool(More, j, opt, false) then
  1871. exclude(init_settings.moduleswitches,cs_create_dynamic)
  1872. Else
  1873. include(init_settings.moduleswitches,cs_create_dynamic);
  1874. 'X' :
  1875. If UnsetBool(More, j, opt, false) then
  1876. exclude(init_settings.moduleswitches,cs_create_smart)
  1877. Else
  1878. include(init_settings.moduleswitches,cs_create_smart);
  1879. 'T' :
  1880. begin
  1881. if not UpdateTargetSwitchStr(copy(more,j+1,length(more)),init_settings.targetswitches,true) then
  1882. IllegalPara(opt);
  1883. break;
  1884. end;
  1885. 'v' :
  1886. If target_info.system in systems_jvm then
  1887. If UnsetBool(More, j, opt, false) then
  1888. exclude(init_settings.localswitches,cs_check_var_copyout)
  1889. Else
  1890. include(init_settings.localswitches,cs_check_var_copyout)
  1891. else
  1892. IllegalPara(opt);
  1893. 'V':
  1894. begin
  1895. s:=upper(copy(more,j+1,length(more)-j));
  1896. if s='GLOBAL-DYNAMIC' then
  1897. init_settings.tlsmodel:=tlsm_global_dynamic
  1898. else if s='LOCAL-EXEC' then
  1899. init_settings.tlsmodel:=tlsm_local_exec
  1900. else
  1901. IllegalPara(opt);
  1902. break;
  1903. end;
  1904. else
  1905. IllegalPara(opt);
  1906. end;
  1907. inc(j);
  1908. end;
  1909. end;
  1910. 'd' :
  1911. begin
  1912. l:=Pos(':=',more);
  1913. DefaultReplacements(more);
  1914. if l>0 then
  1915. hs:=copy(more,1,l-1)
  1916. else
  1917. hs:=more;
  1918. if (not is_identifier(hs)) then
  1919. begin
  1920. if hs='' then
  1921. Message1(option_missing_arg,'-d')
  1922. else
  1923. Message1(option_malformed_para,opt);
  1924. StopOptions(1);
  1925. end;
  1926. if l>0 then
  1927. begin
  1928. if cs_support_macro in init_settings.moduleswitches then
  1929. set_system_macro(hs,Copy(more,l+2,255))
  1930. else
  1931. set_system_compvar(hs,Copy(more,l+2,255));
  1932. end
  1933. else
  1934. def_system_macro(hs);
  1935. end;
  1936. 'D' :
  1937. begin
  1938. j:=1;
  1939. while j<=length(more) do
  1940. begin
  1941. case more[j] of
  1942. 'd' :
  1943. begin
  1944. include(init_settings.globalswitches,cs_link_deffile);
  1945. description:=Copy(more,j+1,255);
  1946. break;
  1947. end;
  1948. 'D' :
  1949. begin
  1950. datestr:=Copy(more,j+1,255);
  1951. break;
  1952. end;
  1953. 'T' :
  1954. begin
  1955. timestr:=Copy(more,j+1,255);
  1956. break;
  1957. end;
  1958. 'v' :
  1959. begin
  1960. include(init_settings.globalswitches,cs_link_deffile);
  1961. dllversion:=Copy(more,j+1,255);
  1962. l:=pos('.',dllversion);
  1963. dllminor:=0;
  1964. error:=0;
  1965. if l>0 then
  1966. begin
  1967. val(copy(dllversion,l+1,255),minor,error);
  1968. if (error=0) and
  1969. (minor>=0) and (minor<=$ffff) then
  1970. dllminor:=minor
  1971. else
  1972. if error=0 then
  1973. error:=1;
  1974. end;
  1975. if l=0 then
  1976. l:=256;
  1977. dllmajor:=1;
  1978. major:=0;
  1979. if error=0 then
  1980. val(copy(dllversion,1,l-1),major,error);
  1981. if (error=0) and (major>=0) and (major<=$ffff) then
  1982. dllmajor:=major
  1983. else
  1984. if error=0 then
  1985. error:=1;
  1986. if error<>0 then
  1987. Message1(scan_w_wrong_version_ignored,dllversion);
  1988. break;
  1989. end;
  1990. 'w' :
  1991. begin
  1992. include(init_settings.globalswitches,cs_link_deffile);
  1993. usewindowapi:=true;
  1994. end;
  1995. '-' :
  1996. begin
  1997. exclude(init_settings.globalswitches,cs_link_deffile);
  1998. usewindowapi:=false;
  1999. end;
  2000. else
  2001. IllegalPara(opt);
  2002. end;
  2003. inc(j);
  2004. end;
  2005. end;
  2006. 'e' :
  2007. exepath:=FixPath(More,true);
  2008. 'E' :
  2009. begin
  2010. if UnsetBool(More, 0, opt, true) then
  2011. exclude(init_settings.globalswitches,cs_link_nolink)
  2012. else
  2013. include(init_settings.globalswitches,cs_link_nolink);
  2014. end;
  2015. 'f' :
  2016. begin
  2017. if more='PIC' then
  2018. begin
  2019. if tf_no_pic_supported in target_info.flags then
  2020. message(scan_w_pic_ignored)
  2021. else
  2022. include(init_settings.moduleswitches,cs_create_pic)
  2023. end
  2024. else
  2025. IllegalPara(opt);
  2026. end;
  2027. 'F' :
  2028. begin
  2029. if more='' then
  2030. IllegalPara(opt);
  2031. c:=more[1];
  2032. Delete(more,1,1);
  2033. DefaultReplacements(More);
  2034. case c of
  2035. 'a' :
  2036. autoloadunits:=more;
  2037. 'c' :
  2038. begin
  2039. { if we first specify that the system code page should be
  2040. used and then explicitly specify a code page, unset the
  2041. flag that we're using the system code page again }
  2042. SetCompileModeSwitch('SYSTEMCODEPAGE-',true);
  2043. if (upper(more)='UTF8') or (upper(more)='UTF-8') then
  2044. init_settings.sourcecodepage:=CP_UTF8
  2045. else if not(cpavailable(more)) then
  2046. Message1(option_code_page_not_available,more)
  2047. else
  2048. init_settings.sourcecodepage:=codepagebyname(more);
  2049. include(init_settings.moduleswitches,cs_explicit_codepage);
  2050. end;
  2051. 'C' :
  2052. RCCompiler:=More;
  2053. 'd' :
  2054. if UnsetBool(more, 0, opt, true) then
  2055. init_settings.disabledircache:=false
  2056. else
  2057. init_settings.disabledircache:=true;
  2058. 'D' :
  2059. utilsdirectory:=FixPath(More,true);
  2060. 'e' :
  2061. SetRedirectFile(More);
  2062. 'E' :
  2063. OutputExeDir:=FixPath(More,true);
  2064. 'f' :
  2065. if (target_info.system in systems_darwin) then
  2066. if ispara then
  2067. ParaFrameworkPath.AddPath(More,false)
  2068. else
  2069. frameworksearchpath.AddPath(More,true)
  2070. {$if defined(XTENSA) or defined(RISCV32)}
  2071. else if (target_info.system=system_xtensa_freertos) then
  2072. idfpath:=FixPath(More,true)
  2073. {$endif defined(XTENSA) or defined(RISCV32)}
  2074. else
  2075. IllegalPara(opt);
  2076. 'F' :
  2077. RCForceFPCRes:=true;
  2078. 'i' :
  2079. begin
  2080. if ispara then
  2081. ParaIncludePath.AddPath(More,false)
  2082. else
  2083. includesearchpath.AddPath(More,true);
  2084. end;
  2085. 'm' :
  2086. begin
  2087. s:=ExtractFileDir(more);
  2088. if TryStrToInt(ExtractFileName(more),j) then
  2089. begin
  2090. unicodemapping:=loadunicodemapping(More,More+'.txt',j);
  2091. if assigned(unicodemapping) then
  2092. registermapping(unicodemapping)
  2093. else
  2094. IllegalPara(opt);
  2095. end
  2096. else
  2097. IllegalPara(opt);
  2098. end;
  2099. 'M' :
  2100. unicodepath:=FixPath(More,true);
  2101. 'g' :
  2102. Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  2103. 'l' :
  2104. begin
  2105. if ispara then
  2106. ParaLibraryPath.AddLibraryPath(sysrootpath,More,false)
  2107. else
  2108. LibrarySearchPath.AddLibraryPath(sysrootpath,More,true)
  2109. end;
  2110. 'L' :
  2111. begin
  2112. if More<>'' then
  2113. ParaDynamicLinker:=More
  2114. else
  2115. IllegalPara(opt);
  2116. end;
  2117. 'N' :
  2118. begin
  2119. if more<>'' then
  2120. paranamespaces.insert(more)
  2121. else
  2122. illegalpara(opt);
  2123. end;
  2124. 'o' :
  2125. begin
  2126. if ispara then
  2127. ParaObjectPath.AddPath(More,false)
  2128. else
  2129. ObjectSearchPath.AddPath(More,true);
  2130. end;
  2131. 'P' :
  2132. begin
  2133. if ispara then
  2134. parapackages.add(more,nil)
  2135. else
  2136. add_package(more,true,true);
  2137. end;
  2138. 'p' :
  2139. begin
  2140. if ispara then
  2141. parapackagepath.AddPath(More,false)
  2142. else
  2143. packagesearchpath.AddPath(More,true);
  2144. end;
  2145. 'r' :
  2146. Msgfilename:=More;
  2147. 'R' :
  2148. ResCompiler:=More;
  2149. 'u' :
  2150. begin
  2151. if ispara then
  2152. ParaUnitPath.AddPath(More,false)
  2153. else
  2154. unitsearchpath.AddPath(More,true);
  2155. end;
  2156. 'U' :
  2157. OutputUnitDir:=FixPath(More,true);
  2158. 'W',
  2159. 'w':
  2160. begin
  2161. if More<>'' then
  2162. begin
  2163. DefaultReplacements(More);
  2164. D:=ExtractFilePath(More);
  2165. if (D<>'') then
  2166. D:=FixPath(D,True);
  2167. D:=D+ExtractFileName(More);
  2168. if (c='W') then
  2169. WpoFeedbackOutput:=D
  2170. else
  2171. WpoFeedbackInput:=D;
  2172. end
  2173. else
  2174. IllegalPara(opt);
  2175. end;
  2176. else
  2177. IllegalPara(opt);
  2178. end;
  2179. end;
  2180. 'g' :
  2181. begin
  2182. if UnsetBool(More, 0, opt, false) then
  2183. begin
  2184. exclude(init_settings.moduleswitches,cs_debuginfo);
  2185. exclude(init_settings.globalswitches,cs_use_heaptrc);
  2186. exclude(init_settings.globalswitches,cs_use_lineinfo);
  2187. exclude(init_settings.localswitches,cs_checkpointer);
  2188. paratargetdbg:=dbg_none;
  2189. localvartrashing := -1;
  2190. end
  2191. else
  2192. begin
  2193. include(init_settings.moduleswitches,cs_debuginfo);
  2194. if paratargetdbg=dbg_none then
  2195. paratargetdbg:=target_info.dbg;
  2196. end;
  2197. if not RelocSectionSetExplicitly then
  2198. RelocSection:=false;
  2199. j:=1;
  2200. while j<=length(more) do
  2201. begin
  2202. case more[j] of
  2203. 'c' :
  2204. begin
  2205. if UnsetBool(More, j, opt, false) then
  2206. exclude(init_settings.localswitches,cs_checkpointer)
  2207. else if (target_info.system in systems_support_checkpointer) then
  2208. begin
  2209. if do_release then
  2210. Message(option_gc_incompatible_with_release_flag)
  2211. else
  2212. include(init_settings.localswitches,cs_checkpointer);
  2213. end
  2214. else
  2215. UnsupportedPara('-gc');
  2216. end;
  2217. 'h' :
  2218. begin
  2219. if UnsetBool(More, j, opt, false) then
  2220. exclude(init_settings.globalswitches,cs_use_heaptrc)
  2221. else
  2222. begin
  2223. if cs_gdb_valgrind in init_settings.globalswitches then
  2224. Message2(option_valgrind_heaptrc_mismatch,'-gh', '-gv');
  2225. include(init_settings.globalswitches,cs_use_heaptrc);
  2226. end;
  2227. end;
  2228. 'l' :
  2229. begin
  2230. if UnsetBool(More, j, opt, false) then
  2231. exclude(init_settings.globalswitches,cs_use_lineinfo)
  2232. else
  2233. include(init_settings.globalswitches,cs_use_lineinfo);
  2234. end;
  2235. 'm' :
  2236. begin
  2237. paratargetdbg:=dbg_codeview;
  2238. end;
  2239. 'o' :
  2240. begin
  2241. if not UpdateDebugStr(copy(more,j+1,length(more)),init_settings.debugswitches) then
  2242. IllegalPara(opt);
  2243. break;
  2244. end;
  2245. 'p' :
  2246. begin
  2247. if UnsetBool(More, j, opt, false) then
  2248. exclude(init_settings.globalswitches,cs_stabs_preservecase)
  2249. else
  2250. include(init_settings.globalswitches,cs_stabs_preservecase);
  2251. end;
  2252. 's' :
  2253. begin
  2254. paratargetdbg:=dbg_stabs;
  2255. end;
  2256. 't' :
  2257. begin
  2258. if UnsetBool(More, j, opt, false) then
  2259. localvartrashing := -1
  2260. else
  2261. localvartrashing := (localvartrashing + 1) mod nroftrashvalues;
  2262. end;
  2263. 'v' :
  2264. begin
  2265. if UnsetBool(More, j, opt, false) then
  2266. exclude(init_settings.globalswitches,cs_gdb_valgrind)
  2267. else
  2268. begin
  2269. if cs_use_heaptrc in init_settings.globalswitches then
  2270. Message2(option_valgrind_heaptrc_mismatch,'-gh', '-gv');
  2271. include(init_settings.globalswitches,cs_gdb_valgrind);
  2272. end;
  2273. end;
  2274. 'w' :
  2275. begin
  2276. if (j<length(more)) and (more[j+1] in ['2','3','4']) then
  2277. begin
  2278. case more[j+1] of
  2279. '2': paratargetdbg:=dbg_dwarf2;
  2280. '3': paratargetdbg:=dbg_dwarf3;
  2281. '4': paratargetdbg:=dbg_dwarf4;
  2282. end;
  2283. inc(j);
  2284. end
  2285. else
  2286. paratargetdbg:=dbg_dwarf2;
  2287. end;
  2288. else
  2289. IllegalPara(opt);
  2290. end;
  2291. inc(j);
  2292. end;
  2293. end;
  2294. 'h' :
  2295. begin
  2296. NoPressEnter:=true;
  2297. if (More <> '') and (More [1] = 'F') then
  2298. begin
  2299. FPCHelpLines := true;
  2300. Delete (More, 1, 1);
  2301. FPCBinaryPath := More;
  2302. end;
  2303. WriteHelpPages;
  2304. end;
  2305. 'i' :
  2306. begin
  2307. if (More='') or
  2308. (More [1] in ['a', 'b', 'c', 'f', 'i', {$ifdef LLVM}'l',{$endif} 'm', 'o', 'r', 't', 'u', 'w', 'x']) then
  2309. WriteInfo (More)
  2310. else
  2311. QuickInfo:=QuickInfo+More;
  2312. end;
  2313. 'I' :
  2314. begin
  2315. if ispara then
  2316. ParaIncludePath.AddPath(More,false)
  2317. else
  2318. includesearchpath.AddPath(More,false);
  2319. end;
  2320. 'k' :
  2321. begin
  2322. if more<>'' then
  2323. ParaLinkOptions:=ParaLinkOptions+' '+More
  2324. else
  2325. IllegalPara(opt);
  2326. end;
  2327. 'l' :
  2328. ParaLogo:=not UnSetBool(more,0,opt,true);
  2329. {$ifdef PREPROCWRITE}
  2330. 'm' :
  2331. parapreprocess:=not UnSetBool(more,0,opt,true);
  2332. {$endif PREPROCWRITE}
  2333. 'M' :
  2334. begin
  2335. more:=Upper(more);
  2336. if not SetCompileMode(more, true) then
  2337. if not SetCompileModeSwitch(more, true) then
  2338. IllegalPara(opt);
  2339. end;
  2340. 'n' :
  2341. begin
  2342. if More='' then
  2343. disable_configfile:=true
  2344. else
  2345. IllegalPara(opt);
  2346. end;
  2347. 'o' :
  2348. begin
  2349. if More<>'' then
  2350. begin
  2351. DefaultReplacements(More);
  2352. D:=ExtractFilePath(More);
  2353. if (D<>'') then
  2354. OutputExeDir:=FixPath(D,True);
  2355. OutputFileName:=ExtractFileName(More);
  2356. end
  2357. else
  2358. IllegalPara(opt);
  2359. end;
  2360. 'O' :
  2361. begin
  2362. j:=1;
  2363. while j<=length(more) do
  2364. begin
  2365. case more[j] of
  2366. '1' :
  2367. init_settings.optimizerswitches:=init_settings.optimizerswitches+level1optimizerswitches;
  2368. '2' :
  2369. init_settings.optimizerswitches:=init_settings.optimizerswitches+level2optimizerswitches;
  2370. '3' :
  2371. init_settings.optimizerswitches:=init_settings.optimizerswitches+level3optimizerswitches;
  2372. '4' :
  2373. init_settings.optimizerswitches:=init_settings.optimizerswitches+level4optimizerswitches;
  2374. 'a' :
  2375. begin
  2376. if not(UpdateAlignmentStr(Copy(Opt,j+3,255),ParaAlignment)) then
  2377. IllegalPara(opt);
  2378. break;
  2379. end;
  2380. 's' :
  2381. include(init_settings.optimizerswitches,cs_opt_size);
  2382. 'p' :
  2383. begin
  2384. if not Setoptimizecputype(copy(more,j+1,length(more)),init_settings.optimizecputype) then
  2385. begin
  2386. OptCPUSetExplicitly:=true;
  2387. { Give warning for old i386 switches }
  2388. if (Length(More)-j=1) and
  2389. (More[j+1]>='1') and (More[j+1]<='5')then
  2390. Message2(option_obsolete_switch_use_new,'-Op<nr>','-Op<name>')
  2391. else
  2392. IllegalPara(opt);
  2393. end;
  2394. break;
  2395. end;
  2396. 'o' :
  2397. begin
  2398. if not UpdateOptimizerStr(copy(more,j+1,length(more)),init_settings.optimizerswitches) then
  2399. IllegalPara(opt);
  2400. break;
  2401. end;
  2402. '-' :
  2403. begin
  2404. init_settings.optimizerswitches:=[];
  2405. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  2406. end;
  2407. { Obsolete switches }
  2408. 'g' :
  2409. Message2(option_obsolete_switch_use_new,'-Og','-Os');
  2410. 'G' :
  2411. Message1(option_obsolete_switch,'-OG');
  2412. 'r' :
  2413. Message2(option_obsolete_switch_use_new,'-Or','-O2 or -Ooregvar');
  2414. 'u' :
  2415. Message2(option_obsolete_switch_use_new,'-Ou','-Oouncertain');
  2416. 'w' :
  2417. begin
  2418. if not UpdateWpoStr(copy(more,j+1,length(more)),init_settings.dowpoptimizerswitches) then
  2419. IllegalPara(opt);
  2420. break;
  2421. end;
  2422. 'W' :
  2423. begin
  2424. if not UpdateWpoStr(copy(more,j+1,length(more)),init_settings.genwpoptimizerswitches) then
  2425. IllegalPara(opt);
  2426. break;
  2427. end;
  2428. else
  2429. IllegalPara(opt);
  2430. end;
  2431. inc(j);
  2432. end;
  2433. end;
  2434. 'p' :
  2435. begin
  2436. if UnsetBool(More, 0, opt, false) then
  2437. begin
  2438. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_profile];
  2439. undef_system_macro('FPC_PROFILE');
  2440. end
  2441. else
  2442. if Length(More)=0 then
  2443. IllegalPara(opt)
  2444. else
  2445. case more[1] of
  2446. 'g' : if UnsetBool(more, 1, opt, false) then
  2447. begin
  2448. exclude(init_settings.moduleswitches,cs_profile);
  2449. undef_system_macro('FPC_PROFILE');
  2450. end
  2451. else if (target_info.system in supported_targets_pg) then
  2452. begin
  2453. include(init_settings.moduleswitches,cs_profile);
  2454. def_system_macro('FPC_PROFILE');
  2455. end
  2456. else
  2457. UnsupportedPara('-pg');
  2458. else
  2459. IllegalPara(opt);
  2460. end;
  2461. end;
  2462. 'P' :
  2463. begin
  2464. { used to select the target processor with the "fpc" binary;
  2465. give an error if it's not the target architecture supported by
  2466. this compiler binary (will be verified after the target_info
  2467. is set) }
  2468. processorstr:=More;
  2469. end;
  2470. 'R' :
  2471. begin
  2472. if not SetAsmReadMode(More,init_settings.asmmode) then
  2473. IllegalPara(opt);
  2474. end;
  2475. 's' :
  2476. begin
  2477. if UnsetBool(More, 0, opt, false) then
  2478. begin
  2479. init_settings.globalswitches:=init_settings.globalswitches-[cs_asm_extern,cs_link_extern,cs_link_nolink];
  2480. if more<>'' then
  2481. IllegalPara(opt);
  2482. end
  2483. else
  2484. begin
  2485. init_settings.globalswitches:=init_settings.globalswitches+[cs_asm_extern,cs_link_extern,cs_link_nolink];
  2486. if more='h' then
  2487. init_settings.globalswitches:=init_settings.globalswitches-[cs_link_on_target,cs_assemble_on_target]
  2488. else if more='t' then
  2489. init_settings.globalswitches:=init_settings.globalswitches+[cs_link_on_target,cs_assemble_on_target]
  2490. else if more='T' then
  2491. init_settings.globalswitches:=init_settings.globalswitches+[cs_link_on_target]-[cs_asm_extern]
  2492. else if more='r' then
  2493. init_settings.globalswitches:=init_settings.globalswitches+[cs_asm_leave,cs_no_regalloc]
  2494. else if more<>'' then
  2495. IllegalPara(opt);
  2496. end;
  2497. end;
  2498. 'S' :
  2499. begin
  2500. if more='' then
  2501. IllegalPara(opt);
  2502. if more[1]='I' then
  2503. begin
  2504. {$ifdef jvm}
  2505. UnsupportedPara('-SI');
  2506. {$endif}
  2507. if upper(more)='ICOM' then
  2508. init_settings.interfacetype:=it_interfacecom
  2509. else if upper(more)='ICORBA' then
  2510. init_settings.interfacetype:=it_interfacecorba
  2511. else
  2512. IllegalPara(opt);
  2513. end
  2514. else
  2515. begin
  2516. j:=1;
  2517. while j<=length(more) do
  2518. begin
  2519. case more[j] of
  2520. '2' : //an alternative to -Mobjfpc
  2521. SetCompileMode('OBJFPC',true);
  2522. 'a' :
  2523. If UnsetBool(More, j, opt, false) then
  2524. exclude(init_settings.localswitches,cs_do_assertion)
  2525. else
  2526. include(init_settings.localswitches,cs_do_assertion);
  2527. 'c' :
  2528. If UnsetBool(More, j, opt, false) then
  2529. exclude(init_settings.moduleswitches,cs_support_c_operators)
  2530. else
  2531. include(init_settings.moduleswitches,cs_support_c_operators);
  2532. 'C':
  2533. If UnsetBool(More, j, opt, false) then
  2534. exclude(init_settings.localswitches,cs_check_all_case_coverage)
  2535. else
  2536. include(init_settings.localswitches,cs_check_all_case_coverage);
  2537. 'd' : //an alternative to -Mdelphi
  2538. SetCompileMode('DELPHI',true);
  2539. 'e' :
  2540. begin
  2541. SetErrorFlags(copy(more,j+1,length(more)));
  2542. break;
  2543. end;
  2544. 'f' :
  2545. begin
  2546. if not(cs_compilesystem in init_settings.moduleswitches) then
  2547. Message(option_features_only_for_system_unit);
  2548. inc(j);
  2549. if more[j]='-' then
  2550. begin
  2551. if length(more)>j then
  2552. IllegalPara(opt)
  2553. else
  2554. features:=[];
  2555. end
  2556. else
  2557. begin
  2558. if (HandleFeature(upper(copy(more,j,length(more)-j+1)))) then
  2559. j:=length(more)
  2560. else
  2561. IllegalPara(opt);
  2562. end;
  2563. end;
  2564. 'g' :
  2565. If UnsetBool(More, j, opt, false) then
  2566. exclude(init_settings.moduleswitches,cs_support_goto)
  2567. else
  2568. include(init_settings.moduleswitches,cs_support_goto);
  2569. 'h' :
  2570. If UnsetBool(More, j, opt, false) then
  2571. exclude(init_settings.localswitches,cs_refcountedstrings)
  2572. else
  2573. include(init_settings.localswitches,cs_refcountedstrings);
  2574. 'i' :
  2575. If UnsetBool(More, j, opt, false) then
  2576. exclude(init_settings.localswitches,cs_do_inline)
  2577. else
  2578. include(init_settings.localswitches,cs_do_inline);
  2579. 'j' :
  2580. If UnsetBool(More, j, opt, false) then
  2581. exclude(init_settings.localswitches,cs_typed_const_writable)
  2582. else
  2583. include(init_settings.localswitches,cs_typed_const_writable);
  2584. 'k' :
  2585. If UnsetBool(More, j, opt, false) then
  2586. exclude(init_settings.globalswitches,cs_load_fpcylix_unit)
  2587. else
  2588. include(init_settings.globalswitches,cs_load_fpcylix_unit);
  2589. 'm' :
  2590. If UnsetBool(More, j, opt, false) then
  2591. exclude(init_settings.moduleswitches,cs_support_macro)
  2592. else
  2593. include(init_settings.moduleswitches,cs_support_macro);
  2594. 'o' : //an alternative to -Mtp
  2595. SetCompileMode('TP',true);
  2596. 'r' :
  2597. If UnsetBool(More, j, opt, false) then
  2598. exclude(init_settings.globalswitches,cs_transparent_file_names)
  2599. else
  2600. include(init_settings.globalswitches,cs_transparent_file_names);
  2601. {$ifdef gpc_mode}
  2602. 'p' : //an alternative to -Mgpc
  2603. SetCompileMode('GPC',true);
  2604. {$endif}
  2605. 's' :
  2606. If UnsetBool(More, j, opt, false) then
  2607. exclude(init_settings.globalswitches,cs_constructor_name)
  2608. else
  2609. include(init_settings.globalswitches,cs_constructor_name);
  2610. 't' :
  2611. Message1(option_obsolete_switch,'-St');
  2612. 'v' :
  2613. If UnsetBool(More, j, opt, false) then
  2614. exclude(init_settings.globalswitches,cs_support_vectors)
  2615. else
  2616. include(init_settings.globalswitches,cs_support_vectors);
  2617. 'x' :
  2618. If UnsetBool(More, j, opt, false) then
  2619. SetCompileModeSwitch('EXCEPTIONS-',true)
  2620. else
  2621. SetCompileModeSwitch('EXCEPTIONS',true);
  2622. 'y' :
  2623. If UnsetBool(More, j, opt, false) then
  2624. exclude(init_settings.localswitches,cs_typed_addresses)
  2625. else
  2626. include(init_settings.localswitches,cs_typed_addresses);
  2627. '-' :
  2628. begin
  2629. init_settings.globalswitches:=init_settings.globalswitches - [cs_constructor_name,cs_support_exceptions,
  2630. cs_support_vectors,cs_load_fpcylix_unit];
  2631. init_settings.localswitches:=init_settings.localswitches - [cs_do_assertion,cs_do_inline, cs_refcountedstrings,
  2632. cs_typed_addresses];
  2633. init_settings.moduleswitches:=init_settings.moduleswitches - [cs_support_c_operators, cs_support_goto,
  2634. cs_support_macro];
  2635. end;
  2636. else
  2637. IllegalPara(opt);
  2638. end;
  2639. inc(j);
  2640. end;
  2641. end;
  2642. end;
  2643. 'T' :
  2644. begin
  2645. more:=Upper(More);
  2646. if paratarget=system_none then
  2647. begin
  2648. { remove old target define }
  2649. TargetOptions(false);
  2650. { load new target }
  2651. paratarget:=find_system_by_string(More);
  2652. if paratarget<>system_none then
  2653. set_target(paratarget)
  2654. else
  2655. IllegalPara(opt);
  2656. { set new define }
  2657. TargetOptions(true);
  2658. end
  2659. else
  2660. if More<>upper(target_info.shortname) then
  2661. Message1(option_target_is_already_set,target_info.shortname);
  2662. end;
  2663. 'u' :
  2664. if is_identifier(more) then
  2665. undef_system_macro(more)
  2666. else
  2667. begin
  2668. if (more='') then
  2669. Message1(option_missing_arg,'-u')
  2670. else
  2671. Message1(option_malformed_para,opt);
  2672. StopOptions(1);
  2673. end;
  2674. 'U' :
  2675. begin
  2676. j:=1;
  2677. while j<=length(more) do
  2678. begin
  2679. case more[j] of
  2680. {$ifdef UNITALIASES}
  2681. 'a' :
  2682. begin
  2683. AddUnitAlias(Copy(More,j+1,255));
  2684. break;
  2685. end;
  2686. {$endif UNITALIASES}
  2687. 'n' :
  2688. exclude(init_settings.globalswitches,cs_check_unit_name);
  2689. 'p' :
  2690. begin
  2691. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  2692. break;
  2693. end;
  2694. 'r' :
  2695. begin
  2696. do_release:=true;
  2697. if (cs_checkpointer in init_settings.localswitches) then
  2698. begin
  2699. Message(option_gc_incompatible_with_release_flag);
  2700. exclude(init_settings.localswitches,cs_checkpointer);
  2701. end;
  2702. end;
  2703. 's' :
  2704. include(init_settings.moduleswitches,cs_compilesystem);
  2705. '-' :
  2706. begin
  2707. exclude(init_settings.moduleswitches,cs_compilesystem);
  2708. exclude(init_settings.globalswitches,cs_check_unit_name);
  2709. end;
  2710. else
  2711. IllegalPara(opt);
  2712. end;
  2713. inc(j);
  2714. end;
  2715. end;
  2716. 'v' :
  2717. begin
  2718. if not setverbosity(More) then
  2719. IllegalPara(opt);
  2720. end;
  2721. 'V' : ; { Ignore used by fpc }
  2722. 'W' :
  2723. begin
  2724. j:=1;
  2725. while j<=length(More) do
  2726. begin
  2727. case More[j] of
  2728. 'A':
  2729. begin
  2730. if target_info.system in systems_all_windows then
  2731. begin
  2732. if UnsetBool(More, j, opt, false) then
  2733. SetApptype(app_cui)
  2734. else
  2735. SetApptype(app_native);
  2736. end
  2737. else
  2738. IllegalPara(opt);
  2739. end;
  2740. 'b':
  2741. begin
  2742. if target_info.system in systems_darwin then
  2743. begin
  2744. if UnsetBool(More, j, opt, false) then
  2745. SetApptype(app_cui)
  2746. else
  2747. SetApptype(app_bundle)
  2748. end
  2749. else
  2750. IllegalPara(opt);
  2751. end;
  2752. 'B':
  2753. begin
  2754. if target_info.system in systems_all_windows+systems_symbian+[system_z80_zxspectrum] then
  2755. begin
  2756. { -WB200000 means set trefered base address
  2757. to $200000, but does not change relocsection boolean
  2758. this way we can create both relocatble and
  2759. non relocatable DLL at a specific base address PM }
  2760. if (length(More)>j) then
  2761. begin
  2762. val('$'+Copy(More,j+1,255),imagebase,code);
  2763. if code<>0 then
  2764. IllegalPara(opt);
  2765. ImageBaseSetExplicity:=true;
  2766. end
  2767. else
  2768. begin
  2769. RelocSection:=true;
  2770. RelocSectionSetExplicitly:=true;
  2771. end;
  2772. break;
  2773. end
  2774. else
  2775. IllegalPara(opt);
  2776. end;
  2777. 'C':
  2778. begin
  2779. if target_info.system in systems_all_windows+systems_os2+systems_macos then
  2780. begin
  2781. if UnsetBool(More, j, opt, false) then
  2782. SetApptype(app_gui)
  2783. else
  2784. SetApptype(app_cui);
  2785. end
  2786. else
  2787. IllegalPara(opt);
  2788. end;
  2789. 'D':
  2790. begin
  2791. if target_info.system in systems_all_windows then
  2792. begin
  2793. UseDeffileForExports:=not UnsetBool(More, j, opt, false);
  2794. UseDeffileForExportsSetExplicitly:=true;
  2795. end
  2796. else
  2797. IllegalPara(opt);
  2798. end;
  2799. 'e':
  2800. begin
  2801. if (target_info.system in systems_darwin) then
  2802. begin
  2803. set_target_res(res_ext);
  2804. target_info.resobjext:='.fpcres';
  2805. end
  2806. else
  2807. IllegalPara(opt);
  2808. end;
  2809. 'F':
  2810. begin
  2811. {$if defined(m68k)}
  2812. if target_info.system in [system_m68k_atari] then
  2813. begin
  2814. if (length(More)>j) then
  2815. begin
  2816. val(Copy(More,j+1,255),ataritos_exe_flags,code);
  2817. if code<>0 then
  2818. IllegalPara(opt);
  2819. end
  2820. else
  2821. IllegalPara(opt);
  2822. break;
  2823. end;
  2824. {$endif defined(m68k)}
  2825. if target_info.system in systems_os2 then
  2826. begin
  2827. if UnsetBool(More, j, opt, false) then
  2828. SetApptype(app_cui)
  2829. else
  2830. SetApptype(app_fs);
  2831. end
  2832. else
  2833. IllegalPara(opt);
  2834. end;
  2835. 'G':
  2836. begin
  2837. if target_info.system in systems_all_windows+systems_os2+systems_macos then
  2838. begin
  2839. if UnsetBool(More, j, opt, false) then
  2840. SetApptype(app_cui)
  2841. else
  2842. SetApptype(app_gui);
  2843. end
  2844. else
  2845. IllegalPara(opt);
  2846. end;
  2847. {$if defined(i8086)}
  2848. 'h':
  2849. begin
  2850. if UnsetBool(More, j, opt, false) then
  2851. exclude(init_settings.moduleswitches,cs_huge_code)
  2852. else
  2853. include(init_settings.moduleswitches,cs_huge_code);
  2854. end;
  2855. {$endif defined(i8086)}
  2856. 'I':
  2857. begin
  2858. if target_info.system in systems_all_windows then
  2859. begin
  2860. GenerateImportSection:=not UnsetBool(More,j,opt,false);
  2861. GenerateImportSectionSetExplicitly:=true;
  2862. end
  2863. else
  2864. IllegalPara(opt);
  2865. end;
  2866. 'i':
  2867. begin
  2868. if (target_info.system in systems_darwin) then
  2869. begin
  2870. set_target_res(res_macho);
  2871. target_info.resobjext:=
  2872. targetinfos[target_info.system]^.resobjext;
  2873. end
  2874. else
  2875. IllegalPara(opt);
  2876. end;
  2877. 'm':
  2878. begin
  2879. {$if defined(i8086)}
  2880. if (target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded]) then
  2881. begin
  2882. case Upper(Copy(More,j+1,255)) of
  2883. 'TINY': init_settings.x86memorymodel:=mm_tiny;
  2884. 'SMALL': init_settings.x86memorymodel:=mm_small;
  2885. 'MEDIUM': init_settings.x86memorymodel:=mm_medium;
  2886. 'COMPACT': init_settings.x86memorymodel:=mm_compact;
  2887. 'LARGE': init_settings.x86memorymodel:=mm_large;
  2888. 'HUGE': init_settings.x86memorymodel:=mm_huge;
  2889. else
  2890. IllegalPara(opt);
  2891. end;
  2892. break;
  2893. end
  2894. else
  2895. {$endif defined(i8086)}
  2896. IllegalPara(opt);
  2897. end;
  2898. 'M':
  2899. begin
  2900. if (target_info.system in (systems_darwin-[system_i386_iphonesim,system_arm_ios,system_aarch64_ios,system_x86_64_iphonesim,system_aarch64_iphonesim])) and
  2901. ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED',copy(More,2,255),false) then
  2902. begin
  2903. break;
  2904. end
  2905. else
  2906. IllegalPara(opt);
  2907. end;
  2908. 'N':
  2909. begin
  2910. if target_info.system in systems_all_windows then
  2911. begin
  2912. RelocSection:=UnsetBool(More,j,opt,false);
  2913. RelocSectionSetExplicitly:=true;
  2914. end
  2915. else
  2916. IllegalPara(opt);
  2917. end;
  2918. 'p':
  2919. begin
  2920. {$push}
  2921. {$warn 6018 off} { Unreachable code due to compile time evaluation }
  2922. if ((target_info.system in systems_embedded) or (target_info.system in systems_freertos)) and
  2923. ControllerSupport then
  2924. begin
  2925. s:=upper(copy(more,j+1,length(more)-j));
  2926. if not(SetControllerType(s,init_settings.controllertype)) then
  2927. IllegalPara(opt)
  2928. else
  2929. begin
  2930. if init_settings.cputype<>embedded_controllers[init_settings.controllertype].cputype then
  2931. begin
  2932. Message(scan_n_changecputype);
  2933. init_settings.cputype:=embedded_controllers[init_settings.controllertype].cputype;
  2934. end;
  2935. end;
  2936. break;
  2937. end
  2938. else
  2939. IllegalPara(opt);
  2940. {$pop}
  2941. end;
  2942. 'P':
  2943. begin
  2944. if (target_info.system in [system_i386_iphonesim,system_arm_ios,system_aarch64_ios,system_x86_64_iphonesim,system_aarch64_iphonesim]) and
  2945. ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED',copy(More,2,255),true) then
  2946. begin
  2947. break;
  2948. end
  2949. {$ifdef XTENSA}
  2950. else if (target_info.system in [system_xtensa_freertos]) and
  2951. ParseVersionStr(idf_version,'IDF_VERSION',copy(More,2,255)) then
  2952. begin
  2953. break;
  2954. end
  2955. {$endif XTENSA}
  2956. else
  2957. IllegalPara(opt);
  2958. end;
  2959. {$if defined(m68k)}
  2960. 'L':
  2961. begin
  2962. if (target_info.system in [system_m68k_sinclairql]) then
  2963. sinclairql_vlink_experimental:=false
  2964. else
  2965. IllegalPara(opt);
  2966. end;
  2967. 'Q':
  2968. begin
  2969. if (target_info.system in [system_m68k_sinclairql]) then
  2970. begin
  2971. sinclairql_metadata_format:=Upper(Copy(More,j+1,255));
  2972. case sinclairql_metadata_format of
  2973. 'QHDR', 'XTCC': ; { allowed formats }
  2974. else
  2975. IllegalPara(opt);
  2976. end;
  2977. break;
  2978. end
  2979. else
  2980. IllegalPara(opt);
  2981. end;
  2982. {$endif defined(m68k)}
  2983. 'R':
  2984. begin
  2985. if target_info.system in systems_all_windows then
  2986. begin
  2987. { support -WR+ / -WR- as synonyms to -WR / -WN }
  2988. RelocSection:=not UnsetBool(More,j,opt,false);
  2989. RelocSectionSetExplicitly:=true;
  2990. end
  2991. else
  2992. IllegalPara(opt);
  2993. end;
  2994. 't':
  2995. begin
  2996. {$if defined(i8086)}
  2997. if (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  2998. begin
  2999. case Upper(Copy(More,j+1,255)) of
  3000. 'EXE': SetAppType(app_cui);
  3001. 'COM': SetAppType(app_com);
  3002. else
  3003. IllegalPara(opt);
  3004. end;
  3005. break;
  3006. end
  3007. else
  3008. {$endif defined(i8086)}
  3009. {$if defined(m68k)}
  3010. if (target_info.system in [system_m68k_atari]) then
  3011. begin
  3012. case Upper(Copy(More,j+1,255)) of
  3013. 'TOS': ataritos_exe_format := 'ataritos';
  3014. 'MINT': ataritos_exe_format := 'aoutmint';
  3015. else
  3016. IllegalPara(opt);
  3017. end;
  3018. break;
  3019. end
  3020. else
  3021. {$endif defined(m68k)}
  3022. IllegalPara(opt);
  3023. end;
  3024. 'T':
  3025. begin
  3026. if target_info.system in systems_macos then
  3027. begin
  3028. if UnsetBool(More, j, opt, false) then
  3029. SetApptype(app_cui)
  3030. else
  3031. SetApptype(app_tool);
  3032. end
  3033. else
  3034. IllegalPara(opt);
  3035. end;
  3036. 'X':
  3037. begin
  3038. if (target_info.system in systems_linux) then
  3039. begin
  3040. if UnsetBool(More, j, opt, false) then
  3041. exclude(init_settings.moduleswitches,cs_executable_stack)
  3042. else
  3043. include(init_settings.moduleswitches,cs_executable_stack)
  3044. end
  3045. else
  3046. IllegalPara(opt);
  3047. end;
  3048. else
  3049. IllegalPara(opt);
  3050. end;
  3051. inc(j);
  3052. end;
  3053. end;
  3054. 'X' :
  3055. begin
  3056. j:=1;
  3057. while j<=length(more) do
  3058. begin
  3059. case More[j] of
  3060. '9' :
  3061. begin
  3062. if target_info.system in systems_linux then
  3063. begin
  3064. if UnsetBool(More, j, opt, false) then
  3065. exclude(init_settings.globalswitches,cs_link_pre_binutils_2_19)
  3066. else
  3067. include(init_settings.globalswitches,cs_link_pre_binutils_2_19);
  3068. end
  3069. else
  3070. IllegalPara(opt);
  3071. end;
  3072. 'a' :
  3073. begin
  3074. If UnsetBool(More, j, opt, false) then
  3075. exclude(init_settings.globalswitches,cs_large)
  3076. else
  3077. include(init_settings.globalswitches,cs_large);
  3078. end;
  3079. 'c' : Cshared:=TRUE;
  3080. 'd' : Dontlinkstdlibpath:=TRUE;
  3081. 'e' :
  3082. begin
  3083. If UnsetBool(More, j, opt, false) then
  3084. exclude(init_settings.globalswitches,cs_link_extern)
  3085. else
  3086. include(init_settings.globalswitches,cs_link_extern);
  3087. end;
  3088. 'f' :
  3089. include(init_settings.globalswitches,cs_link_pthread);
  3090. 'g' :
  3091. begin
  3092. If UnsetBool(More, j, opt, false) then
  3093. exclude(init_settings.globalswitches,cs_link_separate_dbg_file)
  3094. else
  3095. include(init_settings.globalswitches,cs_link_separate_dbg_file);
  3096. end;
  3097. 'i' :
  3098. begin
  3099. If UnsetBool(More, j, opt, false) then
  3100. include(init_settings.globalswitches,cs_link_extern)
  3101. else
  3102. exclude(init_settings.globalswitches,cs_link_extern);
  3103. end;
  3104. 'n' :
  3105. begin
  3106. If UnsetBool(More, j, opt, false) then
  3107. exclude(init_settings.globalswitches,cs_link_native)
  3108. else
  3109. include(init_settings.globalswitches,cs_link_native);
  3110. end;
  3111. {$ifdef llvm}
  3112. 'l' :
  3113. begin
  3114. if j=length(more) then
  3115. IllegalPara(opt)
  3116. else
  3117. begin
  3118. case more[j+1] of
  3119. 'S':
  3120. begin
  3121. llvmutilssuffix:=copy(more,j+2,length(more));
  3122. j:=length(more);
  3123. end
  3124. else
  3125. IllegalPara(opt);
  3126. end;
  3127. end;
  3128. end;
  3129. {$endif}
  3130. 'm' :
  3131. begin
  3132. If UnsetBool(More, j, opt, false) then
  3133. exclude(init_settings.globalswitches,cs_link_map)
  3134. else
  3135. include(init_settings.globalswitches,cs_link_map);
  3136. end;
  3137. 'p' : ; { Ignore used by fpc.pp }
  3138. 'r' :
  3139. begin
  3140. if (target_info.system in suppported_targets_x_smallr) then
  3141. begin
  3142. rlinkpath:=Copy(more,2,length(More)-1);
  3143. DefaultReplacements(rlinkpath);
  3144. end
  3145. else
  3146. IgnoredPara('-Xr');
  3147. more:='';
  3148. end;
  3149. 'R' :
  3150. begin
  3151. sysrootpath:=copy(more,2,length(more)-1);
  3152. defaultreplacements(sysrootpath);
  3153. more:='';
  3154. end;
  3155. 's' :
  3156. begin
  3157. If UnsetBool(More, j, opt, false) then
  3158. exclude(init_settings.globalswitches,cs_link_strip)
  3159. else
  3160. include(init_settings.globalswitches,cs_link_strip);
  3161. end;
  3162. 't' :
  3163. include(init_settings.globalswitches,cs_link_staticflag);
  3164. 'u' :
  3165. begin
  3166. if target_info.system in systems_support_uf2 then
  3167. begin
  3168. if UnsetBool(More, j, opt, false) then
  3169. exclude(init_settings.globalswitches,cs_generate_uf2)
  3170. else
  3171. include(init_settings.globalswitches,cs_generate_uf2);
  3172. end
  3173. else
  3174. IgnoredPara('-Xu');
  3175. end;
  3176. 'v' :
  3177. begin
  3178. If UnsetBool(More, j, opt, false) then
  3179. exclude(init_settings.globalswitches,cs_link_opt_vtable)
  3180. else
  3181. include(init_settings.globalswitches,cs_link_opt_vtable);
  3182. end;
  3183. 'D' :
  3184. begin
  3185. def_system_macro('FPC_LINK_DYNAMIC');
  3186. undef_system_macro('FPC_LINK_SMART');
  3187. undef_system_macro('FPC_LINK_STATIC');
  3188. exclude(init_settings.globalswitches,cs_link_static);
  3189. exclude(init_settings.globalswitches,cs_link_smart);
  3190. include(init_settings.globalswitches,cs_link_shared);
  3191. LinkTypeSetExplicitly:=true;
  3192. end;
  3193. 'M' :
  3194. begin
  3195. mainaliasname:=Copy(more,2,length(More)-1);
  3196. More:='';
  3197. end;
  3198. 'P' :
  3199. begin
  3200. utilsprefix:=Copy(more,2,length(More)-1);
  3201. DefaultReplacements(utilsprefix);
  3202. More:='';
  3203. end;
  3204. 'L' : begin // -XLO is link order -XLA is link alias. -XLD avoids load defaults.
  3205. // these are not aggregable.
  3206. if (j=length(more)) or not (more[j+1] in ['O','A','D']) then
  3207. IllegalPara(opt)
  3208. else
  3209. begin
  3210. case more[j+1] of
  3211. 'A' : begin
  3212. s:=Copy(more,3,length(More)-2);
  3213. if not LinkLibraryAliases.AddDep(s) Then
  3214. IllegalPara(opt);
  3215. end;
  3216. 'O' : begin
  3217. s:=Copy(more,3,length(More)-2);
  3218. if not LinkLibraryOrder.AddWeight(s) Then
  3219. IllegalPara(opt);
  3220. end;
  3221. 'D' : include(init_settings.globalswitches,cs_link_no_default_lib_order)
  3222. else
  3223. IllegalPara(opt);
  3224. end; {case}
  3225. j:=length(more);
  3226. end; {else begin}
  3227. end;
  3228. 'S' :
  3229. begin
  3230. ForceStaticLinking;
  3231. end;
  3232. 'V' :
  3233. begin
  3234. if UnsetBool(More, j, opt, false) then
  3235. exclude(init_settings.globalswitches,cs_link_vlink)
  3236. else
  3237. begin
  3238. include(init_settings.globalswitches,cs_link_vlink);
  3239. include(init_settings.globalswitches,cs_link_extern);
  3240. end;
  3241. LinkerSetExplicitly:=true;
  3242. end;
  3243. 'X' :
  3244. begin
  3245. def_system_macro('FPC_LINK_SMART');
  3246. undef_system_macro('FPC_LINK_STATIC');
  3247. undef_system_macro('FPC_LINK_DYNAMIC');
  3248. exclude(init_settings.globalswitches,cs_link_static);
  3249. include(init_settings.globalswitches,cs_link_smart);
  3250. exclude(init_settings.globalswitches,cs_link_shared);
  3251. LinkTypeSetExplicitly:=true;
  3252. end;
  3253. '-' :
  3254. begin
  3255. exclude(init_settings.globalswitches,cs_link_staticflag);
  3256. exclude(init_settings.globalswitches,cs_link_strip);
  3257. exclude(init_settings.globalswitches,cs_link_map);
  3258. set_default_link_type;
  3259. end;
  3260. else
  3261. IllegalPara(opt);
  3262. end;
  3263. inc(j);
  3264. end;
  3265. end;
  3266. else
  3267. IllegalPara(opt);
  3268. end;
  3269. end;
  3270. '@' :
  3271. begin
  3272. Message(option_no_nested_response_file);
  3273. StopOptions(1);
  3274. end;
  3275. else
  3276. begin
  3277. if (length(param_file)<>0) then
  3278. Message2(option_only_one_source_support,param_file,opt);
  3279. param_file:=opt;
  3280. Message1(option_found_file,opt);
  3281. end;
  3282. end;
  3283. end;
  3284. procedure Toption.Interpret_file(const filename : TPathStr);
  3285. procedure RemoveSep(var fn:TPathStr);
  3286. var
  3287. i : longint;
  3288. begin
  3289. i:=0;
  3290. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  3291. inc(i);
  3292. Delete(fn,1,i);
  3293. i:=length(fn);
  3294. while (i>0) and (fn[i] in [',',' ',#9]) do
  3295. dec(i);
  3296. fn:=copy(fn,1,i);
  3297. end;
  3298. function GetName(var fn:TPathStr):TPathStr;
  3299. var
  3300. i : longint;
  3301. begin
  3302. i:=0;
  3303. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  3304. inc(i);
  3305. GetName:=Copy(fn,1,i);
  3306. Delete(fn,1,i);
  3307. end;
  3308. const
  3309. maxlevel = 15;
  3310. var
  3311. f : text;
  3312. s, tmp,
  3313. opts : TCmdStr;
  3314. skip : array[0..maxlevel] of boolean;
  3315. line,
  3316. level : longint;
  3317. option_read : boolean;
  3318. oldfilemode : byte;
  3319. ConfigFile: TPathStr;
  3320. begin
  3321. { avoid infinite loop }
  3322. Inc(FileLevel);
  3323. Option_read:=false;
  3324. If FileLevel>MaxLevel then
  3325. Message(option_too_many_cfg_files);
  3326. if not ParaIncludeCfgPath.FindFile(fileName,true,ConfigFile) then
  3327. ConfigFile := ExpandFileName(filename);
  3328. { Maybe It's Directory ?} //Jaro Change:
  3329. if PathExists(ConfigFile,false) then
  3330. begin
  3331. Message1(option_config_is_dir,filename);
  3332. exit;
  3333. end;
  3334. { open file }
  3335. Message1(option_using_file,filename);
  3336. oldfilemode:=filemode;
  3337. filemode:=0;
  3338. assign(f,ConfigFile);
  3339. {$push}{$I-}
  3340. reset(f);
  3341. {$pop}
  3342. filemode:=oldfilemode;
  3343. if ioresult<>0 then
  3344. begin
  3345. Message1(option_unable_open_file,filename);
  3346. exit;
  3347. end;
  3348. Message1(option_start_reading_configfile,filename);
  3349. fillchar(skip,sizeof(skip),0);
  3350. level:=0;
  3351. line:=0;
  3352. while not eof(f) do
  3353. begin
  3354. readln(f,opts);
  3355. inc(line);
  3356. RemoveSep(opts);
  3357. if (opts<>'') and (opts[1]<>';') then
  3358. begin
  3359. if opts[1]='#' then
  3360. begin
  3361. Message1(option_interpreting_file_option,opts);
  3362. Delete(opts,1,1);
  3363. s:=upper(GetName(opts));
  3364. if (s='SECTION') then
  3365. begin
  3366. RemoveSep(opts);
  3367. s:=upper(GetName(opts));
  3368. if level=0 then
  3369. skip[level]:=not defined_macro(s) or (s='COMMON');
  3370. end
  3371. else
  3372. if (s='IFDEF') then
  3373. begin
  3374. RemoveSep(opts);
  3375. if Level>=maxlevel then
  3376. begin
  3377. Message2(option_too_many_ifdef,filename,tostr(line));
  3378. stopOptions(1);
  3379. end;
  3380. inc(Level);
  3381. { environment variable? }
  3382. if (opts[1]='$') and (opts[length(opts)]='$') then
  3383. skip[level]:=skip[level-1] or (GetEnvironmentVariable(copy(opts,2,length(opts)-2))='')
  3384. else
  3385. skip[level]:=(skip[level-1] or not defined_macro(upper(GetName(opts))));
  3386. end
  3387. else
  3388. if (s='IFNDEF') then
  3389. begin
  3390. RemoveSep(opts);
  3391. if Level>=maxlevel then
  3392. begin
  3393. Message2(option_too_many_ifdef,filename,tostr(line));
  3394. stopOptions(1);
  3395. end;
  3396. inc(Level);
  3397. { environment variable? }
  3398. if (opts[1]='$') and (opts[length(opts)]='$') then
  3399. skip[level]:=skip[level-1] or (GetEnvironmentVariable(copy(opts,2,length(opts)-2))<>'')
  3400. else
  3401. skip[level]:=skip[level-1] or defined_macro(upper(GetName(opts)));
  3402. end
  3403. else
  3404. if (s='ELSE') then
  3405. begin
  3406. if Level=0 then
  3407. begin
  3408. Message2(option_else_without_if,filename,tostr(line));
  3409. stopOptions(1);
  3410. end
  3411. else
  3412. skip[level]:=skip[level-1] or (not skip[level])
  3413. end
  3414. else
  3415. if (s='ENDIF') then
  3416. begin
  3417. skip[level]:=false;
  3418. if Level=0 then
  3419. begin
  3420. Message2(option_too_many_endif,filename,tostr(line));
  3421. stopOptions(1);
  3422. end;
  3423. dec(level);
  3424. end
  3425. else
  3426. if (not skip[level]) then
  3427. begin
  3428. if (s='DEFINE') then
  3429. begin
  3430. RemoveSep(opts);
  3431. tmp:= GetName(opts);
  3432. if tmp <> '' then
  3433. def_system_macro(tmp);
  3434. Option_read:=true;
  3435. end
  3436. else
  3437. if (s='UNDEF') then
  3438. begin
  3439. RemoveSep(opts);
  3440. tmp:= GetName(opts);
  3441. if tmp <> '' then
  3442. undef_system_macro(tmp);
  3443. Option_read:=true;
  3444. end
  3445. else
  3446. if (s='WRITE') then
  3447. begin
  3448. Delete(opts,1,1);
  3449. DefaultReplacements(opts);
  3450. WriteLn(opts);
  3451. Option_read:=true;
  3452. end
  3453. else
  3454. if (s='INCLUDE') then
  3455. begin
  3456. Delete(opts,1,1);
  3457. DefaultReplacements(opts);
  3458. Interpret_file(opts);
  3459. Option_read:=true;
  3460. end
  3461. else
  3462. if (s='CFGDIR') then
  3463. begin
  3464. Delete(opts,1,1);
  3465. DefaultReplacements(opts);
  3466. ParaIncludeCfgPath.AddPath(opts,false);
  3467. Option_read:=true;
  3468. end;
  3469. end;
  3470. end
  3471. else
  3472. begin
  3473. if (opts[1]='-') or (opts[1]='@') then
  3474. begin
  3475. if (not skip[level]) then
  3476. interpret_option(opts,false);
  3477. Option_read:=true;
  3478. end
  3479. else
  3480. Message1(option_illegal_para,opts);
  3481. end;
  3482. end;
  3483. end;
  3484. if Level>0 then
  3485. Message(option_too_less_endif);
  3486. if Not Option_read then
  3487. Message1(option_no_option_found,filename)
  3488. else
  3489. Message1(option_end_reading_configfile,filename);
  3490. Close(f);
  3491. Dec(FileLevel);
  3492. end;
  3493. procedure Toption.Interpret_envvar(const envname : TCmdStr);
  3494. var
  3495. argstart,
  3496. env,
  3497. pc : pchar;
  3498. arglen : longint;
  3499. quote : set of char;
  3500. hs : TCmdStr;
  3501. begin
  3502. Message1(option_using_env,envname);
  3503. env:=GetEnvPChar(envname);
  3504. pc:=env;
  3505. hs:='';
  3506. if assigned(pc) then
  3507. begin
  3508. repeat
  3509. { skip leading spaces }
  3510. while pc^ in [' ',#9,#13] do
  3511. inc(pc);
  3512. case pc^ of
  3513. #0 :
  3514. break;
  3515. '"' :
  3516. begin
  3517. quote:=['"'];
  3518. inc(pc);
  3519. end;
  3520. '''' :
  3521. begin
  3522. quote:=[''''];
  3523. inc(pc);
  3524. end;
  3525. else
  3526. quote:=[' ',#9,#13];
  3527. end;
  3528. { scan until the end of the argument }
  3529. argstart:=pc;
  3530. while (pc^<>#0) and not(pc^ in quote) do
  3531. inc(pc);
  3532. { create argument }
  3533. arglen:=pc-argstart;
  3534. { TODO: FIXME: silent truncation of environment parameters }
  3535. if (arglen > 255) then
  3536. arglen := 255;
  3537. setlength(hs,arglen);
  3538. move(argstart^,hs[1],arglen);
  3539. interpret_option(hs,true);
  3540. { skip quote }
  3541. if pc^ in quote then
  3542. inc(pc);
  3543. until false;
  3544. end
  3545. else
  3546. Message1(option_no_option_found,'(env) '+envname);
  3547. FreeEnvPChar(env);
  3548. end;
  3549. procedure toption.read_parameters;
  3550. var
  3551. opts : TCmdStr;
  3552. paramindex : longint;
  3553. begin
  3554. paramindex:=0;
  3555. while paramindex<paramcount do
  3556. begin
  3557. inc(paramindex);
  3558. opts:=objpas.paramstr(paramindex);
  3559. if length(opts)>0 then
  3560. case opts[1] of
  3561. '@' :
  3562. if not firstpass then
  3563. begin
  3564. Delete(opts,1,1);
  3565. Message1(option_reading_further_from,opts);
  3566. interpret_file(opts);
  3567. end;
  3568. '!' :
  3569. if not firstpass then
  3570. begin
  3571. Delete(opts,1,1);
  3572. Message1(option_reading_further_from,'(env) '+opts);
  3573. interpret_envvar(opts);
  3574. end;
  3575. else
  3576. interpret_option(opts,true);
  3577. end;
  3578. end;
  3579. end;
  3580. procedure toption.parsecmd(cmd:TCmdStr);
  3581. var
  3582. i,ps : longint;
  3583. opts : TCmdStr;
  3584. begin
  3585. while (cmd<>'') do
  3586. begin
  3587. while cmd[1]=' ' do
  3588. delete(cmd,1,1);
  3589. i:=pos(' ',cmd);
  3590. if i=0 then
  3591. i:=2147483647;
  3592. opts:=Copy(cmd,1,i-1);
  3593. Delete(cmd,1,i);
  3594. case opts[1] of
  3595. '@' :
  3596. if not firstpass then
  3597. begin
  3598. Delete(opts,1,1);
  3599. Message1(option_reading_further_from,opts);
  3600. interpret_file(opts);
  3601. end;
  3602. '!' :
  3603. if not firstpass then
  3604. begin
  3605. Delete(opts,1,1);
  3606. Message1(option_reading_further_from,'(env) '+opts);
  3607. interpret_envvar(opts);
  3608. end;
  3609. '"' :
  3610. begin
  3611. Delete(opts,1,1);
  3612. ps:=pos('"',cmd);
  3613. if (i<>256) and (ps>0) then
  3614. begin
  3615. opts:=opts + ' '+ copy(cmd,1,ps-1);
  3616. cmd:=copy(cmd,ps+1,255);
  3617. end;
  3618. interpret_option(opts,true);
  3619. end;
  3620. else
  3621. interpret_option(opts,true);
  3622. end;
  3623. end;
  3624. end;
  3625. procedure toption.writequickinfo;
  3626. var
  3627. s : string;
  3628. i : longint;
  3629. procedure addinfo(const hs:string);
  3630. begin
  3631. if s<>'' then
  3632. s:=s+' '+hs
  3633. else
  3634. s:=hs;
  3635. end;
  3636. begin
  3637. s:='';
  3638. i:=0;
  3639. while (i<length(quickinfo)) do
  3640. begin
  3641. inc(i);
  3642. case quickinfo[i] of
  3643. 'S' :
  3644. begin
  3645. inc(i);
  3646. case quickinfo[i] of
  3647. 'O' :
  3648. addinfo(lower(source_info.shortname));
  3649. 'P' :
  3650. addinfo(source_cpu_string);
  3651. else
  3652. IllegalPara('-i'+QuickInfo);
  3653. end;
  3654. end;
  3655. 'T' :
  3656. begin
  3657. inc(i);
  3658. case quickinfo[i] of
  3659. 'O' :
  3660. addinfo(lower(target_info.shortname));
  3661. 'P' :
  3662. AddInfo(target_cpu_string);
  3663. else
  3664. IllegalPara('-i'+QuickInfo);
  3665. end;
  3666. end;
  3667. 'V' :
  3668. AddInfo(version_string);
  3669. 'W' :
  3670. AddInfo(full_version_string);
  3671. 'D' :
  3672. AddInfo(date_string);
  3673. '_' :
  3674. ;
  3675. else
  3676. IllegalPara('-i'+QuickInfo);
  3677. end;
  3678. end;
  3679. if s<>'' then
  3680. begin
  3681. writeln(s);
  3682. stopoptions(0);
  3683. end;
  3684. end;
  3685. procedure TOption.TargetOptions(def:boolean);
  3686. var
  3687. s : string;
  3688. i : integer;
  3689. target_unsup_features : tfeatures;
  3690. begin
  3691. if def then
  3692. def_system_macro(target_info.shortname)
  3693. else
  3694. undef_system_macro(target_info.shortname);
  3695. s:=target_info.extradefines;
  3696. while (s<>'') do
  3697. begin
  3698. i:=pos(';',s);
  3699. if i=0 then
  3700. i:=length(s)+1;
  3701. if def then
  3702. def_system_macro(Copy(s,1,i-1))
  3703. else
  3704. undef_system_macro(Copy(s,1,i-1));
  3705. delete(s,1,i);
  3706. end;
  3707. if (tf_winlikewidestring in target_info.flags) then
  3708. if def then
  3709. def_system_macro('FPC_WINLIKEWIDESTRING')
  3710. else
  3711. undef_system_macro('FPC_WINLIKEWIDESTRING');
  3712. if (tf_requires_proper_alignment in target_info.flags) then
  3713. if def then
  3714. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT')
  3715. else
  3716. undef_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  3717. if (tf_init_final_units_by_calls in target_info.flags) then
  3718. if def then
  3719. def_system_macro('FPC_INIT_FINAL_UNITS_BY_CALLS')
  3720. else
  3721. undef_system_macro('FPC_INIT_FINAL_UNITS_BY_CALLS');
  3722. if source_info.system<>target_info.system then
  3723. if def then
  3724. def_system_macro('FPC_CROSSCOMPILING')
  3725. else
  3726. undef_system_macro('FPC_CROSSCOMPILING');
  3727. if source_info.cpu<>target_info.cpu then
  3728. if def then
  3729. def_system_macro('FPC_CPUCROSSCOMPILING')
  3730. else
  3731. def_system_macro('FPC_CPUCROSSCOMPILING');
  3732. if (tf_no_generic_stackcheck in target_info.flags) then
  3733. if def then
  3734. def_system_macro('FPC_NO_GENERIC_STACK_CHECK')
  3735. else
  3736. undef_system_macro('FPC_NO_GENERIC_STACK_CHECK');
  3737. if (tf_section_threadvars in target_info.flags) then
  3738. if def then
  3739. def_system_macro('FPC_SECTION_THREADVARS')
  3740. else
  3741. undef_system_macro('FPC_SECTION_THREADVARS');
  3742. if (tf_use_psabieh in target_info.flags) then
  3743. if def then
  3744. def_system_macro('FPC_USE_PSABIEH')
  3745. else
  3746. undef_system_macro('FPC_USE_PSABIEH');
  3747. { Code generation flags }
  3748. if (tf_pic_default in target_info.flags) then
  3749. if def then
  3750. include(init_settings.moduleswitches,cs_create_pic)
  3751. else
  3752. exclude(init_settings.moduleswitches,cs_create_pic);
  3753. { Resources support }
  3754. if (tf_has_winlike_resources in target_info.flags) then
  3755. if def then
  3756. def_system_macro('FPC_HAS_WINLIKERESOURCES')
  3757. else
  3758. undef_system_macro('FPC_HAS_WINLIKERESOURCES');
  3759. { Features }
  3760. case target_info.system of
  3761. system_arm_gba:
  3762. target_unsup_features:=[f_dynlibs];
  3763. system_arm_nds:
  3764. target_unsup_features:=[f_threading,f_commandargs,f_fileio,f_textio,f_consoleio,f_dynlibs];
  3765. system_i386_nativent:
  3766. // until these features are implemented, they are disabled in the compiler
  3767. target_unsup_features:=[f_stackcheck];
  3768. system_i8086_msdos:
  3769. target_unsup_features:=[f_threading,f_dynlibs];
  3770. system_i8086_win16:
  3771. target_unsup_features:=[f_threading];
  3772. system_jvm_java32,
  3773. system_jvm_android32:
  3774. target_unsup_features:=[f_heap,f_textio,f_consoleio,f_fileio,
  3775. f_variants,f_objects,f_commandargs,
  3776. f_processes,f_stackcheck,f_dynlibs,f_softfpu,f_objectivec1,f_resources];
  3777. system_arm_palmos,
  3778. system_m68k_palmos:
  3779. target_unsup_features:=[f_threading];
  3780. system_m68k_atari:
  3781. target_unsup_features:=[f_threading];
  3782. { classic amiga has dynamic libraries, but they cannot be integrated in the
  3783. normal dynlibs infrastructure due to architectural differences, so therefore
  3784. lets disable the feature. }
  3785. system_m68k_amiga:
  3786. target_unsup_features:=[f_dynlibs];
  3787. system_m68k_sinclairql:
  3788. target_unsup_features:=[f_threading,f_dynlibs];
  3789. system_z80_zxspectrum:
  3790. target_unsup_features:=[f_threading,f_dynlibs{,f_fileio,f_textio},f_commandargs,f_exitcode];
  3791. system_z80_msxdos:
  3792. target_unsup_features:=[f_threading,f_dynlibs];
  3793. else
  3794. target_unsup_features:=[];
  3795. end;
  3796. if def then
  3797. features:=features-target_unsup_features
  3798. else
  3799. features:=features+target_unsup_features;
  3800. {$if defined(hasamiga)}
  3801. { enable vlink as default linker on Amiga but not for cross compilers (for now) }
  3802. if (target_info.system in [system_m68k_amiga,system_powerpc_amiga]) and
  3803. not LinkerSetExplicitly then
  3804. include(init_settings.globalswitches,cs_link_vlink);
  3805. {$endif}
  3806. {$ifdef m68k}
  3807. { always enable vlink as default linker for the Sinclair QL and Atari }
  3808. if (target_info.system in [system_m68k_sinclairql,system_m68k_atari]) and
  3809. not LinkerSetExplicitly then
  3810. include(init_settings.globalswitches,cs_link_vlink);
  3811. {$endif m68k}
  3812. end;
  3813. procedure TOption.checkoptionscompatibility;
  3814. begin
  3815. {$ifdef wasm}
  3816. if (Ord(ts_wasm_no_exceptions in init_settings.targetswitches)+
  3817. Ord(ts_wasm_js_exceptions in init_settings.targetswitches)+
  3818. Ord(ts_wasm_native_exceptions in init_settings.targetswitches)+
  3819. Ord(ts_wasm_bf_exceptions in init_settings.targetswitches))>1 then
  3820. begin
  3821. Message(option_too_many_exception_modes);
  3822. StopOptions(1);
  3823. end;
  3824. {$endif}
  3825. {$ifdef i8086}
  3826. if (apptype=app_com) and (init_settings.x86memorymodel<>mm_tiny) then
  3827. begin
  3828. Message(option_com_files_require_tiny_model);
  3829. StopOptions(1);
  3830. end;
  3831. {$endif i8086}
  3832. {$ifndef i8086_link_intern_debuginfo}
  3833. if (cs_debuginfo in init_settings.moduleswitches) and
  3834. (target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded]) and
  3835. not (cs_link_extern in init_settings.globalswitches) then
  3836. begin
  3837. Message(option_debug_info_requires_external_linker);
  3838. include(init_settings.globalswitches,cs_link_extern);
  3839. end;
  3840. {$endif i8086_link_intern_debuginfo}
  3841. if (paratargetdbg in [dbg_dwarf2,dbg_dwarf3,dbg_dwarf4]) and
  3842. not(target_info.system in (systems_darwin+[system_i8086_msdos,system_i8086_embedded])) then
  3843. begin
  3844. { smartlink creation does not yet work with DWARF
  3845. debug info on most targets, but it works in internal assembler }
  3846. if (cs_create_smart in init_settings.moduleswitches) and
  3847. not (af_outputbinary in target_asm.flags) then
  3848. begin
  3849. Message(option_dwarf_smartlink_creation);
  3850. exclude(init_settings.moduleswitches,cs_create_smart);
  3851. end;
  3852. { smart linking does not yet work with DWARF debug info on most targets }
  3853. if (cs_link_smart in init_settings.globalswitches) then
  3854. begin
  3855. Message(option_dwarf_smart_linking);
  3856. ForceStaticLinking;
  3857. end;
  3858. end;
  3859. { external debug info is only supported for DWARF on darwin }
  3860. if (target_info.system in systems_darwin) and
  3861. (cs_link_separate_dbg_file in init_settings.globalswitches) and
  3862. not(paratargetdbg in [dbg_dwarf2,dbg_dwarf3,dbg_dwarf4]) then
  3863. begin
  3864. Message(option_debug_external_unsupported);
  3865. exclude(init_settings.globalswitches,cs_link_separate_dbg_file);
  3866. end;
  3867. { Also create a smartlinked version, on an assembler that
  3868. does not support smartlink sections like nasm?
  3869. This is not compatible with using internal linker. }
  3870. if ((cs_link_smart in init_settings.globalswitches) or
  3871. (cs_create_smart in init_settings.moduleswitches)) and
  3872. (af_needar in target_asm.flags) and
  3873. not (af_smartlink_sections in target_asm.flags) and
  3874. not (cs_link_extern in init_settings.globalswitches) and
  3875. (target_info.link<>ld_none) and
  3876. not (cs_link_nolink in init_settings.globalswitches) then
  3877. begin
  3878. Message(option_smart_link_requires_external_linker);
  3879. include(init_settings.globalswitches,cs_link_extern);
  3880. end;
  3881. end;
  3882. constructor TOption.create;
  3883. begin
  3884. LogoWritten:=false;
  3885. NoPressEnter:=false;
  3886. FirstPass:=false;
  3887. ABISetExplicitly:=false;
  3888. FPUSetExplicitly:=false;
  3889. CPUSetExplicitly:=false;
  3890. OptCPUSetExplicitly:=false;
  3891. FileLevel:=0;
  3892. Quickinfo:='';
  3893. ParaIncludeCfgPath:=TSearchPathList.Create;
  3894. ParaIncludePath:=TSearchPathList.Create;
  3895. ParaObjectPath:=TSearchPathList.Create;
  3896. ParaUnitPath:=TSearchPathList.Create;
  3897. ParaLibraryPath:=TSearchPathList.Create;
  3898. ParaFrameworkPath:=TSearchPathList.Create;
  3899. parapackagepath:=TSearchPathList.Create;
  3900. parapackages:=TFPHashObjectList.Create;
  3901. paranamespaces:=TCmdStrList.Create;
  3902. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  3903. MacVersionSet:=false;
  3904. paratarget:=system_none;
  3905. paratargetasm:=as_none;
  3906. paratargetdbg:=dbg_none;
  3907. LinkTypeSetExplicitly:=false;
  3908. LinkerSetExplicitly:=false;
  3909. end;
  3910. destructor TOption.destroy;
  3911. begin
  3912. ParaIncludeCfgPath.Free;
  3913. ParaIncludePath.Free;
  3914. ParaObjectPath.Free;
  3915. ParaUnitPath.Free;
  3916. ParaLibraryPath.Free;
  3917. ParaFrameworkPath.Free;
  3918. parapackagepath.Free;
  3919. ParaPackages.Free;
  3920. paranamespaces.free;
  3921. end;
  3922. {****************************************************************************
  3923. Callable Routines
  3924. ****************************************************************************}
  3925. function check_configfile(fn:string; var foundfn:string):boolean;
  3926. function CfgFileExists(const fn:string):boolean;
  3927. begin
  3928. Comment(V_Tried,'Configfile search: '+fn);
  3929. CfgFileExists:=FileExists(fn);
  3930. end;
  3931. var
  3932. {$ifdef Unix}
  3933. hs,
  3934. {$endif Unix}
  3935. configpath : string;
  3936. begin
  3937. foundfn:=fn;
  3938. check_configfile:=true;
  3939. { retrieve configpath }
  3940. configpath:=FixPath(GetEnvironmentVariable('PPC_CONFIG_PATH'),false);
  3941. {$ifdef Unix}
  3942. if configpath='' then
  3943. configpath:=ExpandFileName(FixPath(exepath+'../etc/',false));
  3944. {$endif}
  3945. {
  3946. Order to read configuration file :
  3947. try reading fpc.cfg in :
  3948. 1 - current dir
  3949. 2 - configpath
  3950. 3 - compiler path
  3951. }
  3952. if not FileExists(fn) then
  3953. begin
  3954. {$ifdef Unix}
  3955. hs:=GetEnvironmentVariable('HOME');
  3956. if (hs<>'') and CfgFileExists(FixPath(hs,false)+'.'+fn) then
  3957. foundfn:=FixPath(hs,false)+'.'+fn
  3958. else
  3959. {$endif}
  3960. if CfgFileExists(configpath+fn) then
  3961. foundfn:=configpath+fn
  3962. else
  3963. {$ifdef WINDOWS}
  3964. if (GetEnvironmentVariable('USERPROFILE')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('USERPROFILE'),false)+fn) then
  3965. foundfn:=FixPath(GetEnvironmentVariable('USERPROFILE'),false)+fn
  3966. else
  3967. if (GetEnvironmentVariable('ALLUSERSPROFILE')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('ALLUSERSPROFILE'),false)+fn) then
  3968. foundfn:=FixPath(GetEnvironmentVariable('ALLUSERSPROFILE'),false)+fn
  3969. else
  3970. {$endif WINDOWS}
  3971. {$ifndef Unix}
  3972. if CfgFileExists(exepath+fn) then
  3973. foundfn:=exepath+fn
  3974. else
  3975. {$else}
  3976. if CfgFileExists('/etc/'+fn) then
  3977. foundfn:='/etc/'+fn
  3978. else
  3979. {$endif}
  3980. check_configfile:=false;
  3981. end;
  3982. end;
  3983. procedure read_arguments(cmd:TCmdStr);
  3984. procedure def_cpu_macros;
  3985. var
  3986. abi : tabi;
  3987. fputype : tfputype;
  3988. cputype : tcputype;
  3989. controller: tcontrollertype;
  3990. s: string;
  3991. begin
  3992. {$ifdef llvm}
  3993. def_system_macro('CPULLVM');
  3994. {$endif}
  3995. for cputype:=low(tcputype) to high(tcputype) do
  3996. undef_system_macro('CPU'+Cputypestr[cputype]);
  3997. def_system_macro('CPU'+Cputypestr[init_settings.cputype]);
  3998. for fputype:=low(tfputype) to high(tfputype) do
  3999. undef_system_macro('FPU'+fputypestr[fputype]);
  4000. def_system_macro('FPU'+fputypestr[init_settings.fputype]);
  4001. {$PUSH}
  4002. {$WARN 6018 OFF} { Unreachable code due to compile time evaluation }
  4003. if ControllerSupport then
  4004. begin
  4005. for controller:=low(tcontrollertype) to high(tcontrollertype) do
  4006. begin
  4007. s:=embedded_controllers[controller].controllertypestr;
  4008. if s<>'' then
  4009. undef_system_macro('FPC_MCU_'+s);
  4010. end;
  4011. s:=embedded_controllers[init_settings.controllertype].controllertypestr;
  4012. if s<>'' then
  4013. def_system_macro('FPC_MCU_'+s);
  4014. end;
  4015. {$POP}
  4016. { define abi }
  4017. for abi:=low(tabi) to high(tabi) do
  4018. undef_system_macro('FPC_ABI_'+abiinfo[abi].name);
  4019. def_system_macro('FPC_ABI_'+abiinfo[target_info.abi].name);
  4020. { Define FPC_ABI_EABI in addition to FPC_ABI_EABIHF on EABI VFP hardfloat
  4021. systems since most code needs to behave the same on both}
  4022. if target_info.abi = abi_eabihf then
  4023. def_system_macro('FPC_ABI_EABI');
  4024. { using a case is pretty useless here (FK) }
  4025. { some stuff for TP compatibility }
  4026. {$ifdef i386}
  4027. def_system_macro('CPU86');
  4028. def_system_macro('CPU87');
  4029. def_system_macro('CPU386');
  4030. {$endif}
  4031. { new processor stuff }
  4032. {$ifdef i386}
  4033. def_system_macro('CPUI386');
  4034. def_system_macro('CPU32');
  4035. def_system_macro('CPUX86');
  4036. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  4037. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  4038. def_system_macro('FPC_HAS_TYPE_SINGLE');
  4039. {$endif}
  4040. {$ifdef m68k}
  4041. def_system_macro('CPU68');
  4042. def_system_macro('CPU68K');
  4043. def_system_macro('CPUM68K');
  4044. def_system_macro('CPU32');
  4045. def_system_macro('FPC_CURRENCY_IS_INT64');
  4046. def_system_macro('FPC_COMP_IS_INT64');
  4047. {$endif}
  4048. {$ifdef powerpc}
  4049. def_system_macro('CPUPOWERPC');
  4050. def_system_macro('CPUPOWERPC32');
  4051. def_system_macro('CPU32');
  4052. def_system_macro('FPC_CURRENCY_IS_INT64');
  4053. def_system_macro('FPC_COMP_IS_INT64');
  4054. {$endif}
  4055. {$ifdef POWERPC64}
  4056. def_system_macro('CPUPOWERPC');
  4057. def_system_macro('CPUPOWERPC64');
  4058. def_system_macro('CPU64');
  4059. def_system_macro('FPC_CURRENCY_IS_INT64');
  4060. def_system_macro('FPC_COMP_IS_INT64');
  4061. {$endif}
  4062. {$ifdef x86_64}
  4063. def_system_macro('CPUX86_64');
  4064. def_system_macro('CPUAMD64');
  4065. def_system_macro('CPU64');
  4066. def_system_macro('CPUX64');
  4067. { not supported for now, afaik (FK)
  4068. def_system_macro('FPC_HAS_TYPE_FLOAT128'); }
  4069. {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
  4070. { normally, win64 doesn't support the legacy fpu }
  4071. if target_info.system=system_x86_64_win64 then
  4072. begin
  4073. def_system_macro('FPC_CURRENCY_IS_INT64');
  4074. def_system_macro('FPC_COMP_IS_INT64');
  4075. end;
  4076. {$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
  4077. {$endif}
  4078. {$ifdef sparc}
  4079. def_system_macro('CPUSPARCGEN');
  4080. def_system_macro('CPUSPARC');
  4081. def_system_macro('CPUSPARC32');
  4082. def_system_macro('CPU32');
  4083. def_system_macro('FPC_CURRENCY_IS_INT64');
  4084. def_system_macro('FPC_COMP_IS_INT64');
  4085. {$endif}
  4086. {$ifdef sparc64}
  4087. def_system_macro('CPUSPARCGEN');
  4088. def_system_macro('CPUSPARC64');
  4089. def_system_macro('CPU64');
  4090. def_system_macro('FPC_CURRENCY_IS_INT64');
  4091. def_system_macro('FPC_COMP_IS_INT64');
  4092. {$endif}
  4093. {$ifdef arm}
  4094. def_system_macro('CPUARM');
  4095. def_system_macro('CPU32');
  4096. def_system_macro('FPC_CURRENCY_IS_INT64');
  4097. def_system_macro('FPC_COMP_IS_INT64');
  4098. {$endif arm}
  4099. {$ifdef avr}
  4100. def_system_macro('CPUAVR');
  4101. def_system_macro('CPU16');
  4102. def_system_macro('FPC_CURRENCY_IS_INT64');
  4103. def_system_macro('FPC_COMP_IS_INT64');
  4104. {$endif avr}
  4105. {$ifdef jvm}
  4106. def_system_macro('CPUJVM');
  4107. def_system_macro('CPU32');
  4108. def_system_macro('FPC_CURRENCY_IS_INT64');
  4109. def_system_macro('FPC_COMP_IS_INT64');
  4110. {$endif jvm}
  4111. {$ifdef mipsel}
  4112. def_system_macro('CPUMIPS');
  4113. def_system_macro('CPUMIPSEL');
  4114. def_system_macro('CPUMIPS32');
  4115. def_system_macro('CPUMIPSEL32');
  4116. def_system_macro('CPU32');
  4117. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  4118. def_system_macro('FPC_HAS_TYPE_SINGLE');
  4119. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  4120. def_system_macro('FPC_CURRENCY_IS_INT64');
  4121. def_system_macro('FPC_COMP_IS_INT64');
  4122. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  4123. { On most systems, locals are accessed relative to base pointer,
  4124. but for MIPS cpu, they are accessed relative to stack pointer.
  4125. This needs adaptation for so low level routines,
  4126. like MethodPointerLocal and related objects unit functions. }
  4127. def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
  4128. {$endif mipsel}
  4129. {$ifdef mipseb}
  4130. def_system_macro('CPUMIPS');
  4131. def_system_macro('CPUMIPSEB');
  4132. def_system_macro('CPUMIPS32');
  4133. def_system_macro('CPUMIPSEB32');
  4134. def_system_macro('CPU32');
  4135. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  4136. def_system_macro('FPC_HAS_TYPE_SINGLE');
  4137. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  4138. def_system_macro('FPC_CURRENCY_IS_INT64');
  4139. def_system_macro('FPC_COMP_IS_INT64');
  4140. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  4141. { See comment above for mipsel }
  4142. def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
  4143. {$endif mipseb}
  4144. {$ifdef mips64eb}
  4145. def_system_macro('CPUMIPS');
  4146. def_system_macro('CPUMIPS64');
  4147. def_system_macro('CPUMIPSEB64');
  4148. def_system_macro('CPUMIPS64EB');
  4149. def_system_macro('CPU64');
  4150. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  4151. def_system_macro('FPC_CURRENCY_IS_INT64');
  4152. def_system_macro('FPC_COMP_IS_INT64');
  4153. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  4154. { See comment above for mipsel }
  4155. def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
  4156. {$endif mips64eb}
  4157. {$ifdef mips64el}
  4158. def_system_macro('CPUMIPS');
  4159. def_system_macro('CPUMIPS64');
  4160. def_system_macro('CPUMIPSEL64');
  4161. def_system_macro('CPUMIPS64EL');
  4162. def_system_macro('CPU64');
  4163. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  4164. def_system_macro('FPC_HAS_TYPE_SINGLE');
  4165. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  4166. def_system_macro('FPC_CURRENCY_IS_INT64');
  4167. def_system_macro('FPC_COMP_IS_INT64');
  4168. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  4169. { On most systems, locals are accessed relative to base pointer,
  4170. but for MIPS cpu, they are accessed relative to stack pointer.
  4171. This needs adaptation for so low level routines,
  4172. like MethodPointerLocal and related objects unit functions. }
  4173. def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
  4174. {$endif mips64el}
  4175. {$ifdef i8086}
  4176. def_system_macro('CPU86'); { Borland compatibility }
  4177. def_system_macro('CPU87'); { Borland compatibility }
  4178. def_system_macro('CPUI8086');
  4179. def_system_macro('CPU16');
  4180. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  4181. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  4182. def_system_macro('FPC_HAS_TYPE_SINGLE');
  4183. case init_settings.x86memorymodel of
  4184. mm_tiny: def_system_macro('FPC_MM_TINY');
  4185. mm_small: def_system_macro('FPC_MM_SMALL');
  4186. mm_medium: def_system_macro('FPC_MM_MEDIUM');
  4187. mm_compact: def_system_macro('FPC_MM_COMPACT');
  4188. mm_large: def_system_macro('FPC_MM_LARGE');
  4189. mm_huge: def_system_macro('FPC_MM_HUGE');
  4190. end;
  4191. {$endif i8086}
  4192. {$ifdef aarch64}
  4193. def_system_macro('CPUAARCH64');
  4194. def_system_macro('CPU64');
  4195. def_system_macro('FPC_CURRENCY_IS_INT64');
  4196. def_system_macro('FPC_COMP_IS_INT64');
  4197. {$endif aarch64}
  4198. {$ifdef riscv32}
  4199. def_system_macro('CPURISCV');
  4200. def_system_macro('CPURISCV32');
  4201. def_system_macro('CPU32');
  4202. def_system_macro('FPC_CURRENCY_IS_INT64');
  4203. def_system_macro('FPC_COMP_IS_INT64');
  4204. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  4205. {$endif riscv32}
  4206. {$ifdef riscv64}
  4207. def_system_macro('CPURISCV');
  4208. def_system_macro('CPURISCV64');
  4209. def_system_macro('CPU64');
  4210. def_system_macro('FPC_CURRENCY_IS_INT64');
  4211. def_system_macro('FPC_COMP_IS_INT64');
  4212. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  4213. {$endif riscv64}
  4214. {$ifdef xtensa}
  4215. def_system_macro('CPUXTENSA');
  4216. def_system_macro('CPU32');
  4217. def_system_macro('FPC_CURRENCY_IS_INT64');
  4218. def_system_macro('FPC_COMP_IS_INT64');
  4219. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  4220. {$endif xtensa}
  4221. {$ifdef z80}
  4222. def_system_macro('CPUZ80');
  4223. def_system_macro('CPU16');
  4224. def_system_macro('FPC_CURRENCY_IS_INT64');
  4225. def_system_macro('FPC_COMP_IS_INT64');
  4226. {$endif z80}
  4227. {$ifdef wasm32}
  4228. def_system_macro('CPUWASM');
  4229. def_system_macro('CPUWASM32');
  4230. def_system_macro('CPU32');
  4231. def_system_macro('FPC_CURRENCY_IS_INT64');
  4232. def_system_macro('FPC_COMP_IS_INT64');
  4233. {$endif wasm32}
  4234. {$ifdef loongarch64}
  4235. def_system_macro('CPULOONGARCH');
  4236. def_system_macro('CPULOONGARCH64');
  4237. def_system_macro('CPU64');
  4238. def_system_macro('FPC_CURRENCY_IS_INT64');
  4239. def_system_macro('FPC_COMP_IS_INT64');
  4240. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  4241. def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
  4242. {$endif loongarch64}
  4243. {$if defined(cpu8bitalu)}
  4244. def_system_macro('CPUINT8');
  4245. {$elseif defined(cpu16bitalu)}
  4246. def_system_macro('CPUINT16');
  4247. {$elseif defined(cpu32bitalu)}
  4248. def_system_macro('CPUINT32');
  4249. {$elseif defined(cpu64bitalu)}
  4250. def_system_macro('CPUINT64');
  4251. {$endif defined(cpu64bitalu)}
  4252. {$if defined(avr)}
  4253. def_system_macro('FPC_HAS_INTERNAL_ABS_SHORTINT');
  4254. {$endif}
  4255. {$if defined(i8086) or defined(avr)}
  4256. def_system_macro('FPC_HAS_INTERNAL_ABS_SMALLINT');
  4257. {$endif i8086 or avr}
  4258. { abs(long) is handled internally on all CPUs }
  4259. def_system_macro('FPC_HAS_INTERNAL_ABS_LONG');
  4260. {$if defined(i8086) or defined(i386) or defined(x86_64) or defined(powerpc64) or defined(aarch64)}
  4261. def_system_macro('FPC_HAS_INTERNAL_ABS_INT64');
  4262. {$endif i8086 or i386 or x86_64 or powerpc64 or aarch64}
  4263. def_system_macro('FPC_HAS_UNICODESTRING');
  4264. def_system_macro('FPC_RTTI_PACKSET1');
  4265. def_system_macro('FPC_HAS_CPSTRING');
  4266. {$ifdef x86_64}
  4267. def_system_macro('FPC_HAS_RIP_RELATIVE');
  4268. {$endif x86_64}
  4269. def_system_macro('FPC_HAS_CEXTENDED');
  4270. def_system_macro('FPC_HAS_RESSTRINITS');
  4271. { these cpus have an inline rol/ror implementaion }
  4272. {$ifdef cpurox}
  4273. {$ifdef m68k}
  4274. if CPUM68K_HAS_ROLROR in cpu_capabilities[init_settings.cputype] then
  4275. def_system_macro('FPC_HAS_INTERNAL_ROX');
  4276. {$else}
  4277. def_system_macro('FPC_HAS_INTERNAL_ROX');
  4278. {$endif}
  4279. {$endif}
  4280. {$ifdef powerpc64}
  4281. def_system_macro('FPC_HAS_LWSYNC');
  4282. {$endif}
  4283. { currently, all supported CPUs have an internal sar implementation }
  4284. def_system_macro('FPC_HAS_INTERNAL_SAR');
  4285. {$ifdef SUPPORT_GET_FRAME}
  4286. def_system_macro('INTERNAL_BACKTRACE');
  4287. {$endif SUPPORT_GET_FRAME}
  4288. def_system_macro('STR_CONCAT_PROCS');
  4289. {$warnings off}
  4290. if pocall_default = pocall_register then
  4291. def_system_macro('REGCALL');
  4292. {$warnings on}
  4293. end;
  4294. var
  4295. env: ansistring;
  4296. i : tfeature;
  4297. j : longint;
  4298. tmplist : TCmdStrList;
  4299. cmditem,
  4300. tmpcmditem : TCmdStrListItem;
  4301. cmdstr : TCmdStr;
  4302. {$if defined(cpucapabilities)}
  4303. cpuflag : tcpuflags;
  4304. {$endif defined(cpucapabilities)}
  4305. {$if defined(fpucapabilities)}
  4306. fpuflag : tfpuflags;
  4307. {$endif defined(fpucapabilities)}
  4308. {$if defined(cpucapabilities) or defined(fpucapabilities)}
  4309. hs : string;
  4310. {$endif defined(cpucapabilities) or defined(fpucapabilities)}
  4311. begin
  4312. option:=coption.create;
  4313. disable_configfile:=false;
  4314. { Non-core target defines }
  4315. Option.TargetOptions(true);
  4316. { get default messagefile }
  4317. msgfilename:=GetEnvironmentVariable('PPC_ERROR_FILE');
  4318. { default configfile can be specified on the commandline,
  4319. remove it first }
  4320. if (cmd<>'') and (cmd[1]='[') then
  4321. begin
  4322. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  4323. Delete(cmd,1,pos(']',cmd));
  4324. end
  4325. else
  4326. ppccfg:='fpc.cfg';
  4327. { first pass reading of parameters, only -i -v -T etc.}
  4328. option.firstpass:=true;
  4329. if cmd<>'' then
  4330. option.parsecmd(cmd)
  4331. else
  4332. begin
  4333. option.read_parameters;
  4334. { Write only quickinfo }
  4335. if option.quickinfo<>'' then
  4336. option.writequickinfo;
  4337. end;
  4338. option.firstpass:=false;
  4339. { redefine target options so all defines are written even if no -Txxx is passed on the command line }
  4340. Option.TargetOptions(true);
  4341. { target is set here, for wince the default app type is gui }
  4342. if target_info.system in systems_wince then
  4343. SetApptype(app_gui)
  4344. else
  4345. SetApptype(apptype);
  4346. { default defines }
  4347. def_system_macro(target_info.shortname);
  4348. def_system_macro('FPC');
  4349. def_system_macro('VER'+version_nr);
  4350. def_system_macro('VER'+version_nr+'_'+release_nr);
  4351. def_system_macro('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  4352. { Temporary defines, until things settle down }
  4353. def_system_macro('FPC_HAS_OPERATOR_ENUMERATOR');
  4354. def_system_macro('FPC_HAS_CONSTREF');
  4355. def_system_macro('FPC_STATICRIPFIXED');
  4356. def_system_macro('FPC_VARIANTCOPY_FIXED');
  4357. def_system_macro('FPC_DYNARRAYCOPY_FIXED');
  4358. def_system_macro('FPC_HAS_MEMBAR');
  4359. def_system_macro('FPC_SETBASE_USED');
  4360. def_system_macro('FPC_ALIGNED_THREADVARTABLES');
  4361. { don't remove this, it's also for fpdoc necessary (FK) }
  4362. def_system_macro('FPC_HAS_FEATURE_SUPPORT');
  4363. { make cpu makros available when reading the config files the second time }
  4364. def_cpu_macros;
  4365. set_endianess_macros;
  4366. if tf_cld in target_info.flags then
  4367. if not UpdateTargetSwitchStr('CLD', init_settings.targetswitches, true) then
  4368. InternalError(2013092801);
  4369. if tf_x86_far_procs_push_odd_bp in target_info.flags then
  4370. if not UpdateTargetSwitchStr('FARPROCSPUSHODDBP', init_settings.targetswitches, true) then
  4371. InternalError(2013092802);
  4372. { Use standard Android NDK prefixes when cross-compiling }
  4373. if (source_info.system<>target_info.system) and (target_info.system in systems_android) then
  4374. case target_info.system of
  4375. system_arm_android:
  4376. utilsprefix:='arm-linux-androideabi-';
  4377. system_i386_android:
  4378. utilsprefix:='i686-linux-android-';
  4379. else
  4380. utilsprefix:=target_cpu_string + '-linux-android-';
  4381. end;
  4382. { Set up default value for the heap on Amiga-likes (values only apply if the OSHeap allocator is used) }
  4383. if target_info.system in systems_amigalike then
  4384. begin
  4385. case target_info.system of
  4386. system_m68k_amiga:
  4387. heapsize:=256*1024;
  4388. system_powerpc_amiga,
  4389. system_powerpc_morphos,
  4390. system_arm_aros,
  4391. system_i386_aros,
  4392. system_x86_64_aros:
  4393. heapsize:=1024*1024;
  4394. else
  4395. heapsize:=256*1024;
  4396. end;
  4397. end;
  4398. if target_info.system in (systems_embedded+systems_freertos+[system_z80_zxspectrum,system_z80_msxdos]) then
  4399. begin
  4400. case target_info.system of
  4401. {$ifdef AVR}
  4402. system_avr_embedded:
  4403. if init_settings.controllertype=ct_avrsim then
  4404. heapsize:=8192
  4405. else
  4406. heapsize:=128;
  4407. {$endif AVR}
  4408. system_arm_freertos:
  4409. heapsize:=8192;
  4410. system_xtensa_freertos:
  4411. { keep default value }
  4412. ;
  4413. system_arm_embedded:
  4414. heapsize:=256;
  4415. system_mipsel_embedded:
  4416. heapsize:=256;
  4417. else
  4418. heapsize:=256;
  4419. end;
  4420. end;
  4421. { read configuration file }
  4422. if (not disable_configfile) and
  4423. (ppccfg<>'') then
  4424. read_configfile:=check_configfile(ppccfg,ppccfg)
  4425. else
  4426. read_configfile := false;
  4427. { Read commandline and configfile }
  4428. param_file:='';
  4429. { read configfile }
  4430. if read_configfile then
  4431. option.interpret_file(ppccfg);
  4432. { read parameters again to override config file }
  4433. if cmd<>'' then
  4434. option.parsecmd(cmd)
  4435. else
  4436. begin
  4437. { Write help pages if no parameters are passed }
  4438. if (paramcount=0) then
  4439. Option.WriteHelpPages;
  4440. option.read_parameters;
  4441. { Write only quickinfo }
  4442. if option.quickinfo<>'' then
  4443. option.writequickinfo;
  4444. end;
  4445. { check the compatibility of different options and adjust them if necessary
  4446. (and print possible errors)
  4447. }
  4448. option.checkoptionscompatibility;
  4449. { uses the CPUXXX-defines and target_info to determine whether the selected
  4450. target processor, if any, is supported }
  4451. Option.VerifyTargetProcessor;
  4452. { Stop if errors in options }
  4453. if ErrorCount>0 then
  4454. StopOptions(1);
  4455. { Write logo }
  4456. if option.ParaLogo then
  4457. option.writelogo;
  4458. { Check file to compile }
  4459. if param_file='' then
  4460. begin
  4461. Message(option_no_source_found);
  4462. StopOptions(1);
  4463. end;
  4464. {$ifndef Unix}
  4465. param_file:=FixFileName(param_file);
  4466. {$endif not unix}
  4467. inputfilepath:=ExtractFilePath(param_file);
  4468. inputfilename:=ExtractFileName(param_file);
  4469. if ExtractFileExt(inputfilename)='' then
  4470. begin
  4471. if FileExists(inputfilepath+ChangeFileExt(inputfilename,sourceext)) then
  4472. inputfilename:=ChangeFileExt(inputfilename,sourceext)
  4473. else if FileExists(inputfilepath+ChangeFileExt(inputfilename,pasext)) then
  4474. inputfilename:=ChangeFileExt(inputfilename,pasext)
  4475. else if ((m_mac in current_settings.modeswitches) or
  4476. (tf_p_ext_support in target_info.flags))
  4477. and FileExists(inputfilepath+ChangeFileExt(inputfilename,pext)) then
  4478. inputfilename:=ChangeFileExt(inputfilename,pext);
  4479. end;
  4480. { Check output dir }
  4481. if (OutputExeDir<>'') and
  4482. not PathExists(OutputExeDir,false) then
  4483. begin
  4484. Message1(general_e_path_does_not_exist,OutputExeDir);
  4485. StopOptions(1);
  4486. end;
  4487. { Add paths specified with parameters to the searchpaths }
  4488. UnitSearchPath.AddList(option.ParaUnitPath,true);
  4489. ObjectSearchPath.AddList(option.ParaObjectPath,true);
  4490. IncludeSearchPath.AddList(option.ParaIncludePath,true);
  4491. LibrarySearchPath.AddList(option.ParaLibraryPath,true);
  4492. FrameworkSearchPath.AddList(option.ParaFrameworkPath,true);
  4493. packagesearchpath.addlist(option.parapackagepath,true);
  4494. for j:=0 to option.parapackages.count-1 do
  4495. add_package(option.parapackages.NameOfIndex(j),true,true);
  4496. { add default namespaces }
  4497. tmplist:=TCmdStrList.Create;
  4498. cmditem:=TCmdStrListItem(option.paranamespaces.First);
  4499. while assigned(cmditem) do
  4500. begin
  4501. { use a temporary list cause if ";" are involved we need to reverse the
  4502. order due to how TCmdStrList behaves }
  4503. cmdstr:=cmditem.str;
  4504. repeat
  4505. j:=Pos(';',cmdstr);
  4506. if j>0 then
  4507. begin
  4508. tmplist.insert(copy(cmdstr,1,j-1));
  4509. delete(cmdstr,1,j);
  4510. end
  4511. else
  4512. tmplist.insert(cmdstr);
  4513. until j=0;
  4514. tmpcmditem:=TCmdStrListItem(tmplist.First);
  4515. while assigned(tmpcmditem) do
  4516. begin
  4517. namespacelist.insert(tmpcmditem.Str);
  4518. tmpcmditem:=TCmdStrListItem(tmpcmditem.Next);
  4519. end;
  4520. tmplist.clear;
  4521. cmditem:=TCmdStrListItem(cmditem.Next);
  4522. end;
  4523. tmplist.Free;
  4524. { add unit environment and exepath to the unit search path }
  4525. if inputfilepath<>'' then
  4526. Unitsearchpath.AddPath(inputfilepath,true);
  4527. if not disable_configfile then
  4528. begin
  4529. env:=GetEnvironmentVariable(target_info.unit_env);
  4530. if env<>'' then
  4531. UnitSearchPath.AddPath(GetEnvironmentVariable(target_info.unit_env),false);
  4532. end;
  4533. {$ifdef Unix}
  4534. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  4535. if fpcdir='' then
  4536. begin
  4537. if PathExists('/usr/local/lib/fpc/'+version_string,true) then
  4538. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  4539. else
  4540. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  4541. end;
  4542. {$else unix}
  4543. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  4544. if fpcdir='' then
  4545. begin
  4546. fpcdir:=ExePath+'../';
  4547. if not(PathExists(fpcdir+'units',true)) and
  4548. not(PathExists(fpcdir+'rtl',true)) then
  4549. fpcdir:=fpcdir+'../';
  4550. end;
  4551. {$endif unix}
  4552. { first try development RTL, else use the default installation path }
  4553. if not disable_configfile then
  4554. begin
  4555. if PathExists(FpcDir+'rtl',true) then
  4556. if (tf_use_8_3 in Source_Info.Flags) or
  4557. (tf_use_8_3 in Target_Info.Flags) then
  4558. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_os_string,false)
  4559. else
  4560. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_full_string,false)
  4561. else
  4562. if (tf_use_8_3 in Source_Info.Flags) or
  4563. (tf_use_8_3 in Target_Info.Flags) then
  4564. UnitSearchPath.AddPath(FpcDir+'units/'+target_os_string+'/rtl',false)
  4565. else
  4566. UnitSearchPath.AddPath(FpcDir+'units/'+target_full_string+'/rtl',false);
  4567. end;
  4568. { Add exepath if the exe is not in the current dir, because that is always searched already.
  4569. Do not add it when linking on the target because then we can maybe already find
  4570. .o files that are not for the target }
  4571. if (ExePath<>cfileutl.GetCurrentDir) and
  4572. not(cs_link_on_target in init_settings.globalswitches) then
  4573. UnitSearchPath.AddPath(ExePath,false);
  4574. { Add unit dir to the object and library path }
  4575. objectsearchpath.AddList(unitsearchpath,false);
  4576. librarysearchpath.AddList(unitsearchpath,false);
  4577. {$ifdef llvm}
  4578. { default to clang }
  4579. if (option.paratargetasm=as_none) then
  4580. begin
  4581. if not(target_info.system in systems_darwin) then
  4582. option.paratargetasm:=as_clang_llvm
  4583. else
  4584. option.paratargetasm:=as_clang_llvm_darwin;
  4585. end;
  4586. {$endif llvm}
  4587. { maybe override assembler }
  4588. if (option.paratargetasm<>as_none) then
  4589. begin
  4590. if (option.paratargetasm=as_default) then
  4591. begin
  4592. option.paratargetasm:=target_info.assem;
  4593. end;
  4594. if not set_target_asm(option.paratargetasm) then
  4595. begin
  4596. if assigned(asminfos[option.paratargetasm]) then
  4597. Message2(option_incompatible_asm,asminfos[option.paratargetasm]^.idtxt,target_info.name)
  4598. else
  4599. Message2(option_incompatible_asm,'<invalid assembler>',target_info.name);
  4600. set_target_asm(target_info.assemextern);
  4601. Message1(option_asm_forced,target_asm.idtxt);
  4602. end;
  4603. if (af_no_debug in asminfos[option.paratargetasm]^.flags) and
  4604. (option.paratargetdbg<>dbg_none) then
  4605. begin
  4606. Message1(option_confict_asm_debug,
  4607. asminfos[option.paratargetasm]^.idtxt);
  4608. option.paratargetdbg:=dbg_none;
  4609. exclude(init_settings.moduleswitches,cs_debuginfo);
  4610. end;
  4611. { Some assemblers, like clang, do not support
  4612. stabs debugging format, switch to dwardé in that case }
  4613. if (af_no_stabs in asminfos[option.paratargetasm]^.flags) and
  4614. (option.paratargetdbg=dbg_stabs) then
  4615. begin
  4616. option.paratargetdbg:=dbg_dwarf2;
  4617. end;
  4618. end;
  4619. {TOptionheck a second time as we might have changed assembler just above }
  4620. option.checkoptionscompatibility;
  4621. { maybe override debug info format }
  4622. if (option.paratargetdbg<>dbg_none) then
  4623. if not set_target_dbg(option.paratargetdbg) then
  4624. Message(option_w_unsupported_debug_format);
  4625. { switch assembler if it's binary and we got -a on the cmdline }
  4626. if (af_outputbinary in target_asm.flags) and
  4627. ((cs_asm_leave in init_settings.globalswitches) or
  4628. { if -s is passed, we shouldn't call the internal assembler }
  4629. (cs_asm_extern in init_settings.globalswitches)) then
  4630. begin
  4631. Message(option_switch_bin_to_src_assembler);
  4632. {$ifdef llvm}
  4633. if not(target_info.system in systems_darwin) then
  4634. set_target_asm(as_clang_llvm)
  4635. else
  4636. set_target_asm(as_clang_llvm_darwin);
  4637. {$else}
  4638. set_target_asm(target_info.assemextern);
  4639. {$endif}
  4640. { At least i8086 needs that for nasm and -CX
  4641. which is incompatible with internal linker }
  4642. option.checkoptionscompatibility;
  4643. end;
  4644. { Force use of external linker if there is no
  4645. internal linker or the linking is skipped }
  4646. if not(cs_link_extern in init_settings.globalswitches) and
  4647. ((target_info.link=ld_none) or
  4648. (cs_link_nolink in init_settings.globalswitches)) then
  4649. begin
  4650. include(init_settings.globalswitches,cs_link_extern);
  4651. end;
  4652. { turn off stripping if compiling with debuginfo or profile }
  4653. if (
  4654. (cs_debuginfo in init_settings.moduleswitches) or
  4655. (cs_profile in init_settings.moduleswitches)
  4656. ) and
  4657. not(cs_link_separate_dbg_file in init_settings.globalswitches) then
  4658. exclude(init_settings.globalswitches,cs_link_strip);
  4659. { choose a reasonable tls model }
  4660. if (tf_section_threadvars in target_info.flags) and (init_settings.tlsmodel=tlsm_none) then
  4661. begin
  4662. if cs_create_pic in init_settings.moduleswitches then
  4663. init_settings.tlsmodel:=tlsm_global_dynamic
  4664. else
  4665. init_settings.tlsmodel:=tlsm_local_exec;
  4666. end;
  4667. { set Mac OS X version default macros if not specified explicitly }
  4668. option.MaybeSetDefaultMacVersionMacro;
  4669. {$ifdef XTENSA}
  4670. { set ESP32 or ESP8266 default SDK versions }
  4671. option.MaybeSetIdfVersionMacro;
  4672. {$endif XTENSA}
  4673. {$ifdef cpufpemu}
  4674. { force fpu emulation on arm/wince, arm/gba, arm/embedded and arm/nds etc.
  4675. if fpu type not explicitly set }
  4676. if not(option.FPUSetExplicitly) and
  4677. ((target_info.system in [system_arm_wince,system_arm_gba,
  4678. system_m68k_amiga,system_m68k_atari,
  4679. system_arm_nds,system_arm_embedded,system_arm_freertos,
  4680. system_riscv32_embedded,system_riscv64_embedded,system_xtensa_linux,
  4681. system_z80_embedded,system_z80_zxspectrum,system_riscv32_freertos])
  4682. {$ifdef arm}
  4683. or (target_info.abi=abi_eabi)
  4684. {$endif arm}
  4685. )
  4686. or (init_settings.fputype=fpu_soft)
  4687. then
  4688. begin
  4689. include(init_settings.moduleswitches,cs_fp_emulation);
  4690. { cs_fp_emulation and fpu_soft are equal on arm and m68k }
  4691. init_settings.fputype:=fpu_soft;
  4692. end;
  4693. {$endif cpufpemu}
  4694. {$ifdef i386}
  4695. if target_info.system in systems_i386_default_486 then
  4696. begin
  4697. { Avoid use of MMX/CMOVcc instructions on older systems.
  4698. Some systems might not handle these instructions correctly,
  4699. Used emulators might also be problematic. PM }
  4700. if not option.CPUSetExplicitly then
  4701. init_settings.cputype:=cpu_486;
  4702. end;
  4703. case target_info.system of
  4704. system_i386_android:
  4705. begin
  4706. { set default cpu type to PentiumM for Android unless specified otherwise }
  4707. if not option.CPUSetExplicitly then
  4708. init_settings.cputype:=cpu_PentiumM;
  4709. if not option.OptCPUSetExplicitly then
  4710. init_settings.optimizecputype:=cpu_PentiumM;
  4711. { set default fpu type to SSSE3 for Android unless specified otherwise }
  4712. if not option.FPUSetExplicitly then
  4713. init_settings.fputype:=fpu_ssse3;
  4714. end;
  4715. else
  4716. ;
  4717. end;
  4718. {$endif i386}
  4719. {$ifdef xtensa}
  4720. { xtensa-linux target does not support controller setting option -Wp }
  4721. if not(option.FPUSetExplicitly) and not(target_info.system = system_xtensa_linux) then
  4722. begin
  4723. init_settings.fputype:=embedded_controllers[init_settings.controllertype].fputype;
  4724. if (init_settings.fputype=fpu_soft) then
  4725. include(init_settings.moduleswitches,cs_fp_emulation);
  4726. end;
  4727. if not(option.CPUSetExplicitly) and (target_info.system=system_xtensa_linux) then
  4728. init_settings.cputype:=cpu_lx6;
  4729. if (target_info.system in [system_xtensa_embedded,system_xtensa_freertos]) and not(option.ABISetExplicitly) then
  4730. begin
  4731. if CPUXTENSA_REGWINDOW in cpu_capabilities[init_settings.cputype] then
  4732. target_info.abi:=abi_xtensa_windowed
  4733. else
  4734. target_info.abi:=abi_xtensa_call0;
  4735. end;
  4736. {$endif xtensa}
  4737. {$ifdef arm}
  4738. case target_info.system of
  4739. system_arm_ios:
  4740. begin
  4741. { set default cpu type to ARMv7 for Darwin unless specified otherwise, and fpu
  4742. to VFPv3 (that's what all 32 bit ARM iOS devices use nowadays)
  4743. }
  4744. if not option.CPUSetExplicitly then
  4745. init_settings.cputype:=cpu_armv7;
  4746. if not option.OptCPUSetExplicitly then
  4747. init_settings.optimizecputype:=cpu_armv7;
  4748. if not option.FPUSetExplicitly then
  4749. init_settings.fputype:=fpu_vfpv3;
  4750. end;
  4751. system_arm_android:
  4752. begin
  4753. { set default cpu type to ARMv5T for Android unless specified otherwise }
  4754. if not option.CPUSetExplicitly then
  4755. init_settings.cputype:=cpu_armv5t;
  4756. if not option.OptCPUSetExplicitly then
  4757. init_settings.optimizecputype:=cpu_armv5t;
  4758. end;
  4759. else
  4760. ;
  4761. end;
  4762. { set ABI defaults }
  4763. case target_info.abi of
  4764. abi_eabihf:
  4765. { set default cpu type to ARMv7a for ARMHF unless specified otherwise }
  4766. begin
  4767. {$ifdef CPUARMV6}
  4768. { if the compiler is built for armv6, then
  4769. inherit this setting, e.g. Raspian is armhf but
  4770. only armv6, this makes rebuilds of the compiler
  4771. easier }
  4772. if not option.CPUSetExplicitly then
  4773. init_settings.cputype:=cpu_armv6;
  4774. if not option.OptCPUSetExplicitly then
  4775. init_settings.optimizecputype:=cpu_armv6;
  4776. {$else CPUARMV6}
  4777. if not option.CPUSetExplicitly then
  4778. init_settings.cputype:=cpu_armv7a;
  4779. if not option.OptCPUSetExplicitly then
  4780. init_settings.optimizecputype:=cpu_armv7a;
  4781. {$endif CPUARMV6}
  4782. { Set FPU type }
  4783. if not(option.FPUSetExplicitly) then
  4784. begin
  4785. if init_settings.cputype < cpu_armv7 then
  4786. init_settings.fputype:=fpu_vfpv2
  4787. else
  4788. init_settings.fputype:=fpu_vfpv3_d16;
  4789. end
  4790. else
  4791. begin
  4792. if (not(FPUARM_HAS_VFP_EXTENSION in fpu_capabilities[init_settings.fputype]))
  4793. or (target_info.system = system_arm_ios) then
  4794. begin
  4795. Message(option_illegal_fpu_eabihf);
  4796. StopOptions(1);
  4797. end;
  4798. end;
  4799. end;
  4800. abi_eabi:
  4801. begin
  4802. if target_info.system=system_arm_linux then
  4803. begin
  4804. { this is what Debian uses }
  4805. if not option.CPUSetExplicitly then
  4806. init_settings.cputype:=cpu_armv4t;
  4807. if not option.OptCPUSetExplicitly then
  4808. init_settings.optimizecputype:=cpu_armv4t;
  4809. if not(option.FPUSetExplicitly) then
  4810. init_settings.fputype:=fpu_soft;
  4811. end;
  4812. end;
  4813. else
  4814. ;
  4815. end;
  4816. if (init_settings.instructionset=is_thumb) and not(CPUARM_HAS_THUMB2 in cpu_capabilities[init_settings.cputype]) then
  4817. begin
  4818. def_system_macro('CPUTHUMB');
  4819. if not option.FPUSetExplicitly then
  4820. init_settings.fputype:=fpu_soft;
  4821. if not(init_settings.fputype in [fpu_none,fpu_soft,fpu_libgcc]) then
  4822. Message2(option_unsupported_fpu,fputypestr[init_settings.fputype],'Thumb');
  4823. {$if defined(FPC_ARMEL) or defined(FPC_ARMHF)}
  4824. target_info.llvmdatalayout:='e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:32-n32-S64';
  4825. {$else FPC_ARMAL or FPC_ARMHF}
  4826. if target_info.endian=endian_little then
  4827. target_info.llvmdatalayout:='e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32';
  4828. {$endif FPC_ARMAL or FPC_ARMHF}
  4829. end;
  4830. if (init_settings.instructionset=is_thumb) and (CPUARM_HAS_THUMB2 in cpu_capabilities[init_settings.cputype]) then
  4831. def_system_macro('CPUTHUMB2');
  4832. {$endif arm}
  4833. {$ifdef aarch64}
  4834. case target_info.system of
  4835. system_aarch64_darwin:
  4836. begin
  4837. if not option.CPUSetExplicitly then
  4838. init_settings.cputype:=cpu_armv84a;
  4839. if not option.OptCPUSetExplicitly then
  4840. init_settings.optimizecputype:=cpu_armv84a;
  4841. end;
  4842. else
  4843. ;
  4844. end;
  4845. {$endif aarch64}
  4846. {$if defined(riscv32) or defined(riscv64)}
  4847. { RISC-V defaults }
  4848. if (target_info.abi = abi_riscv_hf) then
  4849. begin
  4850. {$ifdef riscv32}
  4851. if not option.CPUSetExplicitly then
  4852. init_settings.cputype:=cpu_rv32ima;
  4853. if not option.OptCPUSetExplicitly then
  4854. init_settings.optimizecputype:=cpu_rv32ima;
  4855. {$else}
  4856. if not option.CPUSetExplicitly then
  4857. init_settings.cputype:=cpu_rv64imac;
  4858. if not option.OptCPUSetExplicitly then
  4859. init_settings.optimizecputype:=cpu_rv64imac;
  4860. {$endif}
  4861. { Set FPU type }
  4862. if not(option.FPUSetExplicitly) then
  4863. init_settings.fputype:=fpu_fd
  4864. else
  4865. begin
  4866. if not (init_settings.fputype in [fpu_fd]) then
  4867. begin
  4868. Message(option_illegal_fpu_eabihf);
  4869. StopOptions(1);
  4870. end;
  4871. end;
  4872. end;
  4873. {$endif defined(riscv32) or defined(riscv64)}
  4874. {$ifdef jvm}
  4875. { set default CPU type to Dalvik when targeting Android }
  4876. if target_info.system=system_jvm_android32 then
  4877. begin
  4878. if not option.CPUSetExplicitly then
  4879. init_settings.cputype:=cpu_dalvik;
  4880. end;
  4881. {$endif jvm}
  4882. {$ifdef llvm}
  4883. { standard extension for llvm bitcode files }
  4884. target_info.asmext:='.ll';
  4885. { don't generate dwarf cfi, llvm will do that }
  4886. exclude(target_info.flags,tf_needs_dwarf_cfi);
  4887. {$endif llvm}
  4888. {$ifdef mipsel}
  4889. case target_info.system of
  4890. system_mipsel_android:
  4891. begin
  4892. { set default cpu type to MIPS32 rev. 1 and hard float for MIPS-Android unless specified otherwise }
  4893. if not option.CPUSetExplicitly then
  4894. init_settings.cputype:=cpu_mips32;
  4895. if not option.OptCPUSetExplicitly then
  4896. init_settings.optimizecputype:=cpu_mips32;
  4897. if not option.FPUSetExplicitly then
  4898. init_settings.fputype:=fpu_mips2;
  4899. end;
  4900. system_mipsel_embedded:
  4901. begin
  4902. { set default cpu type to PIC32MX and softfloat for MIPSEL-EMBEDDED target unless specified otherwise }
  4903. if not option.CPUSetExplicitly then
  4904. init_settings.cputype:=cpu_pic32mx;
  4905. if not option.OptCPUSetExplicitly then
  4906. init_settings.optimizecputype:=cpu_pic32mx;
  4907. if not option.FPUSetExplicitly then
  4908. init_settings.fputype:=fpu_soft;
  4909. end;
  4910. else
  4911. ;
  4912. end;
  4913. {$endif mipsel}
  4914. {$ifdef m68k}
  4915. if init_settings.cputype in cpu_coldfire then
  4916. def_system_macro('CPUCOLDFIRE');
  4917. case target_info.system of
  4918. system_m68k_linux,
  4919. system_m68k_netbsd:
  4920. begin
  4921. if not (option.FPUSetExplicitly) and
  4922. not (init_settings.cputype in cpu_coldfire) then
  4923. begin
  4924. { enable HW FPU for UNIX by default, but only for
  4925. original 68k, not Coldfire }
  4926. exclude(init_settings.moduleswitches,cs_fp_emulation);
  4927. init_settings.fputype:=fpu_68881;
  4928. end;
  4929. end;
  4930. system_m68k_atari,
  4931. system_m68k_sinclairql:
  4932. begin
  4933. if not option.CPUSetExplicitly then
  4934. init_settings.cputype:=cpu_mc68000;
  4935. end;
  4936. system_m68k_palmos:
  4937. begin
  4938. if not option.CPUSetExplicitly then
  4939. init_settings.cputype:=cpu_mc68000;
  4940. if not (option.FPUSetExplicitly) then
  4941. begin
  4942. { No FPU for PalmOS by default }
  4943. exclude(init_settings.moduleswitches,cs_fp_emulation);
  4944. init_settings.fputype:=fpu_none;
  4945. end;
  4946. end;
  4947. else
  4948. ;
  4949. end;
  4950. {$endif m68k}
  4951. {$ifdef wasm}
  4952. { if no explicit exception handling mode is set for WebAssembly, assume no exceptions }
  4953. if init_settings.targetswitches*[ts_wasm_no_exceptions,ts_wasm_js_exceptions,ts_wasm_native_exceptions,ts_wasm_bf_exceptions]=[] then
  4954. begin
  4955. def_system_macro(TargetSwitchStr[ts_wasm_no_exceptions].define);
  4956. include(init_settings.targetswitches,ts_wasm_no_exceptions);
  4957. end;
  4958. {$endif wasm}
  4959. {$if defined(loongarch64)}
  4960. { LoongArch defaults }
  4961. if (target_info.abi = abi_riscv_hf) then
  4962. begin
  4963. init_settings.cputype:=cpu_3a;
  4964. init_settings.fputype:=fpu_fd;
  4965. end;
  4966. {$endif defined(loongarch64)}
  4967. { now we can define cpu and fpu type }
  4968. def_cpu_macros;
  4969. set_endianess_macros;
  4970. { Use init_settings cpu type for asm cpu type,
  4971. if asmcputype is cpu_none,
  4972. at least as long as there is no explicit
  4973. option to set it on command line PM }
  4974. if init_settings.asmcputype = cpu_none then
  4975. init_settings.asmcputype:=init_settings.cputype;
  4976. {$ifdef llvm}
  4977. def_system_macro('CPULLVM');
  4978. {$endif llvm}
  4979. {$if defined(cpucapabilities)}
  4980. for cpuflag:=low(cpuflag) to high(cpuflag) do
  4981. begin
  4982. str(cpuflag,hs);
  4983. if cpuflag in cpu_capabilities[init_settings.cputype] then
  4984. def_system_macro(hs)
  4985. else
  4986. undef_system_macro(hs);
  4987. end;
  4988. {$endif defined(cpucapabilities)}
  4989. {$if defined(fpucapabilities)}
  4990. for fpuflag:=low(fpuflag) to high(fpuflag) do
  4991. begin
  4992. str(fpuflag,hs);
  4993. if fpuflag in fpu_capabilities[init_settings.fputype] then
  4994. def_system_macro(hs)
  4995. else
  4996. undef_system_macro(hs);
  4997. end;
  4998. {$endif defined(fpucapabilities)}
  4999. if init_settings.fputype<>fpu_none then
  5000. begin
  5001. {$if defined(i386) or defined(i8086)}
  5002. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  5003. {$endif}
  5004. def_system_macro('FPC_HAS_TYPE_SINGLE');
  5005. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  5006. {$if not defined(i386) and not defined(x86_64) and not defined(i8086) and not defined(aarch64)}
  5007. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  5008. {$endif}
  5009. {$if defined(m68k)}
  5010. def_system_macro('FPC_INCLUDE_SOFTWARE_LONGWORD_TO_DOUBLE');
  5011. {$endif}
  5012. {$ifdef x86_64}
  5013. {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
  5014. { normally, win64 doesn't support the legacy fpu }
  5015. if target_info.system=system_x86_64_win64 then
  5016. undef_system_macro('FPC_HAS_TYPE_EXTENDED')
  5017. else
  5018. {$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
  5019. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  5020. {$endif}
  5021. end;
  5022. { Enable now for testing }
  5023. {$ifndef DISABLE_TLS_DIRECTORY}
  5024. if target_info.system in systems_windows then
  5025. def_system_macro('FPC_USE_TLS_DIRECTORY');
  5026. {$endif not DISABLE_TLS_DIRECTORY}
  5027. {$ifndef DISABLE_WIN64_SEH}
  5028. if target_info.system=system_x86_64_win64 then
  5029. def_system_macro('FPC_USE_WIN64_SEH');
  5030. {$endif DISABLE_WIN64_SEH}
  5031. {$ifndef DISABLE_WIN32_SEH}
  5032. if target_info.system=system_i386_win32 then
  5033. def_system_macro('FPC_USE_WIN32_SEH');
  5034. {$endif not DISABLE_WIN32_SEH}
  5035. {$ifdef ARM}
  5036. { define FPC_DOUBLE_HILO_SWAPPED if needed to properly handle doubles in RTL }
  5037. if (init_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
  5038. not(cs_fp_emulation in init_settings.moduleswitches) then
  5039. def_system_macro('FPC_DOUBLE_HILO_SWAPPED');
  5040. {$endif ARM}
  5041. { inline bsf/bsr implementation }
  5042. {$if defined(i386) or defined(x86_64) or defined(aarch64) or defined(powerpc) or defined(powerpc64)}
  5043. def_system_macro('FPC_HAS_INTERNAL_BSF');
  5044. def_system_macro('FPC_HAS_INTERNAL_BSR');
  5045. {$endif}
  5046. { hardware FMA support }
  5047. {$if defined(i386) or defined(x86_64)}
  5048. if (fpu_capabilities[current_settings.fputype]*[FPUX86_HAS_FMA,FPUX86_HAS_FMA4])<>[] then
  5049. begin
  5050. def_system_macro('FPC_HAS_FAST_FMA_SINGLE');
  5051. def_system_macro('FPC_HAS_FAST_FMA_DOUBLE');
  5052. end;
  5053. {$endif defined(i386) or defined(x86_64)}
  5054. {$if defined(arm)}
  5055. { it is determined during system unit compilation if clz is used for bsf or not,
  5056. this is not perfect but the current implementation bsf/bsr does not allow another
  5057. solution }
  5058. if (CPUARM_HAS_CLZ in cpu_capabilities[init_settings.cputype]) and
  5059. ((init_settings.instructionset=is_arm) or
  5060. (CPUARM_HAS_THUMB2 in cpu_capabilities[init_settings.cputype])) then
  5061. begin
  5062. def_system_macro('FPC_HAS_INTERNAL_BSR');
  5063. if CPUARM_HAS_RBIT in cpu_capabilities[init_settings.cputype] then
  5064. def_system_macro('FPC_HAS_INTERNAL_BSF');
  5065. end;
  5066. {$endif}
  5067. {$if defined(xtensa)}
  5068. { it is determined during system unit compilation if nsau is used for bsr or not,
  5069. this is not perfect but the current implementation bsf/bsr does not allow another
  5070. solution }
  5071. if CPUXTENSA_HAS_NSAx in cpu_capabilities[init_settings.cputype] then
  5072. begin
  5073. def_system_macro('FPC_HAS_INTERNAL_BSR');
  5074. end;
  5075. {$endif}
  5076. {$if defined(powerpc64)}
  5077. { on sysv targets, default to elfv2 for little endian and to elfv1 for
  5078. big endian (unless specified otherwise). As the gcc man page says:
  5079. "Overriding the default ABI requires special system support and is
  5080. likely to fail in spectacular ways" }
  5081. if not option.ABISetExplicitly then
  5082. begin
  5083. if (target_info.abi=abi_powerpc_sysv) and
  5084. (target_info.endian=endian_little) then
  5085. target_info.abi:=abi_powerpc_elfv2
  5086. else
  5087. if (target_info.abi=abi_powerpc_elfv2) and
  5088. (target_info.endian=endian_big) then
  5089. target_info.abi:=abi_powerpc_sysv
  5090. end;
  5091. {$endif}
  5092. {$if defined(powerpc) or defined(powerpc64)}
  5093. { define _CALL_ELF symbol like gcc }
  5094. case target_info.abi of
  5095. abi_powerpc_sysv:
  5096. set_system_compvar('_CALL_ELF','1');
  5097. abi_powerpc_elfv2:
  5098. set_system_compvar('_CALL_ELF','2');
  5099. else
  5100. ;
  5101. end;
  5102. {$endif}
  5103. { Section smartlinking conflicts with import sections on Windows }
  5104. if GenerateImportSection and
  5105. (target_info.system in [system_i386_win32,system_x86_64_win64,system_aarch64_win64]) then
  5106. exclude(target_info.flags,tf_smartlink_sections);
  5107. if not option.LinkTypeSetExplicitly then
  5108. set_default_link_type;
  5109. { Default alignment settings,
  5110. 1. load the defaults for the target
  5111. 2. adapt defaults specifically for the target
  5112. 3. override with generic optimizer setting (little size)
  5113. 4. override with the user specified -Oa }
  5114. UpdateAlignment(init_settings.alignment,target_info.alignment);
  5115. {$ifdef arm}
  5116. if (init_settings.instructionset=is_thumb) and not(CPUARM_HAS_THUMB2 in cpu_capabilities[init_settings.cputype]) then
  5117. begin
  5118. init_settings.alignment.procalign:=2;
  5119. init_settings.alignment.jumpalign:=2;
  5120. init_settings.alignment.coalescealign:=2;
  5121. init_settings.alignment.loopalign:=2;
  5122. end;
  5123. {$endif arm}
  5124. if (cs_opt_size in init_settings.optimizerswitches) then
  5125. begin
  5126. init_settings.alignment.procalign:=1;
  5127. init_settings.alignment.jumpalign:=1;
  5128. init_settings.alignment.coalescealign:=1;
  5129. init_settings.alignment.loopalign:=1;
  5130. {$ifdef x86}
  5131. { constalignmax=1 keeps the executable and thus the memory foot print small but
  5132. all processors except x86 are really hurt by this or might even crash }
  5133. init_settings.alignment.constalignmax:=1;
  5134. {$endif x86}
  5135. end;
  5136. UpdateAlignment(init_settings.alignment,option.paraalignment);
  5137. set_system_macro('FPC_VERSION',version_nr);
  5138. set_system_macro('FPC_RELEASE',release_nr);
  5139. set_system_macro('FPC_PATCH',patch_nr);
  5140. set_system_macro('FPC_FULLVERSION',Format('%d%.02d%.02d',[StrToInt(version_nr),StrToInt(release_nr),StrToInt(patch_nr)]));
  5141. if target_info.system in systems_indirect_entry_information then
  5142. def_system_macro('FPC_HAS_INDIRECT_ENTRY_INFORMATION');
  5143. if not (tf_winlikewidestring in target_info.flags) then
  5144. def_system_macro('FPC_WIDESTRING_EQUAL_UNICODESTRING');
  5145. if tf_supports_packages in target_info.flags then
  5146. def_system_macro('FPC_HAS_DYNAMIC_PACKAGES');
  5147. if target_info.system in systems_indirect_var_imports then
  5148. def_system_macro('FPC_HAS_INDIRECT_VAR_ACCESS');
  5149. if cs_compilesystem in init_settings.moduleswitches then
  5150. for i:=low(tfeature) to high(tfeature) do
  5151. if i in features then
  5152. def_system_macro('FPC_HAS_FEATURE_'+featurestr[i]);
  5153. {$push}
  5154. {$warn 6018 off} { Unreachable code due to compile time evaluation }
  5155. if ControllerSupport and (target_info.system in (systems_embedded+systems_freertos)) and
  5156. (init_settings.controllertype<>ct_none) then
  5157. begin
  5158. with embedded_controllers[init_settings.controllertype] do
  5159. begin
  5160. set_system_macro('FPC_FLASHBASE',tostr(flashbase));
  5161. set_system_macro('FPC_FLASHSIZE',tostr(flashsize));
  5162. set_system_macro('FPC_SRAMBASE',tostr(srambase));
  5163. set_system_macro('FPC_SRAMSIZE',tostr(sramsize));
  5164. set_system_macro('FPC_EEPROMBASE',tostr(eeprombase));
  5165. set_system_macro('FPC_EEPROMSIZE',tostr(eepromsize));
  5166. set_system_macro('FPC_BOOTBASE',tostr(bootbase));
  5167. set_system_macro('FPC_BOOTSIZE',tostr(bootsize));
  5168. end;
  5169. end;
  5170. {$pop}
  5171. { as stackalign is not part of the alignment record, we do not need to define the others alignments for symmetry yet }
  5172. set_system_macro('FPC_STACKALIGNMENT',tostr(target_info.stackalign));
  5173. option.free;
  5174. Option:=nil;
  5175. clearstack_pocalls := [pocall_cdecl,pocall_cppdecl,pocall_syscall,pocall_mwpascal,pocall_sysv_abi_cdecl,pocall_ms_abi_cdecl{$ifdef z80},pocall_stdcall{$endif}];
  5176. cdecl_pocalls := [pocall_cdecl, pocall_cppdecl, pocall_mwpascal, pocall_sysv_abi_cdecl, pocall_ms_abi_cdecl];
  5177. if (tf_safecall_clearstack in target_info.flags) then
  5178. begin
  5179. include (cdecl_pocalls, pocall_safecall);
  5180. include (clearstack_pocalls, pocall_safecall)
  5181. end;
  5182. end;
  5183. initialization
  5184. coption:=toption;
  5185. finalization
  5186. if assigned(option) then
  5187. option.free;
  5188. end.