-   Programming (
-   -   phc is generating incomplete code? (

eantoranz 05-27-2012 07:30 PM

phc is generating incomplete code?

I just compiled phc against php 5.2. Now, when I call phc to compile a simple php file, I get a 256 error from g++.


$ /usr/local/phc/bin/phc -c Hello.php -o hello
Error: gcc exited with error 256 (executed via 'gcc -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -L/usr/local/php/lib -Wl,-R/usr/local/php/lib -lphp5 -xc - -ggdb3 -O0 -ohello ')

So, I asked phc to generate C code and saved it into a file. When I tried to compile it, no surprises, it fails.... when I se the generated code, I find that main is incomplete.

File ends up like this:


main (int argc, char* argv[])
  int phc_exit_status;
  signal(SIGABRT, sighandler);
  signal(SIGSEGV, sighandler);

  php_embed_init (argc, argv PTSRMLS_CC);

      // load the compiled extension
      zend_startup_module (&app_module_entry);

      zval main_name;
      ZVAL_STRING (&main_name, "__MAIN__", NULL);

      zval retval;

Just like that. What's going on?

eantoranz 05-27-2012 10:06 PM

Well..... this is very weird. I think the problem is in the parameters that g++ is getting when being called from phc (which, by the way, is the same problem that the compilation of phc was about).

If you recall ( I had to manually pass the linker some -L and -l parameters with -Wl (was there a change in the way g++ passes this parameters since the days of the last phc release?).

So..... I was able to make phc compile my php program by passing this additional parameters:


-C "-Wl\,-L/usr/local/php/lib" -C "-Wl\,-L/usr/local/boost/lib" -C "-Wl\,-lphp5" -C "-Wl\,-lboost_regex"

All times are GMT -5. The time now is 06:11 PM.