meson.build 165 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619
  1. project('qemu', ['c'], meson_version: '>=1.1.0',
  2. default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto',
  3. 'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true'],
  4. version: files('VERSION'))
  5. add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true)
  6. add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow'])
  7. add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
  8. meson.add_postconf_script(find_program('scripts/symlink-install-tree.py'))
  9. ####################
  10. # Global variables #
  11. ####################
  12. not_found = dependency('', required: false)
  13. keyval = import('keyval')
  14. ss = import('sourceset')
  15. fs = import('fs')
  16. host_os = host_machine.system()
  17. config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
  18. # Temporary directory used for files created while
  19. # configure runs. Since it is in the build directory
  20. # we can safely blow away any previous version of it
  21. # (and we need not jump through hoops to try to delete
  22. # it when configure exits.)
  23. tmpdir = meson.current_build_dir() / 'meson-private/temp'
  24. if get_option('qemu_suffix').startswith('/')
  25. error('qemu_suffix cannot start with a /')
  26. endif
  27. qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
  28. qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
  29. qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
  30. qemu_moddir = get_option('libdir') / get_option('qemu_suffix')
  31. qemu_desktopdir = get_option('datadir') / 'applications'
  32. qemu_icondir = get_option('datadir') / 'icons'
  33. genh = []
  34. qapi_trace_events = []
  35. bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
  36. supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
  37. supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
  38. 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64']
  39. cpu = host_machine.cpu_family()
  40. target_dirs = config_host['TARGET_DIRS'].split()
  41. ############
  42. # Programs #
  43. ############
  44. sh = find_program('sh')
  45. python = import('python').find_installation()
  46. cc = meson.get_compiler('c')
  47. all_languages = ['c']
  48. if host_os == 'windows' and add_languages('cpp', required: false, native: false)
  49. all_languages += ['cpp']
  50. cxx = meson.get_compiler('cpp')
  51. endif
  52. if host_os == 'darwin' and \
  53. add_languages('objc', required: true, native: false)
  54. all_languages += ['objc']
  55. objc = meson.get_compiler('objc')
  56. endif
  57. dtrace = not_found
  58. stap = not_found
  59. if 'dtrace' in get_option('trace_backends')
  60. dtrace = find_program('dtrace', required: true)
  61. stap = find_program('stap', required: false)
  62. if stap.found()
  63. # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
  64. # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
  65. # instead. QEMU --enable-modules depends on this because the SystemTap
  66. # semaphores are linked into the main binary and not the module's shared
  67. # object.
  68. add_global_arguments('-DSTAP_SDT_V2',
  69. native: false, language: all_languages)
  70. endif
  71. endif
  72. if get_option('iasl') == ''
  73. iasl = find_program('iasl', required: false)
  74. else
  75. iasl = find_program(get_option('iasl'), required: true)
  76. endif
  77. edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu', 'riscv64-softmmu', 'loongarch64-softmmu' ]
  78. unpack_edk2_blobs = false
  79. foreach target : edk2_targets
  80. if target in target_dirs
  81. bzip2 = find_program('bzip2', required: get_option('install_blobs'))
  82. unpack_edk2_blobs = bzip2.found()
  83. break
  84. endif
  85. endforeach
  86. #####################
  87. # Option validation #
  88. #####################
  89. # Fuzzing
  90. if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
  91. not cc.links('''
  92. #include <stdint.h>
  93. #include <sys/types.h>
  94. int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
  95. int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
  96. ''',
  97. args: ['-Werror', '-fsanitize=fuzzer'])
  98. error('Your compiler does not support -fsanitize=fuzzer')
  99. endif
  100. # Tracing backends
  101. if 'ftrace' in get_option('trace_backends') and host_os != 'linux'
  102. error('ftrace is supported only on Linux')
  103. endif
  104. if 'syslog' in get_option('trace_backends') and not cc.compiles('''
  105. #include <syslog.h>
  106. int main(void) {
  107. openlog("qemu", LOG_PID, LOG_DAEMON);
  108. syslog(LOG_INFO, "configure");
  109. return 0;
  110. }''')
  111. error('syslog is not supported on this system')
  112. endif
  113. # Miscellaneous Linux-only features
  114. get_option('mpath') \
  115. .require(host_os == 'linux', error_message: 'Multipath is supported only on Linux')
  116. multiprocess_allowed = get_option('multiprocess') \
  117. .require(host_os == 'linux', error_message: 'Multiprocess QEMU is supported only on Linux') \
  118. .allowed()
  119. vfio_user_server_allowed = get_option('vfio_user_server') \
  120. .require(host_os == 'linux', error_message: 'vfio-user server is supported only on Linux') \
  121. .allowed()
  122. have_tpm = get_option('tpm') \
  123. .require(host_os != 'windows', error_message: 'TPM emulation only available on POSIX systems') \
  124. .allowed()
  125. # vhost
  126. have_vhost_user = get_option('vhost_user') \
  127. .disable_auto_if(host_os != 'linux') \
  128. .require(host_os != 'windows',
  129. error_message: 'vhost-user is not available on Windows').allowed()
  130. have_vhost_vdpa = get_option('vhost_vdpa') \
  131. .require(host_os == 'linux',
  132. error_message: 'vhost-vdpa is only available on Linux').allowed()
  133. have_vhost_kernel = get_option('vhost_kernel') \
  134. .require(host_os == 'linux',
  135. error_message: 'vhost-kernel is only available on Linux').allowed()
  136. have_vhost_user_crypto = get_option('vhost_crypto') \
  137. .require(have_vhost_user,
  138. error_message: 'vhost-crypto requires vhost-user to be enabled').allowed()
  139. have_vhost = have_vhost_user or have_vhost_vdpa or have_vhost_kernel
  140. have_vhost_net_user = have_vhost_user and get_option('vhost_net').allowed()
  141. have_vhost_net_vdpa = have_vhost_vdpa and get_option('vhost_net').allowed()
  142. have_vhost_net_kernel = have_vhost_kernel and get_option('vhost_net').allowed()
  143. have_vhost_net = have_vhost_net_kernel or have_vhost_net_user or have_vhost_net_vdpa
  144. # type of binaries to build
  145. have_linux_user = false
  146. have_bsd_user = false
  147. have_system = false
  148. foreach target : target_dirs
  149. have_linux_user = have_linux_user or target.endswith('linux-user')
  150. have_bsd_user = have_bsd_user or target.endswith('bsd-user')
  151. have_system = have_system or target.endswith('-softmmu')
  152. endforeach
  153. have_user = have_linux_user or have_bsd_user
  154. have_tools = get_option('tools') \
  155. .disable_auto_if(not have_system) \
  156. .allowed()
  157. have_ga = get_option('guest_agent') \
  158. .disable_auto_if(not have_system and not have_tools) \
  159. .require(host_os in ['sunos', 'linux', 'windows', 'freebsd', 'netbsd', 'openbsd'],
  160. error_message: 'unsupported OS for QEMU guest agent') \
  161. .allowed()
  162. have_block = have_system or have_tools
  163. enable_modules = get_option('modules') \
  164. .require(host_os != 'windows',
  165. error_message: 'Modules are not available for Windows') \
  166. .require(not get_option('prefer_static'),
  167. error_message: 'Modules are incompatible with static linking') \
  168. .allowed()
  169. #######################################
  170. # Variables for host and accelerators #
  171. #######################################
  172. if cpu not in supported_cpus
  173. host_arch = 'unknown'
  174. elif cpu == 'x86'
  175. host_arch = 'i386'
  176. elif cpu == 'mips64'
  177. host_arch = 'mips'
  178. elif cpu in ['riscv32', 'riscv64']
  179. host_arch = 'riscv'
  180. else
  181. host_arch = cpu
  182. endif
  183. if cpu in ['x86', 'x86_64']
  184. kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
  185. elif cpu == 'aarch64'
  186. kvm_targets = ['aarch64-softmmu']
  187. elif cpu == 's390x'
  188. kvm_targets = ['s390x-softmmu']
  189. elif cpu in ['ppc', 'ppc64']
  190. kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
  191. elif cpu in ['mips', 'mips64']
  192. kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
  193. elif cpu in ['riscv32']
  194. kvm_targets = ['riscv32-softmmu']
  195. elif cpu in ['riscv64']
  196. kvm_targets = ['riscv64-softmmu']
  197. elif cpu in ['loongarch64']
  198. kvm_targets = ['loongarch64-softmmu']
  199. else
  200. kvm_targets = []
  201. endif
  202. accelerator_targets = { 'CONFIG_KVM': kvm_targets }
  203. if cpu in ['x86', 'x86_64']
  204. xen_targets = ['i386-softmmu', 'x86_64-softmmu']
  205. elif cpu in ['arm', 'aarch64']
  206. # i386 emulator provides xenpv machine type for multiple architectures
  207. xen_targets = ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu']
  208. else
  209. xen_targets = []
  210. endif
  211. accelerator_targets += { 'CONFIG_XEN': xen_targets }
  212. if cpu in ['aarch64']
  213. accelerator_targets += {
  214. 'CONFIG_HVF': ['aarch64-softmmu']
  215. }
  216. endif
  217. if cpu in ['x86', 'x86_64']
  218. accelerator_targets += {
  219. 'CONFIG_HVF': ['x86_64-softmmu'],
  220. 'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'],
  221. 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
  222. }
  223. endif
  224. modular_tcg = []
  225. # Darwin does not support references to thread-local variables in modules
  226. if host_os != 'darwin'
  227. modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
  228. endif
  229. ##################
  230. # Compiler flags #
  231. ##################
  232. foreach lang : all_languages
  233. compiler = meson.get_compiler(lang)
  234. if compiler.get_id() == 'gcc' and compiler.version().version_compare('>=7.4')
  235. # ok
  236. elif compiler.get_id() == 'clang' and compiler.compiles('''
  237. #ifdef __apple_build_version__
  238. # if __clang_major__ < 12 || (__clang_major__ == 12 && __clang_minor__ < 0)
  239. # error You need at least XCode Clang v12.0 to compile QEMU
  240. # endif
  241. #else
  242. # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
  243. # error You need at least Clang v10.0 to compile QEMU
  244. # endif
  245. #endif''')
  246. # ok
  247. else
  248. error('You either need GCC v7.4 or Clang v10.0 (or XCode Clang v12.0) to compile QEMU')
  249. endif
  250. endforeach
  251. # default flags for all hosts
  252. # We use -fwrapv to tell the compiler that we require a C dialect where
  253. # left shift of signed integers is well defined and has the expected
  254. # 2s-complement style results. (Both clang and gcc agree that it
  255. # provides these semantics.)
  256. qemu_common_flags = [
  257. '-D_GNU_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE',
  258. '-fno-strict-aliasing', '-fno-common', '-fwrapv' ]
  259. qemu_cflags = []
  260. qemu_ldflags = []
  261. if host_os == 'darwin'
  262. # Disable attempts to use ObjectiveC features in os/object.h since they
  263. # won't work when we're compiling with gcc as a C compiler.
  264. if compiler.get_id() == 'gcc'
  265. qemu_common_flags += '-DOS_OBJECT_USE_OBJC=0'
  266. endif
  267. elif host_os == 'sunos'
  268. # needed for CMSG_ macros in sys/socket.h
  269. qemu_common_flags += '-D_XOPEN_SOURCE=600'
  270. # needed for TIOCWIN* defines in termios.h
  271. qemu_common_flags += '-D__EXTENSIONS__'
  272. elif host_os == 'haiku'
  273. qemu_common_flags += ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE', '-fPIC']
  274. elif host_os == 'windows'
  275. if not compiler.compiles('struct x { int y; } __attribute__((gcc_struct));',
  276. args: '-Werror')
  277. error('Your compiler does not support __attribute__((gcc_struct)) - please use GCC instead of Clang')
  278. endif
  279. endif
  280. # __sync_fetch_and_and requires at least -march=i486. Many toolchains
  281. # use i686 as default anyway, but for those that don't, an explicit
  282. # specification is necessary
  283. if host_arch == 'i386' and not cc.links('''
  284. static int sfaa(int *ptr)
  285. {
  286. return __sync_fetch_and_and(ptr, 0);
  287. }
  288. int main(void)
  289. {
  290. int val = 42;
  291. val = __sync_val_compare_and_swap(&val, 0, 1);
  292. sfaa(&val);
  293. return val;
  294. }''')
  295. qemu_common_flags = ['-march=i486'] + qemu_common_flags
  296. endif
  297. # Pick x86-64 baseline version
  298. if host_arch in ['i386', 'x86_64']
  299. if get_option('x86_version') == '0' and host_arch == 'x86_64'
  300. error('x86_64-v1 required for x86-64 hosts')
  301. endif
  302. # add flags for individual instruction set extensions
  303. if get_option('x86_version') >= '1'
  304. if host_arch == 'i386'
  305. qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags
  306. else
  307. # present on basically all processors but technically not part of
  308. # x86-64-v1, so only include -mneeded for x86-64 version 2 and above
  309. qemu_common_flags = ['-mcx16'] + qemu_common_flags
  310. endif
  311. endif
  312. if get_option('x86_version') >= '2'
  313. qemu_common_flags = ['-mpopcnt'] + qemu_common_flags
  314. qemu_common_flags = cc.get_supported_arguments('-mneeded') + qemu_common_flags
  315. endif
  316. if get_option('x86_version') >= '3'
  317. qemu_common_flags = ['-mmovbe', '-mabm', '-mbmi1', '-mbmi2', '-mfma', '-mf16c'] + qemu_common_flags
  318. endif
  319. # add required vector instruction set (each level implies those below)
  320. if get_option('x86_version') == '1'
  321. qemu_common_flags = ['-msse2'] + qemu_common_flags
  322. elif get_option('x86_version') == '2'
  323. qemu_common_flags = ['-msse4.2'] + qemu_common_flags
  324. elif get_option('x86_version') == '3'
  325. qemu_common_flags = ['-mavx2'] + qemu_common_flags
  326. elif get_option('x86_version') == '4'
  327. qemu_common_flags = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl'] + qemu_common_flags
  328. endif
  329. endif
  330. if get_option('prefer_static')
  331. qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
  332. endif
  333. # Meson currently only handles pie as a boolean for now, so if the user
  334. # has explicitly disabled PIE we need to extend our cflags.
  335. #
  336. # -no-pie is supposedly a linker flag that has no effect on the compiler
  337. # command line, but some distros, that didn't quite know what they were
  338. # doing, made local changes to gcc's specs file that turned it into
  339. # a compiler command-line flag.
  340. #
  341. # What about linker flags? For a static build, no PIE is implied by -static
  342. # which we added above (and if it's not because of the same specs patching,
  343. # there's nothing we can do: compilation will fail, report a bug to your
  344. # distro and do not use --disable-pie in the meanwhile). For dynamic linking,
  345. # instead, we can't add -no-pie because it overrides -shared: the linker then
  346. # tries to build an executable instead of a shared library and fails. So
  347. # don't add -no-pie anywhere and cross fingers. :(
  348. if not get_option('b_pie')
  349. qemu_common_flags += cc.get_supported_arguments('-fno-pie', '-no-pie')
  350. endif
  351. if not get_option('stack_protector').disabled()
  352. stack_protector_probe = '''
  353. int main(int argc, char *argv[])
  354. {
  355. char arr[64], *p = arr, *c = argv[argc - 1];
  356. while (*c) {
  357. *p++ = *c++;
  358. }
  359. return 0;
  360. }'''
  361. have_stack_protector = false
  362. foreach arg : ['-fstack-protector-strong', '-fstack-protector-all']
  363. # We need to check both a compile and a link, since some compiler
  364. # setups fail only on a .c->.o compile and some only at link time
  365. if cc.compiles(stack_protector_probe, args: ['-Werror', arg]) and \
  366. cc.links(stack_protector_probe, args: ['-Werror', arg])
  367. have_stack_protector = true
  368. qemu_cflags += arg
  369. qemu_ldflags += arg
  370. break
  371. endif
  372. endforeach
  373. get_option('stack_protector') \
  374. .require(have_stack_protector, error_message: 'Stack protector not supported')
  375. endif
  376. coroutine_backend = get_option('coroutine_backend')
  377. ucontext_probe = '''
  378. #include <ucontext.h>
  379. #ifdef __stub_makecontext
  380. #error Ignoring glibc stub makecontext which will always fail
  381. #endif
  382. int main(void) { makecontext(0, 0, 0); return 0; }'''
  383. # On Windows the only valid backend is the Windows specific one.
  384. # For POSIX prefer ucontext, but it's not always possible. The fallback
  385. # is sigcontext.
  386. supported_backends = []
  387. if host_os == 'windows'
  388. supported_backends += ['windows']
  389. else
  390. if host_os != 'darwin' and cc.links(ucontext_probe)
  391. supported_backends += ['ucontext']
  392. endif
  393. supported_backends += ['sigaltstack']
  394. endif
  395. if coroutine_backend == 'auto'
  396. coroutine_backend = supported_backends[0]
  397. elif coroutine_backend not in supported_backends
  398. error('"@0@" backend requested but not available. Available backends: @1@' \
  399. .format(coroutine_backend, ', '.join(supported_backends)))
  400. endif
  401. # Compiles if SafeStack *not* enabled
  402. safe_stack_probe = '''
  403. int main(void)
  404. {
  405. #if defined(__has_feature)
  406. #if __has_feature(safe_stack)
  407. #error SafeStack Enabled
  408. #endif
  409. #endif
  410. return 0;
  411. }'''
  412. if get_option('safe_stack') != not cc.compiles(safe_stack_probe)
  413. safe_stack_arg = get_option('safe_stack') ? '-fsanitize=safe-stack' : '-fno-sanitize=safe-stack'
  414. if get_option('safe_stack') != not cc.compiles(safe_stack_probe, args: safe_stack_arg)
  415. error(get_option('safe_stack') \
  416. ? 'SafeStack not supported by your compiler' \
  417. : 'Cannot disable SafeStack')
  418. endif
  419. qemu_cflags += safe_stack_arg
  420. qemu_ldflags += safe_stack_arg
  421. endif
  422. if get_option('safe_stack') and coroutine_backend != 'ucontext'
  423. error('SafeStack is only supported with the ucontext coroutine backend')
  424. endif
  425. if get_option('asan')
  426. if cc.has_argument('-fsanitize=address')
  427. qemu_cflags = ['-fsanitize=address'] + qemu_cflags
  428. qemu_ldflags = ['-fsanitize=address'] + qemu_ldflags
  429. else
  430. error('Your compiler does not support -fsanitize=address')
  431. endif
  432. endif
  433. if get_option('ubsan')
  434. # Detect static linking issue with ubsan:
  435. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
  436. if cc.links('int main(int argc, char **argv) { return argc + 1; }',
  437. args: [qemu_ldflags, '-fsanitize=undefined'])
  438. qemu_cflags += ['-fsanitize=undefined']
  439. qemu_ldflags += ['-fsanitize=undefined']
  440. # Suppress undefined behaviour from function call to mismatched type.
  441. # In addition, tcg prologue does not emit function type prefix
  442. # required by function call sanitizer.
  443. if cc.has_argument('-fno-sanitize=function')
  444. qemu_cflags += ['-fno-sanitize=function']
  445. endif
  446. else
  447. error('Your compiler does not support -fsanitize=undefined')
  448. endif
  449. endif
  450. # Thread sanitizer is, for now, much noisier than the other sanitizers;
  451. # keep it separate until that is not the case.
  452. if get_option('tsan')
  453. if get_option('asan') or get_option('ubsan')
  454. error('TSAN is not supported with other sanitizers')
  455. endif
  456. if not cc.has_function('__tsan_create_fiber',
  457. args: '-fsanitize=thread',
  458. prefix: '#include <sanitizer/tsan_interface.h>')
  459. error('Cannot enable TSAN due to missing fiber annotation interface')
  460. endif
  461. qemu_cflags = ['-fsanitize=thread'] + qemu_cflags
  462. qemu_ldflags = ['-fsanitize=thread'] + qemu_ldflags
  463. endif
  464. # Detect support for PT_GNU_RELRO + DT_BIND_NOW.
  465. # The combination is known as "full relro", because .got.plt is read-only too.
  466. qemu_ldflags += cc.get_supported_link_arguments('-Wl,-z,relro', '-Wl,-z,now')
  467. if host_os == 'windows'
  468. qemu_ldflags += cc.get_supported_link_arguments('-Wl,--no-seh', '-Wl,--nxcompat')
  469. qemu_ldflags += cc.get_supported_link_arguments('-Wl,--dynamicbase', '-Wl,--high-entropy-va')
  470. endif
  471. if get_option('fuzzing')
  472. # Specify a filter to only instrument code that is directly related to
  473. # virtual-devices.
  474. configure_file(output: 'instrumentation-filter',
  475. input: 'scripts/oss-fuzz/instrumentation-filter-template',
  476. copy: true)
  477. if cc.compiles('int main () { return 0; }',
  478. name: '-fsanitize-coverage-allowlist=/dev/null',
  479. args: ['-fsanitize-coverage-allowlist=/dev/null',
  480. '-fsanitize-coverage=trace-pc'] )
  481. qemu_common_flags += ['-fsanitize-coverage-allowlist=instrumentation-filter']
  482. endif
  483. if get_option('fuzzing_engine') == ''
  484. # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
  485. # compiled code. To build non-fuzzer binaries with --enable-fuzzing, link
  486. # everything with fsanitize=fuzzer-no-link. Otherwise, the linker will be
  487. # unable to bind the fuzzer-related callbacks added by instrumentation.
  488. qemu_common_flags += ['-fsanitize=fuzzer-no-link']
  489. qemu_ldflags += ['-fsanitize=fuzzer-no-link']
  490. # For the actual fuzzer binaries, we need to link against the libfuzzer
  491. # library. They need to be configurable, to support OSS-Fuzz
  492. fuzz_exe_ldflags = ['-fsanitize=fuzzer']
  493. else
  494. # LIB_FUZZING_ENGINE was set; assume we are running on OSS-Fuzz, and
  495. # the needed CFLAGS have already been provided
  496. fuzz_exe_ldflags = get_option('fuzzing_engine').split()
  497. endif
  498. endif
  499. if get_option('cfi')
  500. cfi_flags=[]
  501. # Check for dependency on LTO
  502. if not get_option('b_lto')
  503. error('Selected Control-Flow Integrity but LTO is disabled')
  504. endif
  505. if enable_modules
  506. error('Selected Control-Flow Integrity is not compatible with modules')
  507. endif
  508. # Check for cfi flags. CFI requires LTO so we can't use
  509. # get_supported_arguments, but need a more complex "compiles" which allows
  510. # custom arguments
  511. if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
  512. args: ['-flto', '-fsanitize=cfi-icall'] )
  513. cfi_flags += '-fsanitize=cfi-icall'
  514. else
  515. error('-fsanitize=cfi-icall is not supported by the compiler')
  516. endif
  517. if cc.compiles('int main () { return 0; }',
  518. name: '-fsanitize-cfi-icall-generalize-pointers',
  519. args: ['-flto', '-fsanitize=cfi-icall',
  520. '-fsanitize-cfi-icall-generalize-pointers'] )
  521. cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
  522. else
  523. error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
  524. endif
  525. if get_option('cfi_debug')
  526. if cc.compiles('int main () { return 0; }',
  527. name: '-fno-sanitize-trap=cfi-icall',
  528. args: ['-flto', '-fsanitize=cfi-icall',
  529. '-fno-sanitize-trap=cfi-icall'] )
  530. cfi_flags += '-fno-sanitize-trap=cfi-icall'
  531. else
  532. error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
  533. endif
  534. endif
  535. add_global_arguments(cfi_flags, native: false, language: all_languages)
  536. add_global_link_arguments(cfi_flags, native: false, language: all_languages)
  537. endif
  538. # Check further flags that make QEMU more robust against malicious parties
  539. hardening_flags = [
  540. # Initialize all stack variables to zero. This makes
  541. # it harder to take advantage of uninitialized stack
  542. # data to drive exploits
  543. '-ftrivial-auto-var-init=zero',
  544. ]
  545. # Zero out registers used during a function call
  546. # upon its return. This makes it harder to assemble
  547. # ROP gadgets into something usable
  548. #
  549. # NB: Clang 17 is broken and SEGVs
  550. # https://github.com/llvm/llvm-project/issues/75168
  551. #
  552. # NB2: This clashes with the "retguard" extension of OpenBSD's Clang
  553. # https://gitlab.com/qemu-project/qemu/-/issues/2278
  554. if host_os != 'openbsd' and \
  555. cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }',
  556. name: '-fzero-call-used-regs=used-gpr',
  557. args: ['-O2', '-fzero-call-used-regs=used-gpr'])
  558. hardening_flags += '-fzero-call-used-regs=used-gpr'
  559. endif
  560. qemu_common_flags += cc.get_supported_arguments(hardening_flags)
  561. add_global_arguments(qemu_common_flags, native: false, language: all_languages)
  562. add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
  563. # Collect warning flags we want to set, sorted alphabetically
  564. warn_flags = [
  565. # First enable interesting warnings
  566. '-Wempty-body',
  567. '-Wendif-labels',
  568. '-Wexpansion-to-defined',
  569. '-Wformat-security',
  570. '-Wformat-y2k',
  571. '-Wignored-qualifiers',
  572. '-Wimplicit-fallthrough=2',
  573. '-Winit-self',
  574. '-Wmissing-format-attribute',
  575. '-Wmissing-prototypes',
  576. '-Wnested-externs',
  577. '-Wold-style-declaration',
  578. '-Wold-style-definition',
  579. '-Wredundant-decls',
  580. '-Wshadow=local',
  581. '-Wstrict-prototypes',
  582. '-Wtype-limits',
  583. '-Wundef',
  584. '-Wvla',
  585. '-Wwrite-strings',
  586. # Then disable some undesirable warnings
  587. '-Wno-gnu-variable-sized-type-not-at-end',
  588. '-Wno-initializer-overrides',
  589. '-Wno-missing-include-dirs',
  590. '-Wno-psabi',
  591. '-Wno-shift-negative-value',
  592. '-Wno-string-plus-int',
  593. '-Wno-tautological-type-limit-compare',
  594. '-Wno-typedef-redefinition',
  595. ]
  596. if host_os != 'darwin'
  597. tsa_has_cleanup = cc.compiles('''
  598. struct __attribute__((capability("mutex"))) mutex {};
  599. void lock(struct mutex *m) __attribute__((acquire_capability(m)));
  600. void unlock(struct mutex *m) __attribute__((release_capability(m)));
  601. void test(void) {
  602. struct mutex __attribute__((cleanup(unlock))) m;
  603. lock(&m);
  604. }
  605. ''', args: ['-Wthread-safety', '-Werror'])
  606. if tsa_has_cleanup
  607. warn_flags += ['-Wthread-safety']
  608. endif
  609. endif
  610. # Set up C++ compiler flags
  611. qemu_cxxflags = []
  612. if 'cpp' in all_languages
  613. qemu_cxxflags = ['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'] + qemu_cflags
  614. endif
  615. add_project_arguments(qemu_cflags, native: false, language: 'c')
  616. add_project_arguments(cc.get_supported_arguments(warn_flags), native: false, language: 'c')
  617. if 'cpp' in all_languages
  618. add_project_arguments(qemu_cxxflags, native: false, language: 'cpp')
  619. add_project_arguments(cxx.get_supported_arguments(warn_flags), native: false, language: 'cpp')
  620. endif
  621. if 'objc' in all_languages
  622. # Note sanitizer flags are not applied to Objective-C sources!
  623. add_project_arguments(objc.get_supported_arguments(warn_flags), native: false, language: 'objc')
  624. endif
  625. if host_os == 'linux'
  626. add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
  627. '-isystem', 'linux-headers',
  628. language: all_languages)
  629. endif
  630. add_project_arguments('-iquote', '.',
  631. '-iquote', meson.current_source_dir(),
  632. '-iquote', meson.current_source_dir() / 'include',
  633. language: all_languages)
  634. # If a host-specific include directory exists, list that first...
  635. host_include = meson.current_source_dir() / 'host/include/'
  636. if fs.is_dir(host_include / host_arch)
  637. add_project_arguments('-iquote', host_include / host_arch,
  638. language: all_languages)
  639. endif
  640. # ... followed by the generic fallback.
  641. add_project_arguments('-iquote', host_include / 'generic',
  642. language: all_languages)
  643. sparse = find_program('cgcc', required: get_option('sparse'))
  644. if sparse.found()
  645. run_target('sparse',
  646. command: [find_program('scripts/check_sparse.py'),
  647. 'compile_commands.json', sparse.full_path(), '-Wbitwise',
  648. '-Wno-transparent-union', '-Wno-old-initializer',
  649. '-Wno-non-pointer-null'])
  650. endif
  651. #####################################
  652. # Host-specific libraries and flags #
  653. #####################################
  654. libm = cc.find_library('m', required: false)
  655. threads = dependency('threads')
  656. util = cc.find_library('util', required: false)
  657. winmm = []
  658. socket = []
  659. version_res = []
  660. coref = []
  661. iokit = []
  662. emulator_link_args = []
  663. midl = not_found
  664. widl = not_found
  665. pathcch = not_found
  666. host_dsosuf = '.so'
  667. if host_os == 'windows'
  668. midl = find_program('midl', required: false)
  669. widl = find_program('widl', required: false)
  670. pathcch = cc.find_library('pathcch')
  671. socket = cc.find_library('ws2_32')
  672. winmm = cc.find_library('winmm')
  673. win = import('windows')
  674. version_res = win.compile_resources('version.rc',
  675. depend_files: files('pc-bios/qemu-nsis.ico'),
  676. include_directories: include_directories('.'))
  677. host_dsosuf = '.dll'
  678. elif host_os == 'darwin'
  679. coref = dependency('appleframeworks', modules: 'CoreFoundation')
  680. iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
  681. host_dsosuf = '.dylib'
  682. elif host_os == 'sunos'
  683. socket = [cc.find_library('socket'),
  684. cc.find_library('nsl'),
  685. cc.find_library('resolv')]
  686. elif host_os == 'haiku'
  687. socket = [cc.find_library('posix_error_mapper'),
  688. cc.find_library('network'),
  689. cc.find_library('bsd')]
  690. elif host_os == 'openbsd'
  691. if get_option('tcg').allowed() and target_dirs.length() > 0
  692. # Disable OpenBSD W^X if available
  693. emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
  694. endif
  695. endif
  696. ###############################################
  697. # Host-specific configuration of accelerators #
  698. ###############################################
  699. accelerators = []
  700. if get_option('kvm').allowed() and host_os == 'linux'
  701. accelerators += 'CONFIG_KVM'
  702. endif
  703. if get_option('whpx').allowed() and host_os == 'windows'
  704. if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
  705. error('WHPX requires 64-bit host')
  706. elif cc.has_header('winhvplatform.h', required: get_option('whpx')) and \
  707. cc.has_header('winhvemulation.h', required: get_option('whpx'))
  708. accelerators += 'CONFIG_WHPX'
  709. endif
  710. endif
  711. hvf = not_found
  712. if get_option('hvf').allowed()
  713. hvf = dependency('appleframeworks', modules: 'Hypervisor',
  714. required: get_option('hvf'))
  715. if hvf.found()
  716. accelerators += 'CONFIG_HVF'
  717. endif
  718. endif
  719. nvmm = not_found
  720. if host_os == 'netbsd'
  721. nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
  722. if nvmm.found()
  723. accelerators += 'CONFIG_NVMM'
  724. endif
  725. endif
  726. tcg_arch = host_arch
  727. if get_option('tcg').allowed()
  728. if host_arch == 'unknown'
  729. if not get_option('tcg_interpreter')
  730. error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
  731. endif
  732. elif get_option('tcg_interpreter')
  733. warning('Use of the TCG interpreter is not recommended on this host')
  734. warning('architecture. There is a native TCG execution backend available')
  735. warning('which provides substantially better performance and reliability.')
  736. warning('It is strongly recommended to remove the --enable-tcg-interpreter')
  737. warning('configuration option on this architecture to use the native')
  738. warning('backend.')
  739. endif
  740. if get_option('tcg_interpreter')
  741. tcg_arch = 'tci'
  742. elif host_arch == 'x86_64'
  743. tcg_arch = 'i386'
  744. elif host_arch == 'ppc64'
  745. tcg_arch = 'ppc'
  746. endif
  747. add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
  748. language: all_languages)
  749. accelerators += 'CONFIG_TCG'
  750. endif
  751. if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
  752. error('KVM not available on this platform')
  753. endif
  754. if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
  755. error('HVF not available on this platform')
  756. endif
  757. if 'CONFIG_NVMM' not in accelerators and get_option('nvmm').enabled()
  758. error('NVMM not available on this platform')
  759. endif
  760. if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
  761. error('WHPX not available on this platform')
  762. endif
  763. xen = not_found
  764. if get_option('xen').enabled() or (get_option('xen').auto() and have_system)
  765. xencontrol = dependency('xencontrol', required: false,
  766. method: 'pkg-config')
  767. if xencontrol.found()
  768. xen_pc = declare_dependency(version: xencontrol.version(),
  769. dependencies: [
  770. xencontrol,
  771. # disabler: true makes xen_pc.found() return false if any is not found
  772. dependency('xenstore', required: false,
  773. method: 'pkg-config',
  774. disabler: true),
  775. dependency('xenforeignmemory', required: false,
  776. method: 'pkg-config',
  777. disabler: true),
  778. dependency('xengnttab', required: false,
  779. method: 'pkg-config',
  780. disabler: true),
  781. dependency('xenevtchn', required: false,
  782. method: 'pkg-config',
  783. disabler: true),
  784. dependency('xendevicemodel', required: false,
  785. method: 'pkg-config',
  786. disabler: true),
  787. # optional, no "disabler: true"
  788. dependency('xentoolcore', required: false,
  789. method: 'pkg-config')])
  790. if xen_pc.found()
  791. xen = xen_pc
  792. endif
  793. endif
  794. if not xen.found()
  795. xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1' ]
  796. xen_libs = {
  797. '4.11.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
  798. '4.10.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
  799. '4.9.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
  800. '4.8.0': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
  801. '4.7.1': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
  802. }
  803. xen_deps = {}
  804. foreach ver: xen_tests
  805. # cache the various library tests to avoid polluting the logs
  806. xen_test_deps = []
  807. foreach l: xen_libs[ver]
  808. if l not in xen_deps
  809. xen_deps += { l: cc.find_library(l, required: false) }
  810. endif
  811. xen_test_deps += xen_deps[l]
  812. endforeach
  813. # Use -D to pick just one of the test programs in scripts/xen-detect.c
  814. xen_version = ver.split('.')
  815. xen_ctrl_version = xen_version[0] + \
  816. ('0' + xen_version[1]).substring(-2) + \
  817. ('0' + xen_version[2]).substring(-2)
  818. if cc.links(files('scripts/xen-detect.c'),
  819. args: '-DCONFIG_XEN_CTRL_INTERFACE_VERSION=' + xen_ctrl_version,
  820. dependencies: xen_test_deps)
  821. xen = declare_dependency(version: ver, dependencies: xen_test_deps)
  822. break
  823. endif
  824. endforeach
  825. endif
  826. if xen.found()
  827. accelerators += 'CONFIG_XEN'
  828. elif get_option('xen').enabled()
  829. error('could not compile and link Xen test program')
  830. endif
  831. endif
  832. have_xen_pci_passthrough = get_option('xen_pci_passthrough') \
  833. .require(xen.found(),
  834. error_message: 'Xen PCI passthrough requested but Xen not enabled') \
  835. .require(host_os == 'linux',
  836. error_message: 'Xen PCI passthrough not available on this platform') \
  837. .require(cpu == 'x86' or cpu == 'x86_64',
  838. error_message: 'Xen PCI passthrough not available on this platform') \
  839. .allowed()
  840. ################
  841. # Dependencies #
  842. ################
  843. # When bumping glib minimum version, please check also whether to increase
  844. # the _WIN32_WINNT setting in osdep.h according to the value from glib
  845. glib_req_ver = '>=2.66.0'
  846. glib_pc = dependency('glib-2.0', version: glib_req_ver, required: true,
  847. method: 'pkg-config')
  848. glib_cflags = []
  849. if enable_modules
  850. gmodule = dependency('gmodule-export-2.0', version: glib_req_ver, required: true,
  851. method: 'pkg-config')
  852. elif get_option('plugins')
  853. gmodule = dependency('gmodule-no-export-2.0', version: glib_req_ver, required: true,
  854. method: 'pkg-config')
  855. else
  856. gmodule = not_found
  857. endif
  858. # This workaround is required due to a bug in pkg-config file for glib as it
  859. # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
  860. if host_os == 'windows' and get_option('prefer_static')
  861. glib_cflags += ['-DGLIB_STATIC_COMPILATION']
  862. endif
  863. # Sanity check that the current size_t matches the
  864. # size that glib thinks it should be. This catches
  865. # problems on multi-arch where people try to build
  866. # 32-bit QEMU while pointing at 64-bit glib headers
  867. if not cc.compiles('''
  868. #include <glib.h>
  869. #include <unistd.h>
  870. #define QEMU_BUILD_BUG_ON(x) \
  871. typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
  872. int main(void) {
  873. QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
  874. return 0;
  875. }''', dependencies: glib_pc, args: glib_cflags)
  876. error('''sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T.
  877. You probably need to set PKG_CONFIG_LIBDIR" to point
  878. to the right pkg-config files for your build target.''')
  879. endif
  880. glib = declare_dependency(dependencies: [glib_pc, gmodule],
  881. compile_args: glib_cflags,
  882. version: glib_pc.version())
  883. # Check whether glib has gslice, which we have to avoid for correctness.
  884. # TODO: remove this check and the corresponding workaround (qtree) when
  885. # the minimum supported glib is >= 2.75.3
  886. glib_has_gslice = glib.version().version_compare('<2.75.3')
  887. # override glib dep to include the above refinements
  888. meson.override_dependency('glib-2.0', glib)
  889. # The path to glib.h is added to all compilation commands.
  890. add_project_dependencies(glib.partial_dependency(compile_args: true, includes: true),
  891. native: false, language: all_languages)
  892. gio = not_found
  893. gdbus_codegen = not_found
  894. gdbus_codegen_error = '@0@ requires gdbus-codegen, please install libgio'
  895. if not get_option('gio').auto() or have_system
  896. gio = dependency('gio-2.0', required: get_option('gio'),
  897. method: 'pkg-config')
  898. if gio.found() and not cc.links('''
  899. #include <gio/gio.h>
  900. int main(void)
  901. {
  902. g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
  903. return 0;
  904. }''', dependencies: [glib, gio])
  905. if get_option('gio').enabled()
  906. error('The installed libgio is broken for static linking')
  907. endif
  908. gio = not_found
  909. endif
  910. if gio.found()
  911. gdbus_codegen = find_program(gio.get_variable('gdbus_codegen'),
  912. required: get_option('gio'))
  913. gio_unix = dependency('gio-unix-2.0', required: get_option('gio'),
  914. method: 'pkg-config')
  915. gio = declare_dependency(dependencies: [gio, gio_unix],
  916. version: gio.version())
  917. endif
  918. endif
  919. if gdbus_codegen.found() and get_option('cfi')
  920. gdbus_codegen = not_found
  921. gdbus_codegen_error = '@0@ uses gdbus-codegen, which does not support control flow integrity'
  922. endif
  923. xml_pp = find_program('scripts/xml-preprocess.py')
  924. lttng = not_found
  925. if 'ust' in get_option('trace_backends')
  926. lttng = dependency('lttng-ust', required: true, version: '>= 2.1',
  927. method: 'pkg-config')
  928. endif
  929. pixman = not_found
  930. if not get_option('pixman').auto() or have_system or have_tools
  931. pixman = dependency('pixman-1', required: get_option('pixman'), version:'>=0.21.8',
  932. method: 'pkg-config')
  933. endif
  934. zlib = dependency('zlib', required: true)
  935. libaio = not_found
  936. if not get_option('linux_aio').auto() or have_block
  937. libaio = cc.find_library('aio', has_headers: ['libaio.h'],
  938. required: get_option('linux_aio'))
  939. endif
  940. linux_io_uring_test = '''
  941. #include <liburing.h>
  942. #include <linux/errqueue.h>
  943. int main(void) { return 0; }'''
  944. linux_io_uring = not_found
  945. if not get_option('linux_io_uring').auto() or have_block
  946. linux_io_uring = dependency('liburing', version: '>=0.3',
  947. required: get_option('linux_io_uring'),
  948. method: 'pkg-config')
  949. if not cc.links(linux_io_uring_test)
  950. linux_io_uring = not_found
  951. endif
  952. endif
  953. libnfs = not_found
  954. if not get_option('libnfs').auto() or have_block
  955. libnfs = dependency('libnfs', version: '>=1.9.3',
  956. required: get_option('libnfs'),
  957. method: 'pkg-config')
  958. endif
  959. libattr_test = '''
  960. #include <stddef.h>
  961. #include <sys/types.h>
  962. #ifdef CONFIG_LIBATTR
  963. #include <attr/xattr.h>
  964. #else
  965. #include <sys/xattr.h>
  966. #endif
  967. int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }'''
  968. libattr = not_found
  969. have_old_libattr = false
  970. if get_option('attr').allowed()
  971. if cc.links(libattr_test)
  972. libattr = declare_dependency()
  973. else
  974. libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'],
  975. required: get_option('attr'))
  976. if libattr.found() and not \
  977. cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR')
  978. libattr = not_found
  979. if get_option('attr').enabled()
  980. error('could not link libattr')
  981. else
  982. warning('could not link libattr, disabling')
  983. endif
  984. else
  985. have_old_libattr = libattr.found()
  986. endif
  987. endif
  988. endif
  989. cocoa = dependency('appleframeworks',
  990. modules: ['Cocoa', 'CoreVideo', 'QuartzCore'],
  991. required: get_option('cocoa'))
  992. vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet'))
  993. if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h',
  994. 'VMNET_BRIDGED_MODE',
  995. dependencies: vmnet)
  996. vmnet = not_found
  997. if get_option('vmnet').enabled()
  998. error('vmnet.framework API is outdated')
  999. else
  1000. warning('vmnet.framework API is outdated, disabling')
  1001. endif
  1002. endif
  1003. seccomp = not_found
  1004. seccomp_has_sysrawrc = false
  1005. if not get_option('seccomp').auto() or have_system or have_tools
  1006. seccomp = dependency('libseccomp', version: '>=2.3.0',
  1007. required: get_option('seccomp'),
  1008. method: 'pkg-config')
  1009. if seccomp.found()
  1010. seccomp_has_sysrawrc = cc.has_header_symbol('seccomp.h',
  1011. 'SCMP_FLTATR_API_SYSRAWRC',
  1012. dependencies: seccomp)
  1013. endif
  1014. endif
  1015. libcap_ng = not_found
  1016. if not get_option('cap_ng').auto() or have_system or have_tools
  1017. libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'],
  1018. required: get_option('cap_ng'))
  1019. endif
  1020. if libcap_ng.found() and not cc.links('''
  1021. #include <cap-ng.h>
  1022. int main(void)
  1023. {
  1024. capng_capability_to_name(CAPNG_EFFECTIVE);
  1025. return 0;
  1026. }''', dependencies: libcap_ng)
  1027. libcap_ng = not_found
  1028. if get_option('cap_ng').enabled()
  1029. error('could not link libcap-ng')
  1030. else
  1031. warning('could not link libcap-ng, disabling')
  1032. endif
  1033. endif
  1034. if get_option('xkbcommon').auto() and not have_system and not have_tools
  1035. xkbcommon = not_found
  1036. else
  1037. xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
  1038. method: 'pkg-config')
  1039. endif
  1040. slirp = not_found
  1041. if not get_option('slirp').auto() or have_system
  1042. slirp = dependency('slirp', required: get_option('slirp'),
  1043. method: 'pkg-config')
  1044. # slirp < 4.7 is incompatible with CFI support in QEMU. This is because
  1045. # it passes function pointers within libslirp as callbacks for timers.
  1046. # When using a system-wide shared libslirp, the type information for the
  1047. # callback is missing and the timer call produces a false positive with CFI.
  1048. # Do not use the "version" keyword argument to produce a better error.
  1049. # with control-flow integrity.
  1050. if get_option('cfi') and slirp.found() and slirp.version().version_compare('<4.7')
  1051. if get_option('slirp').enabled()
  1052. error('Control-Flow Integrity requires libslirp 4.7.')
  1053. else
  1054. warning('Cannot use libslirp since Control-Flow Integrity requires libslirp >= 4.7.')
  1055. slirp = not_found
  1056. endif
  1057. endif
  1058. endif
  1059. vde = not_found
  1060. if not get_option('vde').auto() or have_system or have_tools
  1061. vde = cc.find_library('vdeplug', has_headers: ['libvdeplug.h'],
  1062. required: get_option('vde'))
  1063. endif
  1064. if vde.found() and not cc.links('''
  1065. #include <libvdeplug.h>
  1066. int main(void)
  1067. {
  1068. struct vde_open_args a = {0, 0, 0};
  1069. char s[] = "";
  1070. vde_open(s, s, &a);
  1071. return 0;
  1072. }''', dependencies: vde)
  1073. vde = not_found
  1074. if get_option('cap_ng').enabled()
  1075. error('could not link libvdeplug')
  1076. else
  1077. warning('could not link libvdeplug, disabling')
  1078. endif
  1079. endif
  1080. pulse = not_found
  1081. if not get_option('pa').auto() or (host_os == 'linux' and have_system)
  1082. pulse = dependency('libpulse', required: get_option('pa'),
  1083. method: 'pkg-config')
  1084. endif
  1085. alsa = not_found
  1086. if not get_option('alsa').auto() or (host_os == 'linux' and have_system)
  1087. alsa = dependency('alsa', required: get_option('alsa'),
  1088. method: 'pkg-config')
  1089. endif
  1090. jack = not_found
  1091. if not get_option('jack').auto() or have_system
  1092. jack = dependency('jack', required: get_option('jack'),
  1093. method: 'pkg-config')
  1094. endif
  1095. pipewire = not_found
  1096. if not get_option('pipewire').auto() or (host_os == 'linux' and have_system)
  1097. pipewire = dependency('libpipewire-0.3', version: '>=0.3.60',
  1098. required: get_option('pipewire'),
  1099. method: 'pkg-config')
  1100. endif
  1101. sndio = not_found
  1102. if not get_option('sndio').auto() or have_system
  1103. sndio = dependency('sndio', required: get_option('sndio'),
  1104. method: 'pkg-config')
  1105. endif
  1106. spice_protocol = not_found
  1107. if not get_option('spice_protocol').auto() or have_system
  1108. spice_protocol = dependency('spice-protocol', version: '>=0.14.0',
  1109. required: get_option('spice_protocol'),
  1110. method: 'pkg-config')
  1111. endif
  1112. spice = not_found
  1113. if get_option('spice') \
  1114. .disable_auto_if(not have_system) \
  1115. .require(pixman.found(),
  1116. error_message: 'cannot enable SPICE if pixman is not available') \
  1117. .allowed()
  1118. spice = dependency('spice-server', version: '>=0.14.0',
  1119. required: get_option('spice'),
  1120. method: 'pkg-config')
  1121. endif
  1122. spice_headers = spice.partial_dependency(compile_args: true, includes: true)
  1123. rt = cc.find_library('rt', required: false)
  1124. libiscsi = not_found
  1125. if not get_option('libiscsi').auto() or have_block
  1126. libiscsi = dependency('libiscsi', version: '>=1.9.0',
  1127. required: get_option('libiscsi'),
  1128. method: 'pkg-config')
  1129. endif
  1130. zstd = not_found
  1131. if not get_option('zstd').auto() or have_block
  1132. zstd = dependency('libzstd', version: '>=1.4.0',
  1133. required: get_option('zstd'),
  1134. method: 'pkg-config')
  1135. endif
  1136. qpl = not_found
  1137. if not get_option('qpl').auto() or have_system
  1138. qpl = dependency('qpl', version: '>=1.5.0',
  1139. required: get_option('qpl'),
  1140. method: 'pkg-config')
  1141. endif
  1142. uadk = not_found
  1143. if not get_option('uadk').auto() or have_system
  1144. libwd = dependency('libwd', version: '>=2.6',
  1145. required: get_option('uadk'),
  1146. method: 'pkg-config')
  1147. libwd_comp = dependency('libwd_comp', version: '>=2.6',
  1148. required: get_option('uadk'),
  1149. method: 'pkg-config')
  1150. if libwd.found() and libwd_comp.found()
  1151. uadk = declare_dependency(dependencies: [libwd, libwd_comp])
  1152. endif
  1153. endif
  1154. qatzip = not_found
  1155. if not get_option('qatzip').auto() or have_system
  1156. qatzip = dependency('qatzip', version: '>=1.1.2',
  1157. required: get_option('qatzip'),
  1158. method: 'pkg-config')
  1159. endif
  1160. virgl = not_found
  1161. have_vhost_user_gpu = have_tools and host_os == 'linux' and pixman.found()
  1162. if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu
  1163. virgl = dependency('virglrenderer',
  1164. method: 'pkg-config',
  1165. required: get_option('virglrenderer'))
  1166. endif
  1167. rutabaga = not_found
  1168. if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu
  1169. rutabaga = dependency('rutabaga_gfx_ffi',
  1170. method: 'pkg-config',
  1171. required: get_option('rutabaga_gfx'))
  1172. endif
  1173. blkio = not_found
  1174. if not get_option('blkio').auto() or have_block
  1175. blkio = dependency('blkio',
  1176. method: 'pkg-config',
  1177. required: get_option('blkio'))
  1178. endif
  1179. curl = not_found
  1180. if not get_option('curl').auto() or have_block
  1181. curl = dependency('libcurl', version: '>=7.29.0',
  1182. method: 'pkg-config',
  1183. required: get_option('curl'))
  1184. endif
  1185. libudev = not_found
  1186. if host_os == 'linux' and (have_system or have_tools)
  1187. libudev = dependency('libudev',
  1188. method: 'pkg-config',
  1189. required: get_option('libudev'))
  1190. endif
  1191. mpathlibs = [libudev]
  1192. mpathpersist = not_found
  1193. if host_os == 'linux' and have_tools and get_option('mpath').allowed()
  1194. mpath_test_source = '''
  1195. #include <libudev.h>
  1196. #include <mpath_persist.h>
  1197. unsigned mpath_mx_alloc_len = 1024;
  1198. int logsink;
  1199. static struct config *multipath_conf;
  1200. extern struct udev *udev;
  1201. extern struct config *get_multipath_config(void);
  1202. extern void put_multipath_config(struct config *conf);
  1203. struct udev *udev;
  1204. struct config *get_multipath_config(void) { return multipath_conf; }
  1205. void put_multipath_config(struct config *conf) { }
  1206. int main(void) {
  1207. udev = udev_new();
  1208. multipath_conf = mpath_lib_init();
  1209. return 0;
  1210. }'''
  1211. libmpathpersist = cc.find_library('mpathpersist',
  1212. required: get_option('mpath'))
  1213. if libmpathpersist.found()
  1214. mpathlibs += libmpathpersist
  1215. if get_option('prefer_static')
  1216. mpathlibs += cc.find_library('devmapper',
  1217. required: get_option('mpath'))
  1218. endif
  1219. mpathlibs += cc.find_library('multipath',
  1220. required: get_option('mpath'))
  1221. foreach lib: mpathlibs
  1222. if not lib.found()
  1223. mpathlibs = []
  1224. break
  1225. endif
  1226. endforeach
  1227. if mpathlibs.length() == 0
  1228. msg = 'Dependencies missing for libmpathpersist'
  1229. elif cc.links(mpath_test_source, dependencies: mpathlibs)
  1230. mpathpersist = declare_dependency(dependencies: mpathlibs)
  1231. else
  1232. msg = 'Cannot detect libmpathpersist API'
  1233. endif
  1234. if not mpathpersist.found()
  1235. if get_option('mpath').enabled()
  1236. error(msg)
  1237. else
  1238. warning(msg + ', disabling')
  1239. endif
  1240. endif
  1241. endif
  1242. endif
  1243. iconv = not_found
  1244. curses = not_found
  1245. if have_system and get_option('curses').allowed()
  1246. curses_test = '''
  1247. #if defined(__APPLE__) || defined(__OpenBSD__)
  1248. #define _XOPEN_SOURCE_EXTENDED 1
  1249. #endif
  1250. #include <locale.h>
  1251. #include <curses.h>
  1252. #include <wchar.h>
  1253. int main(void) {
  1254. wchar_t wch = L'w';
  1255. setlocale(LC_ALL, "");
  1256. resize_term(0, 0);
  1257. addwstr(L"wide chars\n");
  1258. addnwstr(&wch, 1);
  1259. add_wch(WACS_DEGREE);
  1260. return 0;
  1261. }'''
  1262. curses_dep_list = host_os == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
  1263. curses = dependency(curses_dep_list,
  1264. required: false,
  1265. method: 'pkg-config')
  1266. msg = get_option('curses').enabled() ? 'curses library not found' : ''
  1267. curses_compile_args = ['-DNCURSES_WIDECHAR=1']
  1268. if curses.found()
  1269. if cc.links(curses_test, args: curses_compile_args, dependencies: [curses])
  1270. curses = declare_dependency(compile_args: curses_compile_args, dependencies: [curses],
  1271. version: curses.version())
  1272. else
  1273. msg = 'curses package not usable'
  1274. curses = not_found
  1275. endif
  1276. endif
  1277. if not curses.found()
  1278. has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
  1279. if host_os != 'windows' and not has_curses_h
  1280. message('Trying with /usr/include/ncursesw')
  1281. curses_compile_args += ['-I/usr/include/ncursesw']
  1282. has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
  1283. endif
  1284. if has_curses_h
  1285. curses_libname_list = (host_os == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
  1286. foreach curses_libname : curses_libname_list
  1287. libcurses = cc.find_library(curses_libname,
  1288. required: false)
  1289. if libcurses.found()
  1290. if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
  1291. curses = declare_dependency(compile_args: curses_compile_args,
  1292. dependencies: [libcurses])
  1293. break
  1294. else
  1295. msg = 'curses library not usable'
  1296. endif
  1297. endif
  1298. endforeach
  1299. endif
  1300. endif
  1301. if get_option('iconv').allowed()
  1302. foreach link_args : [ ['-liconv'], [] ]
  1303. # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
  1304. # We need to use libiconv if available because mixing libiconv's headers with
  1305. # the system libc does not work.
  1306. # However, without adding glib to the dependencies -L/usr/local/lib will not be
  1307. # included in the command line and libiconv will not be found.
  1308. if cc.links('''
  1309. #include <iconv.h>
  1310. int main(void) {
  1311. iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
  1312. return conv != (iconv_t) -1;
  1313. }''', args: link_args, dependencies: glib)
  1314. iconv = declare_dependency(link_args: link_args, dependencies: glib)
  1315. break
  1316. endif
  1317. endforeach
  1318. endif
  1319. if curses.found() and not iconv.found()
  1320. if get_option('iconv').enabled()
  1321. error('iconv not available')
  1322. endif
  1323. msg = 'iconv required for curses UI but not available'
  1324. curses = not_found
  1325. endif
  1326. if not curses.found() and msg != ''
  1327. if get_option('curses').enabled()
  1328. error(msg)
  1329. else
  1330. warning(msg + ', disabling')
  1331. endif
  1332. endif
  1333. endif
  1334. brlapi = not_found
  1335. if not get_option('brlapi').auto() or have_system
  1336. brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'],
  1337. required: get_option('brlapi'))
  1338. if brlapi.found() and not cc.links('''
  1339. #include <brlapi.h>
  1340. #include <stddef.h>
  1341. int main(void) { return brlapi__openConnection (NULL, NULL, NULL); }''', dependencies: brlapi)
  1342. brlapi = not_found
  1343. if get_option('brlapi').enabled()
  1344. error('could not link brlapi')
  1345. else
  1346. warning('could not link brlapi, disabling')
  1347. endif
  1348. endif
  1349. endif
  1350. sdl = not_found
  1351. if not get_option('sdl').auto() or have_system
  1352. sdl = dependency('sdl2', required: get_option('sdl'))
  1353. sdl_image = not_found
  1354. endif
  1355. if sdl.found()
  1356. # Some versions of SDL have problems with -Wundef
  1357. if not cc.compiles('''
  1358. #include <SDL.h>
  1359. #include <SDL_syswm.h>
  1360. int main(int argc, char *argv[]) { return 0; }
  1361. ''', dependencies: sdl, args: '-Werror=undef')
  1362. sdl = declare_dependency(compile_args: '-Wno-undef',
  1363. dependencies: sdl,
  1364. version: sdl.version())
  1365. endif
  1366. sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
  1367. method: 'pkg-config')
  1368. else
  1369. if get_option('sdl_image').enabled()
  1370. error('sdl-image required, but SDL was @0@'.format(
  1371. get_option('sdl').disabled() ? 'disabled' : 'not found'))
  1372. endif
  1373. sdl_image = not_found
  1374. endif
  1375. rbd = not_found
  1376. if not get_option('rbd').auto() or have_block
  1377. librados = cc.find_library('rados', required: get_option('rbd'))
  1378. librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
  1379. required: get_option('rbd'))
  1380. if librados.found() and librbd.found()
  1381. if cc.links('''
  1382. #include <stdio.h>
  1383. #include <rbd/librbd.h>
  1384. int main(void) {
  1385. rados_t cluster;
  1386. rados_create(&cluster, NULL);
  1387. #if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 12, 0)
  1388. #error
  1389. #endif
  1390. return 0;
  1391. }''', dependencies: [librbd, librados])
  1392. rbd = declare_dependency(dependencies: [librbd, librados])
  1393. elif get_option('rbd').enabled()
  1394. error('librbd >= 1.12.0 required')
  1395. else
  1396. warning('librbd >= 1.12.0 not found, disabling')
  1397. endif
  1398. endif
  1399. endif
  1400. glusterfs = not_found
  1401. glusterfs_ftruncate_has_stat = false
  1402. glusterfs_iocb_has_stat = false
  1403. if not get_option('glusterfs').auto() or have_block
  1404. glusterfs = dependency('glusterfs-api', version: '>=3',
  1405. required: get_option('glusterfs'),
  1406. method: 'pkg-config')
  1407. if glusterfs.found()
  1408. glusterfs_ftruncate_has_stat = cc.links('''
  1409. #include <glusterfs/api/glfs.h>
  1410. int
  1411. main(void)
  1412. {
  1413. /* new glfs_ftruncate() passes two additional args */
  1414. return glfs_ftruncate(NULL, 0, NULL, NULL);
  1415. }
  1416. ''', dependencies: glusterfs)
  1417. glusterfs_iocb_has_stat = cc.links('''
  1418. #include <glusterfs/api/glfs.h>
  1419. /* new glfs_io_cbk() passes two additional glfs_stat structs */
  1420. static void
  1421. glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
  1422. {}
  1423. int
  1424. main(void)
  1425. {
  1426. glfs_io_cbk iocb = &glusterfs_iocb;
  1427. iocb(NULL, 0 , NULL, NULL, NULL);
  1428. return 0;
  1429. }
  1430. ''', dependencies: glusterfs)
  1431. endif
  1432. endif
  1433. hv_balloon = false
  1434. if get_option('hv_balloon').allowed() and have_system
  1435. if cc.links('''
  1436. #include <string.h>
  1437. #include <gmodule.h>
  1438. int main(void) {
  1439. GTree *tree;
  1440. tree = g_tree_new((GCompareFunc)strcmp);
  1441. (void)g_tree_node_first(tree);
  1442. g_tree_destroy(tree);
  1443. return 0;
  1444. }
  1445. ''', dependencies: glib)
  1446. hv_balloon = true
  1447. else
  1448. if get_option('hv_balloon').enabled()
  1449. error('could not enable hv-balloon, update your glib')
  1450. else
  1451. warning('could not find glib support for hv-balloon, disabling')
  1452. endif
  1453. endif
  1454. endif
  1455. libssh = not_found
  1456. if not get_option('libssh').auto() or have_block
  1457. libssh = dependency('libssh', version: '>=0.8.7',
  1458. method: 'pkg-config',
  1459. required: get_option('libssh'))
  1460. endif
  1461. libbzip2 = not_found
  1462. if not get_option('bzip2').auto() or have_block
  1463. libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
  1464. required: get_option('bzip2'))
  1465. if libbzip2.found() and not cc.links('''
  1466. #include <bzlib.h>
  1467. int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2)
  1468. libbzip2 = not_found
  1469. if get_option('bzip2').enabled()
  1470. error('could not link libbzip2')
  1471. else
  1472. warning('could not link libbzip2, disabling')
  1473. endif
  1474. endif
  1475. endif
  1476. liblzfse = not_found
  1477. if not get_option('lzfse').auto() or have_block
  1478. liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'],
  1479. required: get_option('lzfse'))
  1480. endif
  1481. if liblzfse.found() and not cc.links('''
  1482. #include <lzfse.h>
  1483. int main(void) { lzfse_decode_scratch_size(); return 0; }''', dependencies: liblzfse)
  1484. liblzfse = not_found
  1485. if get_option('lzfse').enabled()
  1486. error('could not link liblzfse')
  1487. else
  1488. warning('could not link liblzfse, disabling')
  1489. endif
  1490. endif
  1491. oss = not_found
  1492. if get_option('oss').allowed() and have_system
  1493. if not cc.has_header('sys/soundcard.h')
  1494. # not found
  1495. elif host_os == 'netbsd'
  1496. oss = cc.find_library('ossaudio', required: get_option('oss'))
  1497. else
  1498. oss = declare_dependency()
  1499. endif
  1500. if not oss.found()
  1501. if get_option('oss').enabled()
  1502. error('OSS not found')
  1503. endif
  1504. endif
  1505. endif
  1506. dsound = not_found
  1507. if not get_option('dsound').auto() or (host_os == 'windows' and have_system)
  1508. if cc.has_header('dsound.h')
  1509. dsound = declare_dependency(link_args: ['-lole32', '-ldxguid'])
  1510. endif
  1511. if not dsound.found()
  1512. if get_option('dsound').enabled()
  1513. error('DirectSound not found')
  1514. endif
  1515. endif
  1516. endif
  1517. coreaudio = not_found
  1518. if not get_option('coreaudio').auto() or (host_os == 'darwin' and have_system)
  1519. coreaudio = dependency('appleframeworks', modules: 'CoreAudio',
  1520. required: get_option('coreaudio'))
  1521. endif
  1522. opengl = not_found
  1523. if not get_option('opengl').auto() or have_system or have_vhost_user_gpu
  1524. epoxy = dependency('epoxy', method: 'pkg-config',
  1525. required: get_option('opengl'))
  1526. if cc.has_header('epoxy/egl.h', dependencies: epoxy)
  1527. opengl = epoxy
  1528. elif get_option('opengl').enabled()
  1529. error('epoxy/egl.h not found')
  1530. endif
  1531. endif
  1532. gbm = not_found
  1533. if (have_system or have_tools) and (virgl.found() or opengl.found())
  1534. gbm = dependency('gbm', method: 'pkg-config', required: false)
  1535. endif
  1536. have_vhost_user_gpu = have_vhost_user_gpu and virgl.found() and opengl.found() and gbm.found()
  1537. gnutls = not_found
  1538. gnutls_crypto = not_found
  1539. if get_option('gnutls').enabled() or (get_option('gnutls').auto() and have_system)
  1540. # For general TLS support our min gnutls matches
  1541. # that implied by our platform support matrix
  1542. #
  1543. # For the crypto backends, we look for a newer
  1544. # gnutls:
  1545. #
  1546. # Version 3.6.8 is needed to get XTS
  1547. # Version 3.6.13 is needed to get PBKDF
  1548. # Version 3.6.14 is needed to get HW accelerated XTS
  1549. #
  1550. # If newer enough gnutls isn't available, we can
  1551. # still use a different crypto backend to satisfy
  1552. # the platform support requirements
  1553. gnutls_crypto = dependency('gnutls', version: '>=3.6.14',
  1554. method: 'pkg-config',
  1555. required: false)
  1556. if gnutls_crypto.found()
  1557. gnutls = gnutls_crypto
  1558. else
  1559. # Our min version if all we need is TLS
  1560. gnutls = dependency('gnutls', version: '>=3.5.18',
  1561. method: 'pkg-config',
  1562. required: get_option('gnutls'))
  1563. endif
  1564. endif
  1565. # We prefer use of gnutls for crypto, unless the options
  1566. # explicitly asked for nettle or gcrypt.
  1567. #
  1568. # If gnutls isn't available for crypto, then we'll prefer
  1569. # gcrypt over nettle for performance reasons.
  1570. gcrypt = not_found
  1571. nettle = not_found
  1572. hogweed = not_found
  1573. crypto_sm4 = not_found
  1574. xts = 'none'
  1575. if get_option('nettle').enabled() and get_option('gcrypt').enabled()
  1576. error('Only one of gcrypt & nettle can be enabled')
  1577. endif
  1578. # Explicit nettle/gcrypt request, so ignore gnutls for crypto
  1579. if get_option('nettle').enabled() or get_option('gcrypt').enabled()
  1580. gnutls_crypto = not_found
  1581. endif
  1582. if not gnutls_crypto.found()
  1583. if (not get_option('gcrypt').auto() or have_system) and not get_option('nettle').enabled()
  1584. gcrypt = dependency('libgcrypt', version: '>=1.8',
  1585. required: get_option('gcrypt'))
  1586. # Debian has removed -lgpg-error from libgcrypt-config
  1587. # as it "spreads unnecessary dependencies" which in
  1588. # turn breaks static builds...
  1589. if gcrypt.found() and get_option('prefer_static')
  1590. gcrypt = declare_dependency(dependencies:
  1591. [gcrypt,
  1592. cc.find_library('gpg-error', required: true)],
  1593. version: gcrypt.version())
  1594. endif
  1595. crypto_sm4 = gcrypt
  1596. # SM4 ALG is available in libgcrypt >= 1.9
  1597. if gcrypt.found() and not cc.links('''
  1598. #include <gcrypt.h>
  1599. int main(void) {
  1600. gcry_cipher_hd_t handler;
  1601. gcry_cipher_open(&handler, GCRY_CIPHER_SM4, GCRY_CIPHER_MODE_ECB, 0);
  1602. return 0;
  1603. }''', dependencies: gcrypt)
  1604. crypto_sm4 = not_found
  1605. endif
  1606. endif
  1607. if (not get_option('nettle').auto() or have_system) and not gcrypt.found()
  1608. nettle = dependency('nettle', version: '>=3.4',
  1609. method: 'pkg-config',
  1610. required: get_option('nettle'))
  1611. if nettle.found() and not cc.has_header('nettle/xts.h', dependencies: nettle)
  1612. xts = 'private'
  1613. endif
  1614. crypto_sm4 = nettle
  1615. # SM4 ALG is available in nettle >= 3.9
  1616. if nettle.found() and not cc.links('''
  1617. #include <nettle/sm4.h>
  1618. int main(void) {
  1619. struct sm4_ctx ctx;
  1620. unsigned char key[16] = {0};
  1621. sm4_set_encrypt_key(&ctx, key);
  1622. return 0;
  1623. }''', dependencies: nettle)
  1624. crypto_sm4 = not_found
  1625. endif
  1626. endif
  1627. endif
  1628. capstone = not_found
  1629. if not get_option('capstone').auto() or have_system or have_user
  1630. capstone = dependency('capstone', version: '>=3.0.5',
  1631. method: 'pkg-config',
  1632. required: get_option('capstone'))
  1633. # Some versions of capstone have broken pkg-config file
  1634. # that reports a wrong -I path, causing the #include to
  1635. # fail later. If the system has such a broken version
  1636. # do not use it.
  1637. if capstone.found() and not cc.compiles('#include <capstone.h>',
  1638. dependencies: [capstone])
  1639. capstone = not_found
  1640. if get_option('capstone').enabled()
  1641. error('capstone requested, but it does not appear to work')
  1642. endif
  1643. endif
  1644. endif
  1645. gmp = dependency('gmp', required: false, method: 'pkg-config')
  1646. if nettle.found() and gmp.found()
  1647. hogweed = dependency('hogweed', version: '>=3.4',
  1648. method: 'pkg-config',
  1649. required: get_option('nettle'))
  1650. endif
  1651. gtk = not_found
  1652. gtkx11 = not_found
  1653. vte = not_found
  1654. have_gtk_clipboard = get_option('gtk_clipboard').enabled()
  1655. if get_option('gtk') \
  1656. .disable_auto_if(not have_system) \
  1657. .require(pixman.found(),
  1658. error_message: 'cannot enable GTK if pixman is not available') \
  1659. .allowed()
  1660. gtk = dependency('gtk+-3.0', version: '>=3.22.0',
  1661. method: 'pkg-config',
  1662. required: get_option('gtk'))
  1663. if gtk.found()
  1664. gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0',
  1665. method: 'pkg-config',
  1666. required: false)
  1667. gtk = declare_dependency(dependencies: [gtk, gtkx11],
  1668. version: gtk.version())
  1669. if not get_option('vte').auto() or have_system
  1670. vte = dependency('vte-2.91',
  1671. method: 'pkg-config',
  1672. required: get_option('vte'))
  1673. endif
  1674. elif have_gtk_clipboard
  1675. error('GTK clipboard requested, but GTK not found')
  1676. endif
  1677. endif
  1678. x11 = not_found
  1679. if gtkx11.found()
  1680. x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found())
  1681. endif
  1682. png = not_found
  1683. if get_option('png').allowed() and have_system
  1684. png = dependency('libpng', version: '>=1.6.34', required: get_option('png'),
  1685. method: 'pkg-config')
  1686. endif
  1687. vnc = not_found
  1688. jpeg = not_found
  1689. sasl = not_found
  1690. if get_option('vnc') \
  1691. .disable_auto_if(not have_system) \
  1692. .require(pixman.found(),
  1693. error_message: 'cannot enable VNC if pixman is not available') \
  1694. .allowed()
  1695. vnc = declare_dependency() # dummy dependency
  1696. jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'),
  1697. method: 'pkg-config')
  1698. sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
  1699. required: get_option('vnc_sasl'))
  1700. if sasl.found()
  1701. sasl = declare_dependency(dependencies: sasl,
  1702. compile_args: '-DSTRUCT_IOVEC_DEFINED')
  1703. endif
  1704. endif
  1705. pam = not_found
  1706. if not get_option('auth_pam').auto() or have_system
  1707. pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
  1708. required: get_option('auth_pam'))
  1709. endif
  1710. if pam.found() and not cc.links('''
  1711. #include <stddef.h>
  1712. #include <security/pam_appl.h>
  1713. int main(void) {
  1714. const char *service_name = "qemu";
  1715. const char *user = "frank";
  1716. const struct pam_conv pam_conv = { 0 };
  1717. pam_handle_t *pamh = NULL;
  1718. pam_start(service_name, user, &pam_conv, &pamh);
  1719. return 0;
  1720. }''', dependencies: pam)
  1721. pam = not_found
  1722. if get_option('auth_pam').enabled()
  1723. error('could not link libpam')
  1724. else
  1725. warning('could not link libpam, disabling')
  1726. endif
  1727. endif
  1728. snappy = not_found
  1729. if not get_option('snappy').auto() or have_system
  1730. snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
  1731. required: get_option('snappy'))
  1732. endif
  1733. if snappy.found() and not cc.links('''
  1734. #include <snappy-c.h>
  1735. int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy)
  1736. snappy = not_found
  1737. if get_option('snappy').enabled()
  1738. error('could not link libsnappy')
  1739. else
  1740. warning('could not link libsnappy, disabling')
  1741. endif
  1742. endif
  1743. lzo = not_found
  1744. if not get_option('lzo').auto() or have_system
  1745. lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'],
  1746. required: get_option('lzo'))
  1747. endif
  1748. if lzo.found() and not cc.links('''
  1749. #include <lzo/lzo1x.h>
  1750. int main(void) { lzo_version(); return 0; }''', dependencies: lzo)
  1751. lzo = not_found
  1752. if get_option('lzo').enabled()
  1753. error('could not link liblzo2')
  1754. else
  1755. warning('could not link liblzo2, disabling')
  1756. endif
  1757. endif
  1758. numa = not_found
  1759. if not get_option('numa').auto() or have_system or have_tools
  1760. numa = cc.find_library('numa', has_headers: ['numa.h'],
  1761. required: get_option('numa'))
  1762. endif
  1763. if numa.found() and not cc.links('''
  1764. #include <numa.h>
  1765. int main(void) { return numa_available(); }
  1766. ''', dependencies: numa)
  1767. numa = not_found
  1768. if get_option('numa').enabled()
  1769. error('could not link numa')
  1770. else
  1771. warning('could not link numa, disabling')
  1772. endif
  1773. endif
  1774. fdt = not_found
  1775. fdt_opt = get_option('fdt')
  1776. if fdt_opt == 'enabled' and get_option('wrap_mode') == 'nodownload'
  1777. fdt_opt = 'system'
  1778. endif
  1779. if fdt_opt in ['enabled', 'system'] or (fdt_opt == 'auto' and have_system)
  1780. fdt = cc.find_library('fdt', required: fdt_opt == 'system')
  1781. if fdt.found() and cc.links('''
  1782. #include <libfdt.h>
  1783. #include <libfdt_env.h>
  1784. int main(void) { fdt_find_max_phandle(NULL, NULL); return 0; }''',
  1785. dependencies: fdt)
  1786. fdt_opt = 'system'
  1787. elif fdt_opt != 'system'
  1788. fdt_opt = get_option('wrap_mode') == 'nodownload' ? 'disabled' : 'internal'
  1789. fdt = not_found
  1790. else
  1791. error('system libfdt is too old (1.5.1 or newer required)')
  1792. endif
  1793. endif
  1794. if fdt_opt == 'internal'
  1795. assert(not fdt.found())
  1796. libfdt_proj = subproject('dtc', required: true,
  1797. default_options: ['tools=false', 'yaml=disabled',
  1798. 'python=disabled', 'default_library=static'])
  1799. fdt = libfdt_proj.get_variable('libfdt_dep')
  1800. endif
  1801. rdma = not_found
  1802. if not get_option('rdma').auto() or have_system
  1803. rdma_libs = [cc.find_library('rdmacm', has_headers: ['rdma/rdma_cma.h'],
  1804. required: get_option('rdma')),
  1805. cc.find_library('ibverbs', required: get_option('rdma'))]
  1806. rdma = declare_dependency(dependencies: rdma_libs)
  1807. foreach lib: rdma_libs
  1808. if not lib.found()
  1809. rdma = not_found
  1810. endif
  1811. endforeach
  1812. endif
  1813. cacard = not_found
  1814. if not get_option('smartcard').auto() or have_system
  1815. cacard = dependency('libcacard', required: get_option('smartcard'),
  1816. version: '>=2.5.1', method: 'pkg-config')
  1817. endif
  1818. u2f = not_found
  1819. if not get_option('u2f').auto() or have_system
  1820. u2f = dependency('u2f-emu', required: get_option('u2f'),
  1821. method: 'pkg-config')
  1822. endif
  1823. canokey = not_found
  1824. if not get_option('canokey').auto() or have_system
  1825. canokey = dependency('canokey-qemu', required: get_option('canokey'),
  1826. method: 'pkg-config')
  1827. endif
  1828. usbredir = not_found
  1829. if not get_option('usb_redir').auto() or have_system
  1830. usbredir = dependency('libusbredirparser-0.5', required: get_option('usb_redir'),
  1831. version: '>=0.6', method: 'pkg-config')
  1832. endif
  1833. libusb = not_found
  1834. if not get_option('libusb').auto() or have_system
  1835. libusb = dependency('libusb-1.0', required: get_option('libusb'),
  1836. version: '>=1.0.13', method: 'pkg-config')
  1837. endif
  1838. libpmem = not_found
  1839. if not get_option('libpmem').auto() or have_system
  1840. libpmem = dependency('libpmem', required: get_option('libpmem'),
  1841. method: 'pkg-config')
  1842. endif
  1843. libdaxctl = not_found
  1844. if not get_option('libdaxctl').auto() or have_system
  1845. libdaxctl = dependency('libdaxctl', required: get_option('libdaxctl'),
  1846. version: '>=57', method: 'pkg-config')
  1847. endif
  1848. tasn1 = not_found
  1849. if gnutls.found()
  1850. tasn1 = dependency('libtasn1',
  1851. required: false,
  1852. method: 'pkg-config')
  1853. endif
  1854. keyutils = not_found
  1855. if not get_option('libkeyutils').auto() or have_block
  1856. keyutils = dependency('libkeyutils', required: get_option('libkeyutils'),
  1857. method: 'pkg-config')
  1858. endif
  1859. has_gettid = cc.has_function('gettid')
  1860. # libselinux
  1861. selinux = dependency('libselinux',
  1862. required: get_option('selinux'),
  1863. method: 'pkg-config')
  1864. # Malloc tests
  1865. malloc = []
  1866. if get_option('malloc') == 'system'
  1867. has_malloc_trim = \
  1868. get_option('malloc_trim').allowed() and \
  1869. cc.has_function('malloc_trim', prefix: '#include <malloc.h>')
  1870. else
  1871. has_malloc_trim = false
  1872. malloc = cc.find_library(get_option('malloc'), required: true)
  1873. endif
  1874. if not has_malloc_trim and get_option('malloc_trim').enabled()
  1875. if get_option('malloc') == 'system'
  1876. error('malloc_trim not available on this platform.')
  1877. else
  1878. error('malloc_trim not available with non-libc memory allocator')
  1879. endif
  1880. endif
  1881. gnu_source_prefix = '''
  1882. #ifndef _GNU_SOURCE
  1883. #define _GNU_SOURCE
  1884. #endif
  1885. '''
  1886. # Check whether the glibc provides STATX_BASIC_STATS
  1887. has_statx = cc.has_header_symbol('sys/stat.h', 'STATX_BASIC_STATS', prefix: gnu_source_prefix)
  1888. # Check whether statx() provides mount ID information
  1889. has_statx_mnt_id = cc.has_header_symbol('sys/stat.h', 'STATX_MNT_ID', prefix: gnu_source_prefix)
  1890. have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
  1891. .require(host_os == 'linux',
  1892. error_message: 'vhost_user_blk_server requires linux') \
  1893. .require(have_vhost_user,
  1894. error_message: 'vhost_user_blk_server requires vhost-user support') \
  1895. .disable_auto_if(not have_tools and not have_system) \
  1896. .allowed()
  1897. if get_option('fuse').disabled() and get_option('fuse_lseek').enabled()
  1898. error('Cannot enable fuse-lseek while fuse is disabled')
  1899. endif
  1900. fuse = dependency('fuse3', required: get_option('fuse'),
  1901. version: '>=3.1', method: 'pkg-config')
  1902. fuse_lseek = not_found
  1903. if get_option('fuse_lseek').allowed()
  1904. if fuse.version().version_compare('>=3.8')
  1905. # Dummy dependency
  1906. fuse_lseek = declare_dependency()
  1907. elif get_option('fuse_lseek').enabled()
  1908. if fuse.found()
  1909. error('fuse-lseek requires libfuse >=3.8, found ' + fuse.version())
  1910. else
  1911. error('fuse-lseek requires libfuse, which was not found')
  1912. endif
  1913. endif
  1914. endif
  1915. have_libvduse = (host_os == 'linux')
  1916. if get_option('libvduse').enabled()
  1917. if host_os != 'linux'
  1918. error('libvduse requires linux')
  1919. endif
  1920. elif get_option('libvduse').disabled()
  1921. have_libvduse = false
  1922. endif
  1923. have_vduse_blk_export = (have_libvduse and host_os == 'linux')
  1924. if get_option('vduse_blk_export').enabled()
  1925. if host_os != 'linux'
  1926. error('vduse_blk_export requires linux')
  1927. elif not have_libvduse
  1928. error('vduse_blk_export requires libvduse support')
  1929. endif
  1930. elif get_option('vduse_blk_export').disabled()
  1931. have_vduse_blk_export = false
  1932. endif
  1933. # libbpf
  1934. bpf_version = '1.1.0'
  1935. libbpf = dependency('libbpf', version: '>=' + bpf_version, required: get_option('bpf'), method: 'pkg-config')
  1936. if libbpf.found() and not cc.links('''
  1937. #include <bpf/libbpf.h>
  1938. #include <linux/bpf.h>
  1939. int main(void)
  1940. {
  1941. // check flag availability
  1942. int flag = BPF_F_MMAPABLE;
  1943. bpf_object__destroy_skeleton(NULL);
  1944. return 0;
  1945. }''', dependencies: libbpf)
  1946. libbpf = not_found
  1947. if get_option('bpf').enabled()
  1948. error('libbpf skeleton/mmaping test failed')
  1949. else
  1950. warning('libbpf skeleton/mmaping test failed, disabling')
  1951. endif
  1952. endif
  1953. # libxdp
  1954. libxdp = not_found
  1955. if not get_option('af_xdp').auto() or have_system
  1956. libxdp = dependency('libxdp', required: get_option('af_xdp'),
  1957. version: '>=1.4.0', method: 'pkg-config')
  1958. endif
  1959. # libdw
  1960. libdw = not_found
  1961. if not get_option('libdw').auto() or \
  1962. (not get_option('prefer_static') and (have_system or have_user))
  1963. libdw = dependency('libdw',
  1964. method: 'pkg-config',
  1965. required: get_option('libdw'))
  1966. endif
  1967. #################
  1968. # config-host.h #
  1969. #################
  1970. config_host_data = configuration_data()
  1971. audio_drivers_selected = []
  1972. if have_system
  1973. audio_drivers_available = {
  1974. 'alsa': alsa.found(),
  1975. 'coreaudio': coreaudio.found(),
  1976. 'dsound': dsound.found(),
  1977. 'jack': jack.found(),
  1978. 'oss': oss.found(),
  1979. 'pa': pulse.found(),
  1980. 'pipewire': pipewire.found(),
  1981. 'sdl': sdl.found(),
  1982. 'sndio': sndio.found(),
  1983. }
  1984. foreach k, v: audio_drivers_available
  1985. config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
  1986. endforeach
  1987. # Default to native drivers first, OSS second, SDL third
  1988. audio_drivers_priority = \
  1989. [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
  1990. (host_os == 'linux' ? [] : [ 'sdl' ])
  1991. audio_drivers_default = []
  1992. foreach k: audio_drivers_priority
  1993. if audio_drivers_available[k]
  1994. audio_drivers_default += k
  1995. endif
  1996. endforeach
  1997. foreach k: get_option('audio_drv_list')
  1998. if k == 'default'
  1999. audio_drivers_selected += audio_drivers_default
  2000. elif not audio_drivers_available[k]
  2001. error('Audio driver "@0@" not available.'.format(k))
  2002. else
  2003. audio_drivers_selected += k
  2004. endif
  2005. endforeach
  2006. endif
  2007. config_host_data.set('CONFIG_AUDIO_DRIVERS',
  2008. '"' + '", "'.join(audio_drivers_selected) + '", ')
  2009. have_host_block_device = (host_os != 'darwin' or
  2010. cc.has_header('IOKit/storage/IOMedia.h'))
  2011. dbus_display = get_option('dbus_display') \
  2012. .require(gio.version().version_compare('>=2.64'),
  2013. error_message: '-display dbus requires glib>=2.64') \
  2014. .require(gdbus_codegen.found(),
  2015. error_message: gdbus_codegen_error.format('-display dbus')) \
  2016. .allowed()
  2017. have_virtfs = get_option('virtfs') \
  2018. .require(host_os == 'linux' or host_os == 'darwin',
  2019. error_message: 'virtio-9p (virtfs) requires Linux or macOS') \
  2020. .require(host_os == 'linux' or cc.has_function('pthread_fchdir_np'),
  2021. error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \
  2022. .require(host_os == 'darwin' or libattr.found(),
  2023. error_message: 'virtio-9p (virtfs) on Linux requires libattr-devel') \
  2024. .disable_auto_if(not have_tools and not have_system) \
  2025. .allowed()
  2026. qga_fsfreeze = false
  2027. qga_fstrim = false
  2028. if host_os == 'linux'
  2029. if cc.has_header_symbol('linux/fs.h', 'FIFREEZE')
  2030. qga_fsfreeze = true
  2031. endif
  2032. if cc.has_header_symbol('linux/fs.h', 'FITRIM')
  2033. qga_fstrim = true
  2034. endif
  2035. elif host_os == 'freebsd' and cc.has_header_symbol('ufs/ffs/fs.h', 'UFSSUSPEND')
  2036. qga_fsfreeze = true
  2037. endif
  2038. if get_option('block_drv_ro_whitelist') == ''
  2039. config_host_data.set('CONFIG_BDRV_RO_WHITELIST', '')
  2040. else
  2041. config_host_data.set('CONFIG_BDRV_RO_WHITELIST',
  2042. '"' + get_option('block_drv_ro_whitelist').replace(',', '", "') + '", ')
  2043. endif
  2044. if get_option('block_drv_rw_whitelist') == ''
  2045. config_host_data.set('CONFIG_BDRV_RW_WHITELIST', '')
  2046. else
  2047. config_host_data.set('CONFIG_BDRV_RW_WHITELIST',
  2048. '"' + get_option('block_drv_rw_whitelist').replace(',', '", "') + '", ')
  2049. endif
  2050. foreach k : get_option('trace_backends')
  2051. config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true)
  2052. endforeach
  2053. config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('trace_file'))
  2054. config_host_data.set_quoted('CONFIG_TLS_PRIORITY', get_option('tls_priority'))
  2055. if iasl.found()
  2056. config_host_data.set_quoted('CONFIG_IASL', iasl.full_path())
  2057. endif
  2058. config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
  2059. config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
  2060. config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
  2061. config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
  2062. config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
  2063. qemu_firmwarepath = ''
  2064. foreach k : get_option('qemu_firmwarepath')
  2065. qemu_firmwarepath += '"' + get_option('prefix') / k + '", '
  2066. endforeach
  2067. config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_firmwarepath)
  2068. config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
  2069. config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
  2070. config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
  2071. config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
  2072. config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
  2073. config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
  2074. if enable_modules
  2075. config_host_data.set('CONFIG_STAMP', run_command(
  2076. meson.current_source_dir() / 'scripts/qemu-stamp.py',
  2077. meson.project_version(), get_option('pkgversion'), '--',
  2078. meson.current_source_dir() / 'configure',
  2079. capture: true, check: true).stdout().strip())
  2080. endif
  2081. have_slirp_smbd = get_option('slirp_smbd') \
  2082. .require(host_os != 'windows', error_message: 'Host smbd not supported on this platform.') \
  2083. .allowed()
  2084. if have_slirp_smbd
  2085. smbd_path = get_option('smbd')
  2086. if smbd_path == ''
  2087. smbd_path = (host_os == 'sunos' ? '/usr/sfw/sbin/smbd' : '/usr/sbin/smbd')
  2088. endif
  2089. config_host_data.set_quoted('CONFIG_SMBD_COMMAND', smbd_path)
  2090. endif
  2091. config_host_data.set('HOST_' + host_arch.to_upper(), 1)
  2092. kvm_targets_c = '""'
  2093. if get_option('kvm').allowed() and host_os == 'linux'
  2094. kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
  2095. endif
  2096. config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
  2097. if get_option('module_upgrades') and not enable_modules
  2098. error('Cannot enable module-upgrades as modules are not enabled')
  2099. endif
  2100. config_host_data.set('CONFIG_MODULE_UPGRADES', get_option('module_upgrades'))
  2101. config_host_data.set('CONFIG_ATTR', libattr.found())
  2102. config_host_data.set('CONFIG_BDRV_WHITELIST_TOOLS', get_option('block_drv_whitelist_in_tools'))
  2103. config_host_data.set('CONFIG_BRLAPI', brlapi.found())
  2104. config_host_data.set('CONFIG_BSD', host_os in bsd_oses)
  2105. config_host_data.set('CONFIG_FREEBSD', host_os == 'freebsd')
  2106. config_host_data.set('CONFIG_CAPSTONE', capstone.found())
  2107. config_host_data.set('CONFIG_COCOA', cocoa.found())
  2108. config_host_data.set('CONFIG_DARWIN', host_os == 'darwin')
  2109. config_host_data.set('CONFIG_FDT', fdt.found())
  2110. config_host_data.set('CONFIG_FUZZ', get_option('fuzzing'))
  2111. config_host_data.set('CONFIG_GCOV', get_option('b_coverage'))
  2112. config_host_data.set('CONFIG_LIBUDEV', libudev.found())
  2113. config_host_data.set('CONFIG_LINUX', host_os == 'linux')
  2114. config_host_data.set('CONFIG_POSIX', host_os != 'windows')
  2115. config_host_data.set('CONFIG_WIN32', host_os == 'windows')
  2116. config_host_data.set('CONFIG_LZO', lzo.found())
  2117. config_host_data.set('CONFIG_MPATH', mpathpersist.found())
  2118. config_host_data.set('CONFIG_BLKIO', blkio.found())
  2119. if blkio.found()
  2120. config_host_data.set('CONFIG_BLKIO_VHOST_VDPA_FD',
  2121. blkio.version().version_compare('>=1.3.0'))
  2122. config_host_data.set('CONFIG_BLKIO_WRITE_ZEROS_FUA',
  2123. blkio.version().version_compare('>=1.4.0'))
  2124. endif
  2125. config_host_data.set('CONFIG_CURL', curl.found())
  2126. config_host_data.set('CONFIG_CURSES', curses.found())
  2127. config_host_data.set('CONFIG_GBM', gbm.found())
  2128. config_host_data.set('CONFIG_GIO', gio.found())
  2129. config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found())
  2130. if glusterfs.found()
  2131. config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().version_compare('>=4'))
  2132. config_host_data.set('CONFIG_GLUSTERFS_DISCARD', glusterfs.version().version_compare('>=5'))
  2133. config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().version_compare('>=6'))
  2134. config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().version_compare('>=6'))
  2135. config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat)
  2136. config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat)
  2137. endif
  2138. config_host_data.set('CONFIG_GTK', gtk.found())
  2139. config_host_data.set('CONFIG_VTE', vte.found())
  2140. config_host_data.set('CONFIG_GTK_CLIPBOARD', have_gtk_clipboard)
  2141. config_host_data.set('CONFIG_HEXAGON_IDEF_PARSER', get_option('hexagon_idef_parser'))
  2142. config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
  2143. config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
  2144. config_host_data.set('CONFIG_EBPF', libbpf.found())
  2145. config_host_data.set('CONFIG_AF_XDP', libxdp.found())
  2146. config_host_data.set('CONFIG_LIBDAXCTL', libdaxctl.found())
  2147. config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
  2148. config_host_data.set('CONFIG_LIBNFS', libnfs.found())
  2149. config_host_data.set('CONFIG_LIBSSH', libssh.found())
  2150. config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
  2151. config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
  2152. config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
  2153. config_host_data.set('CONFIG_MODULES', enable_modules)
  2154. config_host_data.set('CONFIG_NUMA', numa.found())
  2155. if numa.found()
  2156. config_host_data.set('HAVE_NUMA_HAS_PREFERRED_MANY',
  2157. cc.has_function('numa_has_preferred_many',
  2158. dependencies: numa))
  2159. endif
  2160. config_host_data.set('CONFIG_OPENGL', opengl.found())
  2161. config_host_data.set('CONFIG_PLUGIN', get_option('plugins'))
  2162. config_host_data.set('CONFIG_RBD', rbd.found())
  2163. config_host_data.set('CONFIG_RDMA', rdma.found())
  2164. config_host_data.set('CONFIG_RELOCATABLE', get_option('relocatable'))
  2165. config_host_data.set('CONFIG_SAFESTACK', get_option('safe_stack'))
  2166. config_host_data.set('CONFIG_SDL', sdl.found())
  2167. config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
  2168. config_host_data.set('CONFIG_SECCOMP', seccomp.found())
  2169. if seccomp.found()
  2170. config_host_data.set('CONFIG_SECCOMP_SYSRAWRC', seccomp_has_sysrawrc)
  2171. endif
  2172. config_host_data.set('CONFIG_PIXMAN', pixman.found())
  2173. config_host_data.set('CONFIG_SLIRP', slirp.found())
  2174. config_host_data.set('CONFIG_SNAPPY', snappy.found())
  2175. config_host_data.set('CONFIG_SOLARIS', host_os == 'sunos')
  2176. if get_option('tcg').allowed()
  2177. config_host_data.set('CONFIG_TCG', 1)
  2178. config_host_data.set('CONFIG_TCG_INTERPRETER', tcg_arch == 'tci')
  2179. endif
  2180. config_host_data.set('CONFIG_TPM', have_tpm)
  2181. config_host_data.set('CONFIG_TSAN', get_option('tsan'))
  2182. config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
  2183. config_host_data.set('CONFIG_VDE', vde.found())
  2184. config_host_data.set('CONFIG_VHOST', have_vhost)
  2185. config_host_data.set('CONFIG_VHOST_NET', have_vhost_net)
  2186. config_host_data.set('CONFIG_VHOST_NET_USER', have_vhost_net_user)
  2187. config_host_data.set('CONFIG_VHOST_NET_VDPA', have_vhost_net_vdpa)
  2188. config_host_data.set('CONFIG_VHOST_KERNEL', have_vhost_kernel)
  2189. config_host_data.set('CONFIG_VHOST_USER', have_vhost_user)
  2190. config_host_data.set('CONFIG_VHOST_CRYPTO', have_vhost_user_crypto)
  2191. config_host_data.set('CONFIG_VHOST_VDPA', have_vhost_vdpa)
  2192. config_host_data.set('CONFIG_VMNET', vmnet.found())
  2193. config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
  2194. config_host_data.set('CONFIG_VDUSE_BLK_EXPORT', have_vduse_blk_export)
  2195. config_host_data.set('CONFIG_PNG', png.found())
  2196. config_host_data.set('CONFIG_VNC', vnc.found())
  2197. config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
  2198. config_host_data.set('CONFIG_VNC_SASL', sasl.found())
  2199. if virgl.found()
  2200. config_host_data.set('HAVE_VIRGL_D3D_INFO_EXT',
  2201. cc.has_member('struct virgl_renderer_resource_info_ext', 'd3d_tex2d',
  2202. prefix: '#include <virglrenderer.h>',
  2203. dependencies: virgl))
  2204. endif
  2205. config_host_data.set('CONFIG_VIRTFS', have_virtfs)
  2206. config_host_data.set('CONFIG_VTE', vte.found())
  2207. config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
  2208. config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
  2209. config_host_data.set('CONFIG_GETTID', has_gettid)
  2210. config_host_data.set('CONFIG_GNUTLS', gnutls.found())
  2211. config_host_data.set('CONFIG_GNUTLS_CRYPTO', gnutls_crypto.found())
  2212. config_host_data.set('CONFIG_TASN1', tasn1.found())
  2213. config_host_data.set('CONFIG_GCRYPT', gcrypt.found())
  2214. config_host_data.set('CONFIG_NETTLE', nettle.found())
  2215. config_host_data.set('CONFIG_CRYPTO_SM4', crypto_sm4.found())
  2216. config_host_data.set('CONFIG_HOGWEED', hogweed.found())
  2217. config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts == 'private')
  2218. config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
  2219. config_host_data.set('CONFIG_STATX', has_statx)
  2220. config_host_data.set('CONFIG_STATX_MNT_ID', has_statx_mnt_id)
  2221. config_host_data.set('CONFIG_ZSTD', zstd.found())
  2222. config_host_data.set('CONFIG_QPL', qpl.found())
  2223. config_host_data.set('CONFIG_UADK', uadk.found())
  2224. config_host_data.set('CONFIG_QATZIP', qatzip.found())
  2225. config_host_data.set('CONFIG_FUSE', fuse.found())
  2226. config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found())
  2227. config_host_data.set('CONFIG_SPICE_PROTOCOL', spice_protocol.found())
  2228. if spice_protocol.found()
  2229. config_host_data.set('CONFIG_SPICE_PROTOCOL_MAJOR', spice_protocol.version().split('.')[0])
  2230. config_host_data.set('CONFIG_SPICE_PROTOCOL_MINOR', spice_protocol.version().split('.')[1])
  2231. config_host_data.set('CONFIG_SPICE_PROTOCOL_MICRO', spice_protocol.version().split('.')[2])
  2232. endif
  2233. config_host_data.set('CONFIG_SPICE', spice.found())
  2234. config_host_data.set('CONFIG_X11', x11.found())
  2235. config_host_data.set('CONFIG_DBUS_DISPLAY', dbus_display)
  2236. config_host_data.set('CONFIG_CFI', get_option('cfi'))
  2237. config_host_data.set('CONFIG_SELINUX', selinux.found())
  2238. config_host_data.set('CONFIG_XEN_BACKEND', xen.found())
  2239. config_host_data.set('CONFIG_LIBDW', libdw.found())
  2240. if xen.found()
  2241. # protect from xen.version() having less than three components
  2242. xen_version = xen.version().split('.') + ['0', '0']
  2243. xen_ctrl_version = xen_version[0] + \
  2244. ('0' + xen_version[1]).substring(-2) + \
  2245. ('0' + xen_version[2]).substring(-2)
  2246. config_host_data.set('CONFIG_XEN_CTRL_INTERFACE_VERSION', xen_ctrl_version)
  2247. endif
  2248. config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
  2249. config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
  2250. config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
  2251. config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
  2252. config_host_data.set_quoted('CONFIG_HOST_DSOSUF', host_dsosuf)
  2253. config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device)
  2254. have_coroutine_pool = get_option('coroutine_pool')
  2255. if get_option('debug_stack_usage') and have_coroutine_pool
  2256. message('Disabling coroutine pool to measure stack usage')
  2257. have_coroutine_pool = false
  2258. endif
  2259. config_host_data.set('CONFIG_COROUTINE_POOL', have_coroutine_pool)
  2260. config_host_data.set('CONFIG_DEBUG_GRAPH_LOCK', get_option('debug_graph_lock'))
  2261. config_host_data.set('CONFIG_DEBUG_MUTEX', get_option('debug_mutex'))
  2262. config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_option('debug_stack_usage'))
  2263. config_host_data.set('CONFIG_DEBUG_TCG', get_option('debug_tcg'))
  2264. config_host_data.set('CONFIG_DEBUG_REMAP', get_option('debug_remap'))
  2265. config_host_data.set('CONFIG_QOM_CAST_DEBUG', get_option('qom_cast_debug'))
  2266. config_host_data.set('CONFIG_REPLICATION', get_option('replication').allowed())
  2267. config_host_data.set('CONFIG_FSFREEZE', qga_fsfreeze)
  2268. config_host_data.set('CONFIG_FSTRIM', qga_fstrim)
  2269. # has_header
  2270. config_host_data.set('CONFIG_EPOLL', cc.has_header('sys/epoll.h'))
  2271. config_host_data.set('CONFIG_LINUX_MAGIC_H', cc.has_header('linux/magic.h'))
  2272. config_host_data.set('CONFIG_VALGRIND_H', cc.has_header('valgrind/valgrind.h'))
  2273. config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h'))
  2274. config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
  2275. config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
  2276. config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h'))
  2277. config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
  2278. config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
  2279. if host_os == 'windows'
  2280. config_host_data.set('HAVE_AFUNIX_H', cc.has_header('afunix.h'))
  2281. endif
  2282. # has_function
  2283. config_host_data.set('CONFIG_CLOSE_RANGE', cc.has_function('close_range'))
  2284. config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4'))
  2285. config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime'))
  2286. config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))
  2287. config_host_data.set('CONFIG_FALLOCATE', cc.has_function('fallocate'))
  2288. config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate'))
  2289. config_host_data.set('CONFIG_GETCPU', cc.has_function('getcpu', prefix: gnu_source_prefix))
  2290. config_host_data.set('CONFIG_SCHED_GETCPU', cc.has_function('sched_getcpu', prefix: '#include <sched.h>'))
  2291. # Note that we need to specify prefix: here to avoid incorrectly
  2292. # thinking that Windows has posix_memalign()
  2293. config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include <stdlib.h>'))
  2294. config_host_data.set('CONFIG_ALIGNED_MALLOC', cc.has_function('_aligned_malloc'))
  2295. config_host_data.set('CONFIG_VALLOC', cc.has_function('valloc'))
  2296. config_host_data.set('CONFIG_MEMALIGN', cc.has_function('memalign'))
  2297. config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll'))
  2298. config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
  2299. config_host_data.set('CONFIG_PTHREAD_FCHDIR_NP', cc.has_function('pthread_fchdir_np'))
  2300. config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile'))
  2301. config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare'))
  2302. config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs'))
  2303. config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range'))
  2304. config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create'))
  2305. config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
  2306. config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs'))
  2307. config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice)
  2308. config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
  2309. config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))
  2310. config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
  2311. if rbd.found()
  2312. config_host_data.set('HAVE_RBD_NAMESPACE_EXISTS',
  2313. cc.has_function('rbd_namespace_exists',
  2314. dependencies: rbd,
  2315. prefix: '#include <rbd/librbd.h>'))
  2316. endif
  2317. if rdma.found()
  2318. config_host_data.set('HAVE_IBV_ADVISE_MR',
  2319. cc.has_function('ibv_advise_mr',
  2320. dependencies: rdma,
  2321. prefix: '#include <infiniband/verbs.h>'))
  2322. endif
  2323. have_asan_fiber = false
  2324. if get_option('asan') and \
  2325. not cc.has_function('__sanitizer_start_switch_fiber',
  2326. args: '-fsanitize=address',
  2327. prefix: '#include <sanitizer/asan_interface.h>')
  2328. warning('Missing ASAN due to missing fiber annotation interface')
  2329. warning('Without code annotation, the report may be inferior.')
  2330. else
  2331. have_asan_fiber = true
  2332. endif
  2333. config_host_data.set('CONFIG_ASAN_IFACE_FIBER', have_asan_fiber)
  2334. have_inotify_init = cc.has_header_symbol('sys/inotify.h', 'inotify_init')
  2335. have_inotify_init1 = cc.has_header_symbol('sys/inotify.h', 'inotify_init1')
  2336. inotify = not_found
  2337. if (have_inotify_init or have_inotify_init1) and host_os == 'freebsd'
  2338. # libinotify-kqueue
  2339. inotify = cc.find_library('inotify')
  2340. if have_inotify_init
  2341. have_inotify_init = inotify.found()
  2342. endif
  2343. if have_inotify_init1
  2344. have_inotify_init1 = inotify.found()
  2345. endif
  2346. endif
  2347. config_host_data.set('CONFIG_INOTIFY', have_inotify_init)
  2348. config_host_data.set('CONFIG_INOTIFY1', have_inotify_init1)
  2349. # has_header_symbol
  2350. config_host_data.set('CONFIG_BLKZONED',
  2351. cc.has_header_symbol('linux/blkzoned.h', 'BLKOPENZONE'))
  2352. config_host_data.set('CONFIG_EPOLL_CREATE1',
  2353. cc.has_header_symbol('sys/epoll.h', 'epoll_create1'))
  2354. config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE',
  2355. cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_PUNCH_HOLE') and
  2356. cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_KEEP_SIZE'))
  2357. config_host_data.set('CONFIG_FALLOCATE_ZERO_RANGE',
  2358. cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_ZERO_RANGE'))
  2359. config_host_data.set('CONFIG_FIEMAP',
  2360. cc.has_header('linux/fiemap.h') and
  2361. cc.has_header_symbol('linux/fs.h', 'FS_IOC_FIEMAP'))
  2362. config_host_data.set('CONFIG_GETRANDOM',
  2363. cc.has_function('getrandom') and
  2364. cc.has_header_symbol('sys/random.h', 'GRND_NONBLOCK'))
  2365. config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK',
  2366. cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK'))
  2367. config_host_data.set('CONFIG_RTNETLINK',
  2368. cc.has_header_symbol('linux/rtnetlink.h', 'IFLA_PROTO_DOWN'))
  2369. config_host_data.set('CONFIG_SYSMACROS',
  2370. cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
  2371. config_host_data.set('HAVE_OPTRESET',
  2372. cc.has_header_symbol('getopt.h', 'optreset'))
  2373. config_host_data.set('HAVE_IPPROTO_MPTCP',
  2374. cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
  2375. # has_member
  2376. config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
  2377. cc.has_member('struct sigevent', 'sigev_notify_thread_id',
  2378. prefix: '#include <signal.h>'))
  2379. config_host_data.set('HAVE_STRUCT_STAT_ST_ATIM',
  2380. cc.has_member('struct stat', 'st_atim',
  2381. prefix: '#include <sys/stat.h>'))
  2382. config_host_data.set('HAVE_BLK_ZONE_REP_CAPACITY',
  2383. cc.has_member('struct blk_zone', 'capacity',
  2384. prefix: '#include <linux/blkzoned.h>'))
  2385. # has_type
  2386. config_host_data.set('CONFIG_IOVEC',
  2387. cc.has_type('struct iovec',
  2388. prefix: '#include <sys/uio.h>'))
  2389. config_host_data.set('HAVE_UTMPX',
  2390. cc.has_type('struct utmpx',
  2391. prefix: '#include <utmpx.h>'))
  2392. config_host_data.set('CONFIG_EVENTFD', cc.links('''
  2393. #include <sys/eventfd.h>
  2394. int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }'''))
  2395. config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + '''
  2396. #include <unistd.h>
  2397. int main(void) {
  2398. #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
  2399. return fdatasync(0);
  2400. #else
  2401. #error Not supported
  2402. #endif
  2403. }'''))
  2404. has_madvise = cc.links(gnu_source_prefix + '''
  2405. #include <sys/types.h>
  2406. #include <sys/mman.h>
  2407. #include <stddef.h>
  2408. int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }''')
  2409. missing_madvise_proto = false
  2410. if has_madvise
  2411. # Some platforms (illumos and Solaris before Solaris 11) provide madvise()
  2412. # but forget to prototype it. In this case, has_madvise will be true (the
  2413. # test program links despite a compile warning). To detect the
  2414. # missing-prototype case, we try again with a definitely-bogus prototype.
  2415. # This will only compile if the system headers don't provide the prototype;
  2416. # otherwise the conflicting prototypes will cause a compiler error.
  2417. missing_madvise_proto = cc.links(gnu_source_prefix + '''
  2418. #include <sys/types.h>
  2419. #include <sys/mman.h>
  2420. #include <stddef.h>
  2421. extern int madvise(int);
  2422. int main(void) { return madvise(0); }''')
  2423. endif
  2424. config_host_data.set('CONFIG_MADVISE', has_madvise)
  2425. config_host_data.set('HAVE_MADVISE_WITHOUT_PROTOTYPE', missing_madvise_proto)
  2426. config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + '''
  2427. #include <sys/mman.h>
  2428. int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }'''))
  2429. config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + '''
  2430. #include <fcntl.h>
  2431. #if !defined(AT_EMPTY_PATH)
  2432. # error missing definition
  2433. #else
  2434. int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
  2435. #endif'''))
  2436. # On Darwin posix_madvise() has the same return semantics as plain madvise(),
  2437. # i.e. errno is set and -1 is returned. That's not really how POSIX defines the
  2438. # function. On the flip side, it has madvise() which is preferred anyways.
  2439. if host_os != 'darwin'
  2440. config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + '''
  2441. #include <sys/mman.h>
  2442. #include <stddef.h>
  2443. int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }'''))
  2444. endif
  2445. config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(gnu_source_prefix + '''
  2446. #include <pthread.h>
  2447. static void *f(void *p) { return NULL; }
  2448. int main(void)
  2449. {
  2450. pthread_t thread;
  2451. pthread_create(&thread, 0, f, 0);
  2452. pthread_setname_np(thread, "QEMU");
  2453. return 0;
  2454. }''', dependencies: threads))
  2455. config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_prefix + '''
  2456. #include <pthread.h>
  2457. static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
  2458. int main(void)
  2459. {
  2460. pthread_t thread;
  2461. pthread_create(&thread, 0, f, 0);
  2462. return 0;
  2463. }''', dependencies: threads))
  2464. config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(gnu_source_prefix + '''
  2465. #include <pthread.h>
  2466. #include <pthread_np.h>
  2467. static void *f(void *p) { return NULL; }
  2468. int main(void)
  2469. {
  2470. pthread_t thread;
  2471. pthread_create(&thread, 0, f, 0);
  2472. pthread_set_name_np(thread, "QEMU");
  2473. return 0;
  2474. }''', dependencies: threads))
  2475. config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(gnu_source_prefix + '''
  2476. #include <pthread.h>
  2477. #include <time.h>
  2478. int main(void)
  2479. {
  2480. pthread_condattr_t attr
  2481. pthread_condattr_init(&attr);
  2482. pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
  2483. return 0;
  2484. }''', dependencies: threads))
  2485. config_host_data.set('CONFIG_PTHREAD_AFFINITY_NP', cc.links(gnu_source_prefix + '''
  2486. #include <pthread.h>
  2487. static void *f(void *p) { return NULL; }
  2488. int main(void)
  2489. {
  2490. int setsize = CPU_ALLOC_SIZE(64);
  2491. pthread_t thread;
  2492. cpu_set_t *cpuset;
  2493. pthread_create(&thread, 0, f, 0);
  2494. cpuset = CPU_ALLOC(64);
  2495. CPU_ZERO_S(setsize, cpuset);
  2496. pthread_setaffinity_np(thread, setsize, cpuset);
  2497. pthread_getaffinity_np(thread, setsize, cpuset);
  2498. CPU_FREE(cpuset);
  2499. return 0;
  2500. }''', dependencies: threads))
  2501. config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + '''
  2502. #include <sys/signalfd.h>
  2503. #include <stddef.h>
  2504. int main(void) { return signalfd(-1, NULL, SFD_CLOEXEC); }'''))
  2505. config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + '''
  2506. #include <unistd.h>
  2507. #include <fcntl.h>
  2508. #include <limits.h>
  2509. int main(void)
  2510. {
  2511. int len, fd = 0;
  2512. len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
  2513. splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
  2514. return 0;
  2515. }'''))
  2516. config_host_data.set('HAVE_MLOCKALL', cc.links(gnu_source_prefix + '''
  2517. #include <sys/mman.h>
  2518. int main(void) {
  2519. return mlockall(MCL_FUTURE);
  2520. }'''))
  2521. have_l2tpv3 = false
  2522. if get_option('l2tpv3').allowed() and have_system
  2523. have_l2tpv3 = cc.has_type('struct mmsghdr',
  2524. prefix: gnu_source_prefix + '''
  2525. #include <sys/socket.h>
  2526. #include <linux/ip.h>''')
  2527. endif
  2528. config_host_data.set('CONFIG_L2TPV3', have_l2tpv3)
  2529. have_netmap = false
  2530. if get_option('netmap').allowed() and have_system
  2531. have_netmap = cc.compiles('''
  2532. #include <inttypes.h>
  2533. #include <net/if.h>
  2534. #include <net/netmap.h>
  2535. #include <net/netmap_user.h>
  2536. #if (NETMAP_API < 11) || (NETMAP_API > 15)
  2537. #error
  2538. #endif
  2539. int main(void) { return 0; }''')
  2540. if not have_netmap and get_option('netmap').enabled()
  2541. error('Netmap headers not available')
  2542. endif
  2543. endif
  2544. config_host_data.set('CONFIG_NETMAP', have_netmap)
  2545. # Work around a system header bug with some kernel/XFS header
  2546. # versions where they both try to define 'struct fsxattr':
  2547. # xfs headers will not try to redefine structs from linux headers
  2548. # if this macro is set.
  2549. config_host_data.set('HAVE_FSXATTR', cc.links('''
  2550. #include <linux/fs.h>
  2551. struct fsxattr foo;
  2552. int main(void) {
  2553. return 0;
  2554. }'''))
  2555. # Some versions of Mac OS X incorrectly define SIZE_MAX
  2556. config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles('''
  2557. #include <stdint.h>
  2558. #include <stdio.h>
  2559. int main(void) {
  2560. return printf("%zu", SIZE_MAX);
  2561. }''', args: ['-Werror']))
  2562. # See if 64-bit atomic operations are supported.
  2563. # Note that without __atomic builtins, we can only
  2564. # assume atomic loads/stores max at pointer size.
  2565. config_host_data.set('CONFIG_ATOMIC64', cc.links('''
  2566. #include <stdint.h>
  2567. int main(void)
  2568. {
  2569. uint64_t x = 0, y = 0;
  2570. y = __atomic_load_n(&x, __ATOMIC_RELAXED);
  2571. __atomic_store_n(&x, y, __ATOMIC_RELAXED);
  2572. __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
  2573. __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
  2574. __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
  2575. return 0;
  2576. }'''))
  2577. has_int128_type = cc.compiles('''
  2578. __int128_t a;
  2579. __uint128_t b;
  2580. int main(void) { b = a; }''')
  2581. config_host_data.set('CONFIG_INT128_TYPE', has_int128_type)
  2582. has_int128 = has_int128_type and cc.links('''
  2583. __int128_t a;
  2584. __uint128_t b;
  2585. int main (void) {
  2586. a = a + b;
  2587. b = a * b;
  2588. a = a * a;
  2589. return 0;
  2590. }''')
  2591. config_host_data.set('CONFIG_INT128', has_int128)
  2592. if has_int128_type
  2593. # "do we have 128-bit atomics which are handled inline and specifically not
  2594. # via libatomic". The reason we can't use libatomic is documented in the
  2595. # comment starting "GCC is a house divided" in include/qemu/atomic128.h.
  2596. # We only care about these operations on 16-byte aligned pointers, so
  2597. # force 16-byte alignment of the pointer, which may be greater than
  2598. # __alignof(unsigned __int128) for the host.
  2599. atomic_test_128 = '''
  2600. int main(int ac, char **av) {
  2601. __uint128_t *p = __builtin_assume_aligned(av[ac - 1], 16);
  2602. p[1] = __atomic_load_n(&p[0], __ATOMIC_RELAXED);
  2603. __atomic_store_n(&p[2], p[3], __ATOMIC_RELAXED);
  2604. __atomic_compare_exchange_n(&p[4], &p[5], p[6], 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
  2605. return 0;
  2606. }'''
  2607. has_atomic128 = cc.links(atomic_test_128)
  2608. config_host_data.set('CONFIG_ATOMIC128', has_atomic128)
  2609. if not has_atomic128
  2610. # Even with __builtin_assume_aligned, the above test may have failed
  2611. # without optimization enabled. Try again with optimizations locally
  2612. # enabled for the function. See
  2613. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107389
  2614. has_atomic128_opt = cc.links('__attribute__((optimize("O1")))' + atomic_test_128)
  2615. config_host_data.set('CONFIG_ATOMIC128_OPT', has_atomic128_opt)
  2616. if not has_atomic128_opt
  2617. config_host_data.set('CONFIG_CMPXCHG128', cc.links('''
  2618. int main(void)
  2619. {
  2620. __uint128_t x = 0, y = 0;
  2621. __sync_val_compare_and_swap_16(&x, y, x);
  2622. return 0;
  2623. }
  2624. '''))
  2625. endif
  2626. endif
  2627. endif
  2628. config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + '''
  2629. #include <sys/auxv.h>
  2630. int main(void) {
  2631. return getauxval(AT_HWCAP) == 0;
  2632. }'''))
  2633. config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(gnu_source_prefix + '''
  2634. #include <sys/auxv.h>
  2635. int main(void) {
  2636. unsigned long hwcap = 0;
  2637. elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
  2638. return hwcap;
  2639. }'''))
  2640. config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles('''
  2641. #include <linux/usbdevice_fs.h>
  2642. #ifndef USBDEVFS_GET_CAPABILITIES
  2643. #error "USBDEVFS_GET_CAPABILITIES undefined"
  2644. #endif
  2645. #ifndef USBDEVFS_DISCONNECT_CLAIM
  2646. #error "USBDEVFS_DISCONNECT_CLAIM undefined"
  2647. #endif
  2648. int main(void) { return 0; }'''))
  2649. have_keyring = get_option('keyring') \
  2650. .require(host_os == 'linux', error_message: 'keyring is only available on Linux') \
  2651. .require(cc.compiles('''
  2652. #include <errno.h>
  2653. #include <asm/unistd.h>
  2654. #include <linux/keyctl.h>
  2655. #include <sys/syscall.h>
  2656. #include <unistd.h>
  2657. int main(void) {
  2658. return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
  2659. }'''), error_message: 'keyctl syscall not available on this system').allowed()
  2660. config_host_data.set('CONFIG_SECRET_KEYRING', have_keyring)
  2661. have_cpuid_h = cc.links('''
  2662. #include <cpuid.h>
  2663. int main(void) {
  2664. unsigned a, b, c, d;
  2665. unsigned max = __get_cpuid_max(0, 0);
  2666. if (max >= 1) {
  2667. __cpuid(1, a, b, c, d);
  2668. }
  2669. if (max >= 7) {
  2670. __cpuid_count(7, 0, a, b, c, d);
  2671. }
  2672. return 0;
  2673. }''')
  2674. config_host_data.set('CONFIG_CPUID_H', have_cpuid_h)
  2675. # Don't bother to advertise asm/hwprobe.h for old versions that do
  2676. # not contain RISCV_HWPROBE_EXT_ZBA.
  2677. config_host_data.set('CONFIG_ASM_HWPROBE_H',
  2678. cc.has_header_symbol('asm/hwprobe.h',
  2679. 'RISCV_HWPROBE_EXT_ZBA'))
  2680. config_host_data.set('CONFIG_AVX2_OPT', get_option('avx2') \
  2681. .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX2') \
  2682. .require(cc.links('''
  2683. #include <cpuid.h>
  2684. #include <immintrin.h>
  2685. static int __attribute__((target("avx2"))) bar(void *a) {
  2686. __m256i x = *(__m256i *)a;
  2687. return _mm256_testz_si256(x, x);
  2688. }
  2689. int main(int argc, char *argv[]) { return bar(argv[argc - 1]); }
  2690. '''), error_message: 'AVX2 not available').allowed())
  2691. config_host_data.set('CONFIG_AVX512BW_OPT', get_option('avx512bw') \
  2692. .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512BW') \
  2693. .require(cc.links('''
  2694. #include <cpuid.h>
  2695. #include <immintrin.h>
  2696. static int __attribute__((target("avx512bw"))) bar(void *a) {
  2697. __m512i *x = a;
  2698. __m512i res= _mm512_abs_epi8(*x);
  2699. return res[1];
  2700. }
  2701. int main(int argc, char *argv[]) { return bar(argv[0]); }
  2702. '''), error_message: 'AVX512BW not available').allowed())
  2703. # For both AArch64 and AArch32, detect if builtins are available.
  2704. config_host_data.set('CONFIG_ARM_AES_BUILTIN', cc.compiles('''
  2705. #include <arm_neon.h>
  2706. #ifndef __ARM_FEATURE_AES
  2707. __attribute__((target("+crypto")))
  2708. #endif
  2709. void foo(uint8x16_t *p) { *p = vaesmcq_u8(*p); }
  2710. '''))
  2711. if get_option('membarrier').disabled()
  2712. have_membarrier = false
  2713. elif host_os == 'windows'
  2714. have_membarrier = true
  2715. elif host_os == 'linux'
  2716. have_membarrier = cc.compiles('''
  2717. #include <linux/membarrier.h>
  2718. #include <sys/syscall.h>
  2719. #include <unistd.h>
  2720. #include <stdlib.h>
  2721. int main(void) {
  2722. syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
  2723. syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
  2724. exit(0);
  2725. }''')
  2726. endif
  2727. config_host_data.set('CONFIG_MEMBARRIER', get_option('membarrier') \
  2728. .require(have_membarrier, error_message: 'membarrier system call not available') \
  2729. .allowed())
  2730. have_afalg = get_option('crypto_afalg') \
  2731. .require(cc.compiles(gnu_source_prefix + '''
  2732. #include <errno.h>
  2733. #include <sys/types.h>
  2734. #include <sys/socket.h>
  2735. #include <linux/if_alg.h>
  2736. int main(void) {
  2737. int sock;
  2738. sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
  2739. return sock;
  2740. }
  2741. '''), error_message: 'AF_ALG requested but could not be detected').allowed()
  2742. config_host_data.set('CONFIG_AF_ALG', have_afalg)
  2743. config_host_data.set('CONFIG_AF_VSOCK', cc.has_header_symbol(
  2744. 'linux/vm_sockets.h', 'AF_VSOCK',
  2745. prefix: '#include <sys/socket.h>',
  2746. ))
  2747. have_vss = false
  2748. have_vss_sdk = false # old xp/2003 SDK
  2749. if host_os == 'windows' and 'cpp' in all_languages
  2750. have_vss = cxx.compiles('''
  2751. #define __MIDL_user_allocate_free_DEFINED__
  2752. #include <vss.h>
  2753. int main(void) { return VSS_CTX_BACKUP; }''')
  2754. have_vss_sdk = cxx.has_header('vscoordint.h')
  2755. endif
  2756. config_host_data.set('HAVE_VSS_SDK', have_vss_sdk)
  2757. # Older versions of MinGW do not import _lock_file and _unlock_file properly.
  2758. # This was fixed for v6.0.0 with commit b48e3ac8969d.
  2759. if host_os == 'windows'
  2760. config_host_data.set('HAVE__LOCK_FILE', cc.links('''
  2761. #include <stdio.h>
  2762. int main(void) {
  2763. _lock_file(NULL);
  2764. _unlock_file(NULL);
  2765. return 0;
  2766. }''', name: '_lock_file and _unlock_file'))
  2767. endif
  2768. if host_os == 'windows'
  2769. mingw_has_setjmp_longjmp = cc.links('''
  2770. #include <setjmp.h>
  2771. int main(void) {
  2772. /*
  2773. * These functions are not available in setjmp header, but may be
  2774. * available at link time, from libmingwex.a.
  2775. */
  2776. extern int __mingw_setjmp(jmp_buf);
  2777. extern void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);
  2778. jmp_buf env;
  2779. __mingw_setjmp(env);
  2780. __mingw_longjmp(env, 0);
  2781. }
  2782. ''', name: 'mingw setjmp and longjmp')
  2783. if cpu == 'aarch64' and not mingw_has_setjmp_longjmp
  2784. error('mingw must provide setjmp/longjmp for windows-arm64')
  2785. endif
  2786. endif
  2787. ########################
  2788. # Target configuration #
  2789. ########################
  2790. minikconf = find_program('scripts/minikconf.py')
  2791. config_all_accel = {}
  2792. config_all_devices = {}
  2793. config_devices_mak_list = []
  2794. config_devices_h = {}
  2795. config_target_h = {}
  2796. config_target_mak = {}
  2797. disassemblers = {
  2798. 'alpha' : ['CONFIG_ALPHA_DIS'],
  2799. 'avr' : ['CONFIG_AVR_DIS'],
  2800. 'cris' : ['CONFIG_CRIS_DIS'],
  2801. 'hexagon' : ['CONFIG_HEXAGON_DIS'],
  2802. 'hppa' : ['CONFIG_HPPA_DIS'],
  2803. 'i386' : ['CONFIG_I386_DIS'],
  2804. 'x86_64' : ['CONFIG_I386_DIS'],
  2805. 'm68k' : ['CONFIG_M68K_DIS'],
  2806. 'microblaze' : ['CONFIG_MICROBLAZE_DIS'],
  2807. 'mips' : ['CONFIG_MIPS_DIS'],
  2808. 'or1k' : ['CONFIG_OPENRISC_DIS'],
  2809. 'ppc' : ['CONFIG_PPC_DIS'],
  2810. 'riscv' : ['CONFIG_RISCV_DIS'],
  2811. 'rx' : ['CONFIG_RX_DIS'],
  2812. 's390' : ['CONFIG_S390_DIS'],
  2813. 'sh4' : ['CONFIG_SH4_DIS'],
  2814. 'sparc' : ['CONFIG_SPARC_DIS'],
  2815. 'xtensa' : ['CONFIG_XTENSA_DIS'],
  2816. 'loongarch' : ['CONFIG_LOONGARCH_DIS'],
  2817. }
  2818. have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
  2819. host_kconfig = \
  2820. (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \
  2821. (have_tpm ? ['CONFIG_TPM=y'] : []) + \
  2822. (pixman.found() ? ['CONFIG_PIXMAN=y'] : []) + \
  2823. (spice.found() ? ['CONFIG_SPICE=y'] : []) + \
  2824. (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
  2825. (opengl.found() ? ['CONFIG_OPENGL=y'] : []) + \
  2826. (x11.found() ? ['CONFIG_X11=y'] : []) + \
  2827. (fdt.found() ? ['CONFIG_FDT=y'] : []) + \
  2828. (have_vhost_user ? ['CONFIG_VHOST_USER=y'] : []) + \
  2829. (have_vhost_vdpa ? ['CONFIG_VHOST_VDPA=y'] : []) + \
  2830. (have_vhost_kernel ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
  2831. (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
  2832. (host_os == 'linux' ? ['CONFIG_LINUX=y'] : []) + \
  2833. (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : []) + \
  2834. (vfio_user_server_allowed ? ['CONFIG_VFIO_USER_SERVER_ALLOWED=y'] : []) + \
  2835. (hv_balloon ? ['CONFIG_HV_BALLOON_POSSIBLE=y'] : [])
  2836. ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
  2837. default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
  2838. actual_target_dirs = []
  2839. fdt_required = []
  2840. foreach target : target_dirs
  2841. config_target = { 'TARGET_NAME': target.split('-')[0] }
  2842. if target.endswith('linux-user')
  2843. if host_os != 'linux'
  2844. if default_targets
  2845. continue
  2846. endif
  2847. error('Target @0@ is only available on a Linux host'.format(target))
  2848. endif
  2849. config_target += { 'CONFIG_LINUX_USER': 'y' }
  2850. elif target.endswith('bsd-user')
  2851. if host_os not in bsd_oses
  2852. if default_targets
  2853. continue
  2854. endif
  2855. error('Target @0@ is only available on a BSD host'.format(target))
  2856. endif
  2857. config_target += { 'CONFIG_BSD_USER': 'y' }
  2858. elif target.endswith('softmmu')
  2859. config_target += { 'CONFIG_SYSTEM_ONLY': 'y' }
  2860. config_target += { 'CONFIG_SOFTMMU': 'y' }
  2861. endif
  2862. if target.endswith('-user')
  2863. config_target += {
  2864. 'CONFIG_USER_ONLY': 'y',
  2865. 'CONFIG_QEMU_INTERP_PREFIX':
  2866. get_option('interp_prefix').replace('%M', config_target['TARGET_NAME'])
  2867. }
  2868. endif
  2869. target_kconfig = []
  2870. foreach sym: accelerators
  2871. if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
  2872. config_target += { sym: 'y' }
  2873. config_all_accel += { sym: 'y' }
  2874. if target in modular_tcg
  2875. config_target += { 'CONFIG_TCG_MODULAR': 'y' }
  2876. else
  2877. config_target += { 'CONFIG_TCG_BUILTIN': 'y' }
  2878. endif
  2879. target_kconfig += [ sym + '=y' ]
  2880. endif
  2881. endforeach
  2882. if target_kconfig.length() == 0
  2883. if default_targets
  2884. continue
  2885. endif
  2886. error('No accelerator available for target @0@'.format(target))
  2887. endif
  2888. config_target += keyval.load('configs/targets' / target + '.mak')
  2889. config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
  2890. if 'TARGET_NEED_FDT' in config_target and not fdt.found()
  2891. if default_targets
  2892. warning('Disabling ' + target + ' due to missing libfdt')
  2893. else
  2894. fdt_required += target
  2895. endif
  2896. continue
  2897. endif
  2898. actual_target_dirs += target
  2899. # Add default keys
  2900. if 'TARGET_BASE_ARCH' not in config_target
  2901. config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
  2902. endif
  2903. if 'TARGET_ABI_DIR' not in config_target
  2904. config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']}
  2905. endif
  2906. if 'TARGET_BIG_ENDIAN' not in config_target
  2907. config_target += {'TARGET_BIG_ENDIAN': 'n'}
  2908. endif
  2909. foreach k, v: disassemblers
  2910. if host_arch.startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
  2911. foreach sym: v
  2912. config_target += { sym: 'y' }
  2913. endforeach
  2914. endif
  2915. endforeach
  2916. config_target_data = configuration_data()
  2917. foreach k, v: config_target
  2918. if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
  2919. # do nothing
  2920. elif ignored.contains(k)
  2921. # do nothing
  2922. elif k == 'TARGET_BASE_ARCH'
  2923. # Note that TARGET_BASE_ARCH ends up in config-target.h but it is
  2924. # not used to select files from sourcesets.
  2925. config_target_data.set('TARGET_' + v.to_upper(), 1)
  2926. elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX'
  2927. config_target_data.set_quoted(k, v)
  2928. elif v == 'y'
  2929. config_target_data.set(k, 1)
  2930. elif v == 'n'
  2931. config_target_data.set(k, 0)
  2932. else
  2933. config_target_data.set(k, v)
  2934. endif
  2935. endforeach
  2936. config_target_data.set('QEMU_ARCH',
  2937. 'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper())
  2938. config_target_h += {target: configure_file(output: target + '-config-target.h',
  2939. configuration: config_target_data)}
  2940. if target.endswith('-softmmu')
  2941. target_kconfig += 'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'
  2942. target_kconfig += 'CONFIG_TARGET_BIG_ENDIAN=' + config_target['TARGET_BIG_ENDIAN']
  2943. config_input = meson.get_external_property(target, 'default')
  2944. config_devices_mak = target + '-config-devices.mak'
  2945. config_devices_mak = configure_file(
  2946. input: ['configs/devices' / target / config_input + '.mak', 'Kconfig'],
  2947. output: config_devices_mak,
  2948. depfile: config_devices_mak + '.d',
  2949. capture: true,
  2950. command: [minikconf,
  2951. get_option('default_devices') ? '--defconfig' : '--allnoconfig',
  2952. config_devices_mak, '@DEPFILE@', '@INPUT@',
  2953. host_kconfig, target_kconfig])
  2954. config_devices_data = configuration_data()
  2955. config_devices = keyval.load(config_devices_mak)
  2956. foreach k, v: config_devices
  2957. config_devices_data.set(k, 1)
  2958. endforeach
  2959. config_devices_mak_list += config_devices_mak
  2960. config_devices_h += {target: configure_file(output: target + '-config-devices.h',
  2961. configuration: config_devices_data)}
  2962. config_target += config_devices
  2963. config_all_devices += config_devices
  2964. endif
  2965. config_target_mak += {target: config_target}
  2966. endforeach
  2967. target_dirs = actual_target_dirs
  2968. target_configs_h = []
  2969. foreach target: target_dirs
  2970. target_configs_h += config_target_h[target]
  2971. target_configs_h += config_devices_h.get(target, [])
  2972. endforeach
  2973. genh += custom_target('config-poison.h',
  2974. input: [target_configs_h],
  2975. output: 'config-poison.h',
  2976. capture: true,
  2977. command: [find_program('scripts/make-config-poison.sh'),
  2978. target_configs_h])
  2979. if fdt_required.length() > 0
  2980. error('fdt disabled but required by targets ' + ', '.join(fdt_required))
  2981. endif
  2982. ###############
  2983. # Subprojects #
  2984. ###############
  2985. libvfio_user_dep = not_found
  2986. if have_system and vfio_user_server_allowed
  2987. libvfio_user_proj = subproject('libvfio-user', required: true)
  2988. libvfio_user_dep = libvfio_user_proj.get_variable('libvfio_user_dep')
  2989. endif
  2990. vhost_user = not_found
  2991. if host_os == 'linux' and have_vhost_user
  2992. libvhost_user = subproject('libvhost-user')
  2993. vhost_user = libvhost_user.get_variable('vhost_user_dep')
  2994. endif
  2995. libvduse = not_found
  2996. if have_libvduse
  2997. libvduse_proj = subproject('libvduse')
  2998. libvduse = libvduse_proj.get_variable('libvduse_dep')
  2999. endif
  3000. #####################
  3001. # Generated sources #
  3002. #####################
  3003. genh += configure_file(output: 'config-host.h', configuration: config_host_data)
  3004. hxtool = find_program('scripts/hxtool')
  3005. shaderinclude = find_program('scripts/shaderinclude.py')
  3006. qapi_gen = find_program('scripts/qapi-gen.py')
  3007. qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py',
  3008. meson.current_source_dir() / 'scripts/qapi/commands.py',
  3009. meson.current_source_dir() / 'scripts/qapi/common.py',
  3010. meson.current_source_dir() / 'scripts/qapi/error.py',
  3011. meson.current_source_dir() / 'scripts/qapi/events.py',
  3012. meson.current_source_dir() / 'scripts/qapi/expr.py',
  3013. meson.current_source_dir() / 'scripts/qapi/gen.py',
  3014. meson.current_source_dir() / 'scripts/qapi/introspect.py',
  3015. meson.current_source_dir() / 'scripts/qapi/main.py',
  3016. meson.current_source_dir() / 'scripts/qapi/parser.py',
  3017. meson.current_source_dir() / 'scripts/qapi/schema.py',
  3018. meson.current_source_dir() / 'scripts/qapi/source.py',
  3019. meson.current_source_dir() / 'scripts/qapi/types.py',
  3020. meson.current_source_dir() / 'scripts/qapi/visit.py',
  3021. meson.current_source_dir() / 'scripts/qapi-gen.py'
  3022. ]
  3023. tracetool = [
  3024. python, files('scripts/tracetool.py'),
  3025. '--backend=' + ','.join(get_option('trace_backends'))
  3026. ]
  3027. tracetool_depends = files(
  3028. 'scripts/tracetool/backend/log.py',
  3029. 'scripts/tracetool/backend/__init__.py',
  3030. 'scripts/tracetool/backend/dtrace.py',
  3031. 'scripts/tracetool/backend/ftrace.py',
  3032. 'scripts/tracetool/backend/simple.py',
  3033. 'scripts/tracetool/backend/syslog.py',
  3034. 'scripts/tracetool/backend/ust.py',
  3035. 'scripts/tracetool/format/ust_events_c.py',
  3036. 'scripts/tracetool/format/ust_events_h.py',
  3037. 'scripts/tracetool/format/__init__.py',
  3038. 'scripts/tracetool/format/d.py',
  3039. 'scripts/tracetool/format/simpletrace_stap.py',
  3040. 'scripts/tracetool/format/c.py',
  3041. 'scripts/tracetool/format/h.py',
  3042. 'scripts/tracetool/format/log_stap.py',
  3043. 'scripts/tracetool/format/stap.py',
  3044. 'scripts/tracetool/__init__.py',
  3045. )
  3046. qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
  3047. meson.current_source_dir(),
  3048. get_option('pkgversion'), meson.project_version()]
  3049. qemu_version = custom_target('qemu-version.h',
  3050. output: 'qemu-version.h',
  3051. command: qemu_version_cmd,
  3052. capture: true,
  3053. build_by_default: true,
  3054. build_always_stale: true)
  3055. genh += qemu_version
  3056. hxdep = []
  3057. hx_headers = [
  3058. ['qemu-options.hx', 'qemu-options.def'],
  3059. ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
  3060. ]
  3061. if have_system
  3062. hx_headers += [
  3063. ['hmp-commands.hx', 'hmp-commands.h'],
  3064. ['hmp-commands-info.hx', 'hmp-commands-info.h'],
  3065. ]
  3066. endif
  3067. foreach d : hx_headers
  3068. hxdep += custom_target(d[1],
  3069. input: files(d[0]),
  3070. output: d[1],
  3071. capture: true,
  3072. command: [hxtool, '-h', '@INPUT0@'])
  3073. endforeach
  3074. genh += hxdep
  3075. ###############
  3076. # Trace files #
  3077. ###############
  3078. # TODO: add each directory to the subdirs from its own meson.build, once
  3079. # we have those
  3080. trace_events_subdirs = [
  3081. 'crypto',
  3082. 'qapi',
  3083. 'qom',
  3084. 'monitor',
  3085. 'util',
  3086. 'gdbstub',
  3087. ]
  3088. if have_linux_user
  3089. trace_events_subdirs += [ 'linux-user' ]
  3090. endif
  3091. if have_bsd_user
  3092. trace_events_subdirs += [ 'bsd-user' ]
  3093. endif
  3094. if have_block
  3095. trace_events_subdirs += [
  3096. 'authz',
  3097. 'block',
  3098. 'chardev',
  3099. 'io',
  3100. 'nbd',
  3101. 'scsi',
  3102. ]
  3103. endif
  3104. if have_system
  3105. trace_events_subdirs += [
  3106. 'accel/kvm',
  3107. 'audio',
  3108. 'backends',
  3109. 'backends/tpm',
  3110. 'ebpf',
  3111. 'hw/9pfs',
  3112. 'hw/acpi',
  3113. 'hw/adc',
  3114. 'hw/alpha',
  3115. 'hw/arm',
  3116. 'hw/audio',
  3117. 'hw/block',
  3118. 'hw/char',
  3119. 'hw/display',
  3120. 'hw/dma',
  3121. 'hw/fsi',
  3122. 'hw/hyperv',
  3123. 'hw/i2c',
  3124. 'hw/i386',
  3125. 'hw/i386/xen',
  3126. 'hw/i386/kvm',
  3127. 'hw/ide',
  3128. 'hw/input',
  3129. 'hw/intc',
  3130. 'hw/isa',
  3131. 'hw/mem',
  3132. 'hw/mips',
  3133. 'hw/misc',
  3134. 'hw/misc/macio',
  3135. 'hw/net',
  3136. 'hw/net/can',
  3137. 'hw/nubus',
  3138. 'hw/nvme',
  3139. 'hw/nvram',
  3140. 'hw/pci',
  3141. 'hw/pci-host',
  3142. 'hw/ppc',
  3143. 'hw/rtc',
  3144. 'hw/s390x',
  3145. 'hw/scsi',
  3146. 'hw/sd',
  3147. 'hw/sh4',
  3148. 'hw/sparc',
  3149. 'hw/sparc64',
  3150. 'hw/ssi',
  3151. 'hw/timer',
  3152. 'hw/tpm',
  3153. 'hw/ufs',
  3154. 'hw/usb',
  3155. 'hw/vfio',
  3156. 'hw/virtio',
  3157. 'hw/watchdog',
  3158. 'hw/xen',
  3159. 'hw/gpio',
  3160. 'migration',
  3161. 'net',
  3162. 'system',
  3163. 'ui',
  3164. 'hw/remote',
  3165. ]
  3166. endif
  3167. if have_system or have_user
  3168. trace_events_subdirs += [
  3169. 'accel/tcg',
  3170. 'hw/core',
  3171. 'target/arm',
  3172. 'target/arm/hvf',
  3173. 'target/hppa',
  3174. 'target/i386',
  3175. 'target/i386/kvm',
  3176. 'target/loongarch',
  3177. 'target/mips/tcg',
  3178. 'target/ppc',
  3179. 'target/riscv',
  3180. 'target/s390x',
  3181. 'target/s390x/kvm',
  3182. 'target/sparc',
  3183. ]
  3184. endif
  3185. ###################
  3186. # Collect sources #
  3187. ###################
  3188. authz_ss = ss.source_set()
  3189. blockdev_ss = ss.source_set()
  3190. block_ss = ss.source_set()
  3191. chardev_ss = ss.source_set()
  3192. common_ss = ss.source_set()
  3193. crypto_ss = ss.source_set()
  3194. hwcore_ss = ss.source_set()
  3195. io_ss = ss.source_set()
  3196. qmp_ss = ss.source_set()
  3197. qom_ss = ss.source_set()
  3198. system_ss = ss.source_set()
  3199. specific_fuzz_ss = ss.source_set()
  3200. specific_ss = ss.source_set()
  3201. stub_ss = ss.source_set()
  3202. trace_ss = ss.source_set()
  3203. user_ss = ss.source_set()
  3204. util_ss = ss.source_set()
  3205. # accel modules
  3206. qtest_module_ss = ss.source_set()
  3207. tcg_module_ss = ss.source_set()
  3208. modules = {}
  3209. target_modules = {}
  3210. hw_arch = {}
  3211. target_arch = {}
  3212. target_system_arch = {}
  3213. target_user_arch = {}
  3214. # NOTE: the trace/ subdirectory needs the qapi_trace_events variable
  3215. # that is filled in by qapi/.
  3216. subdir('qapi')
  3217. subdir('qobject')
  3218. subdir('stubs')
  3219. subdir('trace')
  3220. subdir('util')
  3221. subdir('qom')
  3222. subdir('authz')
  3223. subdir('crypto')
  3224. subdir('ui')
  3225. subdir('gdbstub')
  3226. if have_system
  3227. subdir('hw')
  3228. else
  3229. subdir('hw/core')
  3230. endif
  3231. if enable_modules
  3232. libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
  3233. modulecommon = declare_dependency(objects: libmodulecommon.extract_all_objects(recursive: false), compile_args: '-DBUILD_DSO')
  3234. endif
  3235. qom_ss = qom_ss.apply({})
  3236. libqom = static_library('qom', qom_ss.sources() + genh,
  3237. dependencies: [qom_ss.dependencies()],
  3238. build_by_default: false)
  3239. qom = declare_dependency(objects: libqom.extract_all_objects(recursive: false),
  3240. dependencies: qom_ss.dependencies())
  3241. event_loop_base = files('event-loop-base.c')
  3242. event_loop_base = static_library('event-loop-base',
  3243. sources: event_loop_base + genh,
  3244. build_by_default: false)
  3245. event_loop_base = declare_dependency(objects: event_loop_base.extract_all_objects(recursive: false),
  3246. dependencies: [qom])
  3247. stub_ss = stub_ss.apply({})
  3248. util_ss.add_all(trace_ss)
  3249. util_ss = util_ss.apply({})
  3250. libqemuutil = static_library('qemuutil',
  3251. build_by_default: false,
  3252. sources: util_ss.sources() + stub_ss.sources() + genh,
  3253. dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc])
  3254. qemuutil = declare_dependency(link_with: libqemuutil,
  3255. sources: genh + version_res,
  3256. dependencies: [event_loop_base])
  3257. if have_system or have_user
  3258. decodetree = generator(find_program('scripts/decodetree.py'),
  3259. output: 'decode-@BASENAME@.c.inc',
  3260. arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
  3261. subdir('libdecnumber')
  3262. subdir('target')
  3263. endif
  3264. subdir('audio')
  3265. subdir('io')
  3266. subdir('chardev')
  3267. subdir('fsdev')
  3268. subdir('dump')
  3269. if have_block
  3270. block_ss.add(files(
  3271. 'block.c',
  3272. 'blockjob.c',
  3273. 'job.c',
  3274. 'qemu-io-cmds.c',
  3275. ))
  3276. if config_host_data.get('CONFIG_REPLICATION')
  3277. block_ss.add(files('replication.c'))
  3278. endif
  3279. subdir('nbd')
  3280. subdir('scsi')
  3281. subdir('block')
  3282. blockdev_ss.add(files(
  3283. 'blockdev.c',
  3284. 'blockdev-nbd.c',
  3285. 'iothread.c',
  3286. 'job-qmp.c',
  3287. ))
  3288. # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
  3289. # os-win32.c does not
  3290. if host_os == 'windows'
  3291. system_ss.add(files('os-win32.c'))
  3292. else
  3293. blockdev_ss.add(files('os-posix.c'))
  3294. endif
  3295. endif
  3296. common_ss.add(files('cpu-common.c'))
  3297. specific_ss.add(files('cpu-target.c'))
  3298. subdir('system')
  3299. # Work around a gcc bug/misfeature wherein constant propagation looks
  3300. # through an alias:
  3301. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99696
  3302. # to guess that a const variable is always zero. Without lto, this is
  3303. # impossible, as the alias is restricted to page-vary-common.c. Indeed,
  3304. # without lto, not even the alias is required -- we simply use different
  3305. # declarations in different compilation units.
  3306. pagevary = files('page-vary-common.c')
  3307. if get_option('b_lto')
  3308. pagevary_flags = ['-fno-lto']
  3309. if get_option('cfi')
  3310. pagevary_flags += '-fno-sanitize=cfi-icall'
  3311. endif
  3312. pagevary = static_library('page-vary-common', sources: pagevary + genh,
  3313. c_args: pagevary_flags)
  3314. pagevary = declare_dependency(link_with: pagevary)
  3315. endif
  3316. common_ss.add(pagevary)
  3317. specific_ss.add(files('page-target.c', 'page-vary-target.c'))
  3318. subdir('backends')
  3319. subdir('disas')
  3320. subdir('migration')
  3321. subdir('monitor')
  3322. subdir('net')
  3323. subdir('replay')
  3324. subdir('semihosting')
  3325. subdir('stats')
  3326. subdir('tcg')
  3327. subdir('fpu')
  3328. subdir('accel')
  3329. subdir('plugins')
  3330. subdir('ebpf')
  3331. common_user_inc = []
  3332. subdir('common-user')
  3333. subdir('bsd-user')
  3334. subdir('linux-user')
  3335. # needed for fuzzing binaries
  3336. subdir('tests/qtest/libqos')
  3337. subdir('tests/qtest/fuzz')
  3338. # accel modules
  3339. tcg_real_module_ss = ss.source_set()
  3340. tcg_real_module_ss.add_all(when: 'CONFIG_TCG_MODULAR', if_true: tcg_module_ss)
  3341. specific_ss.add_all(when: 'CONFIG_TCG_BUILTIN', if_true: tcg_module_ss)
  3342. target_modules += { 'accel' : { 'qtest': qtest_module_ss,
  3343. 'tcg': tcg_real_module_ss }}
  3344. ##############################################
  3345. # Internal static_libraries and dependencies #
  3346. ##############################################
  3347. modinfo_collect = find_program('scripts/modinfo-collect.py')
  3348. modinfo_generate = find_program('scripts/modinfo-generate.py')
  3349. modinfo_files = []
  3350. block_mods = []
  3351. system_mods = []
  3352. emulator_modules = []
  3353. foreach d, list : modules
  3354. if not (d == 'block' ? have_block : have_system)
  3355. continue
  3356. endif
  3357. foreach m, module_ss : list
  3358. if enable_modules
  3359. module_ss.add(modulecommon)
  3360. module_ss = module_ss.apply(config_all_devices, strict: false)
  3361. sl = static_library(d + '-' + m, [genh, module_ss.sources()],
  3362. dependencies: module_ss.dependencies(), pic: true)
  3363. if d == 'block'
  3364. block_mods += sl
  3365. else
  3366. system_mods += sl
  3367. endif
  3368. emulator_modules += shared_module(sl.name(),
  3369. name_prefix: '',
  3370. objects: sl.extract_all_objects(recursive: false),
  3371. dependencies: module_ss.dependencies(),
  3372. install: true,
  3373. install_dir: qemu_moddir)
  3374. if module_ss.sources() != []
  3375. # FIXME: Should use sl.extract_all_objects(recursive: true) as
  3376. # input. Sources can be used multiple times but objects are
  3377. # unique when it comes to lookup in compile_commands.json.
  3378. # Depnds on a mesion version with
  3379. # https://github.com/mesonbuild/meson/pull/8900
  3380. modinfo_files += custom_target(d + '-' + m + '.modinfo',
  3381. output: d + '-' + m + '.modinfo',
  3382. input: module_ss.sources() + genh,
  3383. capture: true,
  3384. command: [modinfo_collect, module_ss.sources()])
  3385. endif
  3386. else
  3387. if d == 'block'
  3388. block_ss.add_all(module_ss)
  3389. else
  3390. system_ss.add_all(module_ss)
  3391. endif
  3392. endif
  3393. endforeach
  3394. endforeach
  3395. foreach d, list : target_modules
  3396. foreach m, module_ss : list
  3397. if enable_modules
  3398. module_ss.add(modulecommon)
  3399. foreach target : target_dirs
  3400. if target.endswith('-softmmu')
  3401. config_target = config_target_mak[target]
  3402. target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
  3403. c_args = ['-DCOMPILING_PER_TARGET',
  3404. '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
  3405. '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
  3406. target_module_ss = module_ss.apply(config_target, strict: false)
  3407. if target_module_ss.sources() != []
  3408. module_name = d + '-' + m + '-' + config_target['TARGET_NAME']
  3409. sl = static_library(module_name,
  3410. [genh, target_module_ss.sources()],
  3411. dependencies: target_module_ss.dependencies(),
  3412. include_directories: target_inc,
  3413. c_args: c_args,
  3414. pic: true)
  3415. system_mods += sl
  3416. emulator_modules += shared_module(sl.name(),
  3417. name_prefix: '',
  3418. objects: sl.extract_all_objects(recursive: false),
  3419. dependencies: target_module_ss.dependencies(),
  3420. install: true,
  3421. install_dir: qemu_moddir)
  3422. # FIXME: Should use sl.extract_all_objects(recursive: true) too.
  3423. modinfo_files += custom_target(module_name + '.modinfo',
  3424. output: module_name + '.modinfo',
  3425. input: target_module_ss.sources() + genh,
  3426. capture: true,
  3427. command: [modinfo_collect, '--target', target, target_module_ss.sources()])
  3428. endif
  3429. endif
  3430. endforeach
  3431. else
  3432. specific_ss.add_all(module_ss)
  3433. endif
  3434. endforeach
  3435. endforeach
  3436. if enable_modules
  3437. foreach target : target_dirs
  3438. if target.endswith('-softmmu')
  3439. config_target = config_target_mak[target]
  3440. config_devices_mak = target + '-config-devices.mak'
  3441. modinfo_src = custom_target('modinfo-' + target + '.c',
  3442. output: 'modinfo-' + target + '.c',
  3443. input: modinfo_files,
  3444. command: [modinfo_generate, '--devices', config_devices_mak, '@INPUT@'],
  3445. capture: true)
  3446. modinfo_lib = static_library('modinfo-' + target + '.c', modinfo_src)
  3447. modinfo_dep = declare_dependency(link_with: modinfo_lib)
  3448. arch = config_target['TARGET_NAME'] == 'sparc64' ? 'sparc64' : config_target['TARGET_BASE_ARCH']
  3449. hw_arch[arch].add(modinfo_dep)
  3450. endif
  3451. endforeach
  3452. if emulator_modules.length() > 0
  3453. alias_target('modules', emulator_modules)
  3454. endif
  3455. endif
  3456. nm = find_program('nm')
  3457. undefsym = find_program('scripts/undefsym.py')
  3458. block_syms = custom_target('block.syms', output: 'block.syms',
  3459. input: [libqemuutil, block_mods],
  3460. capture: true,
  3461. command: [undefsym, nm, '@INPUT@'])
  3462. qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
  3463. input: [libqemuutil, system_mods],
  3464. capture: true,
  3465. command: [undefsym, nm, '@INPUT@'])
  3466. authz_ss = authz_ss.apply({})
  3467. libauthz = static_library('authz', authz_ss.sources() + genh,
  3468. dependencies: [authz_ss.dependencies()],
  3469. build_by_default: false)
  3470. authz = declare_dependency(objects: libauthz.extract_all_objects(recursive: false),
  3471. dependencies: [authz_ss.dependencies(), qom])
  3472. crypto_ss = crypto_ss.apply({})
  3473. libcrypto = static_library('crypto', crypto_ss.sources() + genh,
  3474. dependencies: [crypto_ss.dependencies()],
  3475. build_by_default: false)
  3476. crypto = declare_dependency(objects: libcrypto.extract_all_objects(recursive: false),
  3477. dependencies: [crypto_ss.dependencies(), authz, qom])
  3478. io_ss = io_ss.apply({})
  3479. libio = static_library('io', io_ss.sources() + genh,
  3480. dependencies: [io_ss.dependencies()],
  3481. link_with: libqemuutil,
  3482. build_by_default: false)
  3483. io = declare_dependency(objects: libio.extract_all_objects(recursive: false),
  3484. dependencies: [io_ss.dependencies(), crypto, qom])
  3485. libmigration = static_library('migration', sources: migration_files + genh,
  3486. build_by_default: false)
  3487. migration = declare_dependency(objects: libmigration.extract_all_objects(recursive: false),
  3488. dependencies: [qom, io])
  3489. system_ss.add(migration)
  3490. block_ss = block_ss.apply({})
  3491. libblock = static_library('block', block_ss.sources() + genh,
  3492. dependencies: block_ss.dependencies(),
  3493. build_by_default: false)
  3494. block = declare_dependency(objects: libblock.extract_all_objects(recursive: false),
  3495. dependencies: [block_ss.dependencies(), crypto, io])
  3496. blockdev_ss = blockdev_ss.apply({})
  3497. libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
  3498. dependencies: blockdev_ss.dependencies(),
  3499. build_by_default: false)
  3500. blockdev = declare_dependency(objects: libblockdev.extract_all_objects(recursive: false),
  3501. dependencies: [blockdev_ss.dependencies(), block, event_loop_base])
  3502. qmp_ss = qmp_ss.apply({})
  3503. libqmp = static_library('qmp', qmp_ss.sources() + genh,
  3504. dependencies: qmp_ss.dependencies(),
  3505. build_by_default: false)
  3506. qmp = declare_dependency(objects: libqmp.extract_all_objects(recursive: false),
  3507. dependencies: qmp_ss.dependencies())
  3508. libchardev = static_library('chardev', chardev_ss.sources() + genh,
  3509. dependencies: chardev_ss.dependencies(),
  3510. build_by_default: false)
  3511. chardev = declare_dependency(objects: libchardev.extract_all_objects(recursive: false),
  3512. dependencies: chardev_ss.dependencies())
  3513. hwcore_ss = hwcore_ss.apply({})
  3514. libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
  3515. build_by_default: false)
  3516. hwcore = declare_dependency(objects: libhwcore.extract_all_objects(recursive: false))
  3517. common_ss.add(hwcore)
  3518. ###########
  3519. # Targets #
  3520. ###########
  3521. system_ss.add(authz, blockdev, chardev, crypto, io, qmp)
  3522. common_ss.add(qom, qemuutil)
  3523. common_ss.add_all(when: 'CONFIG_SYSTEM_ONLY', if_true: [system_ss])
  3524. common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
  3525. # Note that this library is never used directly (only through extract_objects)
  3526. # and is not built by default; therefore, source files not used by the build
  3527. # configuration will be in build.ninja, but are never built by default.
  3528. common_all = static_library('common',
  3529. build_by_default: false,
  3530. sources: common_ss.all_sources() + genh,
  3531. include_directories: common_user_inc,
  3532. implicit_include_directories: false,
  3533. dependencies: common_ss.all_dependencies())
  3534. feature_to_c = find_program('scripts/feature_to_c.py')
  3535. if host_os == 'darwin'
  3536. entitlement = find_program('scripts/entitlement.sh')
  3537. endif
  3538. traceable = []
  3539. emulators = {}
  3540. foreach target : target_dirs
  3541. config_target = config_target_mak[target]
  3542. target_name = config_target['TARGET_NAME']
  3543. target_base_arch = config_target['TARGET_BASE_ARCH']
  3544. arch_srcs = [config_target_h[target]]
  3545. arch_deps = []
  3546. c_args = ['-DCOMPILING_PER_TARGET',
  3547. '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
  3548. '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
  3549. link_args = emulator_link_args
  3550. target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
  3551. if host_os == 'linux'
  3552. target_inc += include_directories('linux-headers', is_system: true)
  3553. endif
  3554. if target.endswith('-softmmu')
  3555. target_type='system'
  3556. t = target_system_arch[target_base_arch].apply(config_target, strict: false)
  3557. arch_srcs += t.sources()
  3558. arch_deps += t.dependencies()
  3559. hw_dir = target_name == 'sparc64' ? 'sparc64' : target_base_arch
  3560. if hw_arch.has_key(hw_dir)
  3561. hw = hw_arch[hw_dir].apply(config_target, strict: false)
  3562. arch_srcs += hw.sources()
  3563. arch_deps += hw.dependencies()
  3564. endif
  3565. arch_srcs += config_devices_h[target]
  3566. link_args += ['@block.syms', '@qemu.syms']
  3567. else
  3568. abi = config_target['TARGET_ABI_DIR']
  3569. target_type='user'
  3570. target_inc += common_user_inc
  3571. if target_base_arch in target_user_arch
  3572. t = target_user_arch[target_base_arch].apply(config_target, strict: false)
  3573. arch_srcs += t.sources()
  3574. arch_deps += t.dependencies()
  3575. endif
  3576. if 'CONFIG_LINUX_USER' in config_target
  3577. base_dir = 'linux-user'
  3578. endif
  3579. if 'CONFIG_BSD_USER' in config_target
  3580. base_dir = 'bsd-user'
  3581. target_inc += include_directories('bsd-user/' / host_os)
  3582. target_inc += include_directories('bsd-user/host/' / host_arch)
  3583. dir = base_dir / abi
  3584. arch_srcs += files(dir / 'signal.c', dir / 'target_arch_cpu.c')
  3585. endif
  3586. target_inc += include_directories(
  3587. base_dir,
  3588. base_dir / abi,
  3589. )
  3590. if 'CONFIG_LINUX_USER' in config_target
  3591. dir = base_dir / abi
  3592. arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
  3593. if config_target.has_key('TARGET_SYSTBL_ABI')
  3594. arch_srcs += \
  3595. syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
  3596. extra_args : config_target['TARGET_SYSTBL_ABI'])
  3597. endif
  3598. endif
  3599. endif
  3600. if 'TARGET_XML_FILES' in config_target
  3601. gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
  3602. output: target + '-gdbstub-xml.c',
  3603. input: files(config_target['TARGET_XML_FILES'].split()),
  3604. command: [feature_to_c, '@INPUT@'],
  3605. capture: true)
  3606. arch_srcs += gdbstub_xml
  3607. endif
  3608. t = target_arch[target_base_arch].apply(config_target, strict: false)
  3609. arch_srcs += t.sources()
  3610. arch_deps += t.dependencies()
  3611. target_common = common_ss.apply(config_target, strict: false)
  3612. objects = common_all.extract_objects(target_common.sources())
  3613. arch_deps += target_common.dependencies()
  3614. target_specific = specific_ss.apply(config_target, strict: false)
  3615. arch_srcs += target_specific.sources()
  3616. arch_deps += target_specific.dependencies()
  3617. # allow using headers from the dependencies but do not include the sources,
  3618. # because this emulator only needs those in "objects". For external
  3619. # dependencies, the full dependency is included below in the executable.
  3620. lib_deps = []
  3621. foreach dep : arch_deps
  3622. lib_deps += dep.partial_dependency(compile_args: true, includes: true)
  3623. endforeach
  3624. lib = static_library('qemu-' + target,
  3625. sources: arch_srcs + genh,
  3626. dependencies: lib_deps,
  3627. objects: objects,
  3628. include_directories: target_inc,
  3629. c_args: c_args,
  3630. build_by_default: false)
  3631. if target.endswith('-softmmu')
  3632. execs = [{
  3633. 'name': 'qemu-system-' + target_name,
  3634. 'win_subsystem': 'console',
  3635. 'sources': files('system/main.c'),
  3636. 'dependencies': []
  3637. }]
  3638. if host_os == 'windows' and (sdl.found() or gtk.found())
  3639. execs += [{
  3640. 'name': 'qemu-system-' + target_name + 'w',
  3641. 'win_subsystem': 'windows',
  3642. 'sources': files('system/main.c'),
  3643. 'dependencies': []
  3644. }]
  3645. endif
  3646. if get_option('fuzzing')
  3647. specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
  3648. execs += [{
  3649. 'name': 'qemu-fuzz-' + target_name,
  3650. 'win_subsystem': 'console',
  3651. 'sources': specific_fuzz.sources(),
  3652. 'dependencies': specific_fuzz.dependencies(),
  3653. }]
  3654. endif
  3655. else
  3656. execs = [{
  3657. 'name': 'qemu-' + target_name,
  3658. 'win_subsystem': 'console',
  3659. 'sources': [],
  3660. 'dependencies': []
  3661. }]
  3662. endif
  3663. foreach exe: execs
  3664. exe_name = exe['name']
  3665. if host_os == 'darwin'
  3666. exe_name += '-unsigned'
  3667. endif
  3668. emulator = executable(exe_name, exe['sources'],
  3669. install: true,
  3670. c_args: c_args,
  3671. dependencies: arch_deps + exe['dependencies'],
  3672. objects: lib.extract_all_objects(recursive: true),
  3673. link_depends: [block_syms, qemu_syms],
  3674. link_args: link_args,
  3675. win_subsystem: exe['win_subsystem'])
  3676. if host_os == 'darwin'
  3677. icon = 'pc-bios/qemu.rsrc'
  3678. build_input = [emulator, files(icon)]
  3679. install_input = [
  3680. get_option('bindir') / exe_name,
  3681. meson.current_source_dir() / icon
  3682. ]
  3683. if 'CONFIG_HVF' in config_target
  3684. entitlements = 'accel/hvf/entitlements.plist'
  3685. build_input += files(entitlements)
  3686. install_input += meson.current_source_dir() / entitlements
  3687. endif
  3688. emulators += {exe['name'] : custom_target(exe['name'],
  3689. input: build_input,
  3690. output: exe['name'],
  3691. command: [entitlement, '@OUTPUT@', '@INPUT@'])
  3692. }
  3693. meson.add_install_script(entitlement, '--install',
  3694. get_option('bindir') / exe['name'],
  3695. install_input)
  3696. else
  3697. emulators += {exe['name']: emulator}
  3698. endif
  3699. traceable += [{
  3700. 'exe': exe['name'],
  3701. 'probe-prefix': 'qemu.' + target_type + '.' + target_name,
  3702. }]
  3703. endforeach
  3704. endforeach
  3705. # Other build targets
  3706. if get_option('plugins')
  3707. install_headers('include/qemu/qemu-plugin.h')
  3708. if host_os == 'windows'
  3709. # On windows, we want to deliver the qemu_plugin_api.lib file in the qemu installer,
  3710. # so that plugin authors can compile against it.
  3711. install_data(win32_qemu_plugin_api_lib, install_dir: 'lib')
  3712. endif
  3713. endif
  3714. subdir('qga')
  3715. # Don't build qemu-keymap if xkbcommon is not explicitly enabled
  3716. # when we don't build tools or system
  3717. if xkbcommon.found()
  3718. # used for the update-keymaps target, so include rules even if !have_tools
  3719. qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
  3720. dependencies: [qemuutil, xkbcommon], install: have_tools)
  3721. endif
  3722. if have_tools
  3723. qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
  3724. link_args: '@block.syms', link_depends: block_syms,
  3725. dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
  3726. qemu_io = executable('qemu-io', files('qemu-io.c'),
  3727. link_args: '@block.syms', link_depends: block_syms,
  3728. dependencies: [block, qemuutil], install: true)
  3729. qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
  3730. link_args: '@block.syms', link_depends: block_syms,
  3731. dependencies: [blockdev, qemuutil, selinux],
  3732. install: true)
  3733. subdir('storage-daemon')
  3734. foreach exe: [ 'qemu-img', 'qemu-io', 'qemu-nbd', 'qemu-storage-daemon']
  3735. traceable += [{
  3736. 'exe': exe,
  3737. 'probe-prefix': 'qemu.' + exe.substring(5).replace('-', '_')
  3738. }]
  3739. endforeach
  3740. subdir('contrib/elf2dmp')
  3741. executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
  3742. dependencies: qemuutil,
  3743. install: true)
  3744. if have_vhost_user
  3745. subdir('contrib/vhost-user-blk')
  3746. subdir('contrib/vhost-user-gpu')
  3747. subdir('contrib/vhost-user-input')
  3748. subdir('contrib/vhost-user-scsi')
  3749. endif
  3750. if host_os == 'linux'
  3751. executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
  3752. dependencies: [qemuutil, libcap_ng],
  3753. install: true,
  3754. install_dir: get_option('libexecdir'))
  3755. executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
  3756. dependencies: [authz, crypto, io, qom, qemuutil,
  3757. libcap_ng, mpathpersist],
  3758. install: true)
  3759. if cpu in ['x86', 'x86_64']
  3760. executable('qemu-vmsr-helper', files('tools/i386/qemu-vmsr-helper.c'),
  3761. dependencies: [authz, crypto, io, qom, qemuutil,
  3762. libcap_ng, mpathpersist],
  3763. install: true)
  3764. endif
  3765. endif
  3766. if have_ivshmem
  3767. subdir('contrib/ivshmem-client')
  3768. subdir('contrib/ivshmem-server')
  3769. endif
  3770. endif
  3771. if stap.found()
  3772. foreach t: traceable
  3773. foreach stp: [
  3774. {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / t['exe'], 'install': false},
  3775. {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / t['exe'], 'install': true},
  3776. {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
  3777. {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
  3778. ]
  3779. cmd = [
  3780. tracetool, '--group=all', '--format=' + stp['fmt'],
  3781. '--binary=' + stp['bin'],
  3782. '--probe-prefix=' + t['probe-prefix'],
  3783. '@INPUT@', '@OUTPUT@'
  3784. ]
  3785. custom_target(t['exe'] + stp['ext'],
  3786. input: trace_events_all,
  3787. output: t['exe'] + stp['ext'],
  3788. install: stp['install'],
  3789. install_dir: get_option('datadir') / 'systemtap/tapset',
  3790. command: cmd,
  3791. depend_files: tracetool_depends)
  3792. endforeach
  3793. endforeach
  3794. endif
  3795. subdir('scripts')
  3796. subdir('tools')
  3797. subdir('pc-bios')
  3798. subdir('docs')
  3799. subdir('tests')
  3800. if gtk.found()
  3801. subdir('po')
  3802. endif
  3803. if host_machine.system() == 'windows'
  3804. nsis_cmd = [
  3805. find_program('scripts/nsis.py'),
  3806. '@OUTPUT@',
  3807. get_option('prefix'),
  3808. meson.current_source_dir(),
  3809. glib_pc.get_variable('bindir'),
  3810. host_machine.cpu(),
  3811. '--',
  3812. '-DDISPLAYVERSION=' + meson.project_version(),
  3813. ]
  3814. if build_docs
  3815. nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
  3816. endif
  3817. if gtk.found()
  3818. nsis_cmd += '-DCONFIG_GTK=y'
  3819. endif
  3820. nsis = custom_target('nsis',
  3821. output: 'qemu-setup-' + meson.project_version() + '.exe',
  3822. input: files('qemu.nsi'),
  3823. build_always_stale: true,
  3824. command: nsis_cmd + ['@INPUT@'])
  3825. alias_target('installer', nsis)
  3826. endif
  3827. #########################
  3828. # Configuration summary #
  3829. #########################
  3830. # Build environment
  3831. summary_info = {}
  3832. summary_info += {'Build directory': meson.current_build_dir()}
  3833. summary_info += {'Source path': meson.current_source_dir()}
  3834. summary_info += {'Download dependencies': get_option('wrap_mode') != 'nodownload'}
  3835. summary(summary_info, bool_yn: true, section: 'Build environment')
  3836. # Directories
  3837. summary_info += {'Install prefix': get_option('prefix')}
  3838. summary_info += {'BIOS directory': qemu_datadir}
  3839. pathsep = host_os == 'windows' ? ';' : ':'
  3840. summary_info += {'firmware path': pathsep.join(get_option('qemu_firmwarepath'))}
  3841. summary_info += {'binary directory': get_option('prefix') / get_option('bindir')}
  3842. summary_info += {'library directory': get_option('prefix') / get_option('libdir')}
  3843. summary_info += {'module directory': qemu_moddir}
  3844. summary_info += {'libexec directory': get_option('prefix') / get_option('libexecdir')}
  3845. summary_info += {'include directory': get_option('prefix') / get_option('includedir')}
  3846. summary_info += {'config directory': get_option('prefix') / get_option('sysconfdir')}
  3847. if host_os != 'windows'
  3848. summary_info += {'local state directory': get_option('prefix') / get_option('localstatedir')}
  3849. summary_info += {'Manual directory': get_option('prefix') / get_option('mandir')}
  3850. else
  3851. summary_info += {'local state directory': 'queried at runtime'}
  3852. endif
  3853. summary_info += {'Doc directory': get_option('prefix') / get_option('docdir')}
  3854. summary(summary_info, bool_yn: true, section: 'Directories')
  3855. # Host binaries
  3856. summary_info = {}
  3857. summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
  3858. summary_info += {'sphinx-build': sphinx_build}
  3859. # FIXME: the [binaries] section of machine files, which can be probed
  3860. # with find_program(), would be great for passing gdb and genisoimage
  3861. # paths from configure to Meson. However, there seems to be no way to
  3862. # hide a program (for example if gdb is too old).
  3863. if config_host.has_key('GDB')
  3864. summary_info += {'gdb': config_host['GDB']}
  3865. endif
  3866. summary_info += {'iasl': iasl}
  3867. summary_info += {'genisoimage': config_host['GENISOIMAGE']}
  3868. if host_os == 'windows' and have_ga
  3869. summary_info += {'wixl': wixl}
  3870. endif
  3871. if slirp.found() and have_system
  3872. summary_info += {'smbd': have_slirp_smbd ? smbd_path : false}
  3873. endif
  3874. summary(summary_info, bool_yn: true, section: 'Host binaries')
  3875. # Configurable features
  3876. summary_info = {}
  3877. summary_info += {'Documentation': build_docs}
  3878. summary_info += {'system-mode emulation': have_system}
  3879. summary_info += {'user-mode emulation': have_user}
  3880. summary_info += {'block layer': have_block}
  3881. summary_info += {'Install blobs': get_option('install_blobs')}
  3882. summary_info += {'module support': enable_modules}
  3883. if enable_modules
  3884. summary_info += {'alternative module path': get_option('module_upgrades')}
  3885. endif
  3886. summary_info += {'fuzzing support': get_option('fuzzing')}
  3887. if have_system
  3888. summary_info += {'Audio drivers': ' '.join(audio_drivers_selected)}
  3889. endif
  3890. summary_info += {'Trace backends': ','.join(get_option('trace_backends'))}
  3891. if 'simple' in get_option('trace_backends')
  3892. summary_info += {'Trace output file': get_option('trace_file') + '-<pid>'}
  3893. endif
  3894. summary_info += {'D-Bus display': dbus_display}
  3895. summary_info += {'QOM debugging': get_option('qom_cast_debug')}
  3896. summary_info += {'Relocatable install': get_option('relocatable')}
  3897. summary_info += {'vhost-kernel support': have_vhost_kernel}
  3898. summary_info += {'vhost-net support': have_vhost_net}
  3899. summary_info += {'vhost-user support': have_vhost_user}
  3900. summary_info += {'vhost-user-crypto support': have_vhost_user_crypto}
  3901. summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server}
  3902. summary_info += {'vhost-vdpa support': have_vhost_vdpa}
  3903. summary_info += {'build guest agent': have_ga}
  3904. summary(summary_info, bool_yn: true, section: 'Configurable features')
  3905. # Compilation information
  3906. summary_info = {}
  3907. summary_info += {'host CPU': cpu}
  3908. summary_info += {'host endianness': build_machine.endian()}
  3909. summary_info += {'C compiler': ' '.join(meson.get_compiler('c').cmd_array())}
  3910. summary_info += {'Host C compiler': ' '.join(meson.get_compiler('c', native: true).cmd_array())}
  3911. if 'cpp' in all_languages
  3912. summary_info += {'C++ compiler': ' '.join(meson.get_compiler('cpp').cmd_array())}
  3913. else
  3914. summary_info += {'C++ compiler': false}
  3915. endif
  3916. if 'objc' in all_languages
  3917. summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
  3918. else
  3919. summary_info += {'Objective-C compiler': false}
  3920. endif
  3921. option_cflags = (get_option('debug') ? ['-g'] : [])
  3922. if get_option('optimization') != 'plain'
  3923. option_cflags += ['-O' + get_option('optimization')]
  3924. endif
  3925. summary_info += {'CFLAGS': ' '.join(get_option('c_args') + option_cflags)}
  3926. if 'cpp' in all_languages
  3927. summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args') + option_cflags)}
  3928. endif
  3929. if 'objc' in all_languages
  3930. summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args') + option_cflags)}
  3931. endif
  3932. link_args = get_option('c_link_args')
  3933. if link_args.length() > 0
  3934. summary_info += {'LDFLAGS': ' '.join(link_args)}
  3935. endif
  3936. summary_info += {'QEMU_CFLAGS': ' '.join(qemu_common_flags + qemu_cflags)}
  3937. if 'cpp' in all_languages
  3938. summary_info += {'QEMU_CXXFLAGS': ' '.join(qemu_common_flags + qemu_cxxflags)}
  3939. endif
  3940. if 'objc' in all_languages
  3941. summary_info += {'QEMU_OBJCFLAGS': ' '.join(qemu_common_flags)}
  3942. endif
  3943. summary_info += {'QEMU_LDFLAGS': ' '.join(qemu_ldflags)}
  3944. summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
  3945. summary_info += {'PIE': get_option('b_pie')}
  3946. summary_info += {'static build': get_option('prefer_static')}
  3947. summary_info += {'malloc trim support': has_malloc_trim}
  3948. summary_info += {'membarrier': have_membarrier}
  3949. summary_info += {'debug graph lock': get_option('debug_graph_lock')}
  3950. summary_info += {'debug stack usage': get_option('debug_stack_usage')}
  3951. summary_info += {'mutex debugging': get_option('debug_mutex')}
  3952. summary_info += {'memory allocator': get_option('malloc')}
  3953. summary_info += {'avx2 optimization': config_host_data.get('CONFIG_AVX2_OPT')}
  3954. summary_info += {'avx512bw optimization': config_host_data.get('CONFIG_AVX512BW_OPT')}
  3955. summary_info += {'gcov': get_option('b_coverage')}
  3956. summary_info += {'thread sanitizer': get_option('tsan')}
  3957. summary_info += {'CFI support': get_option('cfi')}
  3958. if get_option('cfi')
  3959. summary_info += {'CFI debug support': get_option('cfi_debug')}
  3960. endif
  3961. summary_info += {'strip binaries': get_option('strip')}
  3962. summary_info += {'sparse': sparse}
  3963. summary_info += {'mingw32 support': host_os == 'windows'}
  3964. summary(summary_info, bool_yn: true, section: 'Compilation')
  3965. # snarf the cross-compilation information for tests
  3966. summary_info = {}
  3967. have_cross = false
  3968. foreach target: target_dirs
  3969. tcg_mak = meson.current_build_dir() / 'tests/tcg' / target / 'config-target.mak'
  3970. if fs.exists(tcg_mak)
  3971. config_cross_tcg = keyval.load(tcg_mak)
  3972. if 'CC' in config_cross_tcg
  3973. summary_info += {config_cross_tcg['TARGET_NAME']: config_cross_tcg['CC']}
  3974. have_cross = true
  3975. endif
  3976. endif
  3977. endforeach
  3978. if have_cross
  3979. summary(summary_info, bool_yn: true, section: 'Cross compilers')
  3980. endif
  3981. # Targets and accelerators
  3982. summary_info = {}
  3983. if have_system
  3984. summary_info += {'KVM support': config_all_accel.has_key('CONFIG_KVM')}
  3985. summary_info += {'HVF support': config_all_accel.has_key('CONFIG_HVF')}
  3986. summary_info += {'WHPX support': config_all_accel.has_key('CONFIG_WHPX')}
  3987. summary_info += {'NVMM support': config_all_accel.has_key('CONFIG_NVMM')}
  3988. summary_info += {'Xen support': xen.found()}
  3989. if xen.found()
  3990. summary_info += {'xen ctrl version': xen.version()}
  3991. endif
  3992. summary_info += {'Xen emulation': config_all_devices.has_key('CONFIG_XEN_EMU')}
  3993. endif
  3994. summary_info += {'TCG support': config_all_accel.has_key('CONFIG_TCG')}
  3995. if config_all_accel.has_key('CONFIG_TCG')
  3996. if get_option('tcg_interpreter')
  3997. summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, slow)'}
  3998. else
  3999. summary_info += {'TCG backend': 'native (@0@)'.format(cpu)}
  4000. endif
  4001. summary_info += {'TCG plugins': get_option('plugins')}
  4002. summary_info += {'TCG debug enabled': get_option('debug_tcg')}
  4003. if have_linux_user or have_bsd_user
  4004. summary_info += {'syscall buffer debugging support': get_option('debug_remap')}
  4005. endif
  4006. endif
  4007. summary_info += {'target list': ' '.join(target_dirs)}
  4008. if have_system
  4009. summary_info += {'default devices': get_option('default_devices')}
  4010. summary_info += {'out of process emulation': multiprocess_allowed}
  4011. summary_info += {'vfio-user server': vfio_user_server_allowed}
  4012. endif
  4013. summary(summary_info, bool_yn: true, section: 'Targets and accelerators')
  4014. # Block layer
  4015. summary_info = {}
  4016. summary_info += {'coroutine backend': coroutine_backend}
  4017. summary_info += {'coroutine pool': have_coroutine_pool}
  4018. if have_block
  4019. summary_info += {'Block whitelist (rw)': get_option('block_drv_rw_whitelist')}
  4020. summary_info += {'Block whitelist (ro)': get_option('block_drv_ro_whitelist')}
  4021. summary_info += {'Use block whitelist in tools': get_option('block_drv_whitelist_in_tools')}
  4022. summary_info += {'VirtFS (9P) support': have_virtfs}
  4023. summary_info += {'replication support': config_host_data.get('CONFIG_REPLICATION')}
  4024. summary_info += {'bochs support': get_option('bochs').allowed()}
  4025. summary_info += {'cloop support': get_option('cloop').allowed()}
  4026. summary_info += {'dmg support': get_option('dmg').allowed()}
  4027. summary_info += {'qcow v1 support': get_option('qcow1').allowed()}
  4028. summary_info += {'vdi support': get_option('vdi').allowed()}
  4029. summary_info += {'vhdx support': get_option('vhdx').allowed()}
  4030. summary_info += {'vmdk support': get_option('vmdk').allowed()}
  4031. summary_info += {'vpc support': get_option('vpc').allowed()}
  4032. summary_info += {'vvfat support': get_option('vvfat').allowed()}
  4033. summary_info += {'qed support': get_option('qed').allowed()}
  4034. summary_info += {'parallels support': get_option('parallels').allowed()}
  4035. summary_info += {'FUSE exports': fuse}
  4036. summary_info += {'VDUSE block exports': have_vduse_blk_export}
  4037. endif
  4038. summary(summary_info, bool_yn: true, section: 'Block layer support')
  4039. # Crypto
  4040. summary_info = {}
  4041. summary_info += {'TLS priority': get_option('tls_priority')}
  4042. summary_info += {'GNUTLS support': gnutls}
  4043. if gnutls.found()
  4044. summary_info += {' GNUTLS crypto': gnutls_crypto.found()}
  4045. endif
  4046. summary_info += {'libgcrypt': gcrypt}
  4047. summary_info += {'nettle': nettle}
  4048. if nettle.found()
  4049. summary_info += {' XTS': xts != 'private'}
  4050. endif
  4051. summary_info += {'SM4 ALG support': crypto_sm4}
  4052. summary_info += {'AF_ALG support': have_afalg}
  4053. summary_info += {'rng-none': get_option('rng_none')}
  4054. summary_info += {'Linux keyring': have_keyring}
  4055. summary_info += {'Linux keyutils': keyutils}
  4056. summary(summary_info, bool_yn: true, section: 'Crypto')
  4057. # UI
  4058. summary_info = {}
  4059. if host_os == 'darwin'
  4060. summary_info += {'Cocoa support': cocoa}
  4061. endif
  4062. summary_info += {'SDL support': sdl}
  4063. summary_info += {'SDL image support': sdl_image}
  4064. summary_info += {'GTK support': gtk}
  4065. summary_info += {'pixman': pixman}
  4066. summary_info += {'VTE support': vte}
  4067. summary_info += {'PNG support': png}
  4068. summary_info += {'VNC support': vnc}
  4069. if vnc.found()
  4070. summary_info += {'VNC SASL support': sasl}
  4071. summary_info += {'VNC JPEG support': jpeg}
  4072. endif
  4073. summary_info += {'spice protocol support': spice_protocol}
  4074. if spice_protocol.found()
  4075. summary_info += {' spice server support': spice}
  4076. endif
  4077. summary_info += {'curses support': curses}
  4078. summary_info += {'brlapi support': brlapi}
  4079. summary(summary_info, bool_yn: true, section: 'User interface')
  4080. # Graphics backends
  4081. summary_info = {}
  4082. summary_info += {'VirGL support': virgl}
  4083. summary_info += {'Rutabaga support': rutabaga}
  4084. summary(summary_info, bool_yn: true, section: 'Graphics backends')
  4085. # Audio backends
  4086. summary_info = {}
  4087. if host_os not in ['darwin', 'haiku', 'windows']
  4088. summary_info += {'OSS support': oss}
  4089. summary_info += {'sndio support': sndio}
  4090. elif host_os == 'darwin'
  4091. summary_info += {'CoreAudio support': coreaudio}
  4092. elif host_os == 'windows'
  4093. summary_info += {'DirectSound support': dsound}
  4094. endif
  4095. if host_os == 'linux'
  4096. summary_info += {'ALSA support': alsa}
  4097. summary_info += {'PulseAudio support': pulse}
  4098. endif
  4099. summary_info += {'PipeWire support': pipewire}
  4100. summary_info += {'JACK support': jack}
  4101. summary(summary_info, bool_yn: true, section: 'Audio backends')
  4102. # Network backends
  4103. summary_info = {}
  4104. if host_os == 'darwin'
  4105. summary_info += {'vmnet.framework support': vmnet}
  4106. endif
  4107. summary_info += {'AF_XDP support': libxdp}
  4108. summary_info += {'slirp support': slirp}
  4109. summary_info += {'vde support': vde}
  4110. summary_info += {'netmap support': have_netmap}
  4111. summary_info += {'l2tpv3 support': have_l2tpv3}
  4112. summary(summary_info, bool_yn: true, section: 'Network backends')
  4113. # Libraries
  4114. summary_info = {}
  4115. summary_info += {'libtasn1': tasn1}
  4116. summary_info += {'PAM': pam}
  4117. summary_info += {'iconv support': iconv}
  4118. summary_info += {'blkio support': blkio}
  4119. summary_info += {'curl support': curl}
  4120. summary_info += {'Multipath support': mpathpersist}
  4121. summary_info += {'Linux AIO support': libaio}
  4122. summary_info += {'Linux io_uring support': linux_io_uring}
  4123. summary_info += {'ATTR/XATTR support': libattr}
  4124. summary_info += {'RDMA support': rdma}
  4125. summary_info += {'fdt support': fdt_opt == 'internal' ? 'internal' : fdt}
  4126. summary_info += {'libcap-ng support': libcap_ng}
  4127. summary_info += {'bpf support': libbpf}
  4128. summary_info += {'rbd support': rbd}
  4129. summary_info += {'smartcard support': cacard}
  4130. summary_info += {'U2F support': u2f}
  4131. summary_info += {'libusb': libusb}
  4132. summary_info += {'usb net redir': usbredir}
  4133. summary_info += {'OpenGL support (epoxy)': opengl}
  4134. summary_info += {'GBM': gbm}
  4135. summary_info += {'libiscsi support': libiscsi}
  4136. summary_info += {'libnfs support': libnfs}
  4137. if host_os == 'windows'
  4138. if have_ga
  4139. summary_info += {'QGA VSS support': have_qga_vss}
  4140. endif
  4141. endif
  4142. summary_info += {'seccomp support': seccomp}
  4143. summary_info += {'GlusterFS support': glusterfs}
  4144. summary_info += {'hv-balloon support': hv_balloon}
  4145. summary_info += {'TPM support': have_tpm}
  4146. summary_info += {'libssh support': libssh}
  4147. summary_info += {'lzo support': lzo}
  4148. summary_info += {'snappy support': snappy}
  4149. summary_info += {'bzip2 support': libbzip2}
  4150. summary_info += {'lzfse support': liblzfse}
  4151. summary_info += {'zstd support': zstd}
  4152. summary_info += {'Query Processing Library support': qpl}
  4153. summary_info += {'UADK Library support': uadk}
  4154. summary_info += {'qatzip support': qatzip}
  4155. summary_info += {'NUMA host support': numa}
  4156. summary_info += {'capstone': capstone}
  4157. summary_info += {'libpmem support': libpmem}
  4158. summary_info += {'libdaxctl support': libdaxctl}
  4159. summary_info += {'libudev': libudev}
  4160. # Dummy dependency, keep .found()
  4161. summary_info += {'FUSE lseek': fuse_lseek.found()}
  4162. summary_info += {'selinux': selinux}
  4163. summary_info += {'libdw': libdw}
  4164. if host_os == 'freebsd'
  4165. summary_info += {'libinotify-kqueue': inotify}
  4166. endif
  4167. summary(summary_info, bool_yn: true, section: 'Dependencies')
  4168. if host_arch == 'unknown'
  4169. message()
  4170. warning('UNSUPPORTED HOST CPU')
  4171. message()
  4172. message('Support for CPU host architecture ' + cpu + ' is not currently')
  4173. message('maintained. The QEMU project does not guarantee that QEMU will')
  4174. message('compile or work on this host CPU. You can help by volunteering')
  4175. message('to maintain it and providing a build host for our continuous')
  4176. message('integration setup.')
  4177. if get_option('tcg').allowed() and target_dirs.length() > 0
  4178. message()
  4179. message('configure has succeeded and you can continue to build, but')
  4180. message('QEMU will use a slow interpreter to emulate the target CPU.')
  4181. endif
  4182. endif
  4183. if not supported_oses.contains(host_os)
  4184. message()
  4185. warning('UNSUPPORTED HOST OS')
  4186. message()
  4187. message('Support for host OS ' + host_os + 'is not currently maintained.')
  4188. message('configure has succeeded and you can continue to build, but')
  4189. message('the QEMU project does not guarantee that QEMU will compile or')
  4190. message('work on this operating system. You can help by volunteering')
  4191. message('to maintain it and providing a build host for our continuous')
  4192. message('integration setup. This will ensure that future versions of QEMU')
  4193. message('will keep working on ' + host_os + '.')
  4194. endif
  4195. if host_arch == 'unknown' or not supported_oses.contains(host_os)
  4196. message()
  4197. message('If you want to help supporting QEMU on this platform, please')
  4198. message('contact the developers at qemu-devel@nongnu.org.')
  4199. endif
  4200. actually_reloc = get_option('relocatable')
  4201. # check if get_relocated_path() is actually able to relocate paths
  4202. if get_option('relocatable') and \
  4203. not (get_option('prefix') / get_option('bindir')).startswith(get_option('prefix') / '')
  4204. message()
  4205. warning('bindir not included within prefix, the installation will not be relocatable.')
  4206. actually_reloc = false
  4207. endif
  4208. if not actually_reloc and (host_os == 'windows' or get_option('relocatable'))
  4209. if host_os == 'windows'
  4210. message()
  4211. warning('Windows installs should usually be relocatable.')
  4212. endif
  4213. message()
  4214. message('QEMU will have to be installed under ' + get_option('prefix') + '.')
  4215. message('Use --disable-relocatable to remove this warning.')
  4216. endif