From b7ebc951da8800f711142f69d9d958bde67a112d Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 28 Apr 2019 09:54:45 +0100 Subject: gentoo resync : 28.04.2019 --- sys-libs/glibc/Manifest | 23 +- .../glibc/files/2.10/glibc-2.10-gentoo-chk_fail.c | 315 ----- .../glibc-2.10-hardened-configure-picdefault.patch | 30 - .../glibc-2.10-hardened-inittls-nosysenter.patch | 274 ---- .../glibc/files/2.17/glibc-2.17-hardened-pie.patch | 42 - .../glibc/files/2.18/glibc-2.18-gentoo-chk_fail.c | 314 ----- .../files/2.18/glibc-2.18-gentoo-stack_chk_fail.c | 322 ----- .../glibc-2.18-hardened-inittls-nosysenter.patch | 277 ---- .../glibc/files/2.20/glibc-2.20-gentoo-chk_fail.c | 299 ---- .../files/2.20/glibc-2.20-gentoo-stack_chk_fail.c | 2 - .../glibc-2.20-hardened-inittls-nosysenter.patch | 306 ----- sys-libs/glibc/glibc-2.21-r2.ebuild | 149 -- sys-libs/glibc/glibc-2.28-r5.ebuild | 1418 ------------------- sys-libs/glibc/glibc-2.28-r6.ebuild | 1418 +++++++++++++++++++ sys-libs/glibc/glibc-2.29-r1.ebuild | 1418 ------------------- sys-libs/glibc/glibc-2.29-r2.ebuild | 1448 ++++++++++++++++++++ sys-libs/glibc/glibc-9999.ebuild | 40 +- 17 files changed, 2909 insertions(+), 5186 deletions(-) delete mode 100644 sys-libs/glibc/files/2.10/glibc-2.10-gentoo-chk_fail.c delete mode 100644 sys-libs/glibc/files/2.10/glibc-2.10-hardened-configure-picdefault.patch delete mode 100644 sys-libs/glibc/files/2.10/glibc-2.10-hardened-inittls-nosysenter.patch delete mode 100644 sys-libs/glibc/files/2.17/glibc-2.17-hardened-pie.patch delete mode 100644 sys-libs/glibc/files/2.18/glibc-2.18-gentoo-chk_fail.c delete mode 100644 sys-libs/glibc/files/2.18/glibc-2.18-gentoo-stack_chk_fail.c delete mode 100644 sys-libs/glibc/files/2.18/glibc-2.18-hardened-inittls-nosysenter.patch delete mode 100644 sys-libs/glibc/files/2.20/glibc-2.20-gentoo-chk_fail.c delete mode 100644 sys-libs/glibc/files/2.20/glibc-2.20-gentoo-stack_chk_fail.c delete mode 100644 sys-libs/glibc/files/2.20/glibc-2.20-hardened-inittls-nosysenter.patch delete mode 100644 sys-libs/glibc/glibc-2.21-r2.ebuild delete mode 100644 sys-libs/glibc/glibc-2.28-r5.ebuild create mode 100644 sys-libs/glibc/glibc-2.28-r6.ebuild delete mode 100644 sys-libs/glibc/glibc-2.29-r1.ebuild create mode 100644 sys-libs/glibc/glibc-2.29-r2.ebuild (limited to 'sys-libs/glibc') diff --git a/sys-libs/glibc/Manifest b/sys-libs/glibc/Manifest index 728343fa443f..d042a6095bf1 100644 --- a/sys-libs/glibc/Manifest +++ b/sys-libs/glibc/Manifest @@ -1,15 +1,5 @@ -AUX 2.10/glibc-2.10-gentoo-chk_fail.c 9407 BLAKE2B 66451cdde9aa221d437762d81066a2400574f26b7cf8613826c72f953a757ff09765727bec95f2fa4b3873724ca061dab6110e801f39a929f3b5b218a74b0589 SHA512 d1c51c573353b3b8ae6ab1bcc8c10eda5cad8b98fc7ab4848e4fbd8a8736174f3c3fd1b72dd80c72b1e54be78f1cae4dc1ab8130df25aa6d1495e5cbbaf3b9f6 -AUX 2.10/glibc-2.10-hardened-configure-picdefault.patch 865 BLAKE2B 8526ed453dc40716ebbe7e9acf9406db17b030d75505360b5e5d1e4d51d02c8558fc3e9539bc57077a7cdb5c82e91313fb168773e2d573f810938c4e851dc374 SHA512 e0a09f77b209a72ab577fe1e62126609fdddedf3fba0eec749c4b506cdf793779b48390f055a3594892120f694291f8340c0b6f51862e94c03fd516897138be7 -AUX 2.10/glibc-2.10-hardened-inittls-nosysenter.patch 8823 BLAKE2B c52120d9a60860d7c5abe46ebeee1f3b09a8ff9da8dda372c789f319ea711e170d69c0d5d04daa187d7b4936c49eef5841add4cd7c68be6a351c0ef98856ba15 SHA512 0605b7964af87d1d6bdccea5c4d1bfe6267d4401b8bbf0c8bb689663e6bb3ef92eebad8be6c23ffdf6632a4d5e6098d8a403c3e84ffb21b5e87b5b1d1ec3512d -AUX 2.17/glibc-2.17-hardened-pie.patch 1784 BLAKE2B 2f550fb8b5beb6063b77969da7ed179e23445fb76c67d8f463348a8bdb29e9987763ec2226ccb4bb2ef91e2968afb36f091606ff95bf533266b05fa7321556dc SHA512 9ecfe2b6c8c982a42786181d6507d5fa588a6868109065451f58a779848837bd5e69c32a24e43a186c2ff63a9784015c51487e342c87982ac074139e36c169fc -AUX 2.18/glibc-2.18-gentoo-chk_fail.c 9384 BLAKE2B 81094d8c8d1274f0f106277805b550b6e85169e951d54ca43777603bca33a454414f69cd2fba39131266e5cc9b6b48e6b5a80e87ae5604228b55c24aead64377 SHA512 f7106e36fa49b0000192c281edfcd49338c825b8b8663ac9d7304e8fe8b2f44b39c6c82a741b8e8abce4cbe2fd72f64e3cfe7a18ff504a4b2b2d63e5c75d62b7 -AUX 2.18/glibc-2.18-gentoo-stack_chk_fail.c 9599 BLAKE2B 2ec9f78f2c5617c1ef38ee579ee329fa6b561eaea2e3966e04de132b31ca8da1f12ab27d36dc3bd9cfb25f05bd358bf9dca17478088716fc025967e10395df90 SHA512 97acbdb8aa87dd7e197a1577bd053374b1c8c30d6c82f4a71ef04409bf87b36a60322237cb79896ebdb49960fcaae4c4f2333497f5c255f67717b01d6d62c2d5 -AUX 2.18/glibc-2.18-hardened-inittls-nosysenter.patch 8981 BLAKE2B c830477eb0aeb8e5ddbc81eb5bda6710dd91f67433b87ed0df03ac31b8183008db47abdaaa944d3947e800872c7af39226881ebf3734d455d14f942199469e49 SHA512 98feb8f12dc5d2bb030ec7c6c77f3f9389ebc208fafc96496f316e577457dd991294d59735b013b17e1d10d5c7b63471d5b857d2334be78239a8ceb1ad62b1fc AUX 2.19/glibc-2.19-hardened-configure-picdefault.patch 865 BLAKE2B 81431d341d389f5401bdcbc162a52d0419d97afedaee71ab417780bbc273579fa9ccd8966a7afd172325460e1010f50843ce37574390b17a6156e7751093e0bd SHA512 d8e6fea72e240f1fde8a487958463140a84e8bd6bb5b176f8ce84a34df3137943db9016300884f3efdd4da130e342448e57ed0c0dc6eb2956d647286ce1d00ce AUX 2.19/glibc-2.19-ia64-gcc-4.8-reloc-hack.patch 1360 BLAKE2B 19d218e91b1d3d38c526838600d0393de47a0e59ca3e05651bd28becb401021ddd2f6ef77b8740ca4e400f094ab5fd196f092cf25b20729eb4d42e2a200b9e03 SHA512 79876b12871b3e7693340bfdf99276ac0dfd6ff30bc977a9526af9e681fcbab2f25d3ac9e2b33f027c968b38a4b670237de54ffd08edc418423ecd82dddd1d67 -AUX 2.20/glibc-2.20-gentoo-chk_fail.c 8978 BLAKE2B 5a41728d29fb7b7d5cbde47ad53db71a6563ddcf07c9da63642cd8616284f29c5d47f377292428bb3a9993b89ea32e6d7420b2d9ad8b3342ab4bb3c985a3c0e3 SHA512 5cb529ac9d18a315f25fd48a3a80a529924bee0588074c97e6df7dbe8568a67f786363c41da6300ea55818369e3609ed4315b2e2104f8a8b4f1266ba43076eda -AUX 2.20/glibc-2.20-gentoo-stack_chk_fail.c 55 BLAKE2B a7b99997627b8fa110802d9427494487c5d3084312d892532c5aa263cadfbb35c58bc358161bbbdf74cc2c6629b616d3a78c9cff1d18e63aedd1445dbe43d773 SHA512 4dfec1bd17007b826110dcb73d09331a58b7a892c87de55b94480b14c28686442c567725b610082813411cf9911e180835a400a54ea704fe80f81cfba966a989 -AUX 2.20/glibc-2.20-hardened-inittls-nosysenter.patch 9951 BLAKE2B 107afc99f6862109d31828cb85f2ee2958b107055e04feb5aadca869cb5838ef7f6246f010388315c5bc071b34339f5241fd5d7b7935e8d096277fc48eded253 SHA512 a8302ee2963bd791be859233223b17cd154afbf04c13c046956bb1140d748272d7bcb3a6167ce8b61573ebcffe906dff064308374d2910656b8fad18480fe422 AUX 2.25/glibc-2.25-gentoo-chk_fail.c 9068 BLAKE2B 6fabcbb981d92101ff3b97e8eed4da3c0ee4fc3d09ca344c2d0b7ee5e04fec66b5db314263541beeb1290bafa837795fef1a6300986de938d2958ba89a9c1f2f SHA512 4503002b0e2cee0b6efc4599152d24fcff330157d4e35992a77d0d83a2decc4cf2da2b8645a44d90d428a1d82300a4fd8d13c5937b7c89f368c12b3c9139be6f AUX nscd.service 337 BLAKE2B 6b163465dd8db024652921892dc913da8dfc0984eec7ffce621229e48fa99dcedc3b5944844529190122c81f4884b6a6fe7836d37d2d812f34059c530856dec1 SHA512 2001100f3b054843c69b6fd2d38852c7c824282aa8998c25a3c0352db993705429d25c70d8ce6cb3579f836b7089644c520acac423ebd69cb1b36e94a77c5bea AUX nscd.tmpfilesd 111 BLAKE2B 4abb7220564e248fc7eeeced41077f186f42594facbfac9a4c0ff36209baac529c219ad6ead8d8aa53ab2b092002f1006a4479459b9e9a7c5a0294cb7d822100 SHA512 53b80b331e1a85d8ee16eb2ce547a7249e944926c3d1cdd4a47a5301a5c842ffc7ec1e3dc0a731542a8facf8261c1c57121802d01741aa89898a3476c09da340 @@ -17,8 +7,6 @@ DIST gcc-4.7.3-r1-multilib-bootstrap.tar.bz2 8064097 BLAKE2B 3cc5c82cd57d0fbd26d DIST gcc-multilib-bootstrap-20180511.tar.xz 2392908 BLAKE2B f3cf614399368acd8908f60d894c6344a2fa09383b30c1633a0682bc668367c8a2f8c6fec2d41b6e2178d709a2bd8db57e8b2ab56ba263c7d56f819c15acd061 SHA512 98c766e913693ab42ff790557acde2a36a8001e2648046a685b21964200df8d4d52d8452d499c0068c6648284d086ce062c2d36e2c6c2fd8aacd232d193f2853 DIST glibc-2.19-patches-9.tar.bz2 24584 BLAKE2B a96e930a5bd20fa75d9f259cc2117fa5ce98072274a24a5823bf877e3739fa4c001a94d7865e065ee0527f3974430d27da8038e042340a451ad2052c62724f26 SHA512 a95b3063ade974a3556480b798b317d33c7423a8cb9e69f67249ffb8b3d3c671d70d2d5f782c1efadc0bec4cc49a96d4fe89911f3dfcd85b459f69f3b4f38f0e DIST glibc-2.19.tar.xz 12083312 BLAKE2B 9dc03346e0f0df4bf009a92d894b0a9f964ff92b7f4c9663cedf1cb6cf90435f28a15539d33791ecf43ee578fa4e26f916af0367651312ef8f9c1c38ce0dafa2 SHA512 9e021fcb3afbb9ace2a0e37fded231a62de861bd766e29d47163a03182e37add718b7acc3963d1c525f9556773e842297725715acde48dcfbaab6e756af1a23d -DIST glibc-2.21-patches-7.tar.bz2 46894 BLAKE2B 5a15a3a5ca515351d5d41baaa59ae6b6d1c353f1500c3b8dcd6da895119c89afee9ef6afaa1e7d617f2cf7b7504635e5733429f65847acaa63c0a7bf8233ee9c SHA512 e4cca3d753c0b9d213c0ed85e3d08cbbf6517862b3a48af987e010abaf5a022b47330040ced183d30b5b934de7587e97b4342e51a6df3d5cfa768bdd8b43b756 -DIST glibc-2.21.tar.xz 12322092 BLAKE2B 1ce2be09787138262b59b56235e20777459e99861c65694b96f63d7faf24da8655882dd23b39c28a8a2d338c50710f76e1e4dc39a3f4ce9736ef2cbf7f99ed5b SHA512 8cded6693618bec115f678fcbd0b77556f97dfa8337608f66e37224aefa55b38765ba61cb4d58beea37b5934e5ec8e30bad58613707388484906f2a0ce77997d DIST glibc-2.22-patches-13.tar.bz2 74479 BLAKE2B 1ab31614e8334508a63c842f503a395ff3ebeaa33d1890eab1d9e2985cb39064960053f2bbf99ec3bdec0ba5a80d259ca6b964fcaed9d99dcb6da84ddb8dd364 SHA512 73517fc1502b0733d67ade1d1ba6168415f5da64f37045fac0b10ef57155bf6dfbe1876e4742d2543fcea0c935c179426f6fbb94f0205968392ef903d2f83897 DIST glibc-2.22.tar.xz 12969072 BLAKE2B 36a2e08cf4c5c9396c414fcf5cf5f32d0a78a61e06a1309fbc5f560bed7a7f25a084f5f5c1097014d0911239c710ac9c06f6b6d603238b9c928dd286ebd05bbf SHA512 a8719f3a4f8aa5fa81711116fdafbea5082c6dfd85bd8c4cdce60571910263ab422b35bb8b55a84d37ccb146442133ba60a84d453ca4a439c8ccd35419bd051b DIST glibc-2.23-patches-8.tar.bz2 304199 BLAKE2B 693e40090dbe43f0e9c1faa0bce75e43d5d3924b40c141f9d00ef147fd285b03e2c3bab6a32d1bf6978ca139c3f071f685d5caf1bffb1cce7e1d1f3c346e5c50 SHA512 470814bbbd9d4ee5fa2dd7570a2e14b0229723e373e801472856fd6c2f089499eddc300f69b49af8ba0edbdca583ee3ca521fdb5c642509717cafea0ad925fd2 @@ -31,20 +19,19 @@ DIST glibc-2.26-patches-7.tar.bz2 413976 BLAKE2B 18263201cf33abf911eb7b802ed539b DIST glibc-2.26.tar.xz 14682748 BLAKE2B c1c9dbec110dd4e25b2f463a96d8afc43b8e3ebfe3c958107032beaa879710252be3bc4122bb62166408725d43785f233544df6159d29cce0fc5b2c08f45adbe SHA512 6ed368523bc55f00976f96c5177f114e3f714b27273d7bffc252812c8b98fb81970403c1f5b5f0a61da678811532fb446530745492d2b49bfefc0d5bd71ce8c0 DIST glibc-2.27-patches-3.tar.bz2 166511 BLAKE2B 1dc54bef6e82112935c7411f7a5cd07c1edb24c3edaa1e0243b846b3832a40af1ba3a7b77aef04c54a173388156b464ea442fa8310a02e6f44e2ed5b78994286 SHA512 12496e9b0c60630dbec4c2febdd6d20df1f3d7a2c243cc55b595202b27f682b9208e16cd8c387687c0cc9e18b36c3caeef8d1b1148eb3ee8081431997270db5e DIST glibc-2.27.tar.xz 15395316 BLAKE2B ea206d304c8c9aa86d69db981a14bea008602cea06a6c151c4971a8df059949ffe5632b42a67ab0ffcd7c4d7ce1ec02ac48815dac4dade1c4dd41eaee8a6ed33 SHA512 7c5581154487d38d173ce1feb944e60207139cca148bccf066eaae322c0c2d219423bdcfa15c7f9be1b5e45dfc43c641cc5d80d3c3c65837d08a83cdb4e2a147 -DIST glibc-2.28-patches-8.tar.xz 97384 BLAKE2B 036ab39103aa30be61fcbb46a7103cf83c1dd490eeff526444d4701b92e06a428133de2d005d65a296f14f28145f143a2386f8b17df721174a0a0b5303e99931 SHA512 29695212d8ca9c4b6d4787f4919b75cb0828ddecce65d65683b746ed23acb50e4e18419a13bb6ee4a234f44f63b38a2eebf1f1ce3d350435c2bf21d6076a97a6 +DIST glibc-2.28-patches-9.tar.xz 98588 BLAKE2B 4ab583be712994f949dee2512da6e12fd7f7ad73e96393f21678552b43da98f49321b53b5b009551300cdb09ca135e7f6adc636ff750c251a1d6d7f262dbc410 SHA512 e3f40ae6e9d06471c1a11bd2bce7b5161d07c3d0a81791505a72aec4817e7faf9ef09841e98c6dcf62a0a00754dff87dd194d97ac6b6354aeb2497cf60900b96 DIST glibc-2.28.tar.xz 16484344 BLAKE2B 9aa8cbd5a145c2a6fde3a60b3d0a14b12b46ed79333ad1ca3e73464adcfe700277a17a9e7fd0ca36e355a0c5b0b27decfa091da320ba802741ad75cc955bbcc8 SHA512 521f820953ff07c69ece4c2186f59fc061a7f9747932cd70ef2995c2b2deee76eeb6de700d85071cdca5949179aa8ccee75eda7feca1394121ec7b821ad0a3f3 -DIST glibc-2.29-patches-2.tar.xz 35176 BLAKE2B a98d309686068dac5ae7eceac102610f9058e620f62661d9cd7fdbdb31608844cb254e15311ff2ac85be97bdf3d953fde625e3b088e4833c0356f6f4472f52d7 SHA512 69bbd090886942595cf47e2bdf01fc7ed8c0b8f2b7a4f8a6749b74a392a12d9cc601212cce09db434841f3740ff1a81642b8019afbdbfa8903ae4ebc5a71c801 +DIST glibc-2.29-patches-3.tar.xz 35812 BLAKE2B 90b8bc57b7a63f03617795c368b92e525eccfec462d638dbc25c581e5b7a2a72ffd5191842f5ac443a868cbc950838d7e5120e866d343a14b80c55dcbfa48f30 SHA512 4c9b78d9d1a8aa629418f2d758ef800857780b8a1fd8d3582b88348a513ca26ca7f6ac9110a8c6bae16949b360ba36840d184f42293cd4324760273592d1b438 DIST glibc-2.29.tar.xz 16515488 BLAKE2B b754e6825176538a2b8ca03fce014f0d87d333dc4d038bf0cda5ee8a2f484cd3ce93ad78ec126737e093ab64b55ceedf04cd08aecb4f8041daaa329e99717afa SHA512 146bc0769fe853d9edbf93cea7f74c5b3d84d69cb7614c62588e7acdecd1ec789a9d8949f3e8b99f8f36f2ccac740a003bed94f32b07817baf780b06cfeb6ed0 DIST glibc-9999-patches-11.tar.xz 17804 BLAKE2B cb4ef9fbaf0da3e2307c468d2a6731ff2475f6ebc490f0ca43d375b59aa669bec1ad0580775306adb95e249e9641bed910310185e5dced66a491c1491b99a747 SHA512 d2fced779807c7f492c17958cf4f95273d1bdcfe062bd71546f2360f3d4742a696ec8d04d984ec560c0fcccea332446834ae2c9d28cfd9009ffd091c1084edc9 EBUILD glibc-2.19-r2.ebuild 40484 BLAKE2B 9e78b3fcbf40c7c32fd9a7ba0f4c9d31277aa0d5465342b5af1a8115d4dbb9bc34e4dd0be6fe6abca2497306ef84018b62969ff2a2d28eeb092e204a60972714 SHA512 6ee461bd816a33b5eb37e3d7c107e09ebb912ce9cb26620e7bedadf31a5a874c822148859973d4e60931a46b668ce743b7ff04fa3df99f0089251ae653021750 -EBUILD glibc-2.21-r2.ebuild 4899 BLAKE2B 4097f29160b437edb96e6f731c797cba43bfb65fe164c1ffc3af0025d52c18a286b9a75d56d3e371e33e87f99a71a2115ba2eba7cb174dd2787a9b6a6d84b674 SHA512 68cc49c310ff816b2433b4f9e389e992d64f623809d4a4c3391dcce7ee4c385365ef4278de79bf4b6b9a4ed969e10b94bebabe86e560295bd1c0a9652aec12ec EBUILD glibc-2.22-r4.ebuild 4950 BLAKE2B 8d048dafaf8eec034d2ed2f3a8f400b3f4aedab39d7fe11795376a135ed9a42843f9cc6888e721ef242f78bc4230188d53cdccaf7686186d43201101519cc60b SHA512 64387259f921dc26d91d5d4e86bbbbfd740bb4b2e1337c121f799370abc9c6298745f9686e6aa501b10c05150ac1129ef8bd37d140e9c83c41ac3c0f54ee052f EBUILD glibc-2.23-r4.ebuild 4949 BLAKE2B 99db0ec4a452f04a2aef9b347a5ddec03cc88fbb1460c4f3f14b37efe5651b5db374e93a26b32b7918eb05f702d5355c5abcfcdf1228c24c4529218ecdd4017b SHA512 4384f936e1b88edc6639e4d7f31cc4641d287afda7e16f9cbd6a9fef68f04501213d9f2a84314cfb18d9da9b404a1452eba44fb49db8cf2cd1cd6012a659eb38 EBUILD glibc-2.24-r4.ebuild 4988 BLAKE2B 8e08345c96e176984b73a073efca21f771d41af1af75106ec88a22bd55d7f69f28d9c01989026a3e58f3df4fac2a59db68d5ac8a8bbb0f411c75da8792f3402a SHA512 dd1d996eaf35197f7b7b6c111957eb98ef776d0a76a949b95f9bb17075dca43b2a354f8d15be133b9f3ff6c40a5b1f4ec28bd8d41c5cfc51da006eda8b005a05 EBUILD glibc-2.25-r11.ebuild 4975 BLAKE2B cef32f5d160644845e7cf45a9dd4c8cef1dcff8fca6b64c083c3e05d07533e445a6139939710b9284f7587bbf3977ca556caeb964e73ac21a382d942423d886a SHA512 f26645acc02f16209ec068641a800ef0a4ad2a422c9473e14a273fdece9b53074b837907d635a8585cf9dbb1acea14178166a4a3410aa4c70a745b89a764b6f1 EBUILD glibc-2.26-r7.ebuild 25496 BLAKE2B 3edbb2f56d81869f86bd357772c27eb9516a1a0fbbda024412c8588df0b7938c77afc46430ea8b01bfe012eb5097f58b989411d4953d09d9202c33eeea562708 SHA512 e28a2cf8f692e6526fcbee2d9317dbb4cb8a4c249e4b60ed5b3522dc8c4627248b4a4bad0c32192adf0f650f3f002b8e25ebc7038fe0daf959f0dcde0bfe1bc4 EBUILD glibc-2.27-r6.ebuild 41551 BLAKE2B 9b55701da5b61f4b095108f0042181961fc67a9b8a40d7ed70ca5effd8114a9d1769f2e9ed178fcf49069cb63c0ad9bdc53cf6f4526f98c3a7d41609d9e7574c SHA512 1d06a20e0a2dc7deee567a0e2545cea87cfbdf5f0d1037b85e2a6afa829b5106880d3b44f44adb7e790820eaa873aac442208f77f1e5c48411af8c1c94a16ce9 -EBUILD glibc-2.28-r5.ebuild 41328 BLAKE2B ea4e9b1025358a9e38c965825493664886577178223d26dd1abdacd079b3d67ee40419ff931a1c365b32f0710ca2cf62d47c4f9ef8d903a15c77316d6689db01 SHA512 2826e064bb4c2e399bc72fd65eddbe5b54ce7a079dac47b8991d8c86121dfdb74b776fe84e56a236e30dde98eb54cb4e5b85538da6be5c1698c07a66bbe4ebdd -EBUILD glibc-2.29-r1.ebuild 41332 BLAKE2B 6c4881a7d4595fa09fd63ee777e718f003e936c17fe34c8b496bf83094573db1d7afdfb16c2d45347e1040d362aeb736fd17d62e8a4990b87d61dd70b8b23e68 SHA512 a2ce0ca3c343c9c52c382516e8caf166b8e1704b888d2cd30c9281eb377362c7b1f1ec2002b9b849d1142639308eac8a3d0665f7e6fa8f63107058c8f5f2d9e0 -EBUILD glibc-9999.ebuild 41344 BLAKE2B 3a6cf234179c02ae4c68f8ca83e5123e1e464e1886c53ec2d3ea0e47447cc235926f3ceb4f950d20a91d54319a3f8551c7866d27e78df2d761a1fe12a6e18b3c SHA512 dd18c4d46a77ac92aa2537759287a90f7349e7a58ade218c57566192d46bfa5e4f0d5630216b46371a40792554c80fa6c3c70bdcd4dab0670435c1d7d935fc4a +EBUILD glibc-2.28-r6.ebuild 41324 BLAKE2B 835545f2370ee728677c28deb2f9a8e482b7dd714ce467e256aec1b09f1736975279eb7810fdfa495bb3e9281acd4212285c0ef25526cbc0080304021570a17c SHA512 3e978b5fe8a380a7f4c0e2df0cf14166b95d851fc8b9bb3bd218e5c63542b92273dc9e829146975dd2243610acbe716d09618d67d8893f0f65cf3c2eb92a3409 +EBUILD glibc-2.29-r2.ebuild 42180 BLAKE2B af13909bc9e2861882bbb250176dcc069f41ba21c69d0db4df1a24637fec4049ba0f1ca3c3c1f434b6b86b85521cf884147f7b72c574013f7f6c4e5dae4bd775 SHA512 6cf1b0bcd3af1ab76c6fb54abdecb1ff137b45e5e99af33b9781b440d167a9626f1fc3d649e6af0ba7b2cc77112005a5366e0491caf8bdb793b48c558107e980 +EBUILD glibc-9999.ebuild 42354 BLAKE2B 310466b39e6ea8b9290b911d73d6e4046d9073c52adbb7ec3e40899af667d998870812e16c9ec06d79d7b06e529b991afb3b602e9db139a93c219b21f1ee7d03 SHA512 737f454524395815293d576baef64de1a401f7e9bb03c800f70f95d7fd6b84ab6c8b205542210624c900126e626364a945e2553ec9084fd869d1df85fa42e3c1 MISC metadata.xml 1323 BLAKE2B 6a19ccbf9f068c6c3d3b945d3011dce3d7712dd74a2daeaa8244eef73fd86723b275ce018ec5557862278c23883fabfb27e91e0b88ff62c34fffdadd4b024411 SHA512 848adbf531103d69b8b0e7017c25de730daecccae220e337e475ba8dbcaa95c6d5e440330be56367974607050dfa1964026ed90bc699ab5f12fef35c88d67505 diff --git a/sys-libs/glibc/files/2.10/glibc-2.10-gentoo-chk_fail.c b/sys-libs/glibc/files/2.10/glibc-2.10-gentoo-chk_fail.c deleted file mode 100644 index 37711e8aacbf..000000000000 --- a/sys-libs/glibc/files/2.10/glibc-2.10-gentoo-chk_fail.c +++ /dev/null @@ -1,315 +0,0 @@ -/* Copyright (C) 2004, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -/* Copyright (C) 2006-2008 Gentoo Foundation Inc. - * License terms as above. - * - * Hardened Gentoo SSP and FORTIFY handler - * - * An SSP failure handler that does not use functions from the rest of - * glibc; it uses the INTERNAL_SYSCALL methods directly. This ensures - * no possibility of recursion into the handler. - * - * Direct all bug reports to http://bugs.gentoo.org/ - * - * Re-written from the glibc-2.3 Hardened Gentoo SSP handler - * by Kevin F. Quinn - - * - * The following people contributed to the glibc-2.3 Hardened - * Gentoo SSP and FORTIFY handler, from which this implementation draws much: - * - * Ned Ludd - - * Alexander Gabert - - * The PaX Team - - * Peter S. Mazinger - - * Yoann Vandoorselaere - - * Robert Connolly - - * Cory Visi - * Mike Frysinger - * Magnus Granberg - */ - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include -/* from sysdeps */ -#include -/* for the stuff in bits/socket.h */ -#include -#include - -/* Sanity check on SYSCALL macro names - force compilation - * failure if the names used here do not exist - */ -#if !defined __NR_socketcall && !defined __NR_socket -# error Cannot do syscall socket or socketcall -#endif -#if !defined __NR_socketcall && !defined __NR_connect -# error Cannot do syscall connect or socketcall -#endif -#ifndef __NR_write -# error Cannot do syscall write -#endif -#ifndef __NR_close -# error Cannot do syscall close -#endif -#ifndef __NR_getpid -# error Cannot do syscall getpid -#endif -#ifndef __NR_kill -# error Cannot do syscall kill -#endif -#ifndef __NR_exit -# error Cannot do syscall exit -#endif -#ifdef SSP_SMASH_DUMPS_CORE -# define ENABLE_SSP_SMASH_DUMPS_CORE 1 -# if !defined _KERNEL_NSIG && !defined _NSIG -# error No _NSIG or _KERNEL_NSIG for rt_sigaction -# endif -# if !defined __NR_sigaction && !defined __NR_rt_sigaction -# error Cannot do syscall sigaction or rt_sigaction -# endif -/* Although rt_sigaction expects sizeof(sigset_t) - it expects the size - * of the _kernel_ sigset_t which is not the same as the user sigset_t. - * Most arches have this as _NSIG bits - mips has _KERNEL_NSIG bits for - * some reason. - */ -# ifdef _KERNEL_NSIG -# define _SSP_NSIG _KERNEL_NSIG -# else -# define _SSP_NSIG _NSIG -# endif -#else -# define _SSP_NSIG 0 -# define ENABLE_SSP_SMASH_DUMPS_CORE 0 -#endif - -/* Define DO_SIGACTION - default to newer rt signal interface but - * fallback to old as needed. - */ -#ifdef __NR_rt_sigaction -# define DO_SIGACTION(signum, act, oldact) \ - INLINE_SYSCALL(rt_sigaction, 4, signum, act, oldact, _SSP_NSIG/8) -#else -# define DO_SIGACTION(signum, act, oldact) \ - INLINE_SYSCALL(sigaction, 3, signum, act, oldact) -#endif - -/* Define DO_SOCKET/DO_CONNECT functions to deal with socketcall vs socket/connect */ -#if defined(__NR_socket) && defined(__NR_connect) -# define USE_OLD_SOCKETCALL 0 -#else -# define USE_OLD_SOCKETCALL 1 -#endif - -/* stub out the __NR_'s so we can let gcc optimize away dead code */ -#ifndef __NR_socketcall -# define __NR_socketcall 0 -#endif -#ifndef __NR_socket -# define __NR_socket 0 -#endif -#ifndef __NR_connect -# define __NR_connect 0 -#endif -#define DO_SOCKET(result, domain, type, protocol) \ - do { \ - if (USE_OLD_SOCKETCALL) { \ - socketargs[0] = domain; \ - socketargs[1] = type; \ - socketargs[2] = protocol; \ - socketargs[3] = 0; \ - result = INLINE_SYSCALL(socketcall, 2, SOCKOP_socket, socketargs); \ - } else \ - result = INLINE_SYSCALL(socket, 3, domain, type, protocol); \ - } while (0) -#define DO_CONNECT(result, sockfd, serv_addr, addrlen) \ - do { \ - if (USE_OLD_SOCKETCALL) { \ - socketargs[0] = sockfd; \ - socketargs[1] = (unsigned long int)serv_addr; \ - socketargs[2] = addrlen; \ - socketargs[3] = 0; \ - result = INLINE_SYSCALL(socketcall, 2, SOCKOP_connect, socketargs); \ - } else \ - result = INLINE_SYSCALL(connect, 3, sockfd, serv_addr, addrlen); \ - } while (0) - -#ifndef _PATH_LOG -# define _PATH_LOG "/dev/log" -#endif - -static const char path_log[] = _PATH_LOG; - -/* For building glibc with SSP switched on, define __progname to a - * constant if building for the run-time loader, to avoid pulling - * in more of libc.so into ld.so - */ -#ifdef IS_IN_rtld -static char *__progname = ""; -#else -extern char *__progname; -#endif - -/* Common handler code, used by chk_fail - * Inlined to ensure no self-references to the handler within itself. - * Data static to avoid putting more than necessary on the stack, - * to aid core debugging. - */ -__attribute__ ((__noreturn__ , __always_inline__)) -static inline void -__hardened_gentoo_chk_fail(char func[], int damaged) -{ -#define MESSAGE_BUFSIZ 256 - static pid_t pid; - static int plen, i; - static char message[MESSAGE_BUFSIZ]; - static const char msg_ssa[] = ": buffer overflow attack"; - static const char msg_inf[] = " in function "; - static const char msg_ssd[] = "*** buffer overflow detected ***: "; - static const char msg_terminated[] = " - terminated\n"; - static const char msg_report[] = "Report to http://bugs.gentoo.org/\n"; - static const char msg_unknown[] = ""; - static int log_socket, connect_result; - static struct sockaddr_un sock; - static unsigned long int socketargs[4]; - - /* Build socket address - */ - sock.sun_family = AF_UNIX; - i = 0; - while ((path_log[i] != '\0') && (i<(sizeof(sock.sun_path)-1))) { - sock.sun_path[i] = path_log[i]; - i++; - } - sock.sun_path[i] = '\0'; - - /* Try SOCK_DGRAM connection to syslog */ - connect_result = -1; - DO_SOCKET(log_socket, AF_UNIX, SOCK_DGRAM, 0); - if (log_socket != -1) - DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock)); - if (connect_result == -1) { - if (log_socket != -1) - INLINE_SYSCALL(close, 1, log_socket); - /* Try SOCK_STREAM connection to syslog */ - DO_SOCKET(log_socket, AF_UNIX, SOCK_STREAM, 0); - if (log_socket != -1) - DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock)); - } - - /* Build message. Messages are generated both in the old style and new style, - * so that log watchers that are configured for the old-style message continue - * to work. - */ -#define strconcat(str) \ - {i=0; while ((str[i] != '\0') && ((i+plen)<(MESSAGE_BUFSIZ-1))) \ - {\ - message[plen+i]=str[i];\ - i++;\ - }\ - plen+=i;} - - /* R.Henderson post-gcc-4 style message */ - plen = 0; - strconcat(msg_ssd); - if (__progname != (char *)0) - strconcat(__progname) - else - strconcat(msg_unknown); - strconcat(msg_terminated); - - /* Write out error message to STDERR, to syslog if open */ - INLINE_SYSCALL(write, 3, STDERR_FILENO, message, plen); - if (connect_result != -1) - INLINE_SYSCALL(write, 3, log_socket, message, plen); - - /* Dr. Etoh pre-gcc-4 style message */ - plen = 0; - if (__progname != (char *)0) - strconcat(__progname) - else - strconcat(msg_unknown); - strconcat(msg_ssa); - strconcat(msg_inf); - if (func != NULL) - strconcat(func) - else - strconcat(msg_unknown); - strconcat(msg_terminated); - /* Write out error message to STDERR, to syslog if open */ - INLINE_SYSCALL(write, 3, STDERR_FILENO, message, plen); - if (connect_result != -1) - INLINE_SYSCALL(write, 3, log_socket, message, plen); - - /* Direct reports to bugs.gentoo.org */ - plen=0; - strconcat(msg_report); - message[plen++]='\0'; - - /* Write out error message to STDERR, to syslog if open */ - INLINE_SYSCALL(write, 3, STDERR_FILENO, message, plen); - if (connect_result != -1) - INLINE_SYSCALL(write, 3, log_socket, message, plen); - - if (log_socket != -1) - INLINE_SYSCALL(close, 1, log_socket); - - /* Suicide */ - pid = INLINE_SYSCALL(getpid, 0); - - if (ENABLE_SSP_SMASH_DUMPS_CORE) { - static struct sigaction default_abort_act; - /* Remove any user-supplied handler for SIGABRT, before using it */ - default_abort_act.sa_handler = SIG_DFL; - default_abort_act.sa_sigaction = NULL; - __sigfillset(&default_abort_act.sa_mask); - default_abort_act.sa_flags = 0; - if (DO_SIGACTION(SIGABRT, &default_abort_act, NULL) == 0) - INLINE_SYSCALL(kill, 2, pid, SIGABRT); - } - - /* Note; actions cannot be added to SIGKILL */ - INLINE_SYSCALL(kill, 2, pid, SIGKILL); - - /* In case the kill didn't work, exit anyway - * The loop prevents gcc thinking this routine returns - */ - while (1) - INLINE_SYSCALL(exit, 0); -} - -__attribute__ ((__noreturn__)) -void __chk_fail(void) -{ - __hardened_gentoo_chk_fail(NULL, 0); -} - diff --git a/sys-libs/glibc/files/2.10/glibc-2.10-hardened-configure-picdefault.patch b/sys-libs/glibc/files/2.10/glibc-2.10-hardened-configure-picdefault.patch deleted file mode 100644 index e75ccc788c89..000000000000 --- a/sys-libs/glibc/files/2.10/glibc-2.10-hardened-configure-picdefault.patch +++ /dev/null @@ -1,30 +0,0 @@ -Prevent default-fPIE from confusing configure into thinking -PIC code is default. This causes glibc to build both PIC and -non-PIC code as normal, which on the hardened compiler generates -PIC and PIE. - -Patch by Kevin F. Quinn -Fixed for glibc 2.10 by Magnus Granberg - ---- configure.in -+++ configure.in -@@ -2145,7 +2145,7 @@ - # error PIC is default. - #endif - EOF --if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then -+if eval "${CC-cc} -fno-PIE -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then - libc_cv_pic_default=no - fi - rm -f conftest.*]) ---- configure -+++ configure -@@ -7698,7 +7698,7 @@ - # error PIC is default. - #endif - EOF --if eval "${CC-cc} -S conftest.c 2>&5 1>&5"; then -+if eval "${CC-cc} -fno-PIE -S conftest.c 2>&5 1>&5"; then - libc_cv_pic_default=no - fi - rm -f conftest.* diff --git a/sys-libs/glibc/files/2.10/glibc-2.10-hardened-inittls-nosysenter.patch b/sys-libs/glibc/files/2.10/glibc-2.10-hardened-inittls-nosysenter.patch deleted file mode 100644 index cb6d8e3c78ba..000000000000 --- a/sys-libs/glibc/files/2.10/glibc-2.10-hardened-inittls-nosysenter.patch +++ /dev/null @@ -1,274 +0,0 @@ -When building glibc PIE (which is not something upstream support), -several modifications are necessary to the glibc build process. - -First, any syscalls in PIEs must be of the PIC variant, otherwise -textrels ensue. Then, any syscalls made before the initialisation -of the TLS will fail on i386, as the sysenter variant on i386 uses -the TLS, giving rise to a chicken-and-egg situation. This patch -defines a PIC syscall variant that doesn't use sysenter, even when the sysenter -version is normally used, and uses the non-sysenter version for the brk -syscall that is performed by the TLS initialisation. Further, the TLS -initialisation is moved in this case prior to the initialisation of -dl_osversion, as that requires further syscalls. - -csu/libc-start.c: Move initial TLS initialization to before the -initialisation of dl_osversion, when INTERNAL_SYSCALL_NOSYSENTER is defined - -csu/libc-tls.c: Use the no-sysenter version of sbrk when -INTERNAL_SYSCALL_NOSYSENTER is defined. - -misc/sbrk.c: Define a no-sysenter version of sbrk, using the no-sysenter -version of brk - if INTERNAL_SYSCALL_NOSYSENTER is defined. - -misc/brk.c: Define a no-sysenter version of brk if -INTERNAL_SYSCALL_NOSYSENTER is defined. - -sysdeps/unix/sysv/linux/i386/sysdep.h: Define INTERNAL_SYSCALL_NOSYSENTER -Make INTERNAL_SYSCALL always use the PIC variant, even if not SHARED. - -Patch by Kevin F. Quinn -Fixed for 2.10 by Magnus Granberg - ---- csu/libc-start.c -+++ csu/libc-start.c -@@ -28,6 +28,7 @@ - extern int __libc_multiple_libcs; - - #include -+#include - #ifndef SHARED - # include - extern void __pthread_initialize_minimal (void); -@@ -129,6 +130,11 @@ - # endif - _dl_aux_init (auxvec); - # endif -+# ifdef INTERNAL_SYSCALL_NOSYSENTER -+ /* Do the initial TLS initialization before _dl_osversion, -+ since the latter uses the uname syscall. */ -+ __pthread_initialize_minimal (); -+# endif - # ifdef DL_SYSDEP_OSCHECK - if (!__libc_multiple_libcs) - { -@@ -138,10 +144,12 @@ - } - # endif - -+# ifndef INTERNAL_SYSCALL_NOSYSENTER - /* Initialize the thread library at least a bit since the libgcc - functions are using thread functions if these are available and - we need to setup errno. */ - __pthread_initialize_minimal (); -+# endif - - /* Set up the stack checker's canary. */ - uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (); ---- csu/libc-tls.c -+++ csu/libc-tls.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - - #ifdef SHARED -@@ -29,6 +30,9 @@ - #error makefile bug, this file is for static only - #endif - -+#ifdef INTERNAL_SYSCALL_NOSYSENTER -+extern void *__sbrk_nosysenter (intptr_t __delta); -+#endif - extern ElfW(Phdr) *_dl_phdr; - extern size_t _dl_phnum; - -@@ -141,14 +145,26 @@ - - The initialized value of _dl_tls_static_size is provided by dl-open.c - to request some surplus that permits dynamic loading of modules with -- IE-model TLS. */ -+ IE-model TLS. -+ -+ Where the normal sbrk would use a syscall that needs the TLS (i386) -+ use the special non-sysenter version instead. */ - #if TLS_TCB_AT_TP - tcb_offset = roundup (memsz + GL(dl_tls_static_size), tcbalign); -+# ifdef INTERNAL_SYSCALL_NOSYSENTER -+ tlsblock = __sbrk_nosysenter (tcb_offset + tcbsize + max_align); -+# else - tlsblock = __sbrk (tcb_offset + tcbsize + max_align); -+# endif - #elif TLS_DTV_AT_TP - tcb_offset = roundup (tcbsize, align ?: 1); -+# ifdef INTERNAL_SYSCALL_NOSYSENTER -+ tlsblock = __sbrk_nosysenter (tcb_offset + memsz + max_align -+ + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size)); -+# else - tlsblock = __sbrk (tcb_offset + memsz + max_align - + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size)); -+# endif - tlsblock += TLS_PRE_TCB_SIZE; - #else - /* In case a model with a different layout for the TCB and DTV ---- misc/sbrk.c -+++ misc/sbrk.c -@@ -18,6 +18,7 @@ - #include - #include - #include -+#include - - /* Defined in brk.c. */ - extern void *__curbrk; -@@ -29,6 +30,35 @@ - /* Extend the process's data space by INCREMENT. - If INCREMENT is negative, shrink data space by - INCREMENT. - Return start of new space allocated, or -1 for errors. */ -+#ifdef INTERNAL_SYSCALL_NOSYSENTER -+/* This version is used by csu/libc-tls.c whem initialising the TLS -+ if the SYSENTER version requires the TLS (which it does on i386). -+ Obviously using the TLS before it is initialised is broken. */ -+extern int __brk_nosysenter (void *addr); -+void * -+__sbrk_nosysenter (intptr_t increment) -+{ -+ void *oldbrk; -+ -+ /* If this is not part of the dynamic library or the library is used -+ via dynamic loading in a statically linked program update -+ __curbrk from the kernel's brk value. That way two separate -+ instances of __brk and __sbrk can share the heap, returning -+ interleaved pieces of it. */ -+ if (__curbrk == NULL || __libc_multiple_libcs) -+ if (__brk_nosysenter (0) < 0) /* Initialize the break. */ -+ return (void *) -1; -+ -+ if (increment == 0) -+ return __curbrk; -+ -+ oldbrk = __curbrk; -+ if (__brk_nosysenter (oldbrk + increment) < 0) -+ return (void *) -1; -+ -+ return oldbrk; -+} -+#endif - void * - __sbrk (intptr_t increment) - { ---- sysdeps/unix/sysv/linux/i386/brk.c -+++ sysdeps/unix/sysv/linux/i386/brk.c -@@ -31,6 +31,30 @@ - linker. */ - weak_alias (__curbrk, ___brk_addr) - -+#ifdef INTERNAL_SYSCALL_NOSYSENTER -+/* This version is used by csu/libc-tls.c whem initialising the TLS -+ * if the SYSENTER version requires the TLS (which it does on i386). -+ * Obviously using the TLS before it is initialised is broken. */ -+int -+__brk_nosysenter (void *addr) -+{ -+ void *__unbounded newbrk; -+ -+ INTERNAL_SYSCALL_DECL (err); -+ newbrk = (void *__unbounded) INTERNAL_SYSCALL_NOSYSENTER (brk, err, 1, -+ __ptrvalue (addr)); -+ -+ __curbrk = newbrk; -+ -+ if (newbrk < addr) -+ { -+ __set_errno (ENOMEM); -+ return -1; -+ } -+ -+ return 0; -+} -+#endif - int - __brk (void *addr) - { ---- sysdeps/unix/sysv/linux/i386/sysdep.h -+++ sysdeps/unix/sysv/linux/i386/sysdep.h -@@ -187,7 +187,7 @@ - /* The original calling convention for system calls on Linux/i386 is - to use int $0x80. */ - #ifdef I386_USE_SYSENTER --# ifdef SHARED -+# if defined SHARED || defined __PIC__ - # define ENTER_KERNEL call *%gs:SYSINFO_OFFSET - # else - # define ENTER_KERNEL call *_dl_sysinfo -@@ -358,7 +358,7 @@ - possible to use more than four parameters. */ - #undef INTERNAL_SYSCALL - #ifdef I386_USE_SYSENTER --# ifdef SHARED -+# if defined SHARED || defined __PIC__ - # define INTERNAL_SYSCALL(name, err, nr, args...) \ - ({ \ - register unsigned int resultvar; \ -@@ -384,6 +384,18 @@ - : "0" (name), "i" (offsetof (tcbhead_t, sysinfo)) \ - ASMFMT_##nr(args) : "memory", "cc"); \ - (int) resultvar; }) -+# define INTERNAL_SYSCALL_NOSYSENTER(name, err, nr, args...) \ -+ ({ \ -+ register unsigned int resultvar; \ -+ EXTRAVAR_##nr \ -+ asm volatile ( \ -+ LOADARGS_NOSYSENTER_##nr \ -+ "movl %1, %%eax\n\t" \ -+ "int $0x80\n\t" \ -+ RESTOREARGS_NOSYSENTER_##nr \ -+ : "=a" (resultvar) \ -+ : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc"); \ -+ (int) resultvar; }) - # else - # define INTERNAL_SYSCALL(name, err, nr, args...) \ - ({ \ -@@ -447,12 +459,20 @@ - - #define LOADARGS_0 - #ifdef __PIC__ --# if defined I386_USE_SYSENTER && defined SHARED -+# if defined I386_USE_SYSENTER && ( defined SHARED || defined __PIC__ ) - # define LOADARGS_1 \ - "bpushl .L__X'%k3, %k3\n\t" - # define LOADARGS_5 \ - "movl %%ebx, %4\n\t" \ - "movl %3, %%ebx\n\t" -+# define LOADARGS_NOSYSENTER_1 \ -+ "bpushl .L__X'%k2, %k2\n\t" -+# define LOADARGS_NOSYSENTER_2 LOADARGS_NOSYSENTER_1 -+# define LOADARGS_NOSYSENTER_3 LOADARGS_3 -+# define LOADARGS_NOSYSENTER_4 LOADARGS_3 -+# define LOADARGS_NOSYSENTER_5 \ -+ "movl %%ebx, %3\n\t" \ -+ "movl %2, %%ebx\n\t" - # else - # define LOADARGS_1 \ - "bpushl .L__X'%k2, %k2\n\t" -@@ -474,11 +495,18 @@ - - #define RESTOREARGS_0 - #ifdef __PIC__ --# if defined I386_USE_SYSENTER && defined SHARED -+# if defined I386_USE_SYSENTER && ( defined SHARED || defined __PIC__ ) - # define RESTOREARGS_1 \ - "bpopl .L__X'%k3, %k3\n\t" - # define RESTOREARGS_5 \ - "movl %4, %%ebx" -+# define RESTOREARGS_NOSYSENTER_1 \ -+ "bpopl .L__X'%k2, %k2\n\t" -+# define RESTOREARGS_NOSYSENTER_2 RESTOREARGS_NOSYSENTER_1 -+# define RESTOREARGS_NOSYSENTER_3 RESTOREARGS_3 -+# define RESTOREARGS_NOSYSENTER_4 RESTOREARGS_3 -+# define RESTOREARGS_NOSYSENTER_5 \ -+ "movl %3, %%ebx" - # else - # define RESTOREARGS_1 \ - "bpopl .L__X'%k2, %k2\n\t" diff --git a/sys-libs/glibc/files/2.17/glibc-2.17-hardened-pie.patch b/sys-libs/glibc/files/2.17/glibc-2.17-hardened-pie.patch deleted file mode 100644 index da4fb82539cf..000000000000 --- a/sys-libs/glibc/files/2.17/glibc-2.17-hardened-pie.patch +++ /dev/null @@ -1,42 +0,0 @@ -2012-11-11 Magnus Granberg - - #442712 - * Makeconfig (+link): Set to +link-pie. - (+link-static-before-libc): Change $(static-start-installed-name) to - S$(static-start-installed-name). - (+prector): Set to +prectorS. - (+postctor): Set to +postctorS. - ---- libc/Makeconfig -+++ libc/Makeconfig -@@ -447,11 +447,12 @@ - $(common-objpfx)libc% $(+postinit),$^) \ - $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit) - endif -++link = $(+link-pie) - # Command for statically linking programs with the C library. - ifndef +link-static - +link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \ - $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ -- $(addprefix $(csu-objpfx),$(static-start-installed-name)) \ -+ $(addprefix $(csu-objpfx),S$(static-start-installed-name)) \ - $(+preinit) $(+prectorT) \ - $(filter-out $(addprefix $(csu-objpfx),start.o \ - $(start-installed-name))\ -@@ -549,11 +550,10 @@ - ifeq ($(elf),yes) - +preinit = $(addprefix $(csu-objpfx),crti.o) - +postinit = $(addprefix $(csu-objpfx),crtn.o) --+prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o` --+postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o` --# Variants of the two previous definitions for linking PIE programs. - +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o` - +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o` -++prector = $(+prectorS) -++postctor = $(+postctorS) - # Variants of the two previous definitions for statically linking programs. - +prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o` - +postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o` - +interp = $(addprefix $(elf-objpfx),interp.os) - endif - csu-objpfx = $(common-objpfx)csu/ diff --git a/sys-libs/glibc/files/2.18/glibc-2.18-gentoo-chk_fail.c b/sys-libs/glibc/files/2.18/glibc-2.18-gentoo-chk_fail.c deleted file mode 100644 index c1934362f628..000000000000 --- a/sys-libs/glibc/files/2.18/glibc-2.18-gentoo-chk_fail.c +++ /dev/null @@ -1,314 +0,0 @@ -/* Copyright (C) 2004, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -/* Copyright (C) 2006-2013 Gentoo Foundation Inc. - * License terms as above. - * - * Hardened Gentoo SSP and FORTIFY handler - * - * An SSP failure handler that does not use functions from the rest of - * glibc; it uses the INTERNAL_SYSCALL methods directly. This ensures - * no possibility of recursion into the handler. - * - * Direct all bug reports to http://bugs.gentoo.org/ - * - * Re-written from the glibc-2.3 Hardened Gentoo SSP handler - * by Kevin F. Quinn - - * - * The following people contributed to the glibc-2.3 Hardened - * Gentoo SSP and FORTIFY handler, from which this implementation draws much: - * - * Ned Ludd - - * Alexander Gabert - - * The PaX Team - - * Peter S. Mazinger - - * Yoann Vandoorselaere - - * Robert Connolly - - * Cory Visi - * Mike Frysinger - * Magnus Granberg - */ - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include -/* from sysdeps */ -#include -/* for the stuff in bits/socket.h */ -#include -#include - -/* Sanity check on SYSCALL macro names - force compilation - * failure if the names used here do not exist - */ -#if !defined __NR_socketcall && !defined __NR_socket -# error Cannot do syscall socket or socketcall -#endif -#if !defined __NR_socketcall && !defined __NR_connect -# error Cannot do syscall connect or socketcall -#endif -#ifndef __NR_write -# error Cannot do syscall write -#endif -#ifndef __NR_close -# error Cannot do syscall close -#endif -#ifndef __NR_getpid -# error Cannot do syscall getpid -#endif -#ifndef __NR_kill -# error Cannot do syscall kill -#endif -#ifndef __NR_exit -# error Cannot do syscall exit -#endif -#ifdef SSP_SMASH_DUMPS_CORE -# define ENABLE_SSP_SMASH_DUMPS_CORE 1 -# if !defined _KERNEL_NSIG && !defined _NSIG -# error No _NSIG or _KERNEL_NSIG for rt_sigaction -# endif -# if !defined __NR_sigaction && !defined __NR_rt_sigaction -# error Cannot do syscall sigaction or rt_sigaction -# endif -/* Although rt_sigaction expects sizeof(sigset_t) - it expects the size - * of the _kernel_ sigset_t which is not the same as the user sigset_t. - * Most arches have this as _NSIG bits - mips has _KERNEL_NSIG bits for - * some reason. - */ -# ifdef _KERNEL_NSIG -# define _SSP_NSIG _KERNEL_NSIG -# else -# define _SSP_NSIG _NSIG -# endif -#else -# define _SSP_NSIG 0 -# define ENABLE_SSP_SMASH_DUMPS_CORE 0 -#endif - -/* Define DO_SIGACTION - default to newer rt signal interface but - * fallback to old as needed. - */ -#ifdef __NR_rt_sigaction -# define DO_SIGACTION(signum, act, oldact) \ - INLINE_SYSCALL(rt_sigaction, 4, signum, act, oldact, _SSP_NSIG/8) -#else -# define DO_SIGACTION(signum, act, oldact) \ - INLINE_SYSCALL(sigaction, 3, signum, act, oldact) -#endif - -/* Define DO_SOCKET/DO_CONNECT functions to deal with socketcall vs socket/connect */ -#if defined(__NR_socket) && defined(__NR_connect) -# define USE_OLD_SOCKETCALL 0 -#else -# define USE_OLD_SOCKETCALL 1 -#endif - -/* stub out the __NR_'s so we can let gcc optimize away dead code */ -#ifndef __NR_socketcall -# define __NR_socketcall 0 -#endif -#ifndef __NR_socket -# define __NR_socket 0 -#endif -#ifndef __NR_connect -# define __NR_connect 0 -#endif -#define DO_SOCKET(result, domain, type, protocol) \ - do { \ - if (USE_OLD_SOCKETCALL) { \ - socketargs[0] = domain; \ - socketargs[1] = type; \ - socketargs[2] = protocol; \ - socketargs[3] = 0; \ - result = INLINE_SYSCALL(socketcall, 2, SOCKOP_socket, socketargs); \ - } else \ - result = INLINE_SYSCALL(socket, 3, domain, type, protocol); \ - } while (0) -#define DO_CONNECT(result, sockfd, serv_addr, addrlen) \ - do { \ - if (USE_OLD_SOCKETCALL) { \ - socketargs[0] = sockfd; \ - socketargs[1] = (unsigned long int)serv_addr; \ - socketargs[2] = addrlen; \ - socketargs[3] = 0; \ - result = INLINE_SYSCALL(socketcall, 2, SOCKOP_connect, socketargs); \ - } else \ - result = INLINE_SYSCALL(connect, 3, sockfd, serv_addr, addrlen); \ - } while (0) - -#ifndef _PATH_LOG -# define _PATH_LOG "/dev/log" -#endif - -static const char path_log[] = _PATH_LOG; - -/* For building glibc with SSP switched on, define __progname to a - * constant if building for the run-time loader, to avoid pulling - * in more of libc.so into ld.so - */ -#ifdef IS_IN_rtld -static char *__progname = ""; -#else -extern char *__progname; -#endif - -/* Common handler code, used by chk_fail - * Inlined to ensure no self-references to the handler within itself. - * Data static to avoid putting more than necessary on the stack, - * to aid core debugging. - */ -__attribute__ ((__noreturn__ , __always_inline__)) -static inline void -__hardened_gentoo_chk_fail(char func[], int damaged) -{ -#define MESSAGE_BUFSIZ 256 - static pid_t pid; - static int plen, i; - static char message[MESSAGE_BUFSIZ]; - static const char msg_ssa[] = ": buffer overflow attack"; - static const char msg_inf[] = " in function "; - static const char msg_ssd[] = "*** buffer overflow detected ***: "; - static const char msg_terminated[] = " - terminated\n"; - static const char msg_report[] = "Report to http://bugs.gentoo.org/\n"; - static const char msg_unknown[] = ""; - static int log_socket, connect_result; - static struct sockaddr_un sock; - static unsigned long int socketargs[4]; - - /* Build socket address - */ - sock.sun_family = AF_UNIX; - i = 0; - while ((path_log[i] != '\0') && (i<(sizeof(sock.sun_path)-1))) { - sock.sun_path[i] = path_log[i]; - i++; - } - sock.sun_path[i] = '\0'; - - /* Try SOCK_DGRAM connection to syslog */ - connect_result = -1; - DO_SOCKET(log_socket, AF_UNIX, SOCK_DGRAM, 0); - if (log_socket != -1) - DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock)); - if (connect_result == -1) { - if (log_socket != -1) - INLINE_SYSCALL(close, 1, log_socket); - /* Try SOCK_STREAM connection to syslog */ - DO_SOCKET(log_socket, AF_UNIX, SOCK_STREAM, 0); - if (log_socket != -1) - DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock)); - } - - /* Build message. Messages are generated both in the old style and new style, - * so that log watchers that are configured for the old-style message continue - * to work. - */ -#define strconcat(str) \ - {i=0; while ((str[i] != '\0') && ((i+plen)<(MESSAGE_BUFSIZ-1))) \ - {\ - message[plen+i]=str[i];\ - i++;\ - }\ - plen+=i;} - - /* R.Henderson post-gcc-4 style message */ - plen = 0; - strconcat(msg_ssd); - if (__progname != (char *)0) - strconcat(__progname) - else - strconcat(msg_unknown); - strconcat(msg_terminated); - - /* Write out error message to STDERR, to syslog if open */ - INLINE_SYSCALL(write, 3, STDERR_FILENO, message, plen); - if (connect_result != -1) - INLINE_SYSCALL(write, 3, log_socket, message, plen); - - /* Dr. Etoh pre-gcc-4 style message */ - plen = 0; - if (__progname != (char *)0) - strconcat(__progname) - else - strconcat(msg_unknown); - strconcat(msg_ssa); - strconcat(msg_inf); - if (func != NULL) - strconcat(func) - else - strconcat(msg_unknown); - strconcat(msg_terminated); - /* Write out error message to STDERR, to syslog if open */ - INLINE_SYSCALL(write, 3, STDERR_FILENO, message, plen); - if (connect_result != -1) - INLINE_SYSCALL(write, 3, log_socket, message, plen); - - /* Direct reports to bugs.gentoo.org */ - plen=0; - strconcat(msg_report); - message[plen++]='\0'; - - /* Write out error message to STDERR, to syslog if open */ - INLINE_SYSCALL(write, 3, STDERR_FILENO, message, plen); - if (connect_result != -1) - INLINE_SYSCALL(write, 3, log_socket, message, plen); - - if (log_socket != -1) - INLINE_SYSCALL(close, 1, log_socket); - - /* Suicide */ - pid = INLINE_SYSCALL(getpid, 0); - - if (ENABLE_SSP_SMASH_DUMPS_CORE) { - static struct sigaction default_abort_act; - /* Remove any user-supplied handler for SIGABRT, before using it */ - default_abort_act.sa_handler = SIG_DFL; - default_abort_act.sa_sigaction = NULL; - __sigfillset(&default_abort_act.sa_mask); - default_abort_act.sa_flags = 0; - if (DO_SIGACTION(SIGABRT, &default_abort_act, NULL) == 0) - INLINE_SYSCALL(kill, 2, pid, SIGABRT); - } - - /* Note; actions cannot be added to SIGKILL */ - INLINE_SYSCALL(kill, 2, pid, SIGKILL); - - /* In case the kill didn't work, exit anyway - * The loop prevents gcc thinking this routine returns - */ - while (1) - INLINE_SYSCALL(exit, 0); -} - -__attribute__ ((__noreturn__)) -void __chk_fail(void) -{ - __hardened_gentoo_chk_fail(NULL, 0); -} - diff --git a/sys-libs/glibc/files/2.18/glibc-2.18-gentoo-stack_chk_fail.c b/sys-libs/glibc/files/2.18/glibc-2.18-gentoo-stack_chk_fail.c deleted file mode 100644 index 9535c2157895..000000000000 --- a/sys-libs/glibc/files/2.18/glibc-2.18-gentoo-stack_chk_fail.c +++ /dev/null @@ -1,322 +0,0 @@ -/* Copyright (C) 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -/* Copyright (C) 2006-2013 Gentoo Foundation Inc. - * License terms as above. - * - * Hardened Gentoo SSP handler - * - * An SSP failure handler that does not use functions from the rest of - * glibc; it uses the INTERNAL_SYSCALL methods directly. This ensures - * no possibility of recursion into the handler. - * - * Direct all bug reports to http://bugs.gentoo.org/ - * - * Re-written from the glibc-2.3 Hardened Gentoo SSP handler - * by Kevin F. Quinn - - * - * Fixed to support glibc-2.18 by Magnus Granberg - - * - * The following people contributed to the glibc-2.3 Hardened - * Gentoo SSP handler, from which this implementation draws much: - * - * Ned Ludd - - * Alexander Gabert - - * The PaX Team - - * Peter S. Mazinger - - * Yoann Vandoorselaere - - * Robert Connolly - - * Cory Visi - * Mike Frysinger - */ - -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include -/* from sysdeps */ -#include -/* for the stuff in bits/socket.h */ -#include -#include - - -/* Sanity check on SYSCALL macro names - force compilation - * failure if the names used here do not exist - */ -#if !defined __NR_socketcall && !defined __NR_socket -# error Cannot do syscall socket or socketcall -#endif -#if !defined __NR_socketcall && !defined __NR_connect -# error Cannot do syscall connect or socketcall -#endif -#ifndef __NR_write -# error Cannot do syscall write -#endif -#ifndef __NR_close -# error Cannot do syscall close -#endif -#ifndef __NR_getpid -# error Cannot do syscall getpid -#endif -#ifndef __NR_kill -# error Cannot do syscall kill -#endif -#ifndef __NR_exit -# error Cannot do syscall exit -#endif -#ifdef SSP_SMASH_DUMPS_CORE -# define ENABLE_SSP_SMASH_DUMPS_CORE 1 -# if !defined _KERNEL_NSIG && !defined _NSIG -# error No _NSIG or _KERNEL_NSIG for rt_sigaction -# endif -# if !defined __NR_sigaction && !defined __NR_rt_sigaction -# error Cannot do syscall sigaction or rt_sigaction -# endif -/* Although rt_sigaction expects sizeof(sigset_t) - it expects the size - * of the _kernel_ sigset_t which is not the same as the user sigset_t. - * Most arches have this as _NSIG bits - mips has _KERNEL_NSIG bits for - * some reason. - */ -# ifdef _KERNEL_NSIG -# define _SSP_NSIG _KERNEL_NSIG -# else -# define _SSP_NSIG _NSIG -# endif -#else -# define _SSP_NSIG 0 -# define ENABLE_SSP_SMASH_DUMPS_CORE 0 -#endif - -/* Define DO_SIGACTION - default to newer rt signal interface but - * fallback to old as needed. - */ -#ifdef __NR_rt_sigaction -# define DO_SIGACTION(signum, act, oldact) \ - INLINE_SYSCALL(rt_sigaction, 4, signum, act, oldact, _SSP_NSIG/8) -#else -# define DO_SIGACTION(signum, act, oldact) \ - INLINE_SYSCALL(sigaction, 3, signum, act, oldact) -#endif - -/* Define DO_SOCKET/DO_CONNECT functions to deal with socketcall vs socket/connect */ -#if defined(__NR_socket) && defined(__NR_connect) -# define USE_OLD_SOCKETCALL 0 -#else -# define USE_OLD_SOCKETCALL 1 -#endif -/* stub out the __NR_'s so we can let gcc optimize away dead code */ -#ifndef __NR_socketcall -# define __NR_socketcall 0 -#endif -#ifndef __NR_socket -# define __NR_socket 0 -#endif -#ifndef __NR_connect -# define __NR_connect 0 -#endif -#define DO_SOCKET(result, domain, type, protocol) \ - do { \ - if (USE_OLD_SOCKETCALL) { \ - socketargs[0] = domain; \ - socketargs[1] = type; \ - socketargs[2] = protocol; \ - socketargs[3] = 0; \ - result = INLINE_SYSCALL(socketcall, 2, SOCKOP_socket, socketargs); \ - } else \ - result = INLINE_SYSCALL(socket, 3, domain, type, protocol); \ - } while (0) -#define DO_CONNECT(result, sockfd, serv_addr, addrlen) \ - do { \ - if (USE_OLD_SOCKETCALL) { \ - socketargs[0] = sockfd; \ - socketargs[1] = (unsigned long int)serv_addr; \ - socketargs[2] = addrlen; \ - socketargs[3] = 0; \ - result = INLINE_SYSCALL(socketcall, 2, SOCKOP_connect, socketargs); \ - } else \ - result = INLINE_SYSCALL(connect, 3, sockfd, serv_addr, addrlen); \ - } while (0) - -#ifndef _PATH_LOG -# define _PATH_LOG "/dev/log" -#endif - -static const char path_log[] = _PATH_LOG; - -/* For building glibc with SSP switched on, define __progname to a - * constant if building for the run-time loader, to avoid pulling - * in more of libc.so into ld.so - */ -#ifdef IS_IN_rtld -static char *__progname = ""; -#else -extern char *__progname; -#endif - - -/* Common handler code, used by stack_chk_fail and __stack_smash_handler - * Inlined to ensure no self-references to the handler within itself. - * Data static to avoid putting more than necessary on the stack, - * to aid core debugging. - */ -__attribute__ ((__noreturn__ , __always_inline__)) -static inline void -__hardened_gentoo_stack_chk_fail(char func[], int damaged) -{ -#define MESSAGE_BUFSIZ 256 - static pid_t pid; - static int plen, i; - static char message[MESSAGE_BUFSIZ]; - static const char msg_ssa[] = ": stack smashing attack"; - static const char msg_inf[] = " in function "; - static const char msg_ssd[] = "*** stack smashing detected ***: "; - static const char msg_terminated[] = " - terminated\n"; - static const char msg_report[] = "Report to http://bugs.gentoo.org/\n"; - static const char msg_unknown[] = ""; - static int log_socket, connect_result; - static struct sockaddr_un sock; - static unsigned long int socketargs[4]; - - /* Build socket address - */ - sock.sun_family = AF_UNIX; - i = 0; - while ((path_log[i] != '\0') && (i<(sizeof(sock.sun_path)-1))) { - sock.sun_path[i] = path_log[i]; - i++; - } - sock.sun_path[i] = '\0'; - - /* Try SOCK_DGRAM connection to syslog */ - connect_result = -1; - DO_SOCKET(log_socket, AF_UNIX, SOCK_DGRAM, 0); - if (log_socket != -1) - DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock)); - if (connect_result == -1) { - if (log_socket != -1) - INLINE_SYSCALL(close, 1, log_socket); - /* Try SOCK_STREAM connection to syslog */ - DO_SOCKET(log_socket, AF_UNIX, SOCK_STREAM, 0); - if (log_socket != -1) - DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock)); - } - - /* Build message. Messages are generated both in the old style and new style, - * so that log watchers that are configured for the old-style message continue - * to work. - */ -#define strconcat(str) \ - {i=0; while ((str[i] != '\0') && ((i+plen)<(MESSAGE_BUFSIZ-1))) \ - {\ - message[plen+i]=str[i];\ - i++;\ - }\ - plen+=i;} - - /* R.Henderson post-gcc-4 style message */ - plen = 0; - strconcat(msg_ssd); - if (__progname != (char *)0) - strconcat(__progname) - else - strconcat(msg_unknown); - strconcat(msg_terminated); - - /* Write out error message to STDERR, to syslog if open */ - INLINE_SYSCALL(write, 3, STDERR_FILENO, message, plen); - if (connect_result != -1) - INLINE_SYSCALL(write, 3, log_socket, message, plen); - - /* Dr. Etoh pre-gcc-4 style message */ - plen = 0; - if (__progname != (char *)0) - strconcat(__progname) - else - strconcat(msg_unknown); - strconcat(msg_ssa); - strconcat(msg_inf); - if (func != NULL) - strconcat(func) - else - strconcat(msg_unknown); - strconcat(msg_terminated); - /* Write out error message to STDERR, to syslog if open */ - INLINE_SYSCALL(write, 3, STDERR_FILENO, message, plen); - if (connect_result != -1) - INLINE_SYSCALL(write, 3, log_socket, message, plen); - - /* Direct reports to bugs.gentoo.org */ - plen=0; - strconcat(msg_report); - message[plen++]='\0'; - - /* Write out error message to STDERR, to syslog if open */ - INLINE_SYSCALL(write, 3, STDERR_FILENO, message, plen); - if (connect_result != -1) - INLINE_SYSCALL(write, 3, log_socket, message, plen); - - if (log_socket != -1) - INLINE_SYSCALL(close, 1, log_socket); - - /* Suicide */ - pid = INLINE_SYSCALL(getpid, 0); - - if (ENABLE_SSP_SMASH_DUMPS_CORE) { - static struct sigaction default_abort_act; - /* Remove any user-supplied handler for SIGABRT, before using it */ - default_abort_act.sa_handler = SIG_DFL; - default_abort_act.sa_sigaction = NULL; - __sigfillset(&default_abort_act.sa_mask); - default_abort_act.sa_flags = 0; - if (DO_SIGACTION(SIGABRT, &default_abort_act, NULL) == 0) - INLINE_SYSCALL(kill, 2, pid, SIGABRT); - } - - /* Note; actions cannot be added to SIGKILL */ - INLINE_SYSCALL(kill, 2, pid, SIGKILL); - - /* In case the kill didn't work, exit anyway - * The loop prevents gcc thinking this routine returns - */ - while (1) - INLINE_SYSCALL(exit, 0); -} - -__attribute__ ((__noreturn__)) -void __stack_chk_fail(void) -{ - __hardened_gentoo_stack_chk_fail(NULL, 0); -} - -#ifdef ENABLE_OLD_SSP_COMPAT -__attribute__ ((__noreturn__)) -void __stack_smash_handler(char func[], int damaged) -{ - __hardened_gentoo_stack_chk_fail(func, damaged); -} -#endif diff --git a/sys-libs/glibc/files/2.18/glibc-2.18-hardened-inittls-nosysenter.patch b/sys-libs/glibc/files/2.18/glibc-2.18-hardened-inittls-nosysenter.patch deleted file mode 100644 index 8907ab2c6a34..000000000000 --- a/sys-libs/glibc/files/2.18/glibc-2.18-hardened-inittls-nosysenter.patch +++ /dev/null @@ -1,277 +0,0 @@ -When building glibc PIE (which is not something upstream support), -several modifications are necessary to the glibc build process. - -First, any syscalls in PIEs must be of the PIC variant, otherwise -textrels ensue. Then, any syscalls made before the initialisation -of the TLS will fail on i386, as the sysenter variant on i386 uses -the TLS, giving rise to a chicken-and-egg situation. This patch -defines a PIC syscall variant that doesn't use sysenter, even when the sysenter -version is normally used, and uses the non-sysenter version for the brk -syscall that is performed by the TLS initialisation. Further, the TLS -initialisation is moved in this case prior to the initialisation of -dl_osversion, as that requires further syscalls. - -csu/libc-start.c: Move initial TLS initialization to before the -initialisation of dl_osversion, when INTERNAL_SYSCALL_NOSYSENTER is defined - -csu/libc-tls.c: Use the no-sysenter version of sbrk when -INTERNAL_SYSCALL_NOSYSENTER is defined. - -misc/sbrk.c: Define a no-sysenter version of sbrk, using the no-sysenter -version of brk - if INTERNAL_SYSCALL_NOSYSENTER is defined. - -misc/brk.c: Define a no-sysenter version of brk if -INTERNAL_SYSCALL_NOSYSENTER is defined. - -sysdeps/unix/sysv/linux/i386/sysdep.h: Define INTERNAL_SYSCALL_NOSYSENTER -Make INTERNAL_SYSCALL always use the PIC variant, even if not SHARED. - -Patch by Kevin F. Quinn -Fixed for 2.10 by Magnus Granberg -Fixed for 2.18 by Magnus Granberg - ---- csu/libc-start.c -+++ csu/libc-start.c -@@ -28,6 +28,7 @@ - extern int __libc_multiple_libcs; - - #include -+#include - #ifndef SHARED - # include - extern void __pthread_initialize_minimal (void); -@@ -170,7 +170,11 @@ LIBC_START_MAIN (int (*main) (int, char - GL(dl_phnum) = __ehdr_start.e_phnum; - } - } -- -+# ifdef INTERNAL_SYSCALL_NOSYSENTER -+ /* Do the initial TLS initialization before _dl_osversion, -+ since the latter uses the uname syscall. */ -+ __pthread_initialize_minimal (); -+# endif - # ifdef DL_SYSDEP_OSCHECK - if (!__libc_multiple_libcs) - { -@@ -138,10 +144,12 @@ - } - # endif - -+# ifndef INTERNAL_SYSCALL_NOSYSENTER - /* Initialize the thread library at least a bit since the libgcc - functions are using thread functions if these are available and - we need to setup errno. */ - __pthread_initialize_minimal (); -+# endif - - /* Set up the stack checker's canary. */ - uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (); ---- csu/libc-tls.c -+++ csu/libc-tls.c -@@ -22,14 +22,17 @@ - #include - #include - #include -- -+#include - - #ifdef SHARED - #error makefile bug, this file is for static only - #endif - --dtv_t _dl_static_dtv[2 + TLS_SLOTINFO_SURPLUS]; -+#ifdef INTERNAL_SYSCALL_NOSYSENTER -+extern void *__sbrk_nosysenter (intptr_t __delta); -+#endif - -+dtv_t _dl_static_dtv[2 + TLS_SLOTINFO_SURPLUS]; - - static struct - { -@@ -139,14 +142,26 @@ __libc_setup_tls (size_t tcbsize, size_t - - The initialized value of _dl_tls_static_size is provided by dl-open.c - to request some surplus that permits dynamic loading of modules with -- IE-model TLS. */ -+ IE-model TLS. -+ -+ Where the normal sbrk would use a syscall that needs the TLS (i386) -+ use the special non-sysenter version instead. */ - #if TLS_TCB_AT_TP - tcb_offset = roundup (memsz + GL(dl_tls_static_size), tcbalign); -+# ifdef INTERNAL_SYSCALL_NOSYSENTER -+ tlsblock = __sbrk_nosysenter (tcb_offset + tcbsize + max_align); -+# else - tlsblock = __sbrk (tcb_offset + tcbsize + max_align); -+#endif - #elif TLS_DTV_AT_TP - tcb_offset = roundup (tcbsize, align ?: 1); -+# ifdef INTERNAL_SYSCALL_NOSYSENTER -+ tlsblock = __sbrk_nosysenter (tcb_offset + memsz + max_align -+ + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size)); -+# else - tlsblock = __sbrk (tcb_offset + memsz + max_align - + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size)); -+#endif - tlsblock += TLS_PRE_TCB_SIZE; - #else - /* In case a model with a different layout for the TCB and DTV ---- misc/sbrk.c -+++ misc/sbrk.c -@@ -18,6 +18,7 @@ - #include - #include - #include -+#include - - /* Defined in brk.c. */ - extern void *__curbrk; -@@ -29,6 +30,35 @@ - /* Extend the process's data space by INCREMENT. - If INCREMENT is negative, shrink data space by - INCREMENT. - Return start of new space allocated, or -1 for errors. */ -+#ifdef INTERNAL_SYSCALL_NOSYSENTER -+/* This version is used by csu/libc-tls.c whem initialising the TLS -+ if the SYSENTER version requires the TLS (which it does on i386). -+ Obviously using the TLS before it is initialised is broken. */ -+extern int __brk_nosysenter (void *addr); -+void * -+__sbrk_nosysenter (intptr_t increment) -+{ -+ void *oldbrk; -+ -+ /* If this is not part of the dynamic library or the library is used -+ via dynamic loading in a statically linked program update -+ __curbrk from the kernel's brk value. That way two separate -+ instances of __brk and __sbrk can share the heap, returning -+ interleaved pieces of it. */ -+ if (__curbrk == NULL || __libc_multiple_libcs) -+ if (__brk_nosysenter (0) < 0) /* Initialize the break. */ -+ return (void *) -1; -+ -+ if (increment == 0) -+ return __curbrk; -+ -+ oldbrk = __curbrk; -+ if (__brk_nosysenter (oldbrk + increment) < 0) -+ return (void *) -1; -+ -+ return oldbrk; -+} -+#endif - void * - __sbrk (intptr_t increment) - { ---- sysdeps/unix/sysv/linux/i386/brk.c -+++ sysdeps/unix/sysv/linux/i386/brk.c -@@ -31,6 +31,29 @@ - linker. */ - weak_alias (__curbrk, ___brk_addr) - -+#ifdef INTERNAL_SYSCALL_NOSYSENTER -+/* This version is used by csu/libc-tls.c whem initialising the TLS -+ * if the SYSENTER version requires the TLS (which it does on i386). -+ * Obviously using the TLS before it is initialised is broken. */ -+int -+__brk_nosysenter (void *addr) -+{ -+ void * newbrk; -+ -+ INTERNAL_SYSCALL_DECL (err); -+ newbrk = (void *) INTERNAL_SYSCALL_NOSYSENTER (brk, err, 1, addr); -+ -+ __curbrk = newbrk; -+ -+ if (newbrk < addr) -+ { -+ __set_errno (ENOMEM); -+ return -1; -+ } -+ -+ return 0; -+} -+#endif - int - __brk (void *addr) - { ---- sysdeps/unix/sysv/linux/i386/sysdep.h -+++ sysdeps/unix/sysv/linux/i386/sysdep.h -@@ -187,7 +187,7 @@ - /* The original calling convention for system calls on Linux/i386 is - to use int $0x80. */ - #ifdef I386_USE_SYSENTER --# ifdef SHARED -+# if defined SHARED || defined __PIC__ - # define ENTER_KERNEL call *%gs:SYSINFO_OFFSET - # else - # define ENTER_KERNEL call *_dl_sysinfo -@@ -358,7 +358,7 @@ - possible to use more than four parameters. */ - #undef INTERNAL_SYSCALL - #ifdef I386_USE_SYSENTER --# ifdef SHARED -+# if defined SHARED || defined __PIC__ - # define INTERNAL_SYSCALL(name, err, nr, args...) \ - ({ \ - register unsigned int resultvar; \ -@@ -384,6 +384,18 @@ - : "0" (name), "i" (offsetof (tcbhead_t, sysinfo)) \ - ASMFMT_##nr(args) : "memory", "cc"); \ - (int) resultvar; }) -+# define INTERNAL_SYSCALL_NOSYSENTER(name, err, nr, args...) \ -+ ({ \ -+ register unsigned int resultvar; \ -+ EXTRAVAR_##nr \ -+ asm volatile ( \ -+ LOADARGS_NOSYSENTER_##nr \ -+ "movl %1, %%eax\n\t" \ -+ "int $0x80\n\t" \ -+ RESTOREARGS_NOSYSENTER_##nr \ -+ : "=a" (resultvar) \ -+ : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc"); \ -+ (int) resultvar; }) - # else - # define INTERNAL_SYSCALL(name, err, nr, args...) \ - ({ \ -@@ -447,12 +459,20 @@ - - #define LOADARGS_0 - #ifdef __PIC__ --# if defined I386_USE_SYSENTER && defined SHARED -+# if defined I386_USE_SYSENTER && ( defined SHARED || defined __PIC__ ) - # define LOADARGS_1 \ - "bpushl .L__X'%k3, %k3\n\t" - # define LOADARGS_5 \ - "movl %%ebx, %4\n\t" \ - "movl %3, %%ebx\n\t" -+# define LOADARGS_NOSYSENTER_1 \ -+ "bpushl .L__X'%k2, %k2\n\t" -+# define LOADARGS_NOSYSENTER_2 LOADARGS_NOSYSENTER_1 -+# define LOADARGS_NOSYSENTER_3 LOADARGS_3 -+# define LOADARGS_NOSYSENTER_4 LOADARGS_3 -+# define LOADARGS_NOSYSENTER_5 \ -+ "movl %%ebx, %3\n\t" \ -+ "movl %2, %%ebx\n\t" - # else - # define LOADARGS_1 \ - "bpushl .L__X'%k2, %k2\n\t" -@@ -474,11 +495,18 @@ - - #define RESTOREARGS_0 - #ifdef __PIC__ --# if defined I386_USE_SYSENTER && defined SHARED -+# if defined I386_USE_SYSENTER && ( defined SHARED || defined __PIC__ ) - # define RESTOREARGS_1 \ - "bpopl .L__X'%k3, %k3\n\t" - # define RESTOREARGS_5 \ - "movl %4, %%ebx" -+# define RESTOREARGS_NOSYSENTER_1 \ -+ "bpopl .L__X'%k2, %k2\n\t" -+# define RESTOREARGS_NOSYSENTER_2 RESTOREARGS_NOSYSENTER_1 -+# define RESTOREARGS_NOSYSENTER_3 RESTOREARGS_3 -+# define RESTOREARGS_NOSYSENTER_4 RESTOREARGS_3 -+# define RESTOREARGS_NOSYSENTER_5 \ -+ "movl %3, %%ebx" - # else - # define RESTOREARGS_1 \ - "bpopl .L__X'%k2, %k2\n\t" diff --git a/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-chk_fail.c b/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-chk_fail.c deleted file mode 100644 index a8ab9d8a3e29..000000000000 --- a/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-chk_fail.c +++ /dev/null @@ -1,299 +0,0 @@ -/* Copyright (C) 2004-2014 Free Software Foundation, Inc. - Copyright (C) 2006-2014 Gentoo Foundation Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -/* Hardened Gentoo SSP and FORTIFY handler - - A failure handler that does not use functions from the rest of glibc; - it uses the INTERNAL_SYSCALL methods directly. This helps ensure no - possibility of recursion into the handler. - - Direct all bug reports to http://bugs.gentoo.org/ - - People who have contributed significantly to the evolution of this file: - Ned Ludd - - Alexander Gabert - - The PaX Team - - Peter S. Mazinger - - Yoann Vandoorselaere - - Robert Connolly - - Cory Visi - Mike Frysinger - Magnus Granberg - Kevin F. Quinn - - */ - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include -/* from sysdeps */ -#include -/* for the stuff in bits/socket.h */ -#include -#include - -/* Sanity check on SYSCALL macro names - force compilation - * failure if the names used here do not exist - */ -#if !defined __NR_socketcall && !defined __NR_socket -# error Cannot do syscall socket or socketcall -#endif -#if !defined __NR_socketcall && !defined __NR_connect -# error Cannot do syscall connect or socketcall -#endif -#ifndef __NR_write -# error Cannot do syscall write -#endif -#ifndef __NR_close -# error Cannot do syscall close -#endif -#ifndef __NR_getpid -# error Cannot do syscall getpid -#endif -#ifndef __NR_kill -# error Cannot do syscall kill -#endif -#ifndef __NR_exit -# error Cannot do syscall exit -#endif -#ifdef SSP_SMASH_DUMPS_CORE -# define ENABLE_SSP_SMASH_DUMPS_CORE 1 -# if !defined _KERNEL_NSIG && !defined _NSIG -# error No _NSIG or _KERNEL_NSIG for rt_sigaction -# endif -# if !defined __NR_sigaction && !defined __NR_rt_sigaction -# error Cannot do syscall sigaction or rt_sigaction -# endif -/* Although rt_sigaction expects sizeof(sigset_t) - it expects the size - * of the _kernel_ sigset_t which is not the same as the user sigset_t. - * Most arches have this as _NSIG bits - mips has _KERNEL_NSIG bits for - * some reason. - */ -# ifdef _KERNEL_NSIG -# define _SSP_NSIG _KERNEL_NSIG -# else -# define _SSP_NSIG _NSIG -# endif -#else -# define _SSP_NSIG 0 -# define ENABLE_SSP_SMASH_DUMPS_CORE 0 -#endif - -/* Define DO_SIGACTION - default to newer rt signal interface but - * fallback to old as needed. - */ -#ifdef __NR_rt_sigaction -# define DO_SIGACTION(signum, act, oldact) \ - INLINE_SYSCALL(rt_sigaction, 4, signum, act, oldact, _SSP_NSIG/8) -#else -# define DO_SIGACTION(signum, act, oldact) \ - INLINE_SYSCALL(sigaction, 3, signum, act, oldact) -#endif - -/* Define DO_SOCKET/DO_CONNECT functions to deal with socketcall vs socket/connect */ -#if defined(__NR_socket) && defined(__NR_connect) -# define USE_OLD_SOCKETCALL 0 -#else -# define USE_OLD_SOCKETCALL 1 -#endif - -/* stub out the __NR_'s so we can let gcc optimize away dead code */ -#ifndef __NR_socketcall -# define __NR_socketcall 0 -#endif -#ifndef __NR_socket -# define __NR_socket 0 -#endif -#ifndef __NR_connect -# define __NR_connect 0 -#endif -#define DO_SOCKET(result, domain, type, protocol) \ - do { \ - if (USE_OLD_SOCKETCALL) { \ - socketargs[0] = domain; \ - socketargs[1] = type; \ - socketargs[2] = protocol; \ - socketargs[3] = 0; \ - result = INLINE_SYSCALL(socketcall, 2, SOCKOP_socket, socketargs); \ - } else \ - result = INLINE_SYSCALL(socket, 3, domain, type, protocol); \ - } while (0) -#define DO_CONNECT(result, sockfd, serv_addr, addrlen) \ - do { \ - if (USE_OLD_SOCKETCALL) { \ - socketargs[0] = sockfd; \ - socketargs[1] = (unsigned long int)serv_addr; \ - socketargs[2] = addrlen; \ - socketargs[3] = 0; \ - result = INLINE_SYSCALL(socketcall, 2, SOCKOP_connect, socketargs); \ - } else \ - result = INLINE_SYSCALL(connect, 3, sockfd, serv_addr, addrlen); \ - } while (0) - -#ifndef _PATH_LOG -# define _PATH_LOG "/dev/log" -#endif - -static const char path_log[] = _PATH_LOG; - -/* For building glibc with SSP switched on, define __progname to a - * constant if building for the run-time loader, to avoid pulling - * in more of libc.so into ld.so - */ -#ifdef IS_IN_rtld -static const char *__progname = ""; -#else -extern const char *__progname; -#endif - -#ifdef GENTOO_SSP_HANDLER -# define ERROR_MSG "stack smashing" -#else -# define ERROR_MSG "buffer overflow" -#endif - -/* Common handler code, used by chk_fail - * Inlined to ensure no self-references to the handler within itself. - * Data static to avoid putting more than necessary on the stack, - * to aid core debugging. - */ -__attribute__ ((__noreturn__, __always_inline__)) -static inline void -__hardened_gentoo_fail(void) -{ -#define MESSAGE_BUFSIZ 512 - static pid_t pid; - static int plen, i, hlen; - static char message[MESSAGE_BUFSIZ]; - /* <11> is LOG_USER|LOG_ERR. A dummy date for loggers to skip over. */ - static const char msg_header[] = "<11>" __DATE__ " " __TIME__ " glibc-gentoo-hardened-check: "; - static const char msg_ssd[] = "*** " ERROR_MSG " detected ***: "; - static const char msg_terminated[] = " terminated; "; - static const char msg_report[] = "report to " REPORT_BUGS_TO "\n"; - static const char msg_unknown[] = ""; - static int log_socket, connect_result; - static struct sockaddr_un sock; - static unsigned long int socketargs[4]; - - /* Build socket address */ - sock.sun_family = AF_UNIX; - i = 0; - while (path_log[i] != '\0' && i < sizeof(sock.sun_path) - 1) { - sock.sun_path[i] = path_log[i]; - ++i; - } - sock.sun_path[i] = '\0'; - - /* Try SOCK_DGRAM connection to syslog */ - connect_result = -1; - DO_SOCKET(log_socket, AF_UNIX, SOCK_DGRAM, 0); - if (log_socket != -1) - DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock)); - if (connect_result == -1) { - if (log_socket != -1) - INLINE_SYSCALL(close, 1, log_socket); - /* Try SOCK_STREAM connection to syslog */ - DO_SOCKET(log_socket, AF_UNIX, SOCK_STREAM, 0); - if (log_socket != -1) - DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock)); - } - - /* Build message. Messages are generated both in the old style and new style, - * so that log watchers that are configured for the old-style message continue - * to work. - */ -#define strconcat(str) \ - ({ \ - i = 0; \ - while ((str[i] != '\0') && ((i + plen) < (MESSAGE_BUFSIZ - 1))) { \ - message[plen + i] = str[i]; \ - ++i; \ - } \ - plen += i; \ - }) - - /* Tersely log the failure */ - plen = 0; - strconcat(msg_header); - hlen = plen; - strconcat(msg_ssd); - if (__progname != NULL) - strconcat(__progname); - else - strconcat(msg_unknown); - strconcat(msg_terminated); - strconcat(msg_report); - - /* Write out error message to STDERR, to syslog if open */ - INLINE_SYSCALL(write, 3, STDERR_FILENO, message + hlen, plen - hlen); - if (connect_result != -1) { - INLINE_SYSCALL(write, 3, log_socket, message, plen); - INLINE_SYSCALL(close, 1, log_socket); - } - - /* Time to kill self since we have no idea what is going on */ - pid = INLINE_SYSCALL(getpid, 0); - - if (ENABLE_SSP_SMASH_DUMPS_CORE) { - /* Remove any user-supplied handler for SIGABRT, before using it. */ -#if 0 - /* - * Note: Disabled because some programs catch & process their - * own crashes. We've already enabled this code path which - * means we want to let core dumps happen. - */ - static struct sigaction default_abort_act; - default_abort_act.sa_handler = SIG_DFL; - default_abort_act.sa_sigaction = NULL; - __sigfillset(&default_abort_act.sa_mask); - default_abort_act.sa_flags = 0; - if (DO_SIGACTION(SIGABRT, &default_abort_act, NULL) == 0) -#endif - INLINE_SYSCALL(kill, 2, pid, SIGABRT); - } - - /* SIGKILL is only signal which cannot be caught */ - INLINE_SYSCALL(kill, 2, pid, SIGKILL); - - /* In case the kill didn't work, exit anyway. - * The loop prevents gcc thinking this routine returns. - */ - while (1) - INLINE_SYSCALL(exit, 1, 137); -} - -__attribute__ ((__noreturn__)) -#ifdef GENTOO_SSP_HANDLER -void __stack_chk_fail(void) -#else -void __chk_fail(void) -#endif -{ - __hardened_gentoo_fail(); -} diff --git a/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-stack_chk_fail.c b/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-stack_chk_fail.c deleted file mode 100644 index 4a537bb52c5f..000000000000 --- a/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-stack_chk_fail.c +++ /dev/null @@ -1,2 +0,0 @@ -#define GENTOO_SSP_HANDLER -#include diff --git a/sys-libs/glibc/files/2.20/glibc-2.20-hardened-inittls-nosysenter.patch b/sys-libs/glibc/files/2.20/glibc-2.20-hardened-inittls-nosysenter.patch deleted file mode 100644 index 35eabe94014a..000000000000 --- a/sys-libs/glibc/files/2.20/glibc-2.20-hardened-inittls-nosysenter.patch +++ /dev/null @@ -1,306 +0,0 @@ -When building glibc PIE (which is not something upstream support), -several modifications are necessary to the glibc build process. - -First, any syscalls in PIEs must be of the PIC variant, otherwise -textrels ensue. Then, any syscalls made before the initialisation -of the TLS will fail on i386, as the sysenter variant on i386 uses -the TLS, giving rise to a chicken-and-egg situation. This patch -defines a PIC syscall variant that doesn't use sysenter, even when the sysenter -version is normally used, and uses the non-sysenter version for the brk -syscall that is performed by the TLS initialisation. Further, the TLS -initialisation is moved in this case prior to the initialisation of -dl_osversion, as that requires further syscalls. - -csu/libc-start.c: Move initial TLS initialization to before the -initialisation of dl_osversion, when INTERNAL_SYSCALL_PRE_TLS is defined - -csu/libc-tls.c: Use the no-sysenter version of sbrk when -INTERNAL_SYSCALL_PRE_TLS is defined. - -misc/sbrk.c: Define a no-sysenter version of sbrk, using the no-sysenter -version of brk - if INTERNAL_SYSCALL_PRE_TLS is defined. - -misc/brk.c: Define a no-sysenter version of brk if -INTERNAL_SYSCALL_PRE_TLS is defined. - -sysdeps/unix/sysv/linux/i386/sysdep.h: Define INTERNAL_SYSCALL_PRE_TLS -Make INTERNAL_SYSCALL always use the PIC variant, even if not SHARED. - -Patch by Kevin F. Quinn -Fixed for 2.10 by Magnus Granberg -Fixed for 2.18 by Magnus Granberg -Fixed for 2.20 by Francisco Blas Izquierdo Riera - ---- a/csu/libc-start.c -+++ b/csu/libc-start.c -@@ -28,6 +28,7 @@ - extern int __libc_multiple_libcs; - - #include -+#include - #ifndef SHARED - # include - extern void __pthread_initialize_minimal (void); -@@ -170,6 +171,11 @@ LIBC_START_MAIN (int (*main) (int, char - } - } - -+# ifdef INTERNAL_SYSCALL_PRE_TLS -+ /* Do the initial TLS initialization before _dl_osversion, -+ since the latter uses the uname syscall. */ -+ __pthread_initialize_minimal (); -+# endif - # ifdef DL_SYSDEP_OSCHECK - if (!__libc_multiple_libcs) - { -@@ -138,10 +144,12 @@ - } - # endif - -+# ifndef INTERNAL_SYSCALL_PRE_TLS - /* Initialize the thread library at least a bit since the libgcc - functions are using thread functions if these are available and - we need to setup errno. */ - __pthread_initialize_minimal (); -+# endif - - /* Set up the stack checker's canary. */ - uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (); ---- a/csu/libc-tls.c -+++ b/csu/libc-tls.c -@@ -22,12 +22,17 @@ - #include - #include - #include -+#include - - - #ifdef SHARED - #error makefile bug, this file is for static only - #endif - -+#ifdef INTERNAL_SYSCALL_PRE_TLS -+extern void *__sbrk_nosysenter (intptr_t __delta); -+#endif -+ - dtv_t _dl_static_dtv[2 + TLS_SLOTINFO_SURPLUS]; - - -@@ -139,20 +144,29 @@ __libc_setup_tls (size_t tcbsize, size_t - - The initialized value of _dl_tls_static_size is provided by dl-open.c - to request some surplus that permits dynamic loading of modules with -- IE-model TLS. */ -+ IE-model TLS. -+ -+ Where the normal sbrk would use a syscall that needs the TLS (i386) -+ use the special non-sysenter version instead. */ -+#ifdef INTERNAL_SYSCALL_PRE_TLS -+# define __sbrk __sbrk_nosysenter -+#endif - #if TLS_TCB_AT_TP - tcb_offset = roundup (memsz + GL(dl_tls_static_size), tcbalign); - tlsblock = __sbrk (tcb_offset + tcbsize + max_align); - #elif TLS_DTV_AT_TP - tcb_offset = roundup (tcbsize, align ?: 1); - tlsblock = __sbrk (tcb_offset + memsz + max_align - + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size)); - tlsblock += TLS_PRE_TCB_SIZE; - #else - /* In case a model with a different layout for the TCB and DTV - is defined add another #elif here and in the following #ifs. */ - # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" - #endif -+#ifdef INTERNAL_SYSCALL_PRE_TLS -+# undef __sbrk -+#endif - - /* Align the TLS block. */ - tlsblock = (void *) (((uintptr_t) tlsblock + max_align - 1) ---- a/misc/sbrk.c -+++ b/misc/sbrk.c -@@ -18,6 +18,7 @@ - #include - #include - #include -+#include - - /* Defined in brk.c. */ - extern void *__curbrk; -@@ -29,6 +30,35 @@ - /* Extend the process's data space by INCREMENT. - If INCREMENT is negative, shrink data space by - INCREMENT. - Return start of new space allocated, or -1 for errors. */ -+#ifdef INTERNAL_SYSCALL_PRE_TLS -+/* This version is used by csu/libc-tls.c whem initialising the TLS -+ if the SYSENTER version requires the TLS (which it does on i386). -+ Obviously using the TLS before it is initialised is broken. */ -+extern int __brk_nosysenter (void *addr); -+void * -+__sbrk_nosysenter (intptr_t increment) -+{ -+ void *oldbrk; -+ -+ /* If this is not part of the dynamic library or the library is used via -+ dynamic loading in a statically linked program update __curbrk from the -+ kernel's brk value. That way two separate instances of __brk and __sbrk -+ can share the heap, returning interleaved pieces of it. */ -+ if (__curbrk == NULL || __libc_multiple_libcs) -+ if (__brk_nosysenter (0) < 0) /* Initialize the break. */ -+ return (void *) -1; -+ -+ if (increment == 0) -+ return __curbrk; -+ -+ oldbrk = __curbrk; -+ if (__brk_nosysenter (oldbrk + increment) < 0) -+ return (void *) -1; -+ -+ return oldbrk; -+} -+#endif -+ - void * - __sbrk (intptr_t increment) - { ---- a/sysdeps/unix/sysv/linux/i386/brk.c -+++ b/sysdeps/unix/sysv/linux/i386/brk.c -@@ -31,6 +31,30 @@ - linker. */ - weak_alias (__curbrk, ___brk_addr) - -+#ifdef INTERNAL_SYSCALL_PRE_TLS -+/* This version is used by csu/libc-tls.c whem initialising the TLS -+ if the SYSENTER version requires the TLS (which it does on i386). -+ Obviously using the TLS before it is initialised is broken. */ -+int -+__brk_nosysenter (void *addr) -+{ -+ void *newbrk; -+ -+ INTERNAL_SYSCALL_DECL (err); -+ newbrk = (void *) INTERNAL_SYSCALL_PRE_TLS (brk, err, 1, addr); -+ -+ __curbrk = newbrk; -+ -+ if (newbrk < addr) -+ { -+ __set_errno (ENOMEM); -+ return -1; -+ } -+ -+ return 0; -+} -+#endif -+ - int - __brk (void *addr) - { ---- a/sysdeps/unix/sysv/linux/i386/sysdep.h -+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h -@@ -187,7 +187,7 @@ - /* The original calling convention for system calls on Linux/i386 is - to use int $0x80. */ - #ifdef I386_USE_SYSENTER --# ifdef SHARED -+# ifdef __PIC__ - # define ENTER_KERNEL call *%gs:SYSINFO_OFFSET - # else - # define ENTER_KERNEL call *_dl_sysinfo -@@ -358,7 +358,7 @@ - possible to use more than four parameters. */ - #undef INTERNAL_SYSCALL - #ifdef I386_USE_SYSENTER --# ifdef SHARED -+# ifdef __PIC__ - # define INTERNAL_SYSCALL(name, err, nr, args...) \ - ({ \ - register unsigned int resultvar; \ -@@ -384,6 +384,18 @@ - : "0" (name), "i" (offsetof (tcbhead_t, sysinfo)) \ - ASMFMT_##nr(args) : "memory", "cc"); \ - (int) resultvar; }) -+# define INTERNAL_SYSCALL_PRE_TLS(name, err, nr, args...) \ -+ ({ \ -+ register unsigned int resultvar; \ -+ EXTRAVAR_##nr \ -+ asm volatile ( \ -+ LOADARGS_NOSYSENTER_##nr \ -+ "movl %1, %%eax\n\t" \ -+ "int $0x80\n\t" \ -+ RESTOREARGS_NOSYSENTER_##nr \ -+ : "=a" (resultvar) \ -+ : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc"); \ -+ (int) resultvar; }) - # else - # define INTERNAL_SYSCALL(name, err, nr, args...) \ - ({ \ -@@ -447,12 +459,20 @@ - - #define LOADARGS_0 - #ifdef __PIC__ --# if defined I386_USE_SYSENTER && defined SHARED -+# if defined I386_USE_SYSENTER && defined __PIC__ - # define LOADARGS_1 \ - "bpushl .L__X'%k3, %k3\n\t" - # define LOADARGS_5 \ - "movl %%ebx, %4\n\t" \ - "movl %3, %%ebx\n\t" -+# define LOADARGS_NOSYSENTER_1 \ -+ "bpushl .L__X'%k2, %k2\n\t" -+# define LOADARGS_NOSYSENTER_2 LOADARGS_NOSYSENTER_1 -+# define LOADARGS_NOSYSENTER_3 LOADARGS_3 -+# define LOADARGS_NOSYSENTER_4 LOADARGS_3 -+# define LOADARGS_NOSYSENTER_5 \ -+ "movl %%ebx, %3\n\t" \ -+ "movl %2, %%ebx\n\t" - # else - # define LOADARGS_1 \ - "bpushl .L__X'%k2, %k2\n\t" -@@ -474,11 +494,18 @@ - - #define RESTOREARGS_0 - #ifdef __PIC__ --# if defined I386_USE_SYSENTER && defined SHARED -+# if defined I386_USE_SYSENTER && defined __PIC__ - # define RESTOREARGS_1 \ - "bpopl .L__X'%k3, %k3\n\t" - # define RESTOREARGS_5 \ - "movl %4, %%ebx" -+# define RESTOREARGS_NOSYSENTER_1 \ -+ "bpopl .L__X'%k2, %k2\n\t" -+# define RESTOREARGS_NOSYSENTER_2 RESTOREARGS_NOSYSENTER_1 -+# define RESTOREARGS_NOSYSENTER_3 RESTOREARGS_3 -+# define RESTOREARGS_NOSYSENTER_4 RESTOREARGS_3 -+# define RESTOREARGS_NOSYSENTER_5 \ -+ "movl %3, %%ebx" - # else - # define RESTOREARGS_1 \ - "bpopl .L__X'%k2, %k2\n\t" ---- a/sysdeps/i386/nptl/tls.h -+++ b/sysdeps/i386/nptl/tls.h -@@ -189,6 +189,15 @@ - desc->vals[3] = 0x51; - } - -+/* We have no sysenter until the tls is initialized which is a -+ problem for PIC. Thus we need to do the right call depending -+ on the situation. */ -+#ifndef INTERNAL_SYSCALL_PRE_TLS -+# define TLS_INIT_SYSCALL INTERNAL_SYSCALL -+#else -+# define TLS_INIT_SYSCALL INTERNAL_SYSCALL_PRE_TLS -+#endif -+ - /* Code to initially initialize the thread pointer. This might need - special attention since 'errno' is not yet available and if the - operation can cause a failure 'errno' must not be touched. */ -@@ -209,7 +218,7 @@ - \ - /* Install the TLS. */ \ - INTERNAL_SYSCALL_DECL (err); \ -- _result = INTERNAL_SYSCALL (set_thread_area, err, 1, &_segdescr.desc); \ -+ _result = TLS_INIT_SYSCALL (set_thread_area, err, 1, &_segdescr.desc); \ - \ - if (_result == 0) \ - /* We know the index in the GDT, now load the segment register. \ diff --git a/sys-libs/glibc/glibc-2.21-r2.ebuild b/sys-libs/glibc/glibc-2.21-r2.ebuild deleted file mode 100644 index accbd33c95a3..000000000000 --- a/sys-libs/glibc/glibc-2.21-r2.ebuild +++ /dev/null @@ -1,149 +0,0 @@ -# Copyright 1999-2018 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -EAPI="4" - -inherit toolchain-glibc - -DESCRIPTION="GNU libc6 (also called glibc2) C library" -HOMEPAGE="https://www.gnu.org/software/libc/libc.html" - -LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE" -KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86" -RESTRICT="strip" # strip ourself #46186 -EMULTILIB_PKG="true" - -# Configuration variables -RELEASE_VER="" -case ${PV} in -9999*) - EGIT_REPO_URIS="git://sourceware.org/git/glibc.git" - inherit git-r3 - ;; -*) - RELEASE_VER=${PV} - ;; -esac -GCC_BOOTSTRAP_VER="4.7.3-r1" -PATCH_VER="7" # Gentoo patchset -: ${NPTL_KERN_VER:="2.6.32"} # min kernel version nptl requires - -IUSE="debug gd hardened multilib nscd selinux systemtap profile suid vanilla headers-only" - -# Here's how the cross-compile logic breaks down ... -# CTARGET - machine that will target the binaries -# CHOST - machine that will host the binaries -# CBUILD - machine that will build the binaries -# If CTARGET != CHOST, it means you want a libc for cross-compiling. -# If CHOST != CBUILD, it means you want to cross-compile the libc. -# CBUILD = CHOST = CTARGET - native build/install -# CBUILD != (CHOST = CTARGET) - cross-compile a native build -# (CBUILD = CHOST) != CTARGET - libc for cross-compiler -# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler -# For install paths: -# CHOST = CTARGET - install into / -# CHOST != CTARGET - install into /usr/CTARGET/ - -export CBUILD=${CBUILD:-${CHOST}} -export CTARGET=${CTARGET:-${CHOST}} -if [[ ${CTARGET} == ${CHOST} ]] ; then - if [[ ${CATEGORY} == cross-* ]] ; then - export CTARGET=${CATEGORY#cross-} - fi -fi - -is_crosscompile() { - [[ ${CHOST} != ${CTARGET} ]] -} - -# Why SLOT 2.2 you ask yourself while sippin your tea ? -# Everyone knows 2.2 > 0, duh. -SLOT="2.2" - -# General: We need a new-enough binutils/gcc to match upstream baseline. -# arch: we need to make sure our binutils/gcc supports TLS. -DEPEND=">=app-misc/pax-utils-0.1.10 - !' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h') - ALT_BUILD_HEADERS=${header_path%/linux/version.h} - fi - fi - fi - echo "${ALT_BUILD_HEADERS}" -} - -alt_libdir() { - echo $(alt_prefix)/$(get_libdir) -} -alt_usrlibdir() { - echo $(alt_prefix)/usr/$(get_libdir) -} - -builddir() { - echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1" -} - -do_compile_test() { - local ret save_cflags=${CFLAGS} - CFLAGS+=" $1" - shift - - pushd "${T}" >/dev/null - - rm -f glibc-test* - printf '%b' "$*" > glibc-test.c - - nonfatal emake -s glibc-test - ret=$? - - popd >/dev/null - - CFLAGS=${save_cflags} - return ${ret} -} - -do_run_test() { - local ret - - if [[ ${MERGE_TYPE} == "binary" ]] ; then - # ignore build failures when installing a binary package #324685 - do_compile_test "" "$@" 2>/dev/null || return 0 - else - if ! do_compile_test "" "$@" ; then - ewarn "Simple build failed ... assuming this is desired #324685" - return 0 - fi - fi - - pushd "${T}" >/dev/null - - ./glibc-test - ret=$? - rm -f glibc-test* - - popd >/dev/null - - return ${ret} -} - -setup_target_flags() { - # This largely mucks with compiler flags. None of which should matter - # when building up just the headers. - just_headers && return 0 - - case $(tc-arch) in - x86) - # -march needed for #185404 #199334 - # TODO: When creating the first glibc cross-compile, this test will - # always fail as it does a full link which in turn requires glibc. - # Probably also applies when changing multilib profile settings (e.g. - # enabling x86 when the profile was amd64-only previously). - # We could change main to _start and pass -nostdlib here so that we - # only test the gcc code compilation. Or we could do a compile and - # then look for the symbol via scanelf. - if ! do_compile_test "" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then - local t=${CTARGET_OPT:-${CTARGET}} - t=${t%%-*} - filter-flags '-march=*' - export CFLAGS="-march=${t} ${CFLAGS}" - einfo "Auto adding -march=${t} to CFLAGS #185404" - fi - ;; - amd64) - # -march needed for #185404 #199334 - # Note: This test only matters when the x86 ABI is enabled, so we could - # optimize a bit and elide it. - # TODO: See cross-compile issues listed above for x86. - if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then - local t=${CTARGET_OPT:-${CTARGET}} - t=${t%%-*} - # Normally the target is x86_64-xxx, so turn that into the -march that - # gcc actually accepts. #528708 - [[ ${t} == "x86_64" ]] && t="x86-64" - filter-flags '-march=*' - # ugly, ugly, ugly. ugly. - CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") - export CFLAGS_x86="${CFLAGS_x86} -march=${t}" - einfo "Auto adding -march=${t} to CFLAGS_x86 #185404" - fi - ;; - mips) - # The mips abi cannot support the GNU style hashes. #233233 - filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both - ;; - sparc) - # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though. - filter-flags "-fcall-used-g7" - append-flags "-fcall-used-g6" - - # If the CHOST is the basic one (e.g. not sparcv9-xxx already), - # try to pick a better one so glibc can use cpu-specific .S files. - # We key off the CFLAGS to get a good value. Also need to handle - # version skew. - # We can't force users to set their CHOST to their exact machine - # as many of these are not recognized by config.sub/gcc and such :(. - # Note: If the mcpu values don't scale, we might try probing CPP defines. - # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ? - - local cpu - case ${CTARGET} in - sparc64-*) - case $(get-flag mcpu) in - niagara[234]) - if ver_test -ge 2.8 ; then - cpu="sparc64v2" - elif ver_test -ge 2.4 ; then - cpu="sparc64v" - elif ver_test -ge 2.2.3 ; then - cpu="sparc64b" - fi - ;; - niagara) - if ver_test -ge 2.4 ; then - cpu="sparc64v" - elif ver_test -ge 2.2.3 ; then - cpu="sparc64b" - fi - ;; - ultrasparc3) - cpu="sparc64b" - ;; - *) - # We need to force at least v9a because the base build doesn't - # work with just v9. - # https://sourceware.org/bugzilla/show_bug.cgi?id=19477 - [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a" - ;; - esac - ;; - sparc-*) - case $(get-flag mcpu) in - niagara[234]) - if ver_test -ge 2.8 ; then - cpu="sparcv9v2" - elif ver_test -ge 2.4 ; then - cpu="sparcv9v" - elif ver_test -ge 2.2.3 ; then - cpu="sparcv9b" - else - cpu="sparcv9" - fi - ;; - niagara) - if ver_test -ge 2.4 ; then - cpu="sparcv9v" - elif ver_test -ge 2.2.3 ; then - cpu="sparcv9b" - else - cpu="sparcv9" - fi - ;; - ultrasparc3) - cpu="sparcv9b" - ;; - v9|ultrasparc) - cpu="sparcv9" - ;; - v8|supersparc|hypersparc|leon|leon3) - cpu="sparcv8" - ;; - esac - ;; - esac - [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}" - ;; - esac -} - -setup_flags() { - # Make sure host make.conf doesn't pollute us - if is_crosscompile || tc-is-cross-compiler ; then - CHOST=${CTARGET} strip-unsupported-flags - fi - - # Store our CFLAGS because it's changed depending on which CTARGET - # we are building when pulling glibc on a multilib profile - CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}} - CFLAGS=${CFLAGS_BASE} - CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}} - CXXFLAGS=${CXXFLAGS_BASE} - ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}} - ASFLAGS=${ASFLAGS_BASE} - - # Over-zealous CFLAGS can often cause problems. What may work for one - # person may not work for another. To avoid a large influx of bugs - # relating to failed builds, we strip most CFLAGS out to ensure as few - # problems as possible. - strip-flags - strip-unsupported-flags - filter-flags -m32 -m64 '-mabi=*' - - # glibc aborts if rpath is set by LDFLAGS - filter-ldflags '-Wl,-rpath=*' - - # #492892 - filter-flags -frecord-gcc-switches - - unset CBUILD_OPT CTARGET_OPT - if use multilib ; then - CTARGET_OPT=$(get_abi_CTARGET) - [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST) - fi - - setup_target_flags - - if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then - CBUILD_OPT=${CTARGET_OPT} - fi - - # Lock glibc at -O2; we want to be conservative here. - # -fno-strict-aliasing is to work around #155906. - filter-flags '-O?' - append-flags -O2 -fno-strict-aliasing - - filter-flags '-fstack-protector*' -} - -want_tls() { - # Archs that can use TLS (Thread Local Storage) - case $(tc-arch) in - x86) - # requires i486 or better #106556 - [[ ${CTARGET} == i[4567]86* ]] && return 0 - return 1 - ;; - esac - return 0 -} - -want__thread() { - want_tls || return 1 - - # For some reason --with-tls --with__thread is causing segfaults on sparc32. - [[ ${PROFILE_ARCH} == "sparc" ]] && return 1 - - [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD} - - # only test gcc -- can't test linking yet - tc-has-tls -c ${CTARGET} - WANT__THREAD=$? - - return ${WANT__THREAD} -} - -use_multiarch() { - # Allow user to disable runtime arch detection in multilib. - use multiarch || return 1 - # Make sure binutils is new enough to support indirect functions, - # #336792. This funky sed supports gold and bfd linkers. - local bver nver - bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}') - case $(tc-arch ${CTARGET}) in - amd64|x86) nver="2.20" ;; - arm) nver="2.22" ;; - hppa) nver="2.23" ;; - ppc|ppc64) nver="2.20" ;; - # ifunc support was added in 2.23, but glibc also needs - # machinemode which is in 2.24. - s390) nver="2.24" ;; - sparc) nver="2.21" ;; - *) return 1 ;; - esac - ver_test ${bver} -ge ${nver} -} - -# Setup toolchain variables that had historically been defined in the -# profiles for these archs. -setup_env() { - # silly users - unset LD_RUN_PATH - unset LD_ASSUME_KERNEL - - if is_crosscompile || tc-is-cross-compiler ; then - multilib_env ${CTARGET_OPT:-${CTARGET}} - - if ! use multilib ; then - MULTILIB_ABIS=${DEFAULT_ABI} - else - MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}} - fi - - # If the user has CFLAGS_ in their make.conf, use that, - # and fall back on CFLAGS. - local VAR=CFLAGS_${CTARGET//[-.]/_} - CFLAGS=${!VAR-${CFLAGS}} - einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}" - fi - - setup_flags - - export ABI=${ABI:-${DEFAULT_ABI:-default}} - - if just_headers ; then - # Avoid mixing host's CC and target's CFLAGS_${ABI}: - # At this bootstrap stage we have only binutils for - # target but not compiler yet. - einfo "Skip CC ABI injection. We can't use (cross-)compiler yet." - return 0 - fi - local VAR=CFLAGS_${ABI} - # We need to export CFLAGS with abi information in them because glibc's - # configure script checks CFLAGS for some targets (like mips). Keep - # around the original clean value to avoid appending multiple ABIs on - # top of each other. - : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})} - export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}" - einfo " $(printf '%15s' 'Manual CC:') ${CC}" -} - -foreach_abi() { - setup_env - - local ret=0 - local abilist="" - if use multilib ; then - abilist=$(get_install_abis) - else - abilist=${DEFAULT_ABI} - fi - local -x ABI - for ABI in ${abilist:-default} ; do - setup_env - einfo "Running $1 for ABI ${ABI}" - $1 - : $(( ret |= $? )) - done - return ${ret} -} - -glibc_banner() { - local b="Gentoo ${PVR}" - [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}" - echo "${b}" -} - -check_devpts() { - # Make sure devpts is mounted correctly for use w/out setuid pt_chown. - - # If merely building the binary package, then there's nothing to verify. - [[ ${MERGE_TYPE} == "buildonly" ]] && return - - # Only sanity check when installing the native glibc. - [[ ${ROOT} != "/" ]] && return - - # If they're opting in to the old suid code, then no need to check. - use suid && return - - if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then - eerror "In order to use glibc with USE=-suid, you must make sure that" - eerror "you have devpts mounted at /dev/pts with the gid=5 option." - eerror "Openrc should do this for you, so you should check /etc/fstab" - eerror "and make sure you do not have any invalid settings there." - die "mount & fix your /dev/pts settings" - fi -} - -# The following Kernel version handling functions are mostly copied from portage -# source. It's better not to use linux-info.eclass here since a) it adds too -# much magic, see bug 326693 for some of the arguments, and b) some of the -# functions are just not provided. - -g_get_running_KV() { - uname -r - return $? -} - -g_KV_major() { - [[ -z $1 ]] && return 1 - local KV=$@ - echo "${KV%%.*}" -} - -g_KV_minor() { - [[ -z $1 ]] && return 1 - local KV=$@ - KV=${KV#*.} - echo "${KV%%.*}" -} - -g_KV_micro() { - [[ -z $1 ]] && return 1 - local KV=$@ - KV=${KV#*.*.} - echo "${KV%%[^[:digit:]]*}" -} - -g_KV_to_int() { - [[ -z $1 ]] && return 1 - local KV_MAJOR=$(g_KV_major "$1") - local KV_MINOR=$(g_KV_minor "$1") - local KV_MICRO=$(g_KV_micro "$1") - local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO )) - - # We make version 2.2.0 the minimum version we will handle as - # a sanity check ... if its less, we fail ... - if [[ ${KV_int} -ge 131584 ]] ; then - echo "${KV_int}" - return 0 - fi - return 1 -} - -g_int_to_KV() { - local version=$1 major minor micro - major=$((version / 65536)) - minor=$(((version % 65536) / 256)) - micro=$((version % 256)) - echo ${major}.${minor}.${micro} -} - -eend_KV() { - [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]] - eend $? -} - -get_kheader_version() { - printf '#include \nLINUX_VERSION_CODE\n' | \ - $(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" - | \ - tail -n 1 -} - -# We collect all sanity checks here. Consistency is not guranteed between -# pkg_ and src_ phases, so we call this function both in pkg_pretend and in -# src_unpack. -sanity_prechecks() { - # Make sure devpts is mounted correctly for use w/out setuid pt_chown - check_devpts - - # Prevent native builds from downgrading - if [[ ${MERGE_TYPE} != "buildonly" ]] && \ - [[ ${ROOT} == "/" ]] && \ - [[ ${CBUILD} == ${CHOST} ]] && \ - [[ ${CHOST} == ${CTARGET} ]] ; then - - # The high rev # is to allow people to downgrade between -r# - # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2 - # should be fine. Hopefully we never actually use a r# this - # high. - if has_version ">${CATEGORY}/${P}-r10000" ; then - eerror "Sanity check to keep you from breaking your system:" - eerror " Downgrading glibc is not supported and a sure way to destruction." - die "Aborting to save your system." - fi - - if ! do_run_test '#include \n#include \nint main(){return syscall(1000)!=-1;}\n' ; then - eerror "Your old kernel is broken. You need to update it to a newer" - eerror "version as syscall() will break. See bug 279260." - die "Old and broken kernel." - fi - fi - - # Users have had a chance to phase themselves, time to give em the boot - if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then - eerror "You still haven't deleted ${EROOT}/etc/locales.build." - eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher." - die "Lazy upgrader detected" - fi - - if [[ ${CTARGET} == i386-* ]] ; then - eerror "i386 CHOSTs are no longer supported." - eerror "Chances are you don't actually want/need i386." - eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml" - die "Please fix your CHOST" - fi - - if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then - ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS." - ewarn "This will result in a 50% performance penalty when running with a 32bit" - ewarn "hypervisor, which is probably not what you want." - fi - - # Check for sanity of /etc/nsswitch.conf - if [[ -e ${EROOT}/etc/nsswitch.conf ]] ; then - local entry - for entry in passwd group shadow; do - if ! egrep -q "^[ \t]*${entry}:.*files" "${EROOT}"/etc/nsswitch.conf; then - eerror "Your ${EROOT}/etc/nsswitch.conf is out of date." - eerror "Please make sure you have 'files' entries for" - eerror "'passwd:', 'group:' and 'shadow:' databases." - eerror "For more details see:" - eerror " https://wiki.gentoo.org/wiki/Project:Toolchain/nsswitch.conf_in_glibc-2.26" - die "nsswitch.conf has no 'files' provider in '${entry}'." - fi - done - fi - - # ABI-specific checks follow here. Hey, we have a lot more specific conditions that - # we test for... - if ! is_crosscompile ; then - if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then - ebegin "Checking that IA32 emulation is enabled in the running kernel" - echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c" - local STAT - if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then - "${T}/check-ia32-emulation.elf32" - STAT=$? - else - # Don't fail here to allow single->multi ABI switch - # or recover from breakage like bug #646424 - ewarn "Failed to compile the ABI test. Broken host glibc?" - STAT=0 - fi - rm -f "${T}/check-ia32-emulation.elf32" - eend $STAT - [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc." - fi - - fi - - # When we actually have to compile something... - if ! just_headers ; then - ebegin "Checking gcc for __thread support" - if ! eend $(want__thread ; echo $?) ; then - echo - eerror "Could not find a gcc that supports the __thread directive!" - eerror "Please update your binutils/gcc and try again." - die "No __thread support in gcc!" - fi - - if [[ ${CTARGET} == *-linux* ]] ; then - local run_kv build_kv want_kv - - run_kv=$(g_get_running_KV) - build_kv=$(g_int_to_KV $(get_kheader_version)) - want_kv=${MIN_KERN_VER} - - if ! is_crosscompile && ! tc-is-cross-compiler ; then - # Building fails on an non-supporting kernel - ebegin "Checking running kernel version (${run_kv} >= ${want_kv})" - if ! eend_KV ${run_kv} ${want_kv} ; then - echo - eerror "You need a kernel of at least ${want_kv}!" - die "Kernel version too low!" - fi - fi - - ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})" - if ! eend_KV ${build_kv} ${want_kv} ; then - echo - eerror "You need linux-headers of at least ${want_kv}!" - die "linux-headers version too low!" - fi - fi - fi -} - -# -# the phases -# - -# pkg_pretend - -pkg_pretend() { - # All the checks... - einfo "Checking general environment sanity." - sanity_prechecks -} - -# src_unpack - -src_unpack() { - # Consistency is not guaranteed between pkg_ and src_ ... - sanity_prechecks - - use multilib && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz - - setup_env - - if [[ -n ${EGIT_REPO_URI} ]] ; then - git-r3_src_unpack - else - unpack ${P}.tar.xz - fi - - cd "${S}" || die - touch locale/C-translit.h || die #185476 #218003 - - cd "${WORKDIR}" || die - unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz -} - -src_prepare() { - if ! use vanilla ; then - elog "Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER}" - eapply "${WORKDIR}"/patches - einfo "Done." - fi - - default - - gnuconfig_update - - cd "${WORKDIR}" - find . -name configure -exec touch {} + - - eprefixify extra/locale/locale-gen - - # Fix permissions on some of the scripts. - chmod u+x "${S}"/scripts/*.sh - - cd "${S}" -} - -glibc_do_configure() { - # Glibc does not work with gold (for various reasons) #269274. - tc-ld-disable-gold - - # CXX isnt handled by the multilib system, so if we dont unset here - # we accumulate crap across abis - unset CXX - - einfo "Configuring glibc for nptl" - - if use doc ; then - export MAKEINFO=makeinfo - else - export MAKEINFO=/dev/null - fi - - local v - for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO ; do - einfo " $(printf '%15s' ${v}:) ${!v}" - done - - # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760 - # To build .S (assembly) files with the same ABI-specific flags - # upstream currently recommends adding CFLAGS to CC/CXX: - # https://sourceware.org/PR23273 - # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS - # and breaks multiarch support. See 659030#c3 for an example. - # The glibc configure script doesn't properly use LDFLAGS all the time. - export CC="$(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS}" - einfo " $(printf '%15s' 'Manual CC:') ${CC}" - - # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548 - export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS) ${CFLAGS}" - einfo " $(printf '%15s' 'Manual CXX:') ${CXX}" - - echo - - local myconf=() - - case ${CTARGET} in - m68k*) - # setjmp() is not compatible with stack protection: - # https://sourceware.org/PR24202 - myconf+=( --enable-stack-protector=no ) - ;; - powerpc-*) - # Currently gcc on powerpc32 generates invalid code for - # __builtin_return_address(0) calls. Normally programs - # don't do that but malloc hooks in glibc do: - # https://gcc.gnu.org/PR81996 - # https://bugs.gentoo.org/629054 - myconf+=( --enable-stack-protector=no ) - ;; - *) - myconf+=( --enable-stack-protector=$(usex ssp all no) ) - ;; - esac - myconf+=( --enable-stackguard-randomization ) - - # Keep a whitelist of targets supporing IFUNC. glibc's ./configure - # is not robust enough to detect proper support: - # https://bugs.gentoo.org/641216 - # https://sourceware.org/PR22634#c0 - case $(tc-arch ${CTARGET}) in - # Keep whitelist of targets where autodetection mostly works. - amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;; - # Blacklist everywhere else - *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;; - esac - - # Enable Intel Control-flow Enforcement Technology on amd64 if requested - case ${CTARGET} in - x86_64-*) myconf+=( $(use_enable cet) ) ;; - *) ;; - esac - - [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp ) - - myconf+=( --enable-kernel=${MIN_KERN_VER} ) - - # Since SELinux support is only required for nscd, only enable it if: - # 1. USE selinux - # 2. only for the primary ABI on multilib systems - # 3. Not a crosscompile - if ! is_crosscompile && use selinux ; then - if use multilib ; then - if is_final_abi ; then - myconf+=( --with-selinux ) - else - myconf+=( --without-selinux ) - fi - else - myconf+=( --with-selinux ) - fi - else - myconf+=( --without-selinux ) - fi - - # Force a few tests where we always know the answer but - # configure is incapable of finding it. - if is_crosscompile ; then - export \ - libc_cv_c_cleanup=yes \ - libc_cv_forced_unwind=yes - fi - - myconf+=( - --without-cvs - --disable-werror - --enable-bind-now - --build=${CBUILD_OPT:-${CBUILD}} - --host=${CTARGET_OPT:-${CTARGET}} - $(use_enable profile) - $(use_with gd) - --with-headers=$(alt_build_headers) - --prefix="${EPREFIX}/usr" - --sysconfdir="${EPREFIX}/etc" - --localstatedir="${EPREFIX}/var" - --libdir='$(prefix)'/$(get_libdir) - --mandir='$(prefix)'/share/man - --infodir='$(prefix)'/share/info - --libexecdir='$(libdir)'/misc/glibc - --with-bugurl=https://bugs.gentoo.org/ - --with-pkgversion="$(glibc_banner)" - $(use_multiarch || echo --disable-multi-arch) - $(use_enable systemtap) - $(use_enable nscd) - ${EXTRA_ECONF} - ) - - # We rely on sys-libs/timezone-data for timezone tools normally. - myconf+=( $(use_enable vanilla timezone-tools) ) - - # These libs don't have configure flags. - ac_cv_lib_audit_audit_log_user_avc_message=$(usex audit || echo no) - ac_cv_lib_cap_cap_init=$(usex caps || echo no) - - # There is no configure option for this and we need to export it - # since the glibc build will re-run configure on itself - export libc_cv_rootsbindir="${EPREFIX}/sbin" - export libc_cv_slibdir="${EPREFIX}/$(get_libdir)" - - # We take care of patching our binutils to use both hash styles, - # and many people like to force gnu hash style only, so disable - # this overriding check. #347761 - export libc_cv_hashstyle=no - - local builddir=$(builddir nptl) - mkdir -p "${builddir}" - cd "${builddir}" - set -- "${S}"/configure "${myconf[@]}" - echo "$@" - "$@" || die "failed to configure glibc" - - # ia64 static cross-compilers are a pita in so much that they - # can't produce static ELFs (as the libgcc.a is broken). so - # disable building of the programs for those targets if it - # doesn't work. - # XXX: We could turn this into a compiler test, but ia64 is - # the only one that matters, so this should be fine for now. - if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then - sed -i '1i+link-static = touch $@' config.make - fi - - # If we're trying to migrate between ABI sets, we need - # to lie and use a local copy of gcc. Like if the system - # is built with MULTILIB_ABIS="amd64 x86" but we want to - # add x32 to it, gcc/glibc don't yet support x32. - # - if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then - echo 'main(){}' > "${T}"/test.c - if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then - sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die - fi - fi -} - -glibc_headers_configure() { - export ABI=default - - local builddir=$(builddir "headers") - mkdir -p "${builddir}" - cd "${builddir}" - - # if we don't have a compiler yet, we can't really test it now ... - # hopefully they don't affect header generation, so let's hope for - # the best here ... - local v vars=( - ac_cv_header_cpuid_h=yes - libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes - libc_cv_asm_cfi_directives=yes - libc_cv_broken_visibility_attribute=no - libc_cv_c_cleanup=yes - libc_cv_compiler_powerpc64le_binary128_ok=yes - libc_cv_forced_unwind=yes - libc_cv_gcc___thread=yes - libc_cv_mlong_double_128=yes - libc_cv_mlong_double_128ibm=yes - libc_cv_ppc_machine=yes - libc_cv_ppc_rel16=yes - libc_cv_predef_fortify_source=no - libc_cv_target_power8_ok=yes - libc_cv_visibility_attribute=yes - libc_cv_z_combreloc=yes - libc_cv_z_execstack=yes - libc_cv_z_initfirst=yes - libc_cv_z_nodelete=yes - libc_cv_z_nodlopen=yes - libc_cv_z_relro=yes - libc_mips_abi=${ABI} - libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard) - # These libs don't have configure flags. - ac_cv_lib_audit_audit_log_user_avc_message=no - ac_cv_lib_cap_cap_init=no - ) - - einfo "Forcing cached settings:" - for v in "${vars[@]}" ; do - einfo " ${v}" - export ${v} - done - - local headers_only_arch_CPPFLAGS=() - - # Blow away some random CC settings that screw things up. #550192 - if [[ -d ${S}/sysdeps/mips ]]; then - pushd "${S}"/sysdeps/mips >/dev/null - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die - - # Force the mips ABI to the default. This is OK because the set of - # installed headers in this phase is the same between the 3 ABIs. - # If this ever changes, this hack will break, but that's unlikely - # as glibc discourages that behavior. - # https://crbug.com/647033 - sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die - - popd >/dev/null - fi - - case ${CTARGET} in - riscv*) - # RISC-V interrogates the compiler to determine which target to - # build. If building the headers then we don't strictly need a - # RISC-V compiler, so the built-in definitions that are provided - # along with all RISC-V compiler might not exist. This causes - # glibc's RISC-V preconfigure script to blow up. Since we're just - # building the headers any value will actually work here, so just - # pick the standard one (rv64g/lp64d) to make the build scripts - # happy for now -- the headers are all the same anyway so it - # doesn't matter. - headers_only_arch_CPPFLAGS+=( - -D__riscv_xlen=64 - -D__riscv_flen=64 - -D__riscv_float_abi_double=1 - -D__riscv_atomic=1 - ) ;; - esac - - local myconf=() - myconf+=( - --disable-sanity-checks - --enable-hacker-mode - --without-cvs - --disable-werror - --enable-bind-now - --build=${CBUILD_OPT:-${CBUILD}} - --host=${CTARGET_OPT:-${CTARGET}} - --with-headers=$(alt_build_headers) - --prefix="${EPREFIX}/usr" - ${EXTRA_ECONF} - ) - - # Nothing is compiled here which would affect the headers for the target. - # So forcing CC/CFLAGS is sane. - local headers_only_CC=$(tc-getBUILD_CC) - local headers_only_CFLAGS="-O1 -pipe" - local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE ${headers_only_arch_CPPFLAGS[*]}" - local headers_only_LDFLAGS="" - set -- "${S}"/configure "${myconf[@]}" - echo \ - "CC=${headers_only_CC}" \ - "CFLAGS=${headers_only_CFLAGS}" \ - "CPPFLAGS=${headers_only_CPPFLAGS}" \ - "LDFLAGS=${headers_only_LDFLAGS}" \ - "$@" - CC=${headers_only_CC} \ - CFLAGS=${headers_only_CFLAGS} \ - CPPFLAGS=${headers_only_CPPFLAGS} \ - LDFLAGS="" \ - "$@" || die "failed to configure glibc" -} - -do_src_configure() { - if just_headers ; then - glibc_headers_configure - else - glibc_do_configure nptl - fi -} - -src_configure() { - foreach_abi do_src_configure -} - -do_src_compile() { - emake -C "$(builddir nptl)" || die "make nptl for ${ABI} failed" -} - -src_compile() { - if just_headers ; then - return - fi - - foreach_abi do_src_compile -} - -glibc_src_test() { - cd "$(builddir nptl)" - emake check -} - -do_src_test() { - local ret=0 - - glibc_src_test - : $(( ret |= $? )) - - return ${ret} -} - -src_test() { - if just_headers ; then - return - fi - - # Give tests more time to complete. - export TIMEOUTFACTOR=5 - - foreach_abi do_src_test || die "tests failed" -} - -run_locale_gen() { - # if the host locales.gen contains no entries, we'll install everything - local root="$1" - local locale_list="${root}/etc/locale.gen" - if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then - ewarn "Generating all locales; edit /etc/locale.gen to save time/space" - locale_list="${root}/usr/share/i18n/SUPPORTED" - fi - - locale-gen --jobs $(makeopts_jobs) --config "${locale_list}" \ - --destdir "${root}" -} - -glibc_do_src_install() { - local builddir=$(builddir nptl) - cd "${builddir}" - - emake install_root="${D}$(alt_prefix)" install || die - - # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support - # which come without headers etc. Only needed for binary packages since the - # external net-libs/libnsl has increased soversion. Keep only versioned libraries. - find "${D}" -name "libnsl.a" -delete - find "${D}" -name "libnsl.so" -delete - - # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need - # to infer upstream version: - # '#define VERSION "2.26.90"' -> '2.26.90' - local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h) - - if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then - # Move versioned .a file out of libdir to evade portage QA checks - # instead of using gen_usr_ldscript(). We fix ldscript as: - # "GROUP ( /usr/lib64/libm-.a ..." -> "GROUP ( /usr/lib64/glibc-/libm-.a ..." - sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"$(alt_usrlibdir)/libm.a || die - dodir $(alt_usrlibdir)/${P} - mv "${ED}"$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die - fi - - # We'll take care of the cache ourselves - rm -f "${ED}"/etc/ld.so.cache - - # Everything past this point just needs to be done once ... - is_final_abi || return 0 - - # Make sure the non-native interp can be found on multilib systems even - # if the main library set isn't installed into the right place. Maybe - # we should query the active gcc for info instead of hardcoding it ? - local i ldso_abi ldso_name - local ldso_abi_list=( - # x86 - amd64 /lib64/ld-linux-x86-64.so.2 - x32 /libx32/ld-linux-x32.so.2 - x86 /lib/ld-linux.so.2 - # mips - o32 /lib/ld.so.1 - n32 /lib32/ld.so.1 - n64 /lib64/ld.so.1 - # powerpc - ppc /lib/ld.so.1 - ppc64 /lib64/ld64.so.1 - # s390 - s390 /lib/ld.so.1 - s390x /lib/ld64.so.1 - # sparc - sparc32 /lib/ld-linux.so.2 - sparc64 /lib64/ld-linux.so.2 - ) - case $(tc-endian) in - little) - ldso_abi_list+=( - # arm - arm64 /lib/ld-linux-aarch64.so.1 - ) - ;; - big) - ldso_abi_list+=( - # arm - arm64 /lib/ld-linux-aarch64_be.so.1 - ) - ;; - esac - if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then - dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib - fi - for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do - ldso_abi=${ldso_abi_list[i]} - has ${ldso_abi} $(get_install_abis) || continue - - ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}" - if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then - dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name} - fi - done - - # With devpts under Linux mounted properly, we do not need the pt_chown - # binary to be setuid. This is because the default owners/perms will be - # exactly what we want. - if ! use suid ; then - find "${ED}" -name pt_chown -exec chmod -s {} + - fi - - ################################################################# - # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY # - # Make sure we install some symlink hacks so that when we build - # a 2nd stage cross-compiler, gcc finds the target system - # headers correctly. See gcc/doc/gccinstall.info - if is_crosscompile ; then - # We need to make sure that /lib and /usr/lib always exists. - # gcc likes to use relative paths to get to its multilibs like - # /usr/lib/../lib64/. So while we don't install any files into - # /usr/lib/, we do need it to exist. - keepdir $(alt_prefix)/lib - keepdir $(alt_prefix)/usr/lib - - dosym usr/include $(alt_prefix)/sys-include - return 0 - fi - - # Files for Debian-style locale updating - dodir /usr/share/i18n - sed \ - -e "/^#/d" \ - -e "/SUPPORTED-LOCALES=/d" \ - -e "s: \\\\::g" -e "s:/: :g" \ - "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \ - || die "generating /usr/share/i18n/SUPPORTED failed" - cd "${WORKDIR}"/extra/locale - dosbin locale-gen - doman *.[0-8] - insinto /etc - doins locale.gen - - # Make sure all the ABI's can find the locales and so we only - # have to generate one set - local a - keepdir /usr/$(get_libdir)/locale - for a in $(get_install_abis) ; do - if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then - dosym ../$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale - fi - done - - cd "${S}" - - # Install misc network config files - insinto /etc - doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf - doins "${WORKDIR}"/extra/etc/*.conf - - if use nscd ; then - doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)" - - local nscd_args=( - -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):" - ) - - sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd - - systemd_dounit nscd/nscd.service - systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf - else - # Do this since extra/etc/*.conf above might have nscd.conf. - rm -f "${ED}"/etc/nscd.conf - fi - - echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc - doenvd "${T}"/00glibc - - for d in BUGS ChangeLog CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do - [[ -s ${d} ]] && dodoc ${d} - done - dodoc -r ChangeLog.old - - # Prevent overwriting of the /etc/localtime symlink. We'll handle the - # creation of the "factory" symlink in pkg_postinst(). - rm -f "${ED}"/etc/localtime - - # Generate all locales if this is a native build as locale generation - if use compile-locales && ! is_crosscompile ; then - run_locale_gen "${ED}" - fi -} - -glibc_headers_install() { - local builddir=$(builddir "headers") - cd "${builddir}" - emake install_root="${D}$(alt_prefix)" install-headers - - insinto $(alt_headers)/gnu - doins "${S}"/include/gnu/stubs.h - - # Make sure we install the sys-include symlink so that when - # we build a 2nd stage cross-compiler, gcc finds the target - # system headers correctly. See gcc/doc/gccinstall.info - dosym usr/include $(alt_prefix)/sys-include -} - -src_strip() { - # gdb is lame and requires some debugging information to remain in - # libpthread, so we need to strip it by hand. libthread_db makes no - # sense stripped as it is only used when debugging. - local pthread=$(has splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}") - env \ - -uRESTRICT \ - CHOST=${CTARGET} \ - STRIP_MASK="/*/{,tls/}${pthread}*" \ - prepallstrip - # if user has stripping enabled and does not have split debug turned on, - # then leave the debugging sections in libpthread. - if ! has nostrip ${FEATURES} && ! has splitdebug ${FEATURES} ; then - ${STRIP:-${CTARGET}-strip} --strip-debug "${ED}"$(alt_prefix)/*/libpthread-*.so - fi -} - -src_install() { - if just_headers ; then - export ABI=default - glibc_headers_install - return - fi - - foreach_abi glibc_do_src_install - src_strip -} - -# Simple test to make sure our new glibc isn't completely broken. -# Make sure we don't test with statically built binaries since -# they will fail. Also, skip if this glibc is a cross compiler. -# -# If coreutils is built with USE=multicall, some of these files -# will just be wrapper scripts, not actual ELFs we can test. -glibc_sanity_check() { - cd / #228809 - - # We enter ${ED} so to avoid trouble if the path contains - # special characters; for instance if the path contains the - # colon character (:), then the linker will try to split it - # and look for the libraries in an unexpected place. This can - # lead to unsafe code execution if the generated prefix is - # within a world-writable directory. - # (e.g. /var/tmp/portage:${HOSTNAME}) - pushd "${ED}"/$(get_libdir) >/dev/null - - local x striptest - for x in cal date env free ls true uname uptime ; do - x=$(type -p ${x}) - [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue - striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue - case ${striptest} in - *"statically linked"*) continue;; - *"ASCII text"*) continue;; - esac - # We need to clear the locale settings as the upgrade might want - # incompatible locale data. This test is not for verifying that. - LC_ALL=C \ - ./ld-*.so --library-path . ${x} > /dev/null \ - || die "simple run test (${x}) failed" - done - - popd >/dev/null -} - -pkg_preinst() { - # nothing to do if just installing headers - just_headers && return - - # prepare /etc/ld.so.conf.d/ for files - mkdir -p "${EROOT}"/etc/ld.so.conf.d - - # Default /etc/hosts.conf:multi to on for systems with small dbs. - if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then - sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf - einfo "Defaulting /etc/host.conf:multi to on" - fi - - [[ ${ROOT} != "/" ]] && return 0 - [[ -d ${ED}/$(get_libdir) ]] || return 0 - [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check -} - -pkg_postinst() { - # nothing to do if just installing headers - just_headers && return - - if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then - # Generate fastloading iconv module configuration file. - "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}" - fi - - if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then - # Reload init ... if in a chroot or a diff init package, ignore - # errors from this step #253697 - /sbin/telinit U 2>/dev/null - - use compile-locales || run_locale_gen "${EROOT}" - fi - - # Check for sanity of /etc/nsswitch.conf, take 2 - if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then - local entry - for entry in passwd group shadow; do - if egrep -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then - ewarn "" - ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been" - ewarn "removed from glibc and is now provided by the package" - ewarn " sys-auth/libnss-nis" - ewarn "Install it now to keep your NIS setup working." - ewarn "" - fi - done - fi -} diff --git a/sys-libs/glibc/glibc-2.28-r6.ebuild b/sys-libs/glibc/glibc-2.28-r6.ebuild new file mode 100644 index 000000000000..601386fafaf0 --- /dev/null +++ b/sys-libs/glibc/glibc-2.28-r6.ebuild @@ -0,0 +1,1418 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +inherit prefix eutils eapi7-ver toolchain-funcs flag-o-matic gnuconfig \ + multilib systemd multiprocessing + +DESCRIPTION="GNU libc C library" +HOMEPAGE="https://www.gnu.org/software/libc/" +LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE" +RESTRICT="strip" # Strip ourself #46186 +SLOT="2.2" + +EMULTILIB_PKG="true" + +if [[ ${PV} == 9999* ]]; then + EGIT_REPO_URI="https://sourceware.org/git/glibc.git" + inherit git-r3 +else + KEYWORDS="alpha amd64 arm arm64 ~hppa ia64 m68k ~mips ~ppc ~ppc64 s390 sh sparc x86" + SRC_URI="mirror://gnu/glibc/${P}.tar.xz" +fi + +RELEASE_VER=${PV} + +GCC_BOOTSTRAP_VER=20180511 + +# Gentoo patchset +PATCH_VER=9 + +SRC_URI+=" https://dev.gentoo.org/~dilfridge/distfiles/${P}-patches-${PATCH_VER}.tar.xz" +SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )" + +IUSE="audit caps cet compile-locales doc gd headers-only +multiarch multilib nscd profile selinux +ssp suid systemtap test vanilla" + +# Minimum kernel version that glibc requires +MIN_KERN_VER="3.2.0" + +# Here's how the cross-compile logic breaks down ... +# CTARGET - machine that will target the binaries +# CHOST - machine that will host the binaries +# CBUILD - machine that will build the binaries +# If CTARGET != CHOST, it means you want a libc for cross-compiling. +# If CHOST != CBUILD, it means you want to cross-compile the libc. +# CBUILD = CHOST = CTARGET - native build/install +# CBUILD != (CHOST = CTARGET) - cross-compile a native build +# (CBUILD = CHOST) != CTARGET - libc for cross-compiler +# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler +# For install paths: +# CHOST = CTARGET - install into / +# CHOST != CTARGET - install into /usr/CTARGET/ +# +export CBUILD=${CBUILD:-${CHOST}} +export CTARGET=${CTARGET:-${CHOST}} +if [[ ${CTARGET} == ${CHOST} ]] ; then + if [[ ${CATEGORY} == cross-* ]] ; then + export CTARGET=${CATEGORY#cross-} + fi +fi + +# We need a new-enough binutils/gcc to match upstream baseline. +# Also we need to make sure our binutils/gcc supports TLS, +# and that gcc already contains the hardened patches. +COMMON_DEPEND=" + nscd? ( selinux? ( + audit? ( sys-process/audit ) + caps? ( sys-libs/libcap ) + ) ) + suid? ( caps? ( sys-libs/libcap ) ) + selinux? ( sys-libs/libselinux ) + systemtap? ( dev-util/systemtap ) +" +DEPEND="${COMMON_DEPEND} + >=app-misc/pax-utils-0.1.10 + sys-devel/bison + !=net-dns/libidn2-2.0.5 ) +" +RDEPEND="${COMMON_DEPEND} + sys-apps/gentoo-functions + !sys-kernel/ps3-sources + !sys-libs/nss-db +" + +if [[ ${CATEGORY} == cross-* ]] ; then + DEPEND+=" !headers-only? ( + >=${CATEGORY}/binutils-2.24 + >=${CATEGORY}/gcc-6 + )" + [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers" +else + DEPEND+=" + >=sys-devel/binutils-2.24 + >=sys-devel/gcc-6 + virtual/os-headers + " + RDEPEND+=" + >=net-dns/libidn2-2.0.5 + vanilla? ( !sys-libs/timezone-data ) + " + PDEPEND+=" !vanilla? ( sys-libs/timezone-data )" +fi + +# +# Small helper functions +# + +is_crosscompile() { + [[ ${CHOST} != ${CTARGET} ]] +} + +just_headers() { + is_crosscompile && use headers-only +} + +alt_prefix() { + is_crosscompile && echo /usr/${CTARGET} +} + +# We need to be able to set alternative headers for compiling for non-native +# platform. Will also become useful for testing kernel-headers without screwing +# up the whole system. +alt_headers() { + echo ${ALT_HEADERS:=$(alt_prefix)/usr/include} +} + +alt_build_headers() { + if [[ -z ${ALT_BUILD_HEADERS} ]] ; then + ALT_BUILD_HEADERS="${EPREFIX}$(alt_headers)" + if tc-is-cross-compiler ; then + ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers) + if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then + local header_path=$(echo '#include ' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h') + ALT_BUILD_HEADERS=${header_path%/linux/version.h} + fi + fi + fi + echo "${ALT_BUILD_HEADERS}" +} + +alt_libdir() { + echo $(alt_prefix)/$(get_libdir) +} +alt_usrlibdir() { + echo $(alt_prefix)/usr/$(get_libdir) +} + +builddir() { + echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1" +} + +do_compile_test() { + local ret save_cflags=${CFLAGS} + CFLAGS+=" $1" + shift + + pushd "${T}" >/dev/null + + rm -f glibc-test* + printf '%b' "$*" > glibc-test.c + + nonfatal emake -s glibc-test + ret=$? + + popd >/dev/null + + CFLAGS=${save_cflags} + return ${ret} +} + +do_run_test() { + local ret + + if [[ ${MERGE_TYPE} == "binary" ]] ; then + # ignore build failures when installing a binary package #324685 + do_compile_test "" "$@" 2>/dev/null || return 0 + else + if ! do_compile_test "" "$@" ; then + ewarn "Simple build failed ... assuming this is desired #324685" + return 0 + fi + fi + + pushd "${T}" >/dev/null + + ./glibc-test + ret=$? + rm -f glibc-test* + + popd >/dev/null + + return ${ret} +} + +setup_target_flags() { + # This largely mucks with compiler flags. None of which should matter + # when building up just the headers. + just_headers && return 0 + + case $(tc-arch) in + x86) + # -march needed for #185404 #199334 + # TODO: When creating the first glibc cross-compile, this test will + # always fail as it does a full link which in turn requires glibc. + # Probably also applies when changing multilib profile settings (e.g. + # enabling x86 when the profile was amd64-only previously). + # We could change main to _start and pass -nostdlib here so that we + # only test the gcc code compilation. Or we could do a compile and + # then look for the symbol via scanelf. + if ! do_compile_test "" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then + local t=${CTARGET_OPT:-${CTARGET}} + t=${t%%-*} + filter-flags '-march=*' + export CFLAGS="-march=${t} ${CFLAGS}" + einfo "Auto adding -march=${t} to CFLAGS #185404" + fi + ;; + amd64) + # -march needed for #185404 #199334 + # Note: This test only matters when the x86 ABI is enabled, so we could + # optimize a bit and elide it. + # TODO: See cross-compile issues listed above for x86. + if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then + local t=${CTARGET_OPT:-${CTARGET}} + t=${t%%-*} + # Normally the target is x86_64-xxx, so turn that into the -march that + # gcc actually accepts. #528708 + [[ ${t} == "x86_64" ]] && t="x86-64" + filter-flags '-march=*' + # ugly, ugly, ugly. ugly. + CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") + export CFLAGS_x86="${CFLAGS_x86} -march=${t}" + einfo "Auto adding -march=${t} to CFLAGS_x86 #185404" + fi + ;; + mips) + # The mips abi cannot support the GNU style hashes. #233233 + filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both + ;; + sparc) + # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though. + filter-flags "-fcall-used-g7" + append-flags "-fcall-used-g6" + + # If the CHOST is the basic one (e.g. not sparcv9-xxx already), + # try to pick a better one so glibc can use cpu-specific .S files. + # We key off the CFLAGS to get a good value. Also need to handle + # version skew. + # We can't force users to set their CHOST to their exact machine + # as many of these are not recognized by config.sub/gcc and such :(. + # Note: If the mcpu values don't scale, we might try probing CPP defines. + # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ? + + local cpu + case ${CTARGET} in + sparc64-*) + case $(get-flag mcpu) in + niagara[234]) + if ver_test -ge 2.8 ; then + cpu="sparc64v2" + elif ver_test -ge 2.4 ; then + cpu="sparc64v" + elif ver_test -ge 2.2.3 ; then + cpu="sparc64b" + fi + ;; + niagara) + if ver_test -ge 2.4 ; then + cpu="sparc64v" + elif ver_test -ge 2.2.3 ; then + cpu="sparc64b" + fi + ;; + ultrasparc3) + cpu="sparc64b" + ;; + *) + # We need to force at least v9a because the base build doesn't + # work with just v9. + # https://sourceware.org/bugzilla/show_bug.cgi?id=19477 + [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a" + ;; + esac + ;; + sparc-*) + case $(get-flag mcpu) in + niagara[234]) + if ver_test -ge 2.8 ; then + cpu="sparcv9v2" + elif ver_test -ge 2.4 ; then + cpu="sparcv9v" + elif ver_test -ge 2.2.3 ; then + cpu="sparcv9b" + else + cpu="sparcv9" + fi + ;; + niagara) + if ver_test -ge 2.4 ; then + cpu="sparcv9v" + elif ver_test -ge 2.2.3 ; then + cpu="sparcv9b" + else + cpu="sparcv9" + fi + ;; + ultrasparc3) + cpu="sparcv9b" + ;; + v9|ultrasparc) + cpu="sparcv9" + ;; + v8|supersparc|hypersparc|leon|leon3) + cpu="sparcv8" + ;; + esac + ;; + esac + [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}" + ;; + esac +} + +setup_flags() { + # Make sure host make.conf doesn't pollute us + if is_crosscompile || tc-is-cross-compiler ; then + CHOST=${CTARGET} strip-unsupported-flags + fi + + # Store our CFLAGS because it's changed depending on which CTARGET + # we are building when pulling glibc on a multilib profile + CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}} + CFLAGS=${CFLAGS_BASE} + CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}} + CXXFLAGS=${CXXFLAGS_BASE} + ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}} + ASFLAGS=${ASFLAGS_BASE} + + # Over-zealous CFLAGS can often cause problems. What may work for one + # person may not work for another. To avoid a large influx of bugs + # relating to failed builds, we strip most CFLAGS out to ensure as few + # problems as possible. + strip-flags + strip-unsupported-flags + filter-flags -m32 -m64 '-mabi=*' + + # glibc aborts if rpath is set by LDFLAGS + filter-ldflags '-Wl,-rpath=*' + + # #492892 + filter-flags -frecord-gcc-switches + + unset CBUILD_OPT CTARGET_OPT + if use multilib ; then + CTARGET_OPT=$(get_abi_CTARGET) + [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST) + fi + + setup_target_flags + + if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then + CBUILD_OPT=${CTARGET_OPT} + fi + + # Lock glibc at -O2; we want to be conservative here. + # -fno-strict-aliasing is to work around #155906. + filter-flags '-O?' + append-flags -O2 -fno-strict-aliasing + + filter-flags '-fstack-protector*' +} + +want_tls() { + # Archs that can use TLS (Thread Local Storage) + case $(tc-arch) in + x86) + # requires i486 or better #106556 + [[ ${CTARGET} == i[4567]86* ]] && return 0 + return 1 + ;; + esac + return 0 +} + +want__thread() { + want_tls || return 1 + + # For some reason --with-tls --with__thread is causing segfaults on sparc32. + [[ ${PROFILE_ARCH} == "sparc" ]] && return 1 + + [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD} + + # only test gcc -- can't test linking yet + tc-has-tls -c ${CTARGET} + WANT__THREAD=$? + + return ${WANT__THREAD} +} + +use_multiarch() { + # Allow user to disable runtime arch detection in multilib. + use multiarch || return 1 + # Make sure binutils is new enough to support indirect functions, + # #336792. This funky sed supports gold and bfd linkers. + local bver nver + bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}') + case $(tc-arch ${CTARGET}) in + amd64|x86) nver="2.20" ;; + arm) nver="2.22" ;; + hppa) nver="2.23" ;; + ppc|ppc64) nver="2.20" ;; + # ifunc support was added in 2.23, but glibc also needs + # machinemode which is in 2.24. + s390) nver="2.24" ;; + sparc) nver="2.21" ;; + *) return 1 ;; + esac + ver_test ${bver} -ge ${nver} +} + +# Setup toolchain variables that had historically been defined in the +# profiles for these archs. +setup_env() { + # silly users + unset LD_RUN_PATH + unset LD_ASSUME_KERNEL + + if is_crosscompile || tc-is-cross-compiler ; then + multilib_env ${CTARGET_OPT:-${CTARGET}} + + if ! use multilib ; then + MULTILIB_ABIS=${DEFAULT_ABI} + else + MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}} + fi + + # If the user has CFLAGS_ in their make.conf, use that, + # and fall back on CFLAGS. + local VAR=CFLAGS_${CTARGET//[-.]/_} + CFLAGS=${!VAR-${CFLAGS}} + einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}" + fi + + setup_flags + + export ABI=${ABI:-${DEFAULT_ABI:-default}} + + if just_headers ; then + # Avoid mixing host's CC and target's CFLAGS_${ABI}: + # At this bootstrap stage we have only binutils for + # target but not compiler yet. + einfo "Skip CC ABI injection. We can't use (cross-)compiler yet." + return 0 + fi + local VAR=CFLAGS_${ABI} + # We need to export CFLAGS with abi information in them because glibc's + # configure script checks CFLAGS for some targets (like mips). Keep + # around the original clean value to avoid appending multiple ABIs on + # top of each other. + : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})} + export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}" + einfo " $(printf '%15s' 'Manual CC:') ${CC}" +} + +foreach_abi() { + setup_env + + local ret=0 + local abilist="" + if use multilib ; then + abilist=$(get_install_abis) + else + abilist=${DEFAULT_ABI} + fi + local -x ABI + for ABI in ${abilist:-default} ; do + setup_env + einfo "Running $1 for ABI ${ABI}" + $1 + : $(( ret |= $? )) + done + return ${ret} +} + +glibc_banner() { + local b="Gentoo ${PVR}" + [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}" + echo "${b}" +} + +check_devpts() { + # Make sure devpts is mounted correctly for use w/out setuid pt_chown. + + # If merely building the binary package, then there's nothing to verify. + [[ ${MERGE_TYPE} == "buildonly" ]] && return + + # Only sanity check when installing the native glibc. + [[ ${ROOT} != "/" ]] && return + + # If they're opting in to the old suid code, then no need to check. + use suid && return + + if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then + eerror "In order to use glibc with USE=-suid, you must make sure that" + eerror "you have devpts mounted at /dev/pts with the gid=5 option." + eerror "Openrc should do this for you, so you should check /etc/fstab" + eerror "and make sure you do not have any invalid settings there." + die "mount & fix your /dev/pts settings" + fi +} + +# The following Kernel version handling functions are mostly copied from portage +# source. It's better not to use linux-info.eclass here since a) it adds too +# much magic, see bug 326693 for some of the arguments, and b) some of the +# functions are just not provided. + +g_get_running_KV() { + uname -r + return $? +} + +g_KV_major() { + [[ -z $1 ]] && return 1 + local KV=$@ + echo "${KV%%.*}" +} + +g_KV_minor() { + [[ -z $1 ]] && return 1 + local KV=$@ + KV=${KV#*.} + echo "${KV%%.*}" +} + +g_KV_micro() { + [[ -z $1 ]] && return 1 + local KV=$@ + KV=${KV#*.*.} + echo "${KV%%[^[:digit:]]*}" +} + +g_KV_to_int() { + [[ -z $1 ]] && return 1 + local KV_MAJOR=$(g_KV_major "$1") + local KV_MINOR=$(g_KV_minor "$1") + local KV_MICRO=$(g_KV_micro "$1") + local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO )) + + # We make version 2.2.0 the minimum version we will handle as + # a sanity check ... if its less, we fail ... + if [[ ${KV_int} -ge 131584 ]] ; then + echo "${KV_int}" + return 0 + fi + return 1 +} + +g_int_to_KV() { + local version=$1 major minor micro + major=$((version / 65536)) + minor=$(((version % 65536) / 256)) + micro=$((version % 256)) + echo ${major}.${minor}.${micro} +} + +eend_KV() { + [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]] + eend $? +} + +get_kheader_version() { + printf '#include \nLINUX_VERSION_CODE\n' | \ + $(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" - | \ + tail -n 1 +} + +# We collect all sanity checks here. Consistency is not guranteed between +# pkg_ and src_ phases, so we call this function both in pkg_pretend and in +# src_unpack. +sanity_prechecks() { + # Make sure devpts is mounted correctly for use w/out setuid pt_chown + check_devpts + + # Prevent native builds from downgrading + if [[ ${MERGE_TYPE} != "buildonly" ]] && \ + [[ ${ROOT} == "/" ]] && \ + [[ ${CBUILD} == ${CHOST} ]] && \ + [[ ${CHOST} == ${CTARGET} ]] ; then + + # The high rev # is to allow people to downgrade between -r# + # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2 + # should be fine. Hopefully we never actually use a r# this + # high. + if has_version ">${CATEGORY}/${P}-r10000" ; then + eerror "Sanity check to keep you from breaking your system:" + eerror " Downgrading glibc is not supported and a sure way to destruction." + die "Aborting to save your system." + fi + + if ! do_run_test '#include \n#include \nint main(){return syscall(1000)!=-1;}\n' ; then + eerror "Your old kernel is broken. You need to update it to a newer" + eerror "version as syscall() will break. See bug 279260." + die "Old and broken kernel." + fi + fi + + # Users have had a chance to phase themselves, time to give em the boot + if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then + eerror "You still haven't deleted ${EROOT}/etc/locales.build." + eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher." + die "Lazy upgrader detected" + fi + + if [[ ${CTARGET} == i386-* ]] ; then + eerror "i386 CHOSTs are no longer supported." + eerror "Chances are you don't actually want/need i386." + eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml" + die "Please fix your CHOST" + fi + + if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then + ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS." + ewarn "This will result in a 50% performance penalty when running with a 32bit" + ewarn "hypervisor, which is probably not what you want." + fi + + # Check for sanity of /etc/nsswitch.conf + if [[ -e ${EROOT}/etc/nsswitch.conf ]] ; then + local entry + for entry in passwd group shadow; do + if ! egrep -q "^[ \t]*${entry}:.*files" "${EROOT}"/etc/nsswitch.conf; then + eerror "Your ${EROOT}/etc/nsswitch.conf is out of date." + eerror "Please make sure you have 'files' entries for" + eerror "'passwd:', 'group:' and 'shadow:' databases." + eerror "For more details see:" + eerror " https://wiki.gentoo.org/wiki/Project:Toolchain/nsswitch.conf_in_glibc-2.26" + die "nsswitch.conf has no 'files' provider in '${entry}'." + fi + done + fi + + # ABI-specific checks follow here. Hey, we have a lot more specific conditions that + # we test for... + if ! is_crosscompile ; then + if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then + ebegin "Checking that IA32 emulation is enabled in the running kernel" + echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c" + local STAT + if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then + "${T}/check-ia32-emulation.elf32" + STAT=$? + else + # Don't fail here to allow single->multi ABI switch + # or recover from breakage like bug #646424 + ewarn "Failed to compile the ABI test. Broken host glibc?" + STAT=0 + fi + rm -f "${T}/check-ia32-emulation.elf32" + eend $STAT + [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc." + fi + + fi + + # When we actually have to compile something... + if ! just_headers ; then + ebegin "Checking gcc for __thread support" + if ! eend $(want__thread ; echo $?) ; then + echo + eerror "Could not find a gcc that supports the __thread directive!" + eerror "Please update your binutils/gcc and try again." + die "No __thread support in gcc!" + fi + + if [[ ${CTARGET} == *-linux* ]] ; then + local run_kv build_kv want_kv + + run_kv=$(g_get_running_KV) + build_kv=$(g_int_to_KV $(get_kheader_version)) + want_kv=${MIN_KERN_VER} + + if ! is_crosscompile && ! tc-is-cross-compiler ; then + # Building fails on an non-supporting kernel + ebegin "Checking running kernel version (${run_kv} >= ${want_kv})" + if ! eend_KV ${run_kv} ${want_kv} ; then + echo + eerror "You need a kernel of at least ${want_kv}!" + die "Kernel version too low!" + fi + fi + + ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})" + if ! eend_KV ${build_kv} ${want_kv} ; then + echo + eerror "You need linux-headers of at least ${want_kv}!" + die "linux-headers version too low!" + fi + fi + fi +} + +# +# the phases +# + +# pkg_pretend + +pkg_pretend() { + # All the checks... + einfo "Checking general environment sanity." + sanity_prechecks +} + +# src_unpack + +src_unpack() { + # Consistency is not guaranteed between pkg_ and src_ ... + sanity_prechecks + + use multilib && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz + + setup_env + + if [[ -n ${EGIT_REPO_URI} ]] ; then + git-r3_src_unpack + else + unpack ${P}.tar.xz + fi + + cd "${S}" || die + touch locale/C-translit.h || die #185476 #218003 + + cd "${WORKDIR}" || die + unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz +} + +src_prepare() { + if ! use vanilla ; then + elog "Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER}" + eapply "${WORKDIR}"/patches + einfo "Done." + fi + + default + + gnuconfig_update + + cd "${WORKDIR}" + find . -name configure -exec touch {} + + + eprefixify extra/locale/locale-gen + + # Fix permissions on some of the scripts. + chmod u+x "${S}"/scripts/*.sh + + cd "${S}" +} + +glibc_do_configure() { + # Glibc does not work with gold (for various reasons) #269274. + tc-ld-disable-gold + + # CXX isnt handled by the multilib system, so if we dont unset here + # we accumulate crap across abis + unset CXX + + einfo "Configuring glibc for nptl" + + if use doc ; then + export MAKEINFO=makeinfo + else + export MAKEINFO=/dev/null + fi + + local v + for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO ; do + einfo " $(printf '%15s' ${v}:) ${!v}" + done + + # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760 + # To build .S (assembly) files with the same ABI-specific flags + # upstream currently recommends adding CFLAGS to CC/CXX: + # https://sourceware.org/PR23273 + # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS + # and breaks multiarch support. See 659030#c3 for an example. + # The glibc configure script doesn't properly use LDFLAGS all the time. + export CC="$(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS}" + einfo " $(printf '%15s' 'Manual CC:') ${CC}" + + # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548 + export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS) ${CFLAGS}" + einfo " $(printf '%15s' 'Manual CXX:') ${CXX}" + + echo + + local myconf=() + + case ${CTARGET} in + m68k*) + # setjmp() is not compatible with stack protection: + # https://sourceware.org/PR24202 + myconf+=( --enable-stack-protector=no ) + ;; + powerpc-*) + # Currently gcc on powerpc32 generates invalid code for + # __builtin_return_address(0) calls. Normally programs + # don't do that but malloc hooks in glibc do: + # https://gcc.gnu.org/PR81996 + # https://bugs.gentoo.org/629054 + myconf+=( --enable-stack-protector=no ) + ;; + *) + myconf+=( --enable-stack-protector=$(usex ssp all no) ) + ;; + esac + myconf+=( --enable-stackguard-randomization ) + + # Keep a whitelist of targets supporing IFUNC. glibc's ./configure + # is not robust enough to detect proper support: + # https://bugs.gentoo.org/641216 + # https://sourceware.org/PR22634#c0 + case $(tc-arch ${CTARGET}) in + # Keep whitelist of targets where autodetection mostly works. + amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;; + # Blacklist everywhere else + *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;; + esac + + # Enable Intel Control-flow Enforcement Technology on amd64 if requested + case ${CTARGET} in + x86_64-*) myconf+=( $(use_enable cet) ) ;; + *) ;; + esac + + [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp ) + + myconf+=( --enable-kernel=${MIN_KERN_VER} ) + + # Since SELinux support is only required for nscd, only enable it if: + # 1. USE selinux + # 2. only for the primary ABI on multilib systems + # 3. Not a crosscompile + if ! is_crosscompile && use selinux ; then + if use multilib ; then + if is_final_abi ; then + myconf+=( --with-selinux ) + else + myconf+=( --without-selinux ) + fi + else + myconf+=( --with-selinux ) + fi + else + myconf+=( --without-selinux ) + fi + + # Force a few tests where we always know the answer but + # configure is incapable of finding it. + if is_crosscompile ; then + export \ + libc_cv_c_cleanup=yes \ + libc_cv_forced_unwind=yes + fi + + myconf+=( + --without-cvs + --disable-werror + --enable-bind-now + --build=${CBUILD_OPT:-${CBUILD}} + --host=${CTARGET_OPT:-${CTARGET}} + $(use_enable profile) + $(use_with gd) + --with-headers=$(alt_build_headers) + --prefix="${EPREFIX}/usr" + --sysconfdir="${EPREFIX}/etc" + --localstatedir="${EPREFIX}/var" + --libdir='$(prefix)'/$(get_libdir) + --mandir='$(prefix)'/share/man + --infodir='$(prefix)'/share/info + --libexecdir='$(libdir)'/misc/glibc + --with-bugurl=https://bugs.gentoo.org/ + --with-pkgversion="$(glibc_banner)" + $(use_multiarch || echo --disable-multi-arch) + $(use_enable systemtap) + $(use_enable nscd) + ${EXTRA_ECONF} + ) + + # We rely on sys-libs/timezone-data for timezone tools normally. + myconf+=( $(use_enable vanilla timezone-tools) ) + + # These libs don't have configure flags. + ac_cv_lib_audit_audit_log_user_avc_message=$(usex audit || echo no) + ac_cv_lib_cap_cap_init=$(usex caps || echo no) + + # There is no configure option for this and we need to export it + # since the glibc build will re-run configure on itself + export libc_cv_rootsbindir="${EPREFIX}/sbin" + export libc_cv_slibdir="${EPREFIX}/$(get_libdir)" + + # We take care of patching our binutils to use both hash styles, + # and many people like to force gnu hash style only, so disable + # this overriding check. #347761 + export libc_cv_hashstyle=no + + local builddir=$(builddir nptl) + mkdir -p "${builddir}" + cd "${builddir}" + set -- "${S}"/configure "${myconf[@]}" + echo "$@" + "$@" || die "failed to configure glibc" + + # ia64 static cross-compilers are a pita in so much that they + # can't produce static ELFs (as the libgcc.a is broken). so + # disable building of the programs for those targets if it + # doesn't work. + # XXX: We could turn this into a compiler test, but ia64 is + # the only one that matters, so this should be fine for now. + if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then + sed -i '1i+link-static = touch $@' config.make + fi + + # If we're trying to migrate between ABI sets, we need + # to lie and use a local copy of gcc. Like if the system + # is built with MULTILIB_ABIS="amd64 x86" but we want to + # add x32 to it, gcc/glibc don't yet support x32. + # + if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then + echo 'main(){}' > "${T}"/test.c + if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then + sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die + fi + fi +} + +glibc_headers_configure() { + export ABI=default + + local builddir=$(builddir "headers") + mkdir -p "${builddir}" + cd "${builddir}" + + # if we don't have a compiler yet, we can't really test it now ... + # hopefully they don't affect header generation, so let's hope for + # the best here ... + local v vars=( + ac_cv_header_cpuid_h=yes + libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes + libc_cv_asm_cfi_directives=yes + libc_cv_broken_visibility_attribute=no + libc_cv_c_cleanup=yes + libc_cv_compiler_powerpc64le_binary128_ok=yes + libc_cv_forced_unwind=yes + libc_cv_gcc___thread=yes + libc_cv_mlong_double_128=yes + libc_cv_mlong_double_128ibm=yes + libc_cv_ppc_machine=yes + libc_cv_ppc_rel16=yes + libc_cv_predef_fortify_source=no + libc_cv_target_power8_ok=yes + libc_cv_visibility_attribute=yes + libc_cv_z_combreloc=yes + libc_cv_z_execstack=yes + libc_cv_z_initfirst=yes + libc_cv_z_nodelete=yes + libc_cv_z_nodlopen=yes + libc_cv_z_relro=yes + libc_mips_abi=${ABI} + libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard) + # These libs don't have configure flags. + ac_cv_lib_audit_audit_log_user_avc_message=no + ac_cv_lib_cap_cap_init=no + ) + + einfo "Forcing cached settings:" + for v in "${vars[@]}" ; do + einfo " ${v}" + export ${v} + done + + local headers_only_arch_CPPFLAGS=() + + # Blow away some random CC settings that screw things up. #550192 + if [[ -d ${S}/sysdeps/mips ]]; then + pushd "${S}"/sysdeps/mips >/dev/null + sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die + sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die + + # Force the mips ABI to the default. This is OK because the set of + # installed headers in this phase is the same between the 3 ABIs. + # If this ever changes, this hack will break, but that's unlikely + # as glibc discourages that behavior. + # https://crbug.com/647033 + sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die + + popd >/dev/null + fi + + case ${CTARGET} in + riscv*) + # RISC-V interrogates the compiler to determine which target to + # build. If building the headers then we don't strictly need a + # RISC-V compiler, so the built-in definitions that are provided + # along with all RISC-V compiler might not exist. This causes + # glibc's RISC-V preconfigure script to blow up. Since we're just + # building the headers any value will actually work here, so just + # pick the standard one (rv64g/lp64d) to make the build scripts + # happy for now -- the headers are all the same anyway so it + # doesn't matter. + headers_only_arch_CPPFLAGS+=( + -D__riscv_xlen=64 + -D__riscv_flen=64 + -D__riscv_float_abi_double=1 + -D__riscv_atomic=1 + ) ;; + esac + + local myconf=() + myconf+=( + --disable-sanity-checks + --enable-hacker-mode + --without-cvs + --disable-werror + --enable-bind-now + --build=${CBUILD_OPT:-${CBUILD}} + --host=${CTARGET_OPT:-${CTARGET}} + --with-headers=$(alt_build_headers) + --prefix="${EPREFIX}/usr" + ${EXTRA_ECONF} + ) + + # Nothing is compiled here which would affect the headers for the target. + # So forcing CC/CFLAGS is sane. + local headers_only_CC=$(tc-getBUILD_CC) + local headers_only_CFLAGS="-O1 -pipe" + local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE ${headers_only_arch_CPPFLAGS[*]}" + local headers_only_LDFLAGS="" + set -- "${S}"/configure "${myconf[@]}" + echo \ + "CC=${headers_only_CC}" \ + "CFLAGS=${headers_only_CFLAGS}" \ + "CPPFLAGS=${headers_only_CPPFLAGS}" \ + "LDFLAGS=${headers_only_LDFLAGS}" \ + "$@" + CC=${headers_only_CC} \ + CFLAGS=${headers_only_CFLAGS} \ + CPPFLAGS=${headers_only_CPPFLAGS} \ + LDFLAGS="" \ + "$@" || die "failed to configure glibc" +} + +do_src_configure() { + if just_headers ; then + glibc_headers_configure + else + glibc_do_configure nptl + fi +} + +src_configure() { + foreach_abi do_src_configure +} + +do_src_compile() { + emake -C "$(builddir nptl)" || die "make nptl for ${ABI} failed" +} + +src_compile() { + if just_headers ; then + return + fi + + foreach_abi do_src_compile +} + +glibc_src_test() { + cd "$(builddir nptl)" + emake check +} + +do_src_test() { + local ret=0 + + glibc_src_test + : $(( ret |= $? )) + + return ${ret} +} + +src_test() { + if just_headers ; then + return + fi + + # Give tests more time to complete. + export TIMEOUTFACTOR=5 + + foreach_abi do_src_test || die "tests failed" +} + +run_locale_gen() { + # if the host locales.gen contains no entries, we'll install everything + local root="$1" + local locale_list="${root}/etc/locale.gen" + if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then + ewarn "Generating all locales; edit /etc/locale.gen to save time/space" + locale_list="${root}/usr/share/i18n/SUPPORTED" + fi + + locale-gen --jobs $(makeopts_jobs) --config "${locale_list}" \ + --destdir "${root}" +} + +glibc_do_src_install() { + local builddir=$(builddir nptl) + cd "${builddir}" + + emake install_root="${D}$(alt_prefix)" install || die + + # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support + # which come without headers etc. Only needed for binary packages since the + # external net-libs/libnsl has increased soversion. Keep only versioned libraries. + find "${D}" -name "libnsl.a" -delete + find "${D}" -name "libnsl.so" -delete + + # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need + # to infer upstream version: + # '#define VERSION "2.26.90"' -> '2.26.90' + local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h) + + if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then + # Move versioned .a file out of libdir to evade portage QA checks + # instead of using gen_usr_ldscript(). We fix ldscript as: + # "GROUP ( /usr/lib64/libm-.a ..." -> "GROUP ( /usr/lib64/glibc-/libm-.a ..." + sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"$(alt_usrlibdir)/libm.a || die + dodir $(alt_usrlibdir)/${P} + mv "${ED}"$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die + fi + + # We'll take care of the cache ourselves + rm -f "${ED}"/etc/ld.so.cache + + # Everything past this point just needs to be done once ... + is_final_abi || return 0 + + # Make sure the non-native interp can be found on multilib systems even + # if the main library set isn't installed into the right place. Maybe + # we should query the active gcc for info instead of hardcoding it ? + local i ldso_abi ldso_name + local ldso_abi_list=( + # x86 + amd64 /lib64/ld-linux-x86-64.so.2 + x32 /libx32/ld-linux-x32.so.2 + x86 /lib/ld-linux.so.2 + # mips + o32 /lib/ld.so.1 + n32 /lib32/ld.so.1 + n64 /lib64/ld.so.1 + # powerpc + ppc /lib/ld.so.1 + ppc64 /lib64/ld64.so.1 + # s390 + s390 /lib/ld.so.1 + s390x /lib/ld64.so.1 + # sparc + sparc32 /lib/ld-linux.so.2 + sparc64 /lib64/ld-linux.so.2 + ) + case $(tc-endian) in + little) + ldso_abi_list+=( + # arm + arm64 /lib/ld-linux-aarch64.so.1 + ) + ;; + big) + ldso_abi_list+=( + # arm + arm64 /lib/ld-linux-aarch64_be.so.1 + ) + ;; + esac + if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then + dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib + fi + for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do + ldso_abi=${ldso_abi_list[i]} + has ${ldso_abi} $(get_install_abis) || continue + + ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}" + if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then + dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name} + fi + done + + # With devpts under Linux mounted properly, we do not need the pt_chown + # binary to be setuid. This is because the default owners/perms will be + # exactly what we want. + if ! use suid ; then + find "${ED}" -name pt_chown -exec chmod -s {} + + fi + + ################################################################# + # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY # + # Make sure we install some symlink hacks so that when we build + # a 2nd stage cross-compiler, gcc finds the target system + # headers correctly. See gcc/doc/gccinstall.info + if is_crosscompile ; then + # We need to make sure that /lib and /usr/lib always exists. + # gcc likes to use relative paths to get to its multilibs like + # /usr/lib/../lib64/. So while we don't install any files into + # /usr/lib/, we do need it to exist. + keepdir $(alt_prefix)/lib + keepdir $(alt_prefix)/usr/lib + + dosym usr/include $(alt_prefix)/sys-include + return 0 + fi + + # Files for Debian-style locale updating + dodir /usr/share/i18n + sed \ + -e "/^#/d" \ + -e "/SUPPORTED-LOCALES=/d" \ + -e "s: \\\\::g" -e "s:/: :g" \ + "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \ + || die "generating /usr/share/i18n/SUPPORTED failed" + cd "${WORKDIR}"/extra/locale + dosbin locale-gen + doman *.[0-8] + insinto /etc + doins locale.gen + + # Make sure all the ABI's can find the locales and so we only + # have to generate one set + local a + keepdir /usr/$(get_libdir)/locale + for a in $(get_install_abis) ; do + if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then + dosym ../$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale + fi + done + + cd "${S}" + + # Install misc network config files + insinto /etc + doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf + doins "${WORKDIR}"/extra/etc/*.conf + + if use nscd ; then + doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)" + + local nscd_args=( + -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):" + ) + + sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd + + systemd_dounit nscd/nscd.service + systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf + else + # Do this since extra/etc/*.conf above might have nscd.conf. + rm -f "${ED}"/etc/nscd.conf + fi + + echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc + doenvd "${T}"/00glibc + + for d in BUGS ChangeLog CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do + [[ -s ${d} ]] && dodoc ${d} + done + dodoc -r ChangeLog.old + + # Prevent overwriting of the /etc/localtime symlink. We'll handle the + # creation of the "factory" symlink in pkg_postinst(). + rm -f "${ED}"/etc/localtime + + # Generate all locales if this is a native build as locale generation + if use compile-locales && ! is_crosscompile ; then + run_locale_gen "${ED}" + fi +} + +glibc_headers_install() { + local builddir=$(builddir "headers") + cd "${builddir}" + emake install_root="${D}$(alt_prefix)" install-headers + + insinto $(alt_headers)/gnu + doins "${S}"/include/gnu/stubs.h + + # Make sure we install the sys-include symlink so that when + # we build a 2nd stage cross-compiler, gcc finds the target + # system headers correctly. See gcc/doc/gccinstall.info + dosym usr/include $(alt_prefix)/sys-include +} + +src_strip() { + # gdb is lame and requires some debugging information to remain in + # libpthread, so we need to strip it by hand. libthread_db makes no + # sense stripped as it is only used when debugging. + local pthread=$(has splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}") + env \ + -uRESTRICT \ + CHOST=${CTARGET} \ + STRIP_MASK="/*/{,tls/}${pthread}*" \ + prepallstrip + # if user has stripping enabled and does not have split debug turned on, + # then leave the debugging sections in libpthread. + if ! has nostrip ${FEATURES} && ! has splitdebug ${FEATURES} ; then + ${STRIP:-${CTARGET}-strip} --strip-debug "${ED}"$(alt_prefix)/*/libpthread-*.so + fi +} + +src_install() { + if just_headers ; then + export ABI=default + glibc_headers_install + return + fi + + foreach_abi glibc_do_src_install + src_strip +} + +# Simple test to make sure our new glibc isn't completely broken. +# Make sure we don't test with statically built binaries since +# they will fail. Also, skip if this glibc is a cross compiler. +# +# If coreutils is built with USE=multicall, some of these files +# will just be wrapper scripts, not actual ELFs we can test. +glibc_sanity_check() { + cd / #228809 + + # We enter ${ED} so to avoid trouble if the path contains + # special characters; for instance if the path contains the + # colon character (:), then the linker will try to split it + # and look for the libraries in an unexpected place. This can + # lead to unsafe code execution if the generated prefix is + # within a world-writable directory. + # (e.g. /var/tmp/portage:${HOSTNAME}) + pushd "${ED}"/$(get_libdir) >/dev/null + + local x striptest + for x in cal date env free ls true uname uptime ; do + x=$(type -p ${x}) + [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue + striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue + case ${striptest} in + *"statically linked"*) continue;; + *"ASCII text"*) continue;; + esac + # We need to clear the locale settings as the upgrade might want + # incompatible locale data. This test is not for verifying that. + LC_ALL=C \ + ./ld-*.so --library-path . ${x} > /dev/null \ + || die "simple run test (${x}) failed" + done + + popd >/dev/null +} + +pkg_preinst() { + # nothing to do if just installing headers + just_headers && return + + # prepare /etc/ld.so.conf.d/ for files + mkdir -p "${EROOT}"/etc/ld.so.conf.d + + # Default /etc/hosts.conf:multi to on for systems with small dbs. + if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then + sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf + einfo "Defaulting /etc/host.conf:multi to on" + fi + + [[ ${ROOT} != "/" ]] && return 0 + [[ -d ${ED}/$(get_libdir) ]] || return 0 + [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check +} + +pkg_postinst() { + # nothing to do if just installing headers + just_headers && return + + if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then + # Generate fastloading iconv module configuration file. + "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}" + fi + + if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then + # Reload init ... if in a chroot or a diff init package, ignore + # errors from this step #253697 + /sbin/telinit U 2>/dev/null + + use compile-locales || run_locale_gen "${EROOT}" + fi + + # Check for sanity of /etc/nsswitch.conf, take 2 + if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then + local entry + for entry in passwd group shadow; do + if egrep -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then + ewarn "" + ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been" + ewarn "removed from glibc and is now provided by the package" + ewarn " sys-auth/libnss-nis" + ewarn "Install it now to keep your NIS setup working." + ewarn "" + fi + done + fi +} diff --git a/sys-libs/glibc/glibc-2.29-r1.ebuild b/sys-libs/glibc/glibc-2.29-r1.ebuild deleted file mode 100644 index 34fad50ec4fa..000000000000 --- a/sys-libs/glibc/glibc-2.29-r1.ebuild +++ /dev/null @@ -1,1418 +0,0 @@ -# Copyright 1999-2019 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=6 - -PYTHON_COMPAT=( python3_{4,5,6,7} ) - -inherit python-any-r1 prefix eutils eapi7-ver toolchain-funcs flag-o-matic gnuconfig \ - multilib systemd multiprocessing - -DESCRIPTION="GNU libc C library" -HOMEPAGE="https://www.gnu.org/software/libc/" -LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE" -RESTRICT="strip" # Strip ourself #46186 -SLOT="2.2" - -EMULTILIB_PKG="true" - -if [[ ${PV} == 9999* ]]; then - EGIT_REPO_URI="https://sourceware.org/git/glibc.git" - inherit git-r3 -else - KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" - SRC_URI="mirror://gnu/glibc/${P}.tar.xz" -fi - -RELEASE_VER=${PV} - -GCC_BOOTSTRAP_VER=20180511 - -# Gentoo patchset -PATCH_VER=2 - -SRC_URI+=" https://dev.gentoo.org/~dilfridge/distfiles/${P}-patches-${PATCH_VER}.tar.xz" -SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )" - -IUSE="audit caps cet compile-locales doc gd headers-only +multiarch multilib nscd profile selinux +ssp suid systemtap test vanilla" - -# Minimum kernel version that glibc requires -MIN_KERN_VER="3.2.0" - -# Here's how the cross-compile logic breaks down ... -# CTARGET - machine that will target the binaries -# CHOST - machine that will host the binaries -# CBUILD - machine that will build the binaries -# If CTARGET != CHOST, it means you want a libc for cross-compiling. -# If CHOST != CBUILD, it means you want to cross-compile the libc. -# CBUILD = CHOST = CTARGET - native build/install -# CBUILD != (CHOST = CTARGET) - cross-compile a native build -# (CBUILD = CHOST) != CTARGET - libc for cross-compiler -# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler -# For install paths: -# CHOST = CTARGET - install into / -# CHOST != CTARGET - install into /usr/CTARGET/ -# -export CBUILD=${CBUILD:-${CHOST}} -export CTARGET=${CTARGET:-${CHOST}} -if [[ ${CTARGET} == ${CHOST} ]] ; then - if [[ ${CATEGORY} == cross-* ]] ; then - export CTARGET=${CATEGORY#cross-} - fi -fi - -# We need a new-enough binutils/gcc to match upstream baseline. -# Also we need to make sure our binutils/gcc supports TLS, -# and that gcc already contains the hardened patches. -COMMON_DEPEND=" - nscd? ( selinux? ( - audit? ( sys-process/audit ) - caps? ( sys-libs/libcap ) - ) ) - suid? ( caps? ( sys-libs/libcap ) ) - selinux? ( sys-libs/libselinux ) - systemtap? ( dev-util/systemtap ) -" -DEPEND="${COMMON_DEPEND} - ${PYTHON_DEPS} - >=app-misc/pax-utils-0.1.10 - sys-devel/bison - !=net-dns/libidn2-2.0.5 ) -" -RDEPEND="${COMMON_DEPEND} - sys-apps/gentoo-functions - !sys-kernel/ps3-sources - !sys-libs/nss-db -" - -if [[ ${CATEGORY} == cross-* ]] ; then - DEPEND+=" !headers-only? ( - >=${CATEGORY}/binutils-2.24 - >=${CATEGORY}/gcc-6 - )" - [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers" -else - DEPEND+=" - >=sys-devel/binutils-2.24 - >=sys-devel/gcc-6 - virtual/os-headers - " - RDEPEND+=" - >=net-dns/libidn2-2.0.5 - vanilla? ( !sys-libs/timezone-data ) - " - PDEPEND+=" !vanilla? ( sys-libs/timezone-data )" -fi - -# -# Small helper functions -# - -is_crosscompile() { - [[ ${CHOST} != ${CTARGET} ]] -} - -just_headers() { - is_crosscompile && use headers-only -} - -alt_prefix() { - is_crosscompile && echo /usr/${CTARGET} -} - -# We need to be able to set alternative headers for compiling for non-native -# platform. Will also become useful for testing kernel-headers without screwing -# up the whole system. -alt_headers() { - echo ${ALT_HEADERS:=$(alt_prefix)/usr/include} -} - -alt_build_headers() { - if [[ -z ${ALT_BUILD_HEADERS} ]] ; then - ALT_BUILD_HEADERS="${EPREFIX}$(alt_headers)" - if tc-is-cross-compiler ; then - ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers) - if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then - local header_path=$(echo '#include ' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h') - ALT_BUILD_HEADERS=${header_path%/linux/version.h} - fi - fi - fi - echo "${ALT_BUILD_HEADERS}" -} - -alt_libdir() { - echo $(alt_prefix)/$(get_libdir) -} -alt_usrlibdir() { - echo $(alt_prefix)/usr/$(get_libdir) -} - -builddir() { - echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1" -} - -do_compile_test() { - local ret save_cflags=${CFLAGS} - CFLAGS+=" $1" - shift - - pushd "${T}" >/dev/null - - rm -f glibc-test* - printf '%b' "$*" > glibc-test.c - - nonfatal emake -s glibc-test - ret=$? - - popd >/dev/null - - CFLAGS=${save_cflags} - return ${ret} -} - -do_run_test() { - local ret - - if [[ ${MERGE_TYPE} == "binary" ]] ; then - # ignore build failures when installing a binary package #324685 - do_compile_test "" "$@" 2>/dev/null || return 0 - else - if ! do_compile_test "" "$@" ; then - ewarn "Simple build failed ... assuming this is desired #324685" - return 0 - fi - fi - - pushd "${T}" >/dev/null - - ./glibc-test - ret=$? - rm -f glibc-test* - - popd >/dev/null - - return ${ret} -} - -setup_target_flags() { - # This largely mucks with compiler flags. None of which should matter - # when building up just the headers. - just_headers && return 0 - - case $(tc-arch) in - x86) - # -march needed for #185404 #199334 - # TODO: When creating the first glibc cross-compile, this test will - # always fail as it does a full link which in turn requires glibc. - # Probably also applies when changing multilib profile settings (e.g. - # enabling x86 when the profile was amd64-only previously). - # We could change main to _start and pass -nostdlib here so that we - # only test the gcc code compilation. Or we could do a compile and - # then look for the symbol via scanelf. - if ! do_compile_test "" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then - local t=${CTARGET_OPT:-${CTARGET}} - t=${t%%-*} - filter-flags '-march=*' - export CFLAGS="-march=${t} ${CFLAGS}" - einfo "Auto adding -march=${t} to CFLAGS #185404" - fi - ;; - amd64) - # -march needed for #185404 #199334 - # Note: This test only matters when the x86 ABI is enabled, so we could - # optimize a bit and elide it. - # TODO: See cross-compile issues listed above for x86. - if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then - local t=${CTARGET_OPT:-${CTARGET}} - t=${t%%-*} - # Normally the target is x86_64-xxx, so turn that into the -march that - # gcc actually accepts. #528708 - [[ ${t} == "x86_64" ]] && t="x86-64" - filter-flags '-march=*' - # ugly, ugly, ugly. ugly. - CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") - export CFLAGS_x86="${CFLAGS_x86} -march=${t}" - einfo "Auto adding -march=${t} to CFLAGS_x86 #185404" - fi - ;; - mips) - # The mips abi cannot support the GNU style hashes. #233233 - filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both - ;; - sparc) - # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though. - filter-flags "-fcall-used-g7" - append-flags "-fcall-used-g6" - - # If the CHOST is the basic one (e.g. not sparcv9-xxx already), - # try to pick a better one so glibc can use cpu-specific .S files. - # We key off the CFLAGS to get a good value. Also need to handle - # version skew. - # We can't force users to set their CHOST to their exact machine - # as many of these are not recognized by config.sub/gcc and such :(. - # Note: If the mcpu values don't scale, we might try probing CPP defines. - # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ? - - local cpu - case ${CTARGET} in - sparc64-*) - case $(get-flag mcpu) in - niagara[234]) - if ver_test -ge 2.8 ; then - cpu="sparc64v2" - elif ver_test -ge 2.4 ; then - cpu="sparc64v" - elif ver_test -ge 2.2.3 ; then - cpu="sparc64b" - fi - ;; - niagara) - if ver_test -ge 2.4 ; then - cpu="sparc64v" - elif ver_test -ge 2.2.3 ; then - cpu="sparc64b" - fi - ;; - ultrasparc3) - cpu="sparc64b" - ;; - *) - # We need to force at least v9a because the base build doesn't - # work with just v9. - # https://sourceware.org/bugzilla/show_bug.cgi?id=19477 - [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a" - ;; - esac - ;; - sparc-*) - case $(get-flag mcpu) in - niagara[234]) - if ver_test -ge 2.8 ; then - cpu="sparcv9v2" - elif ver_test -ge 2.4 ; then - cpu="sparcv9v" - elif ver_test -ge 2.2.3 ; then - cpu="sparcv9b" - else - cpu="sparcv9" - fi - ;; - niagara) - if ver_test -ge 2.4 ; then - cpu="sparcv9v" - elif ver_test -ge 2.2.3 ; then - cpu="sparcv9b" - else - cpu="sparcv9" - fi - ;; - ultrasparc3) - cpu="sparcv9b" - ;; - v9|ultrasparc) - cpu="sparcv9" - ;; - v8|supersparc|hypersparc|leon|leon3) - cpu="sparcv8" - ;; - esac - ;; - esac - [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}" - ;; - esac -} - -setup_flags() { - # Make sure host make.conf doesn't pollute us - if is_crosscompile || tc-is-cross-compiler ; then - CHOST=${CTARGET} strip-unsupported-flags - fi - - # Store our CFLAGS because it's changed depending on which CTARGET - # we are building when pulling glibc on a multilib profile - CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}} - CFLAGS=${CFLAGS_BASE} - CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}} - CXXFLAGS=${CXXFLAGS_BASE} - ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}} - ASFLAGS=${ASFLAGS_BASE} - - # Over-zealous CFLAGS can often cause problems. What may work for one - # person may not work for another. To avoid a large influx of bugs - # relating to failed builds, we strip most CFLAGS out to ensure as few - # problems as possible. - strip-flags - strip-unsupported-flags - filter-flags -m32 -m64 '-mabi=*' - - # glibc aborts if rpath is set by LDFLAGS - filter-ldflags '-Wl,-rpath=*' - - # #492892 - filter-flags -frecord-gcc-switches - - unset CBUILD_OPT CTARGET_OPT - if use multilib ; then - CTARGET_OPT=$(get_abi_CTARGET) - [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST) - fi - - setup_target_flags - - if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then - CBUILD_OPT=${CTARGET_OPT} - fi - - # Lock glibc at -O2; we want to be conservative here. - # -fno-strict-aliasing is to work around #155906. - filter-flags '-O?' - append-flags -O2 -fno-strict-aliasing - - filter-flags '-fstack-protector*' -} - -want_tls() { - # Archs that can use TLS (Thread Local Storage) - case $(tc-arch) in - x86) - # requires i486 or better #106556 - [[ ${CTARGET} == i[4567]86* ]] && return 0 - return 1 - ;; - esac - return 0 -} - -want__thread() { - want_tls || return 1 - - # For some reason --with-tls --with__thread is causing segfaults on sparc32. - [[ ${PROFILE_ARCH} == "sparc" ]] && return 1 - - [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD} - - # only test gcc -- can't test linking yet - tc-has-tls -c ${CTARGET} - WANT__THREAD=$? - - return ${WANT__THREAD} -} - -use_multiarch() { - # Allow user to disable runtime arch detection in multilib. - use multiarch || return 1 - # Make sure binutils is new enough to support indirect functions, - # #336792. This funky sed supports gold and bfd linkers. - local bver nver - bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}') - case $(tc-arch ${CTARGET}) in - amd64|x86) nver="2.20" ;; - arm) nver="2.22" ;; - hppa) nver="2.23" ;; - ppc|ppc64) nver="2.20" ;; - # ifunc support was added in 2.23, but glibc also needs - # machinemode which is in 2.24. - s390) nver="2.24" ;; - sparc) nver="2.21" ;; - *) return 1 ;; - esac - ver_test ${bver} -ge ${nver} -} - -# Setup toolchain variables that had historically been defined in the -# profiles for these archs. -setup_env() { - # silly users - unset LD_RUN_PATH - unset LD_ASSUME_KERNEL - - if is_crosscompile || tc-is-cross-compiler ; then - multilib_env ${CTARGET_OPT:-${CTARGET}} - - if ! use multilib ; then - MULTILIB_ABIS=${DEFAULT_ABI} - else - MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}} - fi - - # If the user has CFLAGS_ in their make.conf, use that, - # and fall back on CFLAGS. - local VAR=CFLAGS_${CTARGET//[-.]/_} - CFLAGS=${!VAR-${CFLAGS}} - einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}" - fi - - setup_flags - - export ABI=${ABI:-${DEFAULT_ABI:-default}} - - if just_headers ; then - # Avoid mixing host's CC and target's CFLAGS_${ABI}: - # At this bootstrap stage we have only binutils for - # target but not compiler yet. - einfo "Skip CC ABI injection. We can't use (cross-)compiler yet." - return 0 - fi - local VAR=CFLAGS_${ABI} - # We need to export CFLAGS with abi information in them because glibc's - # configure script checks CFLAGS for some targets (like mips). Keep - # around the original clean value to avoid appending multiple ABIs on - # top of each other. - : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})} - export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}" - einfo " $(printf '%15s' 'Manual CC:') ${CC}" -} - -foreach_abi() { - setup_env - - local ret=0 - local abilist="" - if use multilib ; then - abilist=$(get_install_abis) - else - abilist=${DEFAULT_ABI} - fi - local -x ABI - for ABI in ${abilist:-default} ; do - setup_env - einfo "Running $1 for ABI ${ABI}" - $1 - : $(( ret |= $? )) - done - return ${ret} -} - -glibc_banner() { - local b="Gentoo ${PVR}" - [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}" - echo "${b}" -} - -check_devpts() { - # Make sure devpts is mounted correctly for use w/out setuid pt_chown. - - # If merely building the binary package, then there's nothing to verify. - [[ ${MERGE_TYPE} == "buildonly" ]] && return - - # Only sanity check when installing the native glibc. - [[ ${ROOT} != "/" ]] && return - - # If they're opting in to the old suid code, then no need to check. - use suid && return - - if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then - eerror "In order to use glibc with USE=-suid, you must make sure that" - eerror "you have devpts mounted at /dev/pts with the gid=5 option." - eerror "Openrc should do this for you, so you should check /etc/fstab" - eerror "and make sure you do not have any invalid settings there." - die "mount & fix your /dev/pts settings" - fi -} - -# The following Kernel version handling functions are mostly copied from portage -# source. It's better not to use linux-info.eclass here since a) it adds too -# much magic, see bug 326693 for some of the arguments, and b) some of the -# functions are just not provided. - -g_get_running_KV() { - uname -r - return $? -} - -g_KV_major() { - [[ -z $1 ]] && return 1 - local KV=$@ - echo "${KV%%.*}" -} - -g_KV_minor() { - [[ -z $1 ]] && return 1 - local KV=$@ - KV=${KV#*.} - echo "${KV%%.*}" -} - -g_KV_micro() { - [[ -z $1 ]] && return 1 - local KV=$@ - KV=${KV#*.*.} - echo "${KV%%[^[:digit:]]*}" -} - -g_KV_to_int() { - [[ -z $1 ]] && return 1 - local KV_MAJOR=$(g_KV_major "$1") - local KV_MINOR=$(g_KV_minor "$1") - local KV_MICRO=$(g_KV_micro "$1") - local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO )) - - # We make version 2.2.0 the minimum version we will handle as - # a sanity check ... if its less, we fail ... - if [[ ${KV_int} -ge 131584 ]] ; then - echo "${KV_int}" - return 0 - fi - return 1 -} - -g_int_to_KV() { - local version=$1 major minor micro - major=$((version / 65536)) - minor=$(((version % 65536) / 256)) - micro=$((version % 256)) - echo ${major}.${minor}.${micro} -} - -eend_KV() { - [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]] - eend $? -} - -get_kheader_version() { - printf '#include \nLINUX_VERSION_CODE\n' | \ - $(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" - | \ - tail -n 1 -} - -# We collect all sanity checks here. Consistency is not guranteed between -# pkg_ and src_ phases, so we call this function both in pkg_pretend and in -# src_unpack. -sanity_prechecks() { - # Make sure devpts is mounted correctly for use w/out setuid pt_chown - check_devpts - - # Prevent native builds from downgrading - if [[ ${MERGE_TYPE} != "buildonly" ]] && \ - [[ ${ROOT} == "/" ]] && \ - [[ ${CBUILD} == ${CHOST} ]] && \ - [[ ${CHOST} == ${CTARGET} ]] ; then - - # The high rev # is to allow people to downgrade between -r# - # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2 - # should be fine. Hopefully we never actually use a r# this - # high. - if has_version ">${CATEGORY}/${P}-r10000" ; then - eerror "Sanity check to keep you from breaking your system:" - eerror " Downgrading glibc is not supported and a sure way to destruction." - die "Aborting to save your system." - fi - - if ! do_run_test '#include \n#include \nint main(){return syscall(1000)!=-1;}\n' ; then - eerror "Your old kernel is broken. You need to update it to a newer" - eerror "version as syscall() will break. See bug 279260." - die "Old and broken kernel." - fi - fi - - # Users have had a chance to phase themselves, time to give em the boot - if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then - eerror "You still haven't deleted ${EROOT}/etc/locales.build." - eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher." - die "Lazy upgrader detected" - fi - - if [[ ${CTARGET} == i386-* ]] ; then - eerror "i386 CHOSTs are no longer supported." - eerror "Chances are you don't actually want/need i386." - eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml" - die "Please fix your CHOST" - fi - - if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then - ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS." - ewarn "This will result in a 50% performance penalty when running with a 32bit" - ewarn "hypervisor, which is probably not what you want." - fi - - # Check for sanity of /etc/nsswitch.conf - if [[ -e ${EROOT}/etc/nsswitch.conf ]] ; then - local entry - for entry in passwd group shadow; do - if ! egrep -q "^[ \t]*${entry}:.*files" "${EROOT}"/etc/nsswitch.conf; then - eerror "Your ${EROOT}/etc/nsswitch.conf is out of date." - eerror "Please make sure you have 'files' entries for" - eerror "'passwd:', 'group:' and 'shadow:' databases." - eerror "For more details see:" - eerror " https://wiki.gentoo.org/wiki/Project:Toolchain/nsswitch.conf_in_glibc-2.26" - die "nsswitch.conf has no 'files' provider in '${entry}'." - fi - done - fi - - # ABI-specific checks follow here. Hey, we have a lot more specific conditions that - # we test for... - if ! is_crosscompile ; then - if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then - ebegin "Checking that IA32 emulation is enabled in the running kernel" - echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c" - local STAT - if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then - "${T}/check-ia32-emulation.elf32" - STAT=$? - else - # Don't fail here to allow single->multi ABI switch - # or recover from breakage like bug #646424 - ewarn "Failed to compile the ABI test. Broken host glibc?" - STAT=0 - fi - rm -f "${T}/check-ia32-emulation.elf32" - eend $STAT - [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc." - fi - - fi - - # When we actually have to compile something... - if ! just_headers ; then - ebegin "Checking gcc for __thread support" - if ! eend $(want__thread ; echo $?) ; then - echo - eerror "Could not find a gcc that supports the __thread directive!" - eerror "Please update your binutils/gcc and try again." - die "No __thread support in gcc!" - fi - - if [[ ${CTARGET} == *-linux* ]] ; then - local run_kv build_kv want_kv - - run_kv=$(g_get_running_KV) - build_kv=$(g_int_to_KV $(get_kheader_version)) - want_kv=${MIN_KERN_VER} - - if ! is_crosscompile && ! tc-is-cross-compiler ; then - # Building fails on an non-supporting kernel - ebegin "Checking running kernel version (${run_kv} >= ${want_kv})" - if ! eend_KV ${run_kv} ${want_kv} ; then - echo - eerror "You need a kernel of at least ${want_kv}!" - die "Kernel version too low!" - fi - fi - - ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})" - if ! eend_KV ${build_kv} ${want_kv} ; then - echo - eerror "You need linux-headers of at least ${want_kv}!" - die "linux-headers version too low!" - fi - fi - fi -} - -# -# the phases -# - -# pkg_pretend - -pkg_pretend() { - # All the checks... - einfo "Checking general environment sanity." - sanity_prechecks -} - -# src_unpack - -src_unpack() { - # Consistency is not guaranteed between pkg_ and src_ ... - sanity_prechecks - - use multilib && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz - - setup_env - - if [[ -n ${EGIT_REPO_URI} ]] ; then - git-r3_src_unpack - else - unpack ${P}.tar.xz - fi - - cd "${WORKDIR}" || die - unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz -} - -src_prepare() { - if ! use vanilla ; then - elog "Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER}" - eapply "${WORKDIR}"/patches - einfo "Done." - fi - - default - - gnuconfig_update - - cd "${WORKDIR}" - find . -name configure -exec touch {} + - - eprefixify extra/locale/locale-gen - - # Fix permissions on some of the scripts. - chmod u+x "${S}"/scripts/*.sh - - cd "${S}" -} - -glibc_do_configure() { - # Glibc does not work with gold (for various reasons) #269274. - tc-ld-disable-gold - - # CXX isnt handled by the multilib system, so if we dont unset here - # we accumulate crap across abis - unset CXX - - einfo "Configuring glibc for nptl" - - if use doc ; then - export MAKEINFO=makeinfo - else - export MAKEINFO=/dev/null - fi - - local v - for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO ; do - einfo " $(printf '%15s' ${v}:) ${!v}" - done - - # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760 - # To build .S (assembly) files with the same ABI-specific flags - # upstream currently recommends adding CFLAGS to CC/CXX: - # https://sourceware.org/PR23273 - # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS - # and breaks multiarch support. See 659030#c3 for an example. - # The glibc configure script doesn't properly use LDFLAGS all the time. - export CC="$(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS}" - einfo " $(printf '%15s' 'Manual CC:') ${CC}" - - # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548 - export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS) ${CFLAGS}" - einfo " $(printf '%15s' 'Manual CXX:') ${CXX}" - - echo - - local myconf=() - - case ${CTARGET} in - m68k*) - # setjmp() is not compatible with stack protection: - # https://sourceware.org/PR24202 - myconf+=( --enable-stack-protector=no ) - ;; - powerpc-*) - # Currently gcc on powerpc32 generates invalid code for - # __builtin_return_address(0) calls. Normally programs - # don't do that but malloc hooks in glibc do: - # https://gcc.gnu.org/PR81996 - # https://bugs.gentoo.org/629054 - myconf+=( --enable-stack-protector=no ) - ;; - *) - myconf+=( --enable-stack-protector=$(usex ssp all no) ) - ;; - esac - myconf+=( --enable-stackguard-randomization ) - - # Keep a whitelist of targets supporing IFUNC. glibc's ./configure - # is not robust enough to detect proper support: - # https://bugs.gentoo.org/641216 - # https://sourceware.org/PR22634#c0 - case $(tc-arch ${CTARGET}) in - # Keep whitelist of targets where autodetection mostly works. - amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;; - # Blacklist everywhere else - *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;; - esac - - # Enable Intel Control-flow Enforcement Technology on amd64 if requested - case ${CTARGET} in - x86_64-*) myconf+=( $(use_enable cet) ) ;; - *) ;; - esac - - [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp ) - - myconf+=( --enable-kernel=${MIN_KERN_VER} ) - - # Since SELinux support is only required for nscd, only enable it if: - # 1. USE selinux - # 2. only for the primary ABI on multilib systems - # 3. Not a crosscompile - if ! is_crosscompile && use selinux ; then - if use multilib ; then - if is_final_abi ; then - myconf+=( --with-selinux ) - else - myconf+=( --without-selinux ) - fi - else - myconf+=( --with-selinux ) - fi - else - myconf+=( --without-selinux ) - fi - - # Force a few tests where we always know the answer but - # configure is incapable of finding it. - if is_crosscompile ; then - export \ - libc_cv_c_cleanup=yes \ - libc_cv_forced_unwind=yes - fi - - myconf+=( - --without-cvs - --disable-werror - --enable-bind-now - --build=${CBUILD_OPT:-${CBUILD}} - --host=${CTARGET_OPT:-${CTARGET}} - $(use_enable profile) - $(use_with gd) - --with-headers=$(alt_build_headers) - --prefix="${EPREFIX}/usr" - --sysconfdir="${EPREFIX}/etc" - --localstatedir="${EPREFIX}/var" - --libdir='$(prefix)'/$(get_libdir) - --mandir='$(prefix)'/share/man - --infodir='$(prefix)'/share/info - --libexecdir='$(libdir)'/misc/glibc - --with-bugurl=https://bugs.gentoo.org/ - --with-pkgversion="$(glibc_banner)" - $(use_multiarch || echo --disable-multi-arch) - $(use_enable systemtap) - $(use_enable nscd) - ${EXTRA_ECONF} - ) - - # We rely on sys-libs/timezone-data for timezone tools normally. - myconf+=( $(use_enable vanilla timezone-tools) ) - - # These libs don't have configure flags. - ac_cv_lib_audit_audit_log_user_avc_message=$(usex audit || echo no) - ac_cv_lib_cap_cap_init=$(usex caps || echo no) - - # There is no configure option for this and we need to export it - # since the glibc build will re-run configure on itself - export libc_cv_rootsbindir="${EPREFIX}/sbin" - export libc_cv_slibdir="${EPREFIX}/$(get_libdir)" - - # We take care of patching our binutils to use both hash styles, - # and many people like to force gnu hash style only, so disable - # this overriding check. #347761 - export libc_cv_hashstyle=no - - local builddir=$(builddir nptl) - mkdir -p "${builddir}" - cd "${builddir}" - set -- "${S}"/configure "${myconf[@]}" - echo "$@" - "$@" || die "failed to configure glibc" - - # ia64 static cross-compilers are a pita in so much that they - # can't produce static ELFs (as the libgcc.a is broken). so - # disable building of the programs for those targets if it - # doesn't work. - # XXX: We could turn this into a compiler test, but ia64 is - # the only one that matters, so this should be fine for now. - if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then - sed -i '1i+link-static = touch $@' config.make - fi - - # If we're trying to migrate between ABI sets, we need - # to lie and use a local copy of gcc. Like if the system - # is built with MULTILIB_ABIS="amd64 x86" but we want to - # add x32 to it, gcc/glibc don't yet support x32. - # - if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then - echo 'main(){}' > "${T}"/test.c - if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then - sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die - fi - fi -} - -glibc_headers_configure() { - export ABI=default - - local builddir=$(builddir "headers") - mkdir -p "${builddir}" - cd "${builddir}" - - # if we don't have a compiler yet, we can't really test it now ... - # hopefully they don't affect header generation, so let's hope for - # the best here ... - local v vars=( - ac_cv_header_cpuid_h=yes - libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes - libc_cv_asm_cfi_directives=yes - libc_cv_broken_visibility_attribute=no - libc_cv_c_cleanup=yes - libc_cv_compiler_powerpc64le_binary128_ok=yes - libc_cv_forced_unwind=yes - libc_cv_gcc___thread=yes - libc_cv_mlong_double_128=yes - libc_cv_mlong_double_128ibm=yes - libc_cv_ppc_machine=yes - libc_cv_ppc_rel16=yes - libc_cv_predef_fortify_source=no - libc_cv_target_power8_ok=yes - libc_cv_visibility_attribute=yes - libc_cv_z_combreloc=yes - libc_cv_z_execstack=yes - libc_cv_z_initfirst=yes - libc_cv_z_nodelete=yes - libc_cv_z_nodlopen=yes - libc_cv_z_relro=yes - libc_mips_abi=${ABI} - libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard) - # These libs don't have configure flags. - ac_cv_lib_audit_audit_log_user_avc_message=no - ac_cv_lib_cap_cap_init=no - ) - - einfo "Forcing cached settings:" - for v in "${vars[@]}" ; do - einfo " ${v}" - export ${v} - done - - local headers_only_arch_CPPFLAGS=() - - # Blow away some random CC settings that screw things up. #550192 - if [[ -d ${S}/sysdeps/mips ]]; then - pushd "${S}"/sysdeps/mips >/dev/null - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die - - # Force the mips ABI to the default. This is OK because the set of - # installed headers in this phase is the same between the 3 ABIs. - # If this ever changes, this hack will break, but that's unlikely - # as glibc discourages that behavior. - # https://crbug.com/647033 - sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die - - popd >/dev/null - fi - - case ${CTARGET} in - riscv*) - # RISC-V interrogates the compiler to determine which target to - # build. If building the headers then we don't strictly need a - # RISC-V compiler, so the built-in definitions that are provided - # along with all RISC-V compiler might not exist. This causes - # glibc's RISC-V preconfigure script to blow up. Since we're just - # building the headers any value will actually work here, so just - # pick the standard one (rv64g/lp64d) to make the build scripts - # happy for now -- the headers are all the same anyway so it - # doesn't matter. - headers_only_arch_CPPFLAGS+=( - -D__riscv_xlen=64 - -D__riscv_flen=64 - -D__riscv_float_abi_double=1 - -D__riscv_atomic=1 - ) ;; - esac - - local myconf=() - myconf+=( - --disable-sanity-checks - --enable-hacker-mode - --without-cvs - --disable-werror - --enable-bind-now - --build=${CBUILD_OPT:-${CBUILD}} - --host=${CTARGET_OPT:-${CTARGET}} - --with-headers=$(alt_build_headers) - --prefix="${EPREFIX}/usr" - ${EXTRA_ECONF} - ) - - # Nothing is compiled here which would affect the headers for the target. - # So forcing CC/CFLAGS is sane. - local headers_only_CC=$(tc-getBUILD_CC) - local headers_only_CFLAGS="-O1 -pipe" - local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE ${headers_only_arch_CPPFLAGS[*]}" - local headers_only_LDFLAGS="" - set -- "${S}"/configure "${myconf[@]}" - echo \ - "CC=${headers_only_CC}" \ - "CFLAGS=${headers_only_CFLAGS}" \ - "CPPFLAGS=${headers_only_CPPFLAGS}" \ - "LDFLAGS=${headers_only_LDFLAGS}" \ - "$@" - CC=${headers_only_CC} \ - CFLAGS=${headers_only_CFLAGS} \ - CPPFLAGS=${headers_only_CPPFLAGS} \ - LDFLAGS="" \ - "$@" || die "failed to configure glibc" -} - -do_src_configure() { - if just_headers ; then - glibc_headers_configure - else - glibc_do_configure nptl - fi -} - -src_configure() { - foreach_abi do_src_configure -} - -do_src_compile() { - emake -C "$(builddir nptl)" || die "make nptl for ${ABI} failed" -} - -src_compile() { - if just_headers ; then - return - fi - - foreach_abi do_src_compile -} - -glibc_src_test() { - cd "$(builddir nptl)" - emake check -} - -do_src_test() { - local ret=0 - - glibc_src_test - : $(( ret |= $? )) - - return ${ret} -} - -src_test() { - if just_headers ; then - return - fi - - # Give tests more time to complete. - export TIMEOUTFACTOR=5 - - foreach_abi do_src_test || die "tests failed" -} - -run_locale_gen() { - # if the host locales.gen contains no entries, we'll install everything - local root="$1" - local locale_list="${root}/etc/locale.gen" - if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then - ewarn "Generating all locales; edit /etc/locale.gen to save time/space" - locale_list="${root}/usr/share/i18n/SUPPORTED" - fi - - locale-gen --jobs $(makeopts_jobs) --config "${locale_list}" \ - --destdir "${root}" -} - -glibc_do_src_install() { - local builddir=$(builddir nptl) - cd "${builddir}" - - emake install_root="${D}$(alt_prefix)" install || die - - # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support - # which come without headers etc. Only needed for binary packages since the - # external net-libs/libnsl has increased soversion. Keep only versioned libraries. - find "${D}" -name "libnsl.a" -delete - find "${D}" -name "libnsl.so" -delete - - # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need - # to infer upstream version: - # '#define VERSION "2.26.90"' -> '2.26.90' - local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h) - - if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then - # Move versioned .a file out of libdir to evade portage QA checks - # instead of using gen_usr_ldscript(). We fix ldscript as: - # "GROUP ( /usr/lib64/libm-.a ..." -> "GROUP ( /usr/lib64/glibc-/libm-.a ..." - sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"$(alt_usrlibdir)/libm.a || die - dodir $(alt_usrlibdir)/${P} - mv "${ED}"$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die - fi - - # We'll take care of the cache ourselves - rm -f "${ED}"/etc/ld.so.cache - - # Everything past this point just needs to be done once ... - is_final_abi || return 0 - - # Make sure the non-native interp can be found on multilib systems even - # if the main library set isn't installed into the right place. Maybe - # we should query the active gcc for info instead of hardcoding it ? - local i ldso_abi ldso_name - local ldso_abi_list=( - # x86 - amd64 /lib64/ld-linux-x86-64.so.2 - x32 /libx32/ld-linux-x32.so.2 - x86 /lib/ld-linux.so.2 - # mips - o32 /lib/ld.so.1 - n32 /lib32/ld.so.1 - n64 /lib64/ld.so.1 - # powerpc - ppc /lib/ld.so.1 - ppc64 /lib64/ld64.so.1 - # s390 - s390 /lib/ld.so.1 - s390x /lib/ld64.so.1 - # sparc - sparc32 /lib/ld-linux.so.2 - sparc64 /lib64/ld-linux.so.2 - ) - case $(tc-endian) in - little) - ldso_abi_list+=( - # arm - arm64 /lib/ld-linux-aarch64.so.1 - ) - ;; - big) - ldso_abi_list+=( - # arm - arm64 /lib/ld-linux-aarch64_be.so.1 - ) - ;; - esac - if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then - dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib - fi - for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do - ldso_abi=${ldso_abi_list[i]} - has ${ldso_abi} $(get_install_abis) || continue - - ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}" - if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then - dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name} - fi - done - - # With devpts under Linux mounted properly, we do not need the pt_chown - # binary to be setuid. This is because the default owners/perms will be - # exactly what we want. - if ! use suid ; then - find "${ED}" -name pt_chown -exec chmod -s {} + - fi - - ################################################################# - # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY # - # Make sure we install some symlink hacks so that when we build - # a 2nd stage cross-compiler, gcc finds the target system - # headers correctly. See gcc/doc/gccinstall.info - if is_crosscompile ; then - # We need to make sure that /lib and /usr/lib always exists. - # gcc likes to use relative paths to get to its multilibs like - # /usr/lib/../lib64/. So while we don't install any files into - # /usr/lib/, we do need it to exist. - keepdir $(alt_prefix)/lib - keepdir $(alt_prefix)/usr/lib - - dosym usr/include $(alt_prefix)/sys-include - return 0 - fi - - # Files for Debian-style locale updating - dodir /usr/share/i18n - sed \ - -e "/^#/d" \ - -e "/SUPPORTED-LOCALES=/d" \ - -e "s: \\\\::g" -e "s:/: :g" \ - "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \ - || die "generating /usr/share/i18n/SUPPORTED failed" - cd "${WORKDIR}"/extra/locale - dosbin locale-gen - doman *.[0-8] - insinto /etc - doins locale.gen - - # Make sure all the ABI's can find the locales and so we only - # have to generate one set - local a - keepdir /usr/$(get_libdir)/locale - for a in $(get_install_abis) ; do - if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then - dosym ../$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale - fi - done - - cd "${S}" - - # Install misc network config files - insinto /etc - doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf - doins "${WORKDIR}"/extra/etc/*.conf - - if use nscd ; then - doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)" - - local nscd_args=( - -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):" - ) - - sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd - - systemd_dounit nscd/nscd.service - systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf - else - # Do this since extra/etc/*.conf above might have nscd.conf. - rm -f "${ED}"/etc/nscd.conf - fi - - echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc - doenvd "${T}"/00glibc - - for d in BUGS ChangeLog CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do - [[ -s ${d} ]] && dodoc ${d} - done - dodoc -r ChangeLog.old - - # Prevent overwriting of the /etc/localtime symlink. We'll handle the - # creation of the "factory" symlink in pkg_postinst(). - rm -f "${ED}"/etc/localtime - - # Generate all locales if this is a native build as locale generation - if use compile-locales && ! is_crosscompile ; then - run_locale_gen "${ED}" - fi -} - -glibc_headers_install() { - local builddir=$(builddir "headers") - cd "${builddir}" - emake install_root="${D}$(alt_prefix)" install-headers - - insinto $(alt_headers)/gnu - doins "${S}"/include/gnu/stubs.h - - # Make sure we install the sys-include symlink so that when - # we build a 2nd stage cross-compiler, gcc finds the target - # system headers correctly. See gcc/doc/gccinstall.info - dosym usr/include $(alt_prefix)/sys-include -} - -src_strip() { - # gdb is lame and requires some debugging information to remain in - # libpthread, so we need to strip it by hand. libthread_db makes no - # sense stripped as it is only used when debugging. - local pthread=$(has splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}") - env \ - -uRESTRICT \ - CHOST=${CTARGET} \ - STRIP_MASK="/*/{,tls/}${pthread}*" \ - prepallstrip - # if user has stripping enabled and does not have split debug turned on, - # then leave the debugging sections in libpthread. - if ! has nostrip ${FEATURES} && ! has splitdebug ${FEATURES} ; then - ${STRIP:-${CTARGET}-strip} --strip-debug "${ED}"$(alt_prefix)/*/libpthread-*.so - fi -} - -src_install() { - if just_headers ; then - export ABI=default - glibc_headers_install - return - fi - - foreach_abi glibc_do_src_install - src_strip -} - -# Simple test to make sure our new glibc isn't completely broken. -# Make sure we don't test with statically built binaries since -# they will fail. Also, skip if this glibc is a cross compiler. -# -# If coreutils is built with USE=multicall, some of these files -# will just be wrapper scripts, not actual ELFs we can test. -glibc_sanity_check() { - cd / #228809 - - # We enter ${ED} so to avoid trouble if the path contains - # special characters; for instance if the path contains the - # colon character (:), then the linker will try to split it - # and look for the libraries in an unexpected place. This can - # lead to unsafe code execution if the generated prefix is - # within a world-writable directory. - # (e.g. /var/tmp/portage:${HOSTNAME}) - pushd "${ED}"/$(get_libdir) >/dev/null - - local x striptest - for x in cal date env free ls true uname uptime ; do - x=$(type -p ${x}) - [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue - striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue - case ${striptest} in - *"statically linked"*) continue;; - *"ASCII text"*) continue;; - esac - # We need to clear the locale settings as the upgrade might want - # incompatible locale data. This test is not for verifying that. - LC_ALL=C \ - ./ld-*.so --library-path . ${x} > /dev/null \ - || die "simple run test (${x}) failed" - done - - popd >/dev/null -} - -pkg_preinst() { - # nothing to do if just installing headers - just_headers && return - - # prepare /etc/ld.so.conf.d/ for files - mkdir -p "${EROOT}"/etc/ld.so.conf.d - - # Default /etc/hosts.conf:multi to on for systems with small dbs. - if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then - sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf - einfo "Defaulting /etc/host.conf:multi to on" - fi - - [[ ${ROOT} != "/" ]] && return 0 - [[ -d ${ED}/$(get_libdir) ]] || return 0 - [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check -} - -pkg_postinst() { - # nothing to do if just installing headers - just_headers && return - - if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then - # Generate fastloading iconv module configuration file. - "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}" - fi - - if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then - # Reload init ... if in a chroot or a diff init package, ignore - # errors from this step #253697 - /sbin/telinit U 2>/dev/null - - use compile-locales || run_locale_gen "${EROOT}" - fi - - # Check for sanity of /etc/nsswitch.conf, take 2 - if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then - local entry - for entry in passwd group shadow; do - if egrep -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then - ewarn "" - ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been" - ewarn "removed from glibc and is now provided by the package" - ewarn " sys-auth/libnss-nis" - ewarn "Install it now to keep your NIS setup working." - ewarn "" - fi - done - fi -} diff --git a/sys-libs/glibc/glibc-2.29-r2.ebuild b/sys-libs/glibc/glibc-2.29-r2.ebuild new file mode 100644 index 000000000000..60641cf7a5d0 --- /dev/null +++ b/sys-libs/glibc/glibc-2.29-r2.ebuild @@ -0,0 +1,1448 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +PYTHON_COMPAT=( python3_{5,6,7} ) + +inherit python-any-r1 prefix eutils eapi7-ver toolchain-funcs flag-o-matic gnuconfig \ + multilib systemd multiprocessing + +DESCRIPTION="GNU libc C library" +HOMEPAGE="https://www.gnu.org/software/libc/" +LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE" +RESTRICT="strip" # Strip ourself #46186 +SLOT="2.2" + +EMULTILIB_PKG="true" + +if [[ ${PV} == 9999* ]]; then + EGIT_REPO_URI="https://sourceware.org/git/glibc.git" + inherit git-r3 +else + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" + SRC_URI="mirror://gnu/glibc/${P}.tar.xz" +fi + +RELEASE_VER=${PV} + +GCC_BOOTSTRAP_VER=20180511 + +# Gentoo patchset +PATCH_VER=3 + +SRC_URI+=" https://dev.gentoo.org/~dilfridge/distfiles/${P}-patches-${PATCH_VER}.tar.xz" +SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )" + +IUSE="audit caps cet compile-locales doc gd headers-only +multiarch multilib nscd profile selinux +ssp suid systemtap test vanilla" + +# Minimum kernel version that glibc requires +MIN_KERN_VER="3.2.0" + +# Here's how the cross-compile logic breaks down ... +# CTARGET - machine that will target the binaries +# CHOST - machine that will host the binaries +# CBUILD - machine that will build the binaries +# If CTARGET != CHOST, it means you want a libc for cross-compiling. +# If CHOST != CBUILD, it means you want to cross-compile the libc. +# CBUILD = CHOST = CTARGET - native build/install +# CBUILD != (CHOST = CTARGET) - cross-compile a native build +# (CBUILD = CHOST) != CTARGET - libc for cross-compiler +# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler +# For install paths: +# CHOST = CTARGET - install into / +# CHOST != CTARGET - install into /usr/CTARGET/ +# +export CBUILD=${CBUILD:-${CHOST}} +export CTARGET=${CTARGET:-${CHOST}} +if [[ ${CTARGET} == ${CHOST} ]] ; then + if [[ ${CATEGORY} == cross-* ]] ; then + export CTARGET=${CATEGORY#cross-} + fi +fi + +# We need a new-enough binutils/gcc to match upstream baseline. +# Also we need to make sure our binutils/gcc supports TLS, +# and that gcc already contains the hardened patches. +COMMON_DEPEND=" + nscd? ( selinux? ( + audit? ( sys-process/audit ) + caps? ( sys-libs/libcap ) + ) ) + suid? ( caps? ( sys-libs/libcap ) ) + selinux? ( sys-libs/libselinux ) + systemtap? ( dev-util/systemtap ) +" +DEPEND="${COMMON_DEPEND} + ${PYTHON_DEPS} + >=app-misc/pax-utils-0.1.10 + sys-devel/bison + !=net-dns/libidn2-2.0.5 ) +" +RDEPEND="${COMMON_DEPEND} + sys-apps/gentoo-functions + !sys-kernel/ps3-sources + !sys-libs/nss-db +" + +if [[ ${CATEGORY} == cross-* ]] ; then + DEPEND+=" !headers-only? ( + >=${CATEGORY}/binutils-2.24 + >=${CATEGORY}/gcc-6 + )" + [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers" +else + DEPEND+=" + >=sys-devel/binutils-2.24 + >=sys-devel/gcc-6 + virtual/os-headers + " + RDEPEND+=" + >=net-dns/libidn2-2.0.5 + vanilla? ( !sys-libs/timezone-data ) + " + PDEPEND+=" !vanilla? ( sys-libs/timezone-data )" +fi + +# +# Small helper functions +# + +is_crosscompile() { + [[ ${CHOST} != ${CTARGET} ]] +} + +just_headers() { + is_crosscompile && use headers-only +} + +alt_prefix() { + is_crosscompile && echo /usr/${CTARGET} +} + +# We need to be able to set alternative headers for compiling for non-native +# platform. Will also become useful for testing kernel-headers without screwing +# up the whole system. +alt_headers() { + echo ${ALT_HEADERS:=$(alt_prefix)/usr/include} +} + +alt_build_headers() { + if [[ -z ${ALT_BUILD_HEADERS} ]] ; then + ALT_BUILD_HEADERS="${EPREFIX}$(alt_headers)" + if tc-is-cross-compiler ; then + ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers) + if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then + local header_path=$(echo '#include ' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h') + ALT_BUILD_HEADERS=${header_path%/linux/version.h} + fi + fi + fi + echo "${ALT_BUILD_HEADERS}" +} + +alt_libdir() { + echo $(alt_prefix)/$(get_libdir) +} +alt_usrlibdir() { + echo $(alt_prefix)/usr/$(get_libdir) +} + +builddir() { + echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1" +} + +do_compile_test() { + local ret save_cflags=${CFLAGS} + CFLAGS+=" $1" + shift + + pushd "${T}" >/dev/null + + rm -f glibc-test* + printf '%b' "$*" > glibc-test.c + + nonfatal emake -s glibc-test + ret=$? + + popd >/dev/null + + CFLAGS=${save_cflags} + return ${ret} +} + +do_run_test() { + local ret + + if [[ ${MERGE_TYPE} == "binary" ]] ; then + # ignore build failures when installing a binary package #324685 + do_compile_test "" "$@" 2>/dev/null || return 0 + else + if ! do_compile_test "" "$@" ; then + ewarn "Simple build failed ... assuming this is desired #324685" + return 0 + fi + fi + + pushd "${T}" >/dev/null + + ./glibc-test + ret=$? + rm -f glibc-test* + + popd >/dev/null + + return ${ret} +} + +setup_target_flags() { + # This largely mucks with compiler flags. None of which should matter + # when building up just the headers. + just_headers && return 0 + + case $(tc-arch) in + x86) + # -march needed for #185404 #199334 + # TODO: When creating the first glibc cross-compile, this test will + # always fail as it does a full link which in turn requires glibc. + # Probably also applies when changing multilib profile settings (e.g. + # enabling x86 when the profile was amd64-only previously). + # We could change main to _start and pass -nostdlib here so that we + # only test the gcc code compilation. Or we could do a compile and + # then look for the symbol via scanelf. + if ! do_compile_test "" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then + local t=${CTARGET_OPT:-${CTARGET}} + t=${t%%-*} + filter-flags '-march=*' + export CFLAGS="-march=${t} ${CFLAGS}" + einfo "Auto adding -march=${t} to CFLAGS #185404" + fi + ;; + amd64) + # -march needed for #185404 #199334 + # Note: This test only matters when the x86 ABI is enabled, so we could + # optimize a bit and elide it. + # TODO: See cross-compile issues listed above for x86. + if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then + local t=${CTARGET_OPT:-${CTARGET}} + t=${t%%-*} + # Normally the target is x86_64-xxx, so turn that into the -march that + # gcc actually accepts. #528708 + [[ ${t} == "x86_64" ]] && t="x86-64" + filter-flags '-march=*' + # ugly, ugly, ugly. ugly. + CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") + export CFLAGS_x86="${CFLAGS_x86} -march=${t}" + einfo "Auto adding -march=${t} to CFLAGS_x86 #185404" + fi + ;; + mips) + # The mips abi cannot support the GNU style hashes. #233233 + filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both + ;; + sparc) + # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though. + filter-flags "-fcall-used-g7" + append-flags "-fcall-used-g6" + + # If the CHOST is the basic one (e.g. not sparcv9-xxx already), + # try to pick a better one so glibc can use cpu-specific .S files. + # We key off the CFLAGS to get a good value. Also need to handle + # version skew. + # We can't force users to set their CHOST to their exact machine + # as many of these are not recognized by config.sub/gcc and such :(. + # Note: If the mcpu values don't scale, we might try probing CPP defines. + # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ? + + local cpu + case ${CTARGET} in + sparc64-*) + case $(get-flag mcpu) in + niagara[234]) + if ver_test -ge 2.8 ; then + cpu="sparc64v2" + elif ver_test -ge 2.4 ; then + cpu="sparc64v" + elif ver_test -ge 2.2.3 ; then + cpu="sparc64b" + fi + ;; + niagara) + if ver_test -ge 2.4 ; then + cpu="sparc64v" + elif ver_test -ge 2.2.3 ; then + cpu="sparc64b" + fi + ;; + ultrasparc3) + cpu="sparc64b" + ;; + *) + # We need to force at least v9a because the base build doesn't + # work with just v9. + # https://sourceware.org/bugzilla/show_bug.cgi?id=19477 + [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a" + ;; + esac + ;; + sparc-*) + case $(get-flag mcpu) in + niagara[234]) + if ver_test -ge 2.8 ; then + cpu="sparcv9v2" + elif ver_test -ge 2.4 ; then + cpu="sparcv9v" + elif ver_test -ge 2.2.3 ; then + cpu="sparcv9b" + else + cpu="sparcv9" + fi + ;; + niagara) + if ver_test -ge 2.4 ; then + cpu="sparcv9v" + elif ver_test -ge 2.2.3 ; then + cpu="sparcv9b" + else + cpu="sparcv9" + fi + ;; + ultrasparc3) + cpu="sparcv9b" + ;; + v9|ultrasparc) + cpu="sparcv9" + ;; + v8|supersparc|hypersparc|leon|leon3) + cpu="sparcv8" + ;; + esac + ;; + esac + [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}" + ;; + esac +} + +setup_flags() { + # Make sure host make.conf doesn't pollute us + if is_crosscompile || tc-is-cross-compiler ; then + CHOST=${CTARGET} strip-unsupported-flags + fi + + # Store our CFLAGS because it's changed depending on which CTARGET + # we are building when pulling glibc on a multilib profile + CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}} + CFLAGS=${CFLAGS_BASE} + CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}} + CXXFLAGS=${CXXFLAGS_BASE} + ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}} + ASFLAGS=${ASFLAGS_BASE} + + # Over-zealous CFLAGS can often cause problems. What may work for one + # person may not work for another. To avoid a large influx of bugs + # relating to failed builds, we strip most CFLAGS out to ensure as few + # problems as possible. + strip-flags + strip-unsupported-flags + filter-flags -m32 -m64 '-mabi=*' + + # glibc aborts if rpath is set by LDFLAGS + filter-ldflags '-Wl,-rpath=*' + + # #492892 + filter-flags -frecord-gcc-switches + + unset CBUILD_OPT CTARGET_OPT + if use multilib ; then + CTARGET_OPT=$(get_abi_CTARGET) + [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST) + fi + + setup_target_flags + + if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then + CBUILD_OPT=${CTARGET_OPT} + fi + + # Lock glibc at -O2; we want to be conservative here. + # -fno-strict-aliasing is to work around #155906. + filter-flags '-O?' + append-flags -O2 -fno-strict-aliasing + + filter-flags '-fstack-protector*' +} + +want_tls() { + # Archs that can use TLS (Thread Local Storage) + case $(tc-arch) in + x86) + # requires i486 or better #106556 + [[ ${CTARGET} == i[4567]86* ]] && return 0 + return 1 + ;; + esac + return 0 +} + +want__thread() { + want_tls || return 1 + + # For some reason --with-tls --with__thread is causing segfaults on sparc32. + [[ ${PROFILE_ARCH} == "sparc" ]] && return 1 + + [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD} + + # only test gcc -- can't test linking yet + tc-has-tls -c ${CTARGET} + WANT__THREAD=$? + + return ${WANT__THREAD} +} + +use_multiarch() { + # Allow user to disable runtime arch detection in multilib. + use multiarch || return 1 + # Make sure binutils is new enough to support indirect functions, + # #336792. This funky sed supports gold and bfd linkers. + local bver nver + bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}') + case $(tc-arch ${CTARGET}) in + amd64|x86) nver="2.20" ;; + arm) nver="2.22" ;; + hppa) nver="2.23" ;; + ppc|ppc64) nver="2.20" ;; + # ifunc support was added in 2.23, but glibc also needs + # machinemode which is in 2.24. + s390) nver="2.24" ;; + sparc) nver="2.21" ;; + *) return 1 ;; + esac + ver_test ${bver} -ge ${nver} +} + +# Setup toolchain variables that had historically been defined in the +# profiles for these archs. +setup_env() { + # silly users + unset LD_RUN_PATH + unset LD_ASSUME_KERNEL + + if is_crosscompile || tc-is-cross-compiler ; then + multilib_env ${CTARGET_OPT:-${CTARGET}} + + if ! use multilib ; then + MULTILIB_ABIS=${DEFAULT_ABI} + else + MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}} + fi + + # If the user has CFLAGS_ in their make.conf, use that, + # and fall back on CFLAGS. + local VAR=CFLAGS_${CTARGET//[-.]/_} + CFLAGS=${!VAR-${CFLAGS}} + einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}" + fi + + setup_flags + + export ABI=${ABI:-${DEFAULT_ABI:-default}} + + if just_headers ; then + # Avoid mixing host's CC and target's CFLAGS_${ABI}: + # At this bootstrap stage we have only binutils for + # target but not compiler yet. + einfo "Skip CC ABI injection. We can't use (cross-)compiler yet." + return 0 + fi + local VAR=CFLAGS_${ABI} + # We need to export CFLAGS with abi information in them because glibc's + # configure script checks CFLAGS for some targets (like mips). Keep + # around the original clean value to avoid appending multiple ABIs on + # top of each other. + : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})} + export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}" + einfo " $(printf '%15s' 'Manual CC:') ${CC}" +} + +foreach_abi() { + setup_env + + local ret=0 + local abilist="" + if use multilib ; then + abilist=$(get_install_abis) + else + abilist=${DEFAULT_ABI} + fi + local -x ABI + for ABI in ${abilist:-default} ; do + setup_env + einfo "Running $1 for ABI ${ABI}" + $1 + : $(( ret |= $? )) + done + return ${ret} +} + +glibc_banner() { + local b="Gentoo ${PVR}" + [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}" + echo "${b}" +} + +check_devpts() { + # Make sure devpts is mounted correctly for use w/out setuid pt_chown. + + # If merely building the binary package, then there's nothing to verify. + [[ ${MERGE_TYPE} == "buildonly" ]] && return + + # Only sanity check when installing the native glibc. + [[ ${ROOT} != "/" ]] && return + + # If they're opting in to the old suid code, then no need to check. + use suid && return + + if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then + eerror "In order to use glibc with USE=-suid, you must make sure that" + eerror "you have devpts mounted at /dev/pts with the gid=5 option." + eerror "Openrc should do this for you, so you should check /etc/fstab" + eerror "and make sure you do not have any invalid settings there." + die "mount & fix your /dev/pts settings" + fi +} + +# The following Kernel version handling functions are mostly copied from portage +# source. It's better not to use linux-info.eclass here since a) it adds too +# much magic, see bug 326693 for some of the arguments, and b) some of the +# functions are just not provided. + +g_get_running_KV() { + uname -r + return $? +} + +g_KV_major() { + [[ -z $1 ]] && return 1 + local KV=$@ + echo "${KV%%.*}" +} + +g_KV_minor() { + [[ -z $1 ]] && return 1 + local KV=$@ + KV=${KV#*.} + echo "${KV%%.*}" +} + +g_KV_micro() { + [[ -z $1 ]] && return 1 + local KV=$@ + KV=${KV#*.*.} + echo "${KV%%[^[:digit:]]*}" +} + +g_KV_to_int() { + [[ -z $1 ]] && return 1 + local KV_MAJOR=$(g_KV_major "$1") + local KV_MINOR=$(g_KV_minor "$1") + local KV_MICRO=$(g_KV_micro "$1") + local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO )) + + # We make version 2.2.0 the minimum version we will handle as + # a sanity check ... if its less, we fail ... + if [[ ${KV_int} -ge 131584 ]] ; then + echo "${KV_int}" + return 0 + fi + return 1 +} + +g_int_to_KV() { + local version=$1 major minor micro + major=$((version / 65536)) + minor=$(((version % 65536) / 256)) + micro=$((version % 256)) + echo ${major}.${minor}.${micro} +} + +eend_KV() { + [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]] + eend $? +} + +get_kheader_version() { + printf '#include \nLINUX_VERSION_CODE\n' | \ + $(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" - | \ + tail -n 1 +} + +# We collect all sanity checks here. Consistency is not guranteed between +# pkg_ and src_ phases, so we call this function both in pkg_pretend and in +# src_unpack. +sanity_prechecks() { + # Make sure devpts is mounted correctly for use w/out setuid pt_chown + check_devpts + + # Prevent native builds from downgrading + if [[ ${MERGE_TYPE} != "buildonly" ]] && \ + [[ ${ROOT} == "/" ]] && \ + [[ ${CBUILD} == ${CHOST} ]] && \ + [[ ${CHOST} == ${CTARGET} ]] ; then + + # The high rev # is to allow people to downgrade between -r# + # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2 + # should be fine. Hopefully we never actually use a r# this + # high. + if has_version ">${CATEGORY}/${P}-r10000" ; then + eerror "Sanity check to keep you from breaking your system:" + eerror " Downgrading glibc is not supported and a sure way to destruction." + die "Aborting to save your system." + fi + + if ! do_run_test '#include \n#include \nint main(){return syscall(1000)!=-1;}\n' ; then + eerror "Your old kernel is broken. You need to update it to a newer" + eerror "version as syscall() will break. See bug 279260." + die "Old and broken kernel." + fi + fi + + # Users have had a chance to phase themselves, time to give em the boot + if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then + eerror "You still haven't deleted ${EROOT}/etc/locales.build." + eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher." + die "Lazy upgrader detected" + fi + + if [[ ${CTARGET} == i386-* ]] ; then + eerror "i386 CHOSTs are no longer supported." + eerror "Chances are you don't actually want/need i386." + eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml" + die "Please fix your CHOST" + fi + + if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then + ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS." + ewarn "This will result in a 50% performance penalty when running with a 32bit" + ewarn "hypervisor, which is probably not what you want." + fi + + # Check for sanity of /etc/nsswitch.conf + if [[ -e ${EROOT}/etc/nsswitch.conf ]] ; then + local entry + for entry in passwd group shadow; do + if ! egrep -q "^[ \t]*${entry}:.*files" "${EROOT}"/etc/nsswitch.conf; then + eerror "Your ${EROOT}/etc/nsswitch.conf is out of date." + eerror "Please make sure you have 'files' entries for" + eerror "'passwd:', 'group:' and 'shadow:' databases." + eerror "For more details see:" + eerror " https://wiki.gentoo.org/wiki/Project:Toolchain/nsswitch.conf_in_glibc-2.26" + die "nsswitch.conf has no 'files' provider in '${entry}'." + fi + done + fi + + # ABI-specific checks follow here. Hey, we have a lot more specific conditions that + # we test for... + if ! is_crosscompile ; then + if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then + ebegin "Checking that IA32 emulation is enabled in the running kernel" + echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c" + local STAT + if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then + "${T}/check-ia32-emulation.elf32" + STAT=$? + else + # Don't fail here to allow single->multi ABI switch + # or recover from breakage like bug #646424 + ewarn "Failed to compile the ABI test. Broken host glibc?" + STAT=0 + fi + rm -f "${T}/check-ia32-emulation.elf32" + eend $STAT + [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc." + fi + + fi + + # When we actually have to compile something... + if ! just_headers ; then + ebegin "Checking gcc for __thread support" + if ! eend $(want__thread ; echo $?) ; then + echo + eerror "Could not find a gcc that supports the __thread directive!" + eerror "Please update your binutils/gcc and try again." + die "No __thread support in gcc!" + fi + + if [[ ${CTARGET} == *-linux* ]] ; then + local run_kv build_kv want_kv + + run_kv=$(g_get_running_KV) + build_kv=$(g_int_to_KV $(get_kheader_version)) + want_kv=${MIN_KERN_VER} + + if ! is_crosscompile && ! tc-is-cross-compiler ; then + # Building fails on an non-supporting kernel + ebegin "Checking running kernel version (${run_kv} >= ${want_kv})" + if ! eend_KV ${run_kv} ${want_kv} ; then + echo + eerror "You need a kernel of at least ${want_kv}!" + die "Kernel version too low!" + fi + fi + + ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})" + if ! eend_KV ${build_kv} ${want_kv} ; then + echo + eerror "You need linux-headers of at least ${want_kv}!" + die "linux-headers version too low!" + fi + fi + fi +} + +# +# the phases +# + +# pkg_pretend + +pkg_pretend() { + # All the checks... + einfo "Checking general environment sanity." + sanity_prechecks +} + +pkg_setup() { + # see bug 682570 + [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup +} + +# src_unpack + +src_unpack() { + # Consistency is not guaranteed between pkg_ and src_ ... + sanity_prechecks + + use multilib && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz + + setup_env + + if [[ -n ${EGIT_REPO_URI} ]] ; then + git-r3_src_unpack + else + unpack ${P}.tar.xz + fi + + cd "${WORKDIR}" || die + unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz +} + +src_prepare() { + if ! use vanilla ; then + elog "Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER}" + eapply "${WORKDIR}"/patches + einfo "Done." + fi + + default + + gnuconfig_update + + cd "${WORKDIR}" + find . -name configure -exec touch {} + + + eprefixify extra/locale/locale-gen + + # Fix permissions on some of the scripts. + chmod u+x "${S}"/scripts/*.sh + + cd "${S}" +} + +glibc_do_configure() { + # Glibc does not work with gold (for various reasons) #269274. + tc-ld-disable-gold + + # CXX isnt handled by the multilib system, so if we dont unset here + # we accumulate crap across abis + unset CXX + + einfo "Configuring glibc for nptl" + + if use doc ; then + export MAKEINFO=makeinfo + else + export MAKEINFO=/dev/null + fi + + local v + for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO ; do + einfo " $(printf '%15s' ${v}:) ${!v}" + done + + # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760 + # To build .S (assembly) files with the same ABI-specific flags + # upstream currently recommends adding CFLAGS to CC/CXX: + # https://sourceware.org/PR23273 + # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS + # and breaks multiarch support. See 659030#c3 for an example. + # The glibc configure script doesn't properly use LDFLAGS all the time. + export CC="$(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS}" + einfo " $(printf '%15s' 'Manual CC:') ${CC}" + + # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548 + export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS) ${CFLAGS}" + + if is_crosscompile; then + # Assume worst-case bootstrap: glibc is buil first time + # when ${CTARGET}-g++ is not available yet. We avoid + # building auxiliary programs that require C++: bug #683074 + # It should not affect final result. + export libc_cv_cxx_link_ok=no + # The line above has the same effect. We set CXX explicitly + # to make build logs less confusing. + export CXX= + fi + einfo " $(printf '%15s' 'Manual CXX:') ${CXX}" + + echo + + local myconf=() + + case ${CTARGET} in + m68k*) + # setjmp() is not compatible with stack protection: + # https://sourceware.org/PR24202 + myconf+=( --enable-stack-protector=no ) + ;; + powerpc-*) + # Currently gcc on powerpc32 generates invalid code for + # __builtin_return_address(0) calls. Normally programs + # don't do that but malloc hooks in glibc do: + # https://gcc.gnu.org/PR81996 + # https://bugs.gentoo.org/629054 + myconf+=( --enable-stack-protector=no ) + ;; + *) + myconf+=( --enable-stack-protector=$(usex ssp all no) ) + ;; + esac + myconf+=( --enable-stackguard-randomization ) + + # Keep a whitelist of targets supporing IFUNC. glibc's ./configure + # is not robust enough to detect proper support: + # https://bugs.gentoo.org/641216 + # https://sourceware.org/PR22634#c0 + case $(tc-arch ${CTARGET}) in + # Keep whitelist of targets where autodetection mostly works. + amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;; + # Blacklist everywhere else + *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;; + esac + + # Enable Intel Control-flow Enforcement Technology on amd64 if requested + case ${CTARGET} in + x86_64-*) myconf+=( $(use_enable cet) ) ;; + *) ;; + esac + + [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp ) + + myconf+=( --enable-kernel=${MIN_KERN_VER} ) + + # Since SELinux support is only required for nscd, only enable it if: + # 1. USE selinux + # 2. only for the primary ABI on multilib systems + # 3. Not a crosscompile + if ! is_crosscompile && use selinux ; then + if use multilib ; then + if is_final_abi ; then + myconf+=( --with-selinux ) + else + myconf+=( --without-selinux ) + fi + else + myconf+=( --with-selinux ) + fi + else + myconf+=( --without-selinux ) + fi + + # Force a few tests where we always know the answer but + # configure is incapable of finding it. + if is_crosscompile ; then + export \ + libc_cv_c_cleanup=yes \ + libc_cv_forced_unwind=yes + fi + + myconf+=( + --without-cvs + --disable-werror + --enable-bind-now + --build=${CBUILD_OPT:-${CBUILD}} + --host=${CTARGET_OPT:-${CTARGET}} + $(use_enable profile) + $(use_with gd) + --with-headers=$(alt_build_headers) + --prefix="${EPREFIX}/usr" + --sysconfdir="${EPREFIX}/etc" + --localstatedir="${EPREFIX}/var" + --libdir='$(prefix)'/$(get_libdir) + --mandir='$(prefix)'/share/man + --infodir='$(prefix)'/share/info + --libexecdir='$(libdir)'/misc/glibc + --with-bugurl=https://bugs.gentoo.org/ + --with-pkgversion="$(glibc_banner)" + $(use_multiarch || echo --disable-multi-arch) + $(use_enable systemtap) + $(use_enable nscd) + ${EXTRA_ECONF} + ) + + # We rely on sys-libs/timezone-data for timezone tools normally. + myconf+=( $(use_enable vanilla timezone-tools) ) + + # These libs don't have configure flags. + ac_cv_lib_audit_audit_log_user_avc_message=$(usex audit || echo no) + ac_cv_lib_cap_cap_init=$(usex caps || echo no) + + # There is no configure option for this and we need to export it + # since the glibc build will re-run configure on itself + export libc_cv_rootsbindir="${EPREFIX}/sbin" + export libc_cv_slibdir="${EPREFIX}/$(get_libdir)" + + # We take care of patching our binutils to use both hash styles, + # and many people like to force gnu hash style only, so disable + # this overriding check. #347761 + export libc_cv_hashstyle=no + + local builddir=$(builddir nptl) + mkdir -p "${builddir}" + cd "${builddir}" + set -- "${S}"/configure "${myconf[@]}" + echo "$@" + "$@" || die "failed to configure glibc" + + # ia64 static cross-compilers are a pita in so much that they + # can't produce static ELFs (as the libgcc.a is broken). so + # disable building of the programs for those targets if it + # doesn't work. + # XXX: We could turn this into a compiler test, but ia64 is + # the only one that matters, so this should be fine for now. + if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then + sed -i '1i+link-static = touch $@' config.make + fi + + # If we're trying to migrate between ABI sets, we need + # to lie and use a local copy of gcc. Like if the system + # is built with MULTILIB_ABIS="amd64 x86" but we want to + # add x32 to it, gcc/glibc don't yet support x32. + # + if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then + echo 'main(){}' > "${T}"/test.c + if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then + sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die + fi + fi +} + +glibc_headers_configure() { + export ABI=default + + local builddir=$(builddir "headers") + mkdir -p "${builddir}" + cd "${builddir}" + + # if we don't have a compiler yet, we can't really test it now ... + # hopefully they don't affect header generation, so let's hope for + # the best here ... + local v vars=( + ac_cv_header_cpuid_h=yes + libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes + libc_cv_asm_cfi_directives=yes + libc_cv_broken_visibility_attribute=no + libc_cv_c_cleanup=yes + libc_cv_compiler_powerpc64le_binary128_ok=yes + libc_cv_forced_unwind=yes + libc_cv_gcc___thread=yes + libc_cv_mlong_double_128=yes + libc_cv_mlong_double_128ibm=yes + libc_cv_ppc_machine=yes + libc_cv_ppc_rel16=yes + libc_cv_predef_fortify_source=no + libc_cv_target_power8_ok=yes + libc_cv_visibility_attribute=yes + libc_cv_z_combreloc=yes + libc_cv_z_execstack=yes + libc_cv_z_initfirst=yes + libc_cv_z_nodelete=yes + libc_cv_z_nodlopen=yes + libc_cv_z_relro=yes + libc_mips_abi=${ABI} + libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard) + # These libs don't have configure flags. + ac_cv_lib_audit_audit_log_user_avc_message=no + ac_cv_lib_cap_cap_init=no + ) + + einfo "Forcing cached settings:" + for v in "${vars[@]}" ; do + einfo " ${v}" + export ${v} + done + + local headers_only_arch_CPPFLAGS=() + + # Blow away some random CC settings that screw things up. #550192 + if [[ -d ${S}/sysdeps/mips ]]; then + pushd "${S}"/sysdeps/mips >/dev/null + sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die + sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die + + # Force the mips ABI to the default. This is OK because the set of + # installed headers in this phase is the same between the 3 ABIs. + # If this ever changes, this hack will break, but that's unlikely + # as glibc discourages that behavior. + # https://crbug.com/647033 + sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die + + popd >/dev/null + fi + + case ${CTARGET} in + riscv*) + # RISC-V interrogates the compiler to determine which target to + # build. If building the headers then we don't strictly need a + # RISC-V compiler, so the built-in definitions that are provided + # along with all RISC-V compiler might not exist. This causes + # glibc's RISC-V preconfigure script to blow up. Since we're just + # building the headers any value will actually work here, so just + # pick the standard one (rv64g/lp64d) to make the build scripts + # happy for now -- the headers are all the same anyway so it + # doesn't matter. + headers_only_arch_CPPFLAGS+=( + -D__riscv_xlen=64 + -D__riscv_flen=64 + -D__riscv_float_abi_double=1 + -D__riscv_atomic=1 + ) ;; + esac + + local myconf=() + myconf+=( + --disable-sanity-checks + --enable-hacker-mode + --without-cvs + --disable-werror + --enable-bind-now + --build=${CBUILD_OPT:-${CBUILD}} + --host=${CTARGET_OPT:-${CTARGET}} + --with-headers=$(alt_build_headers) + --prefix="${EPREFIX}/usr" + ${EXTRA_ECONF} + ) + + # Nothing is compiled here which would affect the headers for the target. + # So forcing CC/CFLAGS is sane. + local headers_only_CC=$(tc-getBUILD_CC) + local headers_only_CFLAGS="-O1 -pipe" + local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE ${headers_only_arch_CPPFLAGS[*]}" + local headers_only_LDFLAGS="" + set -- "${S}"/configure "${myconf[@]}" + echo \ + "CC=${headers_only_CC}" \ + "CFLAGS=${headers_only_CFLAGS}" \ + "CPPFLAGS=${headers_only_CPPFLAGS}" \ + "LDFLAGS=${headers_only_LDFLAGS}" \ + "$@" + CC=${headers_only_CC} \ + CFLAGS=${headers_only_CFLAGS} \ + CPPFLAGS=${headers_only_CPPFLAGS} \ + LDFLAGS="" \ + "$@" || die "failed to configure glibc" +} + +do_src_configure() { + if just_headers ; then + glibc_headers_configure + else + glibc_do_configure nptl + fi +} + +src_configure() { + foreach_abi do_src_configure +} + +do_src_compile() { + emake -C "$(builddir nptl)" || die "make nptl for ${ABI} failed" +} + +src_compile() { + if just_headers ; then + return + fi + + foreach_abi do_src_compile +} + +glibc_src_test() { + cd "$(builddir nptl)" + emake check +} + +do_src_test() { + local ret=0 + + glibc_src_test + : $(( ret |= $? )) + + return ${ret} +} + +src_test() { + if just_headers ; then + return + fi + + # Give tests more time to complete. + export TIMEOUTFACTOR=5 + + foreach_abi do_src_test || die "tests failed" +} + +run_locale_gen() { + # if the host locales.gen contains no entries, we'll install everything + local root="$1" + local locale_list="${root}/etc/locale.gen" + if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then + ewarn "Generating all locales; edit /etc/locale.gen to save time/space" + locale_list="${root}/usr/share/i18n/SUPPORTED" + fi + + locale-gen --jobs $(makeopts_jobs) --config "${locale_list}" \ + --destdir "${root}" +} + +glibc_do_src_install() { + local builddir=$(builddir nptl) + cd "${builddir}" + + emake install_root="${D}$(alt_prefix)" install || die + + # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support + # which come without headers etc. Only needed for binary packages since the + # external net-libs/libnsl has increased soversion. Keep only versioned libraries. + find "${D}" -name "libnsl.a" -delete + find "${D}" -name "libnsl.so" -delete + + # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need + # to infer upstream version: + # '#define VERSION "2.26.90"' -> '2.26.90' + local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h) + + if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then + # Move versioned .a file out of libdir to evade portage QA checks + # instead of using gen_usr_ldscript(). We fix ldscript as: + # "GROUP ( /usr/lib64/libm-.a ..." -> "GROUP ( /usr/lib64/glibc-/libm-.a ..." + sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"$(alt_usrlibdir)/libm.a || die + dodir $(alt_usrlibdir)/${P} + mv "${ED}"$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die + fi + + # We'll take care of the cache ourselves + rm -f "${ED}"/etc/ld.so.cache + + # Everything past this point just needs to be done once ... + is_final_abi || return 0 + + # Make sure the non-native interp can be found on multilib systems even + # if the main library set isn't installed into the right place. Maybe + # we should query the active gcc for info instead of hardcoding it ? + local i ldso_abi ldso_name + local ldso_abi_list=( + # x86 + amd64 /lib64/ld-linux-x86-64.so.2 + x32 /libx32/ld-linux-x32.so.2 + x86 /lib/ld-linux.so.2 + # mips + o32 /lib/ld.so.1 + n32 /lib32/ld.so.1 + n64 /lib64/ld.so.1 + # powerpc + ppc /lib/ld.so.1 + ppc64 /lib64/ld64.so.1 + # riscv + lp64d /lib/ld-linux-riscv64-lp64d.so.1 + lp64 /lib/ld-linux-riscv64-lp64.so.1 + # s390 + s390 /lib/ld.so.1 + s390x /lib/ld64.so.1 + # sparc + sparc32 /lib/ld-linux.so.2 + sparc64 /lib64/ld-linux.so.2 + ) + case $(tc-endian) in + little) + ldso_abi_list+=( + # arm + arm64 /lib/ld-linux-aarch64.so.1 + ) + ;; + big) + ldso_abi_list+=( + # arm + arm64 /lib/ld-linux-aarch64_be.so.1 + ) + ;; + esac + if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then + dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib + fi + for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do + ldso_abi=${ldso_abi_list[i]} + has ${ldso_abi} $(get_install_abis) || continue + + ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}" + if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then + dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name} + fi + done + + # With devpts under Linux mounted properly, we do not need the pt_chown + # binary to be setuid. This is because the default owners/perms will be + # exactly what we want. + if ! use suid ; then + find "${ED}" -name pt_chown -exec chmod -s {} + + fi + + ################################################################# + # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY # + # Make sure we install some symlink hacks so that when we build + # a 2nd stage cross-compiler, gcc finds the target system + # headers correctly. See gcc/doc/gccinstall.info + if is_crosscompile ; then + # We need to make sure that /lib and /usr/lib always exists. + # gcc likes to use relative paths to get to its multilibs like + # /usr/lib/../lib64/. So while we don't install any files into + # /usr/lib/, we do need it to exist. + keepdir $(alt_prefix)/lib + keepdir $(alt_prefix)/usr/lib + + dosym usr/include $(alt_prefix)/sys-include + return 0 + fi + + # Files for Debian-style locale updating + dodir /usr/share/i18n + sed \ + -e "/^#/d" \ + -e "/SUPPORTED-LOCALES=/d" \ + -e "s: \\\\::g" -e "s:/: :g" \ + "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \ + || die "generating /usr/share/i18n/SUPPORTED failed" + cd "${WORKDIR}"/extra/locale + dosbin locale-gen + doman *.[0-8] + insinto /etc + doins locale.gen + + # Make sure all the ABI's can find the locales and so we only + # have to generate one set + local a + keepdir /usr/$(get_libdir)/locale + for a in $(get_install_abis) ; do + if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then + dosym ../$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale + fi + done + + # HACK: If we're building for riscv, we need to additionally make sure that + # we can find the locale archive afterwards + case ${CTARGET} in + riscv*) + if [[ ! -e ${ED}/usr/lib/locale ]] ; then + dosym ../$(get_libdir)/locale /usr/lib/locale + fi + ;; + *) ;; + esac + + cd "${S}" + + # Install misc network config files + insinto /etc + doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf + doins "${WORKDIR}"/extra/etc/*.conf + + if use nscd ; then + doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)" + + local nscd_args=( + -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):" + ) + + sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd + + systemd_dounit nscd/nscd.service + systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf + else + # Do this since extra/etc/*.conf above might have nscd.conf. + rm -f "${ED}"/etc/nscd.conf + fi + + echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc + doenvd "${T}"/00glibc + + for d in BUGS ChangeLog CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do + [[ -s ${d} ]] && dodoc ${d} + done + dodoc -r ChangeLog.old + + # Prevent overwriting of the /etc/localtime symlink. We'll handle the + # creation of the "factory" symlink in pkg_postinst(). + rm -f "${ED}"/etc/localtime + + # Generate all locales if this is a native build as locale generation + if use compile-locales && ! is_crosscompile ; then + run_locale_gen "${ED}" + fi +} + +glibc_headers_install() { + local builddir=$(builddir "headers") + cd "${builddir}" + emake install_root="${D}$(alt_prefix)" install-headers + + insinto $(alt_headers)/gnu + doins "${S}"/include/gnu/stubs.h + + # Make sure we install the sys-include symlink so that when + # we build a 2nd stage cross-compiler, gcc finds the target + # system headers correctly. See gcc/doc/gccinstall.info + dosym usr/include $(alt_prefix)/sys-include +} + +src_strip() { + # gdb is lame and requires some debugging information to remain in + # libpthread, so we need to strip it by hand. libthread_db makes no + # sense stripped as it is only used when debugging. + local pthread=$(has splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}") + env \ + -uRESTRICT \ + CHOST=${CTARGET} \ + STRIP_MASK="/*/{,tls/}${pthread}*" \ + prepallstrip + # if user has stripping enabled and does not have split debug turned on, + # then leave the debugging sections in libpthread. + if ! has nostrip ${FEATURES} && ! has splitdebug ${FEATURES} ; then + ${STRIP:-${CTARGET}-strip} --strip-debug "${ED}"$(alt_prefix)/*/libpthread-*.so + fi +} + +src_install() { + if just_headers ; then + export ABI=default + glibc_headers_install + return + fi + + foreach_abi glibc_do_src_install + src_strip +} + +# Simple test to make sure our new glibc isn't completely broken. +# Make sure we don't test with statically built binaries since +# they will fail. Also, skip if this glibc is a cross compiler. +# +# If coreutils is built with USE=multicall, some of these files +# will just be wrapper scripts, not actual ELFs we can test. +glibc_sanity_check() { + cd / #228809 + + # We enter ${ED} so to avoid trouble if the path contains + # special characters; for instance if the path contains the + # colon character (:), then the linker will try to split it + # and look for the libraries in an unexpected place. This can + # lead to unsafe code execution if the generated prefix is + # within a world-writable directory. + # (e.g. /var/tmp/portage:${HOSTNAME}) + pushd "${ED}"/$(get_libdir) >/dev/null + + local x striptest + for x in cal date env free ls true uname uptime ; do + x=$(type -p ${x}) + [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue + striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue + case ${striptest} in + *"statically linked"*) continue;; + *"ASCII text"*) continue;; + esac + # We need to clear the locale settings as the upgrade might want + # incompatible locale data. This test is not for verifying that. + LC_ALL=C \ + ./ld-*.so --library-path . ${x} > /dev/null \ + || die "simple run test (${x}) failed" + done + + popd >/dev/null +} + +pkg_preinst() { + # nothing to do if just installing headers + just_headers && return + + # prepare /etc/ld.so.conf.d/ for files + mkdir -p "${EROOT}"/etc/ld.so.conf.d + + # Default /etc/hosts.conf:multi to on for systems with small dbs. + if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then + sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf + einfo "Defaulting /etc/host.conf:multi to on" + fi + + [[ ${ROOT} != "/" ]] && return 0 + [[ -d ${ED}/$(get_libdir) ]] || return 0 + [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check +} + +pkg_postinst() { + # nothing to do if just installing headers + just_headers && return + + if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then + # Generate fastloading iconv module configuration file. + "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}" + fi + + if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then + # Reload init ... if in a chroot or a diff init package, ignore + # errors from this step #253697 + /sbin/telinit U 2>/dev/null + + use compile-locales || run_locale_gen "${EROOT}" + fi + + # Check for sanity of /etc/nsswitch.conf, take 2 + if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then + local entry + for entry in passwd group shadow; do + if egrep -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then + ewarn "" + ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been" + ewarn "removed from glibc and is now provided by the package" + ewarn " sys-auth/libnss-nis" + ewarn "Install it now to keep your NIS setup working." + ewarn "" + fi + done + fi +} diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild index 478b5e5c9dc6..3655b03320f1 100644 --- a/sys-libs/glibc/glibc-9999.ebuild +++ b/sys-libs/glibc/glibc-9999.ebuild @@ -3,7 +3,7 @@ EAPI=6 -PYTHON_COMPAT=( python3_{4,5,6,7} ) +PYTHON_COMPAT=( python3_{5,6,7} ) inherit python-any-r1 prefix eutils eapi7-ver toolchain-funcs flag-o-matic gnuconfig \ multilib systemd multiprocessing @@ -35,7 +35,7 @@ PATCH_VER=11 SRC_URI+=" https://dev.gentoo.org/~slyfox/distfiles/${P}-patches-${PATCH_VER}.tar.xz" SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )" -IUSE="audit caps cet compile-locales doc gd headers-only +multiarch multilib nscd profile selinux +ssp suid systemtap test vanilla" +IUSE="audit caps cet compile-locales doc gd headers-only +multiarch multilib nscd profile selinux +ssp +static-libs suid systemtap test vanilla" # Minimum kernel version that glibc requires MIN_KERN_VER="3.2.0" @@ -720,6 +720,11 @@ pkg_pretend() { sanity_prechecks } +pkg_setup() { + # see bug 682570 + [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup +} + # src_unpack src_unpack() { @@ -795,6 +800,17 @@ glibc_do_configure() { # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548 export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS) ${CFLAGS}" + + if is_crosscompile; then + # Assume worst-case bootstrap: glibc is buil first time + # when ${CTARGET}-g++ is not available yet. We avoid + # building auxiliary programs that require C++: bug #683074 + # It should not affect final result. + export libc_cv_cxx_link_ok=no + # The line above has the same effect. We set CXX explicitly + # to make build logs less confusing. + export CXX= + fi einfo " $(printf '%15s' 'Manual CXX:') ${CXX}" echo @@ -1165,6 +1181,9 @@ glibc_do_src_install() { # powerpc ppc /lib/ld.so.1 ppc64 /lib64/ld64.so.1 + # riscv + lp64d /lib/ld-linux-riscv64-lp64d.so.1 + lp64 /lib/ld-linux-riscv64-lp64.so.1 # s390 s390 /lib/ld.so.1 s390x /lib/ld64.so.1 @@ -1247,6 +1266,17 @@ glibc_do_src_install() { fi done + # HACK: If we're building for riscv, we need to additionally make sure that + # we can find the locale archive afterwards + case ${CTARGET} in + riscv*) + if [[ ! -e ${ED}/usr/lib/locale ]] ; then + dosym ../$(get_libdir)/locale /usr/lib/locale + fi + ;; + *) ;; + esac + cd "${S}" # Install misc network config files @@ -1327,6 +1357,12 @@ src_install() { fi foreach_abi glibc_do_src_install + + if ! use static-libs ; then + elog "Not installing static glibc libraries" + find "${ED}" -name "*.a" -and -not -name "*_nonshared.a" -delete + fi + src_strip } -- cgit v1.2.3