sensational / sassphp

PHP bindings to libsass - fast, native Sass parsing in PHP!
Other
229 stars 39 forks source link

PHP 7 support #30

Open markjeffries opened 9 years ago

markjeffries commented 9 years ago

Hi,

Do you have any plans to work on the extension for PHP 7?

regards

Mark

pilif commented 9 years ago

yes. I will start porting in the next month or two unless somebody wants to send a PR :-)

absalomedia commented 9 years ago

PHP7 shouldn't be that hard to refactor for. I'm midway through already.

https://travis-ci.org/absalomedia/sassphp/jobs/89573716

markjeffries commented 9 years ago

Great, thanks for the info!

absalomedia commented 9 years ago

Well I have a successful build for PHP7: https://travis-ci.org/absalomedia/sassphp/jobs/90245122 I'll start cherry picking stuff ready for a PR

markjeffries commented 9 years ago

Great news! We'll test it once it's ready.

best regards

Mark

On 10 November 2015 at 05:35, Lawrence Meckan notifications@github.com wrote:

Well I have a successful build for PHP7: https://travis-ci.org/absalomedia/sassphp/jobs/90245122 I'll start cherry picking stuff ready for a PR

— Reply to this email directly or view it on GitHub https://github.com/sensational/sassphp/issues/30#issuecomment-155298611.

absalomedia commented 9 years ago

PR done #31

The fixes I've done also resolve #23 as for some reason I fixed it in my build but somehow the documentation didn't merge correctly.

studdugie commented 8 years ago

Hello. Any idea about when this will be merged? It's the only thing stopping me from putting PHP7 into production. If you need me to help test it or anything please let me know.

Regards,

Dane

absalomedia commented 8 years ago

Only thing I've had repeated issues on is Travis segfaulting when trying to run PHPT data. It builds ok, passes all tests locally it's just Travis don't like my test setup for some reason.

studdugie commented 8 years ago

That's great news! Unfortunately git/github is not my normal stomping ground so I need some guidance. Where can I get your sources so I can build it and test my program against it?

absalomedia commented 8 years ago

Here: https://github.com/absalomedia/sassphp

I'm confident it builds successfully under PHP7.

asterixcapri commented 8 years ago

I cloned https://github.com/absalomedia/sassphp repository and the build was successfully. But when i run this simple script I receive a segmentation fault:

$sass = new \Sass();
echo $sass->compileFile(\file_get_contents("test.scss"))."\n";

This is test.scss

$color:#f60;
.error { color:$color; }

I'm building against php 7.0.1.

Alex

absalomedia commented 8 years ago

@asterixcapri,

This is from the PHPT file that tests file compilation:

$sass = new Sass();
$css = $sass->compileFile('tests/support/test.scss');
echo $css;

You shouldn't need to a file_get_contents call to get the output.

asterixcapri commented 8 years ago

Sorry, you are right, file_get_contents is not necessary. But the segmentation fault is happen anyway.

studdugie commented 8 years ago

Hello,

Any progress on the segmentation fault? I'm trying to go live w/ PHP7 next week Tuesday and I don't have a work around for this so any progress would be greatly, greatly, greatly appreciated!

absalomedia commented 8 years ago

I'm building on Debian & Travis. I'm still working on getting stack traces from them. It might help if I had the stack dump from @asterixcapri as well.

studdugie commented 8 years ago

Just provide some instructions on exactly what it is you need me to do (e.g., tools to install, commands to run, etc) and it will be done.

Thanks,

Dane

On Wed, Jan 13, 2016 at 7:02 PM, Lawrence Meckan notifications@github.com wrote:

I'm building on Debian & Travis. I'm still working on getting stack traces from them. It might help if I had the stack dump from @asterixcapri https://github.com/asterixcapri as well.

— Reply to this email directly or view it on GitHub https://github.com/sensational/sassphp/issues/30#issuecomment-171476996.

asterixcapri commented 8 years ago
root@salsalab:/usr/src/sassphp-absalomedia# cat test.php 
<?php

$sass = new \Sass();
echo $sass->compileFile("test.scss")."\n";

root@salsalab:/usr/src/sassphp-absalomedia# cat test.scss 
$color:#f60;
.error { color:$color; }
root@salsalab:/usr/src/sassphp-absalomedia# /usr/src/php-7.0.1/sapi/cli/php test.php 
Segmentation fault (core dumped)
root@salsalab:/usr/src/sassphp-absalomedia# gdb /usr/src/php-7.0.1/sapi/cli/php core 
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/src/php-7.0.1/sapi/cli/php...done.
[New LWP 28314]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/src/php-7.0.1/sapi/cli/php test.php'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  zend_parse_arg_string (check_null=<optimized out>, dest_len=<optimized out>, dest=<optimized out>, arg=<optimized out>)
    at /usr/src/php-7.0.1/Zend/zend_API.h:1132
1132            *dest_len = ZSTR_LEN(str);
(gdb) bt
#0  zend_parse_arg_string (check_null=<optimized out>, dest_len=<optimized out>, dest=<optimized out>, arg=<optimized out>)
    at /usr/src/php-7.0.1/Zend/zend_API.h:1132
#1  zend_parse_arg_impl (arg_num=<optimized out>, severity=<optimized out>, error=<optimized out>, spec=<optimized out>, 
    va=<optimized out>, arg=<optimized out>) at /usr/src/php-7.0.1/Zend/zend_API.c:555
#2  zend_parse_arg (arg_num=arg_num@entry=1, arg=0x7f6b84a13150, va=0x0, spec=0x7fff91ffee08, flags=-1845498040, flags@entry=0)
    at /usr/src/php-7.0.1/Zend/zend_API.c:754
#3  0x00000000007f6eaf in zend_parse_va_args (num_args=0, type_spec=<optimized out>, va=va@entry=0x7fff91ffee58, 
    flags=flags@entry=0) at /usr/src/php-7.0.1/Zend/zend_API.c:926
#4  0x00000000007f72c9 in zend_parse_parameters (num_args=<optimized out>, type_spec=type_spec@entry=0x7f6b820a30dd "s")
    at /usr/src/php-7.0.1/Zend/zend_API.c:960
#5  0x00007f6b81f85474 in zim_Sass_compileFile (execute_data=0x7f6b84a130f0, return_value=0x7f6b84a130d0)
    at /usr/src/sassphp-absalomedia/src/sass.c:266
#6  0x000000000086edc2 in ZEND_DO_FCALL_SPEC_HANDLER () at /usr/src/php-7.0.1/Zend/zend_vm_execute.h:842
#7  0x000000000082b87b in execute_ex (ex=<optimized out>) at /usr/src/php-7.0.1/Zend/zend_vm_execute.h:414
#8  0x000000000087e267 in zend_execute (op_array=0x7f6b84a7e000, op_array@entry=0x7f6b84a5c6e0, 
    return_value=return_value@entry=0x7f6b84a13030) at /usr/src/php-7.0.1/Zend/zend_vm_execute.h:458
#9  0x00000000007eef44 in zend_execute_scripts (type=type@entry=8, retval=0x7f6b84a13030, retval@entry=0x0, 
    file_count=file_count@entry=3) at /usr/src/php-7.0.1/Zend/zend.c:1428
#10 0x00000000007932d0 in php_execute_script (primary_file=0x7fff920015b0) at /usr/src/php-7.0.1/main/main.c:2471
#11 0x000000000087fe7c in do_cli (argc=1, argv=0x10) at /usr/src/php-7.0.1/sapi/cli/php_cli.c:974
#12 0x0000000000447317 in main (argc=1, argv=0x10) at /usr/src/php-7.0.1/sapi/cli/php_cli.c:1345
absalomedia commented 8 years ago

OK. I've done a minor rewrite based on the feedback from @asterixcapri & it does build without errors on Travis. I still can't get any segfault data out of Travis when tests are being run though. Pull the latest & see what it does.

studdugie commented 8 years ago

I tried the new version and it still segfaulted. So I've gone one step more than @asterixcapri in the hope that it will help you root cause and fix this. I compiled a debug build of PHP7.0.2 so that you'll have more detail. Please note, I've used the same test script that @asterixcapri used.

I've attached the output as a text file because I haven't figured out how to stop github from screwing up the formatting. I've also attached the core file in case you want to root around in it yourself.

Good luck!

backtrace.txt core-php.zip

absalomedia commented 8 years ago

@studdugie thanks for that. The more backtraces I have, the better. Looks like the changes to the Zend Hashtable API are breaking it in PHP7.

asterixcapri commented 8 years ago
root@salsalab:/usr/src/sassphp-absalomedia# php test.php 
.error {
  color: #f60; }

Segmentation fault

With the new version now it outputs the correct result but then segfaults anyway...

absalomedia commented 8 years ago

@asterixcapri that's understandable with the changes to the Hashtable API. I think I've fixed up the Hashtable / object issue now. Travis isn't segfaulting as badly now in my latest runs

absalomedia commented 8 years ago

Now have an updated pull request with Libsass 3.3.3 & latest raft of PHP7 changes https://github.com/sensational/sassphp/pull/32

studdugie commented 8 years ago

Just built this and ran make test. During building the compiler produced the following warnings: sassphp/src/sass.c:56:26: warning: passing argument 1 of 'zend_object_std_dtor' from incompatible pointer type [-Wincompatible-pointer-types] zend_object_std_dtor(obj); ^

In file included from /usr/include/php/20151012/Zend/zend_globals.h:34:0, from /usr/include/php/20151012/Zend/zend_compile.h:657, from /usr/include/php/20151012/Zend/zend_modules.h:26, from /usr/include/php/20151012/Zend/zend_API.h:27, from /usr/include/php/20151012/main/php.h:40, from sassphp/src/php_sass.h:19, from sassphp/src/sass.c:16: /usr/include/php/20151012/Zend/zend_objects.h:29:15: note: expected 'zend_object * {aka struct _zend_object *}' but argument is of type 'sass_object * {aka struct sass_object *}' ZEND_API void zend_object_std_dtor(zend_object *object); ^

sassphp/src/sass.c: In function 'sass_create_handler': sassphp/src/sass.c:94:29: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types] sass_handlers.free_obj = sass_free_storage; ^

make test had the following failures: * stack smashing detected _: /usr/bin/php7.0 terminated FAIL compiles correct Sass file and provides source comments [tests/filecomments.phpt] ** stack smashing detected _: /usr/bin/php7.0 terminated FAIL compiles correct Sass file and provides source embedding [tests/fileembed.phpt] ** stack smashing detected _: /usr/bin/php7.0 terminated FAIL compiles SASS file in comparison to SCSS based SASS file [tests/fileindent.phpt] ** stack smashing detected _: /usr/bin/php7.0 terminated FAIL correctly handles setting and getting comments [tests/handlescomments.phpt] ** stack smashing detected _: /usr/bin/php7.0 terminated FAIL correctly handles setting and getting source embedding [tests/handles_embed.phpt] FAIL correctly handles includePath [tests/handles_includepath.phpt] ** stack smashing detected ***: /usr/bin/php7.0 terminated FAIL correctly handles setting and getting SCSS / SASS file indents [tests/handles_indent.phpt]

studdugie commented 8 years ago

It's still segfaulting.

mandersondesign commented 8 years ago

Hi,

I put this in the Pull Request, but I figured I would add it to this thread as well.

Is there any chance we can get a version of the current library that uses libsass 3.3.3 without the php7 compatibility? We are trying to use the latest version of Bourbon and Neat, but they require some things in the latest version of libsass.

Michael

absalomedia commented 8 years ago

@mandersondesign the way the codebase is designed is that it negotiates between PHP below version 7 & version 7 and above for the same functionality.

Pulling https://github.com/absalomedia/sassphp should get you a stable SASS extension that builds under PHP 5.4 to 5.6 with Libsass 3.3.3.

absalomedia commented 8 years ago

OK. We now have a stable PR with PHP7 if anyone wants to merge it in?

gocart commented 8 years ago

+1 I was able to test the pull request from @absalomedia and had no problems. Would love to see this pull request go through.

nicolasbadia commented 8 years ago

Same here, I can confirm the PR is working just fine with PHP7

s4msung commented 7 years ago

+1

paolo-g commented 6 years ago

+1