chobie / php-uv

libuv php extension
185 stars 21 forks source link

undefined symbol: clock_gettime when running on ubuntu 12.04 64 bit #24

Open jimthunderbird opened 12 years ago

jimthunderbird commented 12 years ago

I tried to compile php-uv with gcc 4.6.3 on ubuntu 12.04 64 bit box, it compiled successfully but when i run uv_default_loop() in the code, it says: undefined symbol: clock_gettime

Best Regards, Jim

chobie commented 12 years ago

hmm, it's strange. I've tested php-uv on Ubuntu 11.04 64bit box but I didn't meet the error.

clock_gettime depends librt and I specified it in config.m4.

https://github.com/chobie/php-uv/blob/master/config.m4#L71

for now, can you re-create php-uv module?

phpize --clean
phpize
./configure
make

I'll make ubuntu 12.04 64bit box and test this.

jimthunderbird commented 12 years ago

I tried the solution above, it does not work.

The symptom is, the uv.so is recognized correctly in php -m, but when i run a script with a uv_default_loop function call, it said: symbol lookup error, ... undefined symbol: clock_gettime

jimthunderbird commented 12 years ago

I just verified ubuntu 11.04 64bit works fine, so at this point, i think the issue is realted to either a ubuntu version difference or gcc version difference.

jimthunderbird commented 12 years ago

For ubuntu 12.04 64 bit now, I did a hack to make it work by using gcc 4.4.7.

Here is what I did:

apt-get install gcc-4.4 ln -s /usr/bin/gcc-4.4 /usr/bin/cc ln -s /usr/bin/gcc-4.4 /usr/bin/gcc

After this recompile everything and things start working, but ideally, it should work for the latest gcc

chobie commented 12 years ago

I see. I'll modify config.m4 for latest gcc.

jimthunderbird commented 12 years ago

Great!

chobie commented 12 years ago

I spend some hours to fix this. But I couldn't fix at this moment. for now, please use gcc-4.4.7. I have to learn libtool and autoconf more deeply. so this may take a long time.

lucian303 commented 12 years ago

Even with gcc-4.4.7 I'm still getting this. I'll give it another shot and see if I can get it to compile with the older gcc. It's likely I'm missing something. Or perhaps other parts of the build chain need to be downgraded as well? It's a clean install of Ubuntu 12.04.01 64bit.

jimthunderbird commented 12 years ago

I did not try 10.04 64 bit yet, Di you try ubuntu 11.04 64bit?

lucian303 commented 12 years ago

Oops, sorry, I meant 12.04. I'll edit.

lucian303 commented 12 years ago

I recompiled php-uv by hand with the older gcc (4.4) on ubuntu 12.04.01 64bit and I can verify it works on there.

chrsm commented 11 years ago

Hi folks, just thought I'd drop this note here after struggling with the same thing.

After trying, for a while, unsuccessfully to get librt to be linked properly in the makefile, I went ahead and executed:

export LD_PRELOAD=/lib/x86_64-linux-gnu/librt.so.1

Prior to starting up my instance (i.e. if you're using apache/nginx or php5-fpm) and it works fine. It's a hack, but it works.

chobie commented 11 years ago

@chrsm thank you. i'll re-construct my ubuntu box and try to improve config.m4 later.

romainneutron commented 11 years ago

using export LD_PRELOAD=/lib/x86_64-linux-gnu/librt.so.1, compilation is OK, but I got a segfault when using uv_run_once() (in phpuv.c at line 3370)

I'll post a backtrace soon

chobie commented 11 years ago

I compiled latest php-uv with gcc 4.6.3 but can not reproduce this problem. I'd like to fix this but i don't have good idea...

chobie:~/src/php-uv$ uname -a
Linux  3.2.0-35-generic #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

chobie:~/src/php-uv$ cat /etc/issue
Ubuntu 12.04.1 LTS \n \l

chobie:~/src/php-uv$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc-4.6.real
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --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.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --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.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 
romainneutron commented 11 years ago

heu @chobie , I think it requires GCC 4.7, available on ubuntu 12.10

I'm not at my office, I can confirm that later

xming commented 11 years ago

Do you have -lrt on the last linking line? Pasting the compiler/linker output may help.

cboden commented 11 years ago

When I run a make test before installing php-uv all the tests fail with:

PHP Warning: PHP Startup: Unable to load dynamic library '/home/dev/php-uv/modules/uv.so' - /home/dev/php-uv/modules/uv.so: undefined symbol: clock_gettime in Unknown on line 0

Here is my system info:

dev@reactor:~$ uname -a
Linux reactor 3.5.0-18-generic #29-Ubuntu SMP Fri Oct 19 10:26:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
dev@reactor:~$ cat /etc/issue
Ubuntu 12.10 \n \l

dev@reactor:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --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.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --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.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1)

I will install an older version of gcc, as proposed above, in the mean time.

cboden commented 11 years ago

Tested with gcc/cpp 4.4, 4.6, and 4.7. Everything works on 4.4 but I get the above error on 4.6 and 4.7. Let me know if there's any debug info I can send you to help!