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

build: compile Xdebug 3.2.2 for PHP 8.0, 8.1, 8.2, fixes #6159 #6181

Merged
merged 2 commits into from
May 15, 2024

Conversation

stasadev
Copy link
Member

@stasadev stasadev commented May 13, 2024

The Issue

How This PR Solves The Issue

Compiles Xdebug 3.2.2 library for PHP 8.0, 8.1, 8.2.

Unfortunately we can't build Xdebug 3.2.2 for PHP 8.3:

checking Check for supported PHP versions... configure: error: not supported. Need a PHP version >= 8.0.0 and < 8.3.0 (found 8.3.7)

Xdebug Compatibility https://xdebug.org/docs/compat

Manual Testing Instructions

# check Xdebug library files in DDEV HEAD
ddev exec ls -l $(ddev exec dpkg-query -L php{8.0,8.1,8.2}-xdebug | grep xdebug.so)
# or
docker run --rm -it ddev/ddev-php-base:20240513_stasadev_debsuryorg bash -c 'ls -l $(find / -iname xdebug.so)'

# check Xdebug library files in this PR
ddev exec ls -l /usr/lib/php/20200930/xdebug.so /usr/lib/php/20210902/xdebug.so /usr/lib/php/20220829/xdebug.so
# or
docker run --rm -it ddev/ddev-php-base:v1.23.1 bash -c 'ls -l $(find / -iname xdebug.so)'

ddev config --php-version 8.2 && ddev restart && ddev xdebug && ddev php -v
ddev config --php-version 8.1 && ddev restart && ddev xdebug && ddev php -v
ddev config --php-version 8.0 && ddev restart && ddev xdebug && ddev php -v

Automated Testing Overview

Related Issue Link(s)

Release/Deployment Notes

@stasadev
Copy link
Member Author

I will make a new build of the Docker image only after the next PR goes in:

@stasadev
Copy link
Member Author

And it can be tested manually using .ddev/web-build/Dockerfile

@rfay
Copy link
Member

rfay commented May 13, 2024

Please open an issue with https://bugs.xdebug.org/my_view_page.php explaining your results with php 8.3, thanks!

@stasadev
Copy link
Member Author

Please open an issue with bugs.xdebug.org/my_view_page.php explaining your results with php 8.3, thanks!

It's not compatible (see https://xdebug.org/docs/compat) so they won't fix it.

@rfay
Copy link
Member

rfay commented May 13, 2024

Oh, I understand now, thanks.

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the right strategy to me. We just have to do some good solid testing on multiple PHP versions with and without xdebug.

@stasadev stasadev force-pushed the 20240513_stasadev_compile_xdebug branch from 41bff40 to 3b472ea Compare May 14, 2024 08:03
@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label May 14, 2024
@stasadev stasadev force-pushed the 20240513_stasadev_compile_xdebug branch from 3b472ea to df5a372 Compare May 14, 2024 10:02
@stasadev
Copy link
Member Author

stasadev commented May 14, 2024

I added a new stage for Xdebug, because the size of the Docker image ddev-php-base has grown significantly:

linux/amd64 333.86 MB => 426.51 MB
linux/arm64 327.2 MB => 414 MB

