Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

How to install pthreads extension as a shared extension. #2

Closed
chobie opened this issue Sep 15, 2012 · 9 comments
Closed

How to install pthreads extension as a shared extension. #2

chobie opened this issue Sep 15, 2012 · 9 comments

Comments

@chobie
Copy link

chobie commented Sep 15, 2012

Hi I'm interested in how to use TSRM API correctly as I'm playing php-uv (libuv extension).
your project is very good reference about TSRM I've ever seen!

anyway, how to install this extension as a shared extension?
some unexported functions (e.g zend_activate ...) used in pthreads_object.h and shared extension can't resolve those.

on OSX.

dyld: lazy symbol binding failed: Symbol not found: _zend_activate
  Referenced from: /Users/chobie/src/pthreads/modules/pthreads.so
  Expected in: flat namespace

btw, I've tested with static extension and it seems good.

cd php-5.4.7
(cd ext && git clone git://github.com/krakjoe/pthreads.git)
./buildconf --force
# and add --enable-pthreads, --with-tsrm-pthreads and --enable-maintainer-zts options to ./configure and make install.

Thanks,

@krakjoe
Copy link
Owner

krakjoe commented Sep 16, 2012

Should be fixed in latest commit, can you confirm ?

@chobie
Copy link
Author

chobie commented Sep 18, 2012

let me take a look. maybe I'll send a patch for this.

@chobie
Copy link
Author

chobie commented Sep 21, 2012

sorry, I can't find how to fix this problem. probably this extension should be compile with php on linux machine.

here is my report.

Install pthreads extension as a shared lib.

cd ~/
git clone git://github.com/krakjoe/pthreads.git
cd pthreads
phpize
./configure
make
make install
# and add extension=pthreads.so to php.ini

run a thread

chobie@ubuntu:~/src/pthreads$ php -r 'class T extends Thread{function run(){}};$t = new T();$t->start();'
php: symbol lookup error: /home/chobie/.phpenv/versions/5.4.6-zts/lib/php/extensions/no-debug-zts-20100525/pthreads.so: undefined symbol: zend_activate

can't find zend_activate symbol.

okay, check zend_activate symbols

chobie@ubuntu:~/src/pthreads$ nm modules/pthreads.so | grep zend_activate
                 U zend_activate
                 U zend_activate_modules
chobie@ubuntu:~/src/pthreads$ readelf --dyn-syms /home/chobie/.phpenv/versions/5.4.6-zts/bin/php | grep zend_activate
  2206: 00000000007c9920    35 FUNC    GLOBAL DEFAULT   13 zend_activate_auto_global

there is no zend_activate symbol on php's dynamic symbols table. so pthreads extension can't lookup the function I think.

build environment

================================================================================
BUILD ENVIRONMENT
================================================================================
OS:
Linux - Linux ubuntu 3.2.0-24-generic #37-Ubuntu SMP Wed Apr 25 08:43:22 UTC 2012 x86_64

Autoconf:
autoconf (GNU Autoconf) 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>, <http://gnu.org/licenses/exceptions.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David J. MacKenzie and Akim Demaille.

Bundled Libtool:
ltmain.sh (GNU libtool) 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)

Copyright (C) 2008  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

System Libtool:
libtool (GNU libtool) 2.4.2
Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996

Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiler:
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.7-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.7 (Ubuntu/Linaro 4.4.7-1ubuntu2) 

Bison:
bison (GNU Bison) 2.5
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thanks

@krakjoe
Copy link
Owner

krakjoe commented Sep 21, 2012

I have a solution to this that presents an opportunity for some optimization, but haven't the time to implement it for a few days. It will be fixed in the next week or so ... hope you're getting on with it otherwise ...

@krakjoe
Copy link
Owner

krakjoe commented Sep 21, 2012

I'm afraid that after a closer look, this cannot be reasonable solved. Copying these functions into the pthreads source will be a maintenance nightmare ...
So I'm going to have to close this as a non-issue, pthreads will have to be statically compiled for now, it's not worth the instability, sorry.

@krakjoe krakjoe closed this as completed Sep 21, 2012
@chobie
Copy link
Author

chobie commented Sep 21, 2012

no problem, thank you!

@krakjoe
Copy link
Owner

krakjoe commented Sep 23, 2012

Just to give you an update, you can now build shared ... I still don't recommend it, but it's got to be an option for testing, and so it is ... in production you should compile statically, initialization of the threads environment is less than optimal when loading pthreads as a DSO.

@chobie
Copy link
Author

chobie commented Sep 24, 2012

@krakjoe Thank you. this would be helpful that testing pthreads features.

Just to give you an update, you can now build shared ... I still don't recommend it, but it's got to be an option for testing, and so it is ... in production you should compile statically, initialization of the threads environment is less than optimal when loading pthreads as a DSO.

i think you should add this attention to README.md.

@jasondavis
Copy link

Thanks Joe, glad you got this working. You're awesome!

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants