acinclude.m4 158 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041
  1. dnl
  2. dnl GLIBCXX_CONDITIONAL (NAME, SHELL-TEST)
  3. dnl
  4. dnl Exactly like AM_CONDITIONAL, but delays evaluation of the test until the
  5. dnl end of configure. This lets tested variables be reassigned, and the
  6. dnl conditional will depend on the final state of the variable. For a simple
  7. dnl example of why this is needed, see GLIBCXX_ENABLE_HOSTED.
  8. dnl
  9. m4_define([_m4_divert(glibcxx_diversion)], 8000)dnl
  10. AC_DEFUN([GLIBCXX_CONDITIONAL], [dnl
  11. m4_divert_text([glibcxx_diversion],dnl
  12. AM_CONDITIONAL([$1],[$2])
  13. )dnl
  14. ])dnl
  15. AC_DEFUN([GLIBCXX_EVALUATE_CONDITIONALS], [m4_undivert([glibcxx_diversion])])dnl
  16. dnl
  17. dnl Check to see what architecture and operating system we are compiling
  18. dnl for. Also, if architecture- or OS-specific flags are required for
  19. dnl compilation, pick them up here.
  20. dnl
  21. AC_DEFUN([GLIBCXX_CHECK_HOST], [
  22. . $glibcxx_srcdir/configure.host
  23. AC_MSG_NOTICE([CPU config directory is $cpu_include_dir])
  24. AC_MSG_NOTICE([OS config directory is $os_include_dir])
  25. ])
  26. dnl
  27. dnl Initialize the rest of the library configury. At this point we have
  28. dnl variables like $host.
  29. dnl
  30. dnl Sets:
  31. dnl SUBDIRS
  32. dnl Substs:
  33. dnl glibcxx_builddir (absolute path)
  34. dnl glibcxx_srcdir (absolute path)
  35. dnl toplevel_builddir (absolute path)
  36. dnl toplevel_srcdir (absolute path)
  37. dnl with_cross_host
  38. dnl with_newlib
  39. dnl with_target_subdir
  40. dnl plus
  41. dnl - the variables in GLIBCXX_CHECK_HOST / configure.host
  42. dnl - default settings for all AM_CONFITIONAL test variables
  43. dnl - lots of tools, like CC and CXX
  44. dnl
  45. AC_DEFUN([GLIBCXX_CONFIGURE], [
  46. # Keep these sync'd with the list in Makefile.am. The first provides an
  47. # expandable list at autoconf time; the second provides an expandable list
  48. # (i.e., shell variable) at configure time.
  49. m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem src/libbacktrace doc po testsuite python])
  50. SUBDIRS='glibcxx_SUBDIRS'
  51. # These need to be absolute paths, yet at the same time need to
  52. # canonicalize only relative paths, because then amd will not unmount
  53. # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
  54. glibcxx_builddir=`${PWDCMD-pwd}`
  55. case $srcdir in
  56. [\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;;
  57. *) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
  58. esac
  59. toplevel_builddir=${glibcxx_builddir}/..
  60. toplevel_srcdir=${glibcxx_srcdir}/..
  61. AC_SUBST(glibcxx_builddir)
  62. AC_SUBST(glibcxx_srcdir)
  63. AC_SUBST(toplevel_builddir)
  64. AC_SUBST(toplevel_srcdir)
  65. # We use these options to decide which functions to include. They are
  66. # set from the top level.
  67. AC_ARG_WITH([target-subdir],
  68. AC_HELP_STRING([--with-target-subdir=SUBDIR],
  69. [configuring in a subdirectory]))
  70. AC_ARG_WITH([cross-host],
  71. AC_HELP_STRING([--with-cross-host=HOST],
  72. [configuring with a cross compiler]))
  73. AC_ARG_WITH([newlib],
  74. AC_HELP_STRING([--with-newlib],
  75. [assume newlib as a system C library]))
  76. # Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't
  77. # available). Uncomment the next line to force a particular method.
  78. AC_PROG_LN_S
  79. #LN_S='cp -p'
  80. AC_CHECK_TOOL(AS, as)
  81. AC_CHECK_TOOL(AR, ar)
  82. AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
  83. AM_MAINTAINER_MODE
  84. # Set up safe default values for all subsequent AM_CONDITIONAL tests
  85. # which are themselves conditionally expanded.
  86. ## (Right now, this only matters for enable_wchar_t, but nothing prevents
  87. ## other macros from doing the same. This should be automated.) -pme
  88. # Check for C library flavor since GNU/Linux platforms use different
  89. # configuration directories depending on the C library in use.
  90. AC_EGREP_CPP([_using_uclibc], [
  91. #include <stdio.h>
  92. #if __UCLIBC__
  93. _using_uclibc
  94. #endif
  95. ], uclibc=yes, uclibc=no)
  96. AC_EGREP_CPP([_using_bionic], [
  97. #include <stdio.h>
  98. #if __BIONIC__
  99. _using_bionic
  100. #endif
  101. ], bionic=yes, bionic=no)
  102. # Find platform-specific directories containing configuration info.
  103. # Also possibly modify flags used elsewhere, as needed by the platform.
  104. GLIBCXX_CHECK_HOST
  105. ])
  106. dnl
  107. dnl Tests for newer compiler features, or features that are present in newer
  108. dnl compiler versions but not older compiler versions still in use, should
  109. dnl be placed here.
  110. dnl
  111. dnl Defines:
  112. dnl WERROR='-Werror' if requested and possible; g++'s that lack the
  113. dnl new inlining code or the new system_header pragma will die on -Werror.
  114. dnl Leave it out by default and use maint-mode to use it.
  115. dnl SECTION_FLAGS='-ffunction-sections -fdata-sections' if
  116. dnl compiler supports it and the user has not requested debug mode.
  117. dnl
  118. AC_DEFUN([GLIBCXX_CHECK_COMPILER_FEATURES], [
  119. # All these tests are for C++; save the language and the compiler flags.
  120. # The CXXFLAGS thing is suspicious, but based on similar bits previously
  121. # found in GLIBCXX_CONFIGURE.
  122. AC_LANG_SAVE
  123. AC_LANG_CPLUSPLUS
  124. ac_test_CXXFLAGS="${CXXFLAGS+set}"
  125. ac_save_CXXFLAGS="$CXXFLAGS"
  126. # Check for -ffunction-sections -fdata-sections
  127. AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
  128. CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections'
  129. AC_TRY_COMPILE([int foo; void bar() { };],, [ac_fdsections=yes], [ac_fdsections=no])
  130. if test "$ac_test_CXXFLAGS" = set; then
  131. CXXFLAGS="$ac_save_CXXFLAGS"
  132. else
  133. # this is the suspicious part
  134. CXXFLAGS=''
  135. fi
  136. if test x"$ac_fdsections" = x"yes"; then
  137. SECTION_FLAGS='-ffunction-sections -fdata-sections'
  138. fi
  139. AC_MSG_RESULT($ac_fdsections)
  140. AC_LANG_RESTORE
  141. AC_SUBST(SECTION_FLAGS)
  142. ])
  143. dnl
  144. dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
  145. dnl the native linker is in use, all variables will be defined to something
  146. dnl safe (like an empty string).
  147. dnl
  148. dnl Defines:
  149. dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
  150. dnl OPT_LDFLAGS='-Wl,-O1' and '-z,relro' if possible
  151. dnl LD (as a side effect of testing)
  152. dnl Sets:
  153. dnl with_gnu_ld
  154. dnl glibcxx_ld_is_gold (set to "no" or "yes")
  155. dnl glibcxx_ld_is_mold (set to "no" or "yes")
  156. dnl glibcxx_gnu_ld_version (possibly)
  157. dnl
  158. dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
  159. dnl set glibcxx_gnu_ld_version to 12345. Zeros cause problems.
  160. dnl
  161. AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
  162. # If we're not using GNU ld, then there's no point in even trying these
  163. # tests. Check for that first. We should have already tested for gld
  164. # by now (in libtool), but require it now just to be safe...
  165. test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
  166. test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
  167. AC_REQUIRE([AC_PROG_LD])
  168. AC_REQUIRE([AC_PROG_AWK])
  169. # The name set by libtool depends on the version of libtool. Shame on us
  170. # for depending on an impl detail, but c'est la vie. Older versions used
  171. # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
  172. # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
  173. # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
  174. # set (hence we're using an older libtool), then set it.
  175. if test x${with_gnu_ld+set} != xset; then
  176. if test x${ac_cv_prog_gnu_ld+set} != xset; then
  177. # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
  178. with_gnu_ld=no
  179. else
  180. with_gnu_ld=$ac_cv_prog_gnu_ld
  181. fi
  182. fi
  183. # Start by getting the version number. I think the libtool test already
  184. # does some of this, but throws away the result.
  185. glibcxx_ld_is_gold=no
  186. glibcxx_ld_is_mold=no
  187. if test x"$with_gnu_ld" = x"yes"; then
  188. AC_MSG_CHECKING([for ld version])
  189. changequote(,)
  190. if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
  191. glibcxx_ld_is_gold=yes
  192. elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
  193. glibcxx_ld_is_mold=yes
  194. fi
  195. ldver=`$LD --version 2>/dev/null |
  196. sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
  197. changequote([,])
  198. glibcxx_gnu_ld_version=`echo $ldver | \
  199. $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
  200. AC_MSG_RESULT($glibcxx_gnu_ld_version)
  201. fi
  202. # Set --gc-sections.
  203. glibcxx_have_gc_sections=no
  204. if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
  205. if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
  206. glibcxx_have_gc_sections=yes
  207. fi
  208. else
  209. glibcxx_gcsections_min_ld=21602
  210. if test x"$with_gnu_ld" = x"yes" &&
  211. test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
  212. glibcxx_have_gc_sections=yes
  213. fi
  214. fi
  215. if test "$glibcxx_have_gc_sections" = "yes"; then
  216. # Sufficiently young GNU ld it is! Joy and bunny rabbits!
  217. # NB: This flag only works reliably after 2.16.1. Configure tests
  218. # for this are difficult, so hard wire a value that should work.
  219. ac_test_CFLAGS="${CFLAGS+set}"
  220. ac_save_CFLAGS="$CFLAGS"
  221. CFLAGS='-Wl,--gc-sections'
  222. # Check for -Wl,--gc-sections
  223. AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
  224. AC_TRY_LINK([ int one(void) { return 1; }
  225. int two(void) { return 2; }
  226. ], [ two(); ] , [ac_gcsections=yes], [ac_gcsections=no])
  227. if test "$ac_gcsections" = "yes"; then
  228. rm -f conftest.c
  229. touch conftest.c
  230. if $CC -c conftest.c; then
  231. if $LD --gc-sections -o conftest conftest.o 2>&1 | \
  232. grep "Warning: gc-sections option ignored" > /dev/null; then
  233. ac_gcsections=no
  234. fi
  235. fi
  236. rm -f conftest.c conftest.o conftest
  237. fi
  238. if test "$ac_gcsections" = "yes"; then
  239. SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
  240. fi
  241. AC_MSG_RESULT($ac_gcsections)
  242. if test "$ac_test_CFLAGS" = set; then
  243. CFLAGS="$ac_save_CFLAGS"
  244. else
  245. # this is the suspicious part
  246. CFLAGS=''
  247. fi
  248. fi
  249. # Set -z,relro.
  250. # Note this is only for shared objects.
  251. ac_ld_relro=no
  252. if test x"$with_gnu_ld" = x"yes"; then
  253. # cygwin and mingw uses PE, which has no ELF relro support,
  254. # multi target ld may confuse configure machinery
  255. case "$host" in
  256. *-*-cygwin*)
  257. ;;
  258. *-*-mingw*)
  259. ;;
  260. *)
  261. AC_MSG_CHECKING([for ld that supports -Wl,-z,relro])
  262. cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
  263. if test -n "$cxx_z_relo"; then
  264. OPT_LDFLAGS="-Wl,-z,relro"
  265. ac_ld_relro=yes
  266. fi
  267. AC_MSG_RESULT($ac_ld_relro)
  268. esac
  269. fi
  270. # Set linker optimization flags.
  271. if test x"$with_gnu_ld" = x"yes"; then
  272. OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
  273. fi
  274. AC_SUBST(SECTION_LDFLAGS)
  275. AC_SUBST(OPT_LDFLAGS)
  276. ])
  277. dnl
  278. dnl Check for headers for, and arguments to, the setrlimit() function.
  279. dnl Used only in testsuite_hooks.h. Called from GLIBCXX_CONFIGURE_TESTSUITE.
  280. dnl
  281. dnl Defines:
  282. dnl _GLIBCXX_RES_LIMITS if we can set artificial resource limits
  283. dnl various HAVE_LIMIT_* for individual limit names
  284. dnl
  285. AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT_ancilliary], [
  286. AC_MSG_CHECKING([for RLIMIT_$1])
  287. AC_TRY_COMPILE(
  288. [#include <unistd.h>
  289. #include <sys/time.h>
  290. #include <sys/resource.h>
  291. ],
  292. [ int f = RLIMIT_$1 ; ],
  293. [glibcxx_mresult=1], [glibcxx_mresult=0])
  294. AC_DEFINE_UNQUOTED(HAVE_LIMIT_$1, $glibcxx_mresult,
  295. [Only used in build directory testsuite_hooks.h.])
  296. if test $glibcxx_mresult = 1 ; then res=yes ; else res=no ; fi
  297. AC_MSG_RESULT($res)
  298. ])
  299. AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT], [
  300. AC_LANG_SAVE
  301. AC_LANG_CPLUSPLUS
  302. setrlimit_have_headers=yes
  303. AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h,
  304. [],
  305. [setrlimit_have_headers=no])
  306. # If don't have the headers, then we can't run the tests now, and we
  307. # won't be seeing any of these during testsuite compilation.
  308. if test $setrlimit_have_headers = yes; then
  309. # Can't do these in a loop, else the resulting syntax is wrong.
  310. GLIBCXX_CHECK_SETRLIMIT_ancilliary(DATA)
  311. GLIBCXX_CHECK_SETRLIMIT_ancilliary(RSS)
  312. GLIBCXX_CHECK_SETRLIMIT_ancilliary(VMEM)
  313. GLIBCXX_CHECK_SETRLIMIT_ancilliary(AS)
  314. GLIBCXX_CHECK_SETRLIMIT_ancilliary(FSIZE)
  315. # Check for rlimit, setrlimit.
  316. AC_CACHE_CHECK([for testsuite resource limits support],
  317. glibcxx_cv_setrlimit, [
  318. AC_TRY_COMPILE(
  319. [#include <unistd.h>
  320. #include <sys/time.h>
  321. #include <sys/resource.h>
  322. ],
  323. [struct rlimit r;
  324. setrlimit(0, &r);],
  325. [glibcxx_cv_setrlimit=yes], [glibcxx_cv_setrlimit=no])
  326. ])
  327. if test $glibcxx_cv_setrlimit = yes; then
  328. AC_DEFINE(_GLIBCXX_RES_LIMITS, 1,
  329. [Define if using setrlimit to set resource limits during
  330. "make check"])
  331. fi
  332. fi
  333. AC_LANG_RESTORE
  334. ])
  335. dnl
  336. dnl Check whether S_ISREG (Posix) or S_IFREG is available in <sys/stat.h>.
  337. dnl Define HAVE_S_ISREG / HAVE_S_IFREG appropriately.
  338. dnl
  339. AC_DEFUN([GLIBCXX_CHECK_S_ISREG_OR_S_IFREG], [
  340. AC_LANG_SAVE
  341. AC_LANG_CPLUSPLUS
  342. ac_save_CXXFLAGS="$CXXFLAGS"
  343. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  344. AC_MSG_CHECKING([for S_ISREG or S_IFREG])
  345. AC_CACHE_VAL(glibcxx_cv_S_ISREG, [
  346. GCC_TRY_COMPILE_OR_LINK(
  347. [#include <sys/stat.h>],
  348. [struct stat buffer;
  349. fstat(0, &buffer);
  350. S_ISREG(buffer.st_mode);],
  351. [glibcxx_cv_S_ISREG=yes],
  352. [glibcxx_cv_S_ISREG=no])
  353. ])
  354. AC_CACHE_VAL(glibcxx_cv_S_IFREG, [
  355. GCC_TRY_COMPILE_OR_LINK(
  356. [#include <sys/stat.h>],
  357. [struct stat buffer;
  358. fstat(0, &buffer);
  359. S_IFREG & buffer.st_mode;],
  360. [glibcxx_cv_S_IFREG=yes],
  361. [glibcxx_cv_S_IFREG=no])
  362. ])
  363. res=no
  364. if test $glibcxx_cv_S_ISREG = yes; then
  365. AC_DEFINE(HAVE_S_ISREG, 1,
  366. [Define if S_ISREG is available in <sys/stat.h>.])
  367. res=S_ISREG
  368. elif test $glibcxx_cv_S_IFREG = yes; then
  369. AC_DEFINE(HAVE_S_IFREG, 1,
  370. [Define if S_IFREG is available in <sys/stat.h>.])
  371. res=S_IFREG
  372. fi
  373. AC_MSG_RESULT($res)
  374. CXXFLAGS="$ac_save_CXXFLAGS"
  375. AC_LANG_RESTORE
  376. ])
  377. dnl
  378. dnl Check whether poll is available in <poll.h>, and define HAVE_POLL.
  379. dnl
  380. AC_DEFUN([GLIBCXX_CHECK_POLL], [
  381. AC_LANG_SAVE
  382. AC_LANG_CPLUSPLUS
  383. ac_save_CXXFLAGS="$CXXFLAGS"
  384. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  385. AC_CACHE_CHECK([for poll], glibcxx_cv_POLL, [
  386. GCC_TRY_COMPILE_OR_LINK(
  387. [#include <poll.h>],
  388. [struct pollfd pfd[1];
  389. pfd[0].events = POLLIN;
  390. poll(pfd, 1, 0);],
  391. [glibcxx_cv_POLL=yes],
  392. [glibcxx_cv_POLL=no])
  393. ])
  394. if test $glibcxx_cv_POLL = yes; then
  395. AC_DEFINE(HAVE_POLL, 1, [Define if poll is available in <poll.h>.])
  396. fi
  397. CXXFLAGS="$ac_save_CXXFLAGS"
  398. AC_LANG_RESTORE
  399. ])
  400. dnl
  401. dnl Check whether writev is available in <sys/uio.h>, and define HAVE_WRITEV.
  402. dnl
  403. AC_DEFUN([GLIBCXX_CHECK_WRITEV], [
  404. AC_LANG_SAVE
  405. AC_LANG_CPLUSPLUS
  406. ac_save_CXXFLAGS="$CXXFLAGS"
  407. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  408. AC_CACHE_CHECK([for writev], glibcxx_cv_WRITEV, [
  409. GCC_TRY_COMPILE_OR_LINK(
  410. [#include <sys/uio.h>],
  411. [struct iovec iov[2];
  412. writev(0, iov, 0);],
  413. [glibcxx_cv_WRITEV=yes],
  414. [glibcxx_cv_WRITEV=no])
  415. ])
  416. if test $glibcxx_cv_WRITEV = yes; then
  417. AC_DEFINE(HAVE_WRITEV, 1, [Define if writev is available in <sys/uio.h>.])
  418. fi
  419. CXXFLAGS="$ac_save_CXXFLAGS"
  420. AC_LANG_RESTORE
  421. ])
  422. dnl
  423. dnl Check whether LFS support is available.
  424. dnl
  425. AC_DEFUN([GLIBCXX_CHECK_LFS], [
  426. AC_LANG_SAVE
  427. AC_LANG_CPLUSPLUS
  428. ac_save_CXXFLAGS="$CXXFLAGS"
  429. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  430. AC_CACHE_CHECK([for LFS support], glibcxx_cv_LFS, [
  431. GCC_TRY_COMPILE_OR_LINK(
  432. [#include <unistd.h>
  433. #include <stdio.h>
  434. #include <sys/stat.h>
  435. ],
  436. [FILE* fp;
  437. fopen64("t", "w");
  438. fseeko64(fp, 0, SEEK_CUR);
  439. ftello64(fp);
  440. lseek64(1, 0, SEEK_CUR);
  441. struct stat64 buf;
  442. fstat64(1, &buf);],
  443. [glibcxx_cv_LFS=yes],
  444. [glibcxx_cv_LFS=no])
  445. ])
  446. if test $glibcxx_cv_LFS = yes; then
  447. AC_DEFINE(_GLIBCXX_USE_LFS, 1, [Define if LFS support is available.])
  448. fi
  449. CXXFLAGS="$ac_save_CXXFLAGS"
  450. AC_LANG_RESTORE
  451. ])
  452. dnl
  453. dnl Check whether the old Copy-On-Write basic_string should allocate a new
  454. dnl empty representation for every default-constructed basic_string. Without
  455. dnl this option, COW strings share a single empty rep in static storage,
  456. dnl but this only works if the linker can guarantee the static storage has
  457. dnl a unique definition in the process. It also doesn't work if basic_string
  458. dnl objects are stored in shared memory (see PR libstdc++/16612).
  459. dnl When fully dynamic strings are enabled, the static storage is not used
  460. dnl and a new empty string with reference-count == 1 is allocated each time.
  461. dnl Enabling this changes the libstdc++.so ABI.
  462. dnl
  463. dnl --enable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING to 1
  464. dnl --disable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING to 0
  465. dnl otherwise the macro is not defined.
  466. dnl + Usage: GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING[(DEFAULT)]
  467. dnl Where DEFAULT is either `yes' or `no'.
  468. dnl
  469. AC_DEFUN([GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING], [
  470. GLIBCXX_ENABLE(fully-dynamic-string,$1,,[do not put empty strings in per-process static memory], [permit yes|no])
  471. if test $enable_fully_dynamic_string = yes; then
  472. enable_fully_dynamic_string_def=1
  473. else
  474. enable_fully_dynamic_string_def=0
  475. fi
  476. AC_DEFINE_UNQUOTED([_GLIBCXX_FULLY_DYNAMIC_STRING], [${enable_fully_dynamic_string_def}],
  477. [Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, undefined for platform defaults])
  478. ])
  479. dnl
  480. dnl Does any necessary configuration of the testsuite directory. Generates
  481. dnl the testsuite_hooks.h header.
  482. dnl
  483. dnl GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE must be done before this.
  484. dnl
  485. dnl Sets:
  486. dnl enable_abi_check
  487. dnl GLIBCXX_TEST_WCHAR_T
  488. dnl GLIBCXX_TEST_THREAD
  489. dnl Substs:
  490. dnl baseline_dir
  491. dnl baseline_subdir_switch
  492. dnl
  493. AC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [
  494. # Do checks for resource limit functions.
  495. GLIBCXX_CHECK_SETRLIMIT
  496. if $GLIBCXX_IS_NATIVE ; then
  497. # Look for setenv, so that extended locale tests can be performed.
  498. GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
  499. fi
  500. if $GLIBCXX_IS_NATIVE && test $is_hosted = yes &&
  501. test $enable_symvers != no; then
  502. case "$host" in
  503. *-*-cygwin*)
  504. enable_abi_check=no ;;
  505. *)
  506. enable_abi_check=yes ;;
  507. esac
  508. else
  509. # Only build this as native, since automake does not understand
  510. # CXX_FOR_BUILD.
  511. enable_abi_check=no
  512. fi
  513. # Export file names for ABI checking.
  514. baseline_dir="$glibcxx_srcdir/config/abi/post/${abi_baseline_pair}"
  515. AC_SUBST(baseline_dir)
  516. baseline_subdir_switch="$abi_baseline_subdir_switch"
  517. AC_SUBST(baseline_subdir_switch)
  518. ])
  519. dnl
  520. dnl Does any necessary configuration for docbook in the docs directory.
  521. dnl
  522. dnl XSLTPROC must be set before this
  523. dnl
  524. dnl Sets:
  525. dnl glibcxx_stylesheets
  526. dnl Substs:
  527. dnl XSL_STYLE_DIR
  528. dnl
  529. AC_DEFUN([GLIBCXX_CONFIGURE_DOCBOOK], [
  530. glibcxx_docbook_url=http://docbook.sourceforge.net/release/xsl-ns/current/
  531. AC_MSG_CHECKING([for local stylesheet directory])
  532. glibcxx_local_stylesheets=no
  533. if test x${XMLCATALOG} = xyes && xsl_style_dir=`xmlcatalog "" $glibcxx_docbook_url 2>/dev/null`
  534. then
  535. XSL_STYLE_DIR=`echo $xsl_style_dir | sed -n 's;^file://;;p'`
  536. glibcxx_local_stylesheets=yes
  537. else
  538. for dir in \
  539. /usr/share/sgml/docbook/xsl-ns-stylesheets \
  540. /usr/share/xml/docbook/stylesheet/docbook-xsl-ns \
  541. /usr/share/xml/docbook/stylesheet/nwalsh5/current \
  542. /usr/share/xml/docbook/stylesheet/nwalsh/current
  543. do
  544. if test -d $dir; then
  545. glibcxx_local_stylesheets=yes
  546. XSL_STYLE_DIR=$dir
  547. break
  548. fi
  549. done
  550. fi
  551. AC_MSG_RESULT($glibcxx_local_stylesheets)
  552. if test x"$glibcxx_local_stylesheets" = x"yes"; then
  553. AC_SUBST(XSL_STYLE_DIR)
  554. AC_MSG_NOTICE($XSL_STYLE_DIR)
  555. AC_MSG_CHECKING([for docbook stylesheets for documentation creation])
  556. glibcxx_stylesheets=no
  557. if test x${XMLCATALOG} = xno || xmlcatalog "" $glibcxx_docbook_url/xhtml/docbook.xsl >/dev/null 2>&1; then
  558. if test x${XSLTPROC} = xyes && echo '<title/>' | xsltproc --noout --nonet --xinclude $glibcxx_docbook_url/xhtml/docbook.xsl - 2>/dev/null; then
  559. glibcxx_stylesheets=yes
  560. fi
  561. fi
  562. AC_MSG_RESULT($glibcxx_stylesheets)
  563. else
  564. glibcxx_stylesheets=no
  565. fi
  566. # Check for epub3 dependencies.
  567. AC_MSG_CHECKING([for epub3 stylesheets for documentation creation])
  568. glibcxx_epub_stylesheets=no
  569. if test x"$glibcxx_local_stylesheets" = x"yes"; then
  570. if test -f "$XSL_STYLE_DIR/epub3/chunk.xsl"; then
  571. glibcxx_epub_stylesheets=yes
  572. fi
  573. fi
  574. AC_MSG_RESULT($glibcxx_epub_stylesheets)
  575. AM_CONDITIONAL(BUILD_EPUB, test x"$glibcxx_epub_stylesheets" = x"yes")
  576. ])
  577. dnl
  578. dnl Set up *_INCLUDES variables for all sundry Makefile.am's.
  579. dnl
  580. dnl Substs:
  581. dnl GLIBCXX_INCLUDES
  582. dnl TOPLEVEL_INCLUDES
  583. dnl
  584. AC_DEFUN([GLIBCXX_EXPORT_INCLUDES], [
  585. # Used for every C++ compile we perform.
  586. GLIBCXX_INCLUDES="\
  587. -I$glibcxx_builddir/include/$host_alias \
  588. -I$glibcxx_builddir/include \
  589. -I$glibcxx_srcdir/libsupc++"
  590. # For Canadian crosses, pick this up too.
  591. if test $CANADIAN = yes; then
  592. GLIBCXX_INCLUDES="$GLIBCXX_INCLUDES -I\${includedir}"
  593. fi
  594. # Stuff in the actual top level. Currently only used by libsupc++ to
  595. # get unwind* headers from the libgcc dir.
  596. #TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/libgcc -I$(toplevel_srcdir)/include'
  597. TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/libgcc'
  598. # Now, export this to all the little Makefiles....
  599. AC_SUBST(GLIBCXX_INCLUDES)
  600. AC_SUBST(TOPLEVEL_INCLUDES)
  601. ])
  602. dnl
  603. dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
  604. dnl (SECTION_FLAGS is done under CHECK_COMPILER_FEATURES.)
  605. dnl
  606. dnl Substs:
  607. dnl OPTIMIZE_CXXFLAGS
  608. dnl WARN_FLAGS
  609. dnl
  610. AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [
  611. # Optimization flags that are probably a good idea for thrill-seekers. Just
  612. # uncomment the lines below and make, everything else is ready to go...
  613. # Alternatively OPTIMIZE_CXXFLAGS can be set in configure.host.
  614. # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
  615. AC_SUBST(OPTIMIZE_CXXFLAGS)
  616. WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2"
  617. AC_SUBST(WARN_FLAGS)
  618. ])
  619. dnl
  620. dnl All installation directory information is determined here.
  621. dnl
  622. dnl Substs:
  623. dnl gxx_install_dir
  624. dnl glibcxx_prefixdir
  625. dnl glibcxx_toolexecdir
  626. dnl glibcxx_toolexeclibdir
  627. dnl
  628. dnl Assumes cross_compiling bits already done, and with_cross_host in
  629. dnl particular.
  630. dnl
  631. dnl This logic must match gcc/configure.ac's setting of gcc_gxx_include_dir.
  632. dnl config/gxx-include-dir.m4 must be kept consistant with this as well.
  633. AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO], [
  634. glibcxx_toolexecdir=no
  635. glibcxx_toolexeclibdir=no
  636. glibcxx_prefixdir=$prefix
  637. AC_MSG_CHECKING([for gxx-include-dir])
  638. AC_ARG_WITH([gxx-include-dir],
  639. AC_HELP_STRING([--with-gxx-include-dir=DIR],
  640. [installation directory for include files]),
  641. [case "$withval" in
  642. yes) AC_MSG_ERROR([Missing directory for --with-gxx-include-dir]) ;;
  643. no) gxx_include_dir=no ;;
  644. *) gxx_include_dir=$withval ;;
  645. esac],
  646. [gxx_include_dir=no])
  647. AC_MSG_RESULT($gxx_include_dir)
  648. AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
  649. AC_ARG_ENABLE([version-specific-runtime-libs],
  650. AC_HELP_STRING([--enable-version-specific-runtime-libs],
  651. [Specify that runtime libraries should be installed in a compiler-specific directory]),
  652. [case "$enableval" in
  653. yes) version_specific_libs=yes ;;
  654. no) version_specific_libs=no ;;
  655. *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
  656. esac],
  657. [version_specific_libs=no])
  658. AC_MSG_RESULT($version_specific_libs)
  659. GCC_WITH_TOOLEXECLIBDIR
  660. # Default case for install directory for include files.
  661. if test $version_specific_libs = no && test $gxx_include_dir = no; then
  662. gxx_include_dir='include/c++/${gcc_version}'
  663. if test -n "$with_cross_host" &&
  664. test x"$with_cross_host" != x"no"; then
  665. gxx_include_dir='${prefix}/${target_alias}/'"$gxx_include_dir"
  666. else
  667. gxx_include_dir='${prefix}/'"$gxx_include_dir"
  668. fi
  669. fi
  670. # Version-specific runtime libs processing.
  671. if test $version_specific_libs = yes; then
  672. # Need the gcc compiler version to know where to install libraries
  673. # and header files if --enable-version-specific-runtime-libs option
  674. # is selected. FIXME: these variables are misnamed, there are
  675. # no executables installed in _toolexecdir or _toolexeclibdir.
  676. if test x"$gxx_include_dir" = x"no"; then
  677. gxx_include_dir='${libdir}/gcc/${host_alias}/${gcc_version}/include/c++'
  678. fi
  679. glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
  680. glibcxx_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
  681. fi
  682. # Calculate glibcxx_toolexecdir, glibcxx_toolexeclibdir
  683. # Install a library built with a cross compiler in tooldir, not libdir.
  684. if test x"$glibcxx_toolexecdir" = x"no"; then
  685. if test -n "$with_cross_host" &&
  686. test x"$with_cross_host" != x"no"; then
  687. glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
  688. case ${with_toolexeclibdir} in
  689. no)
  690. glibcxx_toolexeclibdir='${toolexecdir}/lib'
  691. ;;
  692. *)
  693. glibcxx_toolexeclibdir=${with_toolexeclibdir}
  694. ;;
  695. esac
  696. else
  697. glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
  698. glibcxx_toolexeclibdir='${libdir}'
  699. fi
  700. multi_os_directory=`$CXX -print-multi-os-directory`
  701. case $multi_os_directory in
  702. .) ;; # Avoid trailing /.
  703. *) glibcxx_toolexeclibdir=$glibcxx_toolexeclibdir/$multi_os_directory ;;
  704. esac
  705. fi
  706. AC_MSG_CHECKING([for install location])
  707. AC_MSG_RESULT($gxx_include_dir)
  708. AC_SUBST(glibcxx_prefixdir)
  709. AC_SUBST(gxx_include_dir)
  710. AC_SUBST(glibcxx_toolexecdir)
  711. AC_SUBST(glibcxx_toolexeclibdir)
  712. ])
  713. dnl
  714. dnl GLIBCXX_ENABLE
  715. dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
  716. dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
  717. dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
  718. dnl
  719. dnl See manual/appendix_porting.html#appendix.porting.build_hacking for
  720. dnl documentation.
  721. dnl
  722. m4_define([GLIBCXX_ENABLE],[dnl
  723. m4_define([_g_switch],[--enable-$1])dnl
  724. m4_define([_g_help],[AC_HELP_STRING([_g_switch$3],[$4 @<:@default=$2@:>@])])dnl
  725. AC_ARG_ENABLE([$1],m4_dquote(_g_help),
  726. m4_bmatch([$5],
  727. [^permit ],
  728. [[
  729. case "$enableval" in
  730. m4_bpatsubst([$5],[permit ])) ;;
  731. *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
  732. dnl Idea for future: generate a URL pointing to
  733. dnl "onlinedocs/configopts.html#whatever"
  734. esac
  735. ]],
  736. [^$],
  737. [[
  738. case "$enableval" in
  739. yes|no) ;;
  740. *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
  741. esac
  742. ]],
  743. [[$5]]),
  744. [enable_]m4_bpatsubst([$1],-,_)[=][$2])
  745. m4_undefine([_g_switch])dnl
  746. m4_undefine([_g_help])dnl
  747. ])
  748. dnl
  749. dnl Check for ISO/IEC 9899:1999 "C99" support.
  750. dnl
  751. dnl --enable-c99 defines _GLIBCXX_USE_C99
  752. dnl --disable-c99 leaves _GLIBCXX_USE_C99 undefined
  753. dnl + Usage: GLIBCXX_ENABLE_C99[(DEFAULT)]
  754. dnl Where DEFAULT is either `yes' or `no'.
  755. dnl + If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
  756. dnl
  757. AC_DEFUN([GLIBCXX_ENABLE_C99], [
  758. GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
  759. if test x"$enable_c99" = x"yes"; then
  760. AC_LANG_SAVE
  761. AC_LANG_CPLUSPLUS
  762. # Use -std=c++98 (instead of -std=gnu++98) because leaving __STRICT_ANSI__
  763. # undefined may cause fake C99 facilities, like pre-standard snprintf,
  764. # to be spuriously enabled.
  765. ac_save_CXXFLAGS="$CXXFLAGS"
  766. CXXFLAGS="$CXXFLAGS -std=c++98"
  767. ac_save_LIBS="$LIBS"
  768. ac_save_gcc_no_link="$gcc_no_link"
  769. if test x$gcc_no_link != xyes; then
  770. # Use -fno-exceptions to that the C driver can link these tests without
  771. # hitting undefined references to personality routines.
  772. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  773. AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [
  774. # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
  775. gcc_no_link=yes
  776. ])
  777. fi
  778. # Check for the existence of <math.h> functions used if C99 is enabled.
  779. AC_CACHE_CHECK([for ISO C99 support in <math.h> for C++98],
  780. glibcxx_cv_c99_math_cxx98, [
  781. GCC_TRY_COMPILE_OR_LINK(
  782. [#include <math.h>
  783. volatile double d1, d2;
  784. volatile int i;],
  785. [i = fpclassify(d1);
  786. i = isfinite(d1);
  787. i = isinf(d1);
  788. i = isnan(d1);
  789. i = isnormal(d1);
  790. i = signbit(d1);
  791. i = isgreater(d1, d2);
  792. i = isgreaterequal(d1, d2);
  793. i = isless(d1, d2);
  794. i = islessequal(d1, d2);
  795. i = islessgreater(d1, d2);
  796. i = islessgreater(d1, d2);
  797. i = isunordered(d1, d2);
  798. ], [glibcxx_cv_c99_math_cxx98=yes], [glibcxx_cv_c99_math_cxx98=no])
  799. ])
  800. if test x"$glibcxx_cv_c99_math_cxx98" = x"yes"; then
  801. AC_DEFINE(_GLIBCXX98_USE_C99_MATH, 1,
  802. [Define if C99 functions or macros in <math.h> should be imported
  803. in <cmath> in namespace std for C++98.])
  804. fi
  805. # Check for the existence of <complex.h> complex math functions.
  806. # This is necessary even though libstdc++ uses the builtin versions
  807. # of these functions, because if the builtin cannot be used, a reference
  808. # to the library function is emitted.
  809. AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
  810. AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
  811. if test x"$ac_has_complex_h" = x"yes"; then
  812. AC_CACHE_CHECK([for ISO C99 support in <complex.h> for C++98],
  813. glibcxx_cv_c99_complex_cxx98, [
  814. GCC_TRY_COMPILE_OR_LINK(
  815. [#include <complex.h>
  816. typedef __complex__ float float_type;
  817. typedef __complex__ double double_type;
  818. typedef __complex__ long double ld_type;
  819. volatile float_type tmpf;
  820. volatile double_type tmpd;
  821. volatile ld_type tmpld;
  822. volatile float f;
  823. volatile double d;
  824. volatile long double ld;],
  825. [f = cabsf(tmpf);
  826. f = cargf(tmpf);
  827. tmpf = ccosf(tmpf);
  828. tmpf = ccoshf(tmpf);
  829. tmpf = cexpf(tmpf);
  830. tmpf = clogf(tmpf);
  831. tmpf = csinf(tmpf);
  832. tmpf = csinhf(tmpf);
  833. tmpf = csqrtf(tmpf);
  834. tmpf = ctanf(tmpf);
  835. tmpf = ctanhf(tmpf);
  836. tmpf = cpowf(tmpf, tmpf);
  837. tmpf = cprojf(tmpf);
  838. d = cabs(tmpd);
  839. d = carg(tmpd);
  840. tmpd = ccos(tmpd);
  841. tmpd = ccosh(tmpd);
  842. tmpd = cexp(tmpd);
  843. tmpd = clog(tmpd);
  844. tmpd = csin(tmpd);
  845. tmpd = csinh(tmpd);
  846. tmpd = csqrt(tmpd);
  847. tmpd = ctan(tmpd);
  848. tmpd = ctanh(tmpd);
  849. tmpd = cpow(tmpd, tmpd);
  850. tmpd = cproj(tmpd);
  851. ld = cabsl(tmpld);
  852. ld = cargl(tmpld);
  853. tmpld = ccosl(tmpld);
  854. tmpld = ccoshl(tmpld);
  855. tmpld = cexpl(tmpld);
  856. tmpld = clogl(tmpld);
  857. tmpld = csinl(tmpld);
  858. tmpld = csinhl(tmpld);
  859. tmpld = csqrtl(tmpld);
  860. tmpld = ctanl(tmpld);
  861. tmpld = ctanhl(tmpld);
  862. tmpld = cpowl(tmpld, tmpld);
  863. tmpld = cprojl(tmpld);
  864. ], [glibcxx_cv_c99_complex_cxx98=yes], [glibcxx_cv_c99_complex_cxx98=no])
  865. ])
  866. fi
  867. if test x"$glibcxx_cv_c99_complex_cxx98" = x"yes"; then
  868. AC_DEFINE(_GLIBCXX98_USE_C99_COMPLEX, 1,
  869. [Define if C99 functions in <complex.h> should be used in
  870. <complex> for C++98. Using compiler builtins for these functions
  871. requires corresponding C99 library functions to be present.])
  872. fi
  873. # Check for the existence in <stdio.h> of vscanf, et. al.
  874. AC_CACHE_CHECK([for ISO C99 support in <stdio.h> for C++98],
  875. glibcxx_cv_c99_stdio_cxx98, [
  876. GCC_TRY_COMPILE_OR_LINK(
  877. [#include <stdio.h>
  878. #include <stdarg.h>
  879. void foo(char* fmt, ...)
  880. {
  881. va_list args; va_start(args, fmt);
  882. vfscanf(stderr, "%i", args);
  883. vscanf("%i", args);
  884. vsnprintf(fmt, 0, "%i", args);
  885. vsscanf(fmt, "%i", args);
  886. snprintf(fmt, 0, "%i");
  887. }], [],
  888. [glibcxx_cv_c99_stdio_cxx98=yes], [glibcxx_cv_c99_stdio_cxx98=no])
  889. ])
  890. if test x"$glibcxx_cv_c99_stdio_cxx98" = x"yes"; then
  891. AC_DEFINE(_GLIBCXX98_USE_C99_STDIO, 1,
  892. [Define if C99 functions or macros in <stdio.h> should be imported
  893. in <cstdio> in namespace std for C++98.])
  894. fi
  895. # Check for the existence in <stdlib.h> of lldiv_t, et. al.
  896. AC_CACHE_CHECK([for ISO C99 support in <stdlib.h> for C++98],
  897. glibcxx_cv_c99_stdlib_cxx98, [
  898. GCC_TRY_COMPILE_OR_LINK(
  899. [#include <stdlib.h>
  900. volatile float f;
  901. volatile long double ld;
  902. volatile unsigned long long ll;
  903. lldiv_t mydivt;],
  904. [char* tmp;
  905. f = strtof("gnu", &tmp);
  906. ld = strtold("gnu", &tmp);
  907. ll = strtoll("gnu", &tmp, 10);
  908. ll = strtoull("gnu", &tmp, 10);
  909. ll = llabs(10);
  910. mydivt = lldiv(10,1);
  911. ll = mydivt.quot;
  912. ll = mydivt.rem;
  913. ll = atoll("10");
  914. _Exit(0);
  915. ], [glibcxx_cv_c99_stdlib_cxx98=yes], [glibcxx_cv_c99_stdlib_cxx98=no])
  916. ])
  917. if test x"$glibcxx_cv_c99_stdlib_cxx98" = x"yes"; then
  918. AC_DEFINE(_GLIBCXX98_USE_C99_STDLIB, 1,
  919. [Define if C99 functions or macros in <stdlib.h> should be imported
  920. in <cstdlib> in namespace std for C++98.])
  921. fi
  922. # Check for the existence in <wchar.h> of wcstold, etc.
  923. if test x"$ac_has_wchar_h" = xyes &&
  924. test x"$ac_has_wctype_h" = xyes; then
  925. AC_CACHE_CHECK([for ISO C99 support in <wchar.h> for C++98],
  926. glibcxx_cv_c99_wchar_cxx98, [
  927. AC_TRY_COMPILE([#include <wchar.h>
  928. namespace test
  929. {
  930. using ::wcstold;
  931. using ::wcstoll;
  932. using ::wcstoull;
  933. }
  934. ], [], [glibcxx_cv_c99_wchar_cxx98=yes], [glibcxx_cv_c99_wchar_cxx98=no])
  935. ])
  936. # Checks for wide character functions that may not be present.
  937. # Injection of these is wrapped with guard macros.
  938. # NB: only put functions here, instead of immediately above, if
  939. # absolutely necessary.
  940. AC_TRY_COMPILE([#include <wchar.h>
  941. namespace test { using ::vfwscanf; }], [],
  942. [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], [])
  943. AC_TRY_COMPILE([#include <wchar.h>
  944. namespace test { using ::vswscanf; }], [],
  945. [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], [])
  946. AC_TRY_COMPILE([#include <wchar.h>
  947. namespace test { using ::vwscanf; }], [],
  948. [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], [])
  949. AC_TRY_COMPILE([#include <wchar.h>
  950. namespace test { using ::wcstof; }], [],
  951. [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], [])
  952. AC_TRY_COMPILE([#include <wctype.h>],
  953. [wint_t t; int i = iswblank(t);],
  954. [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], [])
  955. if test x"$glibcxx_cv_c99_wchar_cxx98" = x"yes"; then
  956. AC_DEFINE(_GLIBCXX98_USE_C99_WCHAR, 1,
  957. [Define if C99 functions or macros in <wchar.h> should be imported
  958. in <cwchar> in namespace std for C++98.])
  959. fi
  960. fi
  961. # Option parsed, now set things appropriately.
  962. if test x"$glibcxx_cv_c99_math_cxx98" = x"no" ||
  963. test x"$glibcxx_cv_c99_complex_cxx98" = x"no" ||
  964. test x"$glibcxx_cv_c99_stdio_cxx98" = x"no" ||
  965. test x"$glibcxx_cv_c99_stdlib_cxx98" = x"no" ||
  966. test x"$glibcxx_cv_c99_wchar_cxx98" = x"no"; then
  967. enable_c99=no;
  968. else
  969. AC_DEFINE(_GLIBCXX_USE_C99, 1,
  970. [Define if C99 functions or macros from <wchar.h>, <math.h>,
  971. <complex.h>, <stdio.h>, and <stdlib.h> can be used or exposed.])
  972. fi
  973. gcc_no_link="$ac_save_gcc_no_link"
  974. LIBS="$ac_save_LIBS"
  975. CXXFLAGS="$ac_save_CXXFLAGS"
  976. AC_LANG_RESTORE
  977. AC_LANG_SAVE
  978. AC_LANG_CPLUSPLUS
  979. # Use -std=c++11 and test again for C99 library feature in C++11 mode.
  980. # For the reasons given above we use -std=c++11 not -std=gnu++11.
  981. ac_save_CXXFLAGS="$CXXFLAGS"
  982. CXXFLAGS="$CXXFLAGS -std=c++11"
  983. ac_save_LIBS="$LIBS"
  984. ac_save_gcc_no_link="$gcc_no_link"
  985. if test x$gcc_no_link != xyes; then
  986. # Use -fno-exceptions to that the C driver can link these tests without
  987. # hitting undefined references to personality routines.
  988. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  989. AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [
  990. # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
  991. gcc_no_link=yes
  992. ])
  993. fi
  994. # Check for the existence of <math.h> functions used if C99 is enabled.
  995. AC_CACHE_CHECK([for ISO C99 support in <math.h> for C++11],
  996. glibcxx_cv_c99_math_cxx11, [
  997. GCC_TRY_COMPILE_OR_LINK(
  998. [#include <math.h>
  999. volatile double d1, d2;
  1000. volatile int i;],
  1001. [i = fpclassify(d1);
  1002. i = isfinite(d1);
  1003. i = isinf(d1);
  1004. i = isnan(d1);
  1005. i = isnormal(d1);
  1006. i = signbit(d1);
  1007. i = isgreater(d1, d2);
  1008. i = isgreaterequal(d1, d2);
  1009. i = isless(d1, d2);
  1010. i = islessequal(d1, d2);
  1011. i = islessgreater(d1, d2);
  1012. i = islessgreater(d1, d2);
  1013. i = isunordered(d1, d2);
  1014. ], [glibcxx_cv_c99_math_cxx11=yes], [glibcxx_cv_c99_math_cxx11=no])
  1015. ])
  1016. if test x"$glibcxx_cv_c99_math_cxx11" = x"yes"; then
  1017. AC_DEFINE(_GLIBCXX11_USE_C99_MATH, 1,
  1018. [Define if C99 functions or macros in <math.h> should be imported
  1019. in <cmath> in namespace std for C++11.])
  1020. fi
  1021. # Check for the existence of <complex.h> complex math functions.
  1022. # This is necessary even though libstdc++ uses the builtin versions
  1023. # of these functions, because if the builtin cannot be used, a reference
  1024. # to the library function is emitted.
  1025. AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
  1026. AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
  1027. if test x"$ac_has_complex_h" = x"yes"; then
  1028. AC_CACHE_CHECK([for ISO C99 support in <complex.h> for C++11],
  1029. glibcxx_cv_c99_complex_cxx11, [
  1030. GCC_TRY_COMPILE_OR_LINK(
  1031. [#include <complex.h>
  1032. typedef __complex__ float float_type;
  1033. typedef __complex__ double double_type;
  1034. typedef __complex__ long double ld_type;
  1035. volatile float_type tmpf;
  1036. volatile double_type tmpd;
  1037. volatile ld_type tmpld;
  1038. volatile float f;
  1039. volatile double d;
  1040. volatile long double ld;],
  1041. [f = cabsf(tmpf);
  1042. f = cargf(tmpf);
  1043. tmpf = ccosf(tmpf);
  1044. tmpf = ccoshf(tmpf);
  1045. tmpf = cexpf(tmpf);
  1046. tmpf = clogf(tmpf);
  1047. tmpf = csinf(tmpf);
  1048. tmpf = csinhf(tmpf);
  1049. tmpf = csqrtf(tmpf);
  1050. tmpf = ctanf(tmpf);
  1051. tmpf = ctanhf(tmpf);
  1052. tmpf = cpowf(tmpf, tmpf);
  1053. tmpf = cprojf(tmpf);
  1054. d = cabs(tmpd);
  1055. d = carg(tmpd);
  1056. tmpd = ccos(tmpd);
  1057. tmpd = ccosh(tmpd);
  1058. tmpd = cexp(tmpd);
  1059. tmpd = clog(tmpd);
  1060. tmpd = csin(tmpd);
  1061. tmpd = csinh(tmpd);
  1062. tmpd = csqrt(tmpd);
  1063. tmpd = ctan(tmpd);
  1064. tmpd = ctanh(tmpd);
  1065. tmpd = cpow(tmpd, tmpd);
  1066. tmpd = cproj(tmpd);
  1067. ld = cabsl(tmpld);
  1068. ld = cargl(tmpld);
  1069. tmpld = ccosl(tmpld);
  1070. tmpld = ccoshl(tmpld);
  1071. tmpld = cexpl(tmpld);
  1072. tmpld = clogl(tmpld);
  1073. tmpld = csinl(tmpld);
  1074. tmpld = csinhl(tmpld);
  1075. tmpld = csqrtl(tmpld);
  1076. tmpld = ctanl(tmpld);
  1077. tmpld = ctanhl(tmpld);
  1078. tmpld = cpowl(tmpld, tmpld);
  1079. tmpld = cprojl(tmpld);
  1080. ], [glibcxx_cv_c99_complex_cxx11=yes], [glibcxx_cv_c99_complex_cxx11=no])
  1081. ])
  1082. fi
  1083. if test x"$glibcxx_cv_c99_complex_cxx11" = x"yes"; then
  1084. AC_DEFINE(_GLIBCXX11_USE_C99_COMPLEX, 1,
  1085. [Define if C99 functions in <complex.h> should be used in
  1086. <complex> for C++11. Using compiler builtins for these functions
  1087. requires corresponding C99 library functions to be present.])
  1088. fi
  1089. # Check for the existence in <stdio.h> of vscanf, et. al.
  1090. AC_CACHE_CHECK([for ISO C99 support in <stdio.h> for C++11],
  1091. glibcxx_cv_c99_stdio_cxx11, [
  1092. GCC_TRY_COMPILE_OR_LINK(
  1093. [#include <stdio.h>
  1094. #include <stdarg.h>
  1095. void foo(char* fmt, ...)
  1096. {
  1097. va_list args; va_start(args, fmt);
  1098. vfscanf(stderr, "%i", args);
  1099. vscanf("%i", args);
  1100. vsnprintf(fmt, 0, "%i", args);
  1101. vsscanf(fmt, "%i", args);
  1102. snprintf(fmt, 0, "%i");
  1103. }], [],
  1104. [glibcxx_cv_c99_stdio_cxx11=yes], [glibcxx_cv_c99_stdio_cxx11=no])
  1105. ])
  1106. if test x"$glibcxx_cv_c99_stdio_cxx11" = x"yes"; then
  1107. AC_DEFINE(_GLIBCXX11_USE_C99_STDIO, 1,
  1108. [Define if C99 functions or macros in <stdio.h> should be imported
  1109. in <cstdio> in namespace std for C++11.])
  1110. fi
  1111. # Check for the existence in <stdlib.h> of lldiv_t, et. al.
  1112. AC_CACHE_CHECK([for ISO C99 support in <stdlib.h> for C++11],
  1113. glibcxx_cv_c99_stdlib_cxx11, [
  1114. GCC_TRY_COMPILE_OR_LINK(
  1115. [#include <stdlib.h>
  1116. volatile float f;
  1117. volatile long double ld;
  1118. volatile unsigned long long ll;
  1119. lldiv_t mydivt;],
  1120. [char* tmp;
  1121. f = strtof("gnu", &tmp);
  1122. ld = strtold("gnu", &tmp);
  1123. ll = strtoll("gnu", &tmp, 10);
  1124. ll = strtoull("gnu", &tmp, 10);
  1125. ll = llabs(10);
  1126. mydivt = lldiv(10,1);
  1127. ll = mydivt.quot;
  1128. ll = mydivt.rem;
  1129. ll = atoll("10");
  1130. _Exit(0);
  1131. ], [glibcxx_cv_c99_stdlib_cxx11=yes], [glibcxx_cv_c99_stdlib_cxx11=no])
  1132. ])
  1133. if test x"$glibcxx_cv_c99_stdlib_cxx11" = x"yes"; then
  1134. AC_DEFINE(_GLIBCXX11_USE_C99_STDLIB, 1,
  1135. [Define if C99 functions or macros in <stdlib.h> should be imported
  1136. in <cstdlib> in namespace std for C++11.])
  1137. fi
  1138. # Check for the existence in <wchar.h> of wcstold, etc.
  1139. if test x"$ac_has_wchar_h" = xyes &&
  1140. test x"$ac_has_wctype_h" = xyes; then
  1141. AC_CACHE_CHECK([for ISO C99 support in <wchar.h> for C++11],
  1142. glibcxx_cv_c99_wchar_cxx11, [
  1143. AC_TRY_COMPILE([#include <wchar.h>
  1144. namespace test
  1145. {
  1146. using ::wcstold;
  1147. using ::wcstoll;
  1148. using ::wcstoull;
  1149. }
  1150. ], [], [glibcxx_cv_c99_wchar_cxx11=yes], [glibcxx_cv_c99_wchar_cxx11=no])
  1151. ])
  1152. # Checks for wide character functions that may not be present.
  1153. # Injection of these is wrapped with guard macros.
  1154. # NB: only put functions here, instead of immediately above, if
  1155. # absolutely necessary.
  1156. AC_TRY_COMPILE([#include <wchar.h>
  1157. namespace test { using ::vfwscanf; }], [],
  1158. [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], [])
  1159. AC_TRY_COMPILE([#include <wchar.h>
  1160. namespace test { using ::vswscanf; }], [],
  1161. [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], [])
  1162. AC_TRY_COMPILE([#include <wchar.h>
  1163. namespace test { using ::vwscanf; }], [],
  1164. [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], [])
  1165. AC_TRY_COMPILE([#include <wchar.h>
  1166. namespace test { using ::wcstof; }], [],
  1167. [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], [])
  1168. AC_TRY_COMPILE([#include <wctype.h>],
  1169. [wint_t t; int i = iswblank(t);],
  1170. [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], [])
  1171. if test x"$glibcxx_cv_c99_wchar_cxx11" = x"yes"; then
  1172. AC_DEFINE(_GLIBCXX11_USE_C99_WCHAR, 1,
  1173. [Define if C99 functions or macros in <wchar.h> should be imported
  1174. in <cwchar> in namespace std for C++11.])
  1175. fi
  1176. fi
  1177. gcc_no_link="$ac_save_gcc_no_link"
  1178. LIBS="$ac_save_LIBS"
  1179. CXXFLAGS="$ac_save_CXXFLAGS"
  1180. AC_LANG_RESTORE
  1181. fi
  1182. AC_MSG_CHECKING([for fully enabled ISO C99 support])
  1183. AC_MSG_RESULT($enable_c99)
  1184. ])
  1185. dnl
  1186. dnl Check for clock_gettime, nanosleep and sched_yield, used in the
  1187. dnl implementation of 20.11.7 [time.clock], and 30.3.2 [thread.thread.this]
  1188. dnl in the C++11 standard.
  1189. dnl
  1190. dnl --enable-libstdcxx-time
  1191. dnl --enable-libstdcxx-time=yes
  1192. dnl checks for the availability of monotonic and realtime clocks,
  1193. dnl nanosleep and sched_yield in libc.
  1194. dnl --enable-libstdcxx-time=rt
  1195. dnl also searches (and, if needed, links) librt. Note that this is
  1196. dnl not always desirable because, in glibc 2.16 and earlier, for
  1197. dnl example, in turn it triggers the linking of libpthread too,
  1198. dnl which activates locking,
  1199. dnl a large overhead for single-thread programs.
  1200. dnl --enable-libstdcxx-time=no
  1201. dnl --disable-libstdcxx-time
  1202. dnl disables the checks completely
  1203. dnl
  1204. dnl N.B. Darwin provides nanosleep but doesn't support the whole POSIX
  1205. dnl Timers option, so doesn't define _POSIX_TIMERS. Because the test
  1206. dnl below fails Darwin unconditionally defines _GLIBCXX_USE_NANOSLEEP in
  1207. dnl os_defines.h and also defines _GLIBCXX_USE_SCHED_YIELD.
  1208. dnl
  1209. AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
  1210. GLIBCXX_ENABLE(libstdcxx-time,auto,[[[=KIND]]],
  1211. [use KIND for check type],
  1212. [permit yes|no|rt])
  1213. AC_LANG_SAVE
  1214. AC_LANG_CPLUSPLUS
  1215. ac_save_CXXFLAGS="$CXXFLAGS"
  1216. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  1217. ac_save_LIBS="$LIBS"
  1218. ac_has_clock_monotonic=no
  1219. ac_has_clock_realtime=no
  1220. ac_has_nanosleep=no
  1221. ac_has_sched_yield=no
  1222. if test x"$enable_libstdcxx_time" = x"auto"; then
  1223. case "${target_os}" in
  1224. cygwin*)
  1225. ac_has_nanosleep=yes
  1226. ;;
  1227. darwin*)
  1228. ac_has_nanosleep=yes
  1229. ac_has_sched_yield=yes
  1230. ;;
  1231. # VxWorks has nanosleep as soon as the kernel is configured with
  1232. # INCLUDE_POSIX_TIMERS, which is normally/most-often the case.
  1233. vxworks*)
  1234. ac_has_nanosleep=yes
  1235. ;;
  1236. gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
  1237. # Don't use link test for freestanding library, in case gcc_no_link=yes
  1238. if test x"$is_hosted" = xyes; then
  1239. # Versions of glibc before 2.17 needed -lrt for clock_gettime.
  1240. AC_SEARCH_LIBS(clock_gettime, [rt])
  1241. if test x"$ac_cv_search_clock_gettime" = x"none required"; then
  1242. ac_has_clock_monotonic=yes
  1243. ac_has_clock_realtime=yes
  1244. fi
  1245. fi
  1246. ac_has_nanosleep=yes
  1247. ac_has_sched_yield=yes
  1248. ;;
  1249. freebsd*|netbsd*|dragonfly*|rtems*)
  1250. ac_has_clock_monotonic=yes
  1251. ac_has_clock_realtime=yes
  1252. ac_has_nanosleep=yes
  1253. ac_has_sched_yield=yes
  1254. ;;
  1255. openbsd*)
  1256. ac_has_clock_monotonic=yes
  1257. ac_has_clock_realtime=yes
  1258. ac_has_nanosleep=yes
  1259. ;;
  1260. solaris*)
  1261. ac_has_clock_monotonic=yes
  1262. ac_has_clock_realtime=yes
  1263. ac_has_nanosleep=yes
  1264. ac_has_sched_yield=yes
  1265. ;;
  1266. uclinux*)
  1267. ac_has_nanosleep=yes
  1268. ac_has_sched_yield=yes
  1269. esac
  1270. elif test x"$enable_libstdcxx_time" != x"no"; then
  1271. if test x"$enable_libstdcxx_time" = x"rt"; then
  1272. AC_SEARCH_LIBS(clock_gettime, [rt])
  1273. AC_SEARCH_LIBS(nanosleep, [rt])
  1274. else
  1275. AC_CHECK_FUNC(clock_gettime)
  1276. AC_CHECK_FUNC(nanosleep)
  1277. fi
  1278. case "$ac_cv_search_clock_gettime" in
  1279. -l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime
  1280. ;;
  1281. esac
  1282. case "$ac_cv_search_nanosleep" in
  1283. -l*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_nanosleep"
  1284. ;;
  1285. esac
  1286. AC_SEARCH_LIBS(sched_yield, [rt])
  1287. case "$ac_cv_search_sched_yield" in
  1288. -lrt*)
  1289. if test x"$enable_libstdcxx_time" = x"rt"; then
  1290. GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
  1291. ac_has_sched_yield=yes
  1292. fi
  1293. ;;
  1294. *)
  1295. ac_has_sched_yield=yes
  1296. ;;
  1297. esac
  1298. AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
  1299. if test x"$ac_has_unistd_h" = x"yes"; then
  1300. AC_MSG_CHECKING([for monotonic clock])
  1301. AC_TRY_LINK(
  1302. [#include <unistd.h>
  1303. #include <time.h>
  1304. ],
  1305. [#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
  1306. timespec tp;
  1307. #endif
  1308. clock_gettime(CLOCK_MONOTONIC, &tp);
  1309. ], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no])
  1310. AC_MSG_RESULT($ac_has_clock_monotonic)
  1311. AC_MSG_CHECKING([for realtime clock])
  1312. AC_TRY_LINK(
  1313. [#include <unistd.h>
  1314. #include <time.h>
  1315. ],
  1316. [#if _POSIX_TIMERS > 0
  1317. timespec tp;
  1318. #endif
  1319. clock_gettime(CLOCK_REALTIME, &tp);
  1320. ], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
  1321. AC_MSG_RESULT($ac_has_clock_realtime)
  1322. AC_MSG_CHECKING([for nanosleep])
  1323. AC_TRY_LINK(
  1324. [#include <unistd.h>
  1325. #include <time.h>
  1326. ],
  1327. [#if _POSIX_TIMERS > 0
  1328. timespec tp;
  1329. #endif
  1330. nanosleep(&tp, 0);
  1331. ], [ac_has_nanosleep=yes], [ac_has_nanosleep=no])
  1332. AC_MSG_RESULT($ac_has_nanosleep)
  1333. fi
  1334. fi
  1335. if test x"$ac_has_clock_monotonic" != x"yes"; then
  1336. case ${target_os} in
  1337. linux* | uclinux*)
  1338. AC_MSG_CHECKING([for clock_gettime syscall])
  1339. AC_TRY_COMPILE(
  1340. [#include <unistd.h>
  1341. #include <time.h>
  1342. #include <sys/syscall.h>
  1343. ],
  1344. [#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
  1345. timespec tp;
  1346. #endif
  1347. syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &tp);
  1348. syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp);
  1349. ], [ac_has_clock_gettime_syscall=yes], [ac_has_clock_gettime_syscall=no])
  1350. AC_MSG_RESULT($ac_has_clock_gettime_syscall)
  1351. if test x"$ac_has_clock_gettime_syscall" = x"yes"; then
  1352. AC_DEFINE(_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL, 1,
  1353. [Defined if clock_gettime syscall has monotonic and realtime clock support. ])
  1354. ac_has_clock_monotonic=yes
  1355. ac_has_clock_realtime=yes
  1356. AC_MSG_CHECKING([for struct timespec that matches syscall])
  1357. AC_TRY_COMPILE(
  1358. [#include <time.h>
  1359. #include <sys/syscall.h>
  1360. ],
  1361. [#ifdef SYS_clock_gettime64
  1362. #if SYS_clock_gettime64 != SYS_clock_gettime
  1363. // We need to use SYS_clock_gettime and libc appears to
  1364. // also know about the SYS_clock_gettime64 syscall.
  1365. // Check that userspace doesn't use time64 version of timespec.
  1366. static_assert(sizeof(timespec::tv_sec) == sizeof(long),
  1367. "struct timespec must be compatible with SYS_clock_gettime");
  1368. #endif
  1369. #endif
  1370. ],
  1371. [ac_timespec_matches_syscall=yes],
  1372. [ac_timespec_matches_syscall=no])
  1373. AC_MSG_RESULT($ac_timespec_matches_syscall)
  1374. if test x"$ac_timespec_matches_syscall" = no; then
  1375. AC_MSG_ERROR([struct timespec is not compatible with SYS_clock_gettime, please report a bug to http://gcc.gnu.org/bugzilla])
  1376. fi
  1377. fi;;
  1378. esac
  1379. fi
  1380. if test x"$ac_has_clock_monotonic" = x"yes"; then
  1381. AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC, 1,
  1382. [ Defined if clock_gettime has monotonic clock support. ])
  1383. fi
  1384. if test x"$ac_has_clock_realtime" = x"yes"; then
  1385. AC_DEFINE(_GLIBCXX_USE_CLOCK_REALTIME, 1,
  1386. [ Defined if clock_gettime has realtime clock support. ])
  1387. fi
  1388. if test x"$ac_has_sched_yield" = x"yes"; then
  1389. AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
  1390. [ Defined if sched_yield is available. ])
  1391. fi
  1392. if test x"$ac_has_nanosleep" = x"yes"; then
  1393. AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
  1394. [ Defined if nanosleep is available. ])
  1395. else
  1396. AC_MSG_CHECKING([for sleep])
  1397. AC_TRY_COMPILE([#include <unistd.h>],
  1398. [sleep(1)],
  1399. [ac_has_sleep=yes],[ac_has_sleep=no])
  1400. if test x"$ac_has_sleep" = x"yes"; then
  1401. AC_DEFINE(HAVE_SLEEP,1, [Defined if sleep exists.])
  1402. fi
  1403. AC_MSG_RESULT($ac_has_sleep)
  1404. AC_MSG_CHECKING([for usleep])
  1405. AC_TRY_COMPILE([#include <unistd.h>],
  1406. [sleep(1);
  1407. usleep(100);],
  1408. [ac_has_usleep=yes],[ac_has_usleep=no])
  1409. if test x"$ac_has_usleep" = x"yes"; then
  1410. AC_DEFINE(HAVE_USLEEP,1, [Defined if usleep exists.])
  1411. fi
  1412. AC_MSG_RESULT($ac_has_usleep)
  1413. fi
  1414. if test x"$ac_has_nanosleep$ac_has_sleep" = x"nono"; then
  1415. ac_no_sleep=yes
  1416. AC_MSG_CHECKING([for Sleep])
  1417. AC_TRY_COMPILE([#include <windows.h>],
  1418. [Sleep(1)],
  1419. [ac_has_win32_sleep=yes],[ac_has_win32_sleep=no])
  1420. if test x"$ac_has_win32_sleep" = x"yes"; then
  1421. AC_DEFINE(HAVE_WIN32_SLEEP,1, [Defined if Sleep exists.])
  1422. ac_no_sleep=no
  1423. fi
  1424. AC_MSG_RESULT($ac_has_win32_sleep)
  1425. fi
  1426. if test x"$ac_no_sleep" = x"yes"; then
  1427. AC_DEFINE(_GLIBCXX_NO_SLEEP,1, [Defined if no way to sleep is available.])
  1428. fi
  1429. AC_SUBST(GLIBCXX_LIBS)
  1430. CXXFLAGS="$ac_save_CXXFLAGS"
  1431. LIBS="$ac_save_LIBS"
  1432. AC_LANG_RESTORE
  1433. ])
  1434. dnl
  1435. dnl Check for gettimeofday, used in the implementation of 20.11.7
  1436. dnl [time.clock] in the C++11 standard.
  1437. dnl
  1438. AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
  1439. AC_MSG_CHECKING([for gettimeofday])
  1440. AC_LANG_SAVE
  1441. AC_LANG_CPLUSPLUS
  1442. ac_save_CXXFLAGS="$CXXFLAGS"
  1443. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  1444. ac_has_gettimeofday=no;
  1445. AC_CHECK_HEADERS(sys/time.h, ac_has_sys_time_h=yes, ac_has_sys_time_h=no)
  1446. if test x"$ac_has_sys_time_h" = x"yes"; then
  1447. AC_MSG_CHECKING([for gettimeofday])
  1448. GCC_TRY_COMPILE_OR_LINK([#include <sys/time.h>],
  1449. [timeval tv; gettimeofday(&tv, 0);],
  1450. [ac_has_gettimeofday=yes], [ac_has_gettimeofday=no])
  1451. AC_MSG_RESULT($ac_has_gettimeofday)
  1452. fi
  1453. if test x"$ac_has_gettimeofday" = x"yes"; then
  1454. AC_DEFINE(_GLIBCXX_USE_GETTIMEOFDAY, 1,
  1455. [ Defined if gettimeofday is available. ])
  1456. fi
  1457. CXXFLAGS="$ac_save_CXXFLAGS"
  1458. AC_LANG_RESTORE
  1459. ])
  1460. dnl
  1461. dnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
  1462. dnl facilities in Chapter 8, "C compatibility".
  1463. dnl
  1464. AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
  1465. AC_LANG_SAVE
  1466. AC_LANG_CPLUSPLUS
  1467. # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
  1468. # undefined and fake C99 facilities may be spuriously enabled.
  1469. ac_save_CXXFLAGS="$CXXFLAGS"
  1470. CXXFLAGS="$CXXFLAGS -std=c++98"
  1471. # Check for the existence of <complex.h> complex math functions used
  1472. # by tr1/complex.
  1473. AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
  1474. ac_c99_complex_tr1=no;
  1475. if test x"$ac_has_complex_h" = x"yes"; then
  1476. AC_MSG_CHECKING([for ISO C99 support to TR1 in <complex.h>])
  1477. AC_TRY_COMPILE([#include <complex.h>],
  1478. [typedef __complex__ float float_type; float_type tmpf;
  1479. cacosf(tmpf);
  1480. casinf(tmpf);
  1481. catanf(tmpf);
  1482. cacoshf(tmpf);
  1483. casinhf(tmpf);
  1484. catanhf(tmpf);
  1485. typedef __complex__ double double_type; double_type tmpd;
  1486. cacos(tmpd);
  1487. casin(tmpd);
  1488. catan(tmpd);
  1489. cacosh(tmpd);
  1490. casinh(tmpd);
  1491. catanh(tmpd);
  1492. typedef __complex__ long double ld_type; ld_type tmpld;
  1493. cacosl(tmpld);
  1494. casinl(tmpld);
  1495. catanl(tmpld);
  1496. cacoshl(tmpld);
  1497. casinhl(tmpld);
  1498. catanhl(tmpld);
  1499. ],[ac_c99_complex_tr1=yes], [ac_c99_complex_tr1=no])
  1500. fi
  1501. AC_MSG_RESULT($ac_c99_complex_tr1)
  1502. if test x"$ac_c99_complex_tr1" = x"yes"; then
  1503. AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_TR1, 1,
  1504. [Define if C99 functions in <complex.h> should be used in
  1505. <tr1/complex>. Using compiler builtins for these functions
  1506. requires corresponding C99 library functions to be present.])
  1507. fi
  1508. # Check for the existence of <ctype.h> functions.
  1509. AC_CACHE_CHECK([for ISO C99 support to TR1 in <ctype.h>],
  1510. glibcxx_cv_c99_ctype_tr1, [
  1511. AC_TRY_COMPILE([#include <ctype.h>],
  1512. [int ch;
  1513. int ret;
  1514. ret = isblank(ch);
  1515. ],[glibcxx_cv_c99_ctype_tr1=yes],
  1516. [glibcxx_cv_c99_ctype_tr1=no])
  1517. ])
  1518. if test x"$glibcxx_cv_c99_ctype_tr1" = x"yes"; then
  1519. AC_DEFINE(_GLIBCXX_USE_C99_CTYPE_TR1, 1,
  1520. [Define if C99 functions in <ctype.h> should be imported in
  1521. <tr1/cctype> in namespace std::tr1.])
  1522. fi
  1523. # Check for the existence of <fenv.h> functions.
  1524. AC_CHECK_HEADERS(fenv.h, ac_has_fenv_h=yes, ac_has_fenv_h=no)
  1525. ac_c99_fenv_tr1=no;
  1526. if test x"$ac_has_fenv_h" = x"yes"; then
  1527. AC_MSG_CHECKING([for ISO C99 support to TR1 in <fenv.h>])
  1528. AC_TRY_COMPILE([#include <fenv.h>],
  1529. [int except, mode;
  1530. fexcept_t* pflag;
  1531. fenv_t* penv;
  1532. int ret;
  1533. ret = feclearexcept(except);
  1534. ret = fegetexceptflag(pflag, except);
  1535. ret = feraiseexcept(except);
  1536. ret = fesetexceptflag(pflag, except);
  1537. ret = fetestexcept(except);
  1538. ret = fegetround();
  1539. ret = fesetround(mode);
  1540. ret = fegetenv(penv);
  1541. ret = feholdexcept(penv);
  1542. ret = fesetenv(penv);
  1543. ret = feupdateenv(penv);
  1544. ],[ac_c99_fenv_tr1=yes], [ac_c99_fenv_tr1=no])
  1545. AC_MSG_RESULT($ac_c99_fenv_tr1)
  1546. fi
  1547. if test x"$ac_c99_fenv_tr1" = x"yes"; then
  1548. AC_DEFINE(_GLIBCXX_USE_C99_FENV_TR1, 1,
  1549. [Define if C99 functions in <fenv.h> should be imported in
  1550. <tr1/cfenv> in namespace std::tr1.])
  1551. fi
  1552. # Check for the existence of <stdint.h> types.
  1553. AC_CACHE_CHECK([for ISO C99 support to TR1 in <stdint.h>],
  1554. glibcxx_cv_c99_stdint_tr1, [
  1555. AC_TRY_COMPILE([#define __STDC_LIMIT_MACROS
  1556. #define __STDC_CONSTANT_MACROS
  1557. #include <stdint.h>],
  1558. [typedef int8_t my_int8_t;
  1559. my_int8_t i8 = INT8_MIN;
  1560. i8 = INT8_MAX;
  1561. typedef int16_t my_int16_t;
  1562. my_int16_t i16 = INT16_MIN;
  1563. i16 = INT16_MAX;
  1564. typedef int32_t my_int32_t;
  1565. my_int32_t i32 = INT32_MIN;
  1566. i32 = INT32_MAX;
  1567. typedef int64_t my_int64_t;
  1568. my_int64_t i64 = INT64_MIN;
  1569. i64 = INT64_MAX;
  1570. typedef int_fast8_t my_int_fast8_t;
  1571. my_int_fast8_t if8 = INT_FAST8_MIN;
  1572. if8 = INT_FAST8_MAX;
  1573. typedef int_fast16_t my_int_fast16_t;
  1574. my_int_fast16_t if16 = INT_FAST16_MIN;
  1575. if16 = INT_FAST16_MAX;
  1576. typedef int_fast32_t my_int_fast32_t;
  1577. my_int_fast32_t if32 = INT_FAST32_MIN;
  1578. if32 = INT_FAST32_MAX;
  1579. typedef int_fast64_t my_int_fast64_t;
  1580. my_int_fast64_t if64 = INT_FAST64_MIN;
  1581. if64 = INT_FAST64_MAX;
  1582. typedef int_least8_t my_int_least8_t;
  1583. my_int_least8_t il8 = INT_LEAST8_MIN;
  1584. il8 = INT_LEAST8_MAX;
  1585. typedef int_least16_t my_int_least16_t;
  1586. my_int_least16_t il16 = INT_LEAST16_MIN;
  1587. il16 = INT_LEAST16_MAX;
  1588. typedef int_least32_t my_int_least32_t;
  1589. my_int_least32_t il32 = INT_LEAST32_MIN;
  1590. il32 = INT_LEAST32_MAX;
  1591. typedef int_least64_t my_int_least64_t;
  1592. my_int_least64_t il64 = INT_LEAST64_MIN;
  1593. il64 = INT_LEAST64_MAX;
  1594. typedef intmax_t my_intmax_t;
  1595. my_intmax_t im = INTMAX_MAX;
  1596. im = INTMAX_MIN;
  1597. typedef intptr_t my_intptr_t;
  1598. my_intptr_t ip = INTPTR_MAX;
  1599. ip = INTPTR_MIN;
  1600. typedef uint8_t my_uint8_t;
  1601. my_uint8_t ui8 = UINT8_MAX;
  1602. ui8 = UINT8_MAX;
  1603. typedef uint16_t my_uint16_t;
  1604. my_uint16_t ui16 = UINT16_MAX;
  1605. ui16 = UINT16_MAX;
  1606. typedef uint32_t my_uint32_t;
  1607. my_uint32_t ui32 = UINT32_MAX;
  1608. ui32 = UINT32_MAX;
  1609. typedef uint64_t my_uint64_t;
  1610. my_uint64_t ui64 = UINT64_MAX;
  1611. ui64 = UINT64_MAX;
  1612. typedef uint_fast8_t my_uint_fast8_t;
  1613. my_uint_fast8_t uif8 = UINT_FAST8_MAX;
  1614. uif8 = UINT_FAST8_MAX;
  1615. typedef uint_fast16_t my_uint_fast16_t;
  1616. my_uint_fast16_t uif16 = UINT_FAST16_MAX;
  1617. uif16 = UINT_FAST16_MAX;
  1618. typedef uint_fast32_t my_uint_fast32_t;
  1619. my_uint_fast32_t uif32 = UINT_FAST32_MAX;
  1620. uif32 = UINT_FAST32_MAX;
  1621. typedef uint_fast64_t my_uint_fast64_t;
  1622. my_uint_fast64_t uif64 = UINT_FAST64_MAX;
  1623. uif64 = UINT_FAST64_MAX;
  1624. typedef uint_least8_t my_uint_least8_t;
  1625. my_uint_least8_t uil8 = UINT_LEAST8_MAX;
  1626. uil8 = UINT_LEAST8_MAX;
  1627. typedef uint_least16_t my_uint_least16_t;
  1628. my_uint_least16_t uil16 = UINT_LEAST16_MAX;
  1629. uil16 = UINT_LEAST16_MAX;
  1630. typedef uint_least32_t my_uint_least32_t;
  1631. my_uint_least32_t uil32 = UINT_LEAST32_MAX;
  1632. uil32 = UINT_LEAST32_MAX;
  1633. typedef uint_least64_t my_uint_least64_t;
  1634. my_uint_least64_t uil64 = UINT_LEAST64_MAX;
  1635. uil64 = UINT_LEAST64_MAX;
  1636. typedef uintmax_t my_uintmax_t;
  1637. my_uintmax_t uim = UINTMAX_MAX;
  1638. uim = UINTMAX_MAX;
  1639. typedef uintptr_t my_uintptr_t;
  1640. my_uintptr_t uip = UINTPTR_MAX;
  1641. uip = UINTPTR_MAX;
  1642. ],[glibcxx_cv_c99_stdint_tr1=yes],
  1643. [glibcxx_cv_c99_stdint_tr1=no])
  1644. ])
  1645. if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
  1646. AC_DEFINE(_GLIBCXX_USE_C99_STDINT_TR1, 1,
  1647. [Define if C99 types in <stdint.h> should be imported in
  1648. <tr1/cstdint> in namespace std::tr1.])
  1649. fi
  1650. # Check for the existence of <math.h> functions.
  1651. AC_CACHE_CHECK([for ISO C99 support to TR1 in <math.h>],
  1652. glibcxx_cv_c99_math_tr1, [
  1653. AC_TRY_COMPILE([#include <math.h>],
  1654. [typedef double_t my_double_t;
  1655. typedef float_t my_float_t;
  1656. acosh(0.0);
  1657. acoshf(0.0f);
  1658. acoshl(0.0l);
  1659. asinh(0.0);
  1660. asinhf(0.0f);
  1661. asinhl(0.0l);
  1662. atanh(0.0);
  1663. atanhf(0.0f);
  1664. atanhl(0.0l);
  1665. cbrt(0.0);
  1666. cbrtf(0.0f);
  1667. cbrtl(0.0l);
  1668. copysign(0.0, 0.0);
  1669. copysignf(0.0f, 0.0f);
  1670. copysignl(0.0l, 0.0l);
  1671. erf(0.0);
  1672. erff(0.0f);
  1673. erfl(0.0l);
  1674. erfc(0.0);
  1675. erfcf(0.0f);
  1676. erfcl(0.0l);
  1677. exp2(0.0);
  1678. exp2f(0.0f);
  1679. exp2l(0.0l);
  1680. expm1(0.0);
  1681. expm1f(0.0f);
  1682. expm1l(0.0l);
  1683. fdim(0.0, 0.0);
  1684. fdimf(0.0f, 0.0f);
  1685. fdiml(0.0l, 0.0l);
  1686. fma(0.0, 0.0, 0.0);
  1687. fmaf(0.0f, 0.0f, 0.0f);
  1688. fmal(0.0l, 0.0l, 0.0l);
  1689. fmax(0.0, 0.0);
  1690. fmaxf(0.0f, 0.0f);
  1691. fmaxl(0.0l, 0.0l);
  1692. fmin(0.0, 0.0);
  1693. fminf(0.0f, 0.0f);
  1694. fminl(0.0l, 0.0l);
  1695. hypot(0.0, 0.0);
  1696. hypotf(0.0f, 0.0f);
  1697. hypotl(0.0l, 0.0l);
  1698. ilogb(0.0);
  1699. ilogbf(0.0f);
  1700. ilogbl(0.0l);
  1701. lgamma(0.0);
  1702. lgammaf(0.0f);
  1703. lgammal(0.0l);
  1704. #ifndef __APPLE__ /* see below */
  1705. llrint(0.0);
  1706. llrintf(0.0f);
  1707. llrintl(0.0l);
  1708. llround(0.0);
  1709. llroundf(0.0f);
  1710. llroundl(0.0l);
  1711. #endif
  1712. log1p(0.0);
  1713. log1pf(0.0f);
  1714. log1pl(0.0l);
  1715. log2(0.0);
  1716. log2f(0.0f);
  1717. log2l(0.0l);
  1718. logb(0.0);
  1719. logbf(0.0f);
  1720. logbl(0.0l);
  1721. lrint(0.0);
  1722. lrintf(0.0f);
  1723. lrintl(0.0l);
  1724. lround(0.0);
  1725. lroundf(0.0f);
  1726. lroundl(0.0l);
  1727. nan(0);
  1728. nanf(0);
  1729. nanl(0);
  1730. nearbyint(0.0);
  1731. nearbyintf(0.0f);
  1732. nearbyintl(0.0l);
  1733. nextafter(0.0, 0.0);
  1734. nextafterf(0.0f, 0.0f);
  1735. nextafterl(0.0l, 0.0l);
  1736. nexttoward(0.0, 0.0);
  1737. nexttowardf(0.0f, 0.0f);
  1738. nexttowardl(0.0l, 0.0l);
  1739. remainder(0.0, 0.0);
  1740. remainderf(0.0f, 0.0f);
  1741. remainderl(0.0l, 0.0l);
  1742. remquo(0.0, 0.0, 0);
  1743. remquof(0.0f, 0.0f, 0);
  1744. remquol(0.0l, 0.0l, 0);
  1745. rint(0.0);
  1746. rintf(0.0f);
  1747. rintl(0.0l);
  1748. round(0.0);
  1749. roundf(0.0f);
  1750. roundl(0.0l);
  1751. scalbln(0.0, 0l);
  1752. scalblnf(0.0f, 0l);
  1753. scalblnl(0.0l, 0l);
  1754. scalbn(0.0, 0);
  1755. scalbnf(0.0f, 0);
  1756. scalbnl(0.0l, 0);
  1757. tgamma(0.0);
  1758. tgammaf(0.0f);
  1759. tgammal(0.0l);
  1760. trunc(0.0);
  1761. truncf(0.0f);
  1762. truncl(0.0l);
  1763. ],[glibcxx_cv_c99_math_tr1=yes], [glibcxx_cv_c99_math_tr1=no])
  1764. ])
  1765. if test x"$glibcxx_cv_c99_math_tr1" = x"yes"; then
  1766. AC_DEFINE(_GLIBCXX_USE_C99_MATH_TR1, 1,
  1767. [Define if C99 functions or macros in <math.h> should be imported
  1768. in <tr1/cmath> in namespace std::tr1.])
  1769. case "${target_os}" in
  1770. darwin*)
  1771. AC_CACHE_CHECK([for ISO C99 rounding functions in <math.h>],
  1772. glibcxx_cv_c99_math_llround, [
  1773. AC_TRY_COMPILE([#include <math.h>],
  1774. [llrint(0.0);
  1775. llrintf(0.0f);
  1776. llrintl(0.0l);
  1777. llround(0.0);
  1778. llroundf(0.0f);
  1779. llroundl(0.0l);
  1780. ],
  1781. [glibcxx_cv_c99_math_llround=yes],
  1782. [glibcxx_cv_c99_math_llround=no])
  1783. ])
  1784. ;;
  1785. esac
  1786. if test x"$glibcxx_cv_c99_math_llround" = x"no"; then
  1787. AC_DEFINE(_GLIBCXX_NO_C99_ROUNDING_FUNCS, 1,
  1788. [Define if C99 llrint and llround functions are missing from <math.h>.])
  1789. fi
  1790. fi
  1791. # Check for the existence of <inttypes.h> functions (NB: doesn't make
  1792. # sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
  1793. ac_c99_inttypes_tr1=no;
  1794. if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
  1795. AC_MSG_CHECKING([for ISO C99 support to TR1 in <inttypes.h>])
  1796. AC_TRY_COMPILE([#include <inttypes.h>],
  1797. [intmax_t i, numer, denom, base;
  1798. const char* s;
  1799. char** endptr;
  1800. intmax_t ret = imaxabs(i);
  1801. imaxdiv_t dret = imaxdiv(numer, denom);
  1802. ret = strtoimax(s, endptr, base);
  1803. uintmax_t uret = strtoumax(s, endptr, base);
  1804. ],[ac_c99_inttypes_tr1=yes], [ac_c99_inttypes_tr1=no])
  1805. AC_MSG_RESULT($ac_c99_inttypes_tr1)
  1806. fi
  1807. if test x"$ac_c99_inttypes_tr1" = x"yes"; then
  1808. AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_TR1, 1,
  1809. [Define if C99 functions in <inttypes.h> should be imported in
  1810. <tr1/cinttypes> in namespace std::tr1.])
  1811. fi
  1812. # Check for the existence of wchar_t <inttypes.h> functions (NB: doesn't
  1813. # make sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
  1814. ac_c99_inttypes_wchar_t_tr1=no;
  1815. if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
  1816. AC_MSG_CHECKING([for wchar_t ISO C99 support to TR1 in <inttypes.h>])
  1817. AC_TRY_COMPILE([#include <inttypes.h>],
  1818. [intmax_t base;
  1819. const wchar_t* s;
  1820. wchar_t** endptr;
  1821. intmax_t ret = wcstoimax(s, endptr, base);
  1822. uintmax_t uret = wcstoumax(s, endptr, base);
  1823. ],[ac_c99_inttypes_wchar_t_tr1=yes],
  1824. [ac_c99_inttypes_wchar_t_tr1=no])
  1825. AC_MSG_RESULT($ac_c99_inttypes_wchar_t_tr1)
  1826. fi
  1827. if test x"$ac_c99_inttypes_wchar_t_tr1" = x"yes"; then
  1828. AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1, 1,
  1829. [Define if wchar_t C99 functions in <inttypes.h> should be
  1830. imported in <tr1/cinttypes> in namespace std::tr1.])
  1831. fi
  1832. # Check for the existence of the <stdbool.h> header.
  1833. AC_CHECK_HEADERS(stdbool.h)
  1834. # Check for the existence of the <stdalign.h> header.
  1835. AC_CHECK_HEADERS(stdalign.h)
  1836. CXXFLAGS="$ac_save_CXXFLAGS"
  1837. AC_LANG_RESTORE
  1838. ])
  1839. dnl
  1840. dnl Check for uchar.h and usability.
  1841. dnl
  1842. AC_DEFUN([GLIBCXX_CHECK_UCHAR_H], [
  1843. # Test uchar.h.
  1844. AC_CHECK_HEADERS(uchar.h, ac_has_uchar_h=yes, ac_has_uchar_h=no)
  1845. AC_LANG_SAVE
  1846. AC_LANG_CPLUSPLUS
  1847. ac_save_CXXFLAGS="$CXXFLAGS"
  1848. CXXFLAGS="$CXXFLAGS -std=c++11"
  1849. if test x"$ac_has_uchar_h" = x"yes"; then
  1850. AC_MSG_CHECKING([for ISO C11 support for <uchar.h>])
  1851. AC_TRY_COMPILE([#include <uchar.h>
  1852. #ifdef __STDC_UTF_16__
  1853. long i = __STDC_UTF_16__;
  1854. #endif
  1855. #ifdef __STDC_UTF_32__
  1856. long j = __STDC_UTF_32__;
  1857. #endif
  1858. namespace test
  1859. {
  1860. using ::c16rtomb;
  1861. using ::c32rtomb;
  1862. using ::mbrtoc16;
  1863. using ::mbrtoc32;
  1864. }
  1865. ],
  1866. [], [ac_c11_uchar_cxx11=yes], [ac_c11_uchar_cxx11=no])
  1867. AC_MSG_RESULT($ac_c11_uchar_cxx11)
  1868. else
  1869. ac_c11_uchar_cxx11=no
  1870. fi
  1871. if test x"$ac_c11_uchar_cxx11" = x"yes"; then
  1872. AC_DEFINE(_GLIBCXX_USE_C11_UCHAR_CXX11, 1,
  1873. [Define if C11 functions in <uchar.h> should be imported into
  1874. namespace std in <cuchar>.])
  1875. fi
  1876. CXXFLAGS="$CXXFLAGS -fchar8_t"
  1877. if test x"$ac_has_uchar_h" = x"yes"; then
  1878. AC_MSG_CHECKING([for c8rtomb and mbrtoc8 in <uchar.h> with -fchar8_t])
  1879. AC_TRY_COMPILE([#include <uchar.h>
  1880. namespace test
  1881. {
  1882. using ::c8rtomb;
  1883. using ::mbrtoc8;
  1884. }
  1885. ],
  1886. [], [ac_uchar_c8rtomb_mbrtoc8_fchar8_t=yes],
  1887. [ac_uchar_c8rtomb_mbrtoc8_fchar8_t=no])
  1888. else
  1889. ac_uchar_c8rtomb_mbrtoc8_fchar8_t=no
  1890. fi
  1891. AC_MSG_RESULT($ac_uchar_c8rtomb_mbrtoc8_fchar8_t)
  1892. if test x"$ac_uchar_c8rtomb_mbrtoc8_fchar8_t" = x"yes"; then
  1893. AC_DEFINE(_GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T, 1,
  1894. [Define if c8rtomb and mbrtoc8 functions in <uchar.h> should be
  1895. imported into namespace std in <cuchar> for -fchar8_t.])
  1896. fi
  1897. CXXFLAGS="$CXXFLAGS -std=c++20"
  1898. if test x"$ac_has_uchar_h" = x"yes"; then
  1899. AC_MSG_CHECKING([for c8rtomb and mbrtoc8 in <uchar.h> with -std=c++20])
  1900. AC_TRY_COMPILE([#include <uchar.h>
  1901. namespace test
  1902. {
  1903. using ::c8rtomb;
  1904. using ::mbrtoc8;
  1905. }
  1906. ],
  1907. [], [ac_uchar_c8rtomb_mbrtoc8_cxx20=yes],
  1908. [ac_uchar_c8rtomb_mbrtoc8_cxx20=no])
  1909. else
  1910. ac_uchar_c8rtomb_mbrtoc8_cxx20=no
  1911. fi
  1912. AC_MSG_RESULT($ac_uchar_c8rtomb_mbrtoc8_cxx20)
  1913. if test x"$ac_uchar_c8rtomb_mbrtoc8_cxx20" = x"yes"; then
  1914. AC_DEFINE(_GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20, 1,
  1915. [Define if c8rtomb and mbrtoc8 functions in <uchar.h> should be
  1916. imported into namespace std in <cuchar> for C++20.])
  1917. fi
  1918. CXXFLAGS="$ac_save_CXXFLAGS"
  1919. AC_LANG_RESTORE
  1920. ])
  1921. dnl
  1922. dnl Check whether "/dev/random" and "/dev/urandom" are available for
  1923. dnl class std::random_device from C++ 2011 [rand.device], and
  1924. dnl random_device of "TR1" (Chapter 5.1, "Random number generation").
  1925. dnl
  1926. AC_DEFUN([GLIBCXX_CHECK_DEV_RANDOM], [
  1927. AC_CACHE_CHECK([for "/dev/random" and "/dev/urandom" for std::random_device],
  1928. glibcxx_cv_dev_random, [
  1929. if test -r /dev/random && test -r /dev/urandom; then
  1930. ## For MSys environment the test above is detected as false-positive
  1931. ## on mingw-targets. So disable it explicitly for them.
  1932. case ${target_os} in
  1933. *mingw*) glibcxx_cv_dev_random=no ;;
  1934. *) glibcxx_cv_dev_random=yes ;;
  1935. esac
  1936. else
  1937. glibcxx_cv_dev_random=no;
  1938. fi
  1939. ])
  1940. if test x"$glibcxx_cv_dev_random" = x"yes"; then
  1941. AC_DEFINE(_GLIBCXX_USE_DEV_RANDOM, 1,
  1942. [Define if /dev/random and /dev/urandom are available for
  1943. std::random_device.])
  1944. AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1, 1,
  1945. [Define if /dev/random and /dev/urandom are available for
  1946. the random_device of TR1 (Chapter 5.1).])
  1947. fi
  1948. ])
  1949. dnl
  1950. dnl Compute the EOF, SEEK_CUR, and SEEK_END integer constants.
  1951. dnl
  1952. AC_DEFUN([GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS], [
  1953. if test "$is_hosted" = yes; then
  1954. AC_CACHE_CHECK([for the value of EOF], glibcxx_cv_stdio_eof, [
  1955. AC_COMPUTE_INT([glibcxx_cv_stdio_eof], [[EOF]],
  1956. [#include <stdio.h>],
  1957. [AC_MSG_ERROR([computing EOF failed])])
  1958. ])
  1959. AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_EOF, $glibcxx_cv_stdio_eof,
  1960. [Define to the value of the EOF integer constant.])
  1961. AC_CACHE_CHECK([for the value of SEEK_CUR], glibcxx_cv_stdio_seek_cur, [
  1962. AC_COMPUTE_INT([glibcxx_cv_stdio_seek_cur], [[SEEK_CUR]],
  1963. [#include <stdio.h>],
  1964. [AC_MSG_ERROR([computing SEEK_CUR failed])])
  1965. ])
  1966. AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_SEEK_CUR, $glibcxx_cv_stdio_seek_cur,
  1967. [Define to the value of the SEEK_CUR integer constant.])
  1968. AC_CACHE_CHECK([for the value of SEEK_END], glibcxx_cv_stdio_seek_end, [
  1969. AC_COMPUTE_INT([glibcxx_cv_stdio_seek_end], [[SEEK_END]],
  1970. [#include <stdio.h>],
  1971. [AC_MSG_ERROR([computing SEEK_END failed])])
  1972. ])
  1973. AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_SEEK_END, $glibcxx_cv_stdio_seek_end,
  1974. [Define to the value of the SEEK_END integer constant.])
  1975. fi
  1976. ])
  1977. dnl
  1978. dnl Check whether required C++ overloads are present in <stdio.h>.
  1979. dnl
  1980. AC_DEFUN([GLIBCXX_CHECK_STDIO_PROTO], [
  1981. AC_LANG_SAVE
  1982. AC_LANG_CPLUSPLUS
  1983. # Use C++11 because a conforming <stdio.h> won't define gets for C++14,
  1984. # and we don't need a declaration for C++14 anyway.
  1985. ac_save_CXXFLAGS="$CXXFLAGS"
  1986. CXXFLAGS="$CXXFLAGS -std=gnu++11"
  1987. AC_CACHE_CHECK([for gets declaration], glibcxx_cv_gets, [
  1988. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1989. [#include <stdio.h>
  1990. namespace test
  1991. {
  1992. using ::gets;
  1993. }
  1994. ])],
  1995. [glibcxx_cv_gets=yes],
  1996. [glibcxx_cv_gets=no]
  1997. )])
  1998. if test $glibcxx_cv_gets = yes; then
  1999. AC_DEFINE(HAVE_GETS, 1, [Define if gets is available in <stdio.h> before C++14.])
  2000. fi
  2001. CXXFLAGS="$ac_save_CXXFLAGS"
  2002. AC_LANG_RESTORE
  2003. ])
  2004. dnl
  2005. dnl Check whether required C++11 overloads for floating point and integral
  2006. dnl types are present in <math.h>.
  2007. dnl
  2008. AC_DEFUN([GLIBCXX_CHECK_MATH11_PROTO], [
  2009. AC_LANG_SAVE
  2010. AC_LANG_CPLUSPLUS
  2011. ac_save_CXXFLAGS="$CXXFLAGS"
  2012. CXXFLAGS="$CXXFLAGS -std=c++11"
  2013. case "$host" in
  2014. *-*-solaris2.*)
  2015. # Solaris 12 Build 86, Solaris 11.3 SRU 3.6, and Solaris 10 Patch
  2016. # 11996[67]-02 introduced the C++11 <math.h> floating point overloads.
  2017. AC_CACHE_CHECK([for C++11 <math.h> floating point overloads],
  2018. glibcxx_cv_math11_fp_overload, [
  2019. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  2020. [#include <math.h>
  2021. #undef isfinite
  2022. namespace std {
  2023. inline bool isfinite(float __x)
  2024. { return __builtin_isfinite(__x); }
  2025. }
  2026. ])],
  2027. [glibcxx_cv_math11_fp_overload=no],
  2028. [glibcxx_cv_math11_fp_overload=yes]
  2029. )])
  2030. # autoheader cannot handle indented templates.
  2031. AH_VERBATIM([__CORRECT_ISO_CPP11_MATH_H_PROTO_FP],
  2032. [/* Define if all C++11 floating point overloads are available in <math.h>. */
  2033. #if __cplusplus >= 201103L
  2034. #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  2035. #endif])
  2036. if test $glibcxx_cv_math11_fp_overload = yes; then
  2037. AC_DEFINE(__CORRECT_ISO_CPP11_MATH_H_PROTO_FP)
  2038. fi
  2039. # Solaris 12 Build 90, Solaris 11.3 SRU 5.6, and Solaris 10 Patch
  2040. # 11996[67]-02 introduced the C++11 <math.h> integral type overloads.
  2041. AC_CACHE_CHECK([for C++11 <math.h> integral type overloads],
  2042. glibcxx_cv_math11_int_overload, [
  2043. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  2044. [#include <math.h>
  2045. namespace std {
  2046. template<typename _Tp>
  2047. struct __is_integer;
  2048. template<>
  2049. struct __is_integer<int>
  2050. {
  2051. enum { __value = 1 };
  2052. };
  2053. }
  2054. namespace __gnu_cxx {
  2055. template<bool, typename>
  2056. struct __enable_if;
  2057. template<typename _Tp>
  2058. struct __enable_if<true, _Tp>
  2059. { typedef _Tp __type; };
  2060. }
  2061. namespace std {
  2062. template<typename _Tp>
  2063. constexpr typename __gnu_cxx::__enable_if
  2064. <__is_integer<_Tp>::__value, double>::__type
  2065. log2(_Tp __x)
  2066. { return __builtin_log2(__x); }
  2067. }
  2068. int
  2069. main (void)
  2070. {
  2071. int i = 1000;
  2072. return std::log2(i);
  2073. }
  2074. ])],
  2075. [glibcxx_cv_math11_int_overload=no],
  2076. [glibcxx_cv_math11_int_overload=yes]
  2077. )])
  2078. # autoheader cannot handle indented templates.
  2079. AH_VERBATIM([__CORRECT_ISO_CPP11_MATH_H_PROTO_INT],
  2080. [/* Define if all C++11 integral type overloads are available in <math.h>. */
  2081. #if __cplusplus >= 201103L
  2082. #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  2083. #endif])
  2084. if test $glibcxx_cv_math11_int_overload = yes; then
  2085. AC_DEFINE(__CORRECT_ISO_CPP11_MATH_H_PROTO_INT)
  2086. fi
  2087. ;;
  2088. *)
  2089. # If <math.h> defines the obsolete isinf(double) and isnan(double)
  2090. # functions (instead of or as well as the C99 generic macros) then we
  2091. # can't define std::isinf(double) and std::isnan(double) in <cmath>
  2092. # and must use the ones from <math.h> instead.
  2093. AC_CACHE_CHECK([for obsolete isinf function in <math.h>],
  2094. glibcxx_cv_obsolete_isinf, [
  2095. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  2096. [#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
  2097. #include <math.h>
  2098. #undef isinf
  2099. namespace std {
  2100. using ::isinf;
  2101. bool isinf(float);
  2102. bool isinf(long double);
  2103. }
  2104. using std::isinf;
  2105. bool b = isinf(0.0);
  2106. ])],
  2107. [glibcxx_cv_obsolete_isinf=yes],
  2108. [glibcxx_cv_obsolete_isinf=no]
  2109. )])
  2110. if test $glibcxx_cv_obsolete_isinf = yes; then
  2111. AC_DEFINE(HAVE_OBSOLETE_ISINF, 1,
  2112. [Define if <math.h> defines obsolete isinf function.])
  2113. fi
  2114. AC_CACHE_CHECK([for obsolete isnan function in <math.h>],
  2115. glibcxx_cv_obsolete_isnan, [
  2116. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  2117. [#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
  2118. #include <math.h>
  2119. #undef isnan
  2120. namespace std {
  2121. using ::isnan;
  2122. bool isnan(float);
  2123. bool isnan(long double);
  2124. }
  2125. using std::isnan;
  2126. bool b = isnan(0.0);
  2127. ])],
  2128. [glibcxx_cv_obsolete_isnan=yes],
  2129. [glibcxx_cv_obsolete_isnan=no]
  2130. )])
  2131. if test $glibcxx_cv_obsolete_isnan = yes; then
  2132. AC_DEFINE(HAVE_OBSOLETE_ISNAN, 1,
  2133. [Define if <math.h> defines obsolete isnan function.])
  2134. fi
  2135. ;;
  2136. esac
  2137. CXXFLAGS="$ac_save_CXXFLAGS"
  2138. AC_LANG_RESTORE
  2139. ])
  2140. dnl
  2141. dnl Check for what type of C headers to use.
  2142. dnl
  2143. dnl --enable-cheaders= [does stuff].
  2144. dnl --disable-cheaders [does not do anything, really].
  2145. dnl + Usage: GLIBCXX_ENABLE_CHEADERS[(DEFAULT)]
  2146. dnl Where DEFAULT is either 'c' or 'c_global' or 'c_std'.
  2147. dnl
  2148. dnl To use the obsolete 'c_std' headers use --enable-cheaders-obsolete as
  2149. dnl well as --enable-cheaders=c_std, otherwise configure will fail.
  2150. dnl
  2151. AC_DEFUN([GLIBCXX_ENABLE_CHEADERS], [
  2152. GLIBCXX_ENABLE(cheaders-obsolete,no,,
  2153. [allow use of obsolete "C" headers for g++])
  2154. GLIBCXX_ENABLE(cheaders,$1,[[[=KIND]]],
  2155. [construct "C" headers for g++], [permit c|c_global|c_std])
  2156. AC_MSG_NOTICE("C" header strategy set to $enable_cheaders)
  2157. if test $enable_cheaders = c_std ; then
  2158. AC_MSG_WARN([the --enable-cheaders=c_std configuration is obsolete, c_global should be used instead])
  2159. AC_MSG_WARN([if you are unable to use c_global please report a bug or inform libstdc++@gcc.gnu.org])
  2160. if test $enable_cheaders_obsolete != yes ; then
  2161. AC_MSG_ERROR(use --enable-cheaders-obsolete to use c_std "C" headers)
  2162. fi
  2163. fi
  2164. C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders
  2165. # Allow overrides to configure.host here.
  2166. if test $enable_cheaders = c_global; then
  2167. c_compatibility=yes
  2168. fi
  2169. AC_SUBST(C_INCLUDE_DIR)
  2170. GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c)
  2171. GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std)
  2172. GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_GLOBAL, test $enable_cheaders = c_global)
  2173. GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes)
  2174. ])
  2175. dnl
  2176. dnl Check for which locale library to use. The choice is mapped to
  2177. dnl a subdirectory of config/locale.
  2178. dnl
  2179. dnl Default is generic.
  2180. dnl
  2181. AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
  2182. GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]],
  2183. [use MODEL for target locale package],
  2184. [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto])
  2185. # Deal with gettext issues. Default to not using it (=no) until we detect
  2186. # support for it later. Let the user turn it off via --e/d, but let that
  2187. # default to on for easier handling.
  2188. USE_NLS=no
  2189. AC_ARG_ENABLE(nls,
  2190. AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]),
  2191. [],
  2192. [enable_nls=yes])
  2193. # Either a known package, or "auto"
  2194. if test $enable_clocale = no || test $enable_clocale = yes; then
  2195. enable_clocale=auto
  2196. fi
  2197. enable_clocale_flag=$enable_clocale
  2198. # Probe for locale model to use if none specified.
  2199. # Default to "generic".
  2200. if test $enable_clocale_flag = auto; then
  2201. case ${target_os} in
  2202. linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
  2203. enable_clocale_flag=gnu
  2204. ;;
  2205. darwin*)
  2206. enable_clocale_flag=darwin
  2207. ;;
  2208. vxworks*)
  2209. enable_clocale_flag=vxworks
  2210. ;;
  2211. dragonfly* | freebsd*)
  2212. enable_clocale_flag=dragonfly
  2213. ;;
  2214. openbsd*)
  2215. enable_clocale_flag=newlib
  2216. ;;
  2217. *)
  2218. if test x"$with_newlib" = x"yes"; then
  2219. enable_clocale_flag=newlib
  2220. else
  2221. enable_clocale_flag=generic
  2222. fi
  2223. ;;
  2224. esac
  2225. fi
  2226. # Sanity check model, and test for special functionality.
  2227. if test $enable_clocale_flag = gnu; then
  2228. AC_EGREP_CPP([_GLIBCXX_ok], [
  2229. #include <features.h>
  2230. #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(__UCLIBC__)
  2231. _GLIBCXX_ok
  2232. #endif
  2233. ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
  2234. # Set it to scream when it hurts.
  2235. ac_save_CFLAGS="$CFLAGS"
  2236. CFLAGS="-Wimplicit-function-declaration -Werror"
  2237. # Use strxfrm_l if available.
  2238. AC_TRY_COMPILE([#define _GNU_SOURCE 1
  2239. #include <string.h>
  2240. #include <locale.h>],
  2241. [char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);],
  2242. AC_DEFINE(HAVE_STRXFRM_L, 1,
  2243. [Define if strxfrm_l is available in <string.h>.]),)
  2244. # Use strerror_l if available.
  2245. AC_TRY_COMPILE([#define _GNU_SOURCE 1
  2246. #include <string.h>
  2247. #include <locale.h>],
  2248. [__locale_t loc; strerror_l(5, loc);],
  2249. AC_DEFINE(HAVE_STRERROR_L, 1,
  2250. [Define if strerror_l is available in <string.h>.]),)
  2251. CFLAGS="$ac_save_CFLAGS"
  2252. fi
  2253. # Perhaps use strerror_r if available, and strerror_l isn't.
  2254. ac_save_CFLAGS="$CFLAGS"
  2255. CFLAGS="-Wimplicit-function-declaration -Werror"
  2256. AC_TRY_COMPILE([#define _GNU_SOURCE 1
  2257. #include <string.h>
  2258. #include <locale.h>],
  2259. [char s[128]; strerror_r(5, s, 128);],
  2260. AC_DEFINE(HAVE_STRERROR_R, 1,
  2261. [Define if strerror_r is available in <string.h>.]),)
  2262. CFLAGS="$ac_save_CFLAGS"
  2263. # Set configure bits for specified locale package
  2264. AC_MSG_CHECKING([for C locale to use])
  2265. case ${enable_clocale_flag} in
  2266. generic)
  2267. AC_MSG_RESULT(generic)
  2268. CLOCALE_H=config/locale/generic/c_locale.h
  2269. CLOCALE_CC=config/locale/generic/c_locale.cc
  2270. CCODECVT_CC=config/locale/generic/codecvt_members.cc
  2271. CCOLLATE_CC=config/locale/generic/collate_members.cc
  2272. CCTYPE_CC=config/locale/generic/ctype_members.cc
  2273. CMESSAGES_H=config/locale/generic/messages_members.h
  2274. CMESSAGES_CC=config/locale/generic/messages_members.cc
  2275. CMONEY_CC=config/locale/generic/monetary_members.cc
  2276. CNUMERIC_CC=config/locale/generic/numeric_members.cc
  2277. CTIME_H=config/locale/generic/time_members.h
  2278. CTIME_CC=config/locale/generic/time_members.cc
  2279. CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
  2280. ;;
  2281. darwin)
  2282. AC_MSG_RESULT(darwin)
  2283. CLOCALE_H=config/locale/generic/c_locale.h
  2284. CLOCALE_CC=config/locale/generic/c_locale.cc
  2285. CCODECVT_CC=config/locale/generic/codecvt_members.cc
  2286. CCOLLATE_CC=config/locale/generic/collate_members.cc
  2287. CCTYPE_CC=config/locale/darwin/ctype_members.cc
  2288. CMESSAGES_H=config/locale/generic/messages_members.h
  2289. CMESSAGES_CC=config/locale/generic/messages_members.cc
  2290. CMONEY_CC=config/locale/generic/monetary_members.cc
  2291. CNUMERIC_CC=config/locale/generic/numeric_members.cc
  2292. CTIME_H=config/locale/generic/time_members.h
  2293. CTIME_CC=config/locale/generic/time_members.cc
  2294. CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
  2295. ;;
  2296. vxworks)
  2297. AC_MSG_RESULT(vxworks)
  2298. CLOCALE_H=config/locale/generic/c_locale.h
  2299. CLOCALE_CC=config/locale/generic/c_locale.cc
  2300. CCODECVT_CC=config/locale/generic/codecvt_members.cc
  2301. CCOLLATE_CC=config/locale/generic/collate_members.cc
  2302. CCTYPE_CC=config/locale/vxworks/ctype_members.cc
  2303. CMESSAGES_H=config/locale/generic/messages_members.h
  2304. CMESSAGES_CC=config/locale/generic/messages_members.cc
  2305. CMONEY_CC=config/locale/generic/monetary_members.cc
  2306. CNUMERIC_CC=config/locale/generic/numeric_members.cc
  2307. CTIME_H=config/locale/generic/time_members.h
  2308. CTIME_CC=config/locale/generic/time_members.cc
  2309. CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
  2310. ;;
  2311. dragonfly)
  2312. AC_MSG_RESULT(dragonfly or freebsd)
  2313. CLOCALE_H=config/locale/dragonfly/c_locale.h
  2314. CLOCALE_CC=config/locale/dragonfly/c_locale.cc
  2315. CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc
  2316. CCOLLATE_CC=config/locale/dragonfly/collate_members.cc
  2317. CCTYPE_CC=config/locale/dragonfly/ctype_members.cc
  2318. CMESSAGES_H=config/locale/generic/messages_members.h
  2319. CMESSAGES_CC=config/locale/generic/messages_members.cc
  2320. CMONEY_CC=config/locale/dragonfly/monetary_members.cc
  2321. CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc
  2322. CTIME_H=config/locale/dragonfly/time_members.h
  2323. CTIME_CC=config/locale/dragonfly/time_members.cc
  2324. CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
  2325. ;;
  2326. gnu)
  2327. AC_MSG_RESULT(gnu)
  2328. # Declare intention to use gettext, and add support for specific
  2329. # languages.
  2330. # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
  2331. ALL_LINGUAS="de fr"
  2332. # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
  2333. AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
  2334. if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
  2335. USE_NLS=yes
  2336. fi
  2337. # Export the build objects.
  2338. for ling in $ALL_LINGUAS; do \
  2339. glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
  2340. glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
  2341. done
  2342. AC_SUBST(glibcxx_MOFILES)
  2343. AC_SUBST(glibcxx_POFILES)
  2344. CLOCALE_H=config/locale/gnu/c_locale.h
  2345. CLOCALE_CC=config/locale/gnu/c_locale.cc
  2346. CCODECVT_CC=config/locale/gnu/codecvt_members.cc
  2347. CCOLLATE_CC=config/locale/gnu/collate_members.cc
  2348. CCTYPE_CC=config/locale/gnu/ctype_members.cc
  2349. CMESSAGES_H=config/locale/gnu/messages_members.h
  2350. CMESSAGES_CC=config/locale/gnu/messages_members.cc
  2351. CMONEY_CC=config/locale/gnu/monetary_members.cc
  2352. CNUMERIC_CC=config/locale/gnu/numeric_members.cc
  2353. CTIME_H=config/locale/gnu/time_members.h
  2354. CTIME_CC=config/locale/gnu/time_members.cc
  2355. CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h
  2356. ;;
  2357. ieee_1003.1-2001)
  2358. AC_MSG_RESULT(IEEE 1003.1)
  2359. CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
  2360. CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
  2361. CCODECVT_CC=config/locale/generic/codecvt_members.cc
  2362. CCOLLATE_CC=config/locale/generic/collate_members.cc
  2363. CCTYPE_CC=config/locale/generic/ctype_members.cc
  2364. CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
  2365. CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
  2366. CMONEY_CC=config/locale/generic/monetary_members.cc
  2367. CNUMERIC_CC=config/locale/generic/numeric_members.cc
  2368. CTIME_H=config/locale/generic/time_members.h
  2369. CTIME_CC=config/locale/generic/time_members.cc
  2370. CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
  2371. ;;
  2372. newlib)
  2373. AC_MSG_RESULT(newlib)
  2374. CLOCALE_H=config/locale/generic/c_locale.h
  2375. CLOCALE_CC=config/locale/generic/c_locale.cc
  2376. CCODECVT_CC=config/locale/generic/codecvt_members.cc
  2377. CCOLLATE_CC=config/locale/generic/collate_members.cc
  2378. CCTYPE_CC=config/locale/newlib/ctype_members.cc
  2379. CMESSAGES_H=config/locale/generic/messages_members.h
  2380. CMESSAGES_CC=config/locale/generic/messages_members.cc
  2381. CMONEY_CC=config/locale/generic/monetary_members.cc
  2382. CNUMERIC_CC=config/locale/generic/numeric_members.cc
  2383. CTIME_H=config/locale/generic/time_members.h
  2384. CTIME_CC=config/locale/generic/time_members.cc
  2385. CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
  2386. ;;
  2387. esac
  2388. # This is where the testsuite looks for locale catalogs, using the
  2389. # -DLOCALEDIR define during testsuite compilation.
  2390. glibcxx_localedir=${glibcxx_builddir}/po/share/locale
  2391. AC_SUBST(glibcxx_localedir)
  2392. # A standalone libintl (e.g., GNU libintl) may be in use.
  2393. if test $USE_NLS = yes; then
  2394. AC_CHECK_HEADERS([libintl.h], [], USE_NLS=no)
  2395. AC_SEARCH_LIBS(gettext, intl, [], USE_NLS=no)
  2396. fi
  2397. if test $USE_NLS = yes; then
  2398. AC_DEFINE(_GLIBCXX_USE_NLS, 1,
  2399. [Define if NLS translations are to be used.])
  2400. fi
  2401. AC_SUBST(USE_NLS)
  2402. AC_SUBST(CLOCALE_H)
  2403. AC_SUBST(CMESSAGES_H)
  2404. AC_SUBST(CCODECVT_CC)
  2405. AC_SUBST(CCOLLATE_CC)
  2406. AC_SUBST(CCTYPE_CC)
  2407. AC_SUBST(CMESSAGES_CC)
  2408. AC_SUBST(CMONEY_CC)
  2409. AC_SUBST(CNUMERIC_CC)
  2410. AC_SUBST(CTIME_H)
  2411. AC_SUBST(CTIME_CC)
  2412. AC_SUBST(CLOCALE_CC)
  2413. AC_SUBST(CLOCALE_INTERNAL_H)
  2414. ])
  2415. dnl
  2416. dnl Check for which std::allocator base class to use. The choice is
  2417. dnl mapped from a subdirectory of include/ext.
  2418. dnl
  2419. dnl Default is new.
  2420. dnl
  2421. AC_DEFUN([GLIBCXX_ENABLE_ALLOCATOR], [
  2422. AC_MSG_CHECKING([for std::allocator base class])
  2423. GLIBCXX_ENABLE(libstdcxx-allocator,auto,[[[=KIND]]],
  2424. [use KIND for target std::allocator base],
  2425. [permit new|malloc|yes|no|auto])
  2426. # If they didn't use this option switch, or if they specified --enable
  2427. # with no specific model, we'll have to look for one. If they
  2428. # specified --disable (???), do likewise.
  2429. if test $enable_libstdcxx_allocator = no ||
  2430. test $enable_libstdcxx_allocator = yes;
  2431. then
  2432. enable_libstdcxx_allocator=auto
  2433. fi
  2434. # Either a known package, or "auto". Auto implies the default choice
  2435. # for a particular platform.
  2436. enable_libstdcxx_allocator_flag=$enable_libstdcxx_allocator
  2437. # Probe for host-specific support if no specific model is specified.
  2438. # Default to "new".
  2439. if test $enable_libstdcxx_allocator_flag = auto; then
  2440. case ${target_os} in
  2441. linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
  2442. enable_libstdcxx_allocator_flag=new
  2443. ;;
  2444. *)
  2445. enable_libstdcxx_allocator_flag=new
  2446. ;;
  2447. esac
  2448. fi
  2449. AC_MSG_RESULT($enable_libstdcxx_allocator_flag)
  2450. # Set configure bits for specified locale package
  2451. case ${enable_libstdcxx_allocator_flag} in
  2452. malloc)
  2453. ALLOCATOR_H=config/allocator/malloc_allocator_base.h
  2454. ALLOCATOR_NAME=__gnu_cxx::malloc_allocator
  2455. ;;
  2456. new)
  2457. ALLOCATOR_H=config/allocator/new_allocator_base.h
  2458. ALLOCATOR_NAME=__gnu_cxx::new_allocator
  2459. ;;
  2460. esac
  2461. GLIBCXX_CONDITIONAL(ENABLE_ALLOCATOR_NEW,
  2462. test $enable_libstdcxx_allocator_flag = new)
  2463. AC_SUBST(ALLOCATOR_H)
  2464. AC_SUBST(ALLOCATOR_NAME)
  2465. ])
  2466. dnl
  2467. dnl Check for whether the Boost-derived checks should be turned on.
  2468. dnl
  2469. dnl --enable-concept-checks turns them on.
  2470. dnl --disable-concept-checks leaves them off.
  2471. dnl + Usage: GLIBCXX_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
  2472. dnl Where DEFAULT is either `yes' or `no'.
  2473. dnl
  2474. AC_DEFUN([GLIBCXX_ENABLE_CONCEPT_CHECKS], [
  2475. GLIBCXX_ENABLE(concept-checks,$1,,[use Boost-derived template checks])
  2476. if test $enable_concept_checks = yes; then
  2477. AC_DEFINE(_GLIBCXX_CONCEPT_CHECKS, 1,
  2478. [Define to use concept checking code from the boost libraries.])
  2479. fi
  2480. ])
  2481. dnl
  2482. dnl Use extern templates.
  2483. dnl
  2484. dnl --enable-extern-template defines _GLIBCXX_EXTERN_TEMPLATE to 1
  2485. dnl --disable-extern-template defines _GLIBCXX_EXTERN_TEMPLATE to 0
  2486. dnl + Usage: GLIBCXX_ENABLE_TEMPLATE[(DEFAULT)]
  2487. dnl Where DEFAULT is `yes' or `no'.
  2488. dnl
  2489. AC_DEFUN([GLIBCXX_ENABLE_EXTERN_TEMPLATE], [
  2490. GLIBCXX_ENABLE(extern-template,$1,,[enable extern template])
  2491. AC_MSG_CHECKING([for extern template support])
  2492. AC_MSG_RESULT([$enable_extern_template])
  2493. GLIBCXX_CONDITIONAL(ENABLE_EXTERN_TEMPLATE, test $enable_extern_template = yes)
  2494. ])
  2495. dnl
  2496. dnl Use vtable verification.
  2497. dnl
  2498. dnl --enable-vtable-verify defines _GLIBCXX_VTABLE_VERIFY to 1
  2499. dnl --disable-vtable-verify defines _GLIBCXX_VTABLE_VERIFY to 0
  2500. dnl + Usage: GLIBCXX_ENABLE_VTABLE_VERIFY[(DEFAULT)]
  2501. dnl Where DEFAULT is `yes' or `no'.
  2502. dnl
  2503. AC_DEFUN([GLIBCXX_ENABLE_VTABLE_VERIFY], [
  2504. GLIBCXX_ENABLE(vtable-verify,$1,,[enable vtable verify])
  2505. AC_MSG_CHECKING([for vtable verify support])
  2506. AC_MSG_RESULT([$enable_vtable_verify])
  2507. vtv_cygmin=no
  2508. if test $enable_vtable_verify = yes; then
  2509. case ${target_os} in
  2510. cygwin*|mingw32*)
  2511. VTV_CXXFLAGS="-fvtable-verify=std -Wl,-lvtv,-u_vtable_map_vars_start,-u_vtable_map_vars_end"
  2512. VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,--rpath -Wl,${toplevel_builddir}/libvtv/.libs"
  2513. vtv_cygmin=yes
  2514. ;;
  2515. darwin*)
  2516. VTV_CXXFLAGS="-fvtable-verify=std -Wl,-u,_vtable_map_vars_start -Wl,-u,_vtable_map_vars_end"
  2517. VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,-rpath,${toplevel_builddir}/libvtv/.libs"
  2518. ;;
  2519. solaris2*)
  2520. VTV_CXXFLAGS="-fvtable-verify=std -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end"
  2521. VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,-R -Wl,${toplevel_builddir}/libvtv/.libs"
  2522. ;;
  2523. *)
  2524. VTV_CXXFLAGS="-fvtable-verify=std -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end"
  2525. VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,--rpath -Wl,${toplevel_builddir}/libvtv/.libs"
  2526. ;;
  2527. esac
  2528. VTV_PCH_CXXFLAGS="-fvtable-verify=std"
  2529. else
  2530. VTV_CXXFLAGS=
  2531. VTV_PCH_CXXFLAGS=
  2532. VTV_CXXLINKFLAGS=
  2533. fi
  2534. AC_SUBST(VTV_CXXFLAGS)
  2535. AC_SUBST(VTV_PCH_CXXFLAGS)
  2536. AC_SUBST(VTV_CXXLINKFLAGS)
  2537. AM_CONDITIONAL(VTV_CYGMIN, test x$vtv_cygmin = xyes)
  2538. GLIBCXX_CONDITIONAL(ENABLE_VTABLE_VERIFY, test $enable_vtable_verify = yes)
  2539. ])
  2540. dnl
  2541. dnl Check for parallel mode pre-requisites, including OpenMP support.
  2542. dnl
  2543. dnl + Usage: GLIBCXX_ENABLE_PARALLEL
  2544. dnl
  2545. AC_DEFUN([GLIBCXX_ENABLE_PARALLEL], [
  2546. enable_parallel=no;
  2547. # See if configured libgomp/omp.h exists. (libgomp may be in
  2548. # noconfigdirs but not explicitly disabled.)
  2549. if echo " ${TARGET_CONFIGDIRS} " | grep " libgomp " > /dev/null 2>&1 ; then
  2550. enable_parallel=yes;
  2551. else
  2552. AC_MSG_NOTICE([target-libgomp not built])
  2553. fi
  2554. AC_MSG_CHECKING([for parallel mode support])
  2555. AC_MSG_RESULT([$enable_parallel])
  2556. ])
  2557. dnl
  2558. dnl Check for which I/O library to use: stdio and POSIX, or pure stdio.
  2559. dnl
  2560. dnl Default is stdio_posix.
  2561. dnl
  2562. AC_DEFUN([GLIBCXX_ENABLE_CSTDIO], [
  2563. AC_MSG_CHECKING([for underlying I/O to use])
  2564. GLIBCXX_ENABLE(cstdio,stdio,[[[=PACKAGE]]],
  2565. [use target-specific I/O package], [permit stdio|stdio_posix|stdio_pure])
  2566. # The only available I/O model is based on stdio, via basic_file_stdio.
  2567. # The default "stdio" is actually "stdio + POSIX" because it uses fdopen(3)
  2568. # to get a file descriptor and then uses read(3) and write(3) with it.
  2569. # The "stdio_pure" model doesn't use fdopen and only uses FILE* for I/O.
  2570. case ${enable_cstdio} in
  2571. stdio*)
  2572. CSTDIO_H=config/io/c_io_stdio.h
  2573. BASIC_FILE_H=config/io/basic_file_stdio.h
  2574. BASIC_FILE_CC=config/io/basic_file_stdio.cc
  2575. if test "x$enable_cstdio" = "xstdio_pure" ; then
  2576. AC_MSG_RESULT([stdio (without POSIX read/write)])
  2577. AC_DEFINE(_GLIBCXX_USE_STDIO_PURE, 1,
  2578. [Define to restrict std::__basic_file<> to stdio APIs.])
  2579. else
  2580. AC_MSG_RESULT([stdio (with POSIX read/write)])
  2581. fi
  2582. ;;
  2583. esac
  2584. AC_SUBST(CSTDIO_H)
  2585. AC_SUBST(BASIC_FILE_H)
  2586. AC_SUBST(BASIC_FILE_CC)
  2587. ])
  2588. dnl
  2589. dnl Check for "unusual" flags to pass to the compiler while building.
  2590. dnl
  2591. dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
  2592. dnl experimental flags such as -fpch, -fIMI, -Dfloat=char, etc.
  2593. dnl --disable-cxx-flags passes nothing.
  2594. dnl + See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
  2595. dnl http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
  2596. dnl http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
  2597. dnl + Usage: GLIBCXX_ENABLE_CXX_FLAGS(default flags)
  2598. dnl If "default flags" is an empty string, the effect is the same
  2599. dnl as --disable or --enable=no.
  2600. dnl
  2601. AC_DEFUN([GLIBCXX_ENABLE_CXX_FLAGS], [dnl
  2602. AC_MSG_CHECKING([for extra compiler flags for building])
  2603. GLIBCXX_ENABLE(cxx-flags,$1,[=FLAGS],
  2604. [pass compiler FLAGS when building library],
  2605. [case "x$enable_cxx_flags" in
  2606. xno | x) enable_cxx_flags= ;;
  2607. x-*) ;;
  2608. *) AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
  2609. esac])
  2610. # Run through flags (either default or command-line) and set anything
  2611. # extra (e.g., #defines) that must accompany particular g++ options.
  2612. if test -n "$enable_cxx_flags"; then
  2613. for f in $enable_cxx_flags; do
  2614. case "$f" in
  2615. -fhonor-std) ;;
  2616. -*) ;;
  2617. *) # and we're trying to pass /what/ exactly?
  2618. AC_MSG_ERROR([compiler flags start with a -]) ;;
  2619. esac
  2620. done
  2621. fi
  2622. EXTRA_CXX_FLAGS="$enable_cxx_flags"
  2623. AC_MSG_RESULT($EXTRA_CXX_FLAGS)
  2624. AC_SUBST(EXTRA_CXX_FLAGS)
  2625. ])
  2626. dnl
  2627. dnl Check to see if debugging libraries are to be built.
  2628. dnl
  2629. dnl --enable-libstdcxx-debug
  2630. dnl builds a separate set of debugging libraries in addition to the
  2631. dnl normal (shared, static) libstdc++ binaries.
  2632. dnl
  2633. dnl --disable-libstdcxx-debug
  2634. dnl builds only one (non-debug) version of libstdc++.
  2635. dnl
  2636. dnl --enable-libstdcxx-debug-flags=FLAGS
  2637. dnl iff --enable-debug == yes, then use FLAGS to build the debug library.
  2638. dnl
  2639. dnl + Usage: GLIBCXX_ENABLE_DEBUG[(DEFAULT)]
  2640. dnl Where DEFAULT is either `yes' or `no'.
  2641. dnl
  2642. AC_DEFUN([GLIBCXX_ENABLE_DEBUG], [
  2643. AC_MSG_CHECKING([for additional debug build])
  2644. skip_debug_build=
  2645. GLIBCXX_ENABLE(libstdcxx-debug,$1,,[build extra debug library])
  2646. if test x$enable_libstdcxx_debug = xyes; then
  2647. if test -f $toplevel_builddir/../stage_final \
  2648. && test -f $toplevel_builddir/../stage_current; then
  2649. stage_final=`cat $toplevel_builddir/../stage_final`
  2650. stage_current=`cat $toplevel_builddir/../stage_current`
  2651. if test x$stage_current != x$stage_final ; then
  2652. skip_debug_build=" (skipped for bootstrap stage $stage_current)"
  2653. enable_libstdcxx_debug=no
  2654. fi
  2655. fi
  2656. fi
  2657. AC_MSG_RESULT($enable_libstdcxx_debug$skip_debug_build)
  2658. GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_DEBUG, test $enable_libstdcxx_debug = yes)
  2659. ])
  2660. dnl
  2661. dnl Check for explicit debug flags.
  2662. dnl
  2663. dnl --enable-libstdcxx-debug-flags='-O1'
  2664. dnl is a general method for passing flags to be used when
  2665. dnl building debug libraries with --enable-libstdcxx-debug.
  2666. dnl
  2667. dnl --disable-libstdcxx-debug-flags does nothing.
  2668. dnl + Usage: GLIBCXX_ENABLE_DEBUG_FLAGS(default flags)
  2669. dnl If "default flags" is an empty string, the effect is the same
  2670. dnl as --disable or --enable=no.
  2671. dnl
  2672. AC_DEFUN([GLIBCXX_ENABLE_DEBUG_FLAGS], [
  2673. GLIBCXX_ENABLE(libstdcxx-debug-flags,[$1],[=FLAGS],
  2674. [pass compiler FLAGS when building debug library],
  2675. [case "x$enable_libstdcxx_debug_flags" in
  2676. xno | x) enable_libstdcxx_debug_flags= ;;
  2677. x-*) ;;
  2678. *) AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
  2679. esac])
  2680. # Option parsed, now set things appropriately
  2681. DEBUG_FLAGS="$enable_libstdcxx_debug_flags"
  2682. AC_SUBST(DEBUG_FLAGS)
  2683. AC_MSG_NOTICE([Debug build flags set to $DEBUG_FLAGS])
  2684. ])
  2685. dnl
  2686. dnl Check if the user only wants a freestanding library implementation.
  2687. dnl
  2688. dnl --disable-hosted-libstdcxx will turn off most of the library build,
  2689. dnl installing only the headers required by [17.4.1.3] and the language
  2690. dnl support library. More than that will be built (to keep the Makefiles
  2691. dnl conveniently clean), but not installed.
  2692. dnl
  2693. dnl Sets:
  2694. dnl is_hosted (yes/no)
  2695. dnl
  2696. dnl Defines:
  2697. dnl _GLIBCXX_HOSTED (always defined, either to 1 or 0)
  2698. dnl
  2699. AC_DEFUN([GLIBCXX_ENABLE_HOSTED], [
  2700. AC_ARG_ENABLE([hosted-libstdcxx],
  2701. AC_HELP_STRING([--disable-hosted-libstdcxx],
  2702. [only build freestanding C++ runtime support]),,
  2703. [case "$host" in
  2704. arm*-*-symbianelf*)
  2705. enable_hosted_libstdcxx=no
  2706. ;;
  2707. *)
  2708. enable_hosted_libstdcxx=yes
  2709. ;;
  2710. esac])
  2711. freestanding_flags=
  2712. if test "$enable_hosted_libstdcxx" = no; then
  2713. AC_MSG_NOTICE([Only freestanding libraries will be built])
  2714. is_hosted=no
  2715. hosted_define=0
  2716. enable_abi_check=no
  2717. enable_libstdcxx_pch=no
  2718. if test "x$with_headers" = xno; then
  2719. freestanding_flags="-ffreestanding"
  2720. fi
  2721. else
  2722. is_hosted=yes
  2723. hosted_define=1
  2724. fi
  2725. GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes)
  2726. AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define,
  2727. [Define to 1 if a full hosted library is built, or 0 if freestanding.])
  2728. FREESTANDING_FLAGS="$freestanding_flags"
  2729. AC_SUBST(FREESTANDING_FLAGS)
  2730. ])
  2731. dnl
  2732. dnl Check if the user wants a non-verbose library implementation.
  2733. dnl
  2734. dnl --disable-libstdcxx-verbose will turn off descriptive messages to
  2735. dnl standard error on termination.
  2736. dnl
  2737. dnl Defines:
  2738. dnl _GLIBCXX_VERBOSE (always defined, either to 1 or 0)
  2739. dnl
  2740. AC_DEFUN([GLIBCXX_ENABLE_VERBOSE], [
  2741. AC_ARG_ENABLE([libstdcxx-verbose],
  2742. AC_HELP_STRING([--disable-libstdcxx-verbose],
  2743. [disable termination messages to standard error]),,
  2744. [enable_libstdcxx_verbose=yes])
  2745. if test x"$enable_libstdcxx_verbose" = xyes; then
  2746. verbose_define=1
  2747. else
  2748. AC_MSG_NOTICE([verbose termination messages are disabled])
  2749. verbose_define=0
  2750. fi
  2751. AC_DEFINE_UNQUOTED(_GLIBCXX_VERBOSE, $verbose_define,
  2752. [Define to 1 if a verbose library is built, or 0 otherwise.])
  2753. ])
  2754. dnl
  2755. dnl Check for template specializations for the 'long long' type.
  2756. dnl The result determines only whether 'long long' I/O is enabled; things
  2757. dnl like numeric_limits<> specializations are always available.
  2758. dnl
  2759. dnl --enable-long-long defines _GLIBCXX_USE_LONG_LONG
  2760. dnl --disable-long-long leaves _GLIBCXX_USE_LONG_LONG undefined
  2761. dnl + Usage: GLIBCXX_ENABLE_LONG_LONG[(DEFAULT)]
  2762. dnl Where DEFAULT is either `yes' or `no'.
  2763. dnl
  2764. AC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [
  2765. GLIBCXX_ENABLE(long-long,$1,,[enable template specializations for 'long long'])
  2766. if test $enable_long_long = yes; then
  2767. AC_DEFINE(_GLIBCXX_USE_LONG_LONG, 1,
  2768. [Define if code specialized for long long should be used.])
  2769. fi
  2770. AC_MSG_CHECKING([for enabled long long specializations])
  2771. AC_MSG_RESULT([$enable_long_long])
  2772. ])
  2773. dnl
  2774. dnl Check for decimal floating point.
  2775. dnl See:
  2776. dnl http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float
  2777. dnl
  2778. dnl This checks to see if the host supports decimal floating point types.
  2779. dnl
  2780. dnl Defines:
  2781. dnl _GLIBCXX_USE_DECIMAL_FLOAT
  2782. dnl
  2783. AC_DEFUN([GLIBCXX_ENABLE_DECIMAL_FLOAT], [
  2784. # Fake what AC_TRY_COMPILE does, without linking as this is
  2785. # unnecessary for this test.
  2786. cat > conftest.$ac_ext << EOF
  2787. [#]line __oline__ "configure"
  2788. int main()
  2789. {
  2790. _Decimal32 d1;
  2791. _Decimal64 d2;
  2792. _Decimal128 d3;
  2793. return 0;
  2794. }
  2795. EOF
  2796. AC_MSG_CHECKING([for ISO/IEC TR 24733 ])
  2797. if AC_TRY_EVAL(ac_compile); then
  2798. AC_DEFINE(_GLIBCXX_USE_DECIMAL_FLOAT, 1,
  2799. [Define if ISO/IEC TR 24733 decimal floating point types are supported on this host.])
  2800. enable_dfp=yes
  2801. else
  2802. enable_dfp=no
  2803. fi
  2804. AC_MSG_RESULT($enable_dfp)
  2805. rm -f conftest*
  2806. ])
  2807. dnl
  2808. dnl Check for GNU 128-bit floating point type.
  2809. dnl
  2810. dnl Note: also checks that the type isn't a standard types.
  2811. dnl
  2812. dnl Defines:
  2813. dnl ENABLE_FLOAT128
  2814. dnl
  2815. AC_DEFUN([GLIBCXX_ENABLE_FLOAT128], [
  2816. AC_LANG_SAVE
  2817. AC_LANG_CPLUSPLUS
  2818. # Fake what AC_TRY_COMPILE does, without linking as this is
  2819. # unnecessary for this test.
  2820. cat > conftest.$ac_ext << EOF
  2821. [#]line __oline__ "configure"
  2822. template<typename T1, typename T2>
  2823. struct same
  2824. { typedef T2 type; };
  2825. template<typename T>
  2826. struct same<T, T>;
  2827. int main()
  2828. {
  2829. typename same<double, __float128>::type f1;
  2830. typename same<long double, __float128>::type f2;
  2831. }
  2832. EOF
  2833. AC_MSG_CHECKING([for __float128])
  2834. if AC_TRY_EVAL(ac_compile); then
  2835. enable_float128=yes
  2836. else
  2837. enable_float128=no
  2838. fi
  2839. AC_MSG_RESULT($enable_float128)
  2840. GLIBCXX_CONDITIONAL(ENABLE_FLOAT128, test $enable_float128 = yes)
  2841. rm -f conftest*
  2842. AC_LANG_RESTORE
  2843. ])
  2844. dnl
  2845. dnl Check for template specializations for the 'wchar_t' type.
  2846. dnl
  2847. dnl --enable-wchar_t defines _GLIBCXX_USE_WCHAR_T
  2848. dnl --disable-wchar_t leaves _GLIBCXX_USE_WCHAR_T undefined
  2849. dnl + Usage: GLIBCXX_ENABLE_WCHAR_T[(DEFAULT)]
  2850. dnl Where DEFAULT is either `yes' or `no'.
  2851. dnl
  2852. dnl Necessary support must also be present.
  2853. dnl
  2854. AC_DEFUN([GLIBCXX_ENABLE_WCHAR_T], [
  2855. GLIBCXX_ENABLE(wchar_t,$1,,[enable template specializations for 'wchar_t'])
  2856. # Test wchar.h for mbstate_t, which is needed for char_traits and fpos.
  2857. AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
  2858. AC_MSG_CHECKING([for mbstate_t])
  2859. AC_TRY_COMPILE([#include <wchar.h>],
  2860. [mbstate_t teststate;],
  2861. have_mbstate_t=yes, have_mbstate_t=no)
  2862. AC_MSG_RESULT($have_mbstate_t)
  2863. if test x"$have_mbstate_t" = xyes; then
  2864. AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.])
  2865. fi
  2866. # Test it always, for use in GLIBCXX_ENABLE_C99, together with
  2867. # ac_has_wchar_h.
  2868. AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
  2869. if test x"$enable_wchar_t" = x"yes"; then
  2870. AC_LANG_SAVE
  2871. AC_LANG_CPLUSPLUS
  2872. if test x"$ac_has_wchar_h" = xyes &&
  2873. test x"$ac_has_wctype_h" = xyes; then
  2874. AC_TRY_COMPILE([#include <wchar.h>
  2875. #include <stddef.h>
  2876. wint_t i;
  2877. long l = WEOF;
  2878. long j = WCHAR_MIN;
  2879. long k = WCHAR_MAX;
  2880. namespace test
  2881. {
  2882. using ::btowc;
  2883. using ::fgetwc;
  2884. using ::fgetws;
  2885. using ::fputwc;
  2886. using ::fputws;
  2887. using ::fwide;
  2888. using ::fwprintf;
  2889. using ::fwscanf;
  2890. using ::getwc;
  2891. using ::getwchar;
  2892. using ::mbrlen;
  2893. using ::mbrtowc;
  2894. using ::mbsinit;
  2895. using ::mbsrtowcs;
  2896. using ::putwc;
  2897. using ::putwchar;
  2898. using ::swprintf;
  2899. using ::swscanf;
  2900. using ::ungetwc;
  2901. using ::vfwprintf;
  2902. using ::vswprintf;
  2903. using ::vwprintf;
  2904. using ::wcrtomb;
  2905. using ::wcscat;
  2906. using ::wcschr;
  2907. using ::wcscmp;
  2908. using ::wcscoll;
  2909. using ::wcscpy;
  2910. using ::wcscspn;
  2911. using ::wcsftime;
  2912. using ::wcslen;
  2913. using ::wcsncat;
  2914. using ::wcsncmp;
  2915. using ::wcsncpy;
  2916. using ::wcspbrk;
  2917. using ::wcsrchr;
  2918. using ::wcsrtombs;
  2919. using ::wcsspn;
  2920. using ::wcsstr;
  2921. using ::wcstod;
  2922. using ::wcstok;
  2923. using ::wcstol;
  2924. using ::wcstoul;
  2925. using ::wcsxfrm;
  2926. using ::wctob;
  2927. using ::wmemchr;
  2928. using ::wmemcmp;
  2929. using ::wmemcpy;
  2930. using ::wmemmove;
  2931. using ::wmemset;
  2932. using ::wprintf;
  2933. using ::wscanf;
  2934. }
  2935. ],[],[], [enable_wchar_t=no])
  2936. else
  2937. enable_wchar_t=no
  2938. fi
  2939. AC_LANG_RESTORE
  2940. fi
  2941. if test x"$enable_wchar_t" = x"yes"; then
  2942. AC_DEFINE(_GLIBCXX_USE_WCHAR_T, 1,
  2943. [Define if code specialized for wchar_t should be used.])
  2944. fi
  2945. AC_MSG_CHECKING([for enabled wchar_t specializations])
  2946. AC_MSG_RESULT([$enable_wchar_t])
  2947. ])
  2948. dnl
  2949. dnl Check to see if building and using a C++ precompiled header can be done.
  2950. dnl
  2951. dnl --enable-libstdcxx-pch=yes
  2952. dnl default, this shows intent to use stdc++.h.gch If it looks like it
  2953. dnl may work, after some light-hearted attempts to puzzle out compiler
  2954. dnl support, flip bits on in include/Makefile.am
  2955. dnl
  2956. dnl --disable-libstdcxx-pch
  2957. dnl turns off attempts to use or build stdc++.h.gch.
  2958. dnl
  2959. dnl Substs:
  2960. dnl glibcxx_PCHFLAGS
  2961. dnl
  2962. AC_DEFUN([GLIBCXX_ENABLE_PCH], [
  2963. GLIBCXX_ENABLE(libstdcxx-pch,$1,,[build pre-compiled libstdc++ headers])
  2964. if test $enable_libstdcxx_pch = yes; then
  2965. AC_CACHE_CHECK([for compiler with PCH support],
  2966. [glibcxx_cv_prog_CXX_pch],
  2967. [ac_save_CXXFLAGS="$CXXFLAGS"
  2968. CXXFLAGS="$CXXFLAGS -Werror -Winvalid-pch -Wno-deprecated"
  2969. AC_LANG_SAVE
  2970. AC_LANG_CPLUSPLUS
  2971. echo '#include <math.h>' > conftest.h
  2972. if $CXX $CXXFLAGS $CPPFLAGS -x c++-header conftest.h \
  2973. -o conftest.h.gch 1>&5 2>&1 &&
  2974. echo '#error "pch failed"' > conftest.h &&
  2975. echo '#include "conftest.h"' > conftest.cc &&
  2976. $CXX -c $CXXFLAGS $CPPFLAGS conftest.cc 1>&5 2>&1 ;
  2977. then
  2978. glibcxx_cv_prog_CXX_pch=yes
  2979. else
  2980. glibcxx_cv_prog_CXX_pch=no
  2981. fi
  2982. rm -f conftest*
  2983. CXXFLAGS=$ac_save_CXXFLAGS
  2984. AC_LANG_RESTORE
  2985. ])
  2986. enable_libstdcxx_pch=$glibcxx_cv_prog_CXX_pch
  2987. fi
  2988. AC_MSG_CHECKING([for enabled PCH])
  2989. AC_MSG_RESULT([$enable_libstdcxx_pch])
  2990. GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_PCH, test $enable_libstdcxx_pch = yes)
  2991. if test $enable_libstdcxx_pch = yes; then
  2992. glibcxx_PCHFLAGS="-include bits/stdc++.h"
  2993. else
  2994. glibcxx_PCHFLAGS=""
  2995. fi
  2996. AC_SUBST(glibcxx_PCHFLAGS)
  2997. ])
  2998. dnl
  2999. dnl Check for atomic builtins.
  3000. dnl See:
  3001. dnl http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
  3002. dnl
  3003. dnl This checks to see if the host supports the compiler-generated
  3004. dnl builtins for atomic operations for various integral sizes. Note, this
  3005. dnl is intended to be an all-or-nothing switch, so all the atomic operations
  3006. dnl that are used should be checked.
  3007. dnl
  3008. dnl Note:
  3009. dnl libgomp and libgfortran use a link test, see CHECK_SYNC_FETCH_AND_ADD.
  3010. dnl
  3011. AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
  3012. AC_LANG_SAVE
  3013. AC_LANG_CPLUSPLUS
  3014. old_CXXFLAGS="$CXXFLAGS"
  3015. # Do link tests if possible, instead asm tests, limited to some platforms
  3016. # see discussion in PR target/40134, PR libstdc++/40133 and the thread
  3017. # starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html
  3018. atomic_builtins_link_tests=no
  3019. if test x$gcc_no_link != xyes; then
  3020. # Can do link tests. Limit to some tested platforms
  3021. case "$host" in
  3022. *-*-linux* | *-*-uclinux* | *-*-kfreebsd*-gnu | *-*-gnu*)
  3023. atomic_builtins_link_tests=yes
  3024. ;;
  3025. esac
  3026. fi
  3027. if test x$atomic_builtins_link_tests = xyes; then
  3028. # Do link tests.
  3029. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  3030. AC_CACHE_CHECK([for atomic builtins for bool],
  3031. glibcxx_cv_atomic_bool, [
  3032. AC_TRY_LINK(
  3033. [ ],
  3034. [typedef bool atomic_type;
  3035. atomic_type c1;
  3036. atomic_type c2;
  3037. atomic_type c3(0);
  3038. // N.B. __atomic_fetch_add is not supported for bool.
  3039. __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
  3040. __ATOMIC_RELAXED);
  3041. __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
  3042. __atomic_load_n(&c1, __ATOMIC_RELAXED);
  3043. ],
  3044. [glibcxx_cv_atomic_bool=yes],
  3045. [glibcxx_cv_atomic_bool=no])
  3046. ])
  3047. AC_CACHE_CHECK([for atomic builtins for short],
  3048. glibcxx_cv_atomic_short, [
  3049. AC_TRY_LINK(
  3050. [ ],
  3051. [typedef short atomic_type;
  3052. atomic_type c1;
  3053. atomic_type c2;
  3054. atomic_type c3(0);
  3055. __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
  3056. __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
  3057. __ATOMIC_RELAXED);
  3058. __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
  3059. __atomic_load_n(&c1, __ATOMIC_RELAXED);
  3060. ],
  3061. [glibcxx_cv_atomic_short=yes],
  3062. [glibcxx_cv_atomic_short=no])
  3063. ])
  3064. AC_CACHE_CHECK([for atomic builtins for int],
  3065. glibcxx_cv_atomic_int, [
  3066. AC_TRY_LINK(
  3067. [ ],
  3068. [typedef int atomic_type;
  3069. atomic_type c1;
  3070. atomic_type c2;
  3071. atomic_type c3(0);
  3072. __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
  3073. __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
  3074. __ATOMIC_RELAXED);
  3075. __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
  3076. __atomic_load_n(&c1, __ATOMIC_RELAXED);
  3077. ],
  3078. [glibcxx_cv_atomic_int=yes],
  3079. [glibcxx_cv_atomic_int=no])
  3080. ])
  3081. AC_CACHE_CHECK([for atomic builtins for long long],
  3082. glibcxx_cv_atomic_long_long, [
  3083. AC_TRY_LINK(
  3084. [ ],
  3085. [typedef long long atomic_type;
  3086. atomic_type c1;
  3087. atomic_type c2;
  3088. atomic_type c3(0);
  3089. __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
  3090. __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
  3091. __ATOMIC_RELAXED);
  3092. __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
  3093. __atomic_load_n(&c1, __ATOMIC_RELAXED);
  3094. ],
  3095. [glibcxx_cv_atomic_long_long=yes],
  3096. [glibcxx_cv_atomic_long_long=no])
  3097. ])
  3098. else
  3099. # Do asm tests.
  3100. # Compile unoptimized.
  3101. CXXFLAGS='-O0 -S'
  3102. # Fake what AC_TRY_COMPILE does.
  3103. cat > conftest.$ac_ext << EOF
  3104. [#]line __oline__ "configure"
  3105. int main()
  3106. {
  3107. typedef bool atomic_type;
  3108. atomic_type c1;
  3109. atomic_type c2;
  3110. atomic_type c3(0);
  3111. // N.B. __atomic_fetch_add is not supported for bool.
  3112. __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
  3113. __ATOMIC_RELAXED);
  3114. __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
  3115. __atomic_load_n(&c1, __ATOMIC_RELAXED);
  3116. return 0;
  3117. }
  3118. EOF
  3119. AC_MSG_CHECKING([for atomic builtins for bool])
  3120. if AC_TRY_EVAL(ac_compile); then
  3121. if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
  3122. glibcxx_cv_atomic_bool=no
  3123. else
  3124. glibcxx_cv_atomic_bool=yes
  3125. fi
  3126. fi
  3127. AC_MSG_RESULT($glibcxx_cv_atomic_bool)
  3128. rm -f conftest*
  3129. cat > conftest.$ac_ext << EOF
  3130. [#]line __oline__ "configure"
  3131. int main()
  3132. {
  3133. typedef short atomic_type;
  3134. atomic_type c1;
  3135. atomic_type c2;
  3136. atomic_type c3(0);
  3137. __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
  3138. __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
  3139. __ATOMIC_RELAXED);
  3140. __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
  3141. __atomic_load_n(&c1, __ATOMIC_RELAXED);
  3142. return 0;
  3143. }
  3144. EOF
  3145. AC_MSG_CHECKING([for atomic builtins for short])
  3146. if AC_TRY_EVAL(ac_compile); then
  3147. if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
  3148. glibcxx_cv_atomic_short=no
  3149. else
  3150. glibcxx_cv_atomic_short=yes
  3151. fi
  3152. fi
  3153. AC_MSG_RESULT($glibcxx_cv_atomic_short)
  3154. rm -f conftest*
  3155. cat > conftest.$ac_ext << EOF
  3156. [#]line __oline__ "configure"
  3157. int main()
  3158. {
  3159. // NB: _Atomic_word not necessarily int.
  3160. typedef int atomic_type;
  3161. atomic_type c1;
  3162. atomic_type c2;
  3163. atomic_type c3(0);
  3164. __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
  3165. __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
  3166. __ATOMIC_RELAXED);
  3167. __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
  3168. __atomic_load_n(&c1, __ATOMIC_RELAXED);
  3169. return 0;
  3170. }
  3171. EOF
  3172. AC_MSG_CHECKING([for atomic builtins for int])
  3173. if AC_TRY_EVAL(ac_compile); then
  3174. if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
  3175. glibcxx_cv_atomic_int=no
  3176. else
  3177. glibcxx_cv_atomic_int=yes
  3178. fi
  3179. fi
  3180. AC_MSG_RESULT($glibcxx_cv_atomic_int)
  3181. rm -f conftest*
  3182. cat > conftest.$ac_ext << EOF
  3183. [#]line __oline__ "configure"
  3184. int main()
  3185. {
  3186. typedef long long atomic_type;
  3187. atomic_type c1;
  3188. atomic_type c2;
  3189. atomic_type c3(0);
  3190. __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
  3191. __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
  3192. __ATOMIC_RELAXED);
  3193. __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
  3194. __atomic_load_n(&c1, __ATOMIC_RELAXED);
  3195. return 0;
  3196. }
  3197. EOF
  3198. AC_MSG_CHECKING([for atomic builtins for long long])
  3199. if AC_TRY_EVAL(ac_compile); then
  3200. if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
  3201. glibcxx_cv_atomic_long_long=no
  3202. else
  3203. glibcxx_cv_atomic_long_long=yes
  3204. fi
  3205. fi
  3206. AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
  3207. rm -f conftest*
  3208. fi
  3209. CXXFLAGS="$old_CXXFLAGS"
  3210. AC_LANG_RESTORE
  3211. # Set atomicity_dir to builtins if all but the long long test above passes,
  3212. # or if the builtins were already chosen (e.g. by configure.host).
  3213. if { test "$glibcxx_cv_atomic_bool" = yes \
  3214. && test "$glibcxx_cv_atomic_short" = yes \
  3215. && test "$glibcxx_cv_atomic_int" = yes; } \
  3216. || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then
  3217. AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS, 1,
  3218. [Define if the compiler supports C++11 atomics.])
  3219. atomicity_dir=cpu/generic/atomicity_builtins
  3220. fi
  3221. # If still generic, set to mutex.
  3222. if test $atomicity_dir = "cpu/generic" ; then
  3223. atomicity_dir=cpu/generic/atomicity_mutex
  3224. AC_MSG_WARN([No native atomic operations are provided for this platform.])
  3225. if test "x$target_thread_file" = xsingle; then
  3226. AC_MSG_WARN([They cannot be faked when thread support is disabled.])
  3227. AC_MSG_WARN([Thread-safety of certain classes is not guaranteed.])
  3228. else
  3229. AC_MSG_WARN([They will be faked using a mutex.])
  3230. AC_MSG_WARN([Performance of certain classes will degrade as a result.])
  3231. fi
  3232. fi
  3233. ])
  3234. dnl
  3235. dnl Set default lock policy for synchronizing shared_ptr reference counting.
  3236. dnl
  3237. dnl --with-libstdcxx-lock-policy=auto
  3238. dnl Use atomic operations for shared_ptr reference counting only if
  3239. dnl the default target supports atomic compare-and-swap.
  3240. dnl --with-libstdcxx-lock-policy=atomic
  3241. dnl Use atomic operations for shared_ptr reference counting.
  3242. dnl --with-libstdcxx-lock-policy=mutex
  3243. dnl Use a mutex to synchronize shared_ptr reference counting.
  3244. dnl
  3245. dnl This controls the value of __gnu_cxx::__default_lock_policy, which
  3246. dnl determines how shared_ptr reference counts are synchronized.
  3247. dnl The option "atomic" means that atomic operations should be used,
  3248. dnl "mutex" means that a mutex will be used. The default option, "auto",
  3249. dnl will check if the target supports the compiler-generated builtins
  3250. dnl for atomic compare-and-swap operations for 2-byte and 4-byte integers,
  3251. dnl and will use "atomic" if supported, "mutex" otherwise.
  3252. dnl This option is ignored if the thread model used by GCC is "single",
  3253. dnl as no synchronization is used at all in that case.
  3254. dnl This option affects the library ABI (except in the "single" thread model).
  3255. dnl
  3256. dnl Defines _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY to 1 if atomics should be used.
  3257. dnl
  3258. AC_DEFUN([GLIBCXX_ENABLE_LOCK_POLICY], [
  3259. AC_ARG_WITH([libstdcxx-lock-policy],
  3260. AC_HELP_STRING([--with-libstdcxx-lock-policy={atomic,mutex,auto}],
  3261. [synchronization policy for shared_ptr reference counting [default=auto]]),
  3262. [libstdcxx_atomic_lock_policy=$withval],
  3263. [libstdcxx_atomic_lock_policy=auto])
  3264. case "$libstdcxx_atomic_lock_policy" in
  3265. atomic|mutex|auto) ;;
  3266. *) AC_MSG_ERROR([Invalid argument for --with-libstdcxx-lock-policy]) ;;
  3267. esac
  3268. AC_MSG_CHECKING([for lock policy for shared_ptr reference counts])
  3269. if test x"$libstdcxx_atomic_lock_policy" = x"auto"; then
  3270. AC_LANG_SAVE
  3271. AC_LANG_CPLUSPLUS
  3272. ac_save_CXXFLAGS="$CXXFLAGS"
  3273. dnl Why do we care about 2-byte CAS on targets with 4-byte _Atomic_word?!
  3274. dnl Why don't we check 8-byte CAS for sparc64, where _Atomic_word is long?!
  3275. dnl New targets should only check for CAS for the _Atomic_word type.
  3276. AC_TRY_COMPILE([
  3277. #if ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
  3278. # error "No 2-byte compare-and-swap"
  3279. #elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
  3280. # error "No 4-byte compare-and-swap"
  3281. #endif
  3282. ],,
  3283. [libstdcxx_atomic_lock_policy=atomic],
  3284. [libstdcxx_atomic_lock_policy=mutex])
  3285. AC_LANG_RESTORE
  3286. CXXFLAGS="$ac_save_CXXFLAGS"
  3287. fi
  3288. if test x"$libstdcxx_atomic_lock_policy" = x"atomic"; then
  3289. AC_MSG_RESULT(atomic)
  3290. AC_DEFINE(HAVE_ATOMIC_LOCK_POLICY,1,
  3291. [Defined if shared_ptr reference counting should use atomic operations.])
  3292. else
  3293. AC_MSG_RESULT(mutex)
  3294. fi
  3295. ])
  3296. dnl
  3297. dnl Allow visibility attributes to be used on namespaces, objects, etc.
  3298. dnl
  3299. dnl --enable-libstdcxx-visibility enables attempt to use visibility attributes.
  3300. dnl --disable-libstdcxx-visibility turns off all use of visibility attributes.
  3301. dnl + Usage: GLIBCXX_ENABLE_LIBSTDCXX_VISIBILITY[(DEFAULT)]
  3302. dnl Where DEFAULT is 'yes'.
  3303. dnl
  3304. AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_VISIBILITY], [
  3305. GLIBCXX_ENABLE(libstdcxx-visibility,$1,,[enables visibility safe usage])
  3306. if test x$enable_libstdcxx_visibility = xyes ; then
  3307. dnl all hail libgfortran
  3308. dnl Check whether the target supports hidden visibility.
  3309. AC_CACHE_CHECK([whether the target supports hidden visibility],
  3310. glibcxx_cv_have_attribute_visibility, [
  3311. save_CFLAGS="$CFLAGS"
  3312. CFLAGS="$CFLAGS -Werror"
  3313. AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
  3314. [], glibcxx_cv_have_attribute_visibility=yes,
  3315. glibcxx_cv_have_attribute_visibility=no)
  3316. CFLAGS="$save_CFLAGS"])
  3317. if test $glibcxx_cv_have_attribute_visibility = no; then
  3318. enable_libstdcxx_visibility=no
  3319. fi
  3320. fi
  3321. GLIBCXX_CONDITIONAL(ENABLE_VISIBILITY, test $enable_libstdcxx_visibility = yes)
  3322. AC_MSG_NOTICE([visibility supported: $enable_libstdcxx_visibility])
  3323. ])
  3324. dnl
  3325. dnl Add version tags to symbols in shared library (or not), additionally
  3326. dnl marking other symbols as private/local (or not).
  3327. dnl
  3328. dnl Sets libtool_VERSION, and determines shared library SONAME.
  3329. dnl
  3330. dnl This depends on GLIBCXX CHECK_LINKER_FEATURES, but without it assumes no.
  3331. dnl
  3332. dnl --enable-symvers=style adds a version script to the linker call when
  3333. dnl creating the shared library. The choice of version script is
  3334. dnl controlled by 'style'.
  3335. dnl --disable-symvers does not.
  3336. dnl
  3337. dnl + Usage: GLIBCXX_ENABLE_SYMVERS[(DEFAULT)]
  3338. dnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to
  3339. dnl choose a default style based on linker characteristics. Passing
  3340. dnl 'no' disables versioning.
  3341. dnl
  3342. AC_DEFUN([GLIBCXX_ENABLE_SYMVERS], [
  3343. GLIBCXX_ENABLE(symvers,$1,[[[=STYLE]]],
  3344. [enables symbol versioning of the shared library],
  3345. [permit yes|no|gnu|gnu-versioned-namespace|darwin|darwin-export|sun])
  3346. # If we never went through the GLIBCXX_CHECK_LINKER_FEATURES macro, then we
  3347. # don't know enough about $LD to do tricks...
  3348. AC_REQUIRE([GLIBCXX_CHECK_LINKER_FEATURES])
  3349. # Sun style symbol versions needs GNU c++filt for make_sunver.pl to work
  3350. # with extern "C++" in version scripts.
  3351. AC_REQUIRE([GCC_PROG_GNU_CXXFILT])
  3352. # Turn a 'yes' into a suitable default.
  3353. if test x$enable_symvers = xyes ; then
  3354. if test $enable_shared = no || test "x$LD" = x || test x$gcc_no_link = xyes; then
  3355. enable_symvers=no
  3356. else
  3357. if test $with_gnu_ld = yes ; then
  3358. case ${target_os} in
  3359. hpux*)
  3360. enable_symvers=no ;;
  3361. *)
  3362. enable_symvers=gnu ;;
  3363. esac
  3364. else
  3365. case ${target_os} in
  3366. darwin*)
  3367. enable_symvers=darwin ;;
  3368. # Sun symbol versioning exists since Solaris 2.5.
  3369. solaris2.[[5-9]]* | solaris2.1[[0-9]]*)
  3370. # make_sunver.pl needs GNU c++filt to support extern "C++" in
  3371. # version scripts, so disable symbol versioning if none can be
  3372. # found.
  3373. if test -z "$ac_cv_path_CXXFILT"; then
  3374. AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
  3375. AC_MSG_WARN([=== no GNU c++filt could be found.])
  3376. AC_MSG_WARN([=== Symbol versioning will be disabled.])
  3377. enable_symvers=no
  3378. else
  3379. enable_symvers=sun
  3380. fi
  3381. ;;
  3382. *)
  3383. enable_symvers=no ;;
  3384. esac
  3385. fi
  3386. fi
  3387. fi
  3388. # Check to see if 'darwin' or 'darwin-export' can win.
  3389. if test x$enable_symvers = xdarwin-export ; then
  3390. enable_symvers=darwin
  3391. fi
  3392. # Check if 'sun' was requested on non-Solaris 2 platforms.
  3393. if test x$enable_symvers = xsun ; then
  3394. case ${target_os} in
  3395. solaris2*)
  3396. # All fine.
  3397. ;;
  3398. *)
  3399. # Unlikely to work.
  3400. AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
  3401. AC_MSG_WARN([=== you are not targetting Solaris 2.])
  3402. AC_MSG_WARN([=== Symbol versioning will be disabled.])
  3403. enable_symvers=no
  3404. ;;
  3405. esac
  3406. fi
  3407. # Check to see if 'gnu' can win.
  3408. if test $enable_symvers = gnu ||
  3409. test $enable_symvers = gnu-versioned-namespace ||
  3410. test $enable_symvers = sun; then
  3411. # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
  3412. AC_MSG_CHECKING([for shared libgcc])
  3413. ac_save_CFLAGS="$CFLAGS"
  3414. CFLAGS=' -lgcc_s'
  3415. AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes, glibcxx_shared_libgcc=no)
  3416. CFLAGS="$ac_save_CFLAGS"
  3417. if test $glibcxx_shared_libgcc = no; then
  3418. cat > conftest.c <<EOF
  3419. int main (void) { return 0; }
  3420. EOF
  3421. changequote(,)dnl
  3422. glibcxx_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
  3423. -shared -shared-libgcc -o conftest.so \
  3424. conftest.c -v 2>&1 >/dev/null \
  3425. | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
  3426. changequote([,])dnl
  3427. rm -f conftest.c conftest.so
  3428. if test x${glibcxx_libgcc_s_suffix+set} = xset; then
  3429. CFLAGS=" -lgcc_s$glibcxx_libgcc_s_suffix"
  3430. AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes)
  3431. CFLAGS="$ac_save_CFLAGS"
  3432. fi
  3433. fi
  3434. AC_MSG_RESULT($glibcxx_shared_libgcc)
  3435. # For GNU ld, we need at least this version. The format is described in
  3436. # GLIBCXX_CHECK_LINKER_FEATURES above.
  3437. glibcxx_min_gnu_ld_version=21400
  3438. # If no shared libgcc, can't win.
  3439. if test $glibcxx_shared_libgcc != yes; then
  3440. AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
  3441. AC_MSG_WARN([=== you are not building a shared libgcc_s.])
  3442. AC_MSG_WARN([=== Symbol versioning will be disabled.])
  3443. enable_symvers=no
  3444. elif test $with_gnu_ld != yes && test $enable_symvers = sun; then
  3445. : All interesting versions of Sun ld support sun style symbol versioning.
  3446. elif test $with_gnu_ld != yes ; then
  3447. # just fail for now
  3448. AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
  3449. AC_MSG_WARN([=== you are not using the GNU linker.])
  3450. AC_MSG_WARN([=== Symbol versioning will be disabled.])
  3451. enable_symvers=no
  3452. elif test $glibcxx_ld_is_gold = yes ; then
  3453. : All versions of gold support symbol versioning.
  3454. elif test $glibcxx_ld_is_mold = yes ; then
  3455. : All versions of mold support symbol versioning.
  3456. elif test $glibcxx_gnu_ld_version -lt $glibcxx_min_gnu_ld_version ; then
  3457. # The right tools, the right setup, but too old. Fallbacks?
  3458. AC_MSG_WARN(=== Linker version $glibcxx_gnu_ld_version is too old for)
  3459. AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
  3460. AC_MSG_WARN(=== You would need to upgrade your binutils to version)
  3461. AC_MSG_WARN(=== $glibcxx_min_gnu_ld_version or later and rebuild GCC.)
  3462. AC_MSG_WARN([=== Symbol versioning will be disabled.])
  3463. enable_symvers=no
  3464. fi
  3465. fi
  3466. # For libtool versioning info, format is CURRENT:REVISION:AGE
  3467. libtool_VERSION=6:30:0
  3468. # Everything parsed; figure out what files and settings to use.
  3469. case $enable_symvers in
  3470. no)
  3471. SYMVER_FILE=config/abi/pre/none.ver
  3472. ;;
  3473. gnu)
  3474. SYMVER_FILE=config/abi/pre/gnu.ver
  3475. AC_DEFINE(_GLIBCXX_SYMVER_GNU, 1,
  3476. [Define to use GNU versioning in the shared library.])
  3477. ;;
  3478. gnu-versioned-namespace)
  3479. libtool_VERSION=8:0:0
  3480. SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
  3481. AC_DEFINE(_GLIBCXX_SYMVER_GNU_NAMESPACE, 1,
  3482. [Define to use GNU namespace versioning in the shared library.])
  3483. ;;
  3484. darwin)
  3485. SYMVER_FILE=config/abi/pre/gnu.ver
  3486. AC_DEFINE(_GLIBCXX_SYMVER_DARWIN, 1,
  3487. [Define to use darwin versioning in the shared library.])
  3488. ;;
  3489. sun)
  3490. SYMVER_FILE=config/abi/pre/gnu.ver
  3491. AC_DEFINE(_GLIBCXX_SYMVER_SUN, 1,
  3492. [Define to use Sun versioning in the shared library.])
  3493. ;;
  3494. esac
  3495. if test x$enable_symvers != xno ; then
  3496. AC_DEFINE(_GLIBCXX_SYMVER, 1,
  3497. [Define to use symbol versioning in the shared library.])
  3498. fi
  3499. AC_CACHE_CHECK([whether the target supports .symver directive],
  3500. glibcxx_cv_have_as_symver_directive, [
  3501. AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");],
  3502. [], glibcxx_cv_have_as_symver_directive=yes,
  3503. glibcxx_cv_have_as_symver_directive=no)])
  3504. if test $glibcxx_cv_have_as_symver_directive = yes; then
  3505. AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1,
  3506. [Define to 1 if the target assembler supports .symver directive.])
  3507. fi
  3508. AC_SUBST(SYMVER_FILE)
  3509. AC_SUBST(port_specific_symbol_files)
  3510. GLIBCXX_CONDITIONAL(ENABLE_SYMVERS, test $enable_symvers != no)
  3511. GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU, test $enable_symvers = gnu)
  3512. GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU_NAMESPACE, test $enable_symvers = gnu-versioned-namespace)
  3513. GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_DARWIN, test $enable_symvers = darwin)
  3514. GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_SUN, test $enable_symvers = sun)
  3515. AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
  3516. if test $enable_symvers != no ; then
  3517. case ${target_os} in
  3518. # The Solaris 2 runtime linker doesn't support the GNU extension of
  3519. # binding the same symbol to different versions
  3520. solaris2*)
  3521. ;;
  3522. # Other platforms with GNU symbol versioning (GNU/Linux, more?) do.
  3523. *)
  3524. AC_DEFINE(HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT, 1,
  3525. [Define to 1 if the target runtime linker supports binding the same symbol to different versions.])
  3526. ;;
  3527. esac
  3528. fi
  3529. # Now, set up compatibility support, if any.
  3530. # In addition, need this to deal with std::size_t mangling in
  3531. # src/compatibility.cc. In a perfect world, could use
  3532. # typeid(std::size_t).name()[0] to do direct substitution.
  3533. AC_MSG_CHECKING([for size_t as unsigned int])
  3534. ac_save_CFLAGS="$CFLAGS"
  3535. CFLAGS="-Werror"
  3536. AC_TRY_COMPILE(, [__SIZE_TYPE__* stp; unsigned int* uip; stp = uip;],
  3537. [glibcxx_size_t_is_i=yes], [glibcxx_size_t_is_i=no])
  3538. CFLAGS=$ac_save_CFLAGS
  3539. if test "$glibcxx_size_t_is_i" = yes; then
  3540. AC_DEFINE(_GLIBCXX_SIZE_T_IS_UINT, 1, [Define if size_t is unsigned int.])
  3541. fi
  3542. AC_MSG_RESULT([$glibcxx_size_t_is_i])
  3543. AC_MSG_CHECKING([for ptrdiff_t as int])
  3544. ac_save_CFLAGS="$CFLAGS"
  3545. CFLAGS="-Werror"
  3546. AC_TRY_COMPILE(, [__PTRDIFF_TYPE__* ptp; int* ip; ptp = ip;],
  3547. [glibcxx_ptrdiff_t_is_i=yes], [glibcxx_ptrdiff_t_is_i=no])
  3548. CFLAGS=$ac_save_CFLAGS
  3549. if test "$glibcxx_ptrdiff_t_is_i" = yes; then
  3550. AC_DEFINE(_GLIBCXX_PTRDIFF_T_IS_INT, 1, [Define if ptrdiff_t is int.])
  3551. fi
  3552. AC_MSG_RESULT([$glibcxx_ptrdiff_t_is_i])
  3553. ])
  3554. dnl
  3555. dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
  3556. dnl We must stage the required headers so that they will be installed
  3557. dnl with the library (unlike libgcc, the STL implementation is provided
  3558. dnl solely within headers). Since we must not inject random user-space
  3559. dnl macro names into user-provided C++ code, we first stage into <file>-in
  3560. dnl and process to <file> with an output command. The reason for a two-
  3561. dnl stage process here is to correctly handle $srcdir!=$objdir without
  3562. dnl having to write complex code (the sed commands to clean the macro
  3563. dnl namespace are complex and fragile enough as it is). We must also
  3564. dnl add a relative path so that -I- is supported properly.
  3565. dnl
  3566. dnl Substs:
  3567. dnl thread_header
  3568. dnl
  3569. AC_DEFUN([GLIBCXX_ENABLE_THREADS], [
  3570. AC_MSG_CHECKING([for thread model used by GCC])
  3571. target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
  3572. AC_MSG_RESULT([$target_thread_file])
  3573. GCC_AC_THREAD_HEADER([$target_thread_file])
  3574. ])
  3575. dnl
  3576. dnl Check if gthread implementation defines the types and functions
  3577. dnl required by the c++0x thread library. Conforming gthread
  3578. dnl implementations can define __GTHREADS_CXX0X to enable use with c++0x.
  3579. dnl
  3580. dnl GLIBCXX_ENABLE_SYMVERS must be done before this.
  3581. dnl
  3582. AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
  3583. GLIBCXX_ENABLE(libstdcxx-threads,auto,,[enable C++11 threads support])
  3584. if test x$enable_libstdcxx_threads = xauto ||
  3585. test x$enable_libstdcxx_threads = xyes; then
  3586. AC_LANG_SAVE
  3587. AC_LANG_CPLUSPLUS
  3588. ac_save_CXXFLAGS="$CXXFLAGS"
  3589. CXXFLAGS="$CXXFLAGS -fno-exceptions \
  3590. -I${toplevel_srcdir}/libgcc -I${toplevel_builddir}/libgcc"
  3591. target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
  3592. case $target_thread_file in
  3593. posix)
  3594. CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS"
  3595. esac
  3596. AC_MSG_CHECKING([whether it can be safely assumed that mutex_timedlock is available])
  3597. AC_TRY_COMPILE([#include <unistd.h>],
  3598. [
  3599. // In case of POSIX threads check _POSIX_TIMEOUTS.
  3600. #if (defined(_PTHREADS) \
  3601. && (!defined(_POSIX_TIMEOUTS) || _POSIX_TIMEOUTS <= 0))
  3602. #error
  3603. #endif
  3604. ], [ac_gthread_use_mutex_timedlock=1], [ac_gthread_use_mutex_timedlock=0])
  3605. AC_DEFINE_UNQUOTED(_GTHREAD_USE_MUTEX_TIMEDLOCK, $ac_gthread_use_mutex_timedlock,
  3606. [Define to 1 if mutex_timedlock is available.])
  3607. if test $ac_gthread_use_mutex_timedlock = 1 ; then res_mutex_timedlock=yes ;
  3608. else res_mutex_timedlock=no ; fi
  3609. AC_MSG_RESULT([$res_mutex_timedlock])
  3610. AC_MSG_CHECKING([for gthreads library])
  3611. AC_TRY_COMPILE([#include "gthr.h"],
  3612. [
  3613. #ifndef __GTHREADS_CXX0X
  3614. #error
  3615. #endif
  3616. ], [ac_has_gthreads=yes], [ac_has_gthreads=no])
  3617. else
  3618. ac_has_gthreads=no
  3619. fi
  3620. AC_MSG_RESULT([$ac_has_gthreads])
  3621. if test x"$ac_has_gthreads" = x"yes"; then
  3622. AC_DEFINE(_GLIBCXX_HAS_GTHREADS, 1,
  3623. [Define if gthreads library is available.])
  3624. # Also check for pthread_rwlock_t for std::shared_timed_mutex in C++14
  3625. # but only do so if we're using pthread in the gthread library.
  3626. # On VxWorks for example, pthread_rwlock_t is defined in sys/types.h
  3627. # but the pthread library is not there by default and the gthread library
  3628. # does not use it.
  3629. AC_TRY_COMPILE([#include "gthr.h"],
  3630. [
  3631. #if (!defined(_PTHREADS))
  3632. #error
  3633. #endif
  3634. ], [ac_gthread_use_pthreads=yes], [ac_gthread_use_pthreads=no])
  3635. if test x"$ac_gthread_use_pthreads" = x"yes"; then
  3636. AC_CHECK_TYPE([pthread_rwlock_t],
  3637. [AC_DEFINE([_GLIBCXX_USE_PTHREAD_RWLOCK_T], 1,
  3638. [Define if POSIX read/write locks are available in <gthr.h>.])],
  3639. [],
  3640. [#include "gthr.h"])
  3641. fi
  3642. fi
  3643. AC_CHECK_HEADER(semaphore.h, [
  3644. AC_MSG_CHECKING([for POSIX Semaphores and sem_timedwait])
  3645. AC_TRY_COMPILE([
  3646. #include <unistd.h>
  3647. #include <semaphore.h>
  3648. #include <limits.h>
  3649. ],
  3650. [
  3651. #if !defined _POSIX_TIMEOUTS || _POSIX_TIMEOUTS <= 0
  3652. # error "POSIX Timeouts option not supported"
  3653. #elif !defined _POSIX_SEMAPHORES || _POSIX_SEMAPHORES <= 0
  3654. # error "POSIX Semaphores option not supported"
  3655. #else
  3656. #if defined SEM_VALUE_MAX
  3657. constexpr int sem_value_max = SEM_VALUE_MAX;
  3658. #elif defined _POSIX_SEM_VALUE_MAX
  3659. constexpr int sem_value_max = _POSIX_SEM_VALUE_MAX;
  3660. #else
  3661. # error "SEM_VALUE_MAX not available"
  3662. #endif
  3663. sem_t sem;
  3664. sem_init(&sem, 0, sem_value_max);
  3665. struct timespec ts = { 0 };
  3666. sem_timedwait(&sem, &ts);
  3667. #endif
  3668. ],
  3669. [ac_have_posix_semaphore=yes],
  3670. [ac_have_posix_semaphore=no])],
  3671. [ac_have_posix_semaphore=no])
  3672. if test $ac_have_posix_semaphore = yes ; then
  3673. AC_DEFINE(HAVE_POSIX_SEMAPHORE,
  3674. 1,
  3675. [Define to 1 if POSIX Semaphores with sem_timedwait are available in <semaphore.h>.])
  3676. fi
  3677. AC_MSG_RESULT([$ac_have_posix_semaphore])
  3678. CXXFLAGS="$ac_save_CXXFLAGS"
  3679. AC_LANG_RESTORE
  3680. ])
  3681. # Check whether LC_MESSAGES is available in <locale.h>.
  3682. # Ulrich Drepper <drepper@cygnus.com>, 1995.
  3683. #
  3684. # This file file be copied and used freely without restrictions. It can
  3685. # be used in projects which are not available under the GNU Public License
  3686. # but which still want to provide support for the GNU gettext functionality.
  3687. # Please note that the actual code is *not* freely available.
  3688. AC_DEFUN([AC_LC_MESSAGES], [
  3689. AC_CHECK_HEADER(locale.h, [
  3690. AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
  3691. [AC_TRY_COMPILE([#include <locale.h>], [return LC_MESSAGES],
  3692. ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
  3693. if test $ac_cv_val_LC_MESSAGES = yes; then
  3694. AC_DEFINE(HAVE_LC_MESSAGES, 1,
  3695. [Define if LC_MESSAGES is available in <locale.h>.])
  3696. fi
  3697. ])
  3698. ])
  3699. dnl
  3700. dnl Check whether rdrand is supported in the assembler.
  3701. AC_DEFUN([GLIBCXX_CHECK_X86_RDRAND], [
  3702. AC_CACHE_CHECK([for rdrand support in assembler],
  3703. ac_cv_x86_rdrand, [
  3704. ac_cv_x86_rdrand=no
  3705. case "$target" in
  3706. i?86-*-* | \
  3707. x86_64-*-*)
  3708. AC_TRY_COMPILE(, [asm("rdrand %eax");],
  3709. [ac_cv_x86_rdrand=yes], [ac_cv_x86_rdrand=no])
  3710. esac
  3711. ])
  3712. if test $ac_cv_x86_rdrand = yes; then
  3713. AC_DEFINE(_GLIBCXX_X86_RDRAND, 1,
  3714. [ Defined if as can handle rdrand. ])
  3715. fi
  3716. ])
  3717. dnl
  3718. dnl Check whether rdseed is supported in the assembler.
  3719. AC_DEFUN([GLIBCXX_CHECK_X86_RDSEED], [
  3720. AC_CACHE_CHECK([for rdseed support in assembler],
  3721. ac_cv_x86_rdseed, [
  3722. ac_cv_x86_rdseed=no
  3723. case "$target" in
  3724. i?86-*-* | \
  3725. x86_64-*-*)
  3726. AC_TRY_COMPILE(, [asm("rdseed %eax");],
  3727. [ac_cv_x86_rdseed=yes], [ac_cv_x86_rdseed=no])
  3728. esac
  3729. ])
  3730. if test $ac_cv_x86_rdseed = yes; then
  3731. AC_DEFINE(_GLIBCXX_X86_RDSEED, 1,
  3732. [ Defined if as can handle rdseed. ])
  3733. fi
  3734. ])
  3735. dnl
  3736. dnl Check whether get_nprocs is available in <sys/sysinfo.h>, and define _GLIBCXX_USE_GET_NPROCS.
  3737. dnl
  3738. AC_DEFUN([GLIBCXX_CHECK_GET_NPROCS], [
  3739. AC_LANG_SAVE
  3740. AC_LANG_CPLUSPLUS
  3741. ac_save_CXXFLAGS="$CXXFLAGS"
  3742. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  3743. AC_CACHE_CHECK([for get_nprocs],
  3744. glibcxx_cv_GET_NPROCS, [
  3745. GCC_TRY_COMPILE_OR_LINK(
  3746. [#include <sys/sysinfo.h>],
  3747. [int n = get_nprocs();],
  3748. [glibcxx_cv_GET_NPROCS=yes],
  3749. [glibcxx_cv_GET_NPROCS=no])
  3750. ])
  3751. if test $glibcxx_cv_GET_NPROCS = yes; then
  3752. AC_DEFINE(_GLIBCXX_USE_GET_NPROCS, 1, [Define if get_nprocs is available in <sys/sysinfo.h>.])
  3753. fi
  3754. CXXFLAGS="$ac_save_CXXFLAGS"
  3755. AC_LANG_RESTORE
  3756. ])
  3757. dnl
  3758. dnl Check whether sysconf(_SC_NPROCESSORS_ONLN) is available in <unistd.h>, and define _GLIBCXX_USE_SC_NPROCESSORS_ONLN.
  3759. dnl
  3760. AC_DEFUN([GLIBCXX_CHECK_SC_NPROCESSORS_ONLN], [
  3761. AC_LANG_SAVE
  3762. AC_LANG_CPLUSPLUS
  3763. ac_save_CXXFLAGS="$CXXFLAGS"
  3764. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  3765. AC_CACHE_CHECK([for _SC_NPROCESSORS_ONLN],
  3766. glibcxx_cv_SC_NPROCESSORS_ONLN, [
  3767. GCC_TRY_COMPILE_OR_LINK(
  3768. [#include <unistd.h>],
  3769. [int n = sysconf(_SC_NPROCESSORS_ONLN);],
  3770. [glibcxx_cv_SC_NPROCESSORS_ONLN=yes],
  3771. [glibcxx_cv_SC_NPROCESSORS_ONLN=no])
  3772. ])
  3773. if test $glibcxx_cv_SC_NPROCESSORS_ONLN = yes; then
  3774. AC_DEFINE(_GLIBCXX_USE_SC_NPROCESSORS_ONLN, 1, [Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>.])
  3775. fi
  3776. CXXFLAGS="$ac_save_CXXFLAGS"
  3777. AC_LANG_RESTORE
  3778. ])
  3779. dnl
  3780. dnl Check whether sysconf(_SC_NPROC_ONLN) is available in <unistd.h>, and define _GLIBCXX_USE_SC_NPROC_ONLN.
  3781. dnl
  3782. AC_DEFUN([GLIBCXX_CHECK_SC_NPROC_ONLN], [
  3783. AC_LANG_SAVE
  3784. AC_LANG_CPLUSPLUS
  3785. ac_save_CXXFLAGS="$CXXFLAGS"
  3786. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  3787. AC_CACHE_CHECK([for _SC_NPROC_ONLN],
  3788. glibcxx_cv_SC_NPROC_ONLN, [
  3789. GCC_TRY_COMPILE_OR_LINK(
  3790. [#include <unistd.h>],
  3791. [int n = sysconf(_SC_NPROC_ONLN);],
  3792. [glibcxx_cv_SC_NPROC_ONLN=yes],
  3793. [glibcxx_cv_SC_NPROC_ONLN=no])
  3794. ])
  3795. if test $glibcxx_cv_SC_NPROC_ONLN = yes; then
  3796. AC_DEFINE(_GLIBCXX_USE_SC_NPROC_ONLN, 1, [Define if _SC_NPROC_ONLN is available in <unistd.h>.])
  3797. fi
  3798. CXXFLAGS="$ac_save_CXXFLAGS"
  3799. AC_LANG_RESTORE
  3800. ])
  3801. dnl
  3802. dnl Check whether pthread_num_processors_np is available in <pthread.h>, and define _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP.
  3803. dnl
  3804. AC_DEFUN([GLIBCXX_CHECK_PTHREADS_NUM_PROCESSORS_NP], [
  3805. AC_LANG_SAVE
  3806. AC_LANG_CPLUSPLUS
  3807. ac_save_CXXFLAGS="$CXXFLAGS"
  3808. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  3809. AC_CACHE_CHECK([for pthreads_num_processors_np],
  3810. glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP, [
  3811. GCC_TRY_COMPILE_OR_LINK(
  3812. [#include <pthread.h>],
  3813. [int n = pthread_num_processors_np();],
  3814. [glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP=yes],
  3815. [glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP=no])
  3816. ])
  3817. if test $glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP = yes; then
  3818. AC_DEFINE(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP, 1, [Define if pthreads_num_processors_np is available in <pthread.h>.])
  3819. fi
  3820. CXXFLAGS="$ac_save_CXXFLAGS"
  3821. AC_LANG_RESTORE
  3822. ])
  3823. dnl
  3824. dnl Check whether pthread_cond_clockwait is available in <pthread.h> for std::condition_variable to use,
  3825. dnl and define _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT.
  3826. dnl
  3827. AC_DEFUN([GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT], [
  3828. AC_LANG_SAVE
  3829. AC_LANG_CPLUSPLUS
  3830. ac_save_CXXFLAGS="$CXXFLAGS"
  3831. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  3832. ac_save_LIBS="$LIBS"
  3833. LIBS="$LIBS -lpthread"
  3834. AC_CACHE_CHECK([for pthread_cond_clockwait],
  3835. glibcxx_cv_PTHREAD_COND_CLOCKWAIT, [
  3836. GCC_TRY_COMPILE_OR_LINK(
  3837. [#include <pthread.h>],
  3838. [pthread_mutex_t mutex; pthread_cond_t cond; struct timespec ts; int n = pthread_cond_clockwait(&cond, &mutex, 0, &ts);],
  3839. [glibcxx_cv_PTHREAD_COND_CLOCKWAIT=yes],
  3840. [glibcxx_cv_PTHREAD_COND_CLOCKWAIT=no])
  3841. ])
  3842. if test $glibcxx_cv_PTHREAD_COND_CLOCKWAIT = yes; then
  3843. AC_DEFINE(_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT, 1, [Define if pthread_cond_clockwait is available in <pthread.h>.])
  3844. fi
  3845. CXXFLAGS="$ac_save_CXXFLAGS"
  3846. LIBS="$ac_save_LIBS"
  3847. AC_LANG_RESTORE
  3848. ])
  3849. dnl
  3850. dnl Check whether pthread_mutex_clocklock is available in <pthread.h> for std::timed_mutex to use,
  3851. dnl and define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK.
  3852. dnl
  3853. AC_DEFUN([GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK], [
  3854. AC_LANG_SAVE
  3855. AC_LANG_CPLUSPLUS
  3856. ac_save_CXXFLAGS="$CXXFLAGS"
  3857. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  3858. ac_save_LIBS="$LIBS"
  3859. LIBS="$LIBS -lpthread"
  3860. AC_CACHE_CHECK([for pthread_mutex_clocklock],
  3861. glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK, [
  3862. GCC_TRY_COMPILE_OR_LINK(
  3863. [#include <pthread.h>],
  3864. [pthread_mutex_t mutex; struct timespec ts; int n = pthread_mutex_clocklock(&mutex, CLOCK_REALTIME, &ts);],
  3865. [glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK=yes],
  3866. [glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK=no])
  3867. ])
  3868. if test $glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK = yes; then
  3869. AC_DEFINE(_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK, 1, [Define if pthread_mutex_clocklock is available in <pthread.h>.])
  3870. fi
  3871. CXXFLAGS="$ac_save_CXXFLAGS"
  3872. LIBS="$ac_save_LIBS"
  3873. AC_LANG_RESTORE
  3874. ])
  3875. dnl
  3876. dnl Check whether pthread_mutex_clocklock is available in <pthread.h> for std::timed_mutex to use,
  3877. dnl and define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK.
  3878. dnl
  3879. AC_DEFUN([GLIBCXX_CHECK_PTHREAD_RWLOCK_CLOCKLOCK], [
  3880. AC_LANG_SAVE
  3881. AC_LANG_CPLUSPLUS
  3882. ac_save_CXXFLAGS="$CXXFLAGS"
  3883. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  3884. ac_save_LIBS="$LIBS"
  3885. LIBS="$LIBS -lpthread"
  3886. AC_CACHE_CHECK([for pthread_rwlock_clockrdlock, pthread_wlock_clockwrlock],
  3887. glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK, [
  3888. GCC_TRY_COMPILE_OR_LINK(
  3889. [#include <pthread.h>],
  3890. [pthread_rwlock_t rwl; struct timespec ts;]
  3891. [int n = pthread_rwlock_clockrdlock(&rwl, CLOCK_REALTIME, &ts);]
  3892. [int m = pthread_rwlock_clockwrlock(&rwl, CLOCK_REALTIME, &ts);],
  3893. [glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK=yes],
  3894. [glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK=no])
  3895. ])
  3896. if test $glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK = yes; then
  3897. AC_DEFINE(_GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK, 1, [Define if pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock are available in <pthread.h>.])
  3898. fi
  3899. CXXFLAGS="$ac_save_CXXFLAGS"
  3900. LIBS="$ac_save_LIBS"
  3901. AC_LANG_RESTORE
  3902. ])
  3903. dnl
  3904. dnl Check whether sysctl is available in <pthread.h>, and define _GLIBCXX_USE_SYSCTL_HW_NCPU.
  3905. dnl
  3906. AC_DEFUN([GLIBCXX_CHECK_SYSCTL_HW_NCPU], [
  3907. AC_LANG_SAVE
  3908. AC_LANG_CPLUSPLUS
  3909. ac_save_CXXFLAGS="$CXXFLAGS"
  3910. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  3911. AC_CACHE_CHECK([for hw.ncpu sysctl],
  3912. glibcxx_cv_SYSCTL_HW_NCPU, [
  3913. GCC_TRY_COMPILE_OR_LINK(
  3914. [
  3915. #include <stddef.h>
  3916. #include <sys/sysctl.h>
  3917. ],
  3918. [
  3919. int count;
  3920. size_t size = sizeof(count);
  3921. int mib[] = { CTL_HW, HW_NCPU };
  3922. sysctl(mib, 2, &count, &size, NULL, 0);
  3923. ],
  3924. [glibcxx_cv_SYSCTL_HW_NCPU=yes],
  3925. [glibcxx_cv_SYSCTL_HW_NCPU=no])
  3926. ])
  3927. if test $glibcxx_cv_SYSCTL_HW_NCPU = yes; then
  3928. AC_DEFINE(_GLIBCXX_USE_SYSCTL_HW_NCPU, 1, [Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>.])
  3929. fi
  3930. CXXFLAGS="$ac_save_CXXFLAGS"
  3931. AC_LANG_RESTORE
  3932. ])
  3933. dnl
  3934. dnl Check to see if python pretty printing can be activated.
  3935. dnl
  3936. dnl --with-python-dir=dir
  3937. dnl installs directory into $prefix/dir
  3938. AC_DEFUN([GLIBCXX_ENABLE_PYTHON], [
  3939. AC_MSG_CHECKING([for custom python install directory])
  3940. AC_ARG_WITH([python-dir],
  3941. AS_HELP_STRING([--with-python-dir],
  3942. [the location to install Python modules. This path is relative starting from the prefix.]),
  3943. [with_python_dir=$withval], [with_python_dir="no"])
  3944. AC_MSG_RESULT(${with_python_dir})
  3945. # Needed for installing Python modules during make install.
  3946. python_mod_dir="${with_python_dir}"
  3947. AC_SUBST(python_mod_dir)
  3948. GLIBCXX_CONDITIONAL(ENABLE_PYTHONDIR, test $python_mod_dir != no)
  3949. ])
  3950. dnl
  3951. dnl Check to see if -Werror is disabled.
  3952. dnl
  3953. dnl --enable-werror/--disable-werror
  3954. AC_DEFUN([GLIBCXX_ENABLE_WERROR], [
  3955. AC_MSG_CHECKING([for -Werror])
  3956. GLIBCXX_ENABLE(werror,$1,,[turns on -Werror])
  3957. AC_MSG_RESULT($enable_werror)
  3958. GLIBCXX_CONDITIONAL(ENABLE_WERROR, test $enable_werror = yes)
  3959. ])
  3960. dnl
  3961. dnl Check whether obsolescent tmpnam is available in <stdio.h>,
  3962. dnl and define _GLIBCXX_USE_TMPNAM.
  3963. dnl
  3964. AC_DEFUN([GLIBCXX_CHECK_TMPNAM], [dnl
  3965. dnl
  3966. AC_LANG_SAVE
  3967. AC_LANG_CPLUSPLUS
  3968. ac_save_CXXFLAGS="$CXXFLAGS"
  3969. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  3970. dnl
  3971. AC_CACHE_CHECK([for tmpnam], glibcxx_cv_TMPNAM, [dnl
  3972. GCC_TRY_COMPILE_OR_LINK(
  3973. [#include <stdio.h>],
  3974. [char *tmp = tmpnam(NULL);],
  3975. [glibcxx_cv_TMPNAM=yes],
  3976. [glibcxx_cv_TMPNAM=no])
  3977. ])
  3978. if test $glibcxx_cv_TMPNAM = yes; then
  3979. AC_DEFINE(_GLIBCXX_USE_TMPNAM, 1, [Define if obsolescent tmpnam is available in <stdio.h>.])
  3980. fi
  3981. dnl
  3982. CXXFLAGS="$ac_save_CXXFLAGS"
  3983. AC_LANG_RESTORE
  3984. ])
  3985. dnl
  3986. dnl Check to see if sys/sdt.h exists and that it is suitable for use.
  3987. dnl Some versions of sdt.h were not compatible with C++11.
  3988. dnl
  3989. AC_DEFUN([GLIBCXX_CHECK_SDT_H], [
  3990. # Note that this test has to be run with the C language.
  3991. # Otherwise, sdt.h will try to include some headers from
  3992. # libstdc++ itself.
  3993. AC_LANG_SAVE
  3994. AC_LANG_C
  3995. AC_CACHE_CHECK([for suitable sys/sdt.h],
  3996. glibcxx_cv_sys_sdt_h, [
  3997. # Because we have to run the test in C, we use grep rather
  3998. # than the compiler to check for the bug. The bug is that
  3999. # were strings without trailing whitespace, causing g++
  4000. # to look for operator"". The pattern searches for the fixed
  4001. # output.
  4002. AC_EGREP_CPP([ \",\" ], [
  4003. #include <sys/sdt.h>
  4004. int f() { STAP_PROBE(hi, bob); }
  4005. ], [glibcxx_cv_sys_sdt_h=yes], [glibcxx_cv_sys_sdt_h=no])
  4006. ])
  4007. AC_LANG_RESTORE
  4008. if test $glibcxx_cv_sys_sdt_h = yes; then
  4009. AC_DEFINE(HAVE_SYS_SDT_H, 1,
  4010. [Define to 1 if you have a suitable <sys/sdt.h> header file])
  4011. fi
  4012. ])
  4013. dnl
  4014. dnl Control whether the library should define symbols for old and new ABIs.
  4015. dnl This affects definitions of strings, stringstreams and locale facets.
  4016. dnl
  4017. dnl --disable-libstdcxx-dual-abi will use old ABI for all types.
  4018. dnl
  4019. dnl Defines:
  4020. dnl _GLIBCXX_USE_DUAL_ABI (always defined, either to 1 or 0)
  4021. dnl
  4022. AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI], [
  4023. GLIBCXX_ENABLE(libstdcxx-dual-abi,$1,,[support two versions of std::string])
  4024. if test x$enable_symvers = xgnu-versioned-namespace; then
  4025. # gnu-versioned-namespace is incompatible with the dual ABI.
  4026. enable_libstdcxx_dual_abi="no"
  4027. fi
  4028. if test x"$enable_libstdcxx_dual_abi" != xyes; then
  4029. AC_MSG_NOTICE([dual ABI is disabled])
  4030. default_libstdcxx_abi="gcc4-compatible"
  4031. fi
  4032. GLIBCXX_CONDITIONAL(ENABLE_DUAL_ABI, test $enable_libstdcxx_dual_abi = yes)
  4033. ])
  4034. dnl
  4035. dnl Check to see which ABI should be enabled by default.
  4036. dnl
  4037. dnl --with-default-libstdcxx-abi={gcc4-compatible,new}
  4038. dnl
  4039. dnl Defines:
  4040. dnl _GLIBCXX_USE_CXX11_ABI (always defined, either to 1 or 0)
  4041. dnl
  4042. AC_DEFUN([GLIBCXX_DEFAULT_ABI], [
  4043. if test x$enable_libstdcxx_dual_abi = xyes; then
  4044. AC_MSG_CHECKING([for default std::string ABI to use])
  4045. AC_ARG_WITH([default-libstdcxx-abi],
  4046. AS_HELP_STRING([--with-default-libstdcxx-abi],
  4047. [set the std::string ABI to use by default]),
  4048. [case "$withval" in
  4049. gcc4-compatible) default_libstdcxx_abi="gcc4-compatible" ;;
  4050. new|cxx11) default_libstdcxx_abi="new" ;;
  4051. c++*|gnu++*) AC_MSG_ERROR([Supported arguments for --with-default-libstdcxx-abi have changed, use "new" or "gcc4-compatible"]) ;;
  4052. *) AC_MSG_ERROR([Invalid argument for --with-default-libstdcxx-abi]) ;;
  4053. esac
  4054. ],
  4055. [default_libstdcxx_abi="new"])
  4056. AC_MSG_RESULT(${default_libstdcxx_abi})
  4057. fi
  4058. if test $default_libstdcxx_abi = "new"; then
  4059. glibcxx_cxx11_abi=1
  4060. glibcxx_cxx98_abi=0
  4061. else
  4062. glibcxx_cxx11_abi=0
  4063. glibcxx_cxx98_abi=1
  4064. fi
  4065. AC_SUBST(glibcxx_cxx98_abi)
  4066. GLIBCXX_CONDITIONAL(ENABLE_CXX11_ABI, test $glibcxx_cxx11_abi = 1)
  4067. ])
  4068. dnl
  4069. dnl Check to see whether to build libstdc++fs.a
  4070. dnl
  4071. dnl --enable-libstdcxx-filesystem-ts
  4072. dnl
  4073. AC_DEFUN([GLIBCXX_ENABLE_FILESYSTEM_TS], [
  4074. GLIBCXX_ENABLE(libstdcxx-filesystem-ts,auto,,
  4075. [turns on ISO/IEC TS 18822 support],
  4076. [permit yes|no|auto])
  4077. AC_MSG_CHECKING([whether to build Filesystem TS support])
  4078. if test x"$ac_cv_header_dirent_h" != x"yes"; then
  4079. enable_libstdcxx_filesystem_ts=no
  4080. fi
  4081. if test x"$enable_libstdcxx_filesystem_ts" = x"auto"; then
  4082. case "${target_os}" in
  4083. freebsd*|netbsd*|openbsd*|dragonfly*|darwin*)
  4084. enable_libstdcxx_filesystem_ts=yes
  4085. ;;
  4086. gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu | uclinux*)
  4087. enable_libstdcxx_filesystem_ts=yes
  4088. ;;
  4089. rtems*)
  4090. enable_libstdcxx_filesystem_ts=yes
  4091. ;;
  4092. solaris*)
  4093. enable_libstdcxx_filesystem_ts=yes
  4094. ;;
  4095. mingw*)
  4096. enable_libstdcxx_filesystem_ts=yes
  4097. ;;
  4098. *)
  4099. enable_libstdcxx_filesystem_ts=no
  4100. ;;
  4101. esac
  4102. fi
  4103. AC_MSG_RESULT($enable_libstdcxx_filesystem_ts)
  4104. GLIBCXX_CONDITIONAL(ENABLE_FILESYSTEM_TS, test $enable_libstdcxx_filesystem_ts = yes)
  4105. ])
  4106. dnl
  4107. dnl Check whether the library calls required by the C++17 Filesystem library
  4108. dnl and the Filesystem TS are present.
  4109. dnl Defines:
  4110. dnl HAVE_STRUCT_DIRENT_D_TYPE
  4111. dnl _GLIBCXX_USE_REALPATH
  4112. dnl _GLIBCXX_USE_UTIMENSAT
  4113. dnl _GLIBCXX_USE_ST_MTIM
  4114. dnl _GLIBCXX_USE_FCHMOD
  4115. dnl _GLIBCXX_USE_FCHMODAT
  4116. dnl _GLIBCXX_USE_SENDFILE
  4117. dnl HAVE_LINK
  4118. dnl HAVE_READLINK
  4119. dnl HAVE_SYMLINK
  4120. dnl
  4121. AC_DEFUN([GLIBCXX_CHECK_FILESYSTEM_DEPS], [dnl
  4122. dnl
  4123. AC_LANG_SAVE
  4124. AC_LANG_CPLUSPLUS
  4125. ac_save_CXXFLAGS="$CXXFLAGS"
  4126. CXXFLAGS="$CXXFLAGS -fno-exceptions"
  4127. dnl
  4128. AC_CACHE_CHECK([for struct dirent.d_type], glibcxx_cv_dirent_d_type, [dnl
  4129. GCC_TRY_COMPILE_OR_LINK(
  4130. [#include <dirent.h>],
  4131. [
  4132. struct dirent d;
  4133. if (sizeof d.d_type) return 0;
  4134. ],
  4135. [glibcxx_cv_dirent_d_type=yes],
  4136. [glibcxx_cv_dirent_d_type=no])
  4137. ])
  4138. if test $glibcxx_cv_dirent_d_type = yes; then
  4139. AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1, [Define to 1 if `d_type' is a member of `struct dirent'.])
  4140. fi
  4141. dnl
  4142. AC_CACHE_CHECK([for realpath], glibcxx_cv_realpath, [dnl
  4143. GCC_TRY_COMPILE_OR_LINK(
  4144. [
  4145. #include <limits.h>
  4146. #include <stdlib.h>
  4147. #include <unistd.h>
  4148. ],
  4149. [
  4150. #if _XOPEN_VERSION < 500
  4151. #error
  4152. #elif _XOPEN_VERSION >= 700 || defined(PATH_MAX)
  4153. char *tmp = realpath((const char*)NULL, (char*)NULL);
  4154. #else
  4155. #error
  4156. #endif
  4157. ],
  4158. [glibcxx_cv_realpath=yes],
  4159. [glibcxx_cv_realpath=no])
  4160. ])
  4161. if test $glibcxx_cv_realpath = yes; then
  4162. AC_DEFINE(_GLIBCXX_USE_REALPATH, 1, [Define if usable realpath is available in <stdlib.h>.])
  4163. fi
  4164. dnl
  4165. AC_CACHE_CHECK([for utimensat], glibcxx_cv_utimensat, [dnl
  4166. GCC_TRY_COMPILE_OR_LINK(
  4167. [
  4168. #include <fcntl.h>
  4169. #include <sys/stat.h>
  4170. ],
  4171. [
  4172. struct timespec ts[2] = { { 0, UTIME_OMIT }, { 1, 1 } };
  4173. int i = utimensat(AT_FDCWD, "path", ts, 0);
  4174. ],
  4175. [glibcxx_cv_utimensat=yes],
  4176. [glibcxx_cv_utimensat=no])
  4177. ])
  4178. if test $glibcxx_cv_utimensat = yes; then
  4179. AC_DEFINE(_GLIBCXX_USE_UTIMENSAT, 1, [Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and AT_FDCWD in <fcntl.h>.])
  4180. fi
  4181. dnl
  4182. AC_CACHE_CHECK([for utime], glibcxx_cv_utime, [dnl
  4183. GCC_TRY_COMPILE_OR_LINK(
  4184. [
  4185. #include <utime.h>
  4186. ],
  4187. [
  4188. struct utimbuf t = { 1, 1 };
  4189. int i = utime("path", &t);
  4190. ],
  4191. [glibcxx_cv_utime=yes],
  4192. [glibcxx_cv_utime=no])
  4193. ])
  4194. if test $glibcxx_cv_utime = yes; then
  4195. AC_DEFINE(_GLIBCXX_USE_UTIME, 1, [Define if utime is available in <utime.h>.])
  4196. fi
  4197. dnl
  4198. AC_CACHE_CHECK([for lstat], glibcxx_cv_lstat, [dnl
  4199. GCC_TRY_COMPILE_OR_LINK(
  4200. [ #include <sys/stat.h> ],
  4201. [
  4202. struct stat st;
  4203. int i = lstat("path", &st);
  4204. ],
  4205. [glibcxx_cv_lstat=yes],
  4206. [glibcxx_cv_lstat=no])
  4207. ])
  4208. if test $glibcxx_cv_lstat = yes; then
  4209. AC_DEFINE(_GLIBCXX_USE_LSTAT, 1, [Define if lstat is available in <sys/stat.h>.])
  4210. fi
  4211. dnl
  4212. AC_CACHE_CHECK([for struct stat.st_mtim.tv_nsec],
  4213. glibcxx_cv_st_mtim, [dnl
  4214. GCC_TRY_COMPILE_OR_LINK(
  4215. [ #include <sys/stat.h> ],
  4216. [
  4217. struct stat st;
  4218. return st.st_mtim.tv_nsec;
  4219. ],
  4220. [glibcxx_cv_st_mtim=yes],
  4221. [glibcxx_cv_st_mtim=no])
  4222. ])
  4223. if test $glibcxx_cv_st_mtim = yes; then
  4224. AC_DEFINE(_GLIBCXX_USE_ST_MTIM, 1, [Define if struct stat has timespec members.])
  4225. fi
  4226. dnl
  4227. AC_CACHE_CHECK([for fchmod],
  4228. glibcxx_cv_fchmod, [dnl
  4229. GCC_TRY_COMPILE_OR_LINK(
  4230. [#include <sys/stat.h>],
  4231. [fchmod(1, S_IWUSR);],
  4232. [glibcxx_cv_fchmod=yes],
  4233. [glibcxx_cv_fchmod=no])
  4234. ])
  4235. if test $glibcxx_cv_fchmod = yes; then
  4236. AC_DEFINE(_GLIBCXX_USE_FCHMOD, 1, [Define if fchmod is available in <sys/stat.h>.])
  4237. fi
  4238. dnl
  4239. AC_CACHE_CHECK([for fchmodat],
  4240. glibcxx_cv_fchmodat, [dnl
  4241. GCC_TRY_COMPILE_OR_LINK(
  4242. [
  4243. #include <fcntl.h>
  4244. #include <sys/stat.h>
  4245. ],
  4246. [fchmodat(AT_FDCWD, "", 0, AT_SYMLINK_NOFOLLOW);],
  4247. [glibcxx_cv_fchmodat=yes],
  4248. [glibcxx_cv_fchmodat=no])
  4249. ])
  4250. if test $glibcxx_cv_fchmodat = yes; then
  4251. AC_DEFINE(_GLIBCXX_USE_FCHMODAT, 1, [Define if fchmodat is available in <sys/stat.h>.])
  4252. fi
  4253. dnl
  4254. AC_CACHE_CHECK([for sendfile that can copy files],
  4255. glibcxx_cv_sendfile, [dnl
  4256. case "${target_os}" in
  4257. gnu* | linux* | solaris* | uclinux*)
  4258. GCC_TRY_COMPILE_OR_LINK(
  4259. [#include <sys/sendfile.h>],
  4260. [sendfile(1, 2, (off_t*)0, sizeof 1);],
  4261. [glibcxx_cv_sendfile=yes],
  4262. [glibcxx_cv_sendfile=no])
  4263. ;;
  4264. *)
  4265. glibcxx_cv_sendfile=no
  4266. ;;
  4267. esac
  4268. ])
  4269. if test $glibcxx_cv_sendfile = yes; then
  4270. AC_DEFINE(_GLIBCXX_USE_SENDFILE, 1, [Define if sendfile is available in <sys/sendfile.h>.])
  4271. fi
  4272. dnl
  4273. AC_CACHE_CHECK([for link],
  4274. glibcxx_cv_link, [dnl
  4275. GCC_TRY_COMPILE_OR_LINK(
  4276. [#include <unistd.h>],
  4277. [link("", "");],
  4278. [glibcxx_cv_link=yes],
  4279. [glibcxx_cv_link=no])
  4280. ])
  4281. if test $glibcxx_cv_link = yes; then
  4282. AC_DEFINE(HAVE_LINK, 1, [Define if link is available in <unistd.h>.])
  4283. fi
  4284. dnl
  4285. AC_CACHE_CHECK([for readlink],
  4286. glibcxx_cv_readlink, [dnl
  4287. GCC_TRY_COMPILE_OR_LINK(
  4288. [#include <unistd.h>],
  4289. [char buf[32]; readlink("", buf, sizeof(buf));],
  4290. [glibcxx_cv_readlink=yes],
  4291. [glibcxx_cv_readlink=no])
  4292. ])
  4293. if test $glibcxx_cv_readlink = yes; then
  4294. AC_DEFINE(HAVE_READLINK, 1, [Define if readlink is available in <unistd.h>.])
  4295. fi
  4296. dnl
  4297. AC_CACHE_CHECK([for symlink],
  4298. glibcxx_cv_symlink, [dnl
  4299. GCC_TRY_COMPILE_OR_LINK(
  4300. [#include <unistd.h>],
  4301. [symlink("", "");],
  4302. [glibcxx_cv_symlink=yes],
  4303. [glibcxx_cv_symlink=no])
  4304. ])
  4305. if test $glibcxx_cv_symlink = yes; then
  4306. AC_DEFINE(HAVE_SYMLINK, 1, [Define if symlink is available in <unistd.h>.])
  4307. fi
  4308. dnl
  4309. AC_CACHE_CHECK([for truncate],
  4310. glibcxx_cv_truncate, [dnl
  4311. GCC_TRY_COMPILE_OR_LINK(
  4312. [#include <unistd.h>],
  4313. [truncate("", 99);],
  4314. [glibcxx_cv_truncate=yes],
  4315. [glibcxx_cv_truncate=no])
  4316. ])
  4317. if test $glibcxx_cv_truncate = yes; then
  4318. AC_DEFINE(HAVE_TRUNCATE, 1, [Define if truncate is available in <unistd.h>.])
  4319. fi
  4320. dnl
  4321. AC_CACHE_CHECK([for fdopendir],
  4322. glibcxx_cv_fdopendir, [dnl
  4323. GCC_TRY_COMPILE_OR_LINK(
  4324. [#include <dirent.h>],
  4325. [::DIR* dir = ::fdopendir(1);],
  4326. [glibcxx_cv_fdopendir=yes],
  4327. [glibcxx_cv_fdopendir=no])
  4328. ])
  4329. if test $glibcxx_cv_fdopendir = yes; then
  4330. AC_DEFINE(HAVE_FDOPENDIR, 1, [Define if fdopendir is available in <dirent.h>.])
  4331. fi
  4332. dnl
  4333. AC_CACHE_CHECK([for dirfd],
  4334. glibcxx_cv_dirfd, [dnl
  4335. GCC_TRY_COMPILE_OR_LINK(
  4336. [#include <dirent.h>],
  4337. [int fd = ::dirfd((::DIR*)0);],
  4338. [glibcxx_cv_dirfd=yes],
  4339. [glibcxx_cv_dirfd=no])
  4340. ])
  4341. if test $glibcxx_cv_dirfd = yes; then
  4342. AC_DEFINE(HAVE_DIRFD, 1, [Define if dirfd is available in <dirent.h>.])
  4343. fi
  4344. dnl
  4345. AC_CACHE_CHECK([for unlinkat],
  4346. glibcxx_cv_unlinkat, [dnl
  4347. GCC_TRY_COMPILE_OR_LINK(
  4348. [#include <fcntl.h>
  4349. #include <unistd.h>],
  4350. [::unlinkat(AT_FDCWD, "", AT_REMOVEDIR);],
  4351. [glibcxx_cv_unlinkat=yes],
  4352. [glibcxx_cv_unlinkat=no])
  4353. ])
  4354. if test $glibcxx_cv_unlinkat = yes; then
  4355. AC_DEFINE(HAVE_UNLINKAT, 1, [Define if unlinkat is available in <fcntl.h>.])
  4356. fi
  4357. dnl
  4358. CXXFLAGS="$ac_save_CXXFLAGS"
  4359. AC_LANG_RESTORE
  4360. ])
  4361. dnl
  4362. dnl Check how size_t is mangled. Copied from libitm.
  4363. dnl
  4364. AC_DEFUN([GLIBCXX_CHECK_SIZE_T_MANGLING], [
  4365. AC_CACHE_CHECK([how size_t is mangled],
  4366. glibcxx_cv_size_t_mangling, [
  4367. AC_TRY_COMPILE([], [extern __SIZE_TYPE__ x; extern unsigned long x;],
  4368. [glibcxx_cv_size_t_mangling=m], [
  4369. AC_TRY_COMPILE([], [extern __SIZE_TYPE__ x; extern unsigned int x;],
  4370. [glibcxx_cv_size_t_mangling=j], [
  4371. AC_TRY_COMPILE([],
  4372. [extern __SIZE_TYPE__ x; extern unsigned long long x;],
  4373. [glibcxx_cv_size_t_mangling=y], [
  4374. AC_TRY_COMPILE([],
  4375. [extern __SIZE_TYPE__ x; extern unsigned short x;],
  4376. [glibcxx_cv_size_t_mangling=t], [
  4377. AC_TRY_COMPILE([],
  4378. [extern __SIZE_TYPE__ x; extern __int20 unsigned x;],
  4379. [glibcxx_cv_size_t_mangling=u6uint20],
  4380. [glibcxx_cv_size_t_mangling=x])
  4381. ])
  4382. ])
  4383. ])
  4384. ])
  4385. ])
  4386. if test $glibcxx_cv_size_t_mangling = x; then
  4387. AC_MSG_ERROR([Unknown underlying type for size_t])
  4388. fi
  4389. AC_DEFINE_UNQUOTED(_GLIBCXX_MANGLE_SIZE_T, [$glibcxx_cv_size_t_mangling],
  4390. [Define to the letter to which size_t is mangled.])
  4391. ])
  4392. dnl
  4393. dnl Determine whether std::exception_ptr symbols should be exported with
  4394. dnl the symbol versions from GCC 4.6.0 or GCC 7.1.0, depending on which
  4395. dnl release first added support for std::exception_ptr. Originally it was
  4396. dnl only supported for targets with always-lock-free atomics for int, but
  4397. dnl since GCC 7.1 it is supported for all targets.
  4398. dnl
  4399. AC_DEFUN([GLIBCXX_CHECK_EXCEPTION_PTR_SYMVER], [
  4400. if test $enable_symvers != no; then
  4401. AC_MSG_CHECKING([for first version to support std::exception_ptr])
  4402. case ${target} in
  4403. aarch64-*-* | alpha-*-* | hppa*-*-* | i?86-*-* | x86_64-*-* | \
  4404. m68k-*-* | powerpc*-*-* | s390*-*-* | *-*-solaris* )
  4405. ac_exception_ptr_since_gcc46=yes
  4406. ;;
  4407. *)
  4408. # If the value of this macro changes then we will need to hardcode
  4409. # yes/no here for additional targets based on the original value.
  4410. AC_TRY_COMPILE([], [
  4411. #if __GCC_ATOMIC_INT_LOCK_FREE <= 1
  4412. # error atomic int not always lock free
  4413. #endif
  4414. ],
  4415. [ac_exception_ptr_since_gcc46=yes],
  4416. [ac_exception_ptr_since_gcc46=no])
  4417. ;;
  4418. esac
  4419. if test x"$ac_exception_ptr_since_gcc46" = x"yes" ; then
  4420. AC_DEFINE(HAVE_EXCEPTION_PTR_SINCE_GCC46, 1,
  4421. [Define to 1 if GCC 4.6 supported std::exception_ptr for the target])
  4422. AC_MSG_RESULT([4.6.0])
  4423. else
  4424. AC_MSG_RESULT([7.1.0])
  4425. fi
  4426. fi
  4427. ])
  4428. dnl
  4429. dnl Check whether getentropy is present in <unistd.h>.
  4430. dnl
  4431. AC_DEFUN([GLIBCXX_CHECK_GETENTROPY], [
  4432. AC_LANG_SAVE
  4433. AC_LANG_CPLUSPLUS
  4434. AC_CACHE_CHECK([for getentropy], glibcxx_cv_getentropy, [
  4435. GCC_TRY_COMPILE_OR_LINK(
  4436. [#include <unistd.h>],
  4437. [unsigned i;
  4438. ::getentropy(&i, sizeof(i));],
  4439. [glibcxx_cv_getentropy=yes], [glibcxx_cv_getentropy=no])
  4440. ])
  4441. if test $glibcxx_cv_getentropy = yes; then
  4442. AC_DEFINE(HAVE_GETENTROPY, 1, [Define if getentropy is available in <unistd.h>.])
  4443. fi
  4444. AC_LANG_RESTORE
  4445. ])
  4446. dnl
  4447. dnl Check whether arc4random is present in <stdlib.h>.
  4448. dnl
  4449. AC_DEFUN([GLIBCXX_CHECK_ARC4RANDOM], [
  4450. AC_LANG_SAVE
  4451. AC_LANG_CPLUSPLUS
  4452. AC_CACHE_CHECK([for arc4random], glibcxx_cv_arc4random, [
  4453. GCC_TRY_COMPILE_OR_LINK(
  4454. [#include <stdlib.h>],
  4455. [unsigned i = ::arc4random();],
  4456. [glibcxx_cv_arc4random=yes], [glibcxx_cv_arc4random=no])
  4457. ])
  4458. if test $glibcxx_cv_arc4random = yes; then
  4459. AC_DEFINE(HAVE_ARC4RANDOM, 1, [Define if arc4random is available in <stdlib.h>.])
  4460. fi
  4461. AC_LANG_RESTORE
  4462. ])
  4463. dnl
  4464. dnl Check to see whether to build libstdc++_libbacktrace.a
  4465. dnl
  4466. dnl --enable-libstdcxx-backtrace
  4467. dnl
  4468. AC_DEFUN([GLIBCXX_ENABLE_BACKTRACE], [
  4469. GLIBCXX_ENABLE(libstdcxx-backtrace,auto,,
  4470. [turns on libbacktrace support],
  4471. [permit yes|no|auto])
  4472. # Most of this is adapted from libsanitizer/configure.ac
  4473. BACKTRACE_CPPFLAGS=
  4474. # libbacktrace only needs atomics for int, which we've already tested
  4475. if test "$glibcxx_cv_atomic_int" = "yes"; then
  4476. BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_ATOMIC_FUNCTIONS=1"
  4477. fi
  4478. # Test for __sync support.
  4479. AC_CACHE_CHECK([__sync extensions],
  4480. [glibcxx_cv_sys_sync],
  4481. [GCC_TRY_COMPILE_OR_LINK(
  4482. [int i;],
  4483. [__sync_bool_compare_and_swap (&i, i, i);
  4484. __sync_lock_test_and_set (&i, 1);
  4485. __sync_lock_release (&i);],
  4486. [glibcxx_cv_sys_sync=yes],
  4487. [glibcxx_cv_sys_sync=no])
  4488. ])
  4489. if test "$glibcxx_cv_sys_sync" = "yes"; then
  4490. BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_SYNC_FUNCTIONS=1"
  4491. fi
  4492. # Check for dl_iterate_phdr.
  4493. AC_CHECK_HEADERS(link.h)
  4494. if test "$ac_cv_header_link_h" = "no"; then
  4495. have_dl_iterate_phdr=no
  4496. else
  4497. # When built as a GCC target library, we can't do a link test.
  4498. AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
  4499. [have_dl_iterate_phdr=no])
  4500. fi
  4501. if test "$have_dl_iterate_phdr" = "yes"; then
  4502. BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_DL_ITERATE_PHDR=1"
  4503. fi
  4504. # Check for the fcntl function.
  4505. if test -n "${with_target_subdir}"; then
  4506. case "${host}" in
  4507. *-*-mingw*) have_fcntl=no ;;
  4508. *) have_fcntl=yes ;;
  4509. esac
  4510. else
  4511. AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
  4512. fi
  4513. if test "$have_fcntl" = "yes"; then
  4514. BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_FCNTL=1"
  4515. fi
  4516. AC_CHECK_DECLS(strnlen)
  4517. # Check for getexecname function.
  4518. if test -n "${with_target_subdir}"; then
  4519. case "${host}" in
  4520. *-*-solaris2*) have_getexecname=yes ;;
  4521. *) have_getexecname=no ;;
  4522. esac
  4523. else
  4524. AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
  4525. fi
  4526. if test "$have_getexecname" = "yes"; then
  4527. BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_GETEXECNAME=1"
  4528. fi
  4529. # The library needs to be able to read the executable itself. Compile
  4530. # a file to determine the executable format. The awk script
  4531. # filetype.awk prints out the file type.
  4532. AC_CACHE_CHECK([output filetype],
  4533. [glibcxx_cv_sys_filetype],
  4534. [filetype=
  4535. AC_COMPILE_IFELSE(
  4536. [AC_LANG_PROGRAM([int i;], [int j;])],
  4537. [filetype=`${AWK} -f $srcdir/../libbacktrace/filetype.awk conftest.$ac_objext`],
  4538. [AC_MSG_FAILURE([compiler failed])])
  4539. glibcxx_cv_sys_filetype=$filetype])
  4540. # Match the file type to decide what files to compile.
  4541. FORMAT_FILE=
  4542. case "$glibcxx_cv_sys_filetype" in
  4543. elf*) FORMAT_FILE="elf.lo" ;;
  4544. *) AC_MSG_WARN([could not determine output file type])
  4545. FORMAT_FILE="unknown.lo"
  4546. enable_libstdcxx_backtrace=no
  4547. ;;
  4548. esac
  4549. AC_SUBST(FORMAT_FILE)
  4550. # ELF defines.
  4551. elfsize=
  4552. case "$glibcxx_cv_sys_filetype" in
  4553. elf32) elfsize=32 ;;
  4554. elf64) elfsize=64 ;;
  4555. esac
  4556. BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DBACKTRACE_ELF_SIZE=$elfsize"
  4557. ALLOC_FILE=alloc.lo
  4558. AC_SUBST(ALLOC_FILE)
  4559. VIEW_FILE=read.lo
  4560. AC_SUBST(VIEW_FILE)
  4561. AC_MSG_CHECKING([whether to build libbacktrace support])
  4562. if test "$enable_libstdcxx_backtrace" == "auto"; then
  4563. enable_libstdcxx_backtrace=no
  4564. fi
  4565. if test "$enable_libstdcxx_backtrace" == "yes"; then
  4566. BACKTRACE_SUPPORTED=1
  4567. BACKTRACE_USES_MALLOC=1
  4568. if test "$ac_has_gthreads" = "yes"; then
  4569. BACKTRACE_SUPPORTS_THREADS=1
  4570. else
  4571. BACKTRACE_SUPPORTS_THREADS=0
  4572. fi
  4573. AC_SUBST(BACKTRACE_CPPFLAGS)
  4574. AC_SUBST(BACKTRACE_SUPPORTED)
  4575. AC_SUBST(BACKTRACE_USES_MALLOC)
  4576. AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
  4577. AC_DEFINE(HAVE_STACKTRACE, 1, [Define if the <stacktrace> header is supported.])
  4578. else
  4579. BACKTRACE_SUPPORTED=0
  4580. BACKTRACE_USES_MALLOC=0
  4581. BACKTRACE_SUPPORTS_THREADS=0
  4582. fi
  4583. AC_MSG_RESULT($enable_libstdcxx_backtrace)
  4584. GLIBCXX_CONDITIONAL(ENABLE_BACKTRACE, [test "$enable_libstdcxx_backtrace" != no])
  4585. ])
  4586. # Macros from the top-level gcc directory.
  4587. m4_include([../config/gc++filt.m4])
  4588. m4_include([../config/tls.m4])
  4589. m4_include([../config/gthr.m4])
  4590. m4_include([../config/cet.m4])