Also I added cleanup for /tmp/*, because there were leftovers from platformsh:

$ docker run --rm -it ddev/ddev-webserver:v1.23.0-1 ls -la /tmp
total 40
drwxrwxrwt 2 root root  4096 Apr 16 18:31 .
drwxr-xr-x 1 root root  4096 May 14 10:54 ..
-rw-r--r-- 1 root root  4891 Apr 16 18:30 platformsh-install-20240416-183042.log
-rw-r--r-- 1 root root  4862 Apr 16 18:30 platformsh-install-20240416-183049.log
-rw-r--r-- 1 root root 14880 Apr 16 18:30 setup.deb.sh

Building a new image.

@rfay
Copy link
Member

rfay commented May 14, 2024

I was thinking about that last night, about build-essential getting into the final image. Thanks for catching that!

@rfay

This comment was marked as outdated.

@rfay
Copy link
Member

rfay commented May 14, 2024

There is a question remaining: If we can't downgrade for PHP8.3... should we still be downgrading for PHP8.1/2?

@stasadev
Copy link
Member Author

If we can't downgrade for PHP8.3... should we still be downgrading for PHP8.1/2?

It is still supported https://www.php.net/supported-versions.php
If this PR works, it could make life easier for people who have PHP8.0/1/2.

@rfay
Copy link
Member

rfay commented May 14, 2024

Oh, dear, I didn't look at the right thing, did I? That was a previous push. The current ddev-php-base is much too big:

image

@rfay
Copy link
Member

rfay commented May 14, 2024

Oh, I see you were already building as we spoke.

@stasadev
Copy link
Member Author

Yes, but it failed after 30 minutes (connection timeout to php repo), I just restarted it again.

@stasadev stasadev force-pushed the 20240513_stasadev_compile_xdebug branch from 0c993c6 to 779ab2e Compare May 14, 2024 14:36
Copy link

@stasadev
Copy link
Member Author

I ran a basic debugging session with a single breakpoint and step over, using PHP 8.0, 8.1, 8.2.

Used Linux amd64 with PhpStorm 2023.3.6.

And tested Xdebug 3.3.2 with PHP 8.3 to make sure it works the same for me.

@stasadev stasadev marked this pull request as ready for review May 14, 2024 14:48
@stasadev stasadev requested a review from a team as a code owner May 14, 2024 14:48
@rfay
Copy link
Member

rfay commented May 14, 2024

So much better, thanks!:
image

@stasadev
Copy link
Member Author

And this works too, so we don't limit everyone to 3.2.2:

webimage_extra_packages: ['php${DDEV_PHP_VERSION}-xdebug']

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're good to go on this. You've tested carefully manually, I tested a couple of ways, code looks good. It's more complicated than I hoped, and I hope we can remove it at some point. I love the commenting, which reduces the fear factor of introducing this.

Comment on lines +45 to +46
ARG XDEBUG_VERSION="3.2.2"
ARG XDEBUG_BUILD_PACKAGES="build-essential php-pear php8.0-dev php8.1-dev php8.2-dev"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should both be ENV shouldn't they? Don't bother changing it, but they're not ARGS into the build are they? They way you have it they're just taking the assigned value because there is no ARG of this name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I used ARG because we don't want these variables to be inside the container:

$ docker run --rm -it ddev/ddev-php-base:v1.23.1 bash -c 'echo $XDEBUG_VERSION'
(nothing here)

See Docker ARG vs ENV.

But when you declare it with ENV, it will be available inside, e.g.:

$ docker run --rm -it ddev/ddev-php-base:v1.23.1 bash -c 'echo $php83_arm64'
apcu bcmath bz2 curl cli common fpm gd imagick intl ldap mbstring memcached mysql opcache pgsql readline redis soap sqlite3 uploadprogress xdebug xhprof xml xmlrpc zip

I think it doesn't really matter here, since ddev/ddev-php-base isn't what users end up with, it's empty anyway:

$ docker run --rm -it ddev/ddev-webserver:v1.23.1 bash -c 'echo $php83_arm64'
(nothing here)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is awesome, thanks, always great to learn from you! I always use them only for when there's a --build-arg one way or another, but this is a great differentiator.

RUN apt-get -qq remove -y php8.0-xdebug php8.1-xdebug php8.2-xdebug
COPY --from=ddev-xdebug-build /usr/lib/php/20200930/xdebug.so /usr/lib/php/20200930/xdebug.so
COPY --from=ddev-xdebug-build /usr/lib/php/20210902/xdebug.so /usr/lib/php/20210902/xdebug.so
COPY --from=ddev-xdebug-build /usr/lib/php/20220829/xdebug.so /usr/lib/php/20220829/xdebug.so
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is scary wild stuff!

@@ -117,14 +140,21 @@ RUN for v in $PHP_VERSIONS; do \
pkgs=$(echo ${!pkgvar} | awk -v v="$v" ' BEGIN {RS=" "; } { printf "%s-%s ",v,$0 ; }' ); \
[[ ${pkgs// } != "" ]] && (apt-get -qq install --no-install-recommends --no-install-suggests -y $pkgs || exit $?) \
done
### ---------------------------ddev-xdebug-build--------------------------------------
### The dates from /usr/lib/php/YYYYMMDD/ represent PHP API versions https://unix.stackexchange.com/a/591771
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the excellent commenting.

@stasadev stasadev merged commit 90d8956 into ddev:master May 15, 2024
23 of 24 checks passed
@stasadev stasadev deleted the 20240513_stasadev_compile_xdebug branch May 15, 2024 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants