options.pas 147 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350
  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,
  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. ParaAlignment : TAlignmentInfo;
  45. parapackages : tfphashobjectlist;
  46. paratarget : tsystem;
  47. paratargetasm : tasm;
  48. paratargetdbg : tdbg;
  49. LinkTypeSetExplicitly : boolean;
  50. LinkerSetExplicitly : boolean;
  51. Constructor Create;
  52. Destructor Destroy;override;
  53. procedure WriteLogo;
  54. procedure WriteInfo (More: string);
  55. procedure WriteHelpPages;
  56. procedure WriteQuickInfo;
  57. procedure IllegalPara(const opt:TCmdStr);
  58. procedure UnsupportedPara(const opt:TCmdStr);
  59. procedure IgnoredPara(const opt:TCmdStr);
  60. function Unsetbool(var Opts:TCmdStr; Pos: Longint; const FullPara: TCmdStr; RequireBoolPara: Boolean):boolean;
  61. procedure interpret_option(const opt :TCmdStr;ispara:boolean);
  62. procedure Interpret_envvar(const envname : TCmdStr);
  63. procedure Interpret_file(const filename : TPathStr);
  64. procedure Read_Parameters;
  65. procedure parsecmd(cmd:TCmdStr);
  66. procedure TargetOptions(def:boolean);
  67. procedure CheckOptionsCompatibility;
  68. procedure ForceStaticLinking;
  69. protected
  70. MacVersionSet: boolean;
  71. processorstr: TCmdStr;
  72. function ParseMacVersionMin(out minstr, emptystr: string; const compvarname, value: string; ios: boolean): boolean;
  73. procedure MaybeSetDefaultMacVersionMacro;
  74. procedure VerifyTargetProcessor;
  75. end;
  76. TOptionClass=class of toption;
  77. var
  78. coption : TOptionClass;
  79. procedure read_arguments(cmd:TCmdStr);
  80. implementation
  81. uses
  82. widestr,
  83. {$if FPC_FULLVERSION<20700}ccharset{$else}charset{$endif},
  84. SysUtils,
  85. version,
  86. cutils,cmsgs,
  87. comphook,
  88. symtable,scanner,rabase,
  89. symconst,
  90. {$ifdef llvm}
  91. { override supported optimizer transformations at the compiler level }
  92. llvminfo,
  93. {$endif llvm}
  94. dirparse,
  95. pkgutil,
  96. i_bsd;
  97. const
  98. page_size = 24;
  99. page_width = 80;
  100. var
  101. option : toption;
  102. read_configfile, { read config file, set when a cfgfile is found }
  103. disable_configfile : boolean;
  104. fpcdir,
  105. ppccfg,
  106. param_file : string; { file to compile specified on the commandline }
  107. {****************************************************************************
  108. Options not supported on all platforms
  109. ****************************************************************************}
  110. const
  111. { gprof (requires implementation of g_profilecode in the code generator) }
  112. supported_targets_pg = [system_i386_linux,system_x86_64_linux,system_mipseb_linux,system_mipsel_linux,system_arm_linux]
  113. + [system_i386_win32]
  114. + [system_powerpc_darwin,system_x86_64_darwin]
  115. + [system_i386_GO32V2]
  116. + [system_i386_freebsd]
  117. + [system_i386_netbsd]
  118. + [system_i386_wdosx];
  119. suppported_targets_x_smallr = systems_linux + systems_solaris
  120. + [system_i386_haiku]
  121. + [system_i386_beos]
  122. + [system_m68k_amiga];
  123. {****************************************************************************
  124. Defines
  125. ****************************************************************************}
  126. procedure set_default_link_type;
  127. begin
  128. undef_system_macro('FPC_LINK_SMART');
  129. def_system_macro('FPC_LINK_STATIC');
  130. undef_system_macro('FPC_LINK_DYNAMIC');
  131. init_settings.globalswitches:=init_settings.globalswitches+[cs_link_static];
  132. init_settings.globalswitches:=init_settings.globalswitches-[cs_link_shared,cs_link_smart];
  133. {$ifdef AIX}
  134. init_settings.globalswitches:=init_settings.globalswitches+[cs_link_native];
  135. {$endif}
  136. end;
  137. {****************************************************************************
  138. Toption
  139. ****************************************************************************}
  140. procedure StopOptions(err:longint);
  141. begin
  142. if assigned(Option) then
  143. begin
  144. Option.free;
  145. Option:=nil;
  146. end;
  147. raise ECompilerAbortSilent.Create;
  148. end;
  149. function is_identifier(const s: TCmdStr): boolean;
  150. var
  151. i: longint;
  152. begin
  153. result:=false;
  154. if (s='') or not (s[1] in ['A'..'Z','a'..'z','_']) then
  155. exit;
  156. for i:=2 to length(s) do
  157. if not (s[I] in ['A'..'Z','a'..'z','0'..'9','_']) then
  158. exit;
  159. result:=true;
  160. end;
  161. procedure Toption.WriteLogo;
  162. var
  163. msg : TMsgStr;
  164. p : pchar;
  165. begin
  166. if not LogoWritten then
  167. begin
  168. msg:=MessageStr(option_logo);
  169. p:=pchar(msg);
  170. while assigned(p) do
  171. Comment(V_Normal,GetMsgLine(p));
  172. LogoWritten:= true;
  173. end;
  174. end;
  175. procedure Toption.WriteInfo (More: string);
  176. var
  177. msg_str: TMsgStr;
  178. p : pchar;
  179. hs,hs1,hs3,s : TCmdStr;
  180. J: longint;
  181. const
  182. NewLineStr = '$\n';
  183. OSTargetsPlaceholder = '$OSTARGETS';
  184. CPUListPlaceholder = '$INSTRUCTIONSETS';
  185. FPUListPlaceholder = '$FPUINSTRUCTIONSETS';
  186. ABIListPlaceholder = '$ABITARGETS';
  187. OptListPlaceholder = '$OPTIMIZATIONS';
  188. WPOListPlaceholder = '$WPOPTIMIZATIONS';
  189. AsmModeListPlaceholder = '$ASMMODES';
  190. ControllerListPlaceholder = '$CONTROLLERTYPES';
  191. FeatureListPlaceholder = '$FEATURELIST';
  192. procedure SplitLine (var OrigString: TCmdStr; const Placeholder: TCmdStr;
  193. var RemainderString: TCmdStr);
  194. var
  195. I: longint;
  196. HS2: TCmdStr;
  197. begin
  198. RemainderString := '';
  199. if OrigString = '' then
  200. Exit;
  201. repeat
  202. I := Pos (NewLineStr, OrigString);
  203. if I > 0 then
  204. begin
  205. HS2 := Copy (OrigString, 1, Pred (I));
  206. { Stop if this line contains the placeholder for list replacement }
  207. if Pos (Placeholder, HS2) > 0 then
  208. begin
  209. RemainderString := Copy (OrigString, I + Length (NewLineStr),
  210. Length (OrigString) - I - Length (NewLineStr));
  211. { Special case - NewLineStr at the end of the line }
  212. if RemainderString = '' then
  213. RemainderString := NewLineStr;
  214. OrigString := HS2;
  215. Exit;
  216. end;
  217. Comment (V_Normal, HS2);
  218. Delete (OrigString, 1, Pred (I) + Length (NewLineStr));
  219. end;
  220. until I = 0;
  221. if (OrigString <> '') and (Pos (Placeholder, OrigString) = 0) then
  222. Comment (V_Normal, OrigString);
  223. end;
  224. procedure ListOSTargets (OrigString: TCmdStr);
  225. var
  226. target : tsystem;
  227. begin
  228. SplitLine (OrigString, OSTargetsPlaceholder, HS3);
  229. for target:=low(tsystem) to high(tsystem) do
  230. if assigned(targetinfos[target]) then
  231. begin
  232. hs1:=targetinfos[target]^.shortname;
  233. if OrigString = '' then
  234. WriteLn (hs1)
  235. else
  236. begin
  237. hs := OrigString;
  238. hs1:=hs1 + ': ' + targetinfos[target]^.name;
  239. if tf_under_development in targetinfos[target]^.flags then
  240. hs1:=hs1+' {*}';
  241. Replace(hs,OSTargetsPlaceholder,hs1);
  242. Comment(V_Normal,hs);
  243. end;
  244. end;
  245. OrigString := HS3;
  246. SplitLine (OrigString, OSTargetsPlaceholder, HS3);
  247. end;
  248. procedure ListCPUInstructionSets (OrigString: TCmdStr);
  249. var
  250. cpu : tcputype;
  251. begin
  252. SplitLine (OrigString, CPUListPlaceholder, HS3);
  253. hs1:='';
  254. for cpu:=low(tcputype) to high(tcputype) do
  255. begin
  256. if (OrigString = '') then
  257. begin
  258. if CPUTypeStr [CPU] <> '' then
  259. WriteLn (CPUTypeStr [CPU]);
  260. end
  261. else
  262. begin
  263. if length(hs1+cputypestr[cpu])>70 then
  264. begin
  265. hs:=OrigString;
  266. Replace(hs,CPUListPlaceholder,hs1);
  267. Comment(V_Normal,hs);
  268. hs1:=''
  269. end
  270. else if hs1<>'' then
  271. hs1:=hs1+',';
  272. if cputypestr[cpu]<>'' then
  273. hs1:=hs1+cputypestr[cpu];
  274. end;
  275. end;
  276. if (OrigString <> '') and (hs1 <> '') then
  277. begin
  278. hs:=OrigString;
  279. Replace(hs,CPUListPlaceholder,hs1);
  280. Comment(V_Normal,hs);
  281. hs1:=''
  282. end;
  283. OrigString := HS3;
  284. SplitLine (OrigString, CPUListPlaceholder, HS3);
  285. end;
  286. procedure ListFPUInstructionSets (OrigString: TCmdStr);
  287. var
  288. fpu : tfputype;
  289. begin
  290. SplitLine (OrigString, FPUListPlaceholder, HS3);
  291. hs1:='';
  292. for fpu:=low(tfputype) to high(tfputype) do
  293. begin
  294. if (OrigString = '') then
  295. begin
  296. if FPUTypeStr [FPU] <> '' then
  297. WriteLn (FPUTypeStr [FPU]);
  298. end
  299. else
  300. begin
  301. if length(hs1+fputypestr[fpu])>70 then
  302. begin
  303. hs:=OrigString;
  304. Replace(hs,FPUListPlaceholder,hs1);
  305. Comment(V_Normal,hs);
  306. hs1:=''
  307. end
  308. else if hs1<>'' then
  309. hs1:=hs1+',';
  310. if fputypestr[fpu]<>'' then
  311. hs1:=hs1+fputypestr[fpu];
  312. end;
  313. end;
  314. if (OrigString <> '') and (hs1 <> '') then
  315. begin
  316. hs:=OrigString;
  317. Replace(hs,FPUListPlaceholder,hs1);
  318. Comment(V_Normal,hs);
  319. hs1:=''
  320. end;
  321. OrigString := HS3;
  322. SplitLine (OrigString, FPUListPlaceholder, HS3);
  323. end;
  324. procedure ListABITargets (OrigString: TCmdStr);
  325. var
  326. abi : tabi;
  327. begin
  328. SplitLine (OrigString, ABIListPlaceholder, HS3);
  329. for abi:=low(abi) to high(abi) do
  330. begin
  331. if not abiinfo[abi].supported then
  332. continue;
  333. hs1:=abiinfo[abi].name;
  334. if hs1<>'' then
  335. begin
  336. if OrigString = '' then
  337. WriteLn (HS1)
  338. else
  339. begin
  340. hs:=OrigString;
  341. Replace(hs,ABIListPlaceholder,hs1);
  342. Comment(V_Normal,hs);
  343. end;
  344. end;
  345. end;
  346. OrigString := HS3;
  347. SplitLine (OrigString, ABIListPlaceholder, HS3);
  348. end;
  349. procedure ListOptimizations (OrigString: TCmdStr);
  350. var
  351. opt : toptimizerswitch;
  352. begin
  353. SplitLine (OrigString, OptListPlaceholder, HS3);
  354. for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
  355. begin
  356. if opt in supported_optimizerswitches then
  357. begin
  358. hs1:=OptimizerSwitchStr[opt];
  359. if hs1<>'' then
  360. begin
  361. if OrigString = '' then
  362. WriteLn (hs1)
  363. else
  364. begin
  365. hs:=OrigString;
  366. Replace(hs,OptListPlaceholder,hs1);
  367. Comment(V_Normal,hs);
  368. end;
  369. end;
  370. end;
  371. end;
  372. OrigString := HS3;
  373. SplitLine (OrigString, OptListPlaceholder, HS3);
  374. end;
  375. procedure ListWPOptimizations (OrigString: TCmdStr);
  376. var
  377. wpopt: twpoptimizerswitch;
  378. begin
  379. SplitLine (OrigString, WPOListPlaceholder, HS3);
  380. for wpopt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  381. begin
  382. { currently all whole program optimizations are platform-independent
  383. if opt in supported_wpoptimizerswitches then
  384. }
  385. begin
  386. hs1:=WPOptimizerSwitchStr[wpopt];
  387. if hs1<>'' then
  388. begin
  389. if OrigString = '' then
  390. WriteLn (hs1)
  391. else
  392. begin
  393. hs:=OrigString;
  394. Replace(hs,WPOListPlaceholder,hs1);
  395. Comment(V_Normal,hs);
  396. end;
  397. end;
  398. end;
  399. end;
  400. OrigString := HS3;
  401. SplitLine (OrigString, WPOListPlaceholder, HS3);
  402. end;
  403. procedure ListAsmModes (OrigString: TCmdStr);
  404. var
  405. asmmode : tasmmode;
  406. begin
  407. SplitLine (OrigString, AsmModeListPlaceholder, HS3);
  408. for asmmode:=low(tasmmode) to high(tasmmode) do
  409. if assigned(asmmodeinfos[asmmode]) then
  410. begin
  411. hs1:=asmmodeinfos[asmmode]^.idtxt;
  412. if hs1<>'' then
  413. begin
  414. if OrigString = '' then
  415. WriteLn (hs1)
  416. else
  417. begin
  418. hs:=OrigString;
  419. Replace(hs,AsmModeListPlaceholder,hs1);
  420. Comment(V_Normal,hs);
  421. end;
  422. end;
  423. end;
  424. OrigString := HS3;
  425. SplitLine (OrigString, AsmModeListPlaceholder, HS3);
  426. end;
  427. procedure ListControllerTypes (OrigString: TCmdStr);
  428. var
  429. controllertype : tcontrollertype;
  430. begin
  431. {$PUSH}
  432. {$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
  433. if (ControllerSupport) then
  434. begin
  435. SplitLine (OrigString, ControllerListPlaceholder, HS3);
  436. hs1:='';
  437. for controllertype:=low(tcontrollertype) to high(tcontrollertype) do
  438. begin
  439. if (OrigString = '') then
  440. begin
  441. if Embedded_Controllers [ControllerType].ControllerTypeStr <> '' then
  442. WriteLn (Embedded_Controllers [ControllerType].ControllerTypeStr);
  443. end
  444. else
  445. begin
  446. if length(hs1+embedded_controllers[controllertype].ControllerTypeStr)
  447. >70 then
  448. begin
  449. hs:=OrigString;
  450. Replace(hs,ControllerListPlaceholder,hs1);
  451. Comment(V_Normal,hs);
  452. hs1:=''
  453. end
  454. else if hs1<>'' then
  455. hs1:=hs1+',';
  456. if embedded_controllers[controllertype].ControllerTypeStr<>'' then
  457. hs1:=hs1+embedded_controllers[controllertype].ControllerTypeStr;
  458. end;
  459. end;
  460. if (OrigString <> '') and (hs1<>'') then
  461. begin
  462. hs:=OrigString;
  463. Replace(hs,ControllerListPlaceholder,hs1);
  464. Comment(V_Normal,hs);
  465. hs1:=''
  466. end;
  467. OrigString := HS3;
  468. SplitLine (OrigString, ControllerListPlaceholder, HS3);
  469. end;
  470. {$POP}
  471. end;
  472. procedure ListFeatures (OrigString: TCmdStr);
  473. var
  474. Feature: TFeature;
  475. begin
  476. SplitLine (OrigString, FeatureListPlaceholder, HS3);
  477. HS1 := '';
  478. for Feature := Low (TFeature) to High (TFeature) do
  479. begin
  480. if (OrigString = '') then
  481. begin
  482. if FeatureStr [Feature] <> '' then
  483. WriteLn (FeatureStr [Feature]);
  484. end
  485. else
  486. begin
  487. if Length (HS1 + FeatureStr [Feature]) > 70 then
  488. begin
  489. HS := OrigString;
  490. Replace (HS, FeatureListPlaceholder, HS1);
  491. Comment (V_Normal, HS);
  492. HS1 := ''
  493. end
  494. else if HS1 <> '' then
  495. HS1 := HS1 + ',';
  496. if FeatureStr [Feature] <> '' then
  497. HS1 := HS1 + FeatureStr [Feature];
  498. end;
  499. end;
  500. if (OrigString <> '') and (HS1 <> '') then
  501. begin
  502. HS := OrigString;
  503. Replace (HS, FeatureListPlaceholder, HS1);
  504. Comment (V_Normal, HS);
  505. HS1 := ''
  506. end;
  507. OrigString := HS3;
  508. SplitLine (OrigString, FeatureListPlaceholder, HS3);
  509. end;
  510. begin
  511. if More = '' then
  512. begin
  513. msg_str:=MessageStr(option_info);
  514. p:=pchar(msg_str);
  515. while assigned(p) do
  516. begin
  517. s:=GetMsgLine(p);
  518. { list permitted values for certain options }
  519. if pos(OSTargetsPlaceholder,s)>0 then
  520. ListOSTargets (S)
  521. else if pos(CPUListPlaceholder,s)>0 then
  522. ListCPUInstructionSets (S)
  523. else if pos(FPUListPlaceholder,s)>0 then
  524. ListFPUInstructionSets (S)
  525. else if pos(ABIListPlaceholder,s)>0 then
  526. ListABITargets (S)
  527. else if pos(OptListPlaceholder,s)>0 then
  528. ListOptimizations (S)
  529. else if pos(WPOListPlaceholder,s)>0 then
  530. ListWPOptimizations (S)
  531. else if pos(AsmModeListPlaceholder,s)>0 then
  532. ListAsmModes (S)
  533. else if pos(ControllerListPlaceholder,s)>0 then
  534. ListControllerTypes (S)
  535. else if pos(FeatureListPlaceholder,s)>0 then
  536. ListFeatures (S)
  537. else
  538. Comment(V_Normal,s);
  539. end;
  540. end
  541. else
  542. begin
  543. J := 1;
  544. while J <= Length (More) do
  545. begin
  546. if J > 1 then
  547. WriteLn; (* Put empty line between multiple sections *)
  548. case More [J] of
  549. 'a': ListABITargets ('');
  550. 'c': ListCPUInstructionSets ('');
  551. 'f': ListFPUInstructionSets ('');
  552. 'i': ListAsmModes ('');
  553. 'o': ListOptimizations ('');
  554. 'r': ListFeatures ('');
  555. 't': ListOSTargets ('');
  556. 'u': ListControllerTypes ('');
  557. 'w': ListWPOptimizations ('');
  558. else
  559. IllegalPara ('-i' + More);
  560. end;
  561. Inc (J);
  562. end;
  563. end;
  564. StopOptions(0);
  565. end;
  566. procedure Toption.WriteHelpPages;
  567. function PadEnd(s:string;i:longint):string;
  568. begin
  569. if length(s) >= i then
  570. S := S + ' '
  571. else
  572. while (length(s)<i) do
  573. s:=s+' ';
  574. PadEnd:=s;
  575. end;
  576. var
  577. lastident,
  578. j,outline,
  579. ident,
  580. HelpLineHeight,
  581. lines : longint;
  582. show : boolean;
  583. opt : string[32];
  584. input,
  585. HelpLine,
  586. s : string;
  587. p : pchar;
  588. msg_str: TMsgStr;
  589. begin
  590. WriteLogo;
  591. Lines:=4;
  592. if FPCHelpLines then
  593. Message1(option_usage,FixFileName(FPCBinaryPath))
  594. else
  595. Message1(option_usage,FixFileName(system.paramstr(0)));
  596. lastident:=0;
  597. msg_str:=MessageStr(option_help_pages);
  598. p:=pchar(msg_str);
  599. while assigned(p) do
  600. begin
  601. { get a line and reset }
  602. s:=GetMsgLine(p);
  603. ident:=0;
  604. show:=false;
  605. { parse options }
  606. case s[1] of
  607. 'F': if FPCHelpLines then
  608. Show := true;
  609. {$ifdef UNITALIASES}
  610. 'a',
  611. {$endif}
  612. {$ifdef EXTDEBUG}
  613. 'e',
  614. {$endif EXTDEBUG}
  615. {$ifdef i386}
  616. '3',
  617. {$endif}
  618. {$ifdef x86_64}
  619. '4',
  620. {$endif}
  621. {$ifdef m68k}
  622. '6',
  623. {$endif}
  624. {$ifdef i8086}
  625. '8',
  626. {$endif}
  627. {$ifdef aarch64}
  628. 'a',
  629. {$endif}
  630. {$ifdef arm}
  631. 'A',
  632. {$endif}
  633. {$ifdef mipsel}
  634. 'm',
  635. {$endif}
  636. {$ifdef mipseb}
  637. 'M',
  638. {$endif}
  639. {$ifdef powerpc}
  640. 'P',
  641. {$endif}
  642. {$ifdef powerpc64}
  643. 'p',
  644. {$endif}
  645. {$ifdef sparc}
  646. 'S',
  647. {$endif}
  648. {$ifdef sparc64}
  649. 's',
  650. {$endif}
  651. {$ifdef avr}
  652. 'V',
  653. {$endif}
  654. {$ifdef jvm}
  655. 'J',
  656. {$endif}
  657. '*' : show:=true;
  658. end;
  659. if show then
  660. begin
  661. case s[2] of
  662. 'g',
  663. {$ifdef Unix}
  664. 'L',
  665. {$endif}
  666. {$ifdef os2}
  667. 'O',
  668. {$endif}
  669. '*' : show:=true;
  670. else
  671. show:=false;
  672. end;
  673. end;
  674. { now we may show the message or not }
  675. if show then
  676. begin
  677. case s[3] of
  678. '0' : begin
  679. ident:=0;
  680. outline:=0;
  681. end;
  682. '1' : begin
  683. ident:=2;
  684. outline:=7;
  685. end;
  686. '2' : begin
  687. ident:=6;
  688. outline:=11;
  689. end;
  690. '3' : begin
  691. ident:=9;
  692. outline:=11;
  693. end;
  694. else
  695. internalerror(2013112906);
  696. end;
  697. j:=pos('_',s);
  698. opt:=Copy(s,4,j-4);
  699. if opt='*' then
  700. opt:=''
  701. else
  702. if (opt=' ') or (opt[1]='@') then
  703. opt:=PadEnd(opt,outline)
  704. else
  705. opt:=PadEnd('-'+opt,outline);
  706. if (ident=0) and (lastident<>0) then
  707. begin
  708. Comment(V_Normal,'');
  709. inc(Lines);
  710. end;
  711. HelpLine := PadEnd('',ident)+opt+Copy(s,j+1,255);
  712. if HelpLine = '' then
  713. HelpLineHeight := 1
  714. else
  715. HelpLineHeight := Succ (CharLength (HelpLine) div Page_Width);
  716. { page full ? }
  717. if (lines + HelpLineHeight >= page_size - 1) then
  718. begin
  719. if not NoPressEnter then
  720. begin
  721. Message(option_help_press_enter);
  722. readln(input);
  723. if upper(input)='Q' then
  724. StopOptions(0);
  725. end;
  726. lines:=0;
  727. end;
  728. Comment(V_Normal,HelpLine);
  729. LastIdent:=Ident;
  730. Inc (Lines, HelpLineHeight);
  731. end;
  732. end;
  733. StopOptions(0);
  734. end;
  735. procedure Toption.IllegalPara(const opt:TCmdStr);
  736. begin
  737. Message1(option_illegal_para,opt);
  738. Message(option_help_pages_para);
  739. StopOptions(1);
  740. end;
  741. procedure toption.UnsupportedPara(const opt: TCmdStr);
  742. begin
  743. Message1(option_unsupported_target,opt);
  744. StopOptions(1);
  745. end;
  746. procedure toption.IgnoredPara(const opt: TCmdStr);
  747. begin
  748. Message1(option_ignored_target,opt);
  749. end;
  750. procedure toption.ForceStaticLinking;
  751. begin
  752. def_system_macro('FPC_LINK_STATIC');
  753. undef_system_macro('FPC_LINK_SMART');
  754. undef_system_macro('FPC_LINK_DYNAMIC');
  755. include(init_settings.globalswitches,cs_link_static);
  756. exclude(init_settings.globalswitches,cs_link_smart);
  757. exclude(init_settings.globalswitches,cs_link_shared);
  758. LinkTypeSetExplicitly:=true;
  759. end;
  760. function toption.ParseMacVersionMin(out minstr, emptystr: string; const compvarname, value: string; ios: boolean): boolean;
  761. function subval(start,maxlen: longint; out stop: longint): string;
  762. var
  763. i: longint;
  764. begin
  765. result:='';
  766. i:=start;
  767. while (i<=length(value)) and
  768. (value[i] in ['0'..'9']) do
  769. inc(i);
  770. { sufficient amount of digits? }
  771. if (i=start) or
  772. (i-start>maxlen) then
  773. exit;
  774. result:=copy(value,start,i-start);
  775. stop:=i;
  776. end;
  777. var
  778. temp,
  779. compvarvalue: string[15];
  780. i: longint;
  781. osx_minor_two_digits: boolean;
  782. begin
  783. minstr:=value;
  784. emptystr:='';
  785. MacVersionSet:=false;
  786. { check whether the value is a valid version number }
  787. if value='' then
  788. begin
  789. undef_system_macro(compvarname);
  790. exit(true);
  791. end;
  792. { major version number }
  793. compvarvalue:=subval(1,2,i);
  794. { not enough digits -> invalid }
  795. if compvarvalue='' then
  796. exit(false);
  797. { already end of string -> invalid }
  798. if (i>=length(value)) or
  799. (value[i]<>'.') then
  800. exit(false);
  801. { minor version number }
  802. temp:=subval(i+1,2,i);
  803. if temp='' then
  804. exit(false);
  805. { on Mac OS X, the minor version number was originally limited to 1 digit;
  806. with 10.10 the format changed and two digits were also supported; on iOS,
  807. the minor version number always takes up two digits }
  808. osx_minor_two_digits:=false;
  809. if not ios then
  810. begin
  811. { if the minor version number is two digits on OS X (the case since
  812. OS X 10.10), we also have to add two digits for the patch level}
  813. if length(temp)=2 then
  814. osx_minor_two_digits:=true;
  815. end
  816. { the minor version number always takes up two digits on iOS }
  817. else if length(temp)=1 then
  818. temp:='0'+temp;
  819. compvarvalue:=compvarvalue+temp;
  820. { optional patch level }
  821. if i<=length(value) then
  822. begin
  823. if value[i]<>'.' then
  824. exit(false);
  825. temp:=subval(i+1,2,i);
  826. if temp='' then
  827. exit(false);
  828. { there's only room for a single digit patch level in the version macro
  829. for Mac OS X. gcc sets it to zero if there are more digits, but that
  830. seems worse than clamping to 9 (don't declare as invalid like with
  831. minor version number, because there is a precedent like 10.4.11).
  832. As of OS X 10.10 there are two digits for the patch level
  833. }
  834. if not ios and
  835. not osx_minor_two_digits then
  836. begin
  837. if length(temp)<>1 then
  838. temp:='9';
  839. end
  840. else
  841. begin
  842. { on iOS, the patch level is always two digits }
  843. if length(temp)=1 then
  844. temp:='0'+temp;
  845. end;
  846. compvarvalue:=compvarvalue+temp;
  847. { must be the end }
  848. if i<=length(value) then
  849. exit(false);
  850. end
  851. else if not ios and
  852. not osx_minor_two_digits then
  853. compvarvalue:=compvarvalue+'0'
  854. else
  855. compvarvalue:=compvarvalue+'00';
  856. set_system_compvar(compvarname,compvarvalue);
  857. MacVersionSet:=true;
  858. result:=true;
  859. end;
  860. procedure TOption.MaybeSetDefaultMacVersionMacro;
  861. var
  862. envstr: ansistring;
  863. begin
  864. if not(target_info.system in systems_darwin) then
  865. exit;
  866. if MacVersionSet then
  867. exit;
  868. { check for deployment target set via environment variable }
  869. if not(target_info.system in [system_i386_iphonesim,system_arm_darwin,system_aarch64_darwin,system_x86_64_iphonesim]) then
  870. begin
  871. envstr:=GetEnvironmentVariable('MACOSX_DEPLOYMENT_TARGET');
  872. if envstr<>'' then
  873. if not ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED',envstr,false) then
  874. Message1(option_invalid_macosx_deployment_target,envstr)
  875. else
  876. exit;
  877. end
  878. else
  879. begin
  880. envstr:=GetEnvironmentVariable('IPHONEOS_DEPLOYMENT_TARGET');
  881. if envstr<>'' then
  882. if not ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED',envstr,true) then
  883. Message1(option_invalid_iphoneos_deployment_target,envstr)
  884. else
  885. exit;
  886. end;
  887. { nothing specified -> defaults }
  888. case target_info.system of
  889. system_powerpc_darwin:
  890. begin
  891. set_system_compvar('MAC_OS_X_VERSION_MIN_REQUIRED','1030');
  892. MacOSXVersionMin:='10.3';
  893. end;
  894. system_powerpc64_darwin,
  895. system_i386_darwin:
  896. begin
  897. set_system_compvar('MAC_OS_X_VERSION_MIN_REQUIRED','1040');
  898. MacOSXVersionMin:='10.4';
  899. end;
  900. system_x86_64_darwin:
  901. begin
  902. { actually already works on 10.4, but it's unlikely any 10.4 system
  903. with an x86-64 is still in use, so don't default to it }
  904. set_system_compvar('MAC_OS_X_VERSION_MIN_REQUIRED','1050');
  905. MacOSXVersionMin:='10.5';
  906. end;
  907. system_arm_darwin,
  908. system_i386_iphonesim:
  909. begin
  910. set_system_compvar('IPHONE_OS_VERSION_MIN_REQUIRED','30000');
  911. iPhoneOSVersionMin:='3.0';
  912. end;
  913. system_aarch64_darwin,
  914. system_x86_64_iphonesim:
  915. begin
  916. set_system_compvar('IPHONE_OS_VERSION_MIN_REQUIRED','70000');
  917. iPhoneOSVersionMin:='7.0';
  918. end
  919. else
  920. internalerror(2012031001);
  921. end;
  922. end;
  923. procedure TOption.VerifyTargetProcessor;
  924. begin
  925. { no custom target processor specified -> ok }
  926. if processorstr='' then
  927. exit;
  928. { custom target processor specified -> verify it's the one we support }
  929. if upcase(processorstr)<>upcase(target_cpu_string) then
  930. Message1(option_invalid_target_architecture,processorstr);
  931. end;
  932. function Toption.Unsetbool(var Opts:TCmdStr; Pos: Longint; const FullPara: TCmdStr; RequireBoolPara: boolean):boolean;
  933. { checks if the character after pos in Opts is a + or a - and returns resp.
  934. false or true. If it is another character (or none), it also returns false }
  935. begin
  936. UnsetBool := false;
  937. if Length(Opts)>Pos then
  938. begin
  939. inc(Pos);
  940. UnsetBool := Opts[Pos] = '-';
  941. if Opts[Pos] in ['-','+']then
  942. delete(Opts,Pos,1)
  943. else if RequireBoolPara then
  944. IllegalPara(FullPara);
  945. end;
  946. end;
  947. procedure TOption.interpret_option(const opt:TCmdStr;ispara:boolean);
  948. var
  949. code : integer;
  950. c : char;
  951. more : TCmdStr;
  952. major,minor : longint;
  953. error : integer;
  954. j,l : longint;
  955. d,s : TCmdStr;
  956. hs : TCmdStr;
  957. unicodemapping : punicodemap;
  958. begin
  959. if opt='' then
  960. exit;
  961. { only parse define,undef,target,verbosity,link etc options the firsttime
  962. -Us must now also be first-passed to avoid rejection of -Sf options
  963. earlier in command line }
  964. if firstpass and
  965. not(
  966. (opt[1]='-') and
  967. (
  968. ((length(opt)>1) and (opt[2] in ['i','d','v','T','u','n','X','l','U'])) or
  969. ((length(opt)>3) and (opt[2]='F') and (opt[3]='e')) or
  970. ((length(opt)>3) and (opt[2]='C') and (opt[3]='p')) or
  971. ((length(opt)>3) and (opt[2]='W') and (opt[3] in ['m','p']))
  972. )
  973. ) then
  974. exit;
  975. Message1(option_handling_option,opt);
  976. case opt[1] of
  977. '-' :
  978. begin
  979. more:=Copy(opt,3,2147483647);
  980. if firstpass then
  981. Message1(option_interpreting_firstpass_option,opt)
  982. else
  983. Message1(option_interpreting_option,opt);
  984. case opt[2] of
  985. '?' :
  986. begin
  987. if (More <> '') and (More [1] = 'F') then
  988. begin
  989. FPCHelpLines := true;
  990. Delete (More, 1, 1);
  991. FPCBinaryPath := More;
  992. end;
  993. WriteHelpPages;
  994. end;
  995. 'a' :
  996. begin
  997. include(init_settings.globalswitches,cs_asm_leave);
  998. j:=1;
  999. while j<=length(more) do
  1000. begin
  1001. case more[j] of
  1002. '5' :
  1003. if target_info.system in systems_all_windows+systems_nativent-[system_i8086_win16] then
  1004. begin
  1005. if UnsetBool(More, j, opt, false) then
  1006. exclude(init_settings.globalswitches,cs_asm_pre_binutils_2_25)
  1007. else
  1008. include(init_settings.globalswitches,cs_asm_pre_binutils_2_25);
  1009. end
  1010. else
  1011. IllegalPara(opt);
  1012. 'l' :
  1013. include(init_settings.globalswitches,cs_asm_source);
  1014. 'r' :
  1015. include(init_settings.globalswitches,cs_asm_regalloc);
  1016. 't' :
  1017. include(init_settings.globalswitches,cs_asm_tempalloc);
  1018. 'n' :
  1019. include(init_settings.globalswitches,cs_asm_nodes);
  1020. { -ao option must be the last, everything behind it is passed directly to
  1021. external assembler, it is ignored if internal assembler is used. }
  1022. 'o' :
  1023. begin
  1024. asmextraopt:=copy(more,j+1,length(more)-j);
  1025. break;
  1026. end;
  1027. 'p' :
  1028. begin
  1029. exclude(init_settings.globalswitches,cs_asm_leave);
  1030. if UnsetBool(More, 0, opt, false) then
  1031. exclude(init_settings.globalswitches,cs_asm_pipe)
  1032. else
  1033. include(init_settings.globalswitches,cs_asm_pipe);
  1034. end;
  1035. '-' :
  1036. init_settings.globalswitches:=init_settings.globalswitches -
  1037. [cs_asm_leave, cs_asm_source,cs_asm_regalloc, cs_asm_tempalloc,
  1038. cs_asm_nodes, cs_asm_pipe];
  1039. else
  1040. IllegalPara(opt);
  1041. end;
  1042. inc(j);
  1043. end;
  1044. end;
  1045. 'A' :
  1046. begin
  1047. paratargetasm:=find_asm_by_string(More);
  1048. if paratargetasm=as_none then
  1049. IllegalPara(opt);
  1050. end;
  1051. 'b' :
  1052. begin
  1053. // Message1(option_obsolete_switch,'-b');
  1054. if UnsetBool(More,0,opt,false) then
  1055. begin
  1056. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_browser];
  1057. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_local_browser];
  1058. end
  1059. else
  1060. begin
  1061. init_settings.moduleswitches:=init_settings.moduleswitches+[cs_browser];
  1062. end;
  1063. if More<>'' then
  1064. if (More='l') or (More='l+') then
  1065. init_settings.moduleswitches:=init_settings.moduleswitches+[cs_local_browser]
  1066. else if More='l-' then
  1067. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_local_browser]
  1068. else
  1069. IllegalPara(opt);
  1070. end;
  1071. 'B' :
  1072. do_build:=not UnSetBool(more,0,opt,true);
  1073. 'C' :
  1074. begin
  1075. j:=1;
  1076. while j<=length(more) do
  1077. begin
  1078. case more[j] of
  1079. '3' :
  1080. If UnsetBool(More, j, opt, false) then
  1081. exclude(init_settings.localswitches,cs_ieee_errors)
  1082. Else
  1083. include(init_settings.localswitches,cs_ieee_errors);
  1084. 'a' :
  1085. begin
  1086. s:=upper(copy(more,j+1,length(more)-j));
  1087. if not(SetAbiType(s,target_info.abi)) then
  1088. IllegalPara(opt);
  1089. ABISetExplicitly:=true;
  1090. break;
  1091. end;
  1092. 'b' :
  1093. begin
  1094. if UnsetBool(More, j, opt, false) then
  1095. target_info.endian:=endian_little
  1096. else
  1097. target_info.endian:=endian_big;
  1098. end;
  1099. 'c' :
  1100. begin
  1101. if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),init_settings.defproccall) then
  1102. IllegalPara(opt);
  1103. break;
  1104. end;
  1105. {$ifdef cpufpemu}
  1106. 'e' :
  1107. begin
  1108. If UnsetBool(More, j, opt, false) then
  1109. exclude(init_settings.moduleswitches,cs_fp_emulation)
  1110. Else
  1111. include(init_settings.moduleswitches,cs_fp_emulation);
  1112. end;
  1113. {$endif cpufpemu}
  1114. 'f' :
  1115. begin
  1116. s:=upper(copy(more,j+1,length(more)-j));
  1117. if not(SetFpuType(s,init_settings.fputype)) then
  1118. IllegalPara(opt);
  1119. FPUSetExplicitly:=True;
  1120. break;
  1121. end;
  1122. 'F' :
  1123. begin
  1124. if not SetMinFPConstPrec(copy(more,j+1,length(more)-j),init_settings.minfpconstprec) then
  1125. IllegalPara(opt);
  1126. break;
  1127. end;
  1128. 'g' :
  1129. begin
  1130. if tf_no_pic_supported in target_info.flags then
  1131. begin
  1132. { consume a possible '-' coming after it }
  1133. UnsetBool(More, j, opt, false);
  1134. message(scan_w_pic_ignored);
  1135. end
  1136. else if UnsetBool(More, j, opt, false) then
  1137. exclude(init_settings.moduleswitches,cs_create_pic)
  1138. else
  1139. include(init_settings.moduleswitches,cs_create_pic);
  1140. end;
  1141. 'h' :
  1142. begin
  1143. l:=pos(',',copy(more,j+1,length(more)-j));
  1144. if l=0 then
  1145. l:=length(more)-j+1;
  1146. val(copy(more,j+1,l-1),heapsize,code);
  1147. if (code<>0)
  1148. {$ifdef AVR}
  1149. or (heapsize<32)
  1150. {$else AVR}
  1151. or (heapsize<1024)
  1152. {$endif AVR}
  1153. then
  1154. IllegalPara(opt)
  1155. else if l<=length(more)-j then
  1156. begin
  1157. val(copy(more,j+l+1,length(more)),maxheapsize,code);
  1158. if code<>0 then
  1159. IllegalPara(opt)
  1160. else if (maxheapsize<heapsize) then
  1161. begin
  1162. message(scan_w_heapmax_lessthan_heapmin);
  1163. maxheapsize:=heapsize;
  1164. end;
  1165. end;
  1166. break;
  1167. end;
  1168. 'i' :
  1169. If UnsetBool(More, j, opt, false) then
  1170. exclude(init_settings.localswitches,cs_check_io)
  1171. else
  1172. include(init_settings.localswitches,cs_check_io);
  1173. {$ifdef arm}
  1174. 'I' :
  1175. begin
  1176. if (upper(copy(more,j+1,length(more)-j))='THUMB') and
  1177. { does selected CPU really understand thumb? }
  1178. (init_settings.cputype in cpu_has_thumb) then
  1179. init_settings.instructionset:=is_thumb
  1180. else if upper(copy(more,j+1,length(more)-j))='ARM' then
  1181. init_settings.instructionset:=is_arm
  1182. else
  1183. IllegalPara(opt);
  1184. break;
  1185. end;
  1186. {$endif arm}
  1187. 'n' :
  1188. If UnsetBool(More, j, opt, false) then
  1189. exclude(init_settings.globalswitches,cs_link_nolink)
  1190. Else
  1191. include(init_settings.globalswitches,cs_link_nolink);
  1192. 'N' :
  1193. If UnsetBool(More, j, opt, false) then
  1194. exclude(init_settings.localswitches,cs_check_low_addr_load)
  1195. Else
  1196. include(init_settings.localswitches,cs_check_low_addr_load);
  1197. 'o' :
  1198. If UnsetBool(More, j, opt, false) then
  1199. exclude(init_settings.localswitches,cs_check_overflow)
  1200. Else
  1201. include(init_settings.localswitches,cs_check_overflow);
  1202. 'O' :
  1203. If UnsetBool(More, j, opt, false) then
  1204. exclude(init_settings.localswitches,cs_check_ordinal_size)
  1205. Else
  1206. include(init_settings.localswitches,cs_check_ordinal_size);
  1207. 'p' :
  1208. begin
  1209. s:=upper(copy(more,j+1,length(more)-j));
  1210. if not(Setcputype(s,init_settings)) then
  1211. IllegalPara(opt);
  1212. CPUSetExplicitly:=true;
  1213. break;
  1214. end;
  1215. 'P':
  1216. begin
  1217. delete(more,1,1);
  1218. case upper(copy(more,1,pos('=',more)-1)) of
  1219. 'PACKSET':
  1220. begin
  1221. delete(more,1,pos('=',more));
  1222. case more of
  1223. '0','DEFAULT','NORMAL':
  1224. init_settings.setalloc:=0;
  1225. '1','2','4','8':
  1226. init_settings.setalloc:=StrToInt(more);
  1227. else
  1228. IllegalPara(opt);
  1229. end
  1230. end;
  1231. 'PACKENUM':
  1232. begin
  1233. delete(more,1,pos('=',more));
  1234. case more of
  1235. '0','DEFAULT','NORMAL':
  1236. init_settings.packenum:=4;
  1237. '1','2','4':
  1238. init_settings.packenum:=StrToInt(more);
  1239. else
  1240. IllegalPara(opt);
  1241. end;
  1242. end;
  1243. 'PACKRECORD':
  1244. begin
  1245. delete(more,1,pos('=',more));
  1246. case more of
  1247. '0','DEFAULT','NORMAL':
  1248. init_settings.packrecords:=default_settings.packrecords;
  1249. '1','2','4','8','16','32':
  1250. init_settings.packrecords:=StrToInt(more);
  1251. else
  1252. IllegalPara(opt);
  1253. end;
  1254. end
  1255. else
  1256. IllegalPara(opt);
  1257. end;
  1258. end;
  1259. 'r' :
  1260. If UnsetBool(More, j, opt, false) then
  1261. exclude(init_settings.localswitches,cs_check_range)
  1262. Else
  1263. include(init_settings.localswitches,cs_check_range);
  1264. 'R' :
  1265. If UnsetBool(More, j, opt, false) then
  1266. begin
  1267. exclude(init_settings.localswitches,cs_check_range);
  1268. exclude(init_settings.localswitches,cs_check_object);
  1269. end
  1270. Else
  1271. begin
  1272. include(init_settings.localswitches,cs_check_range);
  1273. include(init_settings.localswitches,cs_check_object);
  1274. end;
  1275. 's' :
  1276. begin
  1277. val(copy(more,j+1,length(more)-j),stacksize,code);
  1278. if (code<>0)
  1279. {$ifdef cpu16bitaddr}
  1280. or (stacksize>=65521)
  1281. {$else cpu16bitaddr}
  1282. or (stacksize>=67107840)
  1283. {$endif cpu16bitaddr}
  1284. or (stacksize<1024) then
  1285. IllegalPara(opt);
  1286. break;
  1287. end;
  1288. 't' :
  1289. If UnsetBool(More, j, opt, false) then
  1290. exclude(init_settings.localswitches,cs_check_stack)
  1291. Else
  1292. include(init_settings.localswitches,cs_check_stack);
  1293. 'D' :
  1294. If UnsetBool(More, j, opt, false) then
  1295. exclude(init_settings.moduleswitches,cs_create_dynamic)
  1296. Else
  1297. include(init_settings.moduleswitches,cs_create_dynamic);
  1298. 'X' :
  1299. If UnsetBool(More, j, opt, false) then
  1300. exclude(init_settings.moduleswitches,cs_create_smart)
  1301. Else
  1302. include(init_settings.moduleswitches,cs_create_smart);
  1303. 'T' :
  1304. begin
  1305. if not UpdateTargetSwitchStr(copy(more,j+1,length(more)),init_settings.targetswitches,true) then
  1306. IllegalPara(opt);
  1307. break;
  1308. end;
  1309. 'v' :
  1310. If target_info.system in systems_jvm then
  1311. If UnsetBool(More, j, opt, false) then
  1312. exclude(init_settings.localswitches,cs_check_var_copyout)
  1313. Else
  1314. include(init_settings.localswitches,cs_check_var_copyout)
  1315. else
  1316. IllegalPara(opt)
  1317. else
  1318. IllegalPara(opt);
  1319. end;
  1320. inc(j);
  1321. end;
  1322. end;
  1323. 'd' :
  1324. begin
  1325. l:=Pos(':=',more);
  1326. if l>0 then
  1327. hs:=copy(more,1,l-1)
  1328. else
  1329. hs:=more;
  1330. if (not is_identifier(hs)) then
  1331. begin
  1332. if hs='' then
  1333. Message1(option_missing_arg,'-d')
  1334. else
  1335. Message1(option_malformed_para,opt);
  1336. StopOptions(1);
  1337. end;
  1338. if l>0 then
  1339. begin
  1340. if cs_support_macro in init_settings.moduleswitches then
  1341. set_system_macro(hs,Copy(more,l+2,255))
  1342. else
  1343. set_system_compvar(hs,Copy(more,l+2,255));
  1344. end
  1345. else
  1346. def_system_macro(hs);
  1347. end;
  1348. 'D' :
  1349. begin
  1350. include(init_settings.globalswitches,cs_link_deffile);
  1351. j:=1;
  1352. while j<=length(more) do
  1353. begin
  1354. case more[j] of
  1355. 'd' :
  1356. begin
  1357. description:=Copy(more,j+1,255);
  1358. break;
  1359. end;
  1360. 'v' :
  1361. begin
  1362. dllversion:=Copy(more,j+1,255);
  1363. l:=pos('.',dllversion);
  1364. dllminor:=0;
  1365. error:=0;
  1366. if l>0 then
  1367. begin
  1368. val(copy(dllversion,l+1,255),minor,error);
  1369. if (error=0) and
  1370. (minor>=0) and (minor<=$ffff) then
  1371. dllminor:=minor
  1372. else
  1373. if error=0 then
  1374. error:=1;
  1375. end;
  1376. if l=0 then
  1377. l:=256;
  1378. dllmajor:=1;
  1379. major:=0;
  1380. if error=0 then
  1381. val(copy(dllversion,1,l-1),major,error);
  1382. if (error=0) and (major>=0) and (major<=$ffff) then
  1383. dllmajor:=major
  1384. else
  1385. if error=0 then
  1386. error:=1;
  1387. if error<>0 then
  1388. Message1(scan_w_wrong_version_ignored,dllversion);
  1389. break;
  1390. end;
  1391. 'w' :
  1392. usewindowapi:=true;
  1393. '-' :
  1394. begin
  1395. exclude(init_settings.globalswitches,cs_link_deffile);
  1396. usewindowapi:=false;
  1397. end;
  1398. else
  1399. IllegalPara(opt);
  1400. end;
  1401. inc(j);
  1402. end;
  1403. end;
  1404. 'e' :
  1405. exepath:=FixPath(More,true);
  1406. 'E' :
  1407. begin
  1408. if UnsetBool(More, 0, opt, true) then
  1409. exclude(init_settings.globalswitches,cs_link_nolink)
  1410. else
  1411. include(init_settings.globalswitches,cs_link_nolink);
  1412. end;
  1413. 'f' :
  1414. begin
  1415. if more='PIC' then
  1416. begin
  1417. if tf_no_pic_supported in target_info.flags then
  1418. message(scan_w_pic_ignored)
  1419. else
  1420. include(init_settings.moduleswitches,cs_create_pic)
  1421. end
  1422. else
  1423. IllegalPara(opt);
  1424. end;
  1425. 'F' :
  1426. begin
  1427. if more='' then
  1428. IllegalPara(opt);
  1429. c:=more[1];
  1430. Delete(more,1,1);
  1431. DefaultReplacements(More);
  1432. case c of
  1433. 'a' :
  1434. autoloadunits:=more;
  1435. 'c' :
  1436. begin
  1437. { if we first specify that the system code page should be
  1438. used and then explicitly specify a code page, unset the
  1439. flag that we're using the system code page again }
  1440. SetCompileModeSwitch('SYSTEMCODEPAGE-',true);
  1441. if (upper(more)='UTF8') or (upper(more)='UTF-8') then
  1442. init_settings.sourcecodepage:=CP_UTF8
  1443. else if not(cpavailable(more)) then
  1444. Message1(option_code_page_not_available,more)
  1445. else
  1446. init_settings.sourcecodepage:=codepagebyname(more);
  1447. include(init_settings.moduleswitches,cs_explicit_codepage);
  1448. end;
  1449. 'C' :
  1450. RCCompiler:=More;
  1451. 'd' :
  1452. if UnsetBool(more, 0, opt, true) then
  1453. init_settings.disabledircache:=false
  1454. else
  1455. init_settings.disabledircache:=true;
  1456. 'D' :
  1457. utilsdirectory:=FixPath(More,true);
  1458. 'e' :
  1459. SetRedirectFile(More);
  1460. 'E' :
  1461. OutputExeDir:=FixPath(More,true);
  1462. 'f' :
  1463. if (target_info.system in systems_darwin) then
  1464. if ispara then
  1465. ParaFrameworkPath.AddPath(More,false)
  1466. else
  1467. frameworksearchpath.AddPath(More,true)
  1468. else
  1469. IllegalPara(opt);
  1470. 'i' :
  1471. begin
  1472. if ispara then
  1473. ParaIncludePath.AddPath(More,false)
  1474. else
  1475. includesearchpath.AddPath(More,true);
  1476. end;
  1477. 'm' :
  1478. begin
  1479. s:=ExtractFileDir(more);
  1480. if TryStrToInt(ExtractFileName(more),j) then
  1481. begin
  1482. unicodemapping:=loadunicodemapping(More,More+'.txt',j);
  1483. if assigned(unicodemapping) then
  1484. registermapping(unicodemapping)
  1485. else
  1486. IllegalPara(opt);
  1487. end
  1488. else
  1489. IllegalPara(opt);
  1490. end;
  1491. 'M' :
  1492. unicodepath:=FixPath(More,true);
  1493. 'g' :
  1494. Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  1495. 'l' :
  1496. begin
  1497. if path_absolute(More) then
  1498. if ispara then
  1499. ParaLibraryPath.AddPath(sysrootpath,More,false)
  1500. else
  1501. LibrarySearchPath.AddPath(sysrootpath,More,true)
  1502. else
  1503. if ispara then
  1504. ParaLibraryPath.AddPath('',More,false)
  1505. else
  1506. LibrarySearchPath.AddPath('',More,true);
  1507. end;
  1508. 'L' :
  1509. begin
  1510. if More<>'' then
  1511. ParaDynamicLinker:=More
  1512. else
  1513. IllegalPara(opt);
  1514. end;
  1515. 'o' :
  1516. begin
  1517. if ispara then
  1518. ParaObjectPath.AddPath(More,false)
  1519. else
  1520. ObjectSearchPath.AddPath(More,true);
  1521. end;
  1522. 'P' :
  1523. begin
  1524. if ispara then
  1525. parapackages.add(more,nil)
  1526. else
  1527. add_package(more,true,true);
  1528. end;
  1529. 'p' :
  1530. begin
  1531. if ispara then
  1532. parapackagepath.AddPath(More,false)
  1533. else
  1534. packagesearchpath.AddPath(More,true);
  1535. end;
  1536. 'r' :
  1537. Msgfilename:=More;
  1538. 'R' :
  1539. ResCompiler:=More;
  1540. 'u' :
  1541. begin
  1542. if ispara then
  1543. ParaUnitPath.AddPath(More,false)
  1544. else
  1545. unitsearchpath.AddPath(More,true);
  1546. end;
  1547. 'U' :
  1548. OutputUnitDir:=FixPath(More,true);
  1549. 'W',
  1550. 'w':
  1551. begin
  1552. if More<>'' then
  1553. begin
  1554. DefaultReplacements(More);
  1555. D:=ExtractFilePath(More);
  1556. if (D<>'') then
  1557. D:=FixPath(D,True);
  1558. D:=D+ExtractFileName(More);
  1559. if (c='W') then
  1560. WpoFeedbackOutput:=D
  1561. else
  1562. WpoFeedbackInput:=D;
  1563. end
  1564. else
  1565. IllegalPara(opt);
  1566. end;
  1567. else
  1568. IllegalPara(opt);
  1569. end;
  1570. end;
  1571. 'g' :
  1572. begin
  1573. if UnsetBool(More, 0, opt, false) then
  1574. begin
  1575. exclude(init_settings.moduleswitches,cs_debuginfo);
  1576. exclude(init_settings.globalswitches,cs_use_heaptrc);
  1577. exclude(init_settings.globalswitches,cs_use_lineinfo);
  1578. exclude(init_settings.localswitches,cs_checkpointer);
  1579. localvartrashing := -1;
  1580. end
  1581. else
  1582. begin
  1583. include(init_settings.moduleswitches,cs_debuginfo);
  1584. if paratargetdbg=dbg_none then
  1585. paratargetdbg:=target_info.dbg;
  1586. end;
  1587. if not RelocSectionSetExplicitly then
  1588. RelocSection:=false;
  1589. j:=1;
  1590. while j<=length(more) do
  1591. begin
  1592. case more[j] of
  1593. 'c' :
  1594. begin
  1595. if UnsetBool(More, j, opt, false) then
  1596. exclude(init_settings.localswitches,cs_checkpointer)
  1597. else if (target_info.system in systems_support_checkpointer) then
  1598. begin
  1599. if do_release then
  1600. Message(option_gc_incompatible_with_release_flag)
  1601. else
  1602. include(init_settings.localswitches,cs_checkpointer);
  1603. end
  1604. else
  1605. UnsupportedPara('-gc');
  1606. end;
  1607. 'h' :
  1608. begin
  1609. if UnsetBool(More, j, opt, false) then
  1610. exclude(init_settings.globalswitches,cs_use_heaptrc)
  1611. else
  1612. include(init_settings.globalswitches,cs_use_heaptrc);
  1613. end;
  1614. 'l' :
  1615. begin
  1616. if UnsetBool(More, j, opt, false) then
  1617. exclude(init_settings.globalswitches,cs_use_lineinfo)
  1618. else
  1619. include(init_settings.globalswitches,cs_use_lineinfo);
  1620. end;
  1621. 'o' :
  1622. begin
  1623. if not UpdateDebugStr(copy(more,j+1,length(more)),init_settings.debugswitches) then
  1624. IllegalPara(opt);
  1625. break;
  1626. end;
  1627. 'p' :
  1628. begin
  1629. if UnsetBool(More, j, opt, false) then
  1630. exclude(init_settings.globalswitches,cs_stabs_preservecase)
  1631. else
  1632. include(init_settings.globalswitches,cs_stabs_preservecase);
  1633. end;
  1634. 's' :
  1635. begin
  1636. paratargetdbg:=dbg_stabs;
  1637. end;
  1638. 't' :
  1639. begin
  1640. if UnsetBool(More, j, opt, false) then
  1641. localvartrashing := -1
  1642. else
  1643. localvartrashing := (localvartrashing + 1) mod nroftrashvalues;
  1644. end;
  1645. 'v' :
  1646. begin
  1647. if UnsetBool(More, j, opt, false) then
  1648. exclude(init_settings.globalswitches,cs_gdb_valgrind)
  1649. else
  1650. include(init_settings.globalswitches,cs_gdb_valgrind);
  1651. end;
  1652. 'w' :
  1653. begin
  1654. if (j<length(more)) and (more[j+1] in ['2','3','4']) then
  1655. begin
  1656. case more[j+1] of
  1657. '2': paratargetdbg:=dbg_dwarf2;
  1658. '3': paratargetdbg:=dbg_dwarf3;
  1659. '4': paratargetdbg:=dbg_dwarf4;
  1660. end;
  1661. inc(j);
  1662. end
  1663. else
  1664. paratargetdbg:=dbg_dwarf2;
  1665. end;
  1666. else
  1667. IllegalPara(opt);
  1668. end;
  1669. inc(j);
  1670. end;
  1671. end;
  1672. 'h' :
  1673. begin
  1674. NoPressEnter:=true;
  1675. if (More <> '') and (More [1] = 'F') then
  1676. begin
  1677. FPCHelpLines := true;
  1678. Delete (More, 1, 1);
  1679. FPCBinaryPath := More;
  1680. end;
  1681. WriteHelpPages;
  1682. end;
  1683. 'i' :
  1684. begin
  1685. if (More='') or
  1686. (More [1] in ['a', 'c', 'f', 'i', 'o', 'r', 't', 'u', 'w']) then
  1687. WriteInfo (More)
  1688. else
  1689. QuickInfo:=QuickInfo+More;
  1690. end;
  1691. 'I' :
  1692. begin
  1693. if ispara then
  1694. ParaIncludePath.AddPath(More,false)
  1695. else
  1696. includesearchpath.AddPath(More,false);
  1697. end;
  1698. 'k' :
  1699. begin
  1700. if more<>'' then
  1701. ParaLinkOptions:=ParaLinkOptions+' '+More
  1702. else
  1703. IllegalPara(opt);
  1704. end;
  1705. 'l' :
  1706. ParaLogo:=not UnSetBool(more,0,opt,true);
  1707. {$ifdef PREPROCWRITE}
  1708. 'm' :
  1709. parapreprocess:=not UnSetBool(more,0,opt,true);
  1710. {$endif PREPROCWRITE}
  1711. 'M' :
  1712. begin
  1713. more:=Upper(more);
  1714. if not SetCompileMode(more, true) then
  1715. if not SetCompileModeSwitch(more, true) then
  1716. IllegalPara(opt);
  1717. end;
  1718. 'n' :
  1719. begin
  1720. if More='' then
  1721. disable_configfile:=true
  1722. else
  1723. IllegalPara(opt);
  1724. end;
  1725. 'o' :
  1726. begin
  1727. if More<>'' then
  1728. begin
  1729. DefaultReplacements(More);
  1730. D:=ExtractFilePath(More);
  1731. if (D<>'') then
  1732. OutputExeDir:=FixPath(D,True);
  1733. OutputFileName:=ExtractFileName(More);
  1734. end
  1735. else
  1736. IllegalPara(opt);
  1737. end;
  1738. 'O' :
  1739. begin
  1740. j:=1;
  1741. while j<=length(more) do
  1742. begin
  1743. case more[j] of
  1744. '1' :
  1745. init_settings.optimizerswitches:=init_settings.optimizerswitches+level1optimizerswitches;
  1746. '2' :
  1747. init_settings.optimizerswitches:=init_settings.optimizerswitches+level2optimizerswitches;
  1748. '3' :
  1749. init_settings.optimizerswitches:=init_settings.optimizerswitches+level3optimizerswitches;
  1750. '4' :
  1751. init_settings.optimizerswitches:=init_settings.optimizerswitches+level4optimizerswitches;
  1752. 'a' :
  1753. begin
  1754. if not(UpdateAlignmentStr(Copy(Opt,j+3,255),ParaAlignment)) then
  1755. IllegalPara(opt);
  1756. break;
  1757. end;
  1758. 's' :
  1759. include(init_settings.optimizerswitches,cs_opt_size);
  1760. 'p' :
  1761. begin
  1762. if not Setoptimizecputype(copy(more,j+1,length(more)),init_settings.optimizecputype) then
  1763. begin
  1764. OptCPUSetExplicitly:=true;
  1765. { Give warning for old i386 switches }
  1766. if (Length(More)-j=1) and
  1767. (More[j+1]>='1') and (More[j+1]<='5')then
  1768. Message2(option_obsolete_switch_use_new,'-Op<nr>','-Op<name>')
  1769. else
  1770. IllegalPara(opt);
  1771. end;
  1772. break;
  1773. end;
  1774. 'o' :
  1775. begin
  1776. if not UpdateOptimizerStr(copy(more,j+1,length(more)),init_settings.optimizerswitches) then
  1777. IllegalPara(opt);
  1778. break;
  1779. end;
  1780. '-' :
  1781. begin
  1782. init_settings.optimizerswitches:=[];
  1783. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  1784. end;
  1785. { Obsolete switches }
  1786. 'g' :
  1787. Message2(option_obsolete_switch_use_new,'-Og','-Os');
  1788. 'G' :
  1789. Message1(option_obsolete_switch,'-OG');
  1790. 'r' :
  1791. Message2(option_obsolete_switch_use_new,'-Or','-O2 or -Ooregvar');
  1792. 'u' :
  1793. Message2(option_obsolete_switch_use_new,'-Ou','-Oouncertain');
  1794. 'w' :
  1795. begin
  1796. if not UpdateWpoStr(copy(more,j+1,length(more)),init_settings.dowpoptimizerswitches) then
  1797. IllegalPara(opt);
  1798. break;
  1799. end;
  1800. 'W' :
  1801. begin
  1802. if not UpdateWpoStr(copy(more,j+1,length(more)),init_settings.genwpoptimizerswitches) then
  1803. IllegalPara(opt);
  1804. break;
  1805. end;
  1806. else
  1807. IllegalPara(opt);
  1808. end;
  1809. inc(j);
  1810. end;
  1811. end;
  1812. 'p' :
  1813. begin
  1814. if UnsetBool(More, 0, opt, false) then
  1815. begin
  1816. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_profile];
  1817. undef_system_macro('FPC_PROFILE');
  1818. end
  1819. else
  1820. if Length(More)=0 then
  1821. IllegalPara(opt)
  1822. else
  1823. case more[1] of
  1824. 'g' : if UnsetBool(more, 1, opt, false) then
  1825. begin
  1826. exclude(init_settings.moduleswitches,cs_profile);
  1827. undef_system_macro('FPC_PROFILE');
  1828. end
  1829. else if (target_info.system in supported_targets_pg) then
  1830. begin
  1831. include(init_settings.moduleswitches,cs_profile);
  1832. def_system_macro('FPC_PROFILE');
  1833. end
  1834. else
  1835. UnsupportedPara('-pg');
  1836. else
  1837. IllegalPara(opt);
  1838. end;
  1839. end;
  1840. 'P' :
  1841. begin
  1842. { used to select the target processor with the "fpc" binary;
  1843. give an error if it's not the target architecture supported by
  1844. this compiler binary (will be verified after the target_info
  1845. is set) }
  1846. processorstr:=More;
  1847. end;
  1848. 'R' :
  1849. begin
  1850. if not SetAsmReadMode(More,init_settings.asmmode) then
  1851. IllegalPara(opt);
  1852. end;
  1853. 's' :
  1854. begin
  1855. if UnsetBool(More, 0, opt, false) then
  1856. begin
  1857. init_settings.globalswitches:=init_settings.globalswitches-[cs_asm_extern,cs_link_extern,cs_link_nolink];
  1858. if more<>'' then
  1859. IllegalPara(opt);
  1860. end
  1861. else
  1862. begin
  1863. init_settings.globalswitches:=init_settings.globalswitches+[cs_asm_extern,cs_link_extern,cs_link_nolink];
  1864. if more='h' then
  1865. init_settings.globalswitches:=init_settings.globalswitches-[cs_link_on_target]
  1866. else if more='t' then
  1867. init_settings.globalswitches:=init_settings.globalswitches+[cs_link_on_target]
  1868. else if more='r' then
  1869. init_settings.globalswitches:=init_settings.globalswitches+[cs_asm_leave,cs_no_regalloc]
  1870. else if more<>'' then
  1871. IllegalPara(opt);
  1872. end;
  1873. end;
  1874. 'S' :
  1875. begin
  1876. if more='' then
  1877. IllegalPara(opt);
  1878. if more[1]='I' then
  1879. begin
  1880. {$ifdef jvm}
  1881. UnsupportedPara('-SI');
  1882. {$endif}
  1883. if upper(more)='ICOM' then
  1884. init_settings.interfacetype:=it_interfacecom
  1885. else if upper(more)='ICORBA' then
  1886. init_settings.interfacetype:=it_interfacecorba
  1887. else
  1888. IllegalPara(opt);
  1889. end
  1890. else
  1891. begin
  1892. j:=1;
  1893. while j<=length(more) do
  1894. begin
  1895. case more[j] of
  1896. '2' : //an alternative to -Mobjfpc
  1897. SetCompileMode('OBJFPC',true);
  1898. 'a' :
  1899. If UnsetBool(More, j, opt, false) then
  1900. exclude(init_settings.localswitches,cs_do_assertion)
  1901. else
  1902. include(init_settings.localswitches,cs_do_assertion);
  1903. 'c' :
  1904. If UnsetBool(More, j, opt, false) then
  1905. exclude(init_settings.moduleswitches,cs_support_c_operators)
  1906. else
  1907. include(init_settings.moduleswitches,cs_support_c_operators);
  1908. 'd' : //an alternative to -Mdelphi
  1909. SetCompileMode('DELPHI',true);
  1910. 'e' :
  1911. begin
  1912. SetErrorFlags(copy(more,j+1,length(more)));
  1913. break;
  1914. end;
  1915. 'f' :
  1916. begin
  1917. if not(cs_compilesystem in init_settings.moduleswitches) then
  1918. Message(option_features_only_for_system_unit);
  1919. inc(j);
  1920. if more[j]='-' then
  1921. begin
  1922. if length(more)>j then
  1923. IllegalPara(opt)
  1924. else
  1925. features:=[];
  1926. end
  1927. else
  1928. begin
  1929. if (HandleFeature(upper(copy(more,j,length(more)-j+1)))) then
  1930. j:=length(more)
  1931. else
  1932. IllegalPara(opt);
  1933. end;
  1934. end;
  1935. 'g' :
  1936. If UnsetBool(More, j, opt, false) then
  1937. exclude(init_settings.moduleswitches,cs_support_goto)
  1938. else
  1939. include(init_settings.moduleswitches,cs_support_goto);
  1940. 'h' :
  1941. If UnsetBool(More, j, opt, false) then
  1942. exclude(init_settings.localswitches,cs_refcountedstrings)
  1943. else
  1944. include(init_settings.localswitches,cs_refcountedstrings);
  1945. 'i' :
  1946. If UnsetBool(More, j, opt, false) then
  1947. exclude(init_settings.localswitches,cs_do_inline)
  1948. else
  1949. include(init_settings.localswitches,cs_do_inline);
  1950. 'j' :
  1951. If UnsetBool(More, j, opt, false) then
  1952. exclude(init_settings.localswitches,cs_typed_const_writable)
  1953. else
  1954. include(init_settings.localswitches,cs_typed_const_writable);
  1955. 'k' :
  1956. If UnsetBool(More, j, opt, false) then
  1957. exclude(init_settings.globalswitches,cs_load_fpcylix_unit)
  1958. else
  1959. include(init_settings.globalswitches,cs_load_fpcylix_unit);
  1960. 'm' :
  1961. If UnsetBool(More, j, opt, false) then
  1962. exclude(init_settings.moduleswitches,cs_support_macro)
  1963. else
  1964. include(init_settings.moduleswitches,cs_support_macro);
  1965. 'o' : //an alternative to -Mtp
  1966. SetCompileMode('TP',true);
  1967. 'r' :
  1968. If UnsetBool(More, j, opt, false) then
  1969. exclude(init_settings.globalswitches,cs_transparent_file_names)
  1970. else
  1971. include(init_settings.globalswitches,cs_transparent_file_names);
  1972. {$ifdef gpc_mode}
  1973. 'p' : //an alternative to -Mgpc
  1974. SetCompileMode('GPC',true);
  1975. {$endif}
  1976. 's' :
  1977. If UnsetBool(More, j, opt, false) then
  1978. exclude(init_settings.globalswitches,cs_constructor_name)
  1979. else
  1980. include(init_settings.globalswitches,cs_constructor_name);
  1981. 't' :
  1982. Message1(option_obsolete_switch,'-St');
  1983. 'v' :
  1984. If UnsetBool(More, j, opt, false) then
  1985. exclude(init_settings.globalswitches,cs_support_vectors)
  1986. else
  1987. include(init_settings.globalswitches,cs_support_vectors);
  1988. 'x' :
  1989. If UnsetBool(More, j, opt, false) then
  1990. SetCompileModeSwitch('EXCEPTIONS-',true)
  1991. else
  1992. SetCompileModeSwitch('EXCEPTIONS',true);
  1993. 'y' :
  1994. If UnsetBool(More, j, opt, false) then
  1995. exclude(init_settings.localswitches,cs_typed_addresses)
  1996. else
  1997. include(init_settings.localswitches,cs_typed_addresses);
  1998. '-' :
  1999. begin
  2000. init_settings.globalswitches:=init_settings.globalswitches - [cs_constructor_name,cs_support_exceptions,
  2001. cs_support_vectors,cs_load_fpcylix_unit];
  2002. init_settings.localswitches:=init_settings.localswitches - [cs_do_assertion,cs_do_inline, cs_refcountedstrings,
  2003. cs_typed_addresses];
  2004. init_settings.moduleswitches:=init_settings.moduleswitches - [cs_support_c_operators, cs_support_goto,
  2005. cs_support_macro];
  2006. end;
  2007. else
  2008. IllegalPara(opt);
  2009. end;
  2010. inc(j);
  2011. end;
  2012. end;
  2013. end;
  2014. 'T' :
  2015. begin
  2016. more:=Upper(More);
  2017. if paratarget=system_none then
  2018. begin
  2019. { remove old target define }
  2020. TargetOptions(false);
  2021. { load new target }
  2022. paratarget:=find_system_by_string(More);
  2023. if paratarget<>system_none then
  2024. set_target(paratarget)
  2025. else
  2026. IllegalPara(opt);
  2027. { set new define }
  2028. TargetOptions(true);
  2029. end
  2030. else
  2031. if More<>upper(target_info.shortname) then
  2032. Message1(option_target_is_already_set,target_info.shortname);
  2033. end;
  2034. 'u' :
  2035. if is_identifier(more) then
  2036. undef_system_macro(more)
  2037. else
  2038. begin
  2039. if (more='') then
  2040. Message1(option_missing_arg,'-u')
  2041. else
  2042. Message1(option_malformed_para,opt);
  2043. StopOptions(1);
  2044. end;
  2045. 'U' :
  2046. begin
  2047. j:=1;
  2048. while j<=length(more) do
  2049. begin
  2050. case more[j] of
  2051. {$ifdef UNITALIASES}
  2052. 'a' :
  2053. begin
  2054. AddUnitAlias(Copy(More,j+1,255));
  2055. break;
  2056. end;
  2057. {$endif UNITALIASES}
  2058. 'n' :
  2059. exclude(init_settings.globalswitches,cs_check_unit_name);
  2060. 'p' :
  2061. begin
  2062. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  2063. break;
  2064. end;
  2065. 'r' :
  2066. begin
  2067. do_release:=true;
  2068. if (cs_checkpointer in init_settings.localswitches) then
  2069. begin
  2070. Message(option_gc_incompatible_with_release_flag);
  2071. exclude(init_settings.localswitches,cs_checkpointer);
  2072. end;
  2073. end;
  2074. 's' :
  2075. include(init_settings.moduleswitches,cs_compilesystem);
  2076. '-' :
  2077. begin
  2078. exclude(init_settings.moduleswitches,cs_compilesystem);
  2079. exclude(init_settings.globalswitches,cs_check_unit_name);
  2080. end;
  2081. else
  2082. IllegalPara(opt);
  2083. end;
  2084. inc(j);
  2085. end;
  2086. end;
  2087. 'v' :
  2088. begin
  2089. if not setverbosity(More) then
  2090. IllegalPara(opt);
  2091. end;
  2092. 'V' : ; { Ignore used by fpc }
  2093. 'W' :
  2094. begin
  2095. j:=1;
  2096. while j<=length(More) do
  2097. begin
  2098. case More[j] of
  2099. 'A':
  2100. begin
  2101. if target_info.system in systems_all_windows then
  2102. begin
  2103. if UnsetBool(More, j, opt, false) then
  2104. SetApptype(app_cui)
  2105. else
  2106. SetApptype(app_native);
  2107. end
  2108. else
  2109. IllegalPara(opt);
  2110. end;
  2111. 'b':
  2112. begin
  2113. if target_info.system in systems_darwin then
  2114. begin
  2115. if UnsetBool(More, j, opt, false) then
  2116. SetApptype(app_cui)
  2117. else
  2118. SetApptype(app_bundle)
  2119. end
  2120. else
  2121. IllegalPara(opt);
  2122. end;
  2123. 'B':
  2124. begin
  2125. if target_info.system in systems_all_windows+systems_symbian then
  2126. begin
  2127. { -WB200000 means set trefered base address
  2128. to $200000, but does not change relocsection boolean
  2129. this way we can create both relocatble and
  2130. non relocatable DLL at a specific base address PM }
  2131. if (length(More)>j) then
  2132. begin
  2133. val('$'+Copy(More,j+1,255),imagebase,code);
  2134. if code<>0 then
  2135. IllegalPara(opt);
  2136. ImageBaseSetExplicity:=true;
  2137. end
  2138. else
  2139. begin
  2140. RelocSection:=true;
  2141. RelocSectionSetExplicitly:=true;
  2142. end;
  2143. break;
  2144. end
  2145. else
  2146. IllegalPara(opt);
  2147. end;
  2148. 'C':
  2149. begin
  2150. if target_info.system in systems_all_windows+systems_os2+systems_macos then
  2151. begin
  2152. if UnsetBool(More, j, opt, false) then
  2153. SetApptype(app_gui)
  2154. else
  2155. SetApptype(app_cui);
  2156. end
  2157. else
  2158. IllegalPara(opt);
  2159. end;
  2160. 'D':
  2161. begin
  2162. if target_info.system in systems_all_windows then
  2163. begin
  2164. UseDeffileForExports:=not UnsetBool(More, j, opt, false);
  2165. UseDeffileForExportsSetExplicitly:=true;
  2166. end
  2167. else
  2168. IllegalPara(opt);
  2169. end;
  2170. 'e':
  2171. begin
  2172. if (target_info.system in systems_darwin) then
  2173. begin
  2174. RegisterRes(res_macosx_ext_info,TWinLikeResourceFile);
  2175. set_target_res(res_ext);
  2176. target_info.resobjext:='.fpcres';
  2177. end
  2178. else
  2179. IllegalPara(opt);
  2180. end;
  2181. 'F':
  2182. begin
  2183. if target_info.system in systems_os2 then
  2184. begin
  2185. if UnsetBool(More, j, opt, false) then
  2186. SetApptype(app_cui)
  2187. else
  2188. SetApptype(app_fs);
  2189. end
  2190. else
  2191. IllegalPara(opt);
  2192. end;
  2193. 'G':
  2194. begin
  2195. if target_info.system in systems_all_windows+systems_os2+systems_macos then
  2196. begin
  2197. if UnsetBool(More, j, opt, false) then
  2198. SetApptype(app_cui)
  2199. else
  2200. SetApptype(app_gui);
  2201. end
  2202. else
  2203. IllegalPara(opt);
  2204. end;
  2205. {$if defined(i8086)}
  2206. 'h':
  2207. begin
  2208. if UnsetBool(More, j, opt, false) then
  2209. exclude(init_settings.moduleswitches,cs_huge_code)
  2210. else
  2211. include(init_settings.moduleswitches,cs_huge_code);
  2212. end;
  2213. {$endif defined(i8086)}
  2214. 'I':
  2215. begin
  2216. if target_info.system in systems_all_windows then
  2217. begin
  2218. GenerateImportSection:=not UnsetBool(More,j,opt,false);
  2219. GenerateImportSectionSetExplicitly:=true;
  2220. end
  2221. else
  2222. IllegalPara(opt);
  2223. end;
  2224. 'i':
  2225. begin
  2226. if (target_info.system in systems_darwin) then
  2227. begin
  2228. set_target_res(res_macho);
  2229. target_info.resobjext:=
  2230. targetinfos[target_info.system]^.resobjext;
  2231. end
  2232. else
  2233. IllegalPara(opt);
  2234. end;
  2235. 'm':
  2236. begin
  2237. {$if defined(i8086)}
  2238. if (target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded]) then
  2239. begin
  2240. case Upper(Copy(More,j+1,255)) of
  2241. 'TINY': init_settings.x86memorymodel:=mm_tiny;
  2242. 'SMALL': init_settings.x86memorymodel:=mm_small;
  2243. 'MEDIUM': init_settings.x86memorymodel:=mm_medium;
  2244. 'COMPACT': init_settings.x86memorymodel:=mm_compact;
  2245. 'LARGE': init_settings.x86memorymodel:=mm_large;
  2246. 'HUGE': init_settings.x86memorymodel:=mm_huge;
  2247. else
  2248. IllegalPara(opt);
  2249. end;
  2250. break;
  2251. end
  2252. else
  2253. {$endif defined(i8086)}
  2254. IllegalPara(opt);
  2255. end;
  2256. 'M':
  2257. begin
  2258. if (target_info.system in (systems_darwin-[system_i386_iphonesim,system_arm_darwin,system_aarch64_darwin,system_x86_64_iphonesim])) and
  2259. ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED',copy(More,2,255),false) then
  2260. begin
  2261. break;
  2262. end
  2263. else
  2264. IllegalPara(opt);
  2265. end;
  2266. 'N':
  2267. begin
  2268. if target_info.system in systems_all_windows then
  2269. begin
  2270. RelocSection:=UnsetBool(More,j,opt,false);
  2271. RelocSectionSetExplicitly:=true;
  2272. end
  2273. else
  2274. IllegalPara(opt);
  2275. end;
  2276. 'p':
  2277. begin
  2278. {$push}
  2279. {$warn 6018 off} { Unreachable code due to compile time evaluation }
  2280. if (target_info.system in systems_embedded) and
  2281. ControllerSupport then
  2282. begin
  2283. s:=upper(copy(more,j+1,length(more)-j));
  2284. if not(SetControllerType(s,init_settings.controllertype)) then
  2285. IllegalPara(opt)
  2286. else
  2287. begin
  2288. if init_settings.cputype<>embedded_controllers[init_settings.controllertype].cputype then
  2289. begin
  2290. Message(scan_n_changecputype);
  2291. init_settings.cputype:=embedded_controllers[init_settings.controllertype].cputype;
  2292. end;
  2293. end;
  2294. break;
  2295. end
  2296. else
  2297. IllegalPara(opt);
  2298. {$pop}
  2299. end;
  2300. 'P':
  2301. begin
  2302. if (target_info.system in [system_i386_iphonesim,system_arm_darwin,system_aarch64_darwin,system_x86_64_iphonesim]) and
  2303. ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED',copy(More,2,255),true) then
  2304. begin
  2305. break;
  2306. end
  2307. else
  2308. IllegalPara(opt);
  2309. end;
  2310. 'R':
  2311. begin
  2312. if target_info.system in systems_all_windows then
  2313. begin
  2314. { support -WR+ / -WR- as synonyms to -WR / -WN }
  2315. RelocSection:=not UnsetBool(More,j,opt,false);
  2316. RelocSectionSetExplicitly:=true;
  2317. end
  2318. else
  2319. IllegalPara(opt);
  2320. end;
  2321. 't':
  2322. begin
  2323. {$if defined(i8086)}
  2324. if (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  2325. begin
  2326. case Upper(Copy(More,j+1,255)) of
  2327. 'EXE': SetAppType(app_cui);
  2328. 'COM': SetAppType(app_com);
  2329. else
  2330. IllegalPara(opt);
  2331. end;
  2332. break;
  2333. end
  2334. else
  2335. {$endif defined(i8086)}
  2336. IllegalPara(opt);
  2337. end;
  2338. 'T':
  2339. begin
  2340. if target_info.system in systems_macos then
  2341. begin
  2342. if UnsetBool(More, j, opt, false) then
  2343. SetApptype(app_cui)
  2344. else
  2345. SetApptype(app_tool);
  2346. end
  2347. else
  2348. IllegalPara(opt);
  2349. end;
  2350. 'X':
  2351. begin
  2352. if (target_info.system in systems_linux) then
  2353. begin
  2354. if UnsetBool(More, j, opt, false) then
  2355. exclude(init_settings.moduleswitches,cs_executable_stack)
  2356. else
  2357. include(init_settings.moduleswitches,cs_executable_stack)
  2358. end
  2359. else
  2360. IllegalPara(opt);
  2361. end;
  2362. else
  2363. IllegalPara(opt);
  2364. end;
  2365. inc(j);
  2366. end;
  2367. end;
  2368. 'X' :
  2369. begin
  2370. j:=1;
  2371. while j<=length(more) do
  2372. begin
  2373. case More[j] of
  2374. '9' :
  2375. begin
  2376. if target_info.system in systems_linux then
  2377. begin
  2378. if UnsetBool(More, j, opt, false) then
  2379. exclude(init_settings.globalswitches,cs_link_pre_binutils_2_19)
  2380. else
  2381. include(init_settings.globalswitches,cs_link_pre_binutils_2_19);
  2382. end
  2383. else
  2384. IllegalPara(opt);
  2385. end;
  2386. 'c' : Cshared:=TRUE;
  2387. 'd' : Dontlinkstdlibpath:=TRUE;
  2388. 'e' :
  2389. begin
  2390. If UnsetBool(More, j, opt, false) then
  2391. exclude(init_settings.globalswitches,cs_link_extern)
  2392. else
  2393. include(init_settings.globalswitches,cs_link_extern);
  2394. end;
  2395. 'f' :
  2396. include(init_settings.globalswitches,cs_link_pthread);
  2397. 'g' :
  2398. begin
  2399. If UnsetBool(More, j, opt, false) then
  2400. exclude(init_settings.globalswitches,cs_link_separate_dbg_file)
  2401. else
  2402. include(init_settings.globalswitches,cs_link_separate_dbg_file);
  2403. end;
  2404. 'i' :
  2405. begin
  2406. If UnsetBool(More, j, opt, false) then
  2407. include(init_settings.globalswitches,cs_link_extern)
  2408. else
  2409. exclude(init_settings.globalswitches,cs_link_extern);
  2410. end;
  2411. 'n' :
  2412. begin
  2413. If UnsetBool(More, j, opt, false) then
  2414. exclude(init_settings.globalswitches,cs_link_native)
  2415. else
  2416. include(init_settings.globalswitches,cs_link_native);
  2417. end;
  2418. 'm' :
  2419. begin
  2420. If UnsetBool(More, j, opt, false) then
  2421. exclude(init_settings.globalswitches,cs_link_map)
  2422. else
  2423. include(init_settings.globalswitches,cs_link_map);
  2424. end;
  2425. 'p' : ; { Ignore used by fpc.pp }
  2426. 'r' :
  2427. begin
  2428. if (target_info.system in suppported_targets_x_smallr) then
  2429. begin
  2430. rlinkpath:=Copy(more,2,length(More)-1);
  2431. DefaultReplacements(rlinkpath);
  2432. end
  2433. else
  2434. IgnoredPara('-Xr');
  2435. more:='';
  2436. end;
  2437. 'R' :
  2438. begin
  2439. sysrootpath:=copy(more,2,length(more)-1);
  2440. defaultreplacements(sysrootpath);
  2441. more:='';
  2442. end;
  2443. 's' :
  2444. begin
  2445. If UnsetBool(More, j, opt, false) then
  2446. exclude(init_settings.globalswitches,cs_link_strip)
  2447. else
  2448. include(init_settings.globalswitches,cs_link_strip);
  2449. end;
  2450. 't' :
  2451. include(init_settings.globalswitches,cs_link_staticflag);
  2452. 'v' :
  2453. begin
  2454. If UnsetBool(More, j, opt, false) then
  2455. exclude(init_settings.globalswitches,cs_link_opt_vtable)
  2456. else
  2457. include(init_settings.globalswitches,cs_link_opt_vtable);
  2458. end;
  2459. 'D' :
  2460. begin
  2461. def_system_macro('FPC_LINK_DYNAMIC');
  2462. undef_system_macro('FPC_LINK_SMART');
  2463. undef_system_macro('FPC_LINK_STATIC');
  2464. exclude(init_settings.globalswitches,cs_link_static);
  2465. exclude(init_settings.globalswitches,cs_link_smart);
  2466. include(init_settings.globalswitches,cs_link_shared);
  2467. LinkTypeSetExplicitly:=true;
  2468. end;
  2469. 'M' :
  2470. begin
  2471. mainaliasname:=Copy(more,2,length(More)-1);
  2472. More:='';
  2473. end;
  2474. 'P' :
  2475. begin
  2476. utilsprefix:=Copy(more,2,length(More)-1);
  2477. DefaultReplacements(utilsprefix);
  2478. More:='';
  2479. end;
  2480. 'L' : begin // -XLO is link order -XLA is link alias. -XLD avoids load defaults.
  2481. // these are not aggregable.
  2482. if (j=length(more)) or not (more[j+1] in ['O','A','D']) then
  2483. IllegalPara(opt)
  2484. else
  2485. begin
  2486. case more[j+1] of
  2487. 'A' : begin
  2488. s:=Copy(more,3,length(More)-2);
  2489. if not LinkLibraryAliases.AddDep(s) Then
  2490. IllegalPara(opt);
  2491. end;
  2492. 'O' : begin
  2493. s:=Copy(more,3,length(More)-2);
  2494. if not LinkLibraryOrder.AddWeight(s) Then
  2495. IllegalPara(opt);
  2496. end;
  2497. 'D' : include(init_settings.globalswitches,cs_link_no_default_lib_order)
  2498. else
  2499. IllegalPara(opt);
  2500. end; {case}
  2501. j:=length(more);
  2502. end; {else begin}
  2503. end;
  2504. 'S' :
  2505. begin
  2506. ForceStaticLinking;
  2507. end;
  2508. 'V' :
  2509. begin
  2510. if UnsetBool(More, j, opt, false) then
  2511. exclude(init_settings.globalswitches,cs_link_vlink)
  2512. else
  2513. begin
  2514. include(init_settings.globalswitches,cs_link_vlink);
  2515. include(init_settings.globalswitches,cs_link_extern);
  2516. end;
  2517. LinkerSetExplicitly:=true;
  2518. end;
  2519. 'X' :
  2520. begin
  2521. def_system_macro('FPC_LINK_SMART');
  2522. undef_system_macro('FPC_LINK_STATIC');
  2523. undef_system_macro('FPC_LINK_DYNAMIC');
  2524. exclude(init_settings.globalswitches,cs_link_static);
  2525. include(init_settings.globalswitches,cs_link_smart);
  2526. exclude(init_settings.globalswitches,cs_link_shared);
  2527. LinkTypeSetExplicitly:=true;
  2528. end;
  2529. '-' :
  2530. begin
  2531. exclude(init_settings.globalswitches,cs_link_staticflag);
  2532. exclude(init_settings.globalswitches,cs_link_strip);
  2533. exclude(init_settings.globalswitches,cs_link_map);
  2534. set_default_link_type;
  2535. end;
  2536. else
  2537. IllegalPara(opt);
  2538. end;
  2539. inc(j);
  2540. end;
  2541. end;
  2542. else
  2543. IllegalPara(opt);
  2544. end;
  2545. end;
  2546. '@' :
  2547. begin
  2548. Message(option_no_nested_response_file);
  2549. StopOptions(1);
  2550. end;
  2551. else
  2552. begin
  2553. if (length(param_file)<>0) then
  2554. Message2(option_only_one_source_support,param_file,opt);
  2555. param_file:=opt;
  2556. Message1(option_found_file,opt);
  2557. end;
  2558. end;
  2559. end;
  2560. procedure Toption.Interpret_file(const filename : TPathStr);
  2561. procedure RemoveSep(var fn:TPathStr);
  2562. var
  2563. i : longint;
  2564. begin
  2565. i:=0;
  2566. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  2567. inc(i);
  2568. Delete(fn,1,i);
  2569. i:=length(fn);
  2570. while (i>0) and (fn[i] in [',',' ',#9]) do
  2571. dec(i);
  2572. fn:=copy(fn,1,i);
  2573. end;
  2574. function GetName(var fn:TPathStr):TPathStr;
  2575. var
  2576. i : longint;
  2577. begin
  2578. i:=0;
  2579. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  2580. inc(i);
  2581. GetName:=Copy(fn,1,i);
  2582. Delete(fn,1,i);
  2583. end;
  2584. const
  2585. maxlevel = 15;
  2586. var
  2587. f : text;
  2588. s, tmp,
  2589. opts : TCmdStr;
  2590. skip : array[0..maxlevel] of boolean;
  2591. line,
  2592. level : longint;
  2593. option_read : boolean;
  2594. oldfilemode : byte;
  2595. ConfigFile: TPathStr;
  2596. begin
  2597. { avoid infinite loop }
  2598. Inc(FileLevel);
  2599. Option_read:=false;
  2600. If FileLevel>MaxLevel then
  2601. Message(option_too_many_cfg_files);
  2602. if not ParaIncludeCfgPath.FindFile(fileName,true,ConfigFile) then
  2603. ConfigFile := ExpandFileName(filename);
  2604. { Maybe It's Directory ?} //Jaro Change:
  2605. if PathExists(ConfigFile,false) then
  2606. begin
  2607. Message1(option_config_is_dir,filename);
  2608. exit;
  2609. end;
  2610. { open file }
  2611. Message1(option_using_file,filename);
  2612. oldfilemode:=filemode;
  2613. filemode:=0;
  2614. assign(f,ConfigFile);
  2615. {$push}{$I-}
  2616. reset(f);
  2617. {$pop}
  2618. filemode:=oldfilemode;
  2619. if ioresult<>0 then
  2620. begin
  2621. Message1(option_unable_open_file,filename);
  2622. exit;
  2623. end;
  2624. Message1(option_start_reading_configfile,filename);
  2625. fillchar(skip,sizeof(skip),0);
  2626. level:=0;
  2627. line:=0;
  2628. while not eof(f) do
  2629. begin
  2630. readln(f,opts);
  2631. inc(line);
  2632. RemoveSep(opts);
  2633. if (opts<>'') and (opts[1]<>';') then
  2634. begin
  2635. if opts[1]='#' then
  2636. begin
  2637. Message1(option_interpreting_file_option,opts);
  2638. Delete(opts,1,1);
  2639. s:=upper(GetName(opts));
  2640. if (s='SECTION') then
  2641. begin
  2642. RemoveSep(opts);
  2643. s:=upper(GetName(opts));
  2644. if level=0 then
  2645. skip[level]:=not defined_macro(s) or (s='COMMON');
  2646. end
  2647. else
  2648. if (s='IFDEF') then
  2649. begin
  2650. RemoveSep(opts);
  2651. if Level>=maxlevel then
  2652. begin
  2653. Message2(option_too_many_ifdef,filename,tostr(line));
  2654. stopOptions(1);
  2655. end;
  2656. inc(Level);
  2657. skip[level]:=(skip[level-1] or not defined_macro(upper(GetName(opts))));
  2658. end
  2659. else
  2660. if (s='IFNDEF') then
  2661. begin
  2662. RemoveSep(opts);
  2663. if Level>=maxlevel then
  2664. begin
  2665. Message2(option_too_many_ifdef,filename,tostr(line));
  2666. stopOptions(1);
  2667. end;
  2668. inc(Level);
  2669. skip[level]:=(skip[level-1] or defined_macro(upper(GetName(opts))));
  2670. end
  2671. else
  2672. if (s='ELSE') then
  2673. begin
  2674. if Level=0 then
  2675. begin
  2676. Message2(option_else_without_if,filename,tostr(line));
  2677. stopOptions(1);
  2678. end
  2679. else
  2680. skip[level]:=skip[level-1] or (not skip[level])
  2681. end
  2682. else
  2683. if (s='ENDIF') then
  2684. begin
  2685. skip[level]:=false;
  2686. if Level=0 then
  2687. begin
  2688. Message2(option_too_many_endif,filename,tostr(line));
  2689. stopOptions(1);
  2690. end;
  2691. dec(level);
  2692. end
  2693. else
  2694. if (not skip[level]) then
  2695. begin
  2696. if (s='DEFINE') then
  2697. begin
  2698. RemoveSep(opts);
  2699. tmp:= GetName(opts);
  2700. if tmp <> '' then
  2701. def_system_macro(tmp);
  2702. Option_read:=true;
  2703. end
  2704. else
  2705. if (s='UNDEF') then
  2706. begin
  2707. RemoveSep(opts);
  2708. tmp:= GetName(opts);
  2709. if tmp <> '' then
  2710. undef_system_macro(tmp);
  2711. Option_read:=true;
  2712. end
  2713. else
  2714. if (s='WRITE') then
  2715. begin
  2716. Delete(opts,1,1);
  2717. DefaultReplacements(opts);
  2718. WriteLn(opts);
  2719. Option_read:=true;
  2720. end
  2721. else
  2722. if (s='INCLUDE') then
  2723. begin
  2724. Delete(opts,1,1);
  2725. DefaultReplacements(opts);
  2726. Interpret_file(opts);
  2727. Option_read:=true;
  2728. end
  2729. else
  2730. if (s='CFGDIR') then
  2731. begin
  2732. Delete(opts,1,1);
  2733. DefaultReplacements(opts);
  2734. ParaIncludeCfgPath.AddPath(opts,false);
  2735. Option_read:=true;
  2736. end;
  2737. end;
  2738. end
  2739. else
  2740. begin
  2741. if (opts[1]='-') or (opts[1]='@') then
  2742. begin
  2743. if (not skip[level]) then
  2744. interpret_option(opts,false);
  2745. Option_read:=true;
  2746. end
  2747. else
  2748. Message1(option_illegal_para,opts);
  2749. end;
  2750. end;
  2751. end;
  2752. if Level>0 then
  2753. Message(option_too_less_endif);
  2754. if Not Option_read then
  2755. Message1(option_no_option_found,filename)
  2756. else
  2757. Message1(option_end_reading_configfile,filename);
  2758. Close(f);
  2759. Dec(FileLevel);
  2760. end;
  2761. procedure Toption.Interpret_envvar(const envname : TCmdStr);
  2762. var
  2763. argstart,
  2764. env,
  2765. pc : pchar;
  2766. arglen : longint;
  2767. quote : set of char;
  2768. hs : TCmdStr;
  2769. begin
  2770. Message1(option_using_env,envname);
  2771. env:=GetEnvPChar(envname);
  2772. pc:=env;
  2773. if assigned(pc) then
  2774. begin
  2775. repeat
  2776. { skip leading spaces }
  2777. while pc^ in [' ',#9,#13] do
  2778. inc(pc);
  2779. case pc^ of
  2780. #0 :
  2781. break;
  2782. '"' :
  2783. begin
  2784. quote:=['"'];
  2785. inc(pc);
  2786. end;
  2787. '''' :
  2788. begin
  2789. quote:=[''''];
  2790. inc(pc);
  2791. end;
  2792. else
  2793. quote:=[' ',#9,#13];
  2794. end;
  2795. { scan until the end of the argument }
  2796. argstart:=pc;
  2797. while (pc^<>#0) and not(pc^ in quote) do
  2798. inc(pc);
  2799. { create argument }
  2800. arglen:=pc-argstart;
  2801. { TODO: FIXME: silent truncation of environment parameters }
  2802. if (arglen > 255) then
  2803. arglen := 255;
  2804. setlength(hs,arglen);
  2805. move(argstart^,hs[1],arglen);
  2806. interpret_option(hs,true);
  2807. { skip quote }
  2808. if pc^ in quote then
  2809. inc(pc);
  2810. until false;
  2811. end
  2812. else
  2813. Message1(option_no_option_found,'(env) '+envname);
  2814. FreeEnvPChar(env);
  2815. end;
  2816. procedure toption.read_parameters;
  2817. var
  2818. opts : TCmdStr;
  2819. paramindex : longint;
  2820. begin
  2821. paramindex:=0;
  2822. while paramindex<paramcount do
  2823. begin
  2824. inc(paramindex);
  2825. opts:=objpas.paramstr(paramindex);
  2826. if length(opts)>0 then
  2827. case opts[1] of
  2828. '@' :
  2829. if not firstpass then
  2830. begin
  2831. Delete(opts,1,1);
  2832. Message1(option_reading_further_from,opts);
  2833. interpret_file(opts);
  2834. end;
  2835. '!' :
  2836. if not firstpass then
  2837. begin
  2838. Delete(opts,1,1);
  2839. Message1(option_reading_further_from,'(env) '+opts);
  2840. interpret_envvar(opts);
  2841. end;
  2842. else
  2843. interpret_option(opts,true);
  2844. end;
  2845. end;
  2846. end;
  2847. procedure toption.parsecmd(cmd:TCmdStr);
  2848. var
  2849. i,ps : longint;
  2850. opts : TCmdStr;
  2851. begin
  2852. while (cmd<>'') do
  2853. begin
  2854. while cmd[1]=' ' do
  2855. delete(cmd,1,1);
  2856. i:=pos(' ',cmd);
  2857. if i=0 then
  2858. i:=2147483647;
  2859. opts:=Copy(cmd,1,i-1);
  2860. Delete(cmd,1,i);
  2861. case opts[1] of
  2862. '@' :
  2863. if not firstpass then
  2864. begin
  2865. Delete(opts,1,1);
  2866. Message1(option_reading_further_from,opts);
  2867. interpret_file(opts);
  2868. end;
  2869. '!' :
  2870. if not firstpass then
  2871. begin
  2872. Delete(opts,1,1);
  2873. Message1(option_reading_further_from,'(env) '+opts);
  2874. interpret_envvar(opts);
  2875. end;
  2876. '"' :
  2877. begin
  2878. Delete(opts,1,1);
  2879. ps:=pos('"',cmd);
  2880. if (i<>256) and (ps>0) then
  2881. begin
  2882. opts:=opts + ' '+ copy(cmd,1,ps-1);
  2883. cmd:=copy(cmd,ps+1,255);
  2884. end;
  2885. interpret_option(opts,true);
  2886. end;
  2887. else
  2888. interpret_option(opts,true);
  2889. end;
  2890. end;
  2891. end;
  2892. procedure toption.writequickinfo;
  2893. var
  2894. s : string;
  2895. i : longint;
  2896. procedure addinfo(const hs:string);
  2897. begin
  2898. if s<>'' then
  2899. s:=s+' '+hs
  2900. else
  2901. s:=hs;
  2902. end;
  2903. begin
  2904. s:='';
  2905. i:=0;
  2906. while (i<length(quickinfo)) do
  2907. begin
  2908. inc(i);
  2909. case quickinfo[i] of
  2910. 'S' :
  2911. begin
  2912. inc(i);
  2913. case quickinfo[i] of
  2914. 'O' :
  2915. addinfo(lower(source_info.shortname));
  2916. 'P' :
  2917. addinfo(source_cpu_string);
  2918. else
  2919. IllegalPara('-i'+QuickInfo);
  2920. end;
  2921. end;
  2922. 'T' :
  2923. begin
  2924. inc(i);
  2925. case quickinfo[i] of
  2926. 'O' :
  2927. addinfo(lower(target_info.shortname));
  2928. 'P' :
  2929. AddInfo(target_cpu_string);
  2930. else
  2931. IllegalPara('-i'+QuickInfo);
  2932. end;
  2933. end;
  2934. 'V' :
  2935. AddInfo(version_string);
  2936. 'W' :
  2937. AddInfo(full_version_string);
  2938. 'D' :
  2939. AddInfo(date_string);
  2940. '_' :
  2941. ;
  2942. else
  2943. IllegalPara('-i'+QuickInfo);
  2944. end;
  2945. end;
  2946. if s<>'' then
  2947. begin
  2948. writeln(s);
  2949. stopoptions(0);
  2950. end;
  2951. end;
  2952. procedure TOption.TargetOptions(def:boolean);
  2953. var
  2954. s : string;
  2955. i : integer;
  2956. target_unsup_features : tfeatures;
  2957. begin
  2958. if def then
  2959. def_system_macro(target_info.shortname)
  2960. else
  2961. undef_system_macro(target_info.shortname);
  2962. s:=target_info.extradefines;
  2963. while (s<>'') do
  2964. begin
  2965. i:=pos(';',s);
  2966. if i=0 then
  2967. i:=length(s)+1;
  2968. if def then
  2969. def_system_macro(Copy(s,1,i-1))
  2970. else
  2971. undef_system_macro(Copy(s,1,i-1));
  2972. delete(s,1,i);
  2973. end;
  2974. if (tf_winlikewidestring in target_info.flags) then
  2975. if def then
  2976. def_system_macro('FPC_WINLIKEWIDESTRING')
  2977. else
  2978. undef_system_macro('FPC_WINLIKEWIDESTRING');
  2979. if (tf_requires_proper_alignment in target_info.flags) then
  2980. if def then
  2981. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT')
  2982. else
  2983. undef_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  2984. if source_info.system<>target_info.system then
  2985. if def then
  2986. def_system_macro('FPC_CROSSCOMPILING')
  2987. else
  2988. undef_system_macro('FPC_CROSSCOMPILING');
  2989. if source_info.cpu<>target_info.cpu then
  2990. if def then
  2991. def_system_macro('FPC_CPUCROSSCOMPILING')
  2992. else
  2993. def_system_macro('FPC_CPUCROSSCOMPILING');
  2994. if (tf_no_generic_stackcheck in target_info.flags) then
  2995. if def then
  2996. def_system_macro('FPC_NO_GENERIC_STACK_CHECK')
  2997. else
  2998. undef_system_macro('FPC_NO_GENERIC_STACK_CHECK');
  2999. if (tf_section_threadvars in target_info.flags) then
  3000. if def then
  3001. def_system_macro('FPC_SECTION_THREADVARS')
  3002. else
  3003. undef_system_macro('FPC_SECTION_THREADVARS');
  3004. { Code generation flags }
  3005. if (tf_pic_default in target_info.flags) then
  3006. if def then
  3007. include(init_settings.moduleswitches,cs_create_pic)
  3008. else
  3009. exclude(init_settings.moduleswitches,cs_create_pic);
  3010. { Resources support }
  3011. if (tf_has_winlike_resources in target_info.flags) then
  3012. if def then
  3013. def_system_macro('FPC_HAS_WINLIKERESOURCES')
  3014. else
  3015. undef_system_macro('FPC_HAS_WINLIKERESOURCES');
  3016. { Features }
  3017. case target_info.system of
  3018. system_arm_gba:
  3019. target_unsup_features:=[f_dynlibs];
  3020. system_arm_nds:
  3021. target_unsup_features:=[f_threading,f_commandargs,f_fileio,f_textio,f_consoleio,f_dynlibs];
  3022. system_i386_nativent:
  3023. // until these features are implemented, they are disabled in the compiler
  3024. target_unsup_features:=[f_stackcheck];
  3025. system_i8086_msdos:
  3026. target_unsup_features:=[f_threading,f_dynlibs];
  3027. system_i8086_win16:
  3028. target_unsup_features:=[f_threading];
  3029. system_jvm_java32,
  3030. system_jvm_android32:
  3031. target_unsup_features:=[f_heap,f_textio,f_consoleio,f_fileio,
  3032. f_variants,f_objects,f_commandargs,
  3033. f_processes,f_stackcheck,f_dynlibs,f_softfpu,f_objectivec1,f_resources];
  3034. system_arm_palmos,
  3035. system_m68k_palmos:
  3036. target_unsup_features:=[f_threading];
  3037. system_m68k_atari:
  3038. target_unsup_features:=[f_threading];
  3039. { classic amiga has dynamic libraries, but they cannot be integrated in the
  3040. normal dynlibs infrastructure due to architectural differences, so therefore
  3041. lets disable the feature. }
  3042. system_m68k_amiga:
  3043. target_unsup_features:=[f_dynlibs];
  3044. else
  3045. target_unsup_features:=[];
  3046. end;
  3047. if def then
  3048. features:=features-target_unsup_features
  3049. else
  3050. features:=features+target_unsup_features;
  3051. {$if defined(atari) or defined(hasamiga)}
  3052. { enable vlink as default linker on Atari, Amiga, and MorphOS, but not for cross compilers (for now) }
  3053. if (target_info.system in [system_m68k_amiga,system_m68k_atari,
  3054. system_powerpc_amiga,system_powerpc_morphos]) and
  3055. not LinkerSetExplicitly then
  3056. include(init_settings.globalswitches,cs_link_vlink);
  3057. {$endif}
  3058. end;
  3059. procedure TOption.checkoptionscompatibility;
  3060. begin
  3061. {$ifdef i8086}
  3062. if (apptype=app_com) and (init_settings.x86memorymodel<>mm_tiny) then
  3063. begin
  3064. Message(option_com_files_require_tiny_model);
  3065. StopOptions(1);
  3066. end;
  3067. {$endif i8086}
  3068. if (paratargetdbg in [dbg_dwarf2,dbg_dwarf3]) and
  3069. not(target_info.system in (systems_darwin+[system_i8086_msdos,system_i8086_embedded])) then
  3070. begin
  3071. { smartlink creation does not yet work with DWARF
  3072. debug info on most targets, but it works in internal assembler }
  3073. if (cs_create_smart in init_settings.moduleswitches) and
  3074. not (af_outputbinary in target_asm.flags) then
  3075. begin
  3076. Message(option_dwarf_smartlink_creation);
  3077. exclude(init_settings.moduleswitches,cs_create_smart);
  3078. end;
  3079. { smart linking does not yet work with DWARF debug info on most targets }
  3080. if (cs_link_smart in init_settings.globalswitches) then
  3081. begin
  3082. Message(option_dwarf_smart_linking);
  3083. ForceStaticLinking;
  3084. end;
  3085. end;
  3086. { external debug info is only supported for DWARF on darwin }
  3087. if (target_info.system in systems_darwin) and
  3088. (cs_link_separate_dbg_file in init_settings.globalswitches) and
  3089. not(paratargetdbg in [dbg_dwarf2,dbg_dwarf3]) then
  3090. begin
  3091. Message(option_debug_external_unsupported);
  3092. exclude(init_settings.globalswitches,cs_link_separate_dbg_file);
  3093. end;
  3094. { Also create a smartlinked version, on an assembler that
  3095. does not support smartlink sections like nasm?
  3096. This is not compatible with using internal linker. }
  3097. if ((cs_link_smart in init_settings.globalswitches) or
  3098. (cs_create_smart in init_settings.moduleswitches)) and
  3099. (af_needar in target_asm.flags) and
  3100. not (af_smartlink_sections in target_asm.flags) and
  3101. not (cs_link_extern in init_settings.globalswitches) and
  3102. (target_info.link<>ld_none) and
  3103. not (cs_link_nolink in init_settings.globalswitches) then
  3104. begin
  3105. Message(option_smart_link_requires_external_linker);
  3106. include(init_settings.globalswitches,cs_link_extern);
  3107. end;
  3108. end;
  3109. constructor TOption.create;
  3110. begin
  3111. LogoWritten:=false;
  3112. NoPressEnter:=false;
  3113. FirstPass:=false;
  3114. ABISetExplicitly:=false;
  3115. FPUSetExplicitly:=false;
  3116. CPUSetExplicitly:=false;
  3117. OptCPUSetExplicitly:=false;
  3118. FileLevel:=0;
  3119. Quickinfo:='';
  3120. ParaIncludeCfgPath:=TSearchPathList.Create;
  3121. ParaIncludePath:=TSearchPathList.Create;
  3122. ParaObjectPath:=TSearchPathList.Create;
  3123. ParaUnitPath:=TSearchPathList.Create;
  3124. ParaLibraryPath:=TSearchPathList.Create;
  3125. ParaFrameworkPath:=TSearchPathList.Create;
  3126. parapackagepath:=TSearchPathList.Create;
  3127. parapackages:=TFPHashObjectList.Create;
  3128. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  3129. MacVersionSet:=false;
  3130. paratarget:=system_none;
  3131. paratargetasm:=as_none;
  3132. paratargetdbg:=dbg_none;
  3133. LinkTypeSetExplicitly:=false;
  3134. LinkerSetExplicitly:=false;
  3135. end;
  3136. destructor TOption.destroy;
  3137. begin
  3138. ParaIncludeCfgPath.Free;
  3139. ParaIncludePath.Free;
  3140. ParaObjectPath.Free;
  3141. ParaUnitPath.Free;
  3142. ParaLibraryPath.Free;
  3143. ParaFrameworkPath.Free;
  3144. parapackagepath.Free;
  3145. ParaPackages.Free;
  3146. end;
  3147. {****************************************************************************
  3148. Callable Routines
  3149. ****************************************************************************}
  3150. function check_configfile(fn:string; var foundfn:string):boolean;
  3151. function CfgFileExists(const fn:string):boolean;
  3152. begin
  3153. Comment(V_Tried,'Configfile search: '+fn);
  3154. CfgFileExists:=FileExists(fn);
  3155. end;
  3156. var
  3157. {$ifdef Unix}
  3158. hs,
  3159. {$endif Unix}
  3160. configpath : string;
  3161. begin
  3162. foundfn:=fn;
  3163. check_configfile:=true;
  3164. { retrieve configpath }
  3165. configpath:=FixPath(GetEnvironmentVariable('PPC_CONFIG_PATH'),false);
  3166. {$ifdef Unix}
  3167. if configpath='' then
  3168. configpath:=ExpandFileName(FixPath(exepath+'../etc/',false));
  3169. {$endif}
  3170. {
  3171. Order to read configuration file :
  3172. try reading fpc.cfg in :
  3173. 1 - current dir
  3174. 2 - configpath
  3175. 3 - compiler path
  3176. }
  3177. if not FileExists(fn) then
  3178. begin
  3179. {$ifdef Unix}
  3180. hs:=GetEnvironmentVariable('HOME');
  3181. if (hs<>'') and CfgFileExists(FixPath(hs,false)+'.'+fn) then
  3182. foundfn:=FixPath(hs,false)+'.'+fn
  3183. else
  3184. {$endif}
  3185. if CfgFileExists(configpath+fn) then
  3186. foundfn:=configpath+fn
  3187. else
  3188. {$ifdef WINDOWS}
  3189. if (GetEnvironmentVariable('USERPROFILE')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('USERPROFILE'),false)+fn) then
  3190. foundfn:=FixPath(GetEnvironmentVariable('USERPROFILE'),false)+fn
  3191. else
  3192. if (GetEnvironmentVariable('ALLUSERSPROFILE')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('ALLUSERSPROFILE'),false)+fn) then
  3193. foundfn:=FixPath(GetEnvironmentVariable('ALLUSERSPROFILE'),false)+fn
  3194. else
  3195. {$endif WINDOWS}
  3196. {$ifndef Unix}
  3197. if CfgFileExists(exepath+fn) then
  3198. foundfn:=exepath+fn
  3199. else
  3200. {$else}
  3201. if CfgFileExists('/etc/'+fn) then
  3202. foundfn:='/etc/'+fn
  3203. else
  3204. {$endif}
  3205. check_configfile:=false;
  3206. end;
  3207. end;
  3208. procedure read_arguments(cmd:TCmdStr);
  3209. procedure def_cpu_macros;
  3210. var
  3211. abi : tabi;
  3212. fputype : tfputype;
  3213. cputype : tcputype;
  3214. controller: tcontrollertype;
  3215. s: string;
  3216. begin
  3217. for cputype:=low(tcputype) to high(tcputype) do
  3218. undef_system_macro('CPU'+Cputypestr[cputype]);
  3219. def_system_macro('CPU'+Cputypestr[init_settings.cputype]);
  3220. for fputype:=low(tfputype) to high(tfputype) do
  3221. undef_system_macro('FPU'+fputypestr[fputype]);
  3222. def_system_macro('FPU'+fputypestr[init_settings.fputype]);
  3223. {$PUSH}
  3224. {$WARN 6018 OFF} { Unreachable code due to compile time evaluation }
  3225. if ControllerSupport then
  3226. begin
  3227. for controller:=low(tcontrollertype) to high(tcontrollertype) do
  3228. begin
  3229. s:=embedded_controllers[controller].controllertypestr;
  3230. if s<>'' then
  3231. undef_system_macro('FPC_MCU_'+s);
  3232. end;
  3233. s:=embedded_controllers[init_settings.controllertype].controllertypestr;
  3234. if s<>'' then
  3235. def_system_macro('FPC_MCU_'+s);
  3236. end;
  3237. {$POP}
  3238. { define abi }
  3239. for abi:=low(tabi) to high(tabi) do
  3240. undef_system_macro('FPC_ABI_'+abiinfo[abi].name);
  3241. def_system_macro('FPC_ABI_'+abiinfo[target_info.abi].name);
  3242. { Define FPC_ABI_EABI in addition to FPC_ABI_EABIHF on EABI VFP hardfloat
  3243. systems since most code needs to behave the same on both}
  3244. if target_info.abi = abi_eabihf then
  3245. def_system_macro('FPC_ABI_EABI');
  3246. { using a case is pretty useless here (FK) }
  3247. { some stuff for TP compatibility }
  3248. {$ifdef i386}
  3249. def_system_macro('CPU86');
  3250. def_system_macro('CPU87');
  3251. def_system_macro('CPU386');
  3252. {$endif}
  3253. { new processor stuff }
  3254. {$ifdef i386}
  3255. def_system_macro('CPUI386');
  3256. def_system_macro('CPU32');
  3257. def_system_macro('CPUX86');
  3258. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  3259. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  3260. def_system_macro('FPC_HAS_TYPE_SINGLE');
  3261. {$endif}
  3262. {$ifdef m68k}
  3263. def_system_macro('CPU68');
  3264. def_system_macro('CPU68K');
  3265. def_system_macro('CPUM68K');
  3266. def_system_macro('CPU32');
  3267. def_system_macro('FPC_CURRENCY_IS_INT64');
  3268. def_system_macro('FPC_COMP_IS_INT64');
  3269. {$endif}
  3270. {$ifdef powerpc}
  3271. def_system_macro('CPUPOWERPC');
  3272. def_system_macro('CPUPOWERPC32');
  3273. def_system_macro('CPU32');
  3274. def_system_macro('FPC_CURRENCY_IS_INT64');
  3275. def_system_macro('FPC_COMP_IS_INT64');
  3276. {$endif}
  3277. {$ifdef POWERPC64}
  3278. def_system_macro('CPUPOWERPC');
  3279. def_system_macro('CPUPOWERPC64');
  3280. def_system_macro('CPU64');
  3281. def_system_macro('FPC_CURRENCY_IS_INT64');
  3282. def_system_macro('FPC_COMP_IS_INT64');
  3283. {$endif}
  3284. {$ifdef x86_64}
  3285. def_system_macro('CPUX86_64');
  3286. def_system_macro('CPUAMD64');
  3287. def_system_macro('CPU64');
  3288. def_system_macro('CPUX64');
  3289. { not supported for now, afaik (FK)
  3290. def_system_macro('FPC_HAS_TYPE_FLOAT128'); }
  3291. {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
  3292. { normally, win64 doesn't support the legacy fpu }
  3293. if target_info.system=system_x86_64_win64 then
  3294. begin
  3295. def_system_macro('FPC_CURRENCY_IS_INT64');
  3296. def_system_macro('FPC_COMP_IS_INT64');
  3297. end;
  3298. {$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
  3299. {$endif}
  3300. {$ifdef sparc}
  3301. def_system_macro('CPUSPARCGEN');
  3302. def_system_macro('CPUSPARC');
  3303. def_system_macro('CPUSPARC32');
  3304. def_system_macro('CPU32');
  3305. def_system_macro('FPC_CURRENCY_IS_INT64');
  3306. def_system_macro('FPC_COMP_IS_INT64');
  3307. {$endif}
  3308. {$ifdef sparc64}
  3309. def_system_macro('CPUSPARCGEN');
  3310. def_system_macro('CPUSPARC64');
  3311. def_system_macro('CPU64');
  3312. def_system_macro('FPC_CURRENCY_IS_INT64');
  3313. def_system_macro('FPC_COMP_IS_INT64');
  3314. {$endif}
  3315. {$ifdef arm}
  3316. def_system_macro('CPUARM');
  3317. def_system_macro('CPU32');
  3318. def_system_macro('FPC_CURRENCY_IS_INT64');
  3319. def_system_macro('FPC_COMP_IS_INT64');
  3320. {$endif arm}
  3321. {$ifdef avr}
  3322. def_system_macro('CPUAVR');
  3323. def_system_macro('CPU16');
  3324. def_system_macro('FPC_CURRENCY_IS_INT64');
  3325. def_system_macro('FPC_COMP_IS_INT64');
  3326. {$endif avr}
  3327. {$ifdef jvm}
  3328. def_system_macro('CPUJVM');
  3329. def_system_macro('CPU32');
  3330. def_system_macro('FPC_CURRENCY_IS_INT64');
  3331. def_system_macro('FPC_COMP_IS_INT64');
  3332. {$endif jvm}
  3333. {$ifdef mipsel}
  3334. def_system_macro('CPUMIPS');
  3335. def_system_macro('CPUMIPS32');
  3336. def_system_macro('CPUMIPSEL');
  3337. def_system_macro('CPUMIPSEL32');
  3338. def_system_macro('CPU32');
  3339. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  3340. def_system_macro('FPC_HAS_TYPE_SINGLE');
  3341. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  3342. def_system_macro('FPC_CURRENCY_IS_INT64');
  3343. def_system_macro('FPC_COMP_IS_INT64');
  3344. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  3345. { On most systems, locals are accessed relative to base pointer,
  3346. but for MIPS cpu, they are accessed relative to stack pointer.
  3347. This needs adaptation for so low level routines,
  3348. like MethodPointerLocal and related objects unit functions. }
  3349. def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
  3350. {$endif mipsel}
  3351. {$ifdef mipseb}
  3352. def_system_macro('CPUMIPS');
  3353. def_system_macro('CPUMIPS32');
  3354. def_system_macro('CPUMIPSEB');
  3355. def_system_macro('CPUMIPSEB32');
  3356. def_system_macro('CPU32');
  3357. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  3358. def_system_macro('FPC_HAS_TYPE_SINGLE');
  3359. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  3360. def_system_macro('FPC_CURRENCY_IS_INT64');
  3361. def_system_macro('FPC_COMP_IS_INT64');
  3362. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  3363. { See comment above for mipsel }
  3364. def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
  3365. {$endif}
  3366. {$ifdef i8086}
  3367. def_system_macro('CPU86'); { Borland compatibility }
  3368. def_system_macro('CPU87'); { Borland compatibility }
  3369. def_system_macro('CPUI8086');
  3370. def_system_macro('CPU16');
  3371. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  3372. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  3373. def_system_macro('FPC_HAS_TYPE_SINGLE');
  3374. case init_settings.x86memorymodel of
  3375. mm_tiny: def_system_macro('FPC_MM_TINY');
  3376. mm_small: def_system_macro('FPC_MM_SMALL');
  3377. mm_medium: def_system_macro('FPC_MM_MEDIUM');
  3378. mm_compact: def_system_macro('FPC_MM_COMPACT');
  3379. mm_large: def_system_macro('FPC_MM_LARGE');
  3380. mm_huge: def_system_macro('FPC_MM_HUGE');
  3381. end;
  3382. {$endif i8086}
  3383. {$ifdef aarch64}
  3384. def_system_macro('CPUAARCH64');
  3385. def_system_macro('CPU64');
  3386. def_system_macro('FPC_CURRENCY_IS_INT64');
  3387. def_system_macro('FPC_COMP_IS_INT64');
  3388. {$endif aarch64}
  3389. {$if defined(cpu8bitalu)}
  3390. def_system_macro('CPUINT8');
  3391. {$elseif defined(cpu16bitalu)}
  3392. def_system_macro('CPUINT16');
  3393. {$elseif defined(cpu32bitalu)}
  3394. def_system_macro('CPUINT32');
  3395. {$elseif defined(cpu64bitalu)}
  3396. def_system_macro('CPUINT64');
  3397. {$endif defined(cpu64bitalu)}
  3398. {$if defined(avr)}
  3399. def_system_macro('FPC_HAS_INTERNAL_ABS_SHORTINT');
  3400. {$endif}
  3401. {$if defined(i8086) or defined(avr)}
  3402. def_system_macro('FPC_HAS_INTERNAL_ABS_SMALLINT');
  3403. {$endif i8086 or avr}
  3404. { abs(long) is handled internally on all CPUs }
  3405. def_system_macro('FPC_HAS_INTERNAL_ABS_LONG');
  3406. {$if defined(i8086) or defined(i386) or defined(x86_64) or defined(powerpc64) or defined(cpuaarch64)}
  3407. def_system_macro('FPC_HAS_INTERNAL_ABS_INT64');
  3408. {$endif i8086 or i386 or x86_64 or powerpc64 or aarch64}
  3409. def_system_macro('FPC_HAS_MANAGEMENT_OPERATORS');
  3410. def_system_macro('FPC_HAS_UNICODESTRING');
  3411. def_system_macro('FPC_RTTI_PACKSET1');
  3412. def_system_macro('FPC_HAS_CPSTRING');
  3413. {$ifdef x86_64}
  3414. def_system_macro('FPC_HAS_RIP_RELATIVE');
  3415. {$endif x86_64}
  3416. def_system_macro('FPC_HAS_CEXTENDED');
  3417. def_system_macro('FPC_HAS_RESSTRINITS');
  3418. { these cpus have an inline rol/ror implementaion }
  3419. {$ifdef cpurox}
  3420. {$ifdef m68k}
  3421. if CPUM68K_HAS_ROLROR in cpu_capabilities[init_settings.cputype] then
  3422. def_system_macro('FPC_HAS_INTERNAL_ROX');
  3423. {$else}
  3424. def_system_macro('FPC_HAS_INTERNAL_ROX');
  3425. {$endif}
  3426. {$endif}
  3427. {$ifdef powerpc64}
  3428. def_system_macro('FPC_HAS_LWSYNC');
  3429. {$endif}
  3430. { currently, all supported CPUs have an internal sar implementation }
  3431. def_system_macro('FPC_HAS_INTERNAL_SAR');
  3432. {$ifdef SUPPORT_GET_FRAME}
  3433. def_system_macro('INTERNAL_BACKTRACE');
  3434. {$endif SUPPORT_GET_FRAME}
  3435. def_system_macro('STR_CONCAT_PROCS');
  3436. {$warnings off}
  3437. if pocall_default = pocall_register then
  3438. def_system_macro('REGCALL');
  3439. {$warnings on}
  3440. end;
  3441. var
  3442. env: ansistring;
  3443. i : tfeature;
  3444. j : longint;
  3445. abi : tabi;
  3446. {$if defined(cpucapabilities)}
  3447. cpuflag : tcpuflags;
  3448. hs : string;
  3449. {$endif defined(cpucapabilities)}
  3450. begin
  3451. option:=coption.create;
  3452. disable_configfile:=false;
  3453. { Non-core target defines }
  3454. Option.TargetOptions(true);
  3455. { get default messagefile }
  3456. msgfilename:=GetEnvironmentVariable('PPC_ERROR_FILE');
  3457. { default configfile can be specified on the commandline,
  3458. remove it first }
  3459. if (cmd<>'') and (cmd[1]='[') then
  3460. begin
  3461. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  3462. Delete(cmd,1,pos(']',cmd));
  3463. end
  3464. else
  3465. ppccfg:='fpc.cfg';
  3466. { first pass reading of parameters, only -i -v -T etc.}
  3467. option.firstpass:=true;
  3468. if cmd<>'' then
  3469. option.parsecmd(cmd)
  3470. else
  3471. begin
  3472. option.read_parameters;
  3473. { Write only quickinfo }
  3474. if option.quickinfo<>'' then
  3475. option.writequickinfo;
  3476. end;
  3477. option.firstpass:=false;
  3478. { redefine target options so all defines are written even if no -Txxx is passed on the command line }
  3479. Option.TargetOptions(true);
  3480. { target is set here, for wince the default app type is gui }
  3481. if target_info.system in systems_wince then
  3482. SetApptype(app_gui)
  3483. else
  3484. SetApptype(apptype);
  3485. { default defines }
  3486. def_system_macro(target_info.shortname);
  3487. def_system_macro('FPC');
  3488. def_system_macro('VER'+version_nr);
  3489. def_system_macro('VER'+version_nr+'_'+release_nr);
  3490. def_system_macro('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  3491. { Temporary defines, until things settle down }
  3492. def_system_macro('FPC_HAS_OPERATOR_ENUMERATOR');
  3493. def_system_macro('FPC_HAS_CONSTREF');
  3494. def_system_macro('FPC_STATICRIPFIXED');
  3495. def_system_macro('FPC_VARIANTCOPY_FIXED');
  3496. def_system_macro('FPC_DYNARRAYCOPY_FIXED');
  3497. def_system_macro('FPC_HAS_MEMBAR');
  3498. def_system_macro('FPC_SETBASE_USED');
  3499. { don't remove this, it's also for fpdoc necessary (FK) }
  3500. def_system_macro('FPC_HAS_FEATURE_SUPPORT');
  3501. { make cpu makros available when reading the config files the second time }
  3502. def_cpu_macros;
  3503. if tf_cld in target_info.flags then
  3504. if not UpdateTargetSwitchStr('CLD', init_settings.targetswitches, true) then
  3505. InternalError(2013092801);
  3506. if tf_x86_far_procs_push_odd_bp in target_info.flags then
  3507. if not UpdateTargetSwitchStr('FARPROCSPUSHODDBP', init_settings.targetswitches, true) then
  3508. InternalError(2013092801);
  3509. { Set up a default prefix for binutils when cross-compiling }
  3510. if source_info.system<>target_info.system then
  3511. case target_info.system of
  3512. { Use standard Android NDK prefixes }
  3513. system_arm_android:
  3514. utilsprefix:='arm-linux-androideabi-';
  3515. system_i386_android:
  3516. utilsprefix:='i686-linux-android-';
  3517. system_mipsel_android:
  3518. utilsprefix:='mipsel-linux-android-';
  3519. end;
  3520. { Set up default value for the heap }
  3521. if target_info.system in systems_embedded then
  3522. begin
  3523. case target_info.system of
  3524. {$ifdef AVR}
  3525. system_avr_embedded:
  3526. if init_settings.controllertype=ct_avrsim then
  3527. heapsize:=8192
  3528. else
  3529. heapsize:=128;
  3530. {$endif AVR}
  3531. system_arm_embedded:
  3532. heapsize:=256;
  3533. system_mipsel_embedded:
  3534. heapsize:=256;
  3535. else
  3536. heapsize:=256;
  3537. end;
  3538. end;
  3539. { read configuration file }
  3540. if (not disable_configfile) and
  3541. (ppccfg<>'') then
  3542. read_configfile:=check_configfile(ppccfg,ppccfg)
  3543. else
  3544. read_configfile := false;
  3545. { Read commandline and configfile }
  3546. param_file:='';
  3547. { read configfile }
  3548. if read_configfile then
  3549. option.interpret_file(ppccfg);
  3550. { read parameters again to override config file }
  3551. if cmd<>'' then
  3552. option.parsecmd(cmd)
  3553. else
  3554. begin
  3555. { Write help pages if no parameters are passed }
  3556. if (paramcount=0) then
  3557. Option.WriteHelpPages;
  3558. option.read_parameters;
  3559. { Write only quickinfo }
  3560. if option.quickinfo<>'' then
  3561. option.writequickinfo;
  3562. end;
  3563. { check the compatibility of different options and adjust them if necessary
  3564. (and print possible errors)
  3565. }
  3566. option.checkoptionscompatibility;
  3567. { uses the CPUXXX-defines and target_info to determine whether the selected
  3568. target processor, if any, is supported }
  3569. Option.VerifyTargetProcessor;
  3570. { Stop if errors in options }
  3571. if ErrorCount>0 then
  3572. StopOptions(1);
  3573. { endian define }
  3574. case target_info.endian of
  3575. endian_little :
  3576. begin
  3577. def_system_macro('ENDIAN_LITTLE');
  3578. def_system_macro('FPC_LITTLE_ENDIAN');
  3579. end;
  3580. endian_big :
  3581. begin
  3582. def_system_macro('ENDIAN_BIG');
  3583. def_system_macro('FPC_BIG_ENDIAN');
  3584. end;
  3585. end;
  3586. { Write logo }
  3587. if option.ParaLogo then
  3588. option.writelogo;
  3589. { Check file to compile }
  3590. if param_file='' then
  3591. begin
  3592. Message(option_no_source_found);
  3593. StopOptions(1);
  3594. end;
  3595. {$ifndef Unix}
  3596. param_file:=FixFileName(param_file);
  3597. {$endif not unix}
  3598. inputfilepath:=ExtractFilePath(param_file);
  3599. inputfilename:=ExtractFileName(param_file);
  3600. if ExtractFileExt(inputfilename)='' then
  3601. begin
  3602. if FileExists(inputfilepath+ChangeFileExt(inputfilename,sourceext)) then
  3603. inputfilename:=ChangeFileExt(inputfilename,sourceext)
  3604. else if FileExists(inputfilepath+ChangeFileExt(inputfilename,pasext)) then
  3605. inputfilename:=ChangeFileExt(inputfilename,pasext)
  3606. else if ((m_mac in current_settings.modeswitches) or
  3607. (tf_p_ext_support in target_info.flags))
  3608. and FileExists(inputfilepath+ChangeFileExt(inputfilename,pext)) then
  3609. inputfilename:=ChangeFileExt(inputfilename,pext);
  3610. end;
  3611. { Check output dir }
  3612. if (OutputExeDir<>'') and
  3613. not PathExists(OutputExeDir,false) then
  3614. begin
  3615. Message1(general_e_path_does_not_exist,OutputExeDir);
  3616. StopOptions(1);
  3617. end;
  3618. { Add paths specified with parameters to the searchpaths }
  3619. UnitSearchPath.AddList(option.ParaUnitPath,true);
  3620. ObjectSearchPath.AddList(option.ParaObjectPath,true);
  3621. IncludeSearchPath.AddList(option.ParaIncludePath,true);
  3622. LibrarySearchPath.AddList(option.ParaLibraryPath,true);
  3623. FrameworkSearchPath.AddList(option.ParaFrameworkPath,true);
  3624. packagesearchpath.addlist(option.parapackagepath,true);
  3625. for j:=0 to option.parapackages.count-1 do
  3626. add_package(option.parapackages.NameOfIndex(j),true,true);
  3627. { add unit environment and exepath to the unit search path }
  3628. if inputfilepath<>'' then
  3629. Unitsearchpath.AddPath(inputfilepath,true);
  3630. if not disable_configfile then
  3631. begin
  3632. env:=GetEnvironmentVariable(target_info.unit_env);
  3633. if env<>'' then
  3634. UnitSearchPath.AddPath(GetEnvironmentVariable(target_info.unit_env),false);
  3635. end;
  3636. {$ifdef Unix}
  3637. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  3638. if fpcdir='' then
  3639. begin
  3640. if PathExists('/usr/local/lib/fpc/'+version_string,true) then
  3641. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  3642. else
  3643. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  3644. end;
  3645. {$else unix}
  3646. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  3647. if fpcdir='' then
  3648. begin
  3649. fpcdir:=ExePath+'../';
  3650. if not(PathExists(fpcdir+'units',true)) and
  3651. not(PathExists(fpcdir+'rtl',true)) then
  3652. fpcdir:=fpcdir+'../';
  3653. end;
  3654. {$endif unix}
  3655. { first try development RTL, else use the default installation path }
  3656. if not disable_configfile then
  3657. begin
  3658. if PathExists(FpcDir+'rtl',true) then
  3659. if (tf_use_8_3 in Source_Info.Flags) or
  3660. (tf_use_8_3 in Target_Info.Flags) then
  3661. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_os_string,false)
  3662. else
  3663. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_full_string,false)
  3664. else
  3665. if (tf_use_8_3 in Source_Info.Flags) or
  3666. (tf_use_8_3 in Target_Info.Flags) then
  3667. UnitSearchPath.AddPath(FpcDir+'units/'+target_os_string+'/rtl',false)
  3668. else
  3669. UnitSearchPath.AddPath(FpcDir+'units/'+target_full_string+'/rtl',false);
  3670. end;
  3671. { Add exepath if the exe is not in the current dir, because that is always searched already.
  3672. Do not add it when linking on the target because then we can maybe already find
  3673. .o files that are not for the target }
  3674. if (ExePath<>cfileutl.GetCurrentDir) and
  3675. not(cs_link_on_target in init_settings.globalswitches) then
  3676. UnitSearchPath.AddPath(ExePath,false);
  3677. { Add unit dir to the object and library path }
  3678. objectsearchpath.AddList(unitsearchpath,false);
  3679. librarysearchpath.AddList(unitsearchpath,false);
  3680. {$ifdef llvm}
  3681. { force llvm assembler writer }
  3682. option.paratargetasm:=as_llvm;
  3683. {$endif llvm}
  3684. { maybe override assembler }
  3685. if (option.paratargetasm<>as_none) then
  3686. begin
  3687. if not set_target_asm(option.paratargetasm) then
  3688. begin
  3689. Message2(option_incompatible_asm,asminfos[option.paratargetasm]^.idtxt,target_info.name);
  3690. set_target_asm(target_info.assemextern);
  3691. Message1(option_asm_forced,target_asm.idtxt);
  3692. end;
  3693. if (af_no_debug in asminfos[option.paratargetasm]^.flags) and
  3694. (option.paratargetdbg<>dbg_none) then
  3695. begin
  3696. Message1(option_confict_asm_debug,
  3697. asminfos[option.paratargetasm]^.idtxt);
  3698. option.paratargetdbg:=dbg_none;
  3699. exclude(init_settings.moduleswitches,cs_debuginfo);
  3700. end;
  3701. { Some assemblers, like clang, do not support
  3702. stabs debugging format, switch to dwardé in that case }
  3703. if (af_no_stabs in asminfos[option.paratargetasm]^.flags) and
  3704. (option.paratargetdbg=dbg_stabs) then
  3705. begin
  3706. option.paratargetdbg:=dbg_dwarf2;
  3707. end;
  3708. end;
  3709. {TOptionheck a second time as we might have changed assembler just above }
  3710. option.checkoptionscompatibility;
  3711. { maybe override debug info format }
  3712. if (option.paratargetdbg<>dbg_none) then
  3713. if not set_target_dbg(option.paratargetdbg) then
  3714. Message(option_w_unsupported_debug_format);
  3715. { switch assembler if it's binary and we got -a on the cmdline }
  3716. if (cs_asm_leave in init_settings.globalswitches) and
  3717. (af_outputbinary in target_asm.flags) then
  3718. begin
  3719. Message(option_switch_bin_to_src_assembler);
  3720. set_target_asm(target_info.assemextern);
  3721. { At least i8086 needs that for nasm and -CX
  3722. which is incompatible with internal linker }
  3723. option.checkoptionscompatibility;
  3724. end;
  3725. { Force use of external linker if there is no
  3726. internal linker or the linking is skipped }
  3727. if not(cs_link_extern in init_settings.globalswitches) and
  3728. ((target_info.link=ld_none) or
  3729. (cs_link_nolink in init_settings.globalswitches)) then
  3730. begin
  3731. include(init_settings.globalswitches,cs_link_extern);
  3732. end;
  3733. { turn off stripping if compiling with debuginfo or profile }
  3734. if (
  3735. (cs_debuginfo in init_settings.moduleswitches) or
  3736. (cs_profile in init_settings.moduleswitches)
  3737. ) and
  3738. not(cs_link_separate_dbg_file in init_settings.globalswitches) then
  3739. exclude(init_settings.globalswitches,cs_link_strip);
  3740. { set Mac OS X version default macros if not specified explicitly }
  3741. option.MaybeSetDefaultMacVersionMacro;
  3742. { force fpu emulation on arm/wince, arm/gba, arm/embedded and arm/nds
  3743. if fpu type not explicitly set }
  3744. if not(option.FPUSetExplicitly) and
  3745. ((target_info.system in [system_arm_wince,system_arm_gba,
  3746. system_m68k_amiga,system_m68k_atari,
  3747. system_arm_nds,system_arm_embedded])
  3748. {$ifdef arm}
  3749. or (target_info.abi=abi_eabi)
  3750. {$endif arm}
  3751. )
  3752. {$if defined(arm) or defined (m68k)}
  3753. or (init_settings.fputype=fpu_soft)
  3754. {$endif arm or m68k}
  3755. then
  3756. begin
  3757. {$ifdef cpufpemu}
  3758. include(init_settings.moduleswitches,cs_fp_emulation);
  3759. { cs_fp_emulation and fpu_soft are equal on arm and m68k }
  3760. init_settings.fputype:=fpu_soft;
  3761. {$endif cpufpemu}
  3762. end;
  3763. {$ifdef i386}
  3764. case target_info.system of
  3765. system_i386_android:
  3766. begin
  3767. { set default cpu type to PentiumM for Android unless specified otherwise }
  3768. if not option.CPUSetExplicitly then
  3769. init_settings.cputype:=cpu_PentiumM;
  3770. if not option.OptCPUSetExplicitly then
  3771. init_settings.optimizecputype:=cpu_PentiumM;
  3772. { set default fpu type to SSSE3 for Android unless specified otherwise }
  3773. if not option.FPUSetExplicitly then
  3774. init_settings.fputype:=fpu_ssse3;
  3775. end;
  3776. end;
  3777. {$endif i386}
  3778. {$ifdef arm}
  3779. case target_info.system of
  3780. system_arm_darwin:
  3781. begin
  3782. { set default cpu type to ARMv7 for Darwin unless specified otherwise, and fpu
  3783. to VFPv3 (that's what all 32 bit ARM iOS devices use nowadays)
  3784. }
  3785. if not option.CPUSetExplicitly then
  3786. init_settings.cputype:=cpu_armv7;
  3787. if not option.OptCPUSetExplicitly then
  3788. init_settings.optimizecputype:=cpu_armv7;
  3789. if not option.FPUSetExplicitly then
  3790. init_settings.fputype:=fpu_vfpv3;
  3791. end;
  3792. system_arm_android:
  3793. begin
  3794. { set default cpu type to ARMv5T for Android unless specified otherwise }
  3795. if not option.CPUSetExplicitly then
  3796. init_settings.cputype:=cpu_armv5t;
  3797. if not option.OptCPUSetExplicitly then
  3798. init_settings.optimizecputype:=cpu_armv5t;
  3799. end;
  3800. end;
  3801. { ARMHF defaults }
  3802. if (target_info.abi = abi_eabihf) then
  3803. { set default cpu type to ARMv7a for ARMHF unless specified otherwise }
  3804. begin
  3805. {$ifdef CPUARMV6}
  3806. { if the compiler is built for armv6, then
  3807. inherit this setting, e.g. Raspian is armhf but
  3808. only armv6, this makes rebuilds of the compiler
  3809. easier }
  3810. if not option.CPUSetExplicitly then
  3811. init_settings.cputype:=cpu_armv6;
  3812. if not option.OptCPUSetExplicitly then
  3813. init_settings.optimizecputype:=cpu_armv6;
  3814. {$else CPUARMV6}
  3815. if not option.CPUSetExplicitly then
  3816. init_settings.cputype:=cpu_armv7a;
  3817. if not option.OptCPUSetExplicitly then
  3818. init_settings.optimizecputype:=cpu_armv7a;
  3819. {$endif CPUARMV6}
  3820. { Set FPU type }
  3821. if not(option.FPUSetExplicitly) then
  3822. begin
  3823. init_settings.fputype:=fpu_vfpv3_d16
  3824. end
  3825. else
  3826. begin
  3827. if not (init_settings.fputype in [fpu_vfpv2,fpu_vfpv3,fpu_vfpv3_d16,fpu_vfpv4]) then
  3828. begin
  3829. Message(option_illegal_fpu_eabihf);
  3830. StopOptions(1);
  3831. end;
  3832. end;
  3833. end;
  3834. if (init_settings.instructionset=is_thumb) and not(CPUARM_HAS_THUMB2 in cpu_capabilities[init_settings.cputype]) then
  3835. begin
  3836. def_system_macro('CPUTHUMB');
  3837. if not option.FPUSetExplicitly then
  3838. init_settings.fputype:=fpu_soft;
  3839. {$if defined(FPC_ARMEL) or defined(FPC_ARMHF)}
  3840. 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';
  3841. {$else FPC_ARMAL or FPC_ARMHF}
  3842. if target_info.endian=endian_little then
  3843. 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';
  3844. {$endif FPC_ARMAL or FPC_ARMHF}
  3845. end;
  3846. if (init_settings.instructionset=is_thumb) and (CPUARM_HAS_THUMB2 in cpu_capabilities[init_settings.cputype]) then
  3847. def_system_macro('CPUTHUMB2');
  3848. {$endif arm}
  3849. {$ifdef jvm}
  3850. { set default CPU type to Dalvik when targeting Android }
  3851. if target_info.system=system_jvm_android32 then
  3852. begin
  3853. if not option.CPUSetExplicitly then
  3854. init_settings.cputype:=cpu_dalvik;
  3855. end;
  3856. {$endif jvm}
  3857. {$ifdef llvm}
  3858. { standard extension for llvm bitcode files }
  3859. target_info.asmext:='.ll';
  3860. { don't generate dwarf cfi, llvm will do that }
  3861. exclude(target_info.flags,tf_needs_dwarf_cfi);
  3862. {$endif llvm}
  3863. {$ifdef mipsel}
  3864. case target_info.system of
  3865. system_mipsel_android:
  3866. begin
  3867. { set default cpu type to MIPS32 rev. 1 and hard float for MIPS-Android unless specified otherwise }
  3868. if not option.CPUSetExplicitly then
  3869. init_settings.cputype:=cpu_mips32;
  3870. if not option.OptCPUSetExplicitly then
  3871. init_settings.optimizecputype:=cpu_mips32;
  3872. if not option.FPUSetExplicitly then
  3873. init_settings.fputype:=fpu_mips2;
  3874. end;
  3875. system_mipsel_embedded:
  3876. begin
  3877. { set default cpu type to PIC32MX and softfloat for MIPSEL-EMBEDDED target unless specified otherwise }
  3878. if not option.CPUSetExplicitly then
  3879. init_settings.cputype:=cpu_pic32mx;
  3880. if not option.OptCPUSetExplicitly then
  3881. init_settings.optimizecputype:=cpu_pic32mx;
  3882. if not option.FPUSetExplicitly then
  3883. init_settings.fputype:=fpu_soft;
  3884. end;
  3885. end;
  3886. {$endif mipsel}
  3887. {$ifdef m68k}
  3888. if init_settings.cputype in cpu_coldfire then
  3889. def_system_macro('CPUCOLDFIRE');
  3890. case target_info.system of
  3891. system_m68k_linux,
  3892. system_m68k_netbsd:
  3893. begin
  3894. if not (option.FPUSetExplicitly) and
  3895. not (init_settings.cputype in cpu_coldfire) then
  3896. begin
  3897. { enable HW FPU for UNIX by default, but only for
  3898. original 68k, not Coldfire }
  3899. exclude(init_settings.moduleswitches,cs_fp_emulation);
  3900. init_settings.fputype:=fpu_68881;
  3901. end;
  3902. end;
  3903. system_m68k_palmos:
  3904. begin
  3905. if not option.CPUSetExplicitly then
  3906. init_settings.cputype:=cpu_mc68000;
  3907. if not (option.FPUSetExplicitly) then
  3908. begin
  3909. { No FPU for PalmOS by default }
  3910. exclude(init_settings.moduleswitches,cs_fp_emulation);
  3911. init_settings.fputype:=fpu_none;
  3912. end;
  3913. end;
  3914. end;
  3915. {$endif m68k}
  3916. { now we can define cpu and fpu type }
  3917. def_cpu_macros;
  3918. { Use init_settings cpu type for asm cpu type,
  3919. if asmcputype is cpu_none,
  3920. at least as long as there is no explicit
  3921. option to set it on command line PM }
  3922. if init_settings.asmcputype = cpu_none then
  3923. init_settings.asmcputype:=init_settings.cputype;
  3924. {$ifdef llvm}
  3925. def_system_macro('CPULLVM');
  3926. {$endif llvm}
  3927. {$if defined(cpucapabilities)}
  3928. for cpuflag:=low(cpuflag) to high(cpuflag) do
  3929. begin
  3930. str(cpuflag,hs);
  3931. if cpuflag in cpu_capabilities[init_settings.cputype] then
  3932. def_system_macro(hs)
  3933. else
  3934. undef_system_macro(hs);
  3935. end;
  3936. {$endif defined(cpucapabilities)}
  3937. if init_settings.fputype<>fpu_none then
  3938. begin
  3939. {$if defined(i386) or defined(i8086)}
  3940. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  3941. {$endif}
  3942. def_system_macro('FPC_HAS_TYPE_SINGLE');
  3943. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  3944. {$if not defined(i386) and not defined(x86_64) and not defined(i8086) and not defined(aarch64)}
  3945. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  3946. {$endif}
  3947. {$if defined(m68k)}
  3948. def_system_macro('FPC_INCLUDE_SOFTWARE_LONGWORD_TO_DOUBLE');
  3949. {$endif}
  3950. {$ifdef x86_64}
  3951. {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
  3952. { normally, win64 doesn't support the legacy fpu }
  3953. if target_info.system=system_x86_64_win64 then
  3954. undef_system_macro('FPC_HAS_TYPE_EXTENDED')
  3955. else
  3956. {$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
  3957. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  3958. {$endif}
  3959. end;
  3960. { Enable now for testing }
  3961. {$ifndef DISABLE_TLS_DIRECTORY}
  3962. if target_info.system in systems_windows then
  3963. def_system_macro('FPC_USE_TLS_DIRECTORY');
  3964. {$endif not DISABLE_TLS_DIRECTORY}
  3965. {$ifndef DISABLE_WIN64_SEH}
  3966. if target_info.system=system_x86_64_win64 then
  3967. def_system_macro('FPC_USE_WIN64_SEH');
  3968. {$endif DISABLE_WIN64_SEH}
  3969. {$ifdef TEST_WIN32_SEH}
  3970. if target_info.system=system_i386_win32 then
  3971. def_system_macro('FPC_USE_WIN32_SEH');
  3972. {$endif TEST_WIN32_SEH}
  3973. {$ifdef ARM}
  3974. { define FPC_DOUBLE_HILO_SWAPPED if needed to properly handle doubles in RTL }
  3975. if (init_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
  3976. not(cs_fp_emulation in init_settings.moduleswitches) then
  3977. def_system_macro('FPC_DOUBLE_HILO_SWAPPED');
  3978. {$endif ARM}
  3979. { inline bsf/bsr implementation }
  3980. {$if not defined(llvm) and (defined(i386) or defined(x86_64) or defined(aarch64) or defined(powerpc) or defined(powerpc64))}
  3981. def_system_macro('FPC_HAS_INTERNAL_BSF');
  3982. def_system_macro('FPC_HAS_INTERNAL_BSR');
  3983. {$endif}
  3984. { hardware FMA support }
  3985. {$if defined(i386) or defined(x86_64)}
  3986. if (cpu_capabilities[current_settings.cputype]*[CPUX86_HAS_FMA,CPUX86_HAS_FMA4])<>[] then
  3987. begin
  3988. def_system_macro('FPC_HAS_FAST_FMA_SINGLE');
  3989. def_system_macro('FPC_HAS_FAST_FMA_DOUBLE');
  3990. end;
  3991. {$endif defined(i386) or defined(x86_64)}
  3992. {$if defined(arm)}
  3993. { it is determined during system unit compilation if clz is used for bsf or not,
  3994. this is not perfect but the current implementation bsf/bsr does not allow another
  3995. solution }
  3996. if (CPUARM_HAS_CLZ in cpu_capabilities[init_settings.cputype]) and
  3997. ((init_settings.instructionset=is_arm) or
  3998. (CPUARM_HAS_THUMB2 in cpu_capabilities[init_settings.cputype])) then
  3999. begin
  4000. def_system_macro('FPC_HAS_INTERNAL_BSR');
  4001. if CPUARM_HAS_RBIT in cpu_capabilities[init_settings.cputype] then
  4002. def_system_macro('FPC_HAS_INTERNAL_BSF');
  4003. end;
  4004. {$endif}
  4005. {$if defined(powerpc64)}
  4006. { on sysv targets, default to elfv2 for little endian and to elfv1 for
  4007. big endian (unless specified otherwise). As the gcc man page says:
  4008. "Overriding the default ABI requires special system support and is
  4009. likely to fail in spectacular ways" }
  4010. if not option.ABISetExplicitly then
  4011. begin
  4012. if (target_info.abi=abi_powerpc_sysv) and
  4013. (target_info.endian=endian_little) then
  4014. target_info.abi:=abi_powerpc_elfv2
  4015. else
  4016. if (target_info.abi=abi_powerpc_elfv2) and
  4017. (target_info.endian=endian_big) then
  4018. target_info.abi:=abi_powerpc_sysv
  4019. end;
  4020. {$endif}
  4021. {$if defined(powerpc) or defined(powerpc64)}
  4022. { define _CALL_ELF symbol like gcc }
  4023. case target_info.abi of
  4024. abi_powerpc_sysv:
  4025. set_system_compvar('_CALL_ELF','1');
  4026. abi_powerpc_elfv2:
  4027. set_system_compvar('_CALL_ELF','2');
  4028. end;
  4029. {$endif}
  4030. { Section smartlinking conflicts with import sections on Windows }
  4031. if GenerateImportSection and
  4032. (target_info.system in [system_i386_win32,system_x86_64_win64]) then
  4033. exclude(target_info.flags,tf_smartlink_sections);
  4034. if not option.LinkTypeSetExplicitly then
  4035. set_default_link_type;
  4036. { Default alignment settings,
  4037. 1. load the defaults for the target
  4038. 2. override with generic optimizer setting (little size)
  4039. 3. override with the user specified -Oa }
  4040. UpdateAlignment(init_settings.alignment,target_info.alignment);
  4041. if (cs_opt_size in init_settings.optimizerswitches) then
  4042. begin
  4043. init_settings.alignment.procalign:=1;
  4044. init_settings.alignment.jumpalign:=1;
  4045. init_settings.alignment.loopalign:=1;
  4046. {$ifdef x86}
  4047. { constalignmax=1 keeps the executable and thus the memory foot print small but
  4048. all processors except x86 are really hurt by this or might even crash }
  4049. init_settings.alignment.constalignmax:=1;
  4050. {$endif x86}
  4051. end;
  4052. UpdateAlignment(init_settings.alignment,option.paraalignment);
  4053. set_system_macro('FPC_VERSION',version_nr);
  4054. set_system_macro('FPC_RELEASE',release_nr);
  4055. set_system_macro('FPC_PATCH',patch_nr);
  4056. set_system_macro('FPC_FULLVERSION',Format('%d%.02d%.02d',[StrToInt(version_nr),StrToInt(release_nr),StrToInt(patch_nr)]));
  4057. if target_info.system in systems_indirect_entry_information then
  4058. def_system_macro('FPC_HAS_INDIRECT_ENTRY_INFORMATION');
  4059. if not (tf_winlikewidestring in target_info.flags) then
  4060. def_system_macro('FPC_WIDESTRING_EQUAL_UNICODESTRING');
  4061. if tf_supports_packages in target_info.flags then
  4062. def_system_macro('FPC_HAS_DYNAMIC_PACKAGES');
  4063. if target_info.system in systems_indirect_var_imports then
  4064. def_system_macro('FPC_HAS_INDIRECT_VAR_ACCESS');
  4065. if cs_compilesystem in init_settings.moduleswitches then
  4066. for i:=low(tfeature) to high(tfeature) do
  4067. if i in features then
  4068. def_system_macro('FPC_HAS_FEATURE_'+featurestr[i]);
  4069. {$push}
  4070. {$warn 6018 off} { Unreachable code due to compile time evaluation }
  4071. if ControllerSupport and (target_info.system in systems_embedded) and
  4072. (init_settings.controllertype<>ct_none) then
  4073. begin
  4074. with embedded_controllers[init_settings.controllertype] do
  4075. begin
  4076. set_system_macro('FPC_FLASHBASE',tostr(flashbase));
  4077. set_system_macro('FPC_FLASHSIZE',tostr(flashsize));
  4078. set_system_macro('FPC_SRAMBASE',tostr(srambase));
  4079. set_system_macro('FPC_SRAMSIZE',tostr(sramsize));
  4080. set_system_macro('FPC_EEPROMBASE',tostr(eeprombase));
  4081. set_system_macro('FPC_EEPROMSIZE',tostr(eepromsize));
  4082. set_system_macro('FPC_BOOTBASE',tostr(bootbase));
  4083. set_system_macro('FPC_BOOTSIZE',tostr(bootsize));
  4084. end;
  4085. end;
  4086. {$pop}
  4087. option.free;
  4088. Option:=nil;
  4089. clearstack_pocalls := [pocall_cdecl,pocall_cppdecl,pocall_syscall,pocall_mwpascal,pocall_sysv_abi_cdecl,pocall_ms_abi_cdecl];
  4090. cdecl_pocalls := [pocall_cdecl, pocall_cppdecl, pocall_mwpascal, pocall_sysv_abi_cdecl, pocall_ms_abi_cdecl];
  4091. if (tf_safecall_clearstack in target_info.flags) then
  4092. begin
  4093. include (cdecl_pocalls, pocall_safecall);
  4094. include (clearstack_pocalls, pocall_safecall)
  4095. end;
  4096. end;
  4097. initialization
  4098. coption:=toption;
  4099. finalization
  4100. if assigned(option) then
  4101. option.free;
  4102. end.