summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-08-28 18:52:43 +0000
committerMike Frysinger <vapier@gentoo.org>2011-08-28 18:52:43 +0000
commit8eabadc5659a2bbbab8446b4e23c1e2aa06325b3 (patch)
treec1b134393a6bdc5d40c46e2385c44fa28405c0b3 /sys-libs
parentupdate gdb snapshots (diff)
downloadtoolchain-8eabadc5659a2bbbab8446b4e23c1e2aa06325b3.tar.gz
toolchain-8eabadc5659a2bbbab8446b4e23c1e2aa06325b3.tar.bz2
toolchain-8eabadc5659a2bbbab8446b4e23c1e2aa06325b3.zip
import older versions of glibc
Diffstat (limited to 'sys-libs')
-rw-r--r--sys-libs/glibc/Manifest52
-rw-r--r--sys-libs/glibc/files/2.3.5/glibc-2.3.5-frandom-detect.patch102
-rw-r--r--sys-libs/glibc/files/2.3.5/ssp.c155
-rw-r--r--sys-libs/glibc/files/2.3.6/glibc-2.3.6-propolice-guard-functions.patch138
-rw-r--r--sys-libs/glibc/files/2.5/glibc-2.5-gentoo-stack_chk_fail.c311
-rw-r--r--sys-libs/glibc/files/2.5/glibc-2.5-hardened-configure-picdefault.patch29
-rw-r--r--sys-libs/glibc/files/2.5/glibc-2.5-hardened-inittls-nosysenter.patch283
-rw-r--r--sys-libs/glibc/files/2.5/glibc-2.5-hardened-pie.patch39
-rw-r--r--sys-libs/glibc/files/2.6/glibc-2.6-gentoo-stack_chk_fail.c321
-rw-r--r--sys-libs/glibc/files/2.6/glibc-2.6-hardened-inittls-nosysenter.patch273
-rw-r--r--sys-libs/glibc/files/2.7/glibc-2.7-hardened-inittls-nosysenter.patch273
-rw-r--r--sys-libs/glibc/files/eblits/common.eblit292
-rw-r--r--sys-libs/glibc/files/eblits/pkg_postinst.eblit29
-rw-r--r--sys-libs/glibc/files/eblits/pkg_preinst.eblit90
-rw-r--r--sys-libs/glibc/files/eblits/pkg_setup.eblit105
-rw-r--r--sys-libs/glibc/files/eblits/src_compile.eblit213
-rw-r--r--sys-libs/glibc/files/eblits/src_install.eblit240
-rw-r--r--sys-libs/glibc/files/eblits/src_test.eblit42
-rw-r--r--sys-libs/glibc/files/eblits/src_unpack.eblit197
-rw-r--r--sys-libs/glibc/glibc-2.3.6-r5.ebuild1230
-rw-r--r--sys-libs/glibc/glibc-2.4-r4.ebuild1267
-rw-r--r--sys-libs/glibc/glibc-2.5.1.ebuild1233
-rw-r--r--sys-libs/glibc/glibc-2.6.1.ebuild334
-rw-r--r--sys-libs/glibc/glibc-2.7-r2.ebuild348
-rw-r--r--sys-libs/glibc/glibc-2.8_p20080602-r1.ebuild375
25 files changed, 7971 insertions, 0 deletions
diff --git a/sys-libs/glibc/Manifest b/sys-libs/glibc/Manifest
new file mode 100644
index 0000000..2d3a3b5
--- /dev/null
+++ b/sys-libs/glibc/Manifest
@@ -0,0 +1,52 @@
+AUX 2.3.5/glibc-2.3.5-frandom-detect.patch 3080 RMD160 7d0824edc14f9bfdde07eb7d1ac0d0281e55e343 SHA1 d62af2e590920d8fb07a977ce3f2d5bf3a62c064 SHA256 910a95fe5cf46402fcf865c5d759002e4a54ec979e3a70147f5ac8620e01f3f1
+AUX 2.3.5/ssp.c 4304 RMD160 15f8b28fac043aae94cac0b1793572d0af306143 SHA1 f10be7814dd1f86416eae1c7ee3d6c556eae73c9 SHA256 d1a047960466c1ae5dc00f83e6670ed778aab10d4ccb53b15baae39d80eea49c
+AUX 2.3.6/glibc-2.3.6-propolice-guard-functions.patch 8273 RMD160 d062d48850928039562d0d2bb543e238f852dc75 SHA1 0f52d6bb75b5b1fe7322d28aa614d4397cb58e12 SHA256 34bb6a47b634bb19506f13b652ad24a9e8644369cdb7729d9ea32edcec969370
+AUX 2.5/glibc-2.5-gentoo-stack_chk_fail.c 9058 RMD160 c98d7007857aeeea00e708e7989800dad9b07ae3 SHA1 ff92b7b6cb4a364dbe81c5110da79d1ad56a72ba SHA256 067fba2a36d2630d50198c44395ef208cdf080508f1b716bd3d079f7b964e2df
+AUX 2.5/glibc-2.5-hardened-configure-picdefault.patch 794 RMD160 7ab81bac4b9625043b1e7edea6fb5707696c144d SHA1 25a0b018eb44f3c9818876a12e9ec817e305d80b SHA256 0c0359f567e4ad2d3184618bf6ac7e6102b703eab6227c7e9a4ff4dcdeed2c91
+AUX 2.5/glibc-2.5-hardened-inittls-nosysenter.patch 9407 RMD160 352112bf4f2d8d58471f22f623784350baf0bc86 SHA1 ae244e9923c0a0e8be4121d593897530c0bf08e8 SHA256 2a912e82445815ae32744d990c59d8758ec74e482b856bd274c292848b9af1fd
+AUX 2.5/glibc-2.5-hardened-pie.patch 1569 RMD160 8746aeb9f9c68ca153d93cf92c9df93d0fb324d6 SHA1 c2ec8d9286af38017f5bee5a8823f642c067201d SHA256 ff9cde8857c5da89faa4039e2a81748674fbeaaa49d85c378d80711d55f2b0c1
+AUX 2.6/glibc-2.6-gentoo-stack_chk_fail.c 9545 RMD160 9a21c9deb6ebca5d2245e3bb50b53ce035967a5f SHA1 11ad52117fa55bbe51b429043df49767c7f58de0 SHA256 1410ded812be80d452eada5f9d6b9bd7bdb504c14f01cc27dce3e36b6f92b92a
+AUX 2.6/glibc-2.6-hardened-inittls-nosysenter.patch 8674 RMD160 f4e7df0cb25292afc13e18332569d2ca288fdf92 SHA1 7f34ef26d6607321e0ec5ad0f389cb1aedf5e0da SHA256 cf58ded8fbe9fcb3dc094521feec2588c1520ff2c632b20c69d6a210325c4fcf
+AUX 2.7/glibc-2.7-hardened-inittls-nosysenter.patch 8755 RMD160 b674894f3b16f63193bb8040f8a5657dce82e1f9 SHA1 79fb3a4454b85af70dac95dd79134be3fe3a9201 SHA256 b0b1bf0746f7160b89cf281502b95c38dec9cb948d6a50a907b84fd6230a2dc3
+AUX eblits/common.eblit 9254 RMD160 2cd1b2fc996b59fff7533f94b43754a841236e8a SHA1 1973cd8da8cdd3a600a574332577c0ca8d36b1d3 SHA256 c85b74eb907e7f82b49455fa9c421abccfe93bdcf995627e30e6c2e678ac3436
+AUX eblits/pkg_postinst.eblit 1159 RMD160 4b99846819bf0471d1104a8a17dd260796644f9d SHA1 4a2980fede3edebc7960d40db7cf935c7c854859 SHA256 76c403cf5c77a3a3bb7441566335f0c8da2584eaa21f05ab400e7bb00f9db810
+AUX eblits/pkg_preinst.eblit 3764 RMD160 f9a9d43e2d2d8df073be7e1b66655e651cb10740 SHA1 b987e2802201e0f44c357ffc7b92da4aa77cf377 SHA256 41baa253ea529156d628108247545235c4ec377b184e7824bd790eba1361299e
+AUX eblits/pkg_setup.eblit 3318 RMD160 4a38e5f9a385d9134b54ab27a654e9a83eeb9258 SHA1 85341ef8fbf37e3270719cc940d26fd6f1168d6b SHA256 ca79f36240221519e460b8ff08e8453d624731991c3efc27d45068d8c15b756e
+AUX eblits/src_compile.eblit 5844 RMD160 29faae79a18f157e1412d527380c7b70cf7d2442 SHA1 7be66723d4b8af71dfda1bcd0308791acbdbf12e SHA256 29673cef6619ca56bc9ce8eaf8c1a995857626f6bcd72251c5a339ad0574c6fd
+AUX eblits/src_install.eblit 7754 RMD160 d13b0283a096d681b3a4f1f4f0499af45ca1c97a SHA1 7b5b4b2da323cdc4ec6c39f2a4b229b7118568b9 SHA256 ae407a96cdff1c053846370a791e4796fb45bc04ae5b7ded06bae0b4861ceff7
+AUX eblits/src_test.eblit 1172 RMD160 a70e31e655cd3e306af6a498002de85b72258566 SHA1 4aec15e6ab67279258fd23400701fd38c106a38b SHA256 e5a390761b7ec613460b8da26df3ffe2a137217261dd9f87f2b78c3fa2a12727
+AUX eblits/src_unpack.eblit 5848 RMD160 8012ba4a31e689080ec2d70156c503b0c36e3119 SHA1 5aab07c312c3ab0624ead0e0a7f7d5cecfe1bf00 SHA256 19f73007557718580860a6e1b7613b4a69a4a639f17a9d3cb9ca2aba9576ccca
+DIST glibc-2.3.6-patches-1.19.tar.bz2 216069 RMD160 1998c521c3799f5baa8cfa2510e2f127088cc5be SHA1 dd5e6fa4982b6b07430f2f83266019f17895dca8 SHA256 8aa924347c50bd721cc1dd8dc7b0c986136689346d4d78eaea4d9f15a4db2dea
+DIST glibc-2.3.6.tar.bz2 14014977 RMD160 04b4f71cc3e89581e02ee2dbf5ab05f61e868bf1 SHA1 82d0487419f1bdbf2dee439c344e89d6af47e558 SHA256 e73ff5eddea95d09238b41d3c9c4d9ccddcf99fcc93d04956599c91c704f4a8e
+DIST glibc-2.4-patches-1.19.tar.bz2 132880 RMD160 6df74db9b9e85220fba82658036ced5cdc16ae28 SHA1 b42dfd587fdf4df58c5f95853fc3dc4f8f51bee7 SHA256 9ec4cd3df3b8e7f294b3c93138d2f0fd7e8213b4981cfcc9cb58c25f934a23fa
+DIST glibc-2.4.tar.bz2 15202445 RMD160 ee2712a0e6fab8e086958c1f23221f8d07af3de1 SHA1 35c636e4b474cda0f06e361d5e9caec092fd73d3 SHA256 27aaaaa78b4ab5da76bb29385dc9be087ba7b855a9102eaaa78ce3ec5e2e7fcd
+DIST glibc-2.5.1-patches-1.0.tar.bz2 533092 RMD160 1081874bfba24d7e04c225a6ec3e7e7c18bb006e SHA1 969d32580ffa845f3411a043bbd498378f348842 SHA256 d54847e35b1533ac5eee0dac36cc358b75cdb85e90fa589cf4270e69338197b0
+DIST glibc-2.5.1.tar.bz2 15421428 RMD160 06d234a70a240f9e344c36b6a9789019ca0bf571 SHA1 2b7da136df025bb8c787be3351cba58374226d9c SHA256 a29e0d149816364820512f71b9c9ebd0f8a148fbeaac42b79e2c342532e5bf8e
+DIST glibc-2.6.1-patches-1.2.tar.bz2 89639 RMD160 6a5b91d73eecbed3a867ffc19272efcb82f20a54 SHA1 3d562945a61ca9b6854c6436ca9c68355af8671e SHA256 218b8491d6f0a3e550514fab5e6db60ab9a031f00e71ec3b9e7f5db5eacbc44c
+DIST glibc-2.6.1.tar.bz2 15767401 RMD160 a58226e394780a6996d608febf5881134990919e SHA1 85573fee8d79180165e9466a1fc25133b5792190 SHA256 3ded3a3c3ba2cf02d72479a5cc0829c7c261a9d0934e49a79233de9fa276ec22
+DIST glibc-2.7-patches-1.7.tar.bz2 97989 RMD160 f0404ab12f8ed7d6a42449e4366bc5555894fefb SHA1 b0e7b27fadb3c53069bb5568b93e833c0783f9d3 SHA256 4f71345bc2ef73975f921a5bdbc4841e8911a36fec7edc17f1e758a9688a7153
+DIST glibc-2.7.tar.bz2 15976860 RMD160 c5c0b5a611d26956c46a289478b3349cea2ebf72 SHA1 ccc70e95db826e4b1fd3b484154402fdc3df88f7 SHA256 4224a522ac4ee0fd89eb337e7505e280dfb05e2fe1ad44339ba8874081c0451a
+DIST glibc-2.8-20080602.tar.bz2 16235726 RMD160 8781f2b1dbd22c6579208a689be38a444b5242c7 SHA1 68c2bfcf5f385449c3cb7efbf1f0d425d14cdaad SHA256 142eaba19eb85121206ee034fd828ca5dcd1bf2bfa940fef92c37457c06a6d48
+DIST glibc-2.8-patches-6.tar.bz2 103171 RMD160 c6a9710e53fa6b3698aea1a5f0a497155cf2a1c5 SHA1 39fe516a150621fc34418e23ac1c38cb1f7c1406 SHA256 dc335095de83ff4ff405c9aaf5b3ee3d82148888c73b31081ae1c706510973c2
+DIST glibc-2.8-ports-20080602.tar.bz2 469234 RMD160 57ae79a79c6f82f5ff217e9052f4569c136dca7d SHA1 c3a45ea27c9eb1bf99f1caafe085b50951089384 SHA256 1f3665e80b5832f7d281c109bc2f5412521cc9ccc3bd7b499fd493ff5eb9aa9b
+DIST glibc-infopages-2.3.6.tar.bz2 1298413 RMD160 5a83ca63c4153e5677797c0c0043aec0b55a6fe3 SHA1 8812dc121d24aad022e2aa4289dc75380e325d90 SHA256 651701bb5d8431401fa0f2252ad1cd37f69dc3a2aa28e4ce3405b4417b5e2c22
+DIST glibc-libidn-2.3.6.tar.bz2 101041 RMD160 7bc8e8fa310d2ae543802ea036c036c60d09270d SHA1 95d3a98495d4bd7138149fd312db88da56e735db SHA256 99a20232c1ad994e8a6dcd15c34e413eed94e7dd558bed7b832649dce09fb4f2
+DIST glibc-libidn-2.4.tar.bz2 102305 RMD160 76b2e15e7613c4ac8db3bf90e90929c0e369ab04 SHA1 09981bb5f15812caa5824b3946b30cf030afc255 SHA256 2f29ec2b2b2f75f787a1eed8fdea20aff212dc3bad97651ca376914c49181977
+DIST glibc-libidn-2.5.1.tar.bz2 102290 RMD160 683d557160b28a2369c9dd53ab36367e6641b6bb SHA1 6323f3533f734e8338fd21f9c878b870d6f79fdf SHA256 800e2b35443ffff200970df6d35a7afc2eb6e75c88a8074391867545e46d9f2e
+DIST glibc-libidn-2.6.1.tar.bz2 102319 RMD160 20b86f6c40365084898916fe614b210a7b0ec2e7 SHA1 5440648e71078ecb179c4501b5f6717b54294945 SHA256 67c98ca1299f5f25eaece256d033e0e63bcf6876b920ca62a1fe61ac62c5c451
+DIST glibc-libidn-2.7.tar.bz2 101939 RMD160 17a9692cc59d9f41d6b9fcd68f283f401e206483 SHA1 2338cc9b5795f5e97a19aac6d7d00ab750e81ac3 SHA256 07de78810a5320d696792b67131c4cf3d6654aee015a6b74820d66fb00799000
+DIST glibc-linuxthreads-2.3.6.tar.bz2 243534 RMD160 bb89ac687419cede738314923bc952d191d8d252 SHA1 10190168bf948556afdfff46f87f9208402d810f SHA256 6c3bc4a247d1e5308fb14f81956802f09095d3683219859fcad5795aa3aea638
+DIST glibc-linuxthreads-2.5.tar.bz2 242445 RMD160 788484d035d53ac39aac18f6e3409a912eea1cfa SHA1 eb7765e5c0a14c7475f1c8b92cbe1f625a8fd76f SHA256 ee27aeba6124a8b351c720eb898917f0f8874d9a384cc2f17aa111a3d679bd2c
+DIST glibc-linuxthreads-20060605.tar.bz2 247200 RMD160 aaa0a150eec4d63787f86ae04ded4d92a10c6f29 SHA1 1e0cf861de45f22d01d7d305482bacb0a869262f SHA256 1d15e236926fff6daa81e6af34e7903206b67f849f828ca976ab077b4677fb52
+DIST glibc-manpages-2.3.6-1.tar.bz2 22216 RMD160 a69fc155366d1b263acecd026718dc536c2b12b8 SHA1 10b7914a57f6510354b8d325d6ae18ff3547ba79 SHA256 2ba9c7fff2f02f888160dbadd013356fe4a6e9f3d71ac583f5ba6a1d73cb2ab6
+DIST glibc-ports-2.4.tar.bz2 381472 RMD160 72987098f9fbd5a1ad617bf2136081c0db80a429 SHA1 8b4d93bfbcd5b6a36e09ff08fe0c2a08adc1b886 SHA256 2fbbcaad8a9f8560485c398a9066959fe2713c8bc7e653ec476fb56fed21d19a
+DIST glibc-ports-2.5.tar.bz2 409372 RMD160 e7e29df135a5f0f72760d10e5ad46de038e40725 SHA1 7da6257e641759ed29c4d316700fce6f604bc812 SHA256 80c38a005325e7539012bd665fb8e06af9ee9bfc74efb236ebff121265bfd463
+DIST glibc-ports-2.6.1.tar.bz2 431292 RMD160 aa6ba7bc58932c81416c3407a8dd0b5e61f5454a SHA1 f620103c8b02ced80a425c79691573f949bf5d6b SHA256 d094028bc6d6691f56b4efeff7cd7e1c7ca10733e0cb5efc36e8fb08d8324bf1
+DIST glibc-ports-2.7.tar.bz2 435392 RMD160 b9b96b357a394f29d5617aaa26a2c000bcf88874 SHA1 2186eac2248f1dd604f20a9dc8215ce12319d273 SHA256 3e481996259af87c3581da23481970a27de679e3c87cfa9a5a59751cd20c7b44
+DIST glibc-powerpc-cpu-addon-v0.01.tgz 22422 RMD160 3483c94ec55819b36aa66fc60462317f8d15e4df SHA1 fd30cde7c7cb42baa2c8fa1ac88eeeeb509cac29 SHA256 0ffa9a432fffb9bfed99c529b631a27534ba848c7ec1d707732338b73a4a8ce9
+EBUILD glibc-2.3.6-r5.ebuild 37759 RMD160 4051bfdba2904474fbee423dab06247466534b08 SHA1 fcf641483ba9d0e423775d7b478d2f446ca12b21 SHA256 2259a0e95b4a8f01c7d22e089c31e4de203de60064804daf48a80eca9cd8d774
+EBUILD glibc-2.4-r4.ebuild 39218 RMD160 391da0f0b0e4e9040fead51f5688746f8aeb0098 SHA1 341640ae96da7bf9bcfea1c0f87c6eaa53c10f26 SHA256 23e36f5d6c4fd0e0e934a0b05ccaa00839152f02ce8b2fa5d8702b87d0681028
+EBUILD glibc-2.5.1.ebuild 38284 RMD160 d766cb3c7e0e2f075258464c6836ca5a04229d39 SHA1 a52712f29b9a97c3fa475c16ec2bf366a5377686 SHA256 a1de19b8514fb4f3ccabdde2057d4e528938a6da3a2a4e4a401de0cc14ee8f99
+EBUILD glibc-2.6.1.ebuild 12440 RMD160 7adb44d528bb06ceed78b3f654ea9de0c3b45fa5 SHA1 06b2610fde75d21ce5ee81ae648b94518181e9ec SHA256 312249b3ca6f613d9687d2a52e8e71f40bbfdbad8ae7a0ca6f097e2b6a3ed1b2
+EBUILD glibc-2.7-r2.ebuild 12949 RMD160 acec22ce50d758a70c6adea403ce250377be7282 SHA1 3f8982cc1ccd341c13e53080ab58044d08b284d5 SHA256 f88b3c10119fba9c93e6c055c982f6d8db2c5bee25bda2d6f79e9dc95a5a5a05
+EBUILD glibc-2.8_p20080602-r1.ebuild 13492 RMD160 af0d80016f5157af42d8683a481e7bd9de01bfc3 SHA1 d583f3d21002763118993df9c41ea85d12f3ae4f SHA256 bd9dd02ee81e9cedee9d466ac56181245b132c615bba53681dabef6ffcf79548
diff --git a/sys-libs/glibc/files/2.3.5/glibc-2.3.5-frandom-detect.patch b/sys-libs/glibc/files/2.3.5/glibc-2.3.5-frandom-detect.patch
new file mode 100644
index 0000000..3b1a71a
--- /dev/null
+++ b/sys-libs/glibc/files/2.3.5/glibc-2.3.5-frandom-detect.patch
@@ -0,0 +1,102 @@
+--- config.h.in
++++ config.h.in
+@@ -215,4 +215,7 @@
+ #undef HAVE_LIBIDN
+
++/* Defined if economical random device is available. */
++#undef HAVE_DEV_ERANDOM
++
+ /* Define if inlined system calls are available. */
+ #undef HAVE_INLINED_SYSCALLS
+--- configure.in
++++ configure.in
+@@ -264,4 +264,11 @@
+ AC_SUBST(all_warnings)
+
++dnl See whether the user wants to disable checking for /dev/erandom
++AC_ARG_ENABLE([dev-erandom],
++ AC_HELP_STRING([--disable-dev-erandom],
++ [disable testing for /dev/erandom]),
++ [try_dev_erandom=$enableval],
++ [try_dev_erandom=yes])
++
+ AC_CANONICAL_HOST
+
+@@ -1974,4 +1981,19 @@
+ AC_SUBST(sizeof_long_double)
+
++dnl check whether we have an economical random device
++if test "$try_dev_erandom" = yes ; then
++ AC_CACHE_CHECK(for economical random device, ac_cv_have_dev_random,
++ [if test -r "/dev/erandom" ; then
++ ac_cv_have_dev_erandom=yes; else ac_cv_have_dev_erandom=no; fi])
++ if test "$ac_cv_have_dev_erandom" = yes; then
++ AC_DEFINE(HAVE_DEV_ERANDOM,1,
++ [defined if the system supports an economical random device])
++ fi
++else
++ AC_MSG_CHECKING(for economical random device)
++ ac_cv_have_dev_erandom=no
++ AC_MSG_RESULT(has been disabled)
++fi
++
+ ### End of automated tests.
+ ### Now run sysdeps configure fragments.
+--- configure
++++ configure
+@@ -884,6 +884,7 @@
+ --enable-kernel=VERSION compile for compatibility with kernel not older than
+ VERSION
+ --enable-all-warnings enable all useful warnings gcc can issue
++ --disable-dev-erandom disable testing for /dev/erandom
+
+ Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+@@ -1697,6 +1698,14 @@
+ fi;
+
+
++# Check whether --enable-dev-erandom or --disable-dev-erandom was given.
++if test "${enable_dev_erandom+set}" = set; then
++ enableval="$enable_dev_erandom"
++ try_dev_erandom=$enableval
++else
++ try_dev_erandom=yes
++fi;
++
+ # Make sure we can run config.sub.
+ $ac_config_sub sun4 >/dev/null 2>&1 ||
+ { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
+@@ -7449,6 +7458,32 @@
+ sizeof_long_double=$ac_cv_sizeof_long_double
+
+
++if test "$try_dev_erandom" = yes ; then
++ echo "$as_me:$LINENO: checking for economical random device" >&5
++echo $ECHO_N "checking for economical random device... $ECHO_C" >&6
++if test "${ac_cv_have_dev_random+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ if test -r "/dev/erandom" ; then
++ ac_cv_have_dev_erandom=yes; else ac_cv_have_dev_erandom=no; fi
++fi
++echo "$as_me:$LINENO: result: $ac_cv_have_dev_random" >&5
++echo "${ECHO_T}$ac_cv_have_dev_random" >&6
++ if test "$ac_cv_have_dev_erandom" = yes; then
++
++cat >>confdefs.h <<\_ACEOF
++#define HAVE_DEV_ERANDOM 1
++_ACEOF
++
++ fi
++else
++ echo "$as_me:$LINENO: checking for economical random device" >&5
++echo $ECHO_N "checking for economical random device... $ECHO_C" >&6
++ ac_cv_have_dev_erandom=no
++ echo "$as_me:$LINENO: result: has been disabled" >&5
++echo "${ECHO_T}has been disabled" >&6
++fi
++
+ ### End of automated tests.
+ ### Now run sysdeps configure fragments.
+
diff --git a/sys-libs/glibc/files/2.3.5/ssp.c b/sys-libs/glibc/files/2.3.5/ssp.c
new file mode 100644
index 0000000..99f8531
--- /dev/null
+++ b/sys-libs/glibc/files/2.3.5/ssp.c
@@ -0,0 +1,155 @@
+/*
+ * Distributed under the terms of the GNU General Public License v2
+ * $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/2.3.5/Attic/ssp.c,v 1.4 2009/12/14 14:44:11 vapier dead $
+ *
+ * This is a modified version of Hiroaki Etoh's stack smashing routines
+ * implemented for glibc.
+ *
+ * The following people have contributed input to this code.
+ * Ned Ludd - <solar[@]gentoo.org>
+ * Alexander Gabert - <pappy[@]gentoo.org>
+ * The PaX Team - <pageexec[@]freemail.hu>
+ * Peter S. Mazinger - <ps.m[@]gmx.net>
+ * Yoann Vandoorselaere - <yoann[@]prelude-ids.org>
+ * Robert Connolly - <robert[@]linuxfromscratch.org>
+ * Cory Visi <cory@visi.name>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef __SSP__
+# error ssp.c has to be built w/ -fno-stack-protector
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <sys/syslog.h>
+#include <sys/time.h>
+#ifdef __SSP_USE_ERANDOM__
+# include <sys/sysctl.h>
+#endif
+
+#ifdef __PROPOLICE_BLOCK_SEGV__
+# define SSP_SIGTYPE SIGSEGV
+#elif __PROPOLICE_BLOCK_KILL__
+# define SSP_SIGTYPE SIGKILL
+#else
+# define SSP_SIGTYPE SIGABRT
+#endif
+
+unsigned long __guard = 0UL;
+
+/* Use of __* functions from the rest of glibc here avoids
+ * initialisation problems for executables preloaded with
+ * libraries that overload the associated standard library
+ * functions.
+ */
+#ifdef __UCLIBC__
+extern int __libc_open(__const char *file, int flags, ...);
+extern ssize_t __libc_read(int fd, void *buf, size_t count);
+extern int __libc_close(int fd);
+#else
+# define __libc_open(file, flags) __open(file, flags)
+# define __libc_read(fd, buf, count) __read(fd, buf, count)
+# define __libc_close(fd) __close(fd)
+# define __libc_write(fd, buf, count) __write(fd, buf, count)
+#endif
+
+void __guard_setup(void) __attribute__ ((constructor));
+void __guard_setup(void)
+{
+ size_t size;
+
+ if (__guard != 0UL)
+ return;
+
+ /* Start with the "terminator canary". */
+ __guard = 0xFF0A0D00UL;
+
+#ifndef __SSP_QUICK_CANARY__
+# ifdef __SSP_USE_ERANDOM__
+ {
+ int mib[3];
+ /* Random is another depth in Linux, hence an array of 3. */
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_RANDOM;
+ mib[2] = RANDOM_ERANDOM;
+
+ size = sizeof(unsigned long);
+ if (__sysctl(mib, 3, &__guard, &size, NULL, 0) != (-1))
+ if (__guard != 0UL)
+ return;
+ }
+# endif /* ifdef __SSP_USE_ERANDOM__ */
+ /*
+ * Attempt to open kernel pseudo random device if one exists before
+ * opening urandom to avoid system entropy depletion.
+ */
+ {
+ int fd;
+
+# ifdef __SSP_USE_ERANDOM__
+ if ((fd = __libc_open("/dev/erandom", O_RDONLY)) == (-1))
+# endif
+ fd = __libc_open("/dev/urandom", O_RDONLY);
+ if (fd != (-1)) {
+ size = __libc_read(fd, (char *) &__guard, sizeof(__guard));
+ __libc_close(fd);
+ if (size == sizeof(__guard))
+ return;
+ }
+ }
+#endif /* ifndef __SSP_QUICK_CANARY__ */
+
+ /* Everything failed? Or we are using a weakened model of the
+ * terminator canary */
+ {
+ struct timeval tv;
+ __gettimeofday(&tv, NULL);
+ __guard ^= tv.tv_usec ^ tv.tv_sec;
+ }
+}
+
+void __stack_smash_handler(char func[], int damaged __attribute__ ((unused)));
+void __stack_smash_handler(char func[], int damaged)
+{
+ extern char *__progname;
+ const char message[] = ": stack smashing attack in function ";
+ struct sigaction sa;
+ sigset_t mask;
+
+ sigfillset(&mask);
+
+ sigdelset(&mask, SSP_SIGTYPE); /* Block all signal handlers */
+ sigprocmask(SIG_BLOCK, &mask, NULL); /* except SSP_SIGTYPE */
+
+ /* Print error message to stderr and syslog */
+#if 1 /* syslog() causes issues with glibc #94325 */
+ __libc_write(STDERR_FILENO, __progname, strlen(__progname));
+ __libc_write(STDERR_FILENO, message, strlen(message));
+ __libc_write(STDERR_FILENO, func, strlen(func));
+ __libc_write(STDERR_FILENO, "()\n", 3);
+ //_syscall3(int, _ssp_syslog, int, type, char *, bufp, int, len)
+ //_ssp_syslog(LOG_INFO,
+#else
+ fprintf(stderr, "%s%s%s()\n", __progname, message, func);
+ syslog(LOG_INFO, "%s%s%s()", __progname, message, func);
+#endif
+
+ /* Make the default handler associated with the signal handler */
+ memset(&sa, 0, sizeof(struct sigaction));
+ sigfillset(&sa.sa_mask); /* Block all signals */
+ sa.sa_flags = 0;
+ sa.sa_handler = SIG_DFL;
+ sigaction(SSP_SIGTYPE, &sa, NULL);
+ (void) kill(getpid(), SSP_SIGTYPE);
+ _exit(127);
+}
diff --git a/sys-libs/glibc/files/2.3.6/glibc-2.3.6-propolice-guard-functions.patch b/sys-libs/glibc/files/2.3.6/glibc-2.3.6-propolice-guard-functions.patch
new file mode 100644
index 0000000..8779a2c
--- /dev/null
+++ b/sys-libs/glibc/files/2.3.6/glibc-2.3.6-propolice-guard-functions.patch
@@ -0,0 +1,138 @@
+The configure check for SSP was taken from glibc HEAD
+
+diff -ur glibc-2.3.6-orig/config.make.in glibc-2.3.6/config.make.in
+--- glibc-2.3.6-orig/config.make.in 2006-01-17 14:22:02.000000000 -0500
++++ glibc-2.3.6/config.make.in 2006-01-17 14:22:39.000000000 -0500
+@@ -62,6 +62,7 @@
+ have-libaudit = @have_libaudit@
+ have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
+ fno-unit-at-a-time = @fno_unit_at_a_time@
++have-ssp = @libc_cv_ssp@
+ bind-now = @bindnow@
+
+ static-libgcc = @libc_cv_gcc_static_libgcc@
+diff -ur glibc-2.3.6-orig/configure glibc-2.3.6/configure
+--- glibc-2.3.6-orig/configure 2006-01-17 14:22:17.000000000 -0500
++++ glibc-2.3.6/configure 2006-01-17 14:18:24.000000000 -0500
+@@ -313,7 +313,7 @@
+ # include <unistd.h>
+ #endif"
+
+-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS with_fp with_cvs enable_check_abi oldest_abi bindnow force_install all_warnings build build_cpu build_vendor build_os host host_cpu host_vendor host_os subdirs add_ons base_machine sysnames INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC OBJEXT BUILD_CC cross_compiling CPP CXX CXXFLAGS ac_ct_CXX AR OBJDUMP RANLIB ac_ct_RANLIB MIG AS LD PWD_P MAKE MSGFMT MAKEINFO SED AUTOCONF SYSINCLUDES libc_cv_gcc_static_libgcc BASH libc_cv_have_bash2 KSH libc_cv_have_ksh AWK PERL INSTALL_INFO BISON VERSIONING libc_cv_asm_protected_directive libc_cv_initfinit_array libc_cv_cc_with_libunwind libc_cv_z_nodelete libc_cv_z_nodlopen libc_cv_z_initfirst libc_cv_z_relro libc_cv_Bgroup libc_cv_libgcc_s_suffix libc_cv_as_needed ASFLAGS_config libc_cv_z_combreloc libc_cv_z_execstack libc_cv_fpie fno_unit_at_a_time libc_cv_have_initfini libc_cv_cpp_asm_debuginfo no_whole_archive exceptions LIBGD have_libaudit have_selinux EGREP sizeof_long_double libc_cv_gcc_unwind_find_fde uname_sysname uname_release uname_version old_glibc_headers libc_cv_slibdir libc_cv_localedir libc_cv_sysconfdir libc_cv_rootsbindir libc_cv_forced_unwind use_ldconfig ldd_rewrite_script gnu_ld gnu_as elf xcoff static shared pic_default profile omitfp bounded static_nss nopic_initfini DEFINES linux_doors mach_interface_list VERSION RELEASE LIBOBJS LTLIBOBJS'
++ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS with_fp with_cvs enable_check_abi oldest_abi bindnow force_install all_warnings build build_cpu build_vendor build_os host host_cpu host_vendor host_os subdirs add_ons base_machine sysnames INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC OBJEXT BUILD_CC cross_compiling CPP CXX CXXFLAGS ac_ct_CXX AR OBJDUMP RANLIB ac_ct_RANLIB MIG AS LD PWD_P MAKE MSGFMT MAKEINFO SED AUTOCONF SYSINCLUDES libc_cv_gcc_static_libgcc BASH libc_cv_have_bash2 KSH libc_cv_have_ksh AWK PERL INSTALL_INFO BISON VERSIONING libc_cv_asm_protected_directive libc_cv_initfinit_array libc_cv_cc_with_libunwind libc_cv_z_nodelete libc_cv_z_nodlopen libc_cv_z_initfirst libc_cv_z_relro libc_cv_Bgroup libc_cv_libgcc_s_suffix libc_cv_as_needed ASFLAGS_config libc_cv_z_combreloc libc_cv_z_execstack libc_cv_fpie fno_unit_at_a_time libc_cv_ssp libc_cv_have_initfini libc_cv_cpp_asm_debuginfo no_whole_archive exceptions LIBGD have_libaudit have_selinux EGREP sizeof_long_double libc_cv_gcc_unwind_find_fde uname_sysname uname_release uname_version old_glibc_headers libc_cv_slibdir libc_cv_localedir libc_cv_sysconfdir libc_cv_rootsbindir libc_cv_forced_unwind use_ldconfig ldd_rewrite_script gnu_ld gnu_as elf xcoff static shared pic_default profile omitfp bounded static_nss nopic_initfini DEFINES linux_doors mach_interface_list VERSION RELEASE LIBOBJS LTLIBOBJS'
+ ac_subst_files=''
+
+ # Initialize some variables set by options.
+@@ -5785,6 +5785,33 @@
+ fi
+
+
++echo "$as_me:$LINENO: checking for -fstack-protector" >&5
++echo $ECHO_N "checking for -fstack-protector... $ECHO_C" >&6
++if test "${libc_cv_ssp+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat > conftest.c <<EOF
++int foo;
++main () { return 0;}
++EOF
++if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fstack-protector
++ -o conftest conftest.c 1>&5'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }
++then
++ libc_cv_ssp=yes
++else
++ libc_cv_ssp=no
++fi
++rm -f conftest*
++fi
++echo "$as_me:$LINENO: result: $libc_cv_ssp" >&5
++echo "${ECHO_T}$libc_cv_ssp" >&6
++
++
+ if test $elf != yes; then
+ echo "$as_me:$LINENO: checking for .init and .fini sections" >&5
+ echo $ECHO_N "checking for .init and .fini sections... $ECHO_C" >&6
+@@ -8504,6 +8531,7 @@
+ s,@libc_cv_z_execstack@,$libc_cv_z_execstack,;t t
+ s,@libc_cv_fpie@,$libc_cv_fpie,;t t
+ s,@fno_unit_at_a_time@,$fno_unit_at_a_time,;t t
++s,@libc_cv_ssp@,$libc_cv_ssp,;t t
+ s,@libc_cv_have_initfini@,$libc_cv_have_initfini,;t t
+ s,@libc_cv_cpp_asm_debuginfo@,$libc_cv_cpp_asm_debuginfo,;t t
+ s,@no_whole_archive@,$no_whole_archive,;t t
+diff -ur glibc-2.3.6-orig/configure.in glibc-2.3.6/configure.in
+--- glibc-2.3.6-orig/configure.in 2006-01-17 14:22:17.000000000 -0500
++++ glibc-2.3.6/configure.in 2006-01-17 14:18:24.000000000 -0500
+@@ -1500,6 +1500,21 @@
+ fi
+ AC_SUBST(fno_unit_at_a_time)
+
++AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
++cat > conftest.c <<EOF
++int foo;
++main () { return 0;}
++EOF
++if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fstack-protector
++ -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
++then
++ libc_cv_ssp=yes
++else
++ libc_cv_ssp=no
++fi
++rm -f conftest*])
++AC_SUBST(libc_cv_ssp)
++
+ if test $elf != yes; then
+ AC_CACHE_CHECK(for .init and .fini sections, libc_cv_have_initfini,
+ [AC_TRY_COMPILE(, [asm (".section .init");
+diff -ur glibc-2.3.6-orig/sysdeps/generic/libc-start.c glibc-2.3.6/sysdeps/generic/libc-start.c
+--- glibc-2.3.6-orig/sysdeps/generic/libc-start.c 2006-01-17 14:22:17.000000000 -0500
++++ glibc-2.3.6/sysdeps/generic/libc-start.c 2006-01-17 14:18:24.000000000 -0500
+@@ -188,6 +188,9 @@
+ GLRO(dl_debug_printf) ("\ntransferring control: %s\n\n", argv[0]);
+ #endif
+
++ /* call the __guard_setup to set up the random __guard value */
++ __guard_setup (); /* pappy@gentoo.org (pappy rules) */
++
+ #ifdef HAVE_CLEANUP_JMP_BUF
+ /* Memory for the cancellation buffer. */
+ struct pthread_unwind_buf unwind_buf;
+diff -ur glibc-2.3.6-orig/sysdeps/unix/sysv/linux/Dist glibc-2.3.6/sysdeps/unix/sysv/linux/Dist
+--- glibc-2.3.6-orig/sysdeps/unix/sysv/linux/Dist 2006-01-17 14:22:17.000000000 -0500
++++ glibc-2.3.6/sysdeps/unix/sysv/linux/Dist 2006-01-17 14:18:24.000000000 -0500
+@@ -1,3 +1,4 @@
++ssp.c
+ bits/initspin.h
+ cmsg_nxthdr.c
+ dl-brk.c
+diff -ur glibc-2.3.6-orig/sysdeps/unix/sysv/linux/Makefile glibc-2.3.6/sysdeps/unix/sysv/linux/Makefile
+--- glibc-2.3.6-orig/sysdeps/unix/sysv/linux/Makefile 2006-01-17 14:22:17.000000000 -0500
++++ glibc-2.3.6/sysdeps/unix/sysv/linux/Makefile 2006-01-17 14:18:24.000000000 -0500
+@@ -1,5 +1,8 @@
+ ifeq ($(subdir),csu)
+-sysdep_routines += errno-loc
++sysdep_routines += errno-loc ssp
++ifeq (yes,$(have-ssp))
++CFLAGS-ssp.c += -fno-stack-protector
++endif
+ endif
+
+ ifeq ($(subdir),assert)
+diff -ur glibc-2.3.6-orig/sysdeps/unix/sysv/linux/Versions glibc-2.3.6/sysdeps/unix/sysv/linux/Versions
+--- glibc-2.3.6-orig/sysdeps/unix/sysv/linux/Versions 2006-01-17 14:22:17.000000000 -0500
++++ glibc-2.3.6/sysdeps/unix/sysv/linux/Versions 2006-01-17 14:18:24.000000000 -0500
+@@ -108,6 +108,8 @@
+ GLIBC_2.3.2 {
+ # New kernel interfaces.
+ epoll_create; epoll_ctl; epoll_wait;
++ # global objects and functions for the propolice patch in gcc - moved from libgcc by pappy@gentoo.org
++ __guard; __guard_setup; __stack_smash_handler;
+ }
+ GLIBC_2.3.3 {
+ gnu_dev_major; gnu_dev_minor; gnu_dev_makedev;
diff --git a/sys-libs/glibc/files/2.5/glibc-2.5-gentoo-stack_chk_fail.c b/sys-libs/glibc/files/2.5/glibc-2.5-gentoo-stack_chk_fail.c
new file mode 100644
index 0000000..e304440
--- /dev/null
+++ b/sys-libs/glibc/files/2.5/glibc-2.5-gentoo-stack_chk_fail.c
@@ -0,0 +1,311 @@
+/* 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 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 - <kevquinn[@]gentoo.org>
+ *
+ * The following people contributed to the glibc-2.3 Hardened
+ * Gentoo SSP handler, from which this implementation draws much:
+ *
+ * Ned Ludd - <solar[@]gentoo.org>
+ * Alexander Gabert - <pappy[@]gentoo.org>
+ * The PaX Team - <pageexec[@]freemail.hu>
+ * Peter S. Mazinger - <ps.m[@]gmx.net>
+ * Yoann Vandoorselaere - <yoann[@]prelude-ids.org>
+ * Robert Connolly - <robert[@]linuxfromscratch.org>
+ * Cory Visi <cory[@]visi.name>
+ * Mike Frysinger <vapier[@]gentoo.org>
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+#include <sys/types.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include <kernel-features.h>
+
+#include <alloca.h>
+/* from sysdeps */
+#include <socketcall.h>
+/* for the stuff in bits/socket.h */
+#include <sys/socket.h>
+#include <sys/un.h>
+
+
+/* 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
+# if !defined _KERNEL_NSIG && !defined _NSIG
+# error No _NSIG or _KERNEL_NSIG for rt_sigaction
+# endif
+# if !defined __NR_sigation && !defined __NR_rt_sigaction
+# error Cannot do syscall sigaction or rt_sigaction
+# endif
+#endif
+
+
+
+/* Define DO_SOCKET/DO_CONNECT macros to deal with socketcall vs socket/connect */
+#ifdef __NR_socketcall
+
+# define DO_SOCKET(result,domain,type,protocol) \
+ {socketargs[0] = domain; \
+ socketargs[1] = type; \
+ socketargs[2] = protocol; \
+ socketargs[3] = 0; \
+ result = INLINE_SYSCALL(socketcall,2,SOCKOP_socket,socketargs);}
+
+# define DO_CONNECT(result,sockfd,serv_addr,addrlen) \
+ {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
+
+# define DO_SOCKET(result,domain,type,protocol) \
+ {result = INLINE_SYSCALL(socket,3,domain,type,protocol);}
+
+# define DO_CONNECT(result,sockfd,serv_addr,addrlen) \
+ {result = INLINE_SYSCALL(connect,3,sockfd,serv_addr,addrlen);}
+
+#endif
+/* __NR_socketcall */
+
+
+#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 = "<rtld>";
+#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.
+ */
+static inline void
+__attribute__ ((__noreturn__ , __always_inline__))
+__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[]="<unknown>";
+#ifdef SSP_SMASH_DUMPS_CORE
+ static struct sigaction default_abort_act;
+#endif
+ static int log_socket, connect_result;
+ static struct sockaddr_un sock;
+#ifdef __NR_socketcall
+ static unsigned long int socketargs[4];
+#endif
+
+ /* 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);
+#ifdef SSP_SMASH_DUMPS_CORE
+ /* 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;
+ /* sigaction doesn't exist on amd64; however rt_sigaction seems to
+ * exist everywhere. rt_sigaction has an extra parameter - the
+ * size of sigset_t.
+ */
+# ifdef __NR_sigation
+ if (INLINE_SYSCALL(sigaction,3,SIGABRT,&default_abort_act,NULL) == 0)
+# else
+ /* 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
+ if (INLINE_SYSCALL(rt_sigaction,4,SIGABRT,&default_abort_act,NULL,_KERNEL_NSIG/8) == 0)
+# else
+ if (INLINE_SYSCALL(rt_sigaction,4,SIGABRT,&default_abort_act,NULL,_NSIG/8) == 0)
+# endif
+# endif
+ INLINE_SYSCALL(kill,2,pid,SIGABRT);
+#endif
+ /* 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);
+}
+
+void
+__attribute__ ((__noreturn__))
+ __stack_chk_fail (void)
+{
+ __hardened_gentoo_stack_chk_fail(NULL,0);
+}
+
+#ifdef ENABLE_OLD_SSP_COMPAT
+void
+__attribute__ ((__noreturn__))
+__stack_smash_handler(char func[], int damaged)
+{
+ __hardened_gentoo_stack_chk_fail(func,damaged);
+}
+#endif
+
diff --git a/sys-libs/glibc/files/2.5/glibc-2.5-hardened-configure-picdefault.patch b/sys-libs/glibc/files/2.5/glibc-2.5-hardened-configure-picdefault.patch
new file mode 100644
index 0000000..253a61b
--- /dev/null
+++ b/sys-libs/glibc/files/2.5/glibc-2.5-hardened-configure-picdefault.patch
@@ -0,0 +1,29 @@
+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 <kevquinn@gentoo.org>
+
+--- 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
+ 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
+ pic_default=no
+ fi
+ rm -f conftest.*
diff --git a/sys-libs/glibc/files/2.5/glibc-2.5-hardened-inittls-nosysenter.patch b/sys-libs/glibc/files/2.5/glibc-2.5-hardened-inittls-nosysenter.patch
new file mode 100644
index 0000000..420e6fd
--- /dev/null
+++ b/sys-libs/glibc/files/2.5/glibc-2.5-hardened-inittls-nosysenter.patch
@@ -0,0 +1,283 @@
+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 <kevquinn@gentoo.org>
+
+--- csu/libc-start.c.orig 2007-01-21 11:51:06.000000000 +0100
++++ csu/libc-start.c 2007-01-21 11:55:57.000000000 +0100
+@@ -28,6 +28,7 @@
+ extern int __libc_multiple_libcs;
+
+ #include <tls.h>
++#include <sysdep.h>
+ #ifndef SHARED
+ # include <dl-osinfo.h>
+ extern void __pthread_initialize_minimal (void)
+@@ -133,6 +134,14 @@
+ # 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. */
++# if !(USE_TLS - 0) && !defined NONTLS_INIT_TP
++ if (__pthread_initialize_minimal)
++# endif
++ __pthread_initialize_minimal ();
++# endif
+ # ifdef DL_SYSDEP_OSCHECK
+ if (!__libc_multiple_libcs)
+ {
+@@ -142,15 +151,17 @@
+ }
+ # 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. If there is no thread library and we
+ handle TLS the function is defined in the libc to initialized the
+ TLS handling. */
+-# if !(USE_TLS - 0) && !defined NONTLS_INIT_TP
++# if !(USE_TLS - 0) && !defined NONTLS_INIT_TP
+ if (__pthread_initialize_minimal)
+-# endif
++# endif
+ __pthread_initialize_minimal ();
++# endif
+ #endif
+
+ # ifndef SHARED
+--- csu/libc-tls.c.orig 2007-01-21 11:37:02.000000000 +0100
++++ csu/libc-tls.c 2007-01-21 12:09:33.000000000 +0100
+@@ -23,6 +23,7 @@
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <sys/param.h>
++#include <sysdep.h>
+
+
+ #ifdef SHARED
+@@ -30,6 +31,9 @@
+ #endif
+
+ #ifdef USE_TLS
++# ifdef INTERNAL_SYSCALL_NOSYSENTER
++extern void *__sbrk_nosysenter (intptr_t __delta);
++# endif
+ extern ElfW(Phdr) *_dl_phdr;
+ extern size_t _dl_phnum;
+
+@@ -142,14 +146,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.orig 2007-01-21 11:38:27.000000000 +0100
++++ misc/sbrk.c 2007-01-21 12:07:29.000000000 +0100
+@@ -18,6 +18,7 @@
+
+ #include <unistd.h>
+ #include <errno.h>
++#include <sysdep.h>
+
+ /* 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.orig 2007-01-21 11:39:16.000000000 +0100
++++ sysdeps/unix/sysv/linux/i386/brk.c 2007-01-21 11:44:01.000000000 +0100
+@@ -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.orig 2007-01-21 13:08:00.000000000 +0100
++++ sysdeps/unix/sysv/linux/i386/sysdep.h 2007-01-21 13:19:10.000000000 +0100
+@@ -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.5/glibc-2.5-hardened-pie.patch b/sys-libs/glibc/files/2.5/glibc-2.5-hardened-pie.patch
new file mode 100644
index 0000000..46f3de4
--- /dev/null
+++ b/sys-libs/glibc/files/2.5/glibc-2.5-hardened-pie.patch
@@ -0,0 +1,39 @@
+Change link commands for glibc executables to build PIEs
+
+Patch by Kevin F. Quinn <kevquinn@gentoo.org>
+
+--- Makeconfig
++++ Makeconfig
+@@ -415,10 +415,10 @@
+
+ # Command for linking programs with the C library.
+ ifndef +link
+-+link = $(CC) -nostdlib -nostartfiles -o $@ \
+++link = $(CC) -nostdlib -nostartfiles -fPIE -pie -o $@ \
+ $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
+ $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
+- $(addprefix $(csu-objpfx),$(start-installed-name)) \
++ $(addprefix $(csu-objpfx),S$(start-installed-name)) \
+ $(+preinit) $(+prector) \
+ $(filter-out $(addprefix $(csu-objpfx),start.o \
+ $(start-installed-name))\
+@@ -429,7 +429,7 @@
+ ifndef +link-static
+ +link-static = $(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) $(+prector) \
+ $(filter-out $(addprefix $(csu-objpfx),start.o \
+ $(start-installed-name))\
+@@ -528,8 +528,8 @@
+ ifeq ($(elf),yes)
+ +preinit = $(addprefix $(csu-objpfx),crti.o)
+ +postinit = $(addprefix $(csu-objpfx),crtn.o)
+-+prector = `$(CC) --print-file-name=crtbegin.o`
+-+postctor = `$(CC) --print-file-name=crtend.o`
+++prector = `$(CC) --print-file-name=crtbeginS.o`
+++postctor = `$(CC) --print-file-name=crtendS.o`
+ +interp = $(addprefix $(elf-objpfx),interp.os)
+ endif
+ csu-objpfx = $(common-objpfx)csu/
diff --git a/sys-libs/glibc/files/2.6/glibc-2.6-gentoo-stack_chk_fail.c b/sys-libs/glibc/files/2.6/glibc-2.6-gentoo-stack_chk_fail.c
new file mode 100644
index 0000000..217bf1a
--- /dev/null
+++ b/sys-libs/glibc/files/2.6/glibc-2.6-gentoo-stack_chk_fail.c
@@ -0,0 +1,321 @@
+/* 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-2007 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 - <kevquinn[@]gentoo.org>
+ *
+ * The following people contributed to the glibc-2.3 Hardened
+ * Gentoo SSP handler, from which this implementation draws much:
+ *
+ * Ned Ludd - <solar[@]gentoo.org>
+ * Alexander Gabert - <pappy[@]gentoo.org>
+ * The PaX Team - <pageexec[@]freemail.hu>
+ * Peter S. Mazinger - <ps.m[@]gmx.net>
+ * Yoann Vandoorselaere - <yoann[@]prelude-ids.org>
+ * Robert Connolly - <robert[@]linuxfromscratch.org>
+ * Cory Visi <cory[@]visi.name>
+ * Mike Frysinger <vapier[@]gentoo.org>
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+#include <sys/types.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include <kernel-features.h>
+
+#include <alloca.h>
+/* from sysdeps */
+#include <socketcall.h>
+/* for the stuff in bits/socket.h */
+#include <sys/socket.h>
+#include <sys/un.h>
+
+
+/* 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 = "<rtld>";
+#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[] = "<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.6/glibc-2.6-hardened-inittls-nosysenter.patch b/sys-libs/glibc/files/2.6/glibc-2.6-hardened-inittls-nosysenter.patch
new file mode 100644
index 0000000..be8ca19
--- /dev/null
+++ b/sys-libs/glibc/files/2.6/glibc-2.6-hardened-inittls-nosysenter.patch
@@ -0,0 +1,273 @@
+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 <kevquinn@gentoo.org>
+
+--- csu/libc-start.c
++++ csu/libc-start.c
+@@ -28,6 +28,7 @@
+ extern int __libc_multiple_libcs;
+
+ #include <tls.h>
++#include <sysdep.h>
+ #ifndef SHARED
+ # include <dl-osinfo.h>
+ 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
+ #endif
+
+ # ifndef SHARED
+--- csu/libc-tls.c
++++ csu/libc-tls.c
+@@ -23,6 +23,7 @@
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <sys/param.h>
++#include <sysdep.h>
+
+
+ #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 <unistd.h>
+ #include <errno.h>
++#include <sysdep.h>
+
+ /* 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.7/glibc-2.7-hardened-inittls-nosysenter.patch b/sys-libs/glibc/files/2.7/glibc-2.7-hardened-inittls-nosysenter.patch
new file mode 100644
index 0000000..ecf57a9
--- /dev/null
+++ b/sys-libs/glibc/files/2.7/glibc-2.7-hardened-inittls-nosysenter.patch
@@ -0,0 +1,273 @@
+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 <kevquinn@gentoo.org>
+
+--- csu/libc-start.c
++++ csu/libc-start.c
+@@ -28,6 +28,7 @@
+ extern int __libc_multiple_libcs;
+
+ #include <tls.h>
++#include <sysdep.h>
+ #ifndef SHARED
+ # include <dl-osinfo.h>
+ 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 <unistd.h>
+ #include <stdio.h>
+ #include <sys/param.h>
++#include <sysdep.h>
+
+
+ #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 <unistd.h>
+ #include <errno.h>
++#include <sysdep.h>
+
+ /* 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/eblits/common.eblit b/sys-libs/glibc/files/eblits/common.eblit
new file mode 100644
index 0000000..6ef9bd8
--- /dev/null
+++ b/sys-libs/glibc/files/eblits/common.eblit
@@ -0,0 +1,292 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/common.eblit,v 1.22 2011/08/19 23:03:11 vapier Exp $
+
+# 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.
+# note: intentionally undocumented.
+alt_headers() {
+ if [[ -z ${ALT_HEADERS} ]] ; then
+ if is_crosscompile ; then
+ ALT_HEADERS="/usr/${CTARGET}/usr/include"
+ else
+ ALT_HEADERS="/usr/include"
+ fi
+ fi
+ echo "${ALT_HEADERS}"
+}
+alt_build_headers() {
+ if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
+ ALT_BUILD_HEADERS=$(alt_headers)
+ if tc-is-cross-compiler ; then
+ ALT_BUILD_HEADERS=${ROOT}$(alt_headers)
+ if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
+ local header_path=$(echo '#include <linux/version.h>' | $(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_usrlibdir() {
+ if is_crosscompile ; then
+ echo /usr/${CTARGET}/usr/$(get_libdir)
+ else
+ echo /usr/$(get_libdir)
+ fi
+}
+
+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
+ if ! glibc_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
+ if ! glibc_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%%-*}
+ filter-flags '-march=*'
+ export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
+ einfo "Auto adding -march=${t} to CFLAGS_x86 #185404"
+ fi
+ ;;
+ ppc)
+ append-flags "-freorder-blocks"
+ ;;
+ sparc)
+ # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
+ filter-flags "-fcall-used-g7"
+ append-flags "-fcall-used-g6"
+ filter-flags "-mvis"
+
+ GLIBCMAJOR=$(get_version_component_range 1 ${PV})
+ GLIBCMINOR=$(get_version_component_range 2 ${PV})
+
+ # set CTARGET_OPT so glibc can use cpu-specific .S files for better performance
+ # - UltraSPARC T1 (niagara) support requires >= glibc 2.8
+ # - UltraSPARC T2 (niagara2) support requires >= glibc 2.7
+
+ if is_crosscompile || [[ ${PROFILE_ARCH} == "sparc64" ]] || { has_multilib_profile && ! tc-is-cross-compiler; } ; then
+ case ${ABI}:${CTARGET} in
+ sparc64:*|\
+ default:sparc64*)
+ filter-flags -Wa,-xarch -Wa,-A
+
+ if is-flagq "-mcpu=niagara2" && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.7 ]] ; then
+ CTARGET_OPT="sparc64v2-unknown-linux-gnu"
+ append-flags "-Wa,-xarch=v9b"
+ export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9b"
+ elif { is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2" ; } && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.6 ]] ; then
+ CTARGET_OPT="sparc64v-unknown-linux-gnu"
+ append-flags "-Wa,-xarch=v9b"
+ export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9b"
+ elif is-flagq "-mcpu=ultrasparc3" || is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2"; then
+ CTARGET_OPT="sparc64b-unknown-linux-gnu"
+ append-flags "-Wa,-xarch=v9b"
+ export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9b"
+ else
+ CTARGET_OPT="sparc64-unknown-linux-gnu"
+ append-flags "-Wa,-xarch=v9a"
+ export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9a"
+ fi
+ ;;
+ *)
+ if is-flagq "-mcpu=niagara2" && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.7 ]] ; then
+ CTARGET_OPT="sparcv9v2-unknown-linux-gnu"
+ elif { is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2" ; } && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.6 ]] ; then
+ CTARGET_OPT="sparcv9v-unknown-linux-gnu"
+ elif is-flagq "-mcpu=ultrasparc3" || is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2"; then
+ CTARGET_OPT="sparcv9b-unknown-linux-gnu"
+ else
+ CTARGET_OPT="sparcv9-unknown-linux-gnu"
+ fi
+ ;;
+ esac
+ else
+ if is-flagq "-mcpu=niagara2" && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.7 ]] ; then
+ CTARGET_OPT="sparcv9v2-unknown-linux-gnu"
+ elif { is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2" ; } && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.6 ]] ; then
+ CTARGET_OPT="sparcv9v-unknown-linux-gnu"
+ elif is-flagq "-mcpu=ultrasparc3" || is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2"; then
+ CTARGET_OPT="sparcv9b-unknown-linux-gnu"
+ elif { is_crosscompile && want_nptl; } || is-flagq "-mcpu=ultrasparc2" || is-flagq "-mcpu=ultrasparc"; then
+ CTARGET_OPT="sparcv9-unknown-linux-gnu"
+ fi
+ fi
+ ;;
+ 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=*
+
+ unset CBUILD_OPT CTARGET_OPT
+ if has_multilib_profile ; 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 -- linuxthreads needs it and we want to be
+ # conservative here. -fno-strict-aliasing is to work around #155906
+ filter-flags -O?
+ append-flags -O2 -fno-strict-aliasing
+
+ # Cant build glibc itself with fortify code
+ append-cppflags -U_FORTIFY_SOURCE
+
+ # building glibc with SSP is fraught with difficulty, especially
+ # due to __stack_chk_fail_local which would mean significant changes
+ # to the glibc build process. See bug #94325 #293721
+ use hardened && gcc-specs-ssp && append-cflags $(test-flags-CC -fno-stack-protector)
+
+ if use hardened && gcc-specs-pie ; then
+ # Force PIC macro definition for all compilations since they're all
+ # either -fPIC or -fPIE with the default-PIE compiler.
+ append-cppflags -DPIC
+ else
+ # Don't build -fPIE without the default-PIE compiler and the
+ # hardened-pie patch
+ filter-flags -fPIE
+ fi
+}
+
+want_nptl() {
+ [[ -z ${LT_VER} ]] && return 0
+ want_tls || return 1
+ use nptl || return 1
+
+ # Only list the arches that cannot do NPTL
+ case $(tc-arch) in
+ m68k) return 1;;
+ sparc)
+ # >= v9 is needed for nptl.
+ [[ ${PROFILE_ARCH} == "sparc" ]] && return 1
+ ;;
+ esac
+
+ return 0
+}
+
+want_linuxthreads() {
+ [[ -z ${LT_VER} ]] && return 1
+ ! use nptlonly && return 0
+ want_nptl || return 0
+ return 1
+}
+
+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 -- cant test linking yet
+ tc-has-tls -c ${CTARGET}
+ WANT__THREAD=$?
+
+ return ${WANT__THREAD}
+}
+
+use_multiarch() {
+ # Make sure binutils is new enough to support indirect functions #336792
+ local bver=$($(tc-getLD ${CTARGET}) -v | awk '{print $NF}') nver
+ case $(tc-arch ${CTARGET}) in
+ amd64|x86) nver="2.20" ;;
+ sparc) nver="2.21" ;;
+ *) return 1 ;;
+ esac
+ version_is_at_least ${nver} ${bver}
+}
+
+# Setup toolchain variables that had historically
+# been defined in the profiles for these archs.
+setup_env() {
+ # silly users
+ unset LD_RUN_PATH
+
+ multilib_env ${CTARGET_OPT:-${CTARGET}}
+ if is_crosscompile || tc-is-cross-compiler ; then
+ if ! use multilib ; then
+ MULTILIB_ABIS=${DEFAULT_ABI}
+ else
+ MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
+ fi
+
+ # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
+ # and fall back on CFLAGS.
+ local VAR=CFLAGS_${CTARGET//[-.]/_}
+ CFLAGS=${!VAR-${CFLAGS}}
+ fi
+
+ setup_flags
+
+ export ABI=${ABI:-${DEFAULT_ABI:-default}}
+
+ 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}"
+}
+
+just_headers() {
+ is_crosscompile && use crosscompile_opts_headers-only
+}
diff --git a/sys-libs/glibc/files/eblits/pkg_postinst.eblit b/sys-libs/glibc/files/eblits/pkg_postinst.eblit
new file mode 100644
index 0000000..2566eed
--- /dev/null
+++ b/sys-libs/glibc/files/eblits/pkg_postinst.eblit
@@ -0,0 +1,29 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/pkg_postinst.eblit,v 1.1 2009/03/01 21:06:22 vapier Exp $
+
+eblit-glibc-pkg_postinst() {
+ # nothing to do if just installing headers
+ just_headers && return
+
+ if ! tc-is-cross-compiler && [[ -x ${ROOT}/usr/sbin/iconvconfig ]] ; then
+ # Generate fastloading iconv module configuration file.
+ "${ROOT}"/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
+
+ # if the host locales.gen contains no entries, we'll install everything
+ 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
+ local x jobs
+ for x in ${MAKEOPTS} ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done
+ locale-gen -j ${jobs:-1} --config "${locale_list}"
+ fi
+}
diff --git a/sys-libs/glibc/files/eblits/pkg_preinst.eblit b/sys-libs/glibc/files/eblits/pkg_preinst.eblit
new file mode 100644
index 0000000..dcde615
--- /dev/null
+++ b/sys-libs/glibc/files/eblits/pkg_preinst.eblit
@@ -0,0 +1,90 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/pkg_preinst.eblit,v 1.3 2010/10/08 15:33:13 flameeyes Exp $
+
+fix_lib64_symlinks() {
+ # the original Gentoo/AMD64 devs decided that since 64bit is the native
+ # bitdepth for AMD64, lib should be used for 64bit libraries. however,
+ # this ignores the FHS and breaks multilib horribly... especially
+ # since it wont even work without a lib64 symlink anyways. *rolls eyes*
+ # see bug 59710 for more information.
+ # Travis Tilley <lv@gentoo.org> (08 Aug 2004)
+ if [ -L ${ROOT}/lib64 ] ; then
+ ewarn "removing /lib64 symlink and moving lib to lib64..."
+ ewarn "dont hit ctrl-c until this is done"
+ rm ${ROOT}/lib64
+ # now that lib64 is gone, nothing will run without calling ld.so
+ # directly. luckily the window of brokenness is almost non-existant
+ use amd64 && /lib/ld-linux-x86-64.so.2 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ use ppc64 && /lib/ld64.so.1 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ # all better :)
+ ldconfig
+ ln -s lib64 ${ROOT}/lib
+ einfo "done! :-)"
+ einfo "fixed broken lib64/lib symlink in ${ROOT}"
+ fi
+ if [ -L ${ROOT}/usr/lib64 ] ; then
+ rm ${ROOT}/usr/lib64
+ mv ${ROOT}/usr/lib ${ROOT}/usr/lib64
+ ln -s lib64 ${ROOT}/usr/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr"
+ fi
+ if [ -L ${ROOT}/usr/X11R6/lib64 ] ; then
+ rm ${ROOT}/usr/X11R6/lib64
+ mv ${ROOT}/usr/X11R6/lib ${ROOT}/usr/X11R6/lib64
+ ln -s lib64 ${ROOT}/usr/X11R6/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6"
+ fi
+}
+
+eblit-glibc-pkg_preinst() {
+ # nothing to do if just installing headers
+ just_headers && return
+
+ # PPC64+others may want to eventually be added to this logic if they
+ # decide to be multilib compatible and FHS compliant. note that this
+ # chunk of FHS compliance only applies to 64bit archs where 32bit
+ # compatibility is a major concern (not IA64, for example).
+
+ # amd64's 2005.0 is the first amd64 profile to not need this code.
+ # 2005.0 is setup properly, and this is executed as part of the
+ # 2004.3 -> 2005.0 upgrade script.
+ # It can be removed after 2004.3 has been purged from portage.
+ { use amd64 || use ppc64; } && [ "$(get_libdir)" == "lib64" ] && ! has_multilib_profile && fix_lib64_symlinks
+
+ # it appears that /lib/tls is sometimes not removed. See bug
+ # 69258 for more info.
+ if [[ -d ${ROOT}/$(alt_libdir)/tls ]] && [[ ! -d ${D}/$(alt_libdir)/tls ]] ; then
+ ewarn "nptlonly or -nptl in USE, removing /${ROOT}$(alt_libdir)/tls..."
+ rm -r "${ROOT}"/$(alt_libdir)/tls || die
+ fi
+
+ # prepare /etc/ld.so.conf.d/ for files
+ mkdir -p "${ROOT}"/etc/ld.so.conf.d
+
+ # simple test to make sure our new glibc isnt 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.
+ [[ ${ROOT} != "/" ]] && return 0
+ [[ -d ${D}/$(get_libdir) ]] || return 0
+ cd / #228809
+ local x striptest
+ for x in date env ls true uname ; do
+ x=$(type -p ${x})
+ [[ -z ${x} ]] && continue
+ striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null)
+ [[ -z ${striptest} ]] && continue
+ [[ ${striptest} == *"statically linked"* ]] && continue
+ # we enter ${D} 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 "${D}"/$(get_libdir) 2>/dev/null
+ ./ld-*.so --library-path . ${x} > /dev/null \
+ || die "simple run test (${x}) failed"
+ popd 2>/dev/null
+ done
+}
diff --git a/sys-libs/glibc/files/eblits/pkg_setup.eblit b/sys-libs/glibc/files/eblits/pkg_setup.eblit
new file mode 100644
index 0000000..a0143c7
--- /dev/null
+++ b/sys-libs/glibc/files/eblits/pkg_setup.eblit
@@ -0,0 +1,105 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/pkg_setup.eblit,v 1.6 2011/03/20 22:23:47 vapier Exp $
+
+glibc_compile_test() {
+ local ret save_cflags=${CFLAGS}
+ CFLAGS+=" $1"
+ shift
+
+ pushd "${T}" >/dev/null
+
+ rm -f glibc-test*
+ printf '%b' "$*" > glibc-test.c
+
+ emake -s glibc-test
+ ret=$?
+
+ popd >/dev/null
+
+ CFLAGS=${save_cflags}
+ return ${ret}
+}
+
+glibc_run_test() {
+ local ret
+
+ if [[ ${EMERGE_FROM} == "binary" ]] ; then
+ # ignore build failures when installing a binary package #324685
+ glibc_compile_test "" "$@" 2>/dev/null || return 0
+ else
+ if ! glibc_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}
+}
+
+eblit-glibc-pkg_setup() {
+ # prevent native builds from downgrading ... maybe update to allow people
+ # to change between diff -r versions ? (2.3.6-r4 -> 2.3.6-r2)
+ if [[ ${ROOT} == "/" ]] && [[ ${CBUILD} == ${CHOST} ]] && [[ ${CHOST} == ${CTARGET} ]] ; then
+ if has_version '>'${CATEGORY}/${PF} ; 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 ! glibc_run_test '#include <pwd.h>\nint main(){return getpwuid(0)==0;}\n'
+ then
+ eerror "Your patched vendor kernel is broken. You need to get an"
+ eerror "update from whoever is providing the kernel to you."
+ eerror "http://sourceware.org/bugzilla/show_bug.cgi?id=5227"
+ eerror "http://bugs.gentoo.org/262698"
+ die "keeping your system alive, say thank you"
+ fi
+
+ if ! glibc_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n'
+ then
+ eerror "Your old kernel is broken. You need to update it to"
+ eerror "a newer version as syscall(<bignum>) will break."
+ eerror "http://bugs.gentoo.org/279260"
+ die "keeping your system alive, say thank you"
+ fi
+ fi
+
+ # users have had a chance to phase themselves, time to give em the boot
+ if [[ -e ${ROOT}/etc/locale.gen ]] && [[ -e ${ROOT}/etc/locales.build ]] ; then
+ eerror "You still haven't deleted ${ROOT}/etc/locales.build."
+ eerror "Do so now after making sure ${ROOT}/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 http://www.gentoo.org/doc/en/change-chost.xml"
+ die "please fix your CHOST"
+ fi
+
+ if [[ -n ${LT_VER} ]] ; then
+ if use nptlonly && ! use nptl ; then
+ eerror "If you want nptlonly, add nptl to your USE too ;p"
+ die "nptlonly without nptl"
+ fi
+ 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
+
+ use hardened && ! gcc-specs-pie && \
+ ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
+}
diff --git a/sys-libs/glibc/files/eblits/src_compile.eblit b/sys-libs/glibc/files/eblits/src_compile.eblit
new file mode 100644
index 0000000..dafd2aa
--- /dev/null
+++ b/sys-libs/glibc/files/eblits/src_compile.eblit
@@ -0,0 +1,213 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_compile.eblit,v 1.17 2011/03/11 02:40:28 vapier Exp $
+
+glibc_do_configure() {
+ local myconf
+
+ einfo "Configuring GLIBC for $1"
+
+ # set addons
+ pushd "${S}" > /dev/null
+ local ADDONS=$(echo */configure | sed \
+ -e 's:/configure::g' \
+ -e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
+ -e 's: \+$::' \
+ -e 's! !,!g' \
+ -e 's!^!,!' \
+ -e '/^,\*$/d')
+ [[ -d ports ]] && ADDONS="${ADDONS},ports"
+ popd > /dev/null
+
+ use nls || myconf="${myconf} --disable-nls"
+ myconf="${myconf} $(use_enable hardened stackguard-randomization)"
+ if [[ $(<"${T}"/.ssp.compat) == "yes" ]] ; then
+ myconf="${myconf} --enable-old-ssp-compat"
+ else
+ myconf="${myconf} --disable-old-ssp-compat"
+ fi
+
+ use glibc-omitfp && myconf="${myconf} --enable-omitfp"
+
+ [[ ${CTARGET//_/-} == *-softfloat-* ]] && myconf="${myconf} --without-fp"
+
+ if [[ $1 == "linuxthreads" ]] ; then
+ if want_tls ; then
+ myconf="${myconf} --with-tls"
+
+ if ! want__thread || use glibc-compat20 || [[ ${LT_KER_VER} == 2.[02].* ]] ; then
+ myconf="${myconf} --without-__thread"
+ else
+ myconf="${myconf} --with-__thread"
+ fi
+ else
+ myconf="${myconf} --without-tls --without-__thread"
+ fi
+
+ myconf="${myconf} --disable-sanity-checks"
+ myconf="${myconf} --enable-add-ons=linuxthreads${ADDONS}"
+ myconf="${myconf} --enable-kernel=${LT_KER_VER}"
+ elif [[ $1 == "nptl" ]] ; then
+ myconf="${myconf} --enable-add-ons=nptl${ADDONS}"
+ myconf="${myconf} --enable-kernel=${NPTL_KERN_VER}"
+ else
+ die "invalid pthread option"
+ fi
+
+ # 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 || has_multilib_profile ; then
+ if is_final_abi ; then
+ myconf="${myconf} --with-selinux"
+ else
+ myconf="${myconf} --without-selinux"
+ fi
+ else
+ myconf="${myconf} --with-selinux"
+ fi
+ else
+ myconf="${myconf} --without-selinux"
+ fi
+
+ myconf="${myconf}
+ --without-cvs
+ --enable-bind-now
+ --build=${CBUILD_OPT:-${CBUILD}}
+ --host=${CTARGET_OPT:-${CTARGET}}
+ $(use_enable profile)
+ $(use_with gd)
+ --with-headers=$(alt_build_headers)
+ --prefix=/usr
+ --libdir=/usr/$(get_libdir)
+ --mandir=/usr/share/man
+ --infodir=/usr/share/info
+ --libexecdir=/usr/$(get_libdir)/misc/glibc
+ $(use_multiarch || echo --disable-multi-arch)
+ ${EXTRA_ECONF}"
+
+ # 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_slibdir=/$(get_libdir)
+
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-$1
+ mkdir -p "${GBUILDDIR}"
+ cd "${GBUILDDIR}"
+ echo "${S}"/configure ${myconf}
+ "${S}"/configure ${myconf} || die "failed to configure glibc"
+
+ # since we'll be punting them for cross-compilers, and they can cause
+ # problems (ia64+static), we'll just skip building altogether
+ is_crosscompile && sed -i '1ibuild-programs = no' config.make
+}
+
+toolchain-glibc_src_compile() {
+ echo
+ local v
+ for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CFLAGS ; do
+ einfo " $(printf '%15s' ${v}:) ${!v}"
+ done
+ export CC=$(tc-getCC ${CTARGET})
+ einfo " $(printf '%15s' 'Manual CC:') ${CC}"
+ echo
+
+ if want_linuxthreads ; then
+ glibc_do_configure linuxthreads
+ emake || die "make for ${ABI} failed"
+ fi
+ if want_nptl ; then
+ # ... and then do the optional nptl build
+ unset LD_ASSUME_KERNEL
+ glibc_do_configure nptl
+ emake || die "make for ${ABI} failed"
+ fi
+}
+
+toolchain-glibc_headers_compile() {
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
+ mkdir -p "${GBUILDDIR}"
+ cd "${GBUILDDIR}"
+
+ # if we don't have a compiler yet, we cant really test it now ...
+ # hopefully they don't affect header geneation, so let's hope for
+ # the best here ...
+ export \
+ ac_cv_header_cpuid_h=yes \
+ libc_cv_386_tls=yes \
+ libc_cv_asm_cfi_directives=yes \
+ libc_cv_broken_visibility_attribute=no \
+ 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_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
+
+ # Pick out the correct location for build headers
+ local ports="" myconf="--disable-sanity-checks --enable-hacker-mode"
+ [[ -d ${S}/ports ]] && ports=",ports"
+ myconf="${myconf}
+ --enable-add-ons=nptl${ports}
+ --without-cvs
+ --enable-bind-now
+ --build=${CBUILD_OPT:-${CBUILD}}
+ --host=${CTARGET_OPT:-${CTARGET}}
+ --with-headers=$(alt_build_headers)
+ --prefix=/usr
+ ${EXTRA_ECONF}"
+
+ # Nothing is compiled here which would affect the headers for the target.
+ # so forcing CC/CFLAGS is sane. unless you dont have `gcc`. then i
+ # dont care :p.
+ echo "${S}"/configure ${myconf}
+ CC=gcc \
+ CFLAGS="-O1 -pipe" \
+ CPPFLAGS="-U_FORTIFY_SOURCE" \
+ "${S}"/configure ${myconf} || die "failed to configure glibc"
+}
+
+eblit-glibc-src_compile() {
+ if is_crosscompile ; then
+ export \
+ libc_cv_c_cleanup=yes \
+ libc_cv_forced_unwind=yes
+ fi
+
+ if just_headers ; then
+ export ABI=default
+ toolchain-glibc_headers_compile
+ return
+ fi
+
+ setup_env
+
+ if [[ -z ${OABI} ]] ; then
+ local abilist=""
+ if has_multilib_profile ; then
+ abilist=$(get_install_abis)
+ einfo "Building multilib glibc for ABIs: ${abilist}"
+ elif is_crosscompile || tc-is-cross-compiler ; then
+ abilist=${DEFAULT_ABI}
+ fi
+ if [[ -n ${abilist} ]] ; then
+ OABI=${ABI}
+ for ABI in ${abilist} ; do
+ export ABI
+ src_compile
+ done
+ ABI=${OABI}
+ unset OABI
+ return 0
+ fi
+ fi
+
+ toolchain-glibc_src_compile
+}
diff --git a/sys-libs/glibc/files/eblits/src_install.eblit b/sys-libs/glibc/files/eblits/src_install.eblit
new file mode 100644
index 0000000..7cc838a
--- /dev/null
+++ b/sys-libs/glibc/files/eblits/src_install.eblit
@@ -0,0 +1,240 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_install.eblit,v 1.15 2011/07/08 15:38:29 ssuominen Exp $
+
+toolchain-glibc_src_install() {
+ local GBUILDDIR
+ if want_linuxthreads ; then
+ GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-linuxthreads
+ else
+ GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-nptl
+ fi
+
+ local install_root=${D}
+ is_crosscompile && install_root="${install_root}/usr/${CTARGET}"
+ if want_linuxthreads ; then
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-linuxthreads
+ einfo "Installing GLIBC ${ABI} with linuxthreads ..."
+ else # nptlonly
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
+ einfo "Installing GLIBC ${ABI} with NPTL ..."
+ fi
+ emake install_root="${install_root}" install || die
+
+ if is_crosscompile ; then
+ # punt all the junk not needed by a cross-compiler
+ cd "${D}"/usr/${CTARGET} || die
+ rm -rf ./{,usr/}{bin,etc,sbin,share} ./{,usr/}*/{gconv,misc}
+ fi
+
+ if want_linuxthreads && want_nptl ; then
+ einfo "Installing NPTL to $(alt_libdir)/tls/..."
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
+ dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
+
+ local l src_lib
+ for l in libc libm librt libpthread libthread_db ; do
+ # take care of shared lib first ...
+ l=${l}.so
+ if [[ -e ${l} ]] ; then
+ src_lib=${l}
+ else
+ src_lib=$(eval echo */${l})
+ fi
+ cp -a ${src_lib} "${D}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
+ fperms a+rx $(alt_libdir)/tls/${l}
+ dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
+
+ # then grab the linker script or the symlink ...
+ if [[ -L ${D}$(alt_usrlibdir)/${l} ]] ; then
+ dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
+ else
+ sed \
+ -e "s:/${l}:/tls/${l}:g" \
+ -e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
+ "${D}"$(alt_usrlibdir)/${l} > "${D}"$(alt_usrlibdir)/nptl/${l}
+ fi
+
+ # then grab the static lib ...
+ src_lib=${src_lib/%.so/.a}
+ [[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
+ cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
+ src_lib=${src_lib/%.a/_nonshared.a}
+ if [[ -e ${src_lib} ]] ; then
+ cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
+ fi
+ done
+
+ # use the nptl linker instead of the linuxthreads one as the linuxthreads
+ # one may lack TLS support and that can be really bad for business
+ cp -a elf/ld.so "${D}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
+ fi
+
+ # We'll take care of the cache ourselves
+ rm -f "${D}"/etc/ld.so.cache
+
+ # When cross-compiling for a non-multilib setup, make sure we have
+ # lib and a proper symlink setup
+ if is_crosscompile && ! use multilib && ! has_multilib_profile && [[ $(get_libdir) != "lib" ]] ; then
+ cd "${D}"$(alt_libdir)/..
+ mv $(get_libdir) lib || die
+ ln -s lib $(get_libdir) || die
+ cd "${D}"$(alt_usrlibdir)/..
+ mv $(get_libdir) lib || die
+ ln -s lib $(get_libdir) || die
+ 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
+ dosym usr/include /usr/${CTARGET}/sys-include
+ return 0
+ fi
+
+ # 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
+ if [[ ${SYMLINK_LIB} == "yes" ]] && has_multilib_profile ; then
+ case $(tc-arch) in
+ amd64)
+ [[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR amd64) /lib
+ dosym ../$(get_abi_LIBDIR x86)/ld-linux.so.2 /lib/ld-linux.so.2
+ ;;
+ ppc64)
+ [[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR ppc64) /lib
+ dosym ../$(get_abi_LIBDIR ppc)/ld.so.1 /lib/ld.so.1
+ ;;
+ esac
+ 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 > "${D}"/usr/share/i18n/SUPPORTED \
+ || die "generating /usr/share/i18n/SUPPORTED failed"
+ cd "${WORKDIR}"/extra/locale
+ dosbin locale-gen || die
+ doman *.[0-8]
+ insinto /etc
+ doins locale.gen || die
+
+ # 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 ${D}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
+ dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
+ fi
+ done
+
+ if ! has noinfo ${FEATURES} && [[ -n ${INFOPAGE_VER} ]] ; then
+ einfo "Installing info pages..."
+
+ emake \
+ -C "${GBUILDDIR}" \
+ install_root="${install_root}" \
+ info -i || die
+ fi
+
+ if [[ -n ${MANPAGE_VER} ]] ; then
+ einfo "Installing man pages..."
+
+ # Install linuxthreads man pages even if nptl is enabled
+ cd "${WORKDIR}"/man
+ doman *.3thr
+ fi
+
+ cd "${S}"
+
+ # Install misc network config files
+ insinto /etc
+ doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf || die
+ doins "${WORKDIR}"/extra/etc/*.conf || die
+ doinitd "${WORKDIR}"/extra/etc/nscd || die
+
+ sed -i -e "s:@PIDFILE@:$(strings "${D}"/usr/sbin/nscd | grep nscd.pid):" "${D}"/etc/init.d/nscd
+
+ echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
+ doenvd "${T}"/00glibc || die
+
+ dodoc BUGS ChangeLog* CONFORMANCE FAQ NEWS NOTES PROJECTS README*
+
+ # Prevent overwriting of the /etc/localtime symlink. We'll handle the
+ # creation of the "factory" symlink in pkg_postinst().
+ rm -f "${D}"/etc/localtime
+}
+
+toolchain-glibc_headers_install() {
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
+ cd "${GBUILDDIR}"
+ emake install_root="${D}/usr/${CTARGET}" install-headers || die "install-headers failed"
+ # Copy over headers that are not part of install-headers ... these
+ # are pretty much taken verbatim from crosstool, see it for more details
+ insinto $(alt_headers)/bits
+ doins misc/syscall-list.h bits/stdio_lim.h || die "doins include bits"
+ insinto $(alt_headers)/gnu
+ doins "${S}"/include/gnu/stubs.h || die "doins include gnu"
+ # 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 /usr/${CTARGET}/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 "${D}"/*/libpthread-*.so
+ fi
+}
+
+eblit-glibc-src_install() {
+ if just_headers ; then
+ export ABI=default
+ toolchain-glibc_headers_install
+ return
+ fi
+
+ setup_env
+
+ if [[ -z ${OABI} ]] ; then
+ local abilist=""
+ if has_multilib_profile ; then
+ abilist=$(get_install_abis)
+ einfo "Installing multilib glibc for ABIs: ${abilist}"
+ elif is_crosscompile || tc-is-cross-compiler ; then
+ abilist=${DEFAULT_ABI}
+ fi
+ if [[ -n ${abilist} ]] ; then
+ OABI=${ABI}
+ for ABI in ${abilist} ; do
+ export ABI
+ eblit-glibc-src_install
+ done
+ ABI=${OABI}
+ unset OABI
+ src_strip
+ return 0
+ fi
+ fi
+
+ toolchain-glibc_src_install
+ [[ -z ${OABI} ]] && src_strip
+}
diff --git a/sys-libs/glibc/files/eblits/src_test.eblit b/sys-libs/glibc/files/eblits/src_test.eblit
new file mode 100644
index 0000000..edcdac7
--- /dev/null
+++ b/sys-libs/glibc/files/eblits/src_test.eblit
@@ -0,0 +1,42 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_test.eblit,v 1.4 2010/08/10 08:08:05 vapier Exp $
+
+toolchain-glibc_src_test() {
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-$1 || die "cd build-${ABI}-${CTARGET}-$1"
+ unset LD_ASSUME_KERNEL
+ emake -j1 check && return 0
+ einfo "make check failed - re-running with --keep-going to get the rest of the results"
+ emake -j1 -k check
+ ewarn "make check failed for ${ABI}-${CTARGET}-$1"
+ return 1
+}
+
+eblit-glibc-src_test() {
+ local ret=0
+
+ setup_env
+
+ # give tests more time to complete
+ export TIMEOUTFACTOR=5
+
+ if [[ -z ${OABI} ]] && has_multilib_profile ; then
+ OABI=${ABI}
+ einfo "Testing multilib glibc for ABIs: $(get_install_abis)"
+ for ABI in $(get_install_abis) ; do
+ export ABI
+ einfo " Testing ${ABI} glibc"
+ src_test
+ ((ret+=$?))
+ done
+ ABI=${OABI}
+ unset OABI
+ [[ ${ret} -ne 0 ]] \
+ && die "tests failed" \
+ || return 0
+ fi
+
+ want_linuxthreads && toolchain-glibc_src_test linuxthreads ; ((ret+=$?))
+ want_nptl && toolchain-glibc_src_test nptl ; ((ret+=$?))
+ return ${ret}
+}
diff --git a/sys-libs/glibc/files/eblits/src_unpack.eblit b/sys-libs/glibc/files/eblits/src_unpack.eblit
new file mode 100644
index 0000000..c22c25c
--- /dev/null
+++ b/sys-libs/glibc/files/eblits/src_unpack.eblit
@@ -0,0 +1,197 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_unpack.eblit,v 1.13 2011/08/23 18:37:57 vapier Exp $
+
+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() {
+ [[ $(KV_to_int $1) -ge $(KV_to_int $2) ]]
+ eend $?
+}
+
+get_kheader_version() {
+ printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
+ $(tc-getCPP ${CTARGET}) -I "$(alt_build_headers)" | \
+ tail -n 1
+}
+
+check_nptl_support() {
+ # don't care about the compiler here as we arent using it
+ just_headers && return
+
+ local run_kv build_kv want_kv
+ run_kv=$(int_to_KV $(get_KV))
+ build_kv=$(int_to_KV $(get_kheader_version))
+ want_kv=${NPTL_KERN_VER}
+
+ 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 ! is_crosscompile && ! tc-is-cross-compiler ; then
+ # Building fails on an non-supporting kernel
+ ebegin "Checking 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} for NPTL support!"
+ 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} for NPTL support!"
+ die "linux-headers version too low!"
+ fi
+}
+
+unpack_pkg() {
+ local a=${PN}
+ [[ -n ${SNAP_VER} ]] && a="${a}-${RELEASE_VER}"
+ [[ -n $1 ]] && a="${a}-$1"
+ if [[ -n ${SNAP_VER} ]] ; then
+ a="${a}-${SNAP_VER}"
+ else
+ if [[ -n $2 ]] ; then
+ a="${a}-$2"
+ else
+ a="${a}-${RELEASE_VER}"
+ fi
+ fi
+ unpack ${a}.tar.bz2
+ [[ -n $1 ]] && mv ${a} $1
+}
+
+toolchain-glibc_src_unpack() {
+ # Check NPTL support _before_ we unpack things to save some time
+ want_nptl && check_nptl_support
+
+ if [[ -n ${EGIT_REPO_URIS} ]] ; then
+ local i d
+ for ((i=0; i<${#EGIT_REPO_URIS[@]}; ++i)) ; do
+ EGIT_REPO_URI=${EGIT_REPO_URIS[$i]}
+ EGIT_SOURCEDIR=${EGIT_SOURCEDIRS[$i]}
+ git-2_src_unpack
+ done
+ else
+ unpack_pkg
+ fi
+
+ cd "${S}"
+ touch locale/C-translit.h #185476 #218003
+ [[ -n ${LT_VER} ]] && unpack_pkg linuxthreads ${LT_VER}
+ [[ -n ${PORTS_VER} ]] && unpack_pkg ports ${PORTS_VER}
+ [[ -n ${LIBIDN_VER} ]] && unpack_pkg libidn
+
+ if [[ -n ${PATCH_VER} ]] ; then
+ cd "${WORKDIR}"
+ unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2
+ # pull out all the addons
+ local d
+ for d in extra/*/configure ; do
+ d=${d%/configure}
+ [[ -d ${S}/${d} ]] && die "${d} already exists in \${S}"
+ mv "${d}" "${S}" || die "moving ${d} failed"
+ done
+ fi
+
+ # XXX: We should do the branchupdate, before extracting the manpages and
+ # infopages else it does not help much (mtimes change if there is a change
+ # to them with branchupdate)
+ if [[ -n ${BRANCH_UPDATE} ]] ; then
+ cd "${S}"
+ epatch "${DISTDIR}"/glibc-${RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+
+ # Snapshot date patch
+ einfo "Patching version to display snapshot date ..."
+ sed -i -e "s:\(#define RELEASE\).*:\1 \"${BRANCH_UPDATE}\":" version.h
+ fi
+
+ if [[ -n ${MANPAGE_VER} ]] ; then
+ cd "${WORKDIR}"
+ unpack glibc-manpages-${MANPAGE_VER}.tar.bz2
+ fi
+
+ if [[ -n ${INFOPAGE_VER} ]] ; then
+ cd "${S}"
+ unpack glibc-infopages-${INFOPAGE_VER}.tar.bz2
+ fi
+
+ # tag, glibc is it
+ cd "${S}"
+ [[ -e csu/Banner ]] && die "need new banner location"
+ [[ -n ${SNAP_VER} ]] && echo "Gentoo snapshot ${SNAP_VER}" >> csu/Banner
+ [[ -n ${BRANCH_UPDATE} ]] && echo "Gentoo branch ${BRANCH_UPDATE}" >> csu/Banner
+ if [[ -n ${PATCH_VER} ]] && ! use vanilla ; then
+ cd "${S}"
+ EPATCH_MULTI_MSG="Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER} ..." \
+ EPATCH_EXCLUDE=${GLIBC_PATCH_EXCLUDE} \
+ EPATCH_SUFFIX="patch" \
+ ARCH=$(tc-arch) \
+ epatch "${WORKDIR}"/patches
+ echo "Gentoo patchset ${PATCH_VER}" >> csu/Banner
+ fi
+
+ if just_headers ; then
+ if [[ -e ports/sysdeps/mips/preconfigure ]] ; then
+ # mips peeps like to screw with us. if building headers,
+ # we don't have a real compiler, so we can't let them
+ # insert -mabi on us.
+ sed -i '/CPPFLAGS=.*-mabi/s|.*|:|' ports/sysdeps/mips/preconfigure || die
+ find ports/sysdeps/mips/ -name Makefile -exec sed -i '/^CC.*-mabi=/s:-mabi=.*:-D_MIPS_SZPTR=32:' {} +
+ fi
+ fi
+
+ epatch_user
+
+ gnuconfig_update
+}
+
+eblit-glibc-src_unpack() {
+ setup_env
+
+ toolchain-glibc_src_unpack
+
+ # Backwards SSP support
+ cd "${S}"
+# For now, we force everyone to have the extra symbols
+# einfon "Scanning system for __guard to see if we need SSP compat ... "
+# if [[ -n $(scanelf -qyls__guard -F'#s%F' | grep -v '^/lib.*/libc-2.*.so$') ]] ; then
+ echo "yes" > "${T}"/.ssp.compat
+# else
+# # ok, a quick scan didnt find it, so lets do a deep scan ...
+# if [[ -n $(scanelf -qyRlps__guard -F'#s%F' | grep -v '^/lib.*/libc-2.*.so$') ]] ; then
+# echo "yes" > "${T}"/.ssp.compat
+# else
+# echo "no" > "${T}"/.ssp.compat
+# fi
+# fi
+# cat "${T}"/.ssp.compat
+
+ # Glibc is stupid sometimes, and doesn't realize that with a
+ # static C-Only gcc, -lgcc_eh doesn't exist.
+ # http://sources.redhat.com/ml/libc-alpha/2003-09/msg00100.html
+ # http://sourceware.org/ml/libc-alpha/2005-02/msg00042.html
+ echo 'int main(){}' > "${T}"/gcc_eh_test.c
+ if ! $(tc-getCC ${CTARGET}) "${T}"/gcc_eh_test.c -lgcc_eh 2>/dev/null ; then
+ sed -i -e 's:-lgcc_eh::' Makeconfig || die "sed gcc_eh"
+ fi
+
+ cd "${WORKDIR}"
+ find . -type f '(' -size 0 -o -name "*.orig" ')' -exec rm -f {} \;
+ find . -name configure -exec touch {} \;
+
+ # Fix permissions on some of the scripts
+ chmod u+x "${S}"/scripts/*.sh
+}
diff --git a/sys-libs/glibc/glibc-2.3.6-r5.ebuild b/sys-libs/glibc/glibc-2.3.6-r5.ebuild
new file mode 100644
index 0000000..7922451
--- /dev/null
+++ b/sys-libs/glibc/glibc-2.3.6-r5.ebuild
@@ -0,0 +1,1230 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/Attic/glibc-2.3.6-r5.ebuild,v 1.29 2009/12/14 14:44:09 vapier dead $
+
+# 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/
+
+KEYWORDS="-* alpha amd64 arm hppa ia64 mips ppc ppc64 ~s390 sh sparc x86"
+
+BRANCH_UPDATE=""
+
+# Generated man pages
+GLIBC_MANPAGE_VERSION="2.3.6-1"
+
+# Generated stuff in manual subdir
+GLIBC_INFOPAGE_VERSION="2.3.6"
+
+# Gentoo patchset
+PATCH_VER="1.19"
+
+GENTOO_TOOLCHAIN_BASE_URI="mirror://gentoo"
+GENTOO_TOOLCHAIN_DEV_URI="http://dev.gentoo.org/~azarah/glibc/XXX http://dev.gentoo.org/~vapier/dist/XXX"
+
+### PUNT OUT TO ECLASS?? ###
+inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib
+
+DESCRIPTION="GNU libc6 (also called glibc2) C library"
+HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
+LICENSE="LGPL-2"
+
+IUSE="nls build nptl nptlonly erandom hardened multilib selinux glibc-compat20 glibc-omitfp profile"
+
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ PROVIDE="virtual/libc"
+fi
+
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+just_headers() {
+ is_crosscompile && use crosscompile_opts_headers-only
+}
+
+GLIBC_RELEASE_VER=$(get_version_component_range 1-3)
+
+# Don't set this to :-, - allows BRANCH_UPDATE=""
+BRANCH_UPDATE=${BRANCH_UPDATE-$(get_version_component_range 4)}
+
+# (Recent snapshots fails with 2.6.5 and earlier with NPTL)
+NPTL_KERNEL_VERSION=${NPTL_KERNEL_VERSION:-"2.6.9"}
+LT_KERNEL_VERSION=${LT_KERNEL_VERSION:-"2.4.1"}
+
+### SRC_URI ###
+
+# This function handles the basics of setting the SRC_URI for a glibc ebuild.
+# To use, set SRC_URI with:
+#
+# SRC_URI="$(get_glibc_src_uri)"
+#
+# Other than the variables normally set by portage, this function's behavior
+# can be altered by setting the following:
+#
+# GENTOO_TOOLCHAIN_BASE_URI
+# This sets the base URI for all gentoo-specific patch files. Note
+# that this variable is only important for a brief period of time,
+# before your source files get picked up by mirrors. However, it is
+# still highly suggested that you keep files in this location
+# available.
+#
+# BRANCH_UPDATE
+# If set, this variable signals that we should be using the main
+# release tarball (determined by ebuild version) and applying a
+# CVS branch update patch against it. The location of this branch
+# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
+# Just like with SNAPSHOT, this variable is ignored if the ebuild
+# has a _pre suffix.
+#
+# PATCH_VER
+# PATCH_GLIBC_VER
+# This should be set to the version of the gentoo patch tarball.
+# The resulting filename of this tarball will be:
+# glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+#
+# GLIBC_MANPAGE_VERSION
+# GLIBC_INFOPAGE_VERSION
+# The version of glibc for which we will download pages. This will
+# default to ${GLIBC_RELEASE_VER}, but we may not want to pre-generate man pages
+# for prerelease test ebuilds for example. This allows you to
+# continue using pre-generated manpages from the last stable release.
+# If set to "none", this will prevent the downloading of manpages,
+# which is useful for individual library targets.
+#
+get_glibc_src_uri() {
+ GENTOO_TOOLCHAIN_BASE_URI=${GENTOO_TOOLCHAIN_BASE_URI:-"mirror://gentoo"}
+
+# GLIBC_SRC_URI="http://ftp.gnu.org/gnu/glibc/glibc-${GLIBC_RELEASE_VER}.tar.bz2
+# http://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-${GLIBC_RELEASE_VER}.tar.bz2
+# http://ftp.gnu.org/gnu/glibc/glibc-libidn-${GLIBC_RELEASE_VER}.tar.bz2
+ GLIBC_SRC_URI="mirror://gnu/glibc/glibc-${GLIBC_RELEASE_VER}.tar.bz2
+ mirror://gnu/glibc/glibc-linuxthreads-${GLIBC_RELEASE_VER}.tar.bz2
+ mirror://gnu/glibc/glibc-libidn-${GLIBC_RELEASE_VER}.tar.bz2"
+
+ if [[ -n ${BRANCH_UPDATE} ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-${GLIBC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-${GLIBC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2}"
+ fi
+
+ if [[ -n ${PATCH_VER} ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2}"
+ fi
+
+ if [[ ${GLIBC_MANPAGE_VERSION} != "none" ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-manpages-${GLIBC_MANPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-manpages-${GLIBC_MANPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2}"
+ fi
+
+ if [[ ${GLIBC_INFOPAGE_VERSION} != "none" ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-infopages-${GLIBC_INFOPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-infopages-${GLIBC_INFOPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2}"
+ fi
+
+ echo "${GLIBC_SRC_URI}"
+}
+
+SRC_URI=$(get_glibc_src_uri)
+S=${WORKDIR}/glibc-${GLIBC_RELEASE_VER}
+
+### EXPORTED FUNCTIONS ###
+toolchain-glibc_src_unpack() {
+ # Check NPTL support _before_ we unpack things to save some time
+ want_nptl && check_nptl_support
+
+ unpack glibc-${GLIBC_RELEASE_VER}.tar.bz2
+
+ cd "${S}"
+ unpack glibc-linuxthreads-${GLIBC_RELEASE_VER}.tar.bz2
+ unpack glibc-libidn-${GLIBC_RELEASE_VER}.tar.bz2
+
+ if [[ -n ${PATCH_VER} ]] ; then
+ cd "${WORKDIR}"
+ unpack glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+ # pull out all the addons
+ local d
+ for d in extra/*/configure ; do
+ mv "${d%/configure}" "${S}" || die "moving ${d}"
+ done
+ fi
+
+ # XXX: We should do the branchupdate, before extracting the manpages and
+ # infopages else it does not help much (mtimes change if there is a change
+ # to them with branchupdate)
+ if [[ -n ${BRANCH_UPDATE} ]] ; then
+ cd "${S}"
+ epatch "${DISTDIR}"/glibc-${GLIBC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+
+ # Snapshot date patch
+ einfo "Patching version to display snapshot date ..."
+ sed -i -e "s:\(#define RELEASE\).*:\1 \"${BRANCH_UPDATE}\":" version.h
+ fi
+
+ if [[ ${GLIBC_MANPAGE_VERSION} != "none" ]] ; then
+ cd "${WORKDIR}"
+ unpack glibc-manpages-${GLIBC_MANPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ fi
+
+ if [[ ${GLIBC_INFOPAGE_VERSION} != "none" ]] ; then
+ cd "${S}"
+ unpack glibc-infopages-${GLIBC_INFOPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ fi
+
+ if [[ -n ${PATCH_VER} ]] ; then
+ cd "${S}"
+ EPATCH_MULTI_MSG="Applying Gentoo Glibc Patchset ${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-${PATCH_VER} ..." \
+ EPATCH_EXCLUDE=${GLIBC_PATCH_EXCLUDE} \
+ EPATCH_SUFFIX="patch" \
+ ARCH=$(tc-arch) \
+ epatch "${WORKDIR}"/patches
+
+ # tag, glibc is it
+ [[ -e csu/Banner ]] && die "need new banner location"
+ echo "Gentoo patchset ${PATCH_VER}" > csu/Banner
+ fi
+
+ gnuconfig_update
+}
+
+toolchain-glibc_src_compile() {
+ echo
+ local v
+ for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CFLAGS ; do
+ einfo " $(printf '%15s' ${v}:) ${!v}"
+ done
+ echo
+
+ if want_linuxthreads ; then
+ glibc_do_configure linuxthreads
+ einfo "Building GLIBC with linuxthreads..."
+ make PARALLELMFLAGS="${MAKEOPTS}" || die "make for ${ABI} failed"
+ fi
+ if want_nptl ; then
+ # ... and then do the optional nptl build
+ unset LD_ASSUME_KERNEL
+ glibc_do_configure nptl
+ einfo "Building GLIBC with NPTL..."
+ make PARALLELMFLAGS="${MAKEOPTS}" || die "make for ${ABI} failed"
+ fi
+}
+
+toolchain-glibc_headers_compile() {
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
+ mkdir -p "${GBUILDDIR}"
+ cd "${GBUILDDIR}"
+
+ # Pick out the correct location for build headers
+ local myconf="--disable-sanity-checks --enable-hacker-mode"
+ myconf="${myconf}
+ --enable-add-ons=linuxthreads
+ --without-cvs
+ --enable-bind-now
+ --build=${CBUILD_OPT:-${CBUILD}}
+ --host=${CTARGET_OPT:-${CTARGET}}
+ --with-headers=$(alt_build_headers)
+ --prefix=/usr
+ ${EXTRA_ECONF}"
+
+ einfo "Configuring GLIBC headers with: ${myconf// /\n\t\t}"
+ CC=gcc \
+ CFLAGS="-O1 -pipe" \
+ "${S}"/configure ${myconf} || die "failed to configure glibc"
+}
+
+toolchain-glibc_src_test() {
+ # This is wrong, but glibc's tests fail bad when screwing
+ # around with sandbox, so lets just punt it
+ unset LD_PRELOAD
+
+ # do the linuxthreads build unless we're using nptlonly
+ if want_linuxthreads ; then
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-linuxthreads
+ einfo "Checking GLIBC with linuxthreads..."
+ make check || die "linuxthreads glibc did not pass make check"
+ fi
+ if want_nptl ; then
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
+ unset LD_ASSUME_KERNEL || :
+ einfo "Checking GLIBC with NPTL..."
+ make check || die "nptl glibc did not pass make check"
+ fi
+}
+
+toolchain-glibc_pkg_preinst() {
+ # PPC64+others may want to eventually be added to this logic if they
+ # decide to be multilib compatible and FHS compliant. note that this
+ # chunk of FHS compliance only applies to 64bit archs where 32bit
+ # compatibility is a major concern (not IA64, for example).
+
+ # amd64's 2005.0 is the first amd64 profile to not need this code.
+ # 2005.0 is setup properly, and this is executed as part of the
+ # 2004.3 -> 2005.0 upgrade script.
+ # It can be removed after 2004.3 has been purged from portage.
+ { use amd64 || use ppc64; } && [ "$(get_libdir)" == "lib64" ] && ! has_multilib_profile && fix_lib64_symlinks
+
+ # it appears that /lib/tls is sometimes not removed. See bug
+ # 69258 for more info.
+ if [[ -d ${ROOT}/$(alt_libdir)/tls ]] && ! { want_nptl && want_linuxthreads; }; then
+ addwrite "${ROOT}"/$(alt_libdir)/
+ ewarn "nptlonly or -nptl in USE, removing /${ROOT}$(alt_libdir)/tls..."
+ rm -r "${ROOT}"/$(alt_libdir)/tls || die
+ fi
+
+ # Shouldnt need to keep this updated
+ [[ -e ${ROOT}/etc/locale.gen ]] && rm -f "${D}"/etc/locale.gen
+}
+
+toolchain-glibc_src_install() {
+ # These should not be set, else the
+ # zoneinfo do not always get installed ...
+ unset LANGUAGE LANG LC_ALL
+
+ local GBUILDDIR
+ if want_linuxthreads ; then
+ GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-linuxthreads
+ else
+ GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-nptl
+ fi
+
+ local install_root=${D}
+ if is_crosscompile ; then
+ install_root="${install_root}/usr/${CTARGET}"
+ fi
+ if want_linuxthreads ; then
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-linuxthreads
+ einfo "Installing GLIBC ${ABI} with linuxthreads ..."
+ make PARALLELMFLAGS="${MAKEOPTS} -j1" \
+ install_root="${install_root}" \
+ install || die
+ else # nptlonly
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
+ einfo "Installing GLIBC ${ABI} with NPTL ..."
+ make PARALLELMFLAGS="${MAKEOPTS} -j1" \
+ install_root="${install_root}" \
+ install || die
+ fi
+
+ if is_crosscompile ; then
+ # punt all the junk not needed by a cross-compiler
+ cd "${D}"/usr/${CTARGET} || die
+ rm -rf ./{,usr/}{bin,etc,sbin,share} ./{,usr/}*/{gconv,misc}
+ fi
+
+ if want_linuxthreads && want_nptl ; then
+ einfo "Installing NPTL to $(alt_libdir)/tls/..."
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
+ dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
+
+ local l src_lib
+ for l in libc libm librt libpthread libthread_db ; do
+ # take care of shared lib first ...
+ l=${l}.so
+ if [[ -e ${l} ]] ; then
+ src_lib=${l}
+ else
+ src_lib=$(eval echo */${l})
+ fi
+ cp -a ${src_lib} "${D}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
+ fperms a+rx $(alt_libdir)/tls/${l}
+ dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
+
+ # then grab the linker script or the symlink ...
+ if [[ -L ${D}$(alt_usrlibdir)/${l} ]] ; then
+ dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
+ else
+ sed \
+ -e "s:/${l}:/tls/${l}:g" \
+ -e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
+ "${D}"$(alt_usrlibdir)/${l} > "${D}"$(alt_usrlibdir)/nptl/${l}
+ fi
+
+ # then grab the static lib ...
+ src_lib=${src_lib/%.so/.a}
+ [[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
+ cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
+ src_lib=${src_lib/%.a/_nonshared.a}
+ if [[ -e ${src_lib} ]] ; then
+ cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
+ fi
+ done
+
+ # use the nptl linker instead of the linuxthreads one as the linuxthreads
+ # one may lack TLS support and that can be really bad for business
+ cp -a elf/ld.so "${D}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
+ fi
+
+ # We'll take care of the cache ourselves
+ rm -f "${D}"/etc/ld.so.cache
+
+ # Some things want this, notably ash.
+ dosym libbsd-compat.a $(alt_usrlibdir)/libbsd.a
+
+ # Handle includes for different ABIs
+ prep_ml_includes $(alt_headers)
+
+ # When cross-compiling for a non-multilib setup, make sure we have
+ # lib and a proper symlink setup
+ if is_crosscompile && ! use multilib && ! has_multilib_profile && [[ $(get_libdir) != "lib" ]] ; then
+ cd "${D}"$(alt_libdir)/..
+ mv $(get_libdir) lib || die
+ ln -s lib $(get_libdir) || die
+ cd "${D}"$(alt_usrlibdir)/..
+ mv $(get_libdir) lib || die
+ ln -s lib $(get_libdir) || die
+ 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
+ dosym usr/include /usr/${CTARGET}/sys-include
+ return 0
+ fi
+
+ # 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
+ if has_multilib_profile ; then
+ case $(tc-arch) in
+ amd64)
+ [[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR amd64) /lib
+ dosym /$(get_abi_LIBDIR x86)/ld-linux.so.2 /lib/ld-linux.so.2
+ ;;
+ ppc64)
+ [[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR ppc64) /lib
+ dosym /$(get_abi_LIBDIR ppc)/ld.so.1 /lib/ld.so.1
+ ;;
+ esac
+ 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 > "${D}"/usr/share/i18n/SUPPORTED \
+ || die "generating /usr/share/i18n/SUPPORTED failed"
+ cd "${WORKDIR}"/extra/locale
+ dosbin locale-gen || die
+ doman *.[0-8]
+ insinto /etc
+ doins locale.gen || die
+
+ # 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 ${D}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
+ dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
+ fi
+ done
+
+ if ! has noinfo ${FEATURES} && [[ ${GLIBC_INFOPAGE_VERSION} != "none" ]] ; then
+ einfo "Installing info pages..."
+
+ make \
+ -C "${GBUILDDIR}" \
+ PARALLELMFLAGS="${MAKEOPTS} -j1" \
+ install_root="${install_root}" \
+ info -i || die
+ fi
+
+ if [[ ${GLIBC_MANPAGE_VERSION} != "none" ]] ; then
+ einfo "Installing man pages..."
+
+ # Install linuxthreads man pages even if nptl is enabled
+ cd "${WORKDIR}"/man
+ doman *.3thr
+ fi
+
+ # Install misc network config files
+ insinto /etc
+ doins "${WORKDIR}"/extra/etc/*.conf || die
+ doinitd "${WORKDIR}"/extra/etc/nscd || die
+
+ cd "${S}"
+ dodoc BUGS ChangeLog* CONFORMANCE FAQ INTERFACE NEWS NOTES PROJECTS README*
+
+ # Prevent overwriting of the /etc/localtime symlink. We'll handle the
+ # creation of the "factory" symlink in pkg_postinst().
+ rm -f "${D}"/etc/localtime
+
+ # simple test to make sure our new glibc isnt completely broken.
+ # for now, skip the multilib scenario. also make sure we don't
+ # test with statically built binaries since they will fail.
+ [[ ${CBUILD} != ${CHOST} ]] && return 0
+ [[ $(get_libdir) != "lib" ]] && return 0
+ for x in date env ls true uname ; do
+ x=$(type -p ${x})
+ [[ -z ${x} ]] && continue
+ striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null)
+ [[ -z ${striptest} ]] && continue
+ [[ ${striptest} == *"statically linked"* ]] && continue
+ "${D}"/$(get_libdir)/ld-*.so \
+ --library-path "${D}"/$(get_libdir) \
+ ${x} > /dev/null \
+ || die "simple run test (${x}) failed"
+ done
+}
+
+toolchain-glibc_headers_install() {
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
+ cd "${GBUILDDIR}"
+ make install_root="${D}/usr/${CTARGET}" install-headers || die "install-headers failed"
+ # Copy over headers that are not part of install-headers ... these
+ # are pretty much taken verbatim from crosstool, see it for more details
+ insinto $(alt_headers)/bits
+ doins misc/syscall-list.h bits/stdio_lim.h || die "doins include bits"
+ insinto $(alt_headers)/gnu
+ doins "${S}"/include/gnu/stubs.h || die "doins include gnu"
+ # 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 /usr/${CTARGET}/sys-include
+}
+
+toolchain-glibc_pkg_postinst() {
+ # Mixing nptlonly and -nptlonly glibc can prove dangerous if libpthread
+ # isn't removed in unmerge which happens sometimes. See bug #87671
+ if ! is_crosscompile && want_linuxthreads && [[ ${ROOT} == "/" ]] ; then
+ for libdir in $(get_all_libdirs) ; do
+ for f in "${ROOT}"/${libdir}/libpthread-2.* "${ROOT}"/${libdir}/libpthread-0.6* ; do
+ if [[ -f ${f} ]] ; then
+ rm -f ${f}
+ ldconfig
+ fi
+ done
+ done
+ fi
+
+ if ! tc-is-cross-compiler && [[ -x ${ROOT}/usr/sbin/iconvconfig ]] ; then
+ # Generate fastloading iconv module configuration file.
+ "${ROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
+ fi
+
+ if [[ ! -e ${ROOT}/lib/ld.so.1 ]] && use ppc64 && ! has_multilib_profile ; then
+ ## SHOULDN'T THIS BE lib64??
+ ln -s ld64.so.1 "${ROOT}"/lib/ld.so.1
+ fi
+
+ if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
+ # Reload init ...
+ /sbin/telinit U &> /dev/null
+
+ # if the host locales.gen contains no entries, we'll install everything
+ 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
+ local x jobs
+ for x in ${MAKEOPTS} ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done
+ locale-gen -j ${jobs:-1} --config "${locale_list}"
+ fi
+
+ echo
+ einfo "Gentoo's glibc no longer includes mdns."
+ einfo "If you want mdns, emerge the sys-auth/nss-mdns package."
+ echo
+
+ if want_nptl && want_linuxthreads ; then
+ einfo "The default behavior of glibc on your system is to use NPTL. If"
+ einfo "you want to use linuxthreads for a particular program, start it"
+ einfo "by executing 'LD_ASSUME_KERNEL=${LT_KERNEL_VERSION} <program> [<options>]'"
+ echo
+ fi
+}
+
+### SUPPORT FUNCTIONS ###
+# 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.
+# note: intentionally undocumented.
+alt_headers() {
+ if [[ -z ${ALT_HEADERS} ]] ; then
+ if is_crosscompile ; then
+ ALT_HEADERS="/usr/${CTARGET}/usr/include"
+ else
+ ALT_HEADERS="/usr/include"
+ fi
+ fi
+ echo "${ALT_HEADERS}"
+}
+alt_build_headers() {
+ if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
+ ALT_BUILD_HEADERS=$(alt_headers)
+ tc-is-cross-compiler && ALT_BUILD_HEADERS=${ROOT}$(alt_headers)
+ fi
+ echo "${ALT_BUILD_HEADERS}"
+}
+
+alt_libdir() {
+ if is_crosscompile ; then
+ echo /usr/${CTARGET}/$(get_libdir)
+ else
+ echo /$(get_libdir)
+ fi
+}
+
+alt_usrlibdir() {
+ if is_crosscompile ; then
+ echo /usr/${CTARGET}/usr/$(get_libdir)
+ else
+ echo /usr/$(get_libdir)
+ fi
+}
+
+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}
+ 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=*
+
+ unset CBUILD_OPT CTARGET_OPT
+ if has_multilib_profile ; then
+ CTARGET_OPT=$(get_abi_CTARGET)
+ [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
+ fi
+
+ case $(tc-arch) in
+ amd64)
+ # Punt this when amd64's 2004.3 is removed
+ CFLAGS_x86="-m32"
+ ;;
+ ppc)
+ append-flags "-freorder-blocks"
+ ;;
+ sparc)
+ # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
+ filter-flags "-fcall-used-g7"
+ append-flags "-fcall-used-g6"
+ filter-flags "-mvis"
+
+ if is_crosscompile || [[ ${PROFILE_ARCH} == "sparc64" ]] || { has_multilib_profile && ! tc-is-cross-compiler; } ; then
+ case ${ABI} in
+ sparc64)
+ filter-flags -Wa,-xarch -Wa,-A
+
+ if is-flag "-mcpu=ultrasparc3"; then
+ CTARGET_OPT="sparc64b-unknown-linux-gnu"
+ append-flags "-Wa,-xarch=v9b"
+ export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9b"
+ else
+ CTARGET_OPT="sparc64-unknown-linux-gnu"
+ append-flags "-Wa,-xarch=v9a"
+ export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9a"
+ fi
+ ;;
+ *)
+ if is-flag "-mcpu=ultrasparc3"; then
+ CTARGET_OPT="sparcv9b-unknown-linux-gnu"
+ else
+ CTARGET_OPT="sparcv9-unknown-linux-gnu"
+ fi
+ ;;
+ esac
+ else
+ if is-flag "-mcpu=ultrasparc3"; then
+ CTARGET_OPT="sparcv9b-unknown-linux-gnu"
+ elif { is_crosscompile && want_nptl; } || is-flag "-mcpu=ultrasparc2" || is-flag "-mcpu=ultrasparc"; then
+ CTARGET_OPT="sparcv9-unknown-linux-gnu"
+ fi
+ fi
+ ;;
+ esac
+
+ if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
+ CBUILD_OPT=${CTARGET_OPT}
+ fi
+
+ if $(tc-getCC ${CTARGET}) -v 2>&1 | grep -q 'gcc version 3.[0123]'; then
+ append-flags -finline-limit=2000
+ fi
+
+ # We dont want these flags for glibc
+ filter-ldflags -pie
+
+ # We cannot build glibc with Bdirect support
+ filter-flags -Wl,-Bdirect
+ filter-ldflags -Bdirect
+ filter-ldflags -Wl,-Bdirect
+
+ # Same for hashvals ...
+ filter-flags -Wl,-hashvals
+ filter-ldflags -hashvals
+ filter-ldflags -Wl,-hashvals
+
+ # Lock glibc at -O2 -- linuxthreads needs it and we want to be
+ # conservative here. -fno-strict-aliasing is to work around #155906
+ filter-flags -O?
+ append-flags -O2 -fno-strict-aliasing
+}
+
+check_kheader_version() {
+ local header="$(alt_build_headers)/linux/version.h"
+
+ [[ -z $1 ]] && return 1
+
+ if [ -f "${header}" ] ; then
+ local version="`grep 'LINUX_VERSION_CODE' ${header} | \
+ sed -e 's:^.*LINUX_VERSION_CODE[[:space:]]*::'`"
+
+ if [ "${version}" -ge "$1" ] ; then
+ return 0
+ fi
+ fi
+
+ return 1
+}
+
+check_nptl_support() {
+ local min_kernel_version=$(KV_to_int "${NPTL_KERNEL_VERSION}")
+
+ echo
+
+ 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 ! is_crosscompile && ! tc-is-cross-compiler ; then
+ # Building fails on an non-supporting kernel
+ ebegin "Checking kernel version (>=${NPTL_KERNEL_VERSION})"
+ if ! eend $([[ $(get_KV) -ge ${min_kernel_version} ]] ; echo $?) ; then
+ echo
+ eerror "You need a kernel of at least version ${NPTL_KERNEL_VERSION}"
+ eerror "for NPTL support!"
+ die "Kernel version too low!"
+ fi
+ fi
+
+ # Building fails with too low linux-headers
+ ebegin "Checking linux-headers version (>=${NPTL_KERNEL_VERSION})"
+ if ! eend $(check_kheader_version "${min_kernel_version}" ; echo $?) ; then
+ echo
+ eerror "You need linux-headers of at least version ${NPTL_KERNEL_VERSION}"
+ eerror "for NPTL support!"
+ die "linux-headers version too low!"
+ fi
+
+ echo
+}
+
+want_nptl() {
+ want_tls || return 1
+ use nptl || return 1
+
+ # Archs that can use NPTL
+ case $(tc-arch) in
+ alpha|amd64|ia64|mips|ppc|ppc64|s390|sh|x86)
+ return 0;
+ ;;
+ sparc)
+ # >= v9 is needed for nptl.
+ [[ "${PROFILE_ARCH}" == "sparc" ]] && return 1
+ return 0;
+ ;;
+ esac
+
+ return 1
+}
+
+want_linuxthreads() {
+ ! use nptlonly && return 0
+ want_nptl || return 0
+ return 1
+}
+
+want_tls() {
+ # Archs that can use TLS (Thread Local Storage)
+ case $(tc-arch) in
+ alpha|amd64|ia64|mips|ppc|ppc64|s390|sh)
+ return 0;
+ ;;
+ sparc)
+ # 2.3.6 should have tls support on sparc64
+ # when using newer binutils
+ case ${CTARGET/-*} in
+ sparc64*) return 1 ;;
+ *) return 0 ;;
+ esac
+ ;;
+ x86)
+ # requires i486 or better #106556
+ [[ ${CTARGET} == i[4567]86* ]] && return 0
+ ;;
+ esac
+
+ return 1
+}
+
+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}
+
+ echo 'extern __thread int i;' > "${T}"/test-__thread.c
+ $(tc-getCC ${CTARGET}) -c "${T}"/test-__thread.c -o "${T}"/test-__thread.o &> /dev/null
+ WANT__THREAD=$?
+ rm -f "${T}"/test-__thread.[co]
+
+ return ${WANT__THREAD}
+}
+
+glibc_do_configure() {
+ local myconf
+
+ # set addons
+ pushd "${S}" > /dev/null
+ local ADDONS=$(echo */configure | sed \
+ -e 's:/configure::g' \
+ -e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
+ -e 's: \+$::' \
+ -e 's! !,!g' \
+ -e 's!^!,!' \
+ -e '/^,\*$/d')
+ popd > /dev/null
+ use glibc-compat20 && [[ -d glibc-compat ]] && ADDONS="${ADDONS},glibc-compat"
+
+ use nls || myconf="${myconf} --disable-nls"
+ use erandom || myconf="${myconf} --disable-dev-erandom"
+
+ use glibc-omitfp && myconf="${myconf} --enable-omitfp"
+
+ [[ ${CTARGET//_/-} == *-softfloat-* ]] && myconf="${myconf} --without-fp"
+
+ if [ "$1" == "linuxthreads" ] ; then
+ if want_tls ; then
+ myconf="${myconf} --with-tls"
+
+ if want__thread && ! use glibc-compat20 ; then
+ myconf="${myconf} --with-__thread"
+ else
+ myconf="${myconf} --without-__thread"
+ fi
+ else
+ myconf="${myconf} --without-tls --without-__thread"
+ fi
+
+ myconf="${myconf} --enable-add-ons=linuxthreads${ADDONS}"
+ myconf="${myconf} --enable-kernel=${LT_KERNEL_VERSION}"
+ elif [ "$1" == "nptl" ] ; then
+ myconf="${myconf} --with-tls --with-__thread"
+ myconf="${myconf} --enable-add-ons=nptl${ADDONS}"
+ myconf="${myconf} --enable-kernel=${NPTL_KERNEL_VERSION}"
+ else
+ die "invalid pthread option"
+ fi
+
+ # Since SELinux support is only required for nscd, only enable it if:
+ # 1. USE selinux
+ # 2. ! USE build
+ # 3. only for the primary ABI on multilib systems
+ if use selinux && ! use build ; then
+ if use multilib || has_multilib_profile ; then
+ if is_final_abi ; then
+ myconf="${myconf} --with-selinux"
+ else
+ myconf="${myconf} --without-selinux"
+ fi
+ else
+ myconf="${myconf} --with-selinux"
+ fi
+ else
+ myconf="${myconf} --without-selinux"
+ fi
+
+ myconf="${myconf}
+ --without-cvs
+ --enable-bind-now
+ --build=${CBUILD_OPT:-${CBUILD}}
+ --host=${CTARGET_OPT:-${CTARGET}}
+ $(use_enable profile)
+ --without-gd
+ --with-headers=$(alt_build_headers)
+ --prefix=/usr
+ --libdir=/usr/$(get_libdir)
+ --mandir=/usr/share/man
+ --infodir=/usr/share/info
+ --libexecdir=/usr/$(get_libdir)/misc/glibc
+ ${EXTRA_ECONF}"
+
+ # 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_slibdir=/$(get_libdir)
+
+ has_version app-admin/eselect-compiler || export CC=$(tc-getCC ${CTARGET})
+
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-$1
+ mkdir -p "${GBUILDDIR}"
+ cd "${GBUILDDIR}"
+ einfo "Configuring GLIBC for $1 with: ${myconf// /\n\t\t}"
+ "${S}"/configure ${myconf} || die "failed to configure glibc"
+}
+
+fix_lib64_symlinks() {
+ # the original Gentoo/AMD64 devs decided that since 64bit is the native
+ # bitdepth for AMD64, lib should be used for 64bit libraries. however,
+ # this ignores the FHS and breaks multilib horribly... especially
+ # since it wont even work without a lib64 symlink anyways. *rolls eyes*
+ # see bug 59710 for more information.
+ # Travis Tilley <lv@gentoo.org> (08 Aug 2004)
+ if [ -L ${ROOT}/lib64 ] ; then
+ ewarn "removing /lib64 symlink and moving lib to lib64..."
+ ewarn "dont hit ctrl-c until this is done"
+ addwrite ${ROOT}/
+ rm ${ROOT}/lib64
+ # now that lib64 is gone, nothing will run without calling ld.so
+ # directly. luckily the window of brokenness is almost non-existant
+ use amd64 && /lib/ld-linux-x86-64.so.2 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ use ppc64 && /lib/ld64.so.1 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ # all better :)
+ ldconfig
+ ln -s lib64 ${ROOT}/lib
+ einfo "done! :-)"
+ einfo "fixed broken lib64/lib symlink in ${ROOT}"
+ fi
+ if [ -L ${ROOT}/usr/lib64 ] ; then
+ addwrite ${ROOT}/usr
+ rm ${ROOT}/usr/lib64
+ mv ${ROOT}/usr/lib ${ROOT}/usr/lib64
+ ln -s lib64 ${ROOT}/usr/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr"
+ fi
+ if [ -L ${ROOT}/usr/X11R6/lib64 ] ; then
+ addwrite ${ROOT}/usr/X11R6
+ rm ${ROOT}/usr/X11R6/lib64
+ mv ${ROOT}/usr/X11R6/lib ${ROOT}/usr/X11R6/lib64
+ ln -s lib64 ${ROOT}/usr/X11R6/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6"
+ fi
+}
+
+use_multilib() {
+ case ${CTARGET} in
+ sparc64*|mips64*|x86_64*|powerpc64*|s390x*)
+ has_multilib_profile || use multilib ;;
+ *) false ;;
+ esac
+}
+
+# Setup toolchain variables that would be defined in the profiles for these archs.
+setup_env() {
+ # These should not be set, else the zoneinfo do not always get installed ...
+ unset LANGUAGE LANG LC_ALL
+ # silly users
+ unset LD_RUN_PATH
+
+ if is_crosscompile || tc-is-cross-compiler ; then
+ multilib_env ${CTARGET}
+ if ! use multilib ; then
+ MULTILIB_ABIS=${DEFAULT_ABI}
+ else
+ MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
+ fi
+
+ # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
+ # and fall back on CFLAGS.
+ local VAR=CFLAGS_${CTARGET//[-.]/_}
+ CFLAGS=${!VAR-${CFLAGS}}
+ fi
+
+ setup_flags
+
+ export ABI=${ABI:-${DEFAULT_ABI:-default}}
+
+ if is_crosscompile || tc-is-cross-compiler ; then
+ 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)
+ export CFLAGS="${!VAR} ${CFLAGS}"
+ fi
+}
+
+### /ECLASS PUNTAGE ###
+
+if is_crosscompile ; then
+ SLOT="${CTARGET}-2.2"
+else
+ SLOT="2.2"
+fi
+
+# we'll handle stripping ourself #46186
+RESTRICT="strip"
+EMULTILIB_PKG="true"
+
+# We need a new-enough binutils for as-needed
+DEPEND="!ia64? ( >=sys-devel/gcc-3.4 )
+ nptl? ( >=sys-kernel/linux-headers-${NPTL_KERNEL_VERSION} )
+ >=sys-devel/binutils-2.15.94
+ >=sys-devel/gcc-config-1.3.12
+ >=app-misc/pax-utils-0.1.10
+ virtual/os-headers
+ nls? ( sys-devel/gettext )
+ selinux? ( !build? ( sys-libs/libselinux ) )"
+RDEPEND="nls? ( sys-devel/gettext )
+ selinux? ( !build? ( sys-libs/libselinux ) )"
+
+if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ DEPEND="${DEPEND} !crosscompile_opts_headers-only? ( ${CATEGORY}/gcc )"
+
+ if [[ ${CATEGORY} == *-linux* ]] ; then
+ if [[ ${CATEGORY} == cross-mips* ]] ; then
+ DEPEND="${DEPEND} >=${CATEGORY}/mips-headers-2.6.10"
+ else
+ DEPEND="${DEPEND} ${CATEGORY}/linux-headers"
+ fi
+ fi
+else
+ DEPEND="${DEPEND} sys-libs/timezone-data"
+ RDEPEND="${RDEPEND} sys-libs/timezone-data"
+fi
+
+pkg_setup() {
+ # prevent native builds from downgrading ... maybe update to allow people
+ # to change between diff -r versions ? (2.3.6-r4 -> 2.3.6-r2)
+ if ! is_crosscompile && ! tc-is-cross-compiler ; then
+ if has_version '>'${CATEGORY}/${PF} ; 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
+ fi
+
+ if use nptlonly && ! use nptl ; then
+ eerror "If you want nptlonly, add nptl to your USE too ;p"
+ die "nptlonly without nptl"
+ 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, which is probably not what you want."
+ fi
+
+ if ! type -p scanelf > /dev/null ; then
+ eerror "You do not have pax-utils installed."
+ die "install pax-utils"
+ fi
+
+ # give some sort of warning about the nptl logic changes...
+ if want_nptl && want_linuxthreads ; then
+ ewarn "Warning! Gentoo's GLIBC with NPTL enabled now behaves like the"
+ ewarn "glibc from almost every other distribution out there. This means"
+ ewarn "that glibc is compiled -twice-, once with linuxthreads and once"
+ ewarn "with nptl. The NPTL version is installed to lib/tls and is still"
+ ewarn "used by default. If you do not need nor want the linuxthreads"
+ ewarn "fallback, you can disable this behavior by adding nptlonly to"
+ ewarn "USE to save yourself some compile time."
+
+ ebeep
+ epause 5
+ fi
+}
+
+src_unpack() {
+ setup_env
+
+ # Do not enable -Bdirect support for now.
+ GLIBC_PATCH_EXCLUDE="${GLIBC_PATCH_EXCLUDE} 2020_all_2.3.6-hashvals.patch"
+ GLIBC_PATCH_EXCLUDE="${GLIBC_PATCH_EXCLUDE} 2030_all_2.3.6-bdirect.patch"
+
+ toolchain-glibc_src_unpack
+
+ # XXX: do not package ssp up into tarballs, leave it in FILESDIR
+ cd "${S}"
+ cp "${FILESDIR}"/2.3.5/ssp.c sysdeps/unix/sysv/linux/ || die "could not find ssp.c"
+ rm -f "${WORKDIR}"/patches/2*
+ epatch "${FILESDIR}"/2.3.6/glibc-2.3.6-propolice-guard-functions.patch
+ epatch "${FILESDIR}"/2.3.5/glibc-2.3.5-frandom-detect.patch
+
+ # Glibc is stupid sometimes, and doesn't realize that with a
+ # static C-Only gcc, -lgcc_eh doesn't exist.
+ # http://sources.redhat.com/ml/libc-alpha/2003-09/msg00100.html
+ # http://sourceware.org/ml/libc-alpha/2005-02/msg00042.html
+ echo 'int main(){}' > "${T}"/gcc_eh_test.c
+ if ! $(tc-getCC ${CTARGET}) "${T}"/gcc_eh_test.c -lgcc_eh 2>/dev/null ; then
+ sed -i -e 's:-lgcc_eh::' Makeconfig || die "sed gcc_eh"
+ fi
+
+ # Some configure checks fail on the first emerge through because they
+ # try to link. This doesn't work well if we don't have a libc yet.
+ # http://sourceware.org/ml/libc-alpha/2005-02/msg00042.html
+ if is_crosscompile && use build; then
+ rm "${S}"/sysdeps/sparc/sparc64/elf/configure{,.in}
+ rm "${S}"/nptl/sysdeps/pthread/configure{,.in}
+ fi
+
+ cd "${WORKDIR}"
+ find . -type f '(' -size 0 -o -name "*.orig" ')' -exec rm -f {} \;
+ find . -name configure -exec touch {} \;
+
+ # Fix permissions on some of the scripts
+ chmod u+x "${S}"/scripts/*.sh
+}
+
+src_compile() {
+ setup_env
+
+ if [[ -z ${OABI} ]] ; then
+ local abilist=""
+ if has_multilib_profile ; then
+ abilist=$(get_install_abis)
+ einfo "Building multilib glibc for ABIs: ${abilist}"
+ elif is_crosscompile || tc-is-cross-compiler ; then
+ abilist=${DEFAULT_ABI}
+ fi
+ if [[ -n ${abilist} ]] ; then
+ OABI=${ABI}
+ for ABI in ${abilist} ; do
+ export ABI
+ src_compile
+ done
+ ABI=${OABI}
+ unset OABI
+ return 0
+ fi
+ fi
+
+ if just_headers ; then
+ toolchain-glibc_headers_compile
+ else
+ toolchain-glibc_src_compile
+ fi
+}
+
+src_test() {
+ setup_env
+
+ if [[ -z ${OABI} ]] && has_multilib_profile ; then
+ OABI=${ABI}
+ einfo "Testing multilib glibc for ABIs: $(get_install_abis)"
+ for ABI in $(get_install_abis) ; do
+ export ABI
+ einfo " Testing ${ABI} glibc"
+ src_test
+ done
+ ABI=${OABI}
+ unset OABI
+ return 0
+ fi
+
+ toolchain-glibc_src_test
+}
+
+src_strip() {
+ # Now, strip everything but the thread libs #46186, as well as the dynamic
+ # linker, else we cannot set breakpoints in shared libraries due to bugs in
+ # gdb. Also want to grab stuff in tls subdir. whee.
+#when new portage supports this ...
+# env \
+# -uRESTRICT \
+# CHOST=${CTARGET} \
+# STRIP_MASK="/*/{,tls/}{ld-,lib{pthread,thread_db}}*" \
+# prepallstrip
+ pushd "${D}" > /dev/null
+
+ if ! is_crosscompile ; then
+ mkdir -p "${T}"/strip-backup
+ for x in $(find "${D}" -maxdepth 3 \
+ '(' -name 'ld-*' -o -name 'libpthread*' -o -name 'libthread_db*' ')' \
+ -a '(' '!' -name '*.a' ')' -type f -printf '%P ')
+ do
+ mkdir -p "${T}/strip-backup/${x%/*}"
+ cp -a -- "${D}/${x}" "${T}/strip-backup/${x}" || die "backing up ${x}"
+ done
+ fi
+ env -uRESTRICT CHOST=${CTARGET} prepallstrip
+ if ! is_crosscompile ; then
+ cp -a -- "${T}"/strip-backup/* "${D}"/ || die "restoring non-stripped libs"
+ fi
+
+ popd > /dev/null
+}
+
+src_install() {
+ setup_env
+
+ if [[ -z ${OABI} ]] ; then
+ local abilist=""
+ if has_multilib_profile ; then
+ abilist=$(get_install_abis)
+ einfo "Installing multilib glibc for ABIs: ${abilist}"
+ elif is_crosscompile || tc-is-cross-compiler ; then
+ abilist=${DEFAULT_ABI}
+ fi
+ if [[ -n ${abilist} ]] ; then
+ OABI=${ABI}
+ for ABI in ${abilist} ; do
+ export ABI
+ src_install
+ done
+ ABI=${OABI}
+ unset OABI
+ src_strip
+ return 0
+ fi
+ fi
+
+ if just_headers ; then
+ toolchain-glibc_headers_install
+ else
+ toolchain-glibc_src_install
+ fi
+ [[ -z ${OABI} ]] && src_strip
+}
+
+pkg_preinst() {
+ toolchain-glibc_pkg_preinst
+}
+
+pkg_postinst() {
+ toolchain-glibc_pkg_postinst
+}
diff --git a/sys-libs/glibc/glibc-2.4-r4.ebuild b/sys-libs/glibc/glibc-2.4-r4.ebuild
new file mode 100644
index 0000000..5595a71
--- /dev/null
+++ b/sys-libs/glibc/glibc-2.4-r4.ebuild
@@ -0,0 +1,1267 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/Attic/glibc-2.4-r4.ebuild,v 1.24 2009/12/14 14:44:09 vapier dead $
+
+# 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/
+
+KEYWORDS="-* amd64 ~ia64 ~mips ppc ppc64 s390 sh ~sparc x86"
+
+BRANCH_UPDATE=""
+
+# Generated man pages
+GLIBC_MANPAGE_VERSION="none"
+
+# Generated stuff in manual subdir
+GLIBC_INFOPAGE_VERSION="none"
+
+# Gentoo patchset
+PATCH_VER="1.19"
+
+# PPC cpu addon
+# http://penguinppc.org/dev/glibc/glibc-powerpc-cpu-addon.html
+PPC_CPU_ADDON_VER="0.01"
+PPC_CPU_ADDON_TARBALL="glibc-powerpc-cpu-addon-v${PPC_CPU_ADDON_VER}.tgz"
+PPC_CPU_ADDON_URI="http://penguinppc.org/dev/glibc/${PPC_CPU_ADDON_TARBALL}"
+
+# LinuxThreads addon
+LT_VER="20060605"
+LT_TARBALL="glibc-linuxthreads-${LT_VER}.tar.bz2"
+LT_URI="ftp://sources.redhat.com/pub/glibc/snapshots/${LT_TARBALL} mirror://gentoo/${LT_TARBALL}"
+
+GENTOO_TOOLCHAIN_BASE_URI="mirror://gentoo"
+GENTOO_TOOLCHAIN_DEV_URI="http://dev.gentoo.org/~azarah/glibc/XXX http://dev.gentoo.org/~vapier/dist/XXX"
+
+### PUNT OUT TO ECLASS?? ###
+inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib
+
+DESCRIPTION="GNU libc6 (also called glibc2) C library"
+HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
+LICENSE="LGPL-2"
+
+# note that nptl/nptlonly/glibc-compat20 are for upgrade checks only.
+# we dont generally support these things in this version.
+IUSE="nls build nptl nptlonly hardened multilib selinux glibc-omitfp profile glibc-compat20"
+
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ PROVIDE="virtual/libc"
+fi
+
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+just_headers() {
+ is_crosscompile && use crosscompile_opts_headers-only
+}
+
+GLIBC_RELEASE_VER=$(get_version_component_range 1-3)
+
+# Don't set this to :-, - allows BRANCH_UPDATE=""
+BRANCH_UPDATE=${BRANCH_UPDATE-$(get_version_component_range 4)}
+
+# (Recent snapshots fails with 2.6.5 and earlier with NPTL)
+NPTL_KERNEL_VERSION=${NPTL_KERNEL_VERSION:-"2.6.9"}
+LT_KERNEL_VERSION=${LT_KERNEL_VERSION:-"2.4.1"}
+
+### SRC_URI ###
+
+# This function handles the basics of setting the SRC_URI for a glibc ebuild.
+# To use, set SRC_URI with:
+#
+# SRC_URI="$(get_glibc_src_uri)"
+#
+# Other than the variables normally set by portage, this function's behavior
+# can be altered by setting the following:
+#
+# GENTOO_TOOLCHAIN_BASE_URI
+# This sets the base URI for all gentoo-specific patch files. Note
+# that this variable is only important for a brief period of time,
+# before your source files get picked up by mirrors. However, it is
+# still highly suggested that you keep files in this location
+# available.
+#
+# BRANCH_UPDATE
+# If set, this variable signals that we should be using the main
+# release tarball (determined by ebuild version) and applying a
+# CVS branch update patch against it. The location of this branch
+# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
+# Just like with SNAPSHOT, this variable is ignored if the ebuild
+# has a _pre suffix.
+#
+# PATCH_VER
+# PATCH_GLIBC_VER
+# This should be set to the version of the gentoo patch tarball.
+# The resulting filename of this tarball will be:
+# glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+#
+# GLIBC_MANPAGE_VERSION
+# GLIBC_INFOPAGE_VERSION
+# The version of glibc for which we will download pages. This will
+# default to ${GLIBC_RELEASE_VER}, but we may not want to pre-generate man pages
+# for prerelease test ebuilds for example. This allows you to
+# continue using pre-generated manpages from the last stable release.
+# If set to "none", this will prevent the downloading of manpages,
+# which is useful for individual library targets.
+#
+get_glibc_src_uri() {
+ GENTOO_TOOLCHAIN_BASE_URI=${GENTOO_TOOLCHAIN_BASE_URI:-"mirror://gentoo"}
+
+# GLIBC_SRC_URI="http://ftp.gnu.org/gnu/glibc/glibc-${GLIBC_RELEASE_VER}.tar.bz2
+# http://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-${GLIBC_RELEASE_VER}.tar.bz2
+# http://ftp.gnu.org/gnu/glibc/glibc-libidn-${GLIBC_RELEASE_VER}.tar.bz2
+ GLIBC_SRC_URI="mirror://gnu/glibc/glibc-${GLIBC_RELEASE_VER}.tar.bz2
+ mirror://gnu/glibc/glibc-ports-${GLIBC_RELEASE_VER}.tar.bz2
+ mirror://gnu/glibc/glibc-libidn-${GLIBC_RELEASE_VER}.tar.bz2"
+
+ if [[ -n ${BRANCH_UPDATE} ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-${GLIBC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-${GLIBC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2}"
+ fi
+
+ if [[ -n ${PATCH_VER} ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2}"
+ fi
+
+ if [[ ${GLIBC_MANPAGE_VERSION} != "none" ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-manpages-${GLIBC_MANPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-manpages-${GLIBC_MANPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2}"
+ fi
+
+ if [[ ${GLIBC_INFOPAGE_VERSION} != "none" ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-infopages-${GLIBC_INFOPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-infopages-${GLIBC_INFOPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2}"
+ fi
+
+ [[ -n ${LT_VER} ]] && GLIBC_SRC_URI="${GLIBC_SRC_URI} ${LT_URI}"
+
+ GLIBC_SRC_URI="${GLIBC_SRC_URI} ${PPC_CPU_ADDON_URI}"
+
+ echo "${GLIBC_SRC_URI}"
+}
+
+SRC_URI=$(get_glibc_src_uri)
+S=${WORKDIR}/glibc-${GLIBC_RELEASE_VER}
+
+### EXPORTED FUNCTIONS ###
+unpack_addon() {
+ local addon=$1 ver=${2:-${GLIBC_RELEASE_VER}}
+ unpack glibc-${addon}-${ver}.tar.bz2
+ mv glibc-${addon}-${ver} ${addon} || die
+}
+toolchain-glibc_src_unpack() {
+ # Check NPTL support _before_ we unpack things to save some time
+ want_nptl && check_nptl_support
+
+ unpack glibc-${GLIBC_RELEASE_VER}.tar.bz2
+
+ cd "${S}"
+ if [[ -n ${LT_VER} ]] ; then
+ unpack ${LT_TARBALL}
+ mv glibc-linuxthreads-${LT_VER}/* . || die
+ fi
+ unpack_addon libidn
+ unpack_addon ports
+
+ if [[ -n ${PPC_CPU_ADDON_TARBALL} ]] ; then
+ cd "${S}"
+ unpack ${PPC_CPU_ADDON_TARBALL}
+ fi
+
+ if [[ -n ${PATCH_VER} ]] ; then
+ cd "${WORKDIR}"
+ unpack glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+ # pull out all the addons
+ local d
+ for d in extra/*/configure ; do
+ mv "${d%/configure}" "${S}" || die "moving ${d}"
+ done
+ fi
+
+ # XXX: We should do the branchupdate, before extracting the manpages and
+ # infopages else it does not help much (mtimes change if there is a change
+ # to them with branchupdate)
+ if [[ -n ${BRANCH_UPDATE} ]] ; then
+ cd "${S}"
+ epatch "${DISTDIR}"/glibc-${GLIBC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+
+ # Snapshot date patch
+ einfo "Patching version to display snapshot date ..."
+ sed -i -e "s:\(#define RELEASE\).*:\1 \"${BRANCH_UPDATE}\":" version.h
+ fi
+
+ if [[ ${GLIBC_MANPAGE_VERSION} != "none" ]] ; then
+ cd "${WORKDIR}"
+ unpack glibc-manpages-${GLIBC_MANPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ fi
+
+ if [[ ${GLIBC_INFOPAGE_VERSION} != "none" ]] ; then
+ cd "${S}"
+ unpack glibc-infopages-${GLIBC_INFOPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ fi
+
+ if [[ -n ${PATCH_VER} ]] ; then
+ cd "${S}"
+ EPATCH_MULTI_MSG="Applying Gentoo Glibc Patchset ${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-${PATCH_VER} ..." \
+ EPATCH_EXCLUDE=${GLIBC_PATCH_EXCLUDE} \
+ EPATCH_SUFFIX="patch" \
+ ARCH=$(tc-arch) \
+ epatch "${WORKDIR}"/patches
+
+ # tag, glibc is it
+ [[ -e csu/Banner ]] && die "need new banner location"
+ echo "Gentoo patchset ${PATCH_VER}" > csu/Banner
+ fi
+
+ gnuconfig_update
+}
+
+toolchain-glibc_src_compile() {
+ echo
+ local v
+ for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CFLAGS ; do
+ einfo " $(printf '%15s' ${v}:) ${!v}"
+ done
+ echo
+
+ if want_linuxthreads ; then
+ glibc_do_configure linuxthreads
+ einfo "Building GLIBC with linuxthreads..."
+ make PARALLELMFLAGS="${MAKEOPTS}" || die "make for ${ABI} failed"
+ fi
+ if want_nptl ; then
+ # ... and then do the optional nptl build
+ unset LD_ASSUME_KERNEL
+ glibc_do_configure nptl
+ einfo "Building GLIBC with NPTL..."
+ make PARALLELMFLAGS="${MAKEOPTS}" || die "make for ${ABI} failed"
+ fi
+}
+
+toolchain-glibc_headers_compile() {
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
+ mkdir -p "${GBUILDDIR}"
+ cd "${GBUILDDIR}"
+
+ # Pick out the correct location for build headers
+ local myconf="--disable-sanity-checks --enable-hacker-mode"
+ myconf="${myconf}
+ --enable-add-ons=nptl,ports
+ --without-cvs
+ --enable-bind-now
+ --build=${CBUILD_OPT:-${CBUILD}}
+ --host=${CTARGET_OPT:-${CTARGET}}
+ --with-headers=$(alt_build_headers)
+ --prefix=/usr
+ ${EXTRA_ECONF}"
+
+ einfo "Configuring GLIBC headers with: ${myconf// /\n\t\t}"
+ CC=gcc \
+ CFLAGS="-O1 -pipe" \
+ "${S}"/configure ${myconf} || die "failed to configure glibc"
+}
+
+toolchain-glibc_src_test() {
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-$1 || die "cd build-${ABI}-${CTARGET}-$1"
+ unset LD_ASSUME_KERNEL
+ make check || die "make check failed for ${ABI}-${CTARGET}-$1"
+}
+
+toolchain-glibc_pkg_preinst() {
+ # PPC64+others may want to eventually be added to this logic if they
+ # decide to be multilib compatible and FHS compliant. note that this
+ # chunk of FHS compliance only applies to 64bit archs where 32bit
+ # compatibility is a major concern (not IA64, for example).
+
+ # amd64's 2005.0 is the first amd64 profile to not need this code.
+ # 2005.0 is setup properly, and this is executed as part of the
+ # 2004.3 -> 2005.0 upgrade script.
+ # It can be removed after 2004.3 has been purged from portage.
+ { use amd64 || use ppc64; } && [ "$(get_libdir)" == "lib64" ] && ! has_multilib_profile && fix_lib64_symlinks
+
+ # it appears that /lib/tls is sometimes not removed. See bug
+ # 69258 for more info.
+ if [[ -d ${ROOT}/$(alt_libdir)/tls ]] && ! { want_nptl && want_linuxthreads; }; then
+ addwrite "${ROOT}"/$(alt_libdir)/
+ ewarn "nptlonly or -nptl in USE, removing /${ROOT}$(alt_libdir)/tls..."
+ rm -r "${ROOT}"/$(alt_libdir)/tls || die
+ fi
+
+ # Shouldnt need to keep this updated
+ [[ -e ${ROOT}/etc/locale.gen ]] && rm -f "${D}"/etc/locale.gen
+}
+
+toolchain-glibc_src_install() {
+ # These should not be set, else the
+ # zoneinfo do not always get installed ...
+ unset LANGUAGE LANG LC_ALL
+
+ local GBUILDDIR
+ if want_linuxthreads ; then
+ GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-linuxthreads
+ else
+ GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-nptl
+ fi
+
+ local install_root=${D}
+ if is_crosscompile ; then
+ install_root="${install_root}/usr/${CTARGET}"
+ fi
+ if want_linuxthreads ; then
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-linuxthreads
+ einfo "Installing GLIBC ${ABI} with linuxthreads ..."
+ make PARALLELMFLAGS="${MAKEOPTS} -j1" \
+ install_root="${install_root}" \
+ install || die
+ else # nptlonly
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
+ einfo "Installing GLIBC ${ABI} with NPTL ..."
+ make PARALLELMFLAGS="${MAKEOPTS} -j1" \
+ install_root="${install_root}" \
+ install || die
+ fi
+
+ if is_crosscompile ; then
+ # punt all the junk not needed by a cross-compiler
+ cd "${D}"/usr/${CTARGET} || die
+ rm -rf ./{,usr/}{bin,etc,sbin,share} ./{,usr/}*/{gconv,misc}
+ fi
+
+ if want_linuxthreads && want_nptl ; then
+ einfo "Installing NPTL to $(alt_libdir)/tls/..."
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
+ dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
+
+ local l src_lib
+ for l in libc libm librt libpthread libthread_db ; do
+ # take care of shared lib first ...
+ l=${l}.so
+ if [[ -e ${l} ]] ; then
+ src_lib=${l}
+ else
+ src_lib=$(eval echo */${l})
+ fi
+ cp -a ${src_lib} "${D}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
+ fperms a+rx $(alt_libdir)/tls/${l}
+ dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
+
+ # then grab the linker script or the symlink ...
+ if [[ -L ${D}$(alt_usrlibdir)/${l} ]] ; then
+ dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
+ else
+ sed \
+ -e "s:/${l}:/tls/${l}:g" \
+ -e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
+ "${D}"$(alt_usrlibdir)/${l} > "${D}"$(alt_usrlibdir)/nptl/${l}
+ fi
+
+ # then grab the static lib ...
+ src_lib=${src_lib/%.so/.a}
+ [[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
+ cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
+ src_lib=${src_lib/%.a/_nonshared.a}
+ if [[ -e ${src_lib} ]] ; then
+ cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
+ fi
+ done
+
+ # use the nptl linker instead of the linuxthreads one as the linuxthreads
+ # one may lack TLS support and that can be really bad for business
+ cp -a elf/ld.so "${D}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
+ fi
+
+ # We'll take care of the cache ourselves
+ rm -f "${D}"/etc/ld.so.cache
+
+ # Some things want this, notably ash.
+ dosym libbsd-compat.a $(alt_usrlibdir)/libbsd.a
+
+ # Handle includes for different ABIs
+ prep_ml_includes $(alt_headers)
+
+ # When cross-compiling for a non-multilib setup, make sure we have
+ # lib and a proper symlink setup
+ if is_crosscompile && ! use multilib && ! has_multilib_profile && [[ $(get_libdir) != "lib" ]] ; then
+ cd "${D}"$(alt_libdir)/..
+ mv $(get_libdir) lib || die
+ ln -s lib $(get_libdir) || die
+ cd "${D}"$(alt_usrlibdir)/..
+ mv $(get_libdir) lib || die
+ ln -s lib $(get_libdir) || die
+ 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
+ dosym usr/include /usr/${CTARGET}/sys-include
+ return 0
+ fi
+
+ # 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
+ if has_multilib_profile ; then
+ case $(tc-arch) in
+ amd64)
+ [[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR amd64) /lib
+ dosym /$(get_abi_LIBDIR x86)/ld-linux.so.2 /lib/ld-linux.so.2
+ ;;
+ ppc64)
+ [[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR ppc64) /lib
+ dosym /$(get_abi_LIBDIR ppc)/ld.so.1 /lib/ld.so.1
+ ;;
+ esac
+ 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 > "${D}"/usr/share/i18n/SUPPORTED \
+ || die "generating /usr/share/i18n/SUPPORTED failed"
+ cd "${WORKDIR}"/extra/locale
+ dosbin locale-gen || die
+ doman *.[0-8]
+ insinto /etc
+ doins locale.gen || die
+
+ # 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 ${D}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
+ dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
+ fi
+ done
+
+ if ! has noinfo ${FEATURES} && [[ ${GLIBC_INFOPAGE_VERSION} != "none" ]] ; then
+ einfo "Installing info pages..."
+
+ make \
+ -C "${GBUILDDIR}" \
+ PARALLELMFLAGS="${MAKEOPTS} -j1" \
+ install_root="${install_root}" \
+ info -i || die
+ fi
+
+ if [[ ${GLIBC_MANPAGE_VERSION} != "none" ]] ; then
+ einfo "Installing man pages..."
+
+ # Install linuxthreads man pages even if nptl is enabled
+ cd "${WORKDIR}"/man
+ doman *.3thr
+ fi
+
+ # Install misc network config files
+ insinto /etc
+ doins "${WORKDIR}"/extra/etc/*.conf || die
+ doinitd "${WORKDIR}"/extra/etc/nscd || die
+
+ cd "${S}"
+ dodoc BUGS ChangeLog* CONFORMANCE FAQ INTERFACE NEWS NOTES PROJECTS README*
+
+ # Prevent overwriting of the /etc/localtime symlink. We'll handle the
+ # creation of the "factory" symlink in pkg_postinst().
+ rm -f "${D}"/etc/localtime
+
+ # simple test to make sure our new glibc isnt completely broken.
+ # for now, skip the multilib scenario. also make sure we don't
+ # test with statically built binaries since they will fail.
+ [[ ${CBUILD} != ${CHOST} ]] && return 0
+ [[ $(get_libdir) != "lib" ]] && return 0
+ for x in date env ls true uname ; do
+ x=$(type -p ${x})
+ [[ -z ${x} ]] && continue
+ striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null)
+ [[ -z ${striptest} ]] && continue
+ [[ ${striptest} == *"statically linked"* ]] && continue
+ "${D}"/$(get_libdir)/ld-*.so \
+ --library-path "${D}"/$(get_libdir) \
+ ${x} > /dev/null \
+ || die "simple run test (${x}) failed"
+ done
+}
+
+toolchain-glibc_headers_install() {
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
+ cd "${GBUILDDIR}"
+ make install_root="${D}/usr/${CTARGET}" install-headers || die "install-headers failed"
+ # Copy over headers that are not part of install-headers ... these
+ # are pretty much taken verbatim from crosstool, see it for more details
+ insinto $(alt_headers)/bits
+ doins misc/syscall-list.h bits/stdio_lim.h || die "doins include bits"
+ insinto $(alt_headers)/gnu
+ doins "${S}"/include/gnu/stubs.h || die "doins include gnu"
+ # 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 /usr/${CTARGET}/sys-include
+}
+
+toolchain-glibc_pkg_postinst() {
+ # Mixing nptlonly and -nptlonly glibc can prove dangerous if libpthread
+ # isn't removed in unmerge which happens sometimes. See bug #87671
+ if ! is_crosscompile && want_linuxthreads && [[ ${ROOT} == "/" ]] ; then
+ for libdir in $(get_all_libdirs) ; do
+ for f in "${ROOT}"/${libdir}/libpthread-2.* "${ROOT}"/${libdir}/libpthread-0.6* ; do
+ if [[ -f ${f} ]] ; then
+ rm -f ${f}
+ ldconfig
+ fi
+ done
+ done
+ fi
+
+ if ! tc-is-cross-compiler && [[ -x ${ROOT}/usr/sbin/iconvconfig ]] ; then
+ # Generate fastloading iconv module configuration file.
+ "${ROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
+ fi
+
+ if [[ ! -e ${ROOT}/lib/ld.so.1 ]] && use ppc64 && ! has_multilib_profile ; then
+ ## SHOULDN'T THIS BE lib64??
+ ln -s ld64.so.1 "${ROOT}"/lib/ld.so.1
+ fi
+
+ if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
+ # Reload init ...
+ /sbin/telinit U &> /dev/null
+
+ # if the host locales.gen contains no entries, we'll install everything
+ 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
+ local x jobs
+ for x in ${MAKEOPTS} ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done
+ locale-gen -j ${jobs:-1} --config "${locale_list}"
+ fi
+
+ echo
+ einfo "Gentoo's glibc no longer includes mdns."
+ einfo "If you want mdns, emerge the sys-auth/nss-mdns package."
+ echo
+
+ if want_nptl && want_linuxthreads ; then
+ einfo "The default behavior of glibc on your system is to use NPTL. If"
+ einfo "you want to use linuxthreads for a particular program, start it"
+ einfo "by executing 'LD_ASSUME_KERNEL=${LT_KERNEL_VERSION} <program> [<options>]'"
+ echo
+ fi
+}
+
+### SUPPORT FUNCTIONS ###
+# 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.
+# note: intentionally undocumented.
+alt_headers() {
+ if [[ -z ${ALT_HEADERS} ]] ; then
+ if is_crosscompile ; then
+ ALT_HEADERS="/usr/${CTARGET}/usr/include"
+ else
+ ALT_HEADERS="/usr/include"
+ fi
+ fi
+ echo "${ALT_HEADERS}"
+}
+alt_build_headers() {
+ if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
+ ALT_BUILD_HEADERS=$(alt_headers)
+ tc-is-cross-compiler && ALT_BUILD_HEADERS=${ROOT}$(alt_headers)
+ fi
+ echo "${ALT_BUILD_HEADERS}"
+}
+
+alt_libdir() {
+ if is_crosscompile ; then
+ echo /usr/${CTARGET}/$(get_libdir)
+ else
+ echo /$(get_libdir)
+ fi
+}
+
+alt_usrlibdir() {
+ if is_crosscompile ; then
+ echo /usr/${CTARGET}/usr/$(get_libdir)
+ else
+ echo /usr/$(get_libdir)
+ fi
+}
+
+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}
+ 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=*
+
+ unset CBUILD_OPT CTARGET_OPT
+ if has_multilib_profile ; then
+ CTARGET_OPT=$(get_abi_CTARGET)
+ [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
+ fi
+
+ case $(tc-arch) in
+ amd64)
+ # Punt this when amd64's 2004.3 is removed
+ CFLAGS_x86="-m32"
+ ;;
+ ppc)
+ append-flags "-freorder-blocks"
+ ;;
+ sparc)
+ # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
+ filter-flags "-fcall-used-g7"
+ append-flags "-fcall-used-g6"
+ filter-flags "-mvis"
+
+ if is_crosscompile || [[ ${PROFILE_ARCH} == "sparc64" ]] || { has_multilib_profile && ! tc-is-cross-compiler; } ; then
+ case ${ABI} in
+ sparc64)
+ filter-flags -Wa,-xarch -Wa,-A
+
+ if is-flag "-mcpu=ultrasparc3"; then
+ CTARGET_OPT="sparc64b-unknown-linux-gnu"
+ append-flags "-Wa,-xarch=v9b"
+ export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9b"
+ else
+ CTARGET_OPT="sparc64-unknown-linux-gnu"
+ append-flags "-Wa,-xarch=v9a"
+ export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9a"
+ fi
+ ;;
+ *)
+ if is-flag "-mcpu=ultrasparc3"; then
+ CTARGET_OPT="sparcv9b-unknown-linux-gnu"
+ else
+ CTARGET_OPT="sparcv9-unknown-linux-gnu"
+ fi
+ ;;
+ esac
+ else
+ if is-flag "-mcpu=ultrasparc3"; then
+ CTARGET_OPT="sparcv9b-unknown-linux-gnu"
+ elif { is_crosscompile && want_nptl; } || is-flag "-mcpu=ultrasparc2" || is-flag "-mcpu=ultrasparc"; then
+ CTARGET_OPT="sparcv9-unknown-linux-gnu"
+ fi
+ fi
+ ;;
+ esac
+
+ if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
+ CBUILD_OPT=${CTARGET_OPT}
+ fi
+
+ if $(tc-getCC ${CTARGET}) -v 2>&1 | grep -q 'gcc version 3.[0123]'; then
+ append-flags -finline-limit=2000
+ fi
+
+ # We dont want these flags for glibc
+ filter-ldflags -pie
+
+ # Lock glibc at -O2 -- linuxthreads needs it and we want to be
+ # conservative here. -fno-strict-aliasing is to work around #155906
+ filter-flags -O?
+ append-flags -O2 -fno-strict-aliasing
+}
+
+check_kheader_version() {
+ local header="$(alt_build_headers)/linux/version.h"
+
+ [[ -z $1 ]] && return 1
+
+ if [[ -f ${header} ]] ; then
+ local version=$(grep 'LINUX_VERSION_CODE' ${header} | \
+ sed -e 's:^.*LINUX_VERSION_CODE[[:space:]]*::')
+
+ if [[ ${version} -ge "$1" ]] ; then
+ return 0
+ fi
+ fi
+
+ return 1
+}
+
+check_nptl_support() {
+ local min_kernel_version=$(KV_to_int "${NPTL_KERNEL_VERSION}")
+
+ echo
+
+ 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 ! is_crosscompile && ! tc-is-cross-compiler ; then
+ # Building fails on an non-supporting kernel
+ ebegin "Checking kernel version (>=${NPTL_KERNEL_VERSION})"
+ if ! eend $([[ $(get_KV) -ge ${min_kernel_version} ]] ; echo $?) ; then
+ echo
+ eerror "You need a kernel of at least version ${NPTL_KERNEL_VERSION}"
+ eerror "for NPTL support!"
+ die "Kernel version too low!"
+ fi
+ fi
+
+ # Building fails with too low linux-headers
+ ebegin "Checking linux-headers version (>=${NPTL_KERNEL_VERSION})"
+ if ! eend $(check_kheader_version "${min_kernel_version}" ; echo $?) ; then
+ echo
+ eerror "You need linux-headers of at least version ${NPTL_KERNEL_VERSION}"
+ eerror "for NPTL support!"
+ die "linux-headers version too low!"
+ fi
+
+ echo
+}
+
+want_nptl() {
+ want_tls || return 1
+ use nptl || return 1
+
+ # Only list the arches that cannot do NPTL
+ case $(tc-arch) in
+ hppa|m68k) return 1;;
+ sparc)
+ # >= v9 is needed for nptl.
+ [[ ${PROFILE_ARCH} == "sparc" ]] && return 1
+ ;;
+ esac
+
+ return 0
+}
+
+want_linuxthreads() {
+ ! use nptlonly && return 0
+ want_nptl || return 0
+ return 1
+}
+
+want_tls() {
+ # Archs that can use TLS (Thread Local Storage)
+ case $(tc-arch) in
+ sparc)
+ # 2.3.6 should have tls support on sparc64
+ # when using newer binutils
+ case ${CTARGET/-*} in
+ sparc64*) return 1 ;;
+ *) return 0 ;;
+ esac
+ ;;
+ 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}
+
+ echo 'extern __thread int i;' > "${T}"/test-__thread.c
+ $(tc-getCC ${CTARGET}) -c "${T}"/test-__thread.c -o "${T}"/test-__thread.o &> /dev/null
+ WANT__THREAD=$?
+ rm -f "${T}"/test-__thread.[co]
+
+ return ${WANT__THREAD}
+}
+
+glibc_do_configure() {
+ local myconf
+
+ # set addons
+ pushd "${S}" > /dev/null
+ local ADDONS=$(echo */configure | sed \
+ -e 's:/configure::g' \
+ -e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
+ -e 's: \+$::' \
+ -e 's! !,!g' \
+ -e 's!^!,!' \
+ -e '/^,\*$/d')
+ popd > /dev/null
+
+ if [[ -n ${PPC_CPU_ADDON_VER} ]] && [[ $(tc-arch) == ppc* ]] ; then
+ ADDONS="${ADDONS},powerpc-cpu"
+ case $(get-flag mcpu) in
+ 970|power4|power5|power5+) myconf="${myconf} --with-cpu=$(get-flag mcpu)"
+ esac
+ fi
+
+ use nls || myconf="${myconf} --disable-nls"
+ myconf="${myconf} $(use_enable hardened stackguard-randomization)"
+ if [[ $(<"${T}"/.ssp.compat) == "yes" ]] ; then
+ myconf="${myconf} --enable-old-ssp-compat"
+ else
+ myconf="${myconf} --disable-old-ssp-compat"
+ fi
+
+ use glibc-omitfp && myconf="${myconf} --enable-omitfp"
+
+ [[ ${CTARGET//_/-} == *-softfloat-* ]] && myconf="${myconf} --without-fp"
+
+ if [[ $1 == "linuxthreads" ]] ; then
+ if want_tls ; then
+ myconf="${myconf} --with-tls"
+
+ if ! want__thread || use glibc-compat20 || [[ ${LT_KERNEL_VERSION} == 2.[02].* ]] ; then
+ myconf="${myconf} --without-__thread"
+ else
+ myconf="${myconf} --with-__thread"
+ fi
+ else
+ myconf="${myconf} --without-tls --without-__thread"
+ fi
+
+ myconf="${myconf} --disable-sanity-checks"
+ myconf="${myconf} --enable-add-ons=ports,linuxthreads${ADDONS}"
+ myconf="${myconf} --enable-kernel=${LT_KERNEL_VERSION}"
+ elif [[ $1 == "nptl" ]] ; then
+ myconf="${myconf} --with-tls --with-__thread"
+ myconf="${myconf} --enable-add-ons=ports,nptl${ADDONS}"
+ myconf="${myconf} --enable-kernel=${NPTL_KERNEL_VERSION}"
+ else
+ die "invalid pthread option"
+ fi
+
+ # Since SELinux support is only required for nscd, only enable it if:
+ # 1. USE selinux
+ # 2. ! USE build
+ # 3. only for the primary ABI on multilib systems
+ if use selinux && ! use build ; then
+ if use multilib || has_multilib_profile ; then
+ if is_final_abi ; then
+ myconf="${myconf} --with-selinux"
+ else
+ myconf="${myconf} --without-selinux"
+ fi
+ else
+ myconf="${myconf} --with-selinux"
+ fi
+ else
+ myconf="${myconf} --without-selinux"
+ fi
+
+ myconf="${myconf}
+ --without-cvs
+ --enable-bind-now
+ --build=${CBUILD_OPT:-${CBUILD}}
+ --host=${CTARGET_OPT:-${CTARGET}}
+ $(use_enable profile)
+ --without-gd
+ --with-headers=$(alt_build_headers)
+ --prefix=/usr
+ --libdir=/usr/$(get_libdir)
+ --mandir=/usr/share/man
+ --infodir=/usr/share/info
+ --libexecdir=/usr/$(get_libdir)/misc/glibc
+ ${EXTRA_ECONF}"
+
+ # 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_slibdir=/$(get_libdir)
+
+ has_version app-admin/eselect-compiler || export CC=$(tc-getCC ${CTARGET})
+
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-$1
+ mkdir -p "${GBUILDDIR}"
+ cd "${GBUILDDIR}"
+ einfo "Configuring GLIBC for $1 with: ${myconf// /\n\t\t}"
+ "${S}"/configure ${myconf} || die "failed to configure glibc"
+}
+
+fix_lib64_symlinks() {
+ # the original Gentoo/AMD64 devs decided that since 64bit is the native
+ # bitdepth for AMD64, lib should be used for 64bit libraries. however,
+ # this ignores the FHS and breaks multilib horribly... especially
+ # since it wont even work without a lib64 symlink anyways. *rolls eyes*
+ # see bug 59710 for more information.
+ # Travis Tilley <lv@gentoo.org> (08 Aug 2004)
+ if [ -L ${ROOT}/lib64 ] ; then
+ ewarn "removing /lib64 symlink and moving lib to lib64..."
+ ewarn "dont hit ctrl-c until this is done"
+ addwrite ${ROOT}/
+ rm ${ROOT}/lib64
+ # now that lib64 is gone, nothing will run without calling ld.so
+ # directly. luckily the window of brokenness is almost non-existant
+ use amd64 && /lib/ld-linux-x86-64.so.2 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ use ppc64 && /lib/ld64.so.1 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ # all better :)
+ ldconfig
+ ln -s lib64 ${ROOT}/lib
+ einfo "done! :-)"
+ einfo "fixed broken lib64/lib symlink in ${ROOT}"
+ fi
+ if [ -L ${ROOT}/usr/lib64 ] ; then
+ addwrite ${ROOT}/usr
+ rm ${ROOT}/usr/lib64
+ mv ${ROOT}/usr/lib ${ROOT}/usr/lib64
+ ln -s lib64 ${ROOT}/usr/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr"
+ fi
+ if [ -L ${ROOT}/usr/X11R6/lib64 ] ; then
+ addwrite ${ROOT}/usr/X11R6
+ rm ${ROOT}/usr/X11R6/lib64
+ mv ${ROOT}/usr/X11R6/lib ${ROOT}/usr/X11R6/lib64
+ ln -s lib64 ${ROOT}/usr/X11R6/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6"
+ fi
+}
+
+use_multilib() {
+ case ${CTARGET} in
+ sparc64*|mips64*|x86_64*|powerpc64*|s390x*)
+ has_multilib_profile || use multilib ;;
+ *) false ;;
+ esac
+}
+
+# Setup toolchain variables that would be defined in the profiles for these archs.
+setup_env() {
+ # These should not be set, else the zoneinfo do not always get installed ...
+ unset LANGUAGE LANG LC_ALL
+ # silly users
+ unset LD_RUN_PATH
+
+ if is_crosscompile || tc-is-cross-compiler ; then
+ multilib_env ${CTARGET}
+ if ! use multilib ; then
+ MULTILIB_ABIS=${DEFAULT_ABI}
+ else
+ MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
+ fi
+
+ # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
+ # and fall back on CFLAGS.
+ local VAR=CFLAGS_${CTARGET//[-.]/_}
+ CFLAGS=${!VAR-${CFLAGS}}
+ fi
+
+ setup_flags
+
+ export ABI=${ABI:-${DEFAULT_ABI:-default}}
+
+ if is_crosscompile || tc-is-cross-compiler ; then
+ 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)
+ export CFLAGS="${!VAR} ${CFLAGS}"
+ fi
+}
+
+### /ECLASS PUNTAGE ###
+
+if is_crosscompile ; then
+ SLOT="${CTARGET}-2.2"
+else
+ SLOT="2.2"
+fi
+
+# we'll handle stripping ourself #46186
+RESTRICT="strip"
+EMULTILIB_PKG="true"
+
+# General: We need a new-enough binutils for as-needed
+# arch: we need to make sure our binutils/gcc supports TLS
+DEPEND=">=sys-devel/gcc-3.4.4
+ arm? ( >=sys-devel/binutils-2.16.90 >=sys-devel/gcc-4.1.0 )
+ ppc? ( >=sys-devel/gcc-4.1.0 )
+ ppc64? ( >=sys-devel/gcc-4.1.0 )
+ nptl? ( || ( >=sys-kernel/mips-headers-${NPTL_KERNEL_VERSION} >=sys-kernel/linux-headers-${NPTL_KERNEL_VERSION} ) )
+ >=sys-devel/binutils-2.15.94
+ >=sys-devel/gcc-config-1.3.12
+ >=app-misc/pax-utils-0.1.10
+ virtual/os-headers
+ nls? ( sys-devel/gettext )
+ selinux? ( !build? ( sys-libs/libselinux ) )"
+RDEPEND="nls? ( sys-devel/gettext )
+ selinux? ( !build? ( sys-libs/libselinux ) )"
+
+if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ DEPEND="${DEPEND} !crosscompile_opts_headers-only? ( ${CATEGORY}/gcc )"
+
+ if [[ ${CATEGORY} == *-linux* ]] ; then
+ if [[ ${CATEGORY} == cross-mips* ]] ; then
+ DEPEND="${DEPEND} >=${CATEGORY}/mips-headers-2.6.10"
+ else
+ DEPEND="${DEPEND} ${CATEGORY}/linux-headers"
+ fi
+ fi
+else
+ DEPEND="${DEPEND} sys-libs/timezone-data"
+ RDEPEND="${RDEPEND} sys-libs/timezone-data"
+fi
+
+pkg_setup() {
+ # prevent native builds from downgrading ... maybe update to allow people
+ # to change between diff -r versions ? (2.3.6-r4 -> 2.3.6-r2)
+ if ! is_crosscompile && ! tc-is-cross-compiler ; then
+ if has_version '>'${CATEGORY}/${PF} ; 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
+ fi
+
+ if use glibc-compat20 ; then
+ eerror "This version no longer provides compatibility with old broken"
+ eerror "applications. If you need this support, call your vendor"
+ eerror "and tell them to release an update that isn't broken."
+ die "non-TLS symbol errno@glibc_2.0 not supported"
+ fi
+ if want_linuxthreads ; then
+ ewarn "glibc-2.4 is nptl-only!"
+ [[ ${CTARGET} == i386-* ]] && eerror "NPTL requires a CHOST of i486 or better"
+ die "please add USE='nptl nptlonly' to make.conf"
+ fi
+
+ if use nptlonly && ! use nptl ; then
+ eerror "If you want nptlonly, add nptl to your USE too ;p"
+ die "nptlonly without nptl"
+ 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, which is probably not what you want."
+ fi
+
+ if ! type -p scanelf > /dev/null ; then
+ eerror "You do not have pax-utils installed."
+ die "install pax-utils"
+ fi
+
+ # give some sort of warning about the nptl logic changes...
+ if want_nptl && want_linuxthreads ; then
+ ewarn "Warning! Gentoo's GLIBC with NPTL enabled now behaves like the"
+ ewarn "glibc from almost every other distribution out there. This means"
+ ewarn "that glibc is compiled -twice-, once with linuxthreads and once"
+ ewarn "with nptl. The NPTL version is installed to lib/tls and is still"
+ ewarn "used by default. If you do not need nor want the linuxthreads"
+ ewarn "fallback, you can disable this behavior by adding nptlonly to"
+ ewarn "USE to save yourself some compile time."
+
+ ebeep
+ epause 5
+ fi
+}
+
+src_unpack() {
+ setup_env
+
+ toolchain-glibc_src_unpack
+
+ # Backwards SSP support
+ cd "${S}"
+# For now, we force everyone to have the extra symbols
+# einfon "Scanning system for __guard to see if we need SSP compat ... "
+# if [[ -n $(scanelf -qyls__guard -F'#s%F' | grep -v '^/lib.*/libc-2.*.so$') ]] ; then
+ echo "yes" > "${T}"/.ssp.compat
+# else
+# # ok, a quick scan didnt find it, so lets do a deep scan ...
+# if [[ -n $(scanelf -qyRlps__guard -F'#s%F' | grep -v '^/lib.*/libc-2.*.so$') ]] ; then
+# echo "yes" > "${T}"/.ssp.compat
+# else
+# echo "no" > "${T}"/.ssp.compat
+# fi
+# fi
+# cat "${T}"/.ssp.compat
+
+ # Glibc is stupid sometimes, and doesn't realize that with a
+ # static C-Only gcc, -lgcc_eh doesn't exist.
+ # http://sources.redhat.com/ml/libc-alpha/2003-09/msg00100.html
+ # http://sourceware.org/ml/libc-alpha/2005-02/msg00042.html
+ echo 'int main(){}' > "${T}"/gcc_eh_test.c
+ if ! $(tc-getCC ${CTARGET}) "${T}"/gcc_eh_test.c -lgcc_eh 2>/dev/null ; then
+ sed -i -e 's:-lgcc_eh::' Makeconfig || die "sed gcc_eh"
+ fi
+
+ # Some configure checks fail on the first emerge through because they
+ # try to link. This doesn't work well if we don't have a libc yet.
+ # http://sourceware.org/ml/libc-alpha/2005-02/msg00042.html
+ if is_crosscompile && use build; then
+ rm "${S}"/sysdeps/sparc/sparc64/elf/configure{,.in}
+ rm "${S}"/nptl/sysdeps/pthread/configure{,.in}
+ fi
+
+ cd "${WORKDIR}"
+ find . -type f '(' -size 0 -o -name "*.orig" ')' -exec rm -f {} \;
+ find . -name configure -exec touch {} \;
+
+ # Fix permissions on some of the scripts
+ chmod u+x "${S}"/scripts/*.sh
+}
+
+src_compile() {
+ setup_env
+
+ if [[ -z ${OABI} ]] ; then
+ local abilist=""
+ if has_multilib_profile ; then
+ abilist=$(get_install_abis)
+ einfo "Building multilib glibc for ABIs: ${abilist}"
+ elif is_crosscompile || tc-is-cross-compiler ; then
+ abilist=${DEFAULT_ABI}
+ fi
+ if [[ -n ${abilist} ]] ; then
+ OABI=${ABI}
+ for ABI in ${abilist} ; do
+ export ABI
+ src_compile
+ done
+ ABI=${OABI}
+ unset OABI
+ return 0
+ fi
+ fi
+
+ if just_headers ; then
+ toolchain-glibc_headers_compile
+ else
+ toolchain-glibc_src_compile
+ fi
+}
+
+src_test() {
+ setup_env
+
+ if [[ -z ${OABI} ]] && has_multilib_profile ; then
+ OABI=${ABI}
+ einfo "Testing multilib glibc for ABIs: $(get_install_abis)"
+ for ABI in $(get_install_abis) ; do
+ export ABI
+ einfo " Testing ${ABI} glibc"
+ src_test
+ done
+ ABI=${OABI}
+ unset OABI
+ return 0
+ fi
+
+ want_linuxthreads && toolchain-glibc_src_test linuxthreads
+ want_nptl && toolchain-glibc_src_test nptl
+}
+
+src_strip() {
+ # Now, strip everything but the thread libs #46186, as well as the dynamic
+ # linker, else we cannot set breakpoints in shared libraries due to bugs in
+ # gdb. Also want to grab stuff in tls subdir. whee.
+#when new portage supports this ...
+# env \
+# -uRESTRICT \
+# CHOST=${CTARGET} \
+# STRIP_MASK="/*/{,tls/}{ld-,lib{pthread,thread_db}}*" \
+# prepallstrip
+ pushd "${D}" > /dev/null
+
+ if ! is_crosscompile ; then
+ mkdir -p "${T}"/strip-backup
+ for x in $(find "${D}" -maxdepth 3 \
+ '(' -name 'ld-*' -o -name 'libpthread*' -o -name 'libthread_db*' ')' \
+ -a '(' '!' -name '*.a' ')' -type f -printf '%P ')
+ do
+ mkdir -p "${T}/strip-backup/${x%/*}"
+ cp -a -- "${D}/${x}" "${T}/strip-backup/${x}" || die "backing up ${x}"
+ done
+ fi
+ env -uRESTRICT CHOST=${CTARGET} prepallstrip
+ if ! is_crosscompile ; then
+ cp -a -- "${T}"/strip-backup/* "${D}"/ || die "restoring non-stripped libs"
+ fi
+
+ popd > /dev/null
+}
+
+src_install() {
+ setup_env
+
+ if [[ -z ${OABI} ]] ; then
+ local abilist=""
+ if has_multilib_profile ; then
+ abilist=$(get_install_abis)
+ einfo "Installing multilib glibc for ABIs: ${abilist}"
+ elif is_crosscompile || tc-is-cross-compiler ; then
+ abilist=${DEFAULT_ABI}
+ fi
+ if [[ -n ${abilist} ]] ; then
+ OABI=${ABI}
+ for ABI in ${abilist} ; do
+ export ABI
+ src_install
+ done
+ ABI=${OABI}
+ unset OABI
+ src_strip
+ return 0
+ fi
+ fi
+
+ if just_headers ; then
+ toolchain-glibc_headers_install
+ else
+ toolchain-glibc_src_install
+ fi
+ [[ -z ${OABI} ]] && src_strip
+}
+
+pkg_preinst() {
+ toolchain-glibc_pkg_preinst
+}
+
+pkg_postinst() {
+ toolchain-glibc_pkg_postinst
+}
diff --git a/sys-libs/glibc/glibc-2.5.1.ebuild b/sys-libs/glibc/glibc-2.5.1.ebuild
new file mode 100644
index 0000000..ad50c42
--- /dev/null
+++ b/sys-libs/glibc/glibc-2.5.1.ebuild
@@ -0,0 +1,1233 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/Attic/glibc-2.5.1.ebuild,v 1.11 2011/03/20 22:22:24 vapier dead $
+
+# 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/
+
+# need to wait for proper ports/linuxthreads release
+KEYWORDS="" #~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
+
+BRANCH_UPDATE=""
+
+# Generated man pages
+GLIBC_MANPAGE_VERSION="none"
+
+# Generated stuff in manual subdir
+GLIBC_INFOPAGE_VERSION="none"
+
+# Gentoo patchset
+PATCH_VER="1.0"
+
+GENTOO_TOOLCHAIN_BASE_URI="mirror://gentoo"
+GENTOO_TOOLCHAIN_DEV_URI="http://dev.gentoo.org/~azarah/glibc/XXX http://dev.gentoo.org/~vapier/dist/XXX"
+
+### PUNT OUT TO ECLASS?? ###
+inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib
+
+DESCRIPTION="GNU libc6 (also called glibc2) C library"
+HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
+LICENSE="LGPL-2"
+
+IUSE="build debug nls nptl nptlonly hardened multilib selinux glibc-omitfp profile glibc-compat20"
+
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ PROVIDE="virtual/libc"
+fi
+
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+just_headers() {
+ is_crosscompile && use crosscompile_opts_headers-only
+}
+
+GLIBC_RELEASE_VER=$(get_version_component_range 1-3)
+
+# Don't set this to :-, - allows BRANCH_UPDATE=""
+BRANCH_UPDATE=${BRANCH_UPDATE-$(get_version_component_range 4)}
+GLIBC_PORTS_VER="2.5" #${GLIBC_RELEASE_VER}
+#GLIBC_PORTS_VER="20060925"
+GLIBC_LT_VER="2.5" #${GLIBC_RELEASE_VER}
+#GLIBC_LT_VER="20060605"
+
+# (Recent snapshots fails with 2.6.5 and earlier with NPTL)
+NPTL_KERNEL_VERSION=${NPTL_KERNEL_VERSION:-"2.6.9"}
+LT_KERNEL_VERSION=${LT_KERNEL_VERSION:-"2.4.1"}
+
+[[ ${CTARGET} == hppa* ]] && NPTL_KERNEL_VERSION=${NPTL_KERNEL_VERSION:-2.6.20}
+
+### SRC_URI ###
+
+# This function handles the basics of setting the SRC_URI for a glibc ebuild.
+# To use, set SRC_URI with:
+#
+# SRC_URI="$(get_glibc_src_uri)"
+#
+# Other than the variables normally set by portage, this function's behavior
+# can be altered by setting the following:
+#
+# GENTOO_TOOLCHAIN_BASE_URI
+# This sets the base URI for all gentoo-specific patch files. Note
+# that this variable is only important for a brief period of time,
+# before your source files get picked up by mirrors. However, it is
+# still highly suggested that you keep files in this location
+# available.
+#
+# BRANCH_UPDATE
+# If set, this variable signals that we should be using the main
+# release tarball (determined by ebuild version) and applying a
+# CVS branch update patch against it. The location of this branch
+# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
+# Just like with SNAPSHOT, this variable is ignored if the ebuild
+# has a _pre suffix.
+#
+# PATCH_VER
+# PATCH_GLIBC_VER
+# This should be set to the version of the gentoo patch tarball.
+# The resulting filename of this tarball will be:
+# glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+#
+# GLIBC_MANPAGE_VERSION
+# GLIBC_INFOPAGE_VERSION
+# The version of glibc for which we will download pages. This will
+# default to ${GLIBC_RELEASE_VER}, but we may not want to pre-generate man pages
+# for prerelease test ebuilds for example. This allows you to
+# continue using pre-generated manpages from the last stable release.
+# If set to "none", this will prevent the downloading of manpages,
+# which is useful for individual library targets.
+#
+get_glibc_src_uri() {
+ GENTOO_TOOLCHAIN_BASE_URI=${GENTOO_TOOLCHAIN_BASE_URI:-"mirror://gentoo"}
+
+ GLIBC_SRC_URI="mirror://gnu/glibc/glibc-${GLIBC_RELEASE_VER}.tar.bz2
+ mirror://gnu/glibc/glibc-ports-${GLIBC_PORTS_VER}.tar.bz2
+ ftp://sources.redhat.com/pub/glibc/snapshots/glibc-ports-${GLIBC_PORTS_VER}.tar.bz2
+ mirror://gnu/glibc/glibc-libidn-${GLIBC_RELEASE_VER}.tar.bz2"
+
+ if [[ -n ${BRANCH_UPDATE} ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-${GLIBC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-${GLIBC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2}"
+ fi
+
+ if [[ -n ${PATCH_VER} ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2}"
+ fi
+
+ if [[ ${GLIBC_MANPAGE_VERSION} != "none" ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-manpages-${GLIBC_MANPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-manpages-${GLIBC_MANPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2}"
+ fi
+
+ if [[ ${GLIBC_INFOPAGE_VERSION} != "none" ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ ${GENTOO_TOOLCHAIN_BASE_URI}/glibc-infopages-${GLIBC_INFOPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ ${GENTOO_TOOLCHAIN_DEV_URI//XXX/glibc-infopages-${GLIBC_INFOPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2}"
+ fi
+
+ if [[ -n ${GLIBC_LT_VER} ]] ; then
+ GLIBC_SRC_URI="${GLIBC_SRC_URI}
+ mirror://gnu/glibc/glibc-linuxthreads-${GLIBC_LT_VER}.tar.bz2
+ ftp://sources.redhat.com/pub/glibc/snapshots/glibc-linuxthreads-${GLIBC_LT_VER}.tar.bz2"
+ fi
+
+ echo "${GLIBC_SRC_URI}"
+}
+
+SRC_URI=$(get_glibc_src_uri)
+S=${WORKDIR}/glibc-${GLIBC_RELEASE_VER}
+
+### EXPORTED FUNCTIONS ###
+unpack_addon() {
+ local addon=$1 ver=${2:-${GLIBC_RELEASE_VER}}
+ unpack glibc-${addon}-${ver}.tar.bz2
+ mv glibc-${addon}-${ver} ${addon} || die
+}
+toolchain-glibc_src_unpack() {
+ # Check NPTL support _before_ we unpack things to save some time
+ want_nptl && check_nptl_support
+
+ unpack glibc-${GLIBC_RELEASE_VER}.tar.bz2
+
+ cd "${S}"
+ [[ -n ${GLIBC_LT_VER} ]] && unpack glibc-linuxthreads-${GLIBC_LT_VER}.tar.bz2
+ unpack_addon libidn
+ unpack_addon ports ${GLIBC_PORTS_VER}
+
+ if [[ -n ${PATCH_VER} ]] ; then
+ cd "${WORKDIR}"
+ unpack glibc-${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+ # pull out all the addons
+ local d
+ for d in extra/*/configure ; do
+ mv "${d%/configure}" "${S}" || die "moving ${d}"
+ done
+ fi
+
+ # XXX: We should do the branchupdate, before extracting the manpages and
+ # infopages else it does not help much (mtimes change if there is a change
+ # to them with branchupdate)
+ if [[ -n ${BRANCH_UPDATE} ]] ; then
+ cd "${S}"
+ epatch "${DISTDIR}"/glibc-${GLIBC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+
+ # Snapshot date patch
+ einfo "Patching version to display snapshot date ..."
+ sed -i -e "s:\(#define RELEASE\).*:\1 \"${BRANCH_UPDATE}\":" version.h
+ fi
+
+ if [[ ${GLIBC_MANPAGE_VERSION} != "none" ]] ; then
+ cd "${WORKDIR}"
+ unpack glibc-manpages-${GLIBC_MANPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ fi
+
+ if [[ ${GLIBC_INFOPAGE_VERSION} != "none" ]] ; then
+ cd "${S}"
+ unpack glibc-infopages-${GLIBC_INFOPAGE_VERSION:-${GLIBC_RELEASE_VER}}.tar.bz2
+ fi
+
+ if [[ -n ${PATCH_VER} ]] ; then
+ cd "${S}"
+ EPATCH_MULTI_MSG="Applying Gentoo Glibc Patchset ${PATCH_GLIBC_VER:-${GLIBC_RELEASE_VER}}-${PATCH_VER} ..." \
+ EPATCH_EXCLUDE=${GLIBC_PATCH_EXCLUDE} \
+ EPATCH_SUFFIX="patch" \
+ ARCH=$(tc-arch) \
+ epatch "${WORKDIR}"/patches
+
+ # tag, glibc is it
+ [[ -e csu/Banner ]] && die "need new banner location"
+ echo "Gentoo patchset ${PATCH_VER}" > csu/Banner
+ fi
+
+ if use hardened ; then
+ cd "${S}"
+ einfo "Patching to get working PIE binaries on PIE (hardened) platforms"
+ gcc-specs-pie && epatch "${FILESDIR}"/2.5/glibc-2.5-hardened-pie.patch
+ epatch "${FILESDIR}"/2.5/glibc-2.5-hardened-configure-picdefault.patch
+ epatch "${FILESDIR}"/2.5/glibc-2.5-hardened-inittls-nosysenter.patch
+
+ einfo "Installing Hardened Gentoo SSP handler"
+ cp -f "${FILESDIR}"/2.5/glibc-2.5-gentoo-stack_chk_fail.c \
+ debug/stack_chk_fail.c || die
+
+ if use debug ; then
+ # When using Hardened Gentoo stack handler, have smashes dump core for
+ # analysis - debug only, as core could be an information leak
+ # (paranoia).
+ sed -i \
+ -e '/^CFLAGS-backtrace.c/ iCFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
+ debug/Makefile \
+ || die "Failed to modify debug/Makefile for debug stack handler"
+ fi
+
+ # Build nscd with ssp-all
+ sed -i \
+ -e 's:-fstack-protector$:-fstack-protector-all:' \
+ nscd/Makefile \
+ || die "Failed to ensure nscd builds with ssp-all"
+ fi
+
+ gnuconfig_update
+}
+
+toolchain-glibc_src_compile() {
+ echo
+ local v
+ for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CFLAGS ; do
+ einfo " $(printf '%15s' ${v}:) ${!v}"
+ done
+ echo
+
+ if want_linuxthreads ; then
+ glibc_do_configure linuxthreads
+ einfo "Building GLIBC with linuxthreads..."
+ make PARALLELMFLAGS="${MAKEOPTS}" || die "make for ${ABI} failed"
+ fi
+ if want_nptl ; then
+ # ... and then do the optional nptl build
+ unset LD_ASSUME_KERNEL
+ glibc_do_configure nptl
+ einfo "Building GLIBC with NPTL..."
+ make PARALLELMFLAGS="${MAKEOPTS}" || die "make for ${ABI} failed"
+ fi
+}
+
+toolchain-glibc_headers_compile() {
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
+ mkdir -p "${GBUILDDIR}"
+ cd "${GBUILDDIR}"
+
+ # Pick out the correct location for build headers
+ local myconf="--disable-sanity-checks --enable-hacker-mode"
+ myconf="${myconf}
+ --enable-add-ons=nptl,ports
+ --without-cvs
+ --enable-bind-now
+ --build=${CBUILD_OPT:-${CBUILD}}
+ --host=${CTARGET_OPT:-${CTARGET}}
+ --with-headers=$(alt_build_headers)
+ --prefix=/usr
+ ${EXTRA_ECONF}"
+
+ einfo "Configuring GLIBC headers with: ${myconf// /\n\t\t}"
+ CC=gcc \
+ CFLAGS="-O1 -pipe" \
+ "${S}"/configure ${myconf} || die "failed to configure glibc"
+}
+
+toolchain-glibc_src_test() {
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-$1 || die "cd build-${ABI}-${CTARGET}-$1"
+ unset LD_ASSUME_KERNEL
+ make check && return 0
+ einfo "make check failed - re-running with --keep-going to get the rest of the results"
+ make -k check
+ ewarn "make check failed for ${ABI}-${CTARGET}-$1"
+ return 1
+}
+
+toolchain-glibc_pkg_preinst() {
+ # PPC64+others may want to eventually be added to this logic if they
+ # decide to be multilib compatible and FHS compliant. note that this
+ # chunk of FHS compliance only applies to 64bit archs where 32bit
+ # compatibility is a major concern (not IA64, for example).
+
+ # amd64's 2005.0 is the first amd64 profile to not need this code.
+ # 2005.0 is setup properly, and this is executed as part of the
+ # 2004.3 -> 2005.0 upgrade script.
+ # It can be removed after 2004.3 has been purged from portage.
+ { use amd64 || use ppc64; } && [ "$(get_libdir)" == "lib64" ] && ! has_multilib_profile && fix_lib64_symlinks
+
+ # it appears that /lib/tls is sometimes not removed. See bug
+ # 69258 for more info.
+ if [[ -d ${ROOT}/$(alt_libdir)/tls ]] && ! { want_nptl && want_linuxthreads; }; then
+ addwrite "${ROOT}"/$(alt_libdir)/
+ ewarn "nptlonly or -nptl in USE, removing /${ROOT}$(alt_libdir)/tls..."
+ rm -r "${ROOT}"/$(alt_libdir)/tls || die
+ fi
+
+ # Shouldnt need to keep this updated
+ [[ -e ${ROOT}/etc/locale.gen ]] && rm -f "${D}"/etc/locale.gen
+
+ # simple test to make sure our new glibc isnt 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.
+ [[ ${ROOT} != "/" ]] && return 0
+ is_crosscompile && return 0
+ local x striptest
+ for x in date env ls true uname ; do
+ x=$(type -p ${x})
+ [[ -z ${x} ]] && continue
+ striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null)
+ [[ -z ${striptest} ]] && continue
+ [[ ${striptest} == *"statically linked"* ]] && continue
+ "${D}"/$(get_libdir)/ld-*.so \
+ --library-path "${D}"/$(get_libdir) \
+ ${x} > /dev/null \
+ || die "simple run test (${x}) failed"
+ done
+}
+
+toolchain-glibc_src_install() {
+ # These should not be set, else the
+ # zoneinfo do not always get installed ...
+ unset LANGUAGE LANG LC_ALL
+
+ local GBUILDDIR
+ if want_linuxthreads ; then
+ GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-linuxthreads
+ else
+ GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-nptl
+ fi
+
+ local install_root=${D}
+ is_crosscompile && install_root="${install_root}/usr/${CTARGET}"
+ if want_linuxthreads ; then
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-linuxthreads
+ einfo "Installing GLIBC ${ABI} with linuxthreads ..."
+ make PARALLELMFLAGS="${MAKEOPTS}" \
+ install_root="${install_root}" \
+ install || die
+ else # nptlonly
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
+ einfo "Installing GLIBC ${ABI} with NPTL ..."
+ make PARALLELMFLAGS="${MAKEOPTS}" \
+ install_root="${install_root}" \
+ install || die
+ fi
+
+ if is_crosscompile ; then
+ # punt all the junk not needed by a cross-compiler
+ cd "${D}"/usr/${CTARGET} || die
+ rm -rf ./{,usr/}{bin,etc,sbin,share} ./{,usr/}*/{gconv,misc}
+ fi
+
+ if want_linuxthreads && want_nptl ; then
+ einfo "Installing NPTL to $(alt_libdir)/tls/..."
+ cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
+ dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
+
+ local l src_lib
+ for l in libc libm librt libpthread libthread_db ; do
+ # take care of shared lib first ...
+ l=${l}.so
+ if [[ -e ${l} ]] ; then
+ src_lib=${l}
+ else
+ src_lib=$(eval echo */${l})
+ fi
+ cp -a ${src_lib} "${D}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
+ fperms a+rx $(alt_libdir)/tls/${l}
+ dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
+
+ # then grab the linker script or the symlink ...
+ if [[ -L ${D}$(alt_usrlibdir)/${l} ]] ; then
+ dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
+ else
+ sed \
+ -e "s:/${l}:/tls/${l}:g" \
+ -e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
+ "${D}"$(alt_usrlibdir)/${l} > "${D}"$(alt_usrlibdir)/nptl/${l}
+ fi
+
+ # then grab the static lib ...
+ src_lib=${src_lib/%.so/.a}
+ [[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
+ cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
+ src_lib=${src_lib/%.a/_nonshared.a}
+ if [[ -e ${src_lib} ]] ; then
+ cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
+ fi
+ done
+
+ # use the nptl linker instead of the linuxthreads one as the linuxthreads
+ # one may lack TLS support and that can be really bad for business
+ cp -a elf/ld.so "${D}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
+ fi
+
+ # We'll take care of the cache ourselves
+ rm -f "${D}"/etc/ld.so.cache
+
+ # When cross-compiling for a non-multilib setup, make sure we have
+ # lib and a proper symlink setup
+ if is_crosscompile && ! use multilib && ! has_multilib_profile && [[ $(get_libdir) != "lib" ]] ; then
+ cd "${D}"$(alt_libdir)/..
+ mv $(get_libdir) lib || die
+ ln -s lib $(get_libdir) || die
+ cd "${D}"$(alt_usrlibdir)/..
+ mv $(get_libdir) lib || die
+ ln -s lib $(get_libdir) || die
+ 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
+ dosym usr/include /usr/${CTARGET}/sys-include
+ return 0
+ fi
+
+ # 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
+ if has_multilib_profile ; then
+ case $(tc-arch) in
+ amd64)
+ [[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR amd64) /lib
+ dosym ../$(get_abi_LIBDIR x86)/ld-linux.so.2 /lib/ld-linux.so.2
+ ;;
+ ppc64)
+ [[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR ppc64) /lib
+ dosym ../$(get_abi_LIBDIR ppc)/ld.so.1 /lib/ld.so.1
+ ;;
+ esac
+ 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 > "${D}"/usr/share/i18n/SUPPORTED \
+ || die "generating /usr/share/i18n/SUPPORTED failed"
+ cd "${WORKDIR}"/extra/locale
+ dosbin locale-gen || die
+ doman *.[0-8]
+ insinto /etc
+ doins locale.gen || die
+
+ # 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 ${D}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
+ dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
+ fi
+ done
+
+ if ! has noinfo ${FEATURES} && [[ ${GLIBC_INFOPAGE_VERSION} != "none" ]] ; then
+ einfo "Installing info pages..."
+
+ make \
+ -C "${GBUILDDIR}" \
+ PARALLELMFLAGS="${MAKEOPTS}" \
+ install_root="${install_root}" \
+ info -i || die
+ fi
+
+ if [[ ${GLIBC_MANPAGE_VERSION} != "none" ]] ; then
+ einfo "Installing man pages..."
+
+ # Install linuxthreads man pages even if nptl is enabled
+ cd "${WORKDIR}"/man
+ doman *.3thr
+ fi
+
+ cd "${S}"
+
+ # Install misc network config files
+ insinto /etc
+ doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf || die
+ doins "${WORKDIR}"/extra/etc/*.conf || die
+ doinitd "${WORKDIR}"/extra/etc/nscd || die
+
+ dodoc BUGS ChangeLog* CONFORMANCE FAQ NEWS NOTES PROJECTS README*
+
+ # Prevent overwriting of the /etc/localtime symlink. We'll handle the
+ # creation of the "factory" symlink in pkg_postinst().
+ rm -f "${D}"/etc/localtime
+}
+
+toolchain-glibc_headers_install() {
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
+ cd "${GBUILDDIR}"
+ make install_root="${D}/usr/${CTARGET}" install-headers || die "install-headers failed"
+ # Copy over headers that are not part of install-headers ... these
+ # are pretty much taken verbatim from crosstool, see it for more details
+ insinto $(alt_headers)/bits
+ doins misc/syscall-list.h bits/stdio_lim.h || die "doins include bits"
+ insinto $(alt_headers)/gnu
+ doins "${S}"/include/gnu/stubs.h || die "doins include gnu"
+ # 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 /usr/${CTARGET}/sys-include
+}
+
+toolchain-glibc_pkg_postinst() {
+ # Mixing nptlonly and -nptlonly glibc can prove dangerous if libpthread
+ # isn't removed in unmerge which happens sometimes. See bug #87671
+ if ! is_crosscompile && want_linuxthreads && [[ ${ROOT} == "/" ]] ; then
+ for libdir in $(get_all_libdirs) ; do
+ for f in "${ROOT}"/${libdir}/libpthread-2.* "${ROOT}"/${libdir}/libpthread-0.6* ; do
+ if [[ -f ${f} ]] ; then
+ rm -f ${f}
+ ldconfig
+ fi
+ done
+ done
+ fi
+
+ if ! tc-is-cross-compiler && [[ -x ${ROOT}/usr/sbin/iconvconfig ]] ; then
+ # Generate fastloading iconv module configuration file.
+ "${ROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
+ fi
+
+ if [[ ! -e ${ROOT}/lib/ld.so.1 ]] && use ppc64 && ! has_multilib_profile ; then
+ ## SHOULDN'T THIS BE lib64??
+ ln -s ld64.so.1 "${ROOT}"/lib/ld.so.1
+ fi
+
+ if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
+ # Reload init ...
+ /sbin/telinit U &> /dev/null
+
+ # if the host locales.gen contains no entries, we'll install everything
+ 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
+ local x jobs
+ for x in ${MAKEOPTS} ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done
+ locale-gen -j ${jobs:-1} --config "${locale_list}"
+ fi
+
+ echo
+ einfo "Gentoo's glibc no longer includes mdns."
+ einfo "If you want mdns, emerge the sys-auth/nss-mdns package."
+ echo
+
+ if want_nptl && want_linuxthreads ; then
+ einfo "The default behavior of glibc on your system is to use NPTL. If"
+ einfo "you want to use linuxthreads for a particular program, start it"
+ einfo "by executing 'LD_ASSUME_KERNEL=${LT_KERNEL_VERSION} <program> [<options>]'"
+ echo
+ fi
+}
+
+### SUPPORT FUNCTIONS ###
+# 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.
+# note: intentionally undocumented.
+alt_headers() {
+ if [[ -z ${ALT_HEADERS} ]] ; then
+ if is_crosscompile ; then
+ ALT_HEADERS="/usr/${CTARGET}/usr/include"
+ else
+ ALT_HEADERS="/usr/include"
+ fi
+ fi
+ echo "${ALT_HEADERS}"
+}
+alt_build_headers() {
+ if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
+ ALT_BUILD_HEADERS=$(alt_headers)
+ if tc-is-cross-compiler ; then
+ ALT_BUILD_HEADERS=${ROOT}$(alt_headers)
+ if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
+ local header_path=$(echo '#include <linux/version.h>' | $(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() {
+ if is_crosscompile ; then
+ echo /usr/${CTARGET}/$(get_libdir)
+ else
+ echo /$(get_libdir)
+ fi
+}
+
+alt_usrlibdir() {
+ if is_crosscompile ; then
+ echo /usr/${CTARGET}/usr/$(get_libdir)
+ else
+ echo /usr/$(get_libdir)
+ fi
+}
+
+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=*
+
+ unset CBUILD_OPT CTARGET_OPT
+ if has_multilib_profile ; then
+ CTARGET_OPT=$(get_abi_CTARGET)
+ [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
+ fi
+
+ case $(tc-arch) in
+ amd64)
+ # Punt this when amd64's 2004.3 is removed
+ CFLAGS_x86="-m32"
+ ;;
+ ppc)
+ append-flags "-freorder-blocks"
+ ;;
+ sparc)
+ # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
+ filter-flags "-fcall-used-g7"
+ append-flags "-fcall-used-g6"
+ filter-flags "-mvis"
+
+ if is_crosscompile || [[ ${PROFILE_ARCH} == "sparc64" ]] || { has_multilib_profile && ! tc-is-cross-compiler; } ; then
+ case ${ABI} in
+ sparc64)
+ filter-flags -Wa,-xarch -Wa,-A
+
+ if is-flag "-mcpu=ultrasparc3"; then
+ CTARGET_OPT="sparc64b-unknown-linux-gnu"
+ append-flags "-Wa,-xarch=v9b"
+ export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9b"
+ else
+ CTARGET_OPT="sparc64-unknown-linux-gnu"
+ append-flags "-Wa,-xarch=v9a"
+ export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9a"
+ fi
+ ;;
+ *)
+ if is-flag "-mcpu=ultrasparc3"; then
+ CTARGET_OPT="sparcv9b-unknown-linux-gnu"
+ else
+ CTARGET_OPT="sparcv9-unknown-linux-gnu"
+ fi
+ ;;
+ esac
+ else
+ if is-flag "-mcpu=ultrasparc3"; then
+ CTARGET_OPT="sparcv9b-unknown-linux-gnu"
+ elif { is_crosscompile && want_nptl; } || is-flag "-mcpu=ultrasparc2" || is-flag "-mcpu=ultrasparc"; then
+ CTARGET_OPT="sparcv9-unknown-linux-gnu"
+ fi
+ fi
+ ;;
+ esac
+
+ if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
+ CBUILD_OPT=${CTARGET_OPT}
+ fi
+
+ # Lock glibc at -O2 -- linuxthreads needs it and we want to be
+ # conservative here. -fno-strict-aliasing is to work around #155906
+ filter-flags -O?
+ append-flags -O2 -fno-strict-aliasing
+
+ # building glibc with SSP is fraught with difficulty, especially
+ # due to __stack_chk_fail_local which would mean significant changes
+ # to the glibc build process. See bug #94325
+ filter-flags -fstack-protector
+
+ if use hardened && gcc-specs-pie ; then
+ # Force PIC macro definition for all compilations since they're all
+ # either -fPIC or -fPIE with the default-PIE compiler.
+ append-cppflags -DPIC
+ else
+ # Don't build -fPIE without the default-PIE compiler and the
+ # hardened-pie patch
+ filter-flags -fPIE
+ fi
+}
+
+check_kheader_version() {
+ local version=$(
+ printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
+ $(tc-getCPP ${CTARGET}) -I "$(alt_build_headers)" | \
+ tail -n 1
+ )
+ [[ ${version} -ge "$1" ]]
+}
+
+check_nptl_support() {
+ local min_kernel_version=$(KV_to_int "${NPTL_KERNEL_VERSION}")
+
+ echo
+
+ 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 ! is_crosscompile && ! tc-is-cross-compiler ; then
+ # Building fails on an non-supporting kernel
+ ebegin "Checking kernel version (>=${NPTL_KERNEL_VERSION})"
+ if ! eend $([[ $(get_KV) -ge ${min_kernel_version} ]] ; echo $?) ; then
+ echo
+ eerror "You need a kernel of at least version ${NPTL_KERNEL_VERSION}"
+ eerror "for NPTL support!"
+ die "Kernel version too low!"
+ fi
+ fi
+
+ # Building fails with too low linux-headers
+ ebegin "Checking linux-headers version (>=${NPTL_KERNEL_VERSION})"
+ if ! eend $(check_kheader_version "${min_kernel_version}" ; echo $?) ; then
+ echo
+ eerror "You need linux-headers of at least version ${NPTL_KERNEL_VERSION}"
+ eerror "for NPTL support!"
+ die "linux-headers version too low!"
+ fi
+
+ echo
+}
+
+want_nptl() {
+ want_tls || return 1
+ use nptl || return 1
+
+ # Only list the arches that cannot do NPTL
+ case $(tc-arch) in
+ m68k) return 1;;
+ sparc)
+ # >= v9 is needed for nptl.
+ [[ ${PROFILE_ARCH} == "sparc" ]] && return 1
+ ;;
+ esac
+
+ return 0
+}
+
+want_linuxthreads() {
+ ! use nptlonly && return 0
+ want_nptl || return 0
+ return 1
+}
+
+want_tls() {
+ # Archs that can use TLS (Thread Local Storage)
+ case $(tc-arch) in
+ sparc)
+ # 2.3.6 should have tls support on sparc64
+ # when using newer binutils
+ case ${CTARGET/-*} in
+ sparc64*) return 1 ;;
+ *) return 0 ;;
+ esac
+ ;;
+ 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}
+
+ echo 'extern __thread int i;' > "${T}"/test-__thread.c
+ $(tc-getCC ${CTARGET}) -c "${T}"/test-__thread.c -o "${T}"/test-__thread.o &> /dev/null
+ WANT__THREAD=$?
+ rm -f "${T}"/test-__thread.[co]
+
+ return ${WANT__THREAD}
+}
+
+glibc_do_configure() {
+ local myconf
+
+ # set addons
+ pushd "${S}" > /dev/null
+ local ADDONS=$(echo */configure | sed \
+ -e 's:/configure::g' \
+ -e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
+ -e 's: \+$::' \
+ -e 's! !,!g' \
+ -e 's!^!,!' \
+ -e '/^,\*$/d')
+ popd > /dev/null
+
+ use nls || myconf="${myconf} --disable-nls"
+ myconf="${myconf} $(use_enable hardened stackguard-randomization)"
+ if [[ $(<"${T}"/.ssp.compat) == "yes" ]] ; then
+ myconf="${myconf} --enable-old-ssp-compat"
+ else
+ myconf="${myconf} --disable-old-ssp-compat"
+ fi
+
+ use glibc-omitfp && myconf="${myconf} --enable-omitfp"
+
+ [[ ${CTARGET//_/-} == *-softfloat-* ]] && myconf="${myconf} --without-fp"
+
+ if [[ $1 == "linuxthreads" ]] ; then
+ if want_tls ; then
+ myconf="${myconf} --with-tls"
+
+ if ! want__thread || use glibc-compat20 || [[ ${LT_KERNEL_VERSION} == 2.[02].* ]] ; then
+ myconf="${myconf} --without-__thread"
+ else
+ myconf="${myconf} --with-__thread"
+ fi
+ else
+ myconf="${myconf} --without-tls --without-__thread"
+ fi
+
+ myconf="${myconf} --disable-sanity-checks"
+ myconf="${myconf} --enable-add-ons=ports,linuxthreads${ADDONS}"
+ myconf="${myconf} --enable-kernel=${LT_KERNEL_VERSION}"
+ elif [[ $1 == "nptl" ]] ; then
+ myconf="${myconf} --with-tls --with-__thread"
+ myconf="${myconf} --enable-add-ons=ports,nptl${ADDONS}"
+ myconf="${myconf} --enable-kernel=${NPTL_KERNEL_VERSION}"
+ else
+ die "invalid pthread option"
+ fi
+
+ # Since SELinux support is only required for nscd, only enable it if:
+ # 1. USE selinux
+ # 2. ! USE build
+ # 3. only for the primary ABI on multilib systems
+ if use selinux && ! use build ; then
+ if use multilib || has_multilib_profile ; then
+ if is_final_abi ; then
+ myconf="${myconf} --with-selinux"
+ else
+ myconf="${myconf} --without-selinux"
+ fi
+ else
+ myconf="${myconf} --with-selinux"
+ fi
+ else
+ myconf="${myconf} --without-selinux"
+ fi
+
+ myconf="${myconf}
+ --without-cvs
+ --enable-bind-now
+ --build=${CBUILD_OPT:-${CBUILD}}
+ --host=${CTARGET_OPT:-${CTARGET}}
+ $(use_enable profile)
+ --without-gd
+ --with-headers=$(alt_build_headers)
+ --prefix=/usr
+ --libdir=/usr/$(get_libdir)
+ --mandir=/usr/share/man
+ --infodir=/usr/share/info
+ --libexecdir=/usr/$(get_libdir)/misc/glibc
+ ${EXTRA_ECONF}"
+
+ # 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_slibdir=/$(get_libdir)
+
+ has_version app-admin/eselect-compiler || export CC=$(tc-getCC ${CTARGET})
+
+ local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-$1
+ mkdir -p "${GBUILDDIR}"
+ cd "${GBUILDDIR}"
+ einfo "Configuring GLIBC for $1 with: ${myconf// /\n\t\t}"
+ "${S}"/configure ${myconf} || die "failed to configure glibc"
+}
+
+fix_lib64_symlinks() {
+ # the original Gentoo/AMD64 devs decided that since 64bit is the native
+ # bitdepth for AMD64, lib should be used for 64bit libraries. however,
+ # this ignores the FHS and breaks multilib horribly... especially
+ # since it wont even work without a lib64 symlink anyways. *rolls eyes*
+ # see bug 59710 for more information.
+ # Travis Tilley <lv@gentoo.org> (08 Aug 2004)
+ if [ -L ${ROOT}/lib64 ] ; then
+ ewarn "removing /lib64 symlink and moving lib to lib64..."
+ ewarn "dont hit ctrl-c until this is done"
+ addwrite ${ROOT}/
+ rm ${ROOT}/lib64
+ # now that lib64 is gone, nothing will run without calling ld.so
+ # directly. luckily the window of brokenness is almost non-existant
+ use amd64 && /lib/ld-linux-x86-64.so.2 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ use ppc64 && /lib/ld64.so.1 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ # all better :)
+ ldconfig
+ ln -s lib64 ${ROOT}/lib
+ einfo "done! :-)"
+ einfo "fixed broken lib64/lib symlink in ${ROOT}"
+ fi
+ if [ -L ${ROOT}/usr/lib64 ] ; then
+ addwrite ${ROOT}/usr
+ rm ${ROOT}/usr/lib64
+ mv ${ROOT}/usr/lib ${ROOT}/usr/lib64
+ ln -s lib64 ${ROOT}/usr/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr"
+ fi
+ if [ -L ${ROOT}/usr/X11R6/lib64 ] ; then
+ addwrite ${ROOT}/usr/X11R6
+ rm ${ROOT}/usr/X11R6/lib64
+ mv ${ROOT}/usr/X11R6/lib ${ROOT}/usr/X11R6/lib64
+ ln -s lib64 ${ROOT}/usr/X11R6/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6"
+ fi
+}
+
+# Setup toolchain variables that would be defined in the profiles for these archs.
+setup_env() {
+ # These should not be set, else the zoneinfo do not always get installed ...
+ unset LANGUAGE LANG LC_ALL
+ # silly users
+ unset LD_RUN_PATH
+
+ if is_crosscompile || tc-is-cross-compiler ; then
+ multilib_env ${CTARGET}
+ if ! use multilib ; then
+ MULTILIB_ABIS=${DEFAULT_ABI}
+ else
+ MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
+ fi
+
+ # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
+ # and fall back on CFLAGS.
+ local VAR=CFLAGS_${CTARGET//[-.]/_}
+ CFLAGS=${!VAR-${CFLAGS}}
+ fi
+
+ setup_flags
+
+ export ABI=${ABI:-${DEFAULT_ABI:-default}}
+
+ if is_crosscompile || tc-is-cross-compiler ; then
+ 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)
+ export CFLAGS="${!VAR} ${CFLAGS}"
+ fi
+}
+
+### /ECLASS PUNTAGE ###
+
+if is_crosscompile ; then
+ SLOT="${CTARGET}-2.2"
+else
+ SLOT="2.2"
+fi
+
+# we'll handle stripping ourself #46186
+RESTRICT="strip"
+EMULTILIB_PKG="true"
+
+# General: We need a new-enough binutils for as-needed
+# arch: we need to make sure our binutils/gcc supports TLS
+DEPEND=">=sys-devel/gcc-3.4.4
+ arm? ( >=sys-devel/binutils-2.16.90 >=sys-devel/gcc-4.1.0 )
+ ppc? ( >=sys-devel/gcc-4.1.0 )
+ ppc64? ( >=sys-devel/gcc-4.1.0 )
+ nptl? ( >=sys-kernel/linux-headers-${NPTL_KERNEL_VERSION} )
+ >=sys-devel/binutils-2.15.94
+ >=sys-devel/gcc-config-1.3.12
+ >=app-misc/pax-utils-0.1.10
+ virtual/os-headers
+ nls? ( sys-devel/gettext )
+ !<sys-apps/portage-2.1.2
+ selinux? ( !build? ( sys-libs/libselinux ) )"
+RDEPEND="nls? ( sys-devel/gettext )
+ selinux? ( !build? ( sys-libs/libselinux ) )"
+
+if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ DEPEND="${DEPEND} !crosscompile_opts_headers-only? ( ${CATEGORY}/gcc )"
+
+ if [[ ${CATEGORY} == *-linux* ]] ; then
+ DEPEND="${DEPEND} ${CATEGORY}/linux-headers"
+ fi
+else
+ DEPEND="${DEPEND} >=sys-libs/timezone-data-2007c"
+ RDEPEND="${RDEPEND} sys-libs/timezone-data"
+fi
+
+pkg_setup() {
+ # prevent native builds from downgrading ... maybe update to allow people
+ # to change between diff -r versions ? (2.3.6-r4 -> 2.3.6-r2)
+ if ! is_crosscompile && ! tc-is-cross-compiler ; then
+ if has_version '>'${CATEGORY}/${PF} ; 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
+ 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 http://www.gentoo.org/doc/en/change-chost.xml"
+ die "please fix your CHOST"
+ fi
+
+ if use nptlonly && ! use nptl ; then
+ eerror "If you want nptlonly, add nptl to your USE too ;p"
+ die "nptlonly without nptl"
+ 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, which is probably not what you want."
+ fi
+
+ if ! type -p scanelf > /dev/null ; then
+ eerror "You do not have pax-utils installed."
+ die "install pax-utils"
+ fi
+
+ use hardened && ! gcc-specs-pie && \
+ ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
+}
+
+src_unpack() {
+ setup_env
+
+ toolchain-glibc_src_unpack
+
+ # Backwards SSP support
+ cd "${S}"
+# For now, we force everyone to have the extra symbols
+# einfon "Scanning system for __guard to see if we need SSP compat ... "
+# if [[ -n $(scanelf -qyls__guard -F'#s%F' | grep -v '^/lib.*/libc-2.*.so$') ]] ; then
+ echo "yes" > "${T}"/.ssp.compat
+# else
+# # ok, a quick scan didnt find it, so lets do a deep scan ...
+# if [[ -n $(scanelf -qyRlps__guard -F'#s%F' | grep -v '^/lib.*/libc-2.*.so$') ]] ; then
+# echo "yes" > "${T}"/.ssp.compat
+# else
+# echo "no" > "${T}"/.ssp.compat
+# fi
+# fi
+# cat "${T}"/.ssp.compat
+
+ # Glibc is stupid sometimes, and doesn't realize that with a
+ # static C-Only gcc, -lgcc_eh doesn't exist.
+ # http://sources.redhat.com/ml/libc-alpha/2003-09/msg00100.html
+ # http://sourceware.org/ml/libc-alpha/2005-02/msg00042.html
+ echo 'int main(){}' > "${T}"/gcc_eh_test.c
+ if ! $(tc-getCC ${CTARGET}) "${T}"/gcc_eh_test.c -lgcc_eh 2>/dev/null ; then
+ sed -i -e 's:-lgcc_eh::' Makeconfig || die "sed gcc_eh"
+ fi
+
+ cd "${WORKDIR}"
+ find . -type f '(' -size 0 -o -name "*.orig" ')' -exec rm -f {} \;
+ find . -name configure -exec touch {} \;
+
+ # Fix permissions on some of the scripts
+ chmod u+x "${S}"/scripts/*.sh
+}
+
+src_compile() {
+ setup_env
+
+ if [[ -z ${OABI} ]] ; then
+ local abilist=""
+ if has_multilib_profile ; then
+ abilist=$(get_install_abis)
+ einfo "Building multilib glibc for ABIs: ${abilist}"
+ elif is_crosscompile || tc-is-cross-compiler ; then
+ abilist=${DEFAULT_ABI}
+ fi
+ if [[ -n ${abilist} ]] ; then
+ OABI=${ABI}
+ for ABI in ${abilist} ; do
+ export ABI
+ src_compile
+ done
+ ABI=${OABI}
+ unset OABI
+ return 0
+ fi
+ fi
+
+ if just_headers ; then
+ toolchain-glibc_headers_compile
+ else
+ toolchain-glibc_src_compile
+ fi
+}
+
+src_test() {
+ local ret=0
+
+ setup_env
+
+ if [[ -z ${OABI} ]] && has_multilib_profile ; then
+ OABI=${ABI}
+ einfo "Testing multilib glibc for ABIs: $(get_install_abis)"
+ for ABI in $(get_install_abis) ; do
+ export ABI
+ einfo " Testing ${ABI} glibc"
+ src_test
+ ((ret+=$?))
+ done
+ ABI=${OABI}
+ unset OABI
+ [[ ${ret} -ne 0 ]] \
+ && die "tests failed" \
+ || return 0
+ fi
+
+ want_linuxthreads && toolchain-glibc_src_test linuxthreads ; ((ret+=$?))
+ want_nptl && toolchain-glibc_src_test nptl ; ((ret+=$?))
+ return ${ret}
+}
+
+src_strip() {
+ # Now, strip everything but the thread libs #46186, as well as the dynamic
+ # linker, else we cannot set breakpoints in shared libraries due to bugs in
+ # gdb. Also want to grab stuff in tls subdir. whee.
+ env \
+ -uRESTRICT \
+ CHOST=${CTARGET} \
+ STRIP_MASK="/*/{,tls/}{ld-,lib{pthread,thread_db}}*" \
+ prepallstrip
+}
+
+src_install() {
+ setup_env
+
+ if [[ -z ${OABI} ]] ; then
+ local abilist=""
+ if has_multilib_profile ; then
+ abilist=$(get_install_abis)
+ einfo "Installing multilib glibc for ABIs: ${abilist}"
+ elif is_crosscompile || tc-is-cross-compiler ; then
+ abilist=${DEFAULT_ABI}
+ fi
+ if [[ -n ${abilist} ]] ; then
+ OABI=${ABI}
+ for ABI in ${abilist} ; do
+ export ABI
+ src_install
+ done
+ ABI=${OABI}
+ unset OABI
+ src_strip
+ return 0
+ fi
+ fi
+
+ if just_headers ; then
+ toolchain-glibc_headers_install
+ else
+ toolchain-glibc_src_install
+ fi
+ [[ -z ${OABI} ]] && src_strip
+}
+
+pkg_preinst() {
+ toolchain-glibc_pkg_preinst
+}
+
+pkg_postinst() {
+ toolchain-glibc_pkg_postinst
+}
diff --git a/sys-libs/glibc/glibc-2.6.1.ebuild b/sys-libs/glibc/glibc-2.6.1.ebuild
new file mode 100644
index 0000000..a426fe1
--- /dev/null
+++ b/sys-libs/glibc/glibc-2.6.1.ebuild
@@ -0,0 +1,334 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/Attic/glibc-2.6.1.ebuild,v 1.32 2011/03/20 22:22:24 vapier dead $
+
+inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib
+
+DESCRIPTION="GNU libc6 (also called glibc2) C library"
+HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
+
+LICENSE="LGPL-2"
+KEYWORDS="alpha amd64 arm ia64 ~mips ppc ppc64 sh sparc x86"
+RESTRICT="strip" # strip ourself #46186
+EMULTILIB_PKG="true"
+
+# Configuration variables
+RELEASE_VER=$(get_version_component_range 1-3) # major glibc version
+BRANCH_UPDATE=$(get_version_component_range 4) # upstream cvs snaps
+MANPAGE_VER="" # pregenerated manpages
+INFOPAGE_VER="" # pregenerated infopages
+PATCH_VER="1.2" # Gentoo patchset
+PATCH_GLIBC_VER=${RELEASE_VER} # glibc version in patchset
+PORTS_VER=${RELEASE_VER} # version of glibc ports addon
+LIBIDN_VER=${RELEASE_VER} # version of libidn addon
+LT_VER="" # version of linuxthreads addon
+NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"} # min kernel version nptl requires
+#LT_KERN_VER=${LT_KERN_VER:-"2.4.1"} # min kernel version linuxthreads requires
+
+[[ ${CTARGET} == hppa* ]] && NPTL_KERN_VER=${NPTL_KERN_VER:-2.6.20}
+
+IUSE="debug gd nls hardened multilib selinux glibc-omitfp profile vanilla crosscompile_opts_headers-only ${LT_VER:+glibc-compat20 nptl nptlonly}"
+S=${WORKDIR}/glibc-${RELEASE_VER}
+
+# 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-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+alt_libdir() {
+ if is_crosscompile ; then
+ echo /usr/${CTARGET}/$(get_libdir)
+ else
+ echo /$(get_libdir)
+ fi
+}
+
+if is_crosscompile ; then
+ SLOT="${CTARGET}-2.2"
+else
+ # Why SLOT 2.2 you ask yourself while sippin your tea ?
+ # Everyone knows 2.2 > 0, duh.
+ SLOT="2.2"
+ PROVIDE="virtual/libc"
+fi
+
+# General: We need a new-enough binutils for as-needed
+# arch: we need to make sure our binutils/gcc supports TLS
+DEPEND=">=sys-devel/gcc-3.4.4
+ arm? ( >=sys-devel/binutils-2.16.90 >=sys-devel/gcc-4.1.0 )
+ ppc? ( >=sys-devel/gcc-4.1.0 )
+ ppc64? ( >=sys-devel/gcc-4.1.0 )
+ >=sys-devel/binutils-2.15.94
+ ${LT_VER:+nptl? (} >=sys-kernel/linux-headers-${NPTL_KERN_VER} ${LT_VER:+)}
+ >=sys-devel/gcc-config-1.3.12
+ >=app-misc/pax-utils-0.1.10
+ virtual/os-headers
+ nls? ( sys-devel/gettext )
+ !<sys-apps/portage-2.1.2
+ selinux? ( sys-libs/libselinux )"
+RDEPEND="nls? ( sys-devel/gettext )
+ selinux? ( sys-libs/libselinux )"
+
+if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ DEPEND="${DEPEND} !crosscompile_opts_headers-only? ( ${CATEGORY}/gcc )"
+ [[ ${CATEGORY} == *-linux* ]] && DEPEND="${DEPEND} ${CATEGORY}/linux-headers"
+else
+ DEPEND="${DEPEND} >=sys-libs/timezone-data-2007c"
+ RDEPEND="${RDEPEND} sys-libs/timezone-data"
+fi
+
+SRC_URI=$(
+ upstream_uris() {
+ echo mirror://gnu/glibc/$1 ftp://sources.redhat.com/pub/glibc/{releases,snapshots}/$1
+ }
+ gentoo_uris() {
+ local devspace="HTTP~vapier/dist/URI HTTP~azarah/glibc/URI"
+ devspace=${devspace//HTTP/http://dev.gentoo.org/}
+ echo mirror://gentoo/$1 ${devspace//URI/$1}
+ }
+
+ upstream_uris glibc-${RELEASE_VER}.tar.bz2
+ upstream_uris glibc-libidn-${RELEASE_VER}.tar.bz2
+
+ [[ -n ${PORTS_VER} ]] && upstream_uris glibc-ports-${PORTS_VER}.tar.bz2
+ [[ -n ${LT_VER} ]] && upstream_uris glibc-linuxthreads-${LT_VER}.tar.bz2
+ [[ -n ${BRANCH_UPDATE} ]] && gentoo_uris glibc-${RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+ [[ -n ${PATCH_VER} ]] && gentoo_uris glibc-${PATCH_GLIBC_VER}-patches-${PATCH_VER}.tar.bz2
+ [[ -n ${MANPAGE_VER} ]] && gentoo_uris glibc-manpages-${MANPAGE_VER}.tar.bz2
+ [[ -n ${INFOPAGE_VER} ]] && gentoo_uris glibc-infopages-${INFOPAGE_VER}.tar.bz2
+)
+
+# eblit-include [--skip] <function> [version]
+eblit-include() {
+ local skipable=false
+ [[ $1 == "--skip" ]] && skipable=true && shift
+
+ local e v func=$1 ver=$2
+ [[ -z ${func} ]] && die "Usage: eblit-include <function> [version]"
+ for v in ${ver:+-}${ver} -${PVR} -${PV} "" ; do
+ e="${FILESDIR}/eblits/${func}${v}.eblit"
+ if [[ -e ${e} ]] ; then
+ source "${e}"
+ return 0
+ fi
+ done
+ ${skipable} && return 0
+ die "Could not locate requested eblit '${func}' in ${FILESDIR}/eblits/"
+}
+
+# eblit-run-maybe <function>
+# run the specified function if it is defined
+eblit-run-maybe() {
+ [[ $(type -t "$@") == "function" ]] && "$@"
+}
+
+# eblit-run <function> [version]
+# aka: src_unpack() { eblit-run src_unpack ; }
+eblit-run() {
+ eblit-include --skip common "${*:2}"
+ eblit-include "$@"
+ eblit-run-maybe eblit-$1-pre
+ eblit-${PN}-$1 || die
+ eblit-run-maybe eblit-$1-post
+}
+
+src_unpack() { eblit-run src_unpack ; }
+src_compile() { eblit-run src_compile ; }
+src_test() { eblit-run src_test ; }
+src_install() { eblit-run src_install 2.6 ; }
+
+eblit-src_unpack-post() {
+ if use hardened ; then
+ cd "${S}"
+ einfo "Patching to get working PIE binaries on PIE (hardened) platforms"
+ gcc-specs-pie && epatch "${FILESDIR}"/2.5/glibc-2.5-hardened-pie.patch
+ epatch "${FILESDIR}"/2.5/glibc-2.5-hardened-configure-picdefault.patch
+ epatch "${FILESDIR}"/2.6/glibc-2.6-hardened-inittls-nosysenter.patch
+
+ einfo "Installing Hardened Gentoo SSP handler"
+ cp -f "${FILESDIR}"/2.6/glibc-2.6-gentoo-stack_chk_fail.c \
+ debug/stack_chk_fail.c || die
+
+ if use debug ; then
+ # When using Hardened Gentoo stack handler, have smashes dump core for
+ # analysis - debug only, as core could be an information leak
+ # (paranoia).
+ sed -i \
+ -e '/^CFLAGS-backtrace.c/ iCFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
+ debug/Makefile \
+ || die "Failed to modify debug/Makefile for debug stack handler"
+ fi
+
+ # Build nscd with ssp-all
+ sed -i \
+ -e 's:-fstack-protector$:-fstack-protector-all:' \
+ nscd/Makefile \
+ || die "Failed to ensure nscd builds with ssp-all"
+ fi
+}
+
+pkg_setup() {
+ # prevent native builds from downgrading ... maybe update to allow people
+ # to change between diff -r versions ? (2.3.6-r4 -> 2.3.6-r2)
+ if [[ ${ROOT} == "/" ]] && [[ ${CBUILD} == ${CHOST} ]] && [[ ${CHOST} == ${CTARGET} ]] ; then
+ if has_version '>'${CATEGORY}/${PF} ; 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
+ fi
+
+ # users have had a chance to phase themselves, time to give em the boot
+ if [[ -e ${ROOT}/etc/locale.gen ]] && [[ -e ${ROOT}/etc/locales.build ]] ; then
+ eerror "You still haven't deleted ${ROOT}/etc/locales.build."
+ eerror "Do so now after making sure ${ROOT}/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 http://www.gentoo.org/doc/en/change-chost.xml"
+ die "please fix your CHOST"
+ fi
+
+ if [[ -n ${LT_VER} ]] ; then
+ if use nptlonly && ! use nptl ; then
+ eerror "If you want nptlonly, add nptl to your USE too ;p"
+ die "nptlonly without nptl"
+ fi
+ 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, which is probably not what you want."
+ fi
+
+ use hardened && ! gcc-specs-pie && \
+ ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
+}
+
+fix_lib64_symlinks() {
+ # the original Gentoo/AMD64 devs decided that since 64bit is the native
+ # bitdepth for AMD64, lib should be used for 64bit libraries. however,
+ # this ignores the FHS and breaks multilib horribly... especially
+ # since it wont even work without a lib64 symlink anyways. *rolls eyes*
+ # see bug 59710 for more information.
+ # Travis Tilley <lv@gentoo.org> (08 Aug 2004)
+ if [ -L ${ROOT}/lib64 ] ; then
+ ewarn "removing /lib64 symlink and moving lib to lib64..."
+ ewarn "dont hit ctrl-c until this is done"
+ rm ${ROOT}/lib64
+ # now that lib64 is gone, nothing will run without calling ld.so
+ # directly. luckily the window of brokenness is almost non-existant
+ use amd64 && /lib/ld-linux-x86-64.so.2 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ use ppc64 && /lib/ld64.so.1 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ # all better :)
+ ldconfig
+ ln -s lib64 ${ROOT}/lib
+ einfo "done! :-)"
+ einfo "fixed broken lib64/lib symlink in ${ROOT}"
+ fi
+ if [ -L ${ROOT}/usr/lib64 ] ; then
+ rm ${ROOT}/usr/lib64
+ mv ${ROOT}/usr/lib ${ROOT}/usr/lib64
+ ln -s lib64 ${ROOT}/usr/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr"
+ fi
+ if [ -L ${ROOT}/usr/X11R6/lib64 ] ; then
+ rm ${ROOT}/usr/X11R6/lib64
+ mv ${ROOT}/usr/X11R6/lib ${ROOT}/usr/X11R6/lib64
+ ln -s lib64 ${ROOT}/usr/X11R6/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6"
+ fi
+}
+
+pkg_preinst() {
+ # nothing to do if just installing headers
+ just_headers && return
+
+ # PPC64+others may want to eventually be added to this logic if they
+ # decide to be multilib compatible and FHS compliant. note that this
+ # chunk of FHS compliance only applies to 64bit archs where 32bit
+ # compatibility is a major concern (not IA64, for example).
+
+ # amd64's 2005.0 is the first amd64 profile to not need this code.
+ # 2005.0 is setup properly, and this is executed as part of the
+ # 2004.3 -> 2005.0 upgrade script.
+ # It can be removed after 2004.3 has been purged from portage.
+ { use amd64 || use ppc64; } && [ "$(get_libdir)" == "lib64" ] && ! has_multilib_profile && fix_lib64_symlinks
+
+ # it appears that /lib/tls is sometimes not removed. See bug
+ # 69258 for more info.
+ if [[ -d ${ROOT}/$(alt_libdir)/tls ]] && [[ ! -d ${D}/$(alt_libdir)/tls ]] ; then
+ ewarn "nptlonly or -nptl in USE, removing /${ROOT}$(alt_libdir)/tls..."
+ rm -r "${ROOT}"/$(alt_libdir)/tls || die
+ fi
+
+ # Shouldnt need to keep this updated
+ [[ -e ${ROOT}/etc/locale.gen ]] && rm -f "${D}"/etc/locale.gen
+
+ # simple test to make sure our new glibc isnt 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.
+ [[ ${ROOT} != "/" ]] && return 0
+ [[ -d ${D}/$(get_libdir) ]] || return 0
+ cd / #228809
+ local x striptest
+ for x in date env ls true uname ; do
+ x=$(type -p ${x})
+ [[ -z ${x} ]] && continue
+ striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null)
+ [[ -z ${striptest} ]] && continue
+ [[ ${striptest} == *"statically linked"* ]] && continue
+ "${D}"/$(get_libdir)/ld-*.so \
+ --library-path "${D}"/$(get_libdir) \
+ ${x} > /dev/null \
+ || die "simple run test (${x}) failed"
+ done
+}
+
+pkg_postinst() {
+ # nothing to do if just installing headers
+ just_headers && return
+
+ if ! tc-is-cross-compiler && [[ -x ${ROOT}/usr/sbin/iconvconfig ]] ; then
+ # Generate fastloading iconv module configuration file.
+ "${ROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
+ fi
+
+ if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
+ # Reload init ...
+ /sbin/telinit U
+
+ # if the host locales.gen contains no entries, we'll install everything
+ 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
+ local x jobs
+ for x in ${MAKEOPTS} ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done
+ locale-gen -j ${jobs:-1} --config "${locale_list}"
+ fi
+}
diff --git a/sys-libs/glibc/glibc-2.7-r2.ebuild b/sys-libs/glibc/glibc-2.7-r2.ebuild
new file mode 100644
index 0000000..1a4b7b9
--- /dev/null
+++ b/sys-libs/glibc/glibc-2.7-r2.ebuild
@@ -0,0 +1,348 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/Attic/glibc-2.7-r2.ebuild,v 1.21 2011/03/20 22:22:24 vapier dead $
+
+inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib
+
+DESCRIPTION="GNU libc6 (also called glibc2) C library"
+HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
+
+LICENSE="LGPL-2"
+KEYWORDS="~amd64 arm hppa ~ia64 ~ppc ppc64 s390 sh ~sparc ~x86"
+RESTRICT="strip" # strip ourself #46186
+EMULTILIB_PKG="true"
+
+# Configuration variables
+RELEASE_VER=$(get_version_component_range 1-3) # major glibc version
+BRANCH_UPDATE=$(get_version_component_range 4) # upstream cvs snaps
+MANPAGE_VER="" # pregenerated manpages
+INFOPAGE_VER="" # pregenerated infopages
+PATCH_VER="1.7" # Gentoo patchset
+PATCH_GLIBC_VER=${RELEASE_VER} # glibc version in patchset
+PORTS_VER=${RELEASE_VER} # version of glibc ports addon
+LIBIDN_VER=${RELEASE_VER} # version of libidn addon
+LT_VER="" # version of linuxthreads addon
+NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"} # min kernel version nptl requires
+#LT_KERN_VER=${LT_KERN_VER:-"2.4.1"} # min kernel version linuxthreads requires
+
+IUSE="debug gd glibc-omitfp hardened multilib nls selinux profile vanilla crosscompile_opts_headers-only ${LT_VER:+glibc-compat20 nptl nptlonly}"
+S=${WORKDIR}/glibc-${RELEASE_VER}
+
+# 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-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+
+[[ ${CTARGET} == hppa* ]] && NPTL_KERN_VER=${NPTL_KERN_VER/2.6.9/2.6.20}
+
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+alt_libdir() {
+ if is_crosscompile ; then
+ echo /usr/${CTARGET}/$(get_libdir)
+ else
+ echo /$(get_libdir)
+ fi
+}
+
+if is_crosscompile ; then
+ SLOT="${CTARGET}-2.2"
+else
+ # Why SLOT 2.2 you ask yourself while sippin your tea ?
+ # Everyone knows 2.2 > 0, duh.
+ SLOT="2.2"
+ PROVIDE="virtual/libc"
+fi
+
+# General: We need a new-enough binutils for as-needed
+# arch: we need to make sure our binutils/gcc supports TLS
+DEPEND=">=sys-devel/gcc-3.4.4
+ arm? ( >=sys-devel/binutils-2.16.90 >=sys-devel/gcc-4.1.0 )
+ ppc? ( >=sys-devel/gcc-4.1.0 )
+ ppc64? ( >=sys-devel/gcc-4.1.0 )
+ >=sys-devel/binutils-2.15.94
+ ${LT_VER:+nptl? (} >=sys-kernel/linux-headers-${NPTL_KERN_VER} ${LT_VER:+)}
+ >=sys-devel/gcc-config-1.3.12
+ >=app-misc/pax-utils-0.1.10
+ virtual/os-headers
+ nls? ( sys-devel/gettext )
+ >=sys-apps/sandbox-1.2.18.1-r2
+ !<sys-apps/portage-2.1.2
+ selinux? ( sys-libs/libselinux )"
+RDEPEND="nls? ( sys-devel/gettext )
+ selinux? ( sys-libs/libselinux )"
+
+if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ DEPEND="${DEPEND} !crosscompile_opts_headers-only? ( ${CATEGORY}/gcc )"
+ [[ ${CATEGORY} == *-linux* ]] && DEPEND="${DEPEND} ${CATEGORY}/linux-headers"
+else
+ DEPEND="${DEPEND} >=sys-libs/timezone-data-2007c"
+ RDEPEND="${RDEPEND} sys-libs/timezone-data"
+fi
+
+SRC_URI=$(
+ upstream_uris() {
+ echo mirror://gnu/glibc/$1 ftp://sources.redhat.com/pub/glibc/{releases,snapshots}/$1
+ }
+ gentoo_uris() {
+ local devspace="HTTP~vapier/dist/URI HTTP~azarah/glibc/URI"
+ devspace=${devspace//HTTP/http://dev.gentoo.org/}
+ echo mirror://gentoo/$1 ${devspace//URI/$1}
+ }
+
+ upstream_uris glibc-${RELEASE_VER}.tar.bz2
+ upstream_uris glibc-libidn-${RELEASE_VER}.tar.bz2
+
+ [[ -n ${PORTS_VER} ]] && upstream_uris glibc-ports-${PORTS_VER}.tar.bz2
+ [[ -n ${LT_VER} ]] && upstream_uris glibc-linuxthreads-${LT_VER}.tar.bz2
+ [[ -n ${BRANCH_UPDATE} ]] && gentoo_uris glibc-${RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+ [[ -n ${PATCH_VER} ]] && gentoo_uris glibc-${PATCH_GLIBC_VER}-patches-${PATCH_VER}.tar.bz2
+ [[ -n ${MANPAGE_VER} ]] && gentoo_uris glibc-manpages-${MANPAGE_VER}.tar.bz2
+ [[ -n ${INFOPAGE_VER} ]] && gentoo_uris glibc-infopages-${INFOPAGE_VER}.tar.bz2
+)
+
+# eblit-include [--skip] <function> [version]
+eblit-include() {
+ local skipable=false
+ [[ $1 == "--skip" ]] && skipable=true && shift
+
+ local e v func=$1 ver=$2
+ [[ -z ${func} ]] && die "Usage: eblit-include <function> [version]"
+ for v in ${ver:+-}${ver} -${PVR} -${PV} "" ; do
+ e="${FILESDIR}/eblits/${func}${v}.eblit"
+ if [[ -e ${e} ]] ; then
+ source "${e}"
+ return 0
+ fi
+ done
+ ${skipable} && return 0
+ die "Could not locate requested eblit '${func}' in ${FILESDIR}/eblits/"
+}
+
+# eblit-run-maybe <function>
+# run the specified function if it is defined
+eblit-run-maybe() {
+ [[ $(type -t "$@") == "function" ]] && "$@"
+}
+
+# eblit-run <function> [version]
+# aka: src_unpack() { eblit-run src_unpack ; }
+eblit-run() {
+ eblit-include --skip common "${*:2}"
+ eblit-include "$@"
+ eblit-run-maybe eblit-$1-pre
+ eblit-${PN}-$1 || die
+ eblit-run-maybe eblit-$1-post
+}
+
+src_unpack() { eblit-run src_unpack ; }
+src_compile() { eblit-run src_compile ; }
+src_test() { eblit-run src_test ; }
+src_install() { eblit-run src_install ; }
+
+eblit-src_unpack-post() {
+ if use hardened ; then
+ cd "${S}"
+ einfo "Patching to get working PIE binaries on PIE (hardened) platforms"
+ gcc-specs-pie && epatch "${FILESDIR}"/2.5/glibc-2.5-hardened-pie.patch
+ epatch "${FILESDIR}"/2.5/glibc-2.5-hardened-configure-picdefault.patch
+ epatch "${FILESDIR}"/2.7/glibc-2.7-hardened-inittls-nosysenter.patch
+
+ einfo "Installing Hardened Gentoo SSP handler"
+ cp -f "${FILESDIR}"/2.6/glibc-2.6-gentoo-stack_chk_fail.c \
+ debug/stack_chk_fail.c || die
+
+ if use debug ; then
+ # When using Hardened Gentoo stack handler, have smashes dump core for
+ # analysis - debug only, as core could be an information leak
+ # (paranoia).
+ sed -i \
+ -e '/^CFLAGS-backtrace.c/ iCFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
+ debug/Makefile \
+ || die "Failed to modify debug/Makefile for debug stack handler"
+ fi
+
+ # Build nscd with ssp-all
+ sed -i \
+ -e 's:-fstack-protector$:-fstack-protector-all:' \
+ nscd/Makefile \
+ || die "Failed to ensure nscd builds with ssp-all"
+ fi
+}
+
+pkg_setup() {
+ # prevent native builds from downgrading ... maybe update to allow people
+ # to change between diff -r versions ? (2.3.6-r4 -> 2.3.6-r2)
+ if [[ ${ROOT} == "/" ]] && [[ ${CBUILD} == ${CHOST} ]] && [[ ${CHOST} == ${CTARGET} ]] ; then
+ if has_version '>'${CATEGORY}/${PF} ; 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
+
+ # Check for broken kernels #262698
+ cd "${T}"
+ printf '#include <pwd.h>\nint main(){return getpwuid(0)==0;}\n' > kern-clo-test.c
+ emake kern-clo-test || die
+ if ! ./kern-clo-test ; then
+ eerror "Your patched vendor kernel is broken. You need to get an"
+ eerror "update from whoever is providing the kernel to you."
+ eerror "http://sourceware.org/bugzilla/show_bug.cgi?id=5227"
+ die "keeping your system alive, say thank you"
+ fi
+ fi
+
+ # users have had a chance to phase themselves, time to give em the boot
+ if [[ -e ${ROOT}/etc/locale.gen ]] && [[ -e ${ROOT}/etc/locales.build ]] ; then
+ eerror "You still haven't deleted ${ROOT}/etc/locales.build."
+ eerror "Do so now after making sure ${ROOT}/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 http://www.gentoo.org/doc/en/change-chost.xml"
+ die "please fix your CHOST"
+ fi
+
+ if [[ -n ${LT_VER} ]] ; then
+ if use nptlonly && ! use nptl ; then
+ eerror "If you want nptlonly, add nptl to your USE too ;p"
+ die "nptlonly without nptl"
+ fi
+ 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, which is probably not what you want."
+ fi
+
+ use hardened && ! gcc-specs-pie && \
+ ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
+
+ export LC_ALL=C #252802
+}
+
+fix_lib64_symlinks() {
+ # the original Gentoo/AMD64 devs decided that since 64bit is the native
+ # bitdepth for AMD64, lib should be used for 64bit libraries. however,
+ # this ignores the FHS and breaks multilib horribly... especially
+ # since it wont even work without a lib64 symlink anyways. *rolls eyes*
+ # see bug 59710 for more information.
+ # Travis Tilley <lv@gentoo.org> (08 Aug 2004)
+ if [ -L ${ROOT}/lib64 ] ; then
+ ewarn "removing /lib64 symlink and moving lib to lib64..."
+ ewarn "dont hit ctrl-c until this is done"
+ rm ${ROOT}/lib64
+ # now that lib64 is gone, nothing will run without calling ld.so
+ # directly. luckily the window of brokenness is almost non-existant
+ use amd64 && /lib/ld-linux-x86-64.so.2 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ use ppc64 && /lib/ld64.so.1 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ # all better :)
+ ldconfig
+ ln -s lib64 ${ROOT}/lib
+ einfo "done! :-)"
+ einfo "fixed broken lib64/lib symlink in ${ROOT}"
+ fi
+ if [ -L ${ROOT}/usr/lib64 ] ; then
+ rm ${ROOT}/usr/lib64
+ mv ${ROOT}/usr/lib ${ROOT}/usr/lib64
+ ln -s lib64 ${ROOT}/usr/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr"
+ fi
+ if [ -L ${ROOT}/usr/X11R6/lib64 ] ; then
+ rm ${ROOT}/usr/X11R6/lib64
+ mv ${ROOT}/usr/X11R6/lib ${ROOT}/usr/X11R6/lib64
+ ln -s lib64 ${ROOT}/usr/X11R6/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6"
+ fi
+}
+
+pkg_preinst() {
+ # nothing to do if just installing headers
+ just_headers && return
+
+ # PPC64+others may want to eventually be added to this logic if they
+ # decide to be multilib compatible and FHS compliant. note that this
+ # chunk of FHS compliance only applies to 64bit archs where 32bit
+ # compatibility is a major concern (not IA64, for example).
+
+ # amd64's 2005.0 is the first amd64 profile to not need this code.
+ # 2005.0 is setup properly, and this is executed as part of the
+ # 2004.3 -> 2005.0 upgrade script.
+ # It can be removed after 2004.3 has been purged from portage.
+ { use amd64 || use ppc64; } && [ "$(get_libdir)" == "lib64" ] && ! has_multilib_profile && fix_lib64_symlinks
+
+ # it appears that /lib/tls is sometimes not removed. See bug
+ # 69258 for more info.
+ if [[ -d ${ROOT}/$(alt_libdir)/tls ]] && [[ ! -d ${D}/$(alt_libdir)/tls ]] ; then
+ ewarn "nptlonly or -nptl in USE, removing /${ROOT}$(alt_libdir)/tls..."
+ rm -r "${ROOT}"/$(alt_libdir)/tls || die
+ fi
+
+ # Shouldnt need to keep this updated
+ [[ -e ${ROOT}/etc/locale.gen ]] && rm -f "${D}"/etc/locale.gen
+
+ # simple test to make sure our new glibc isnt 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.
+ [[ ${ROOT} != "/" ]] && return 0
+ [[ -d ${D}/$(get_libdir) ]] || return 0
+ cd / #228809
+ local x striptest
+ for x in date env ls true uname ; do
+ x=$(type -p ${x})
+ [[ -z ${x} ]] && continue
+ striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null)
+ [[ -z ${striptest} ]] && continue
+ [[ ${striptest} == *"statically linked"* ]] && continue
+ "${D}"/$(get_libdir)/ld-*.so \
+ --library-path "${D}"/$(get_libdir) \
+ ${x} > /dev/null \
+ || die "simple run test (${x}) failed"
+ done
+}
+
+pkg_postinst() {
+ # nothing to do if just installing headers
+ just_headers && return
+
+ if ! tc-is-cross-compiler && [[ -x ${ROOT}/usr/sbin/iconvconfig ]] ; then
+ # Generate fastloading iconv module configuration file.
+ "${ROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
+ fi
+
+ if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
+ # Reload init ...
+ /sbin/telinit U
+
+ # if the host locales.gen contains no entries, we'll install everything
+ 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
+ local x jobs
+ for x in ${MAKEOPTS} ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done
+ locale-gen -j ${jobs:-1} --config "${locale_list}"
+ fi
+}
diff --git a/sys-libs/glibc/glibc-2.8_p20080602-r1.ebuild b/sys-libs/glibc/glibc-2.8_p20080602-r1.ebuild
new file mode 100644
index 0000000..ad59dc4
--- /dev/null
+++ b/sys-libs/glibc/glibc-2.8_p20080602-r1.ebuild
@@ -0,0 +1,375 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/Attic/glibc-2.8_p20080602-r1.ebuild,v 1.21 2011/03/20 22:22:24 vapier dead $
+
+inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib
+
+DESCRIPTION="GNU libc6 (also called glibc2) C library"
+HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
+
+LICENSE="LGPL-2"
+KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 s390 sh sparc x86"
+RESTRICT="strip" # strip ourself #46186
+EMULTILIB_PKG="true"
+
+# Configuration variables
+if [[ ${PV} == *_p* ]] ; then
+RELEASE_VER=${PV%_p*}
+BRANCH_UPDATE=""
+SNAP_VER=${PV#*_p}
+else
+RELEASE_VER=${PV}
+BRANCH_UPDATE=""
+SNAP_VER=""
+fi
+MANPAGE_VER="" # pregenerated manpages
+INFOPAGE_VER="" # pregenerated infopages
+PATCH_VER="6" # Gentoo patchset
+PORTS_VER=${RELEASE_VER} # version of glibc ports addon
+LIBIDN_VER="" # version of libidn addon
+LT_VER="" # version of linuxthreads addon
+NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"} # min kernel version nptl requires
+#LT_KERN_VER=${LT_KERN_VER:-"2.4.1"} # min kernel version linuxthreads requires
+
+IUSE="debug gd glibc-omitfp hardened multilib nls selinux profile vanilla crosscompile_opts_headers-only ${LT_VER:+glibc-compat20 nptl nptlonly}"
+S=${WORKDIR}/glibc-${RELEASE_VER}${SNAP_VER+-${SNAP_VER}}
+
+# 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-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+
+[[ ${CTARGET} == hppa* ]] && NPTL_KERN_VER=${NPTL_KERN_VER/2.6.9/2.6.20}
+
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+alt_libdir() {
+ if is_crosscompile ; then
+ echo /usr/${CTARGET}/$(get_libdir)
+ else
+ echo /$(get_libdir)
+ fi
+}
+
+if is_crosscompile ; then
+ SLOT="${CTARGET}-2.2"
+else
+ # Why SLOT 2.2 you ask yourself while sippin your tea ?
+ # Everyone knows 2.2 > 0, duh.
+ SLOT="2.2"
+ PROVIDE="virtual/libc"
+fi
+
+# General: We need a new-enough binutils for as-needed
+# arch: we need to make sure our binutils/gcc supports TLS
+DEPEND=">=sys-devel/gcc-3.4.4
+ arm? ( >=sys-devel/binutils-2.16.90 >=sys-devel/gcc-4.1.0 )
+ ppc? ( >=sys-devel/gcc-4.1.0 )
+ ppc64? ( >=sys-devel/gcc-4.1.0 )
+ >=sys-devel/binutils-2.15.94
+ ${LT_VER:+nptl? (} >=sys-kernel/linux-headers-${NPTL_KERN_VER} ${LT_VER:+)}
+ >=sys-devel/gcc-config-1.3.12
+ >=app-misc/pax-utils-0.1.10
+ virtual/os-headers
+ nls? ( sys-devel/gettext )
+ >=sys-apps/sandbox-1.2.18.1-r2
+ !<sys-apps/portage-2.1.2
+ selinux? ( sys-libs/libselinux )"
+RDEPEND="nls? ( sys-devel/gettext )
+ selinux? ( sys-libs/libselinux )"
+
+if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ DEPEND="${DEPEND} !crosscompile_opts_headers-only? ( ${CATEGORY}/gcc )"
+ [[ ${CATEGORY} == *-linux* ]] && DEPEND="${DEPEND} ${CATEGORY}/linux-headers"
+else
+ DEPEND="${DEPEND} >=sys-libs/timezone-data-2007c"
+ RDEPEND="${RDEPEND} sys-libs/timezone-data"
+fi
+
+SRC_URI=$(
+ upstream_uris() {
+ echo mirror://gnu/glibc/$1 ftp://sources.redhat.com/pub/glibc/{releases,snapshots}/$1 mirror://gentoo/$1
+ }
+ gentoo_uris() {
+ local devspace="HTTP~vapier/dist/URI HTTP~azarah/glibc/URI"
+ devspace=${devspace//HTTP/http://dev.gentoo.org/}
+ echo mirror://gentoo/$1 ${devspace//URI/$1}
+ }
+
+ TARNAME=${PN}
+ if [[ -n ${SNAP_VER} ]] ; then
+ TARNAME="${PN}-${RELEASE_VER}"
+ [[ -n ${PORTS_VER} ]] && PORTS_VER=${SNAP_VER}
+ upstream_uris ${TARNAME}-${SNAP_VER}.tar.bz2
+ else
+ upstream_uris ${TARNAME}-${RELEASE_VER}.tar.bz2
+ fi
+ [[ -n ${LIBIDN_VER} ]] && upstream_uris glibc-libidn-${LIBIDN_VER}.tar.bz2
+ [[ -n ${PORTS_VER} ]] && upstream_uris ${TARNAME}-ports-${PORTS_VER}.tar.bz2
+ [[ -n ${LT_VER} ]] && upstream_uris ${TARNAME}-linuxthreads-${LT_VER}.tar.bz2
+ [[ -n ${BRANCH_UPDATE} ]] && gentoo_uris glibc-${RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+ [[ -n ${PATCH_VER} ]] && gentoo_uris glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2
+ [[ -n ${MANPAGE_VER} ]] && gentoo_uris glibc-manpages-${MANPAGE_VER}.tar.bz2
+ [[ -n ${INFOPAGE_VER} ]] && gentoo_uris glibc-infopages-${INFOPAGE_VER}.tar.bz2
+)
+
+# eblit-include [--skip] <function> [version]
+eblit-include() {
+ local skipable=false
+ [[ $1 == "--skip" ]] && skipable=true && shift
+
+ local e v func=$1 ver=$2
+ [[ -z ${func} ]] && die "Usage: eblit-include <function> [version]"
+ for v in ${ver:+-}${ver} -${PVR} -${PV} "" ; do
+ e="${FILESDIR}/eblits/${func}${v}.eblit"
+ if [[ -e ${e} ]] ; then
+ source "${e}"
+ return 0
+ fi
+ done
+ ${skipable} && return 0
+ die "Could not locate requested eblit '${func}' in ${FILESDIR}/eblits/"
+}
+
+# eblit-run-maybe <function>
+# run the specified function if it is defined
+eblit-run-maybe() {
+ [[ $(type -t "$@") == "function" ]] && "$@"
+}
+
+# eblit-run <function> [version]
+# aka: src_unpack() { eblit-run src_unpack ; }
+eblit-run() {
+ eblit-include --skip common "${*:2}"
+ eblit-include "$@"
+ eblit-run-maybe eblit-$1-pre
+ eblit-${PN}-$1 || die
+ eblit-run-maybe eblit-$1-post
+}
+
+src_unpack() { eblit-run src_unpack ; }
+src_compile() { eblit-run src_compile ; }
+src_test() { eblit-run src_test ; }
+src_install() { eblit-run src_install ; }
+
+eblit-src_unpack-post() {
+ if use hardened ; then
+ cd "${S}"
+ einfo "Patching to get working PIE binaries on PIE (hardened) platforms"
+ gcc-specs-pie && epatch "${FILESDIR}"/2.5/glibc-2.5-hardened-pie.patch
+ epatch "${FILESDIR}"/2.5/glibc-2.5-hardened-configure-picdefault.patch
+ epatch "${FILESDIR}"/2.7/glibc-2.7-hardened-inittls-nosysenter.patch
+
+ einfo "Installing Hardened Gentoo SSP handler"
+ cp -f "${FILESDIR}"/2.6/glibc-2.6-gentoo-stack_chk_fail.c \
+ debug/stack_chk_fail.c || die
+
+ if use debug ; then
+ # When using Hardened Gentoo stack handler, have smashes dump core for
+ # analysis - debug only, as core could be an information leak
+ # (paranoia).
+ sed -i \
+ -e '/^CFLAGS-backtrace.c/ iCFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
+ debug/Makefile \
+ || die "Failed to modify debug/Makefile for debug stack handler"
+ fi
+
+ # Build nscd with ssp-all
+ sed -i \
+ -e 's:-fstack-protector$:-fstack-protector-all:' \
+ nscd/Makefile \
+ || die "Failed to ensure nscd builds with ssp-all"
+ fi
+}
+
+maint_pkg_create() {
+ local base="/usr/local/src/gnu/glibc/glibc-${PV:0:1}_${PV:2:1}"
+ cd ${base}
+ local stamp=$(date +%Y%m%d)
+ local d
+ for d in libc ports ; do
+ #(cd ${d} && cvs up)
+ case ${d} in
+ libc) tarball="${P}";;
+ ports) tarball="${PN}-ports-${PV}";;
+ esac
+ rm -f ${tarball}*
+ ln -sf ${d} ${tarball}
+ tar hcf - ${tarball} --exclude-vcs | lzma > "${T}"/${tarball}.tar.lzma
+ du -b "${T}"/${tarball}.tar.lzma
+ done
+}
+
+pkg_setup() {
+ # prevent native builds from downgrading ... maybe update to allow people
+ # to change between diff -r versions ? (2.3.6-r4 -> 2.3.6-r2)
+ if [[ ${ROOT} == "/" ]] && [[ ${CBUILD} == ${CHOST} ]] && [[ ${CHOST} == ${CTARGET} ]] ; then
+ if has_version '>'${CATEGORY}/${PF} ; 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
+
+ # Check for broken kernels #262698
+ cd "${T}"
+ printf '#include <pwd.h>\nint main(){return getpwuid(0)==0;}\n' > kern-clo-test.c
+ emake kern-clo-test || die
+ if ! ./kern-clo-test ; then
+ eerror "Your patched vendor kernel is broken. You need to get an"
+ eerror "update from whoever is providing the kernel to you."
+ eerror "http://sourceware.org/bugzilla/show_bug.cgi?id=5227"
+ die "keeping your system alive, say thank you"
+ fi
+ fi
+
+ # users have had a chance to phase themselves, time to give em the boot
+ if [[ -e ${ROOT}/etc/locale.gen ]] && [[ -e ${ROOT}/etc/locales.build ]] ; then
+ eerror "You still haven't deleted ${ROOT}/etc/locales.build."
+ eerror "Do so now after making sure ${ROOT}/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 http://www.gentoo.org/doc/en/change-chost.xml"
+ die "please fix your CHOST"
+ fi
+
+ if [[ -n ${LT_VER} ]] ; then
+ if use nptlonly && ! use nptl ; then
+ eerror "If you want nptlonly, add nptl to your USE too ;p"
+ die "nptlonly without nptl"
+ fi
+ 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, which is probably not what you want."
+ fi
+
+ use hardened && ! gcc-specs-pie && \
+ ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
+
+ export LC_ALL=C #252802
+}
+
+fix_lib64_symlinks() {
+ # the original Gentoo/AMD64 devs decided that since 64bit is the native
+ # bitdepth for AMD64, lib should be used for 64bit libraries. however,
+ # this ignores the FHS and breaks multilib horribly... especially
+ # since it wont even work without a lib64 symlink anyways. *rolls eyes*
+ # see bug 59710 for more information.
+ # Travis Tilley <lv@gentoo.org> (08 Aug 2004)
+ if [ -L ${ROOT}/lib64 ] ; then
+ ewarn "removing /lib64 symlink and moving lib to lib64..."
+ ewarn "dont hit ctrl-c until this is done"
+ rm ${ROOT}/lib64
+ # now that lib64 is gone, nothing will run without calling ld.so
+ # directly. luckily the window of brokenness is almost non-existant
+ use amd64 && /lib/ld-linux-x86-64.so.2 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ use ppc64 && /lib/ld64.so.1 /bin/mv ${ROOT}/lib ${ROOT}/lib64
+ # all better :)
+ ldconfig
+ ln -s lib64 ${ROOT}/lib
+ einfo "done! :-)"
+ einfo "fixed broken lib64/lib symlink in ${ROOT}"
+ fi
+ if [ -L ${ROOT}/usr/lib64 ] ; then
+ rm ${ROOT}/usr/lib64
+ mv ${ROOT}/usr/lib ${ROOT}/usr/lib64
+ ln -s lib64 ${ROOT}/usr/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr"
+ fi
+ if [ -L ${ROOT}/usr/X11R6/lib64 ] ; then
+ rm ${ROOT}/usr/X11R6/lib64
+ mv ${ROOT}/usr/X11R6/lib ${ROOT}/usr/X11R6/lib64
+ ln -s lib64 ${ROOT}/usr/X11R6/lib
+ einfo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6"
+ fi
+}
+
+pkg_preinst() {
+ # nothing to do if just installing headers
+ just_headers && return
+
+ # PPC64+others may want to eventually be added to this logic if they
+ # decide to be multilib compatible and FHS compliant. note that this
+ # chunk of FHS compliance only applies to 64bit archs where 32bit
+ # compatibility is a major concern (not IA64, for example).
+
+ # amd64's 2005.0 is the first amd64 profile to not need this code.
+ # 2005.0 is setup properly, and this is executed as part of the
+ # 2004.3 -> 2005.0 upgrade script.
+ # It can be removed after 2004.3 has been purged from portage.
+ { use amd64 || use ppc64; } && [ "$(get_libdir)" == "lib64" ] && ! has_multilib_profile && fix_lib64_symlinks
+
+ # it appears that /lib/tls is sometimes not removed. See bug
+ # 69258 for more info.
+ if [[ -d ${ROOT}/$(alt_libdir)/tls ]] && [[ ! -d ${D}/$(alt_libdir)/tls ]] ; then
+ ewarn "nptlonly or -nptl in USE, removing /${ROOT}$(alt_libdir)/tls..."
+ rm -r "${ROOT}"/$(alt_libdir)/tls || die
+ fi
+
+ # simple test to make sure our new glibc isnt 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.
+ [[ ${ROOT} != "/" ]] && return 0
+ [[ -d ${D}/$(get_libdir) ]] || return 0
+ cd / #228809
+ local x striptest
+ for x in date env ls true uname ; do
+ x=$(type -p ${x})
+ [[ -z ${x} ]] && continue
+ striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null)
+ [[ -z ${striptest} ]] && continue
+ [[ ${striptest} == *"statically linked"* ]] && continue
+ "${D}"/$(get_libdir)/ld-*.so \
+ --library-path "${D}"/$(get_libdir) \
+ ${x} > /dev/null \
+ || die "simple run test (${x}) failed"
+ done
+}
+
+pkg_postinst() {
+ # nothing to do if just installing headers
+ just_headers && return
+
+ if ! tc-is-cross-compiler && [[ -x ${ROOT}/usr/sbin/iconvconfig ]] ; then
+ # Generate fastloading iconv module configuration file.
+ "${ROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
+ fi
+
+ if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
+ # Reload init ...
+ /sbin/telinit U
+
+ # if the host locales.gen contains no entries, we'll install everything
+ 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
+ local x jobs
+ for x in ${MAKEOPTS} ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done
+ locale-gen -j ${jobs:-1} --config "${locale_list}"
+ fi
+}