PHP4 (cli version) doesn't follow ZTS rules of apache module... I emerged mod_php on my system. I've enabled thread support in apache2. mod_php correctly detects thread support in apache2 and builds module with ZTS enabled. Then php is emerged with ZTS disabled. I emerged then turck-mmcache and it's build ZTS off (using rules from php module, not mod_php)... This module can't work... Ebuild I propose integrates such apache threading detection as in mod_php and to automatically enable ZTS in php (cli version) too. This corrected the problem for me...
Created attachment 40400 [details] php-4.3.8-r1.ebuild
You cannot use the cli from the mod_php version without some breakages happening. A different solution must be found - probably a ZTS use flag.
I didn't use cli from mod_php ebuild but from php ebuild. I saw a dependancy beween mod_php and php ebuild. The problem I tried to solve is 'php-config' script witch is called by other ebuild (php-ext-source_src_compile I suppose). Another possibility is to modify this function to generate both ZTS and non-ZTS versions when Apache2 is threaded. ZTS use flag seems good, but should then be implemented in all php module (modify portage php-ext-source class?). What did you mean with "some breakages"? Which packages? (I'm a newbie in ebuild buiding...). The problem could be that extensions emerged before apache (treads on) + php (ZTS on, then) are not working any more and sould be re-emerged.
Please test with the latest version of PHP that is available in portage (currently) PHP 4.3.11 and reopen if the problem persists.