Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7 support #30

Open
markjeffries opened this issue Nov 5, 2015 · 32 comments
Open

PHP 7 support #30

markjeffries opened this issue Nov 5, 2015 · 32 comments

Comments

@markjeffries
Copy link

Hi,

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

regards

Mark

@pilif
Copy link
Member

pilif commented Nov 5, 2015

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

@absalomedia
Copy link

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

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

@markjeffries
Copy link
Author

Great, thanks for the info!

@absalomedia
Copy link

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
Copy link
Author

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

best regards

Mark

On 10 November 2015 at 05:35, Lawrence Meckan [email protected]
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
#30 (comment).

@absalomedia
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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

I'm confident it builds successfully under PHP7.

@asterixcapri
Copy link

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
Copy link

@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
Copy link

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

@studdugie
Copy link

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
Copy link

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
Copy link

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 [email protected]
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
#30 (comment).

@asterixcapri
Copy link

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
Copy link

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
Copy link

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
Copy link

@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
Copy link

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
Copy link

@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
Copy link

Now have an updated pull request with Libsass 3.3.3 & latest raft of PHP7 changes #32

@studdugie
Copy link

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/file_comments.phpt]
*_* stack smashing detected **: /usr/bin/php7.0 terminated
FAIL compiles correct Sass file and provides source embedding [tests/file_embed.phpt]
*
* stack smashing detected **: /usr/bin/php7.0 terminated
FAIL compiles SASS file in comparison to SCSS based SASS file [tests/file_indent.phpt]
*
* stack smashing detected **: /usr/bin/php7.0 terminated
FAIL correctly handles setting and getting comments [tests/handles_comments.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_include_path.phpt]
*
* stack smashing detected ***: /usr/bin/php7.0 terminated
FAIL correctly handles setting and getting SCSS / SASS file indents [tests/handles_indent.phpt]

@studdugie
Copy link

It's still segfaulting.

@mandersondesign
Copy link

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
Copy link

@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
Copy link

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

@gocart
Copy link

gocart commented May 21, 2016

+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
Copy link

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

@s4msung
Copy link

s4msung commented May 8, 2017

+1

1 similar comment
@paolo-g
Copy link

paolo-g commented Dec 28, 2017

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants