shivammathur / setup-php

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.
https://setup-php.com
MIT License
2.85k stars 334 forks source link

Installing a Debug Build of PHP does not work #816

Closed TimWolla closed 5 months ago

TimWolla commented 5 months ago

Describe the bug

Installing a Debug Build as per https://github.com/shivammathur/setup-php?tab=readme-ov-file#debug-build-setup does not appear to work.

Version

Runners

Operating systems

ubuntu-latest

PHP versions

Any of 7.4 - 8.3 (possible more).

To Reproduce

name: Test

on: push

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php:
          - "8.3"
          - "8.2"
          - "8.1"
          - "8.0"
          - "7.4"
    steps:
    - uses: actions/checkout@v4
    - name: "Install PHP"
      uses: "shivammathur/setup-php@v2"
      with:
        php-version: "${{ matrix.php }}"
      env:
        debug: "true"
    - run: php -i
    - run: |
        php -i |grep Debug

Expected behavior

I expected php -i to indicate that the PHP build is a debug build.

Screenshots/Logs

Run php -i |grep Debug
Debug Build => no
APCu Debugging => Disabled
Debug => No
Step Debugger => ✘ disabled

Additional context

Example run at: https://github.com/TimWolla/setup-php-debug/actions/runs/7874782401

Are you willing to submit a PR?

No, as I could not find where it goes wrong. I confirmed that the debug environment variable is properly set.

shivammathur commented 5 months ago

php -i | grep Debug says no, as it is built without --enable-debug, but with -g in CFLAGS.

From that build dh_strip removes the debug symbols, so they can be packaged separately, this way it does not need to be built twice. All packaging for Debian is done similarly.

When debug is set to true, it adds those stripped debug symbols to /var/lib/debug/.build-id directory. Tools like objdump and gdb should pick debuginfo from there.

Test workflow: https://github.com/shivammathur/test-setup-php/actions/runs/7875037633/workflow

TimWolla commented 5 months ago

I see. Calling it a “Debug Build Setup” without it actually being a Debug Build of PHP certainly was confusing to me.

Do you plan to provide actual Debug Builds with your Action? If not, I would suggest adding a clarification to the README that the “Debug Build Setup” will just install the debug symbols.

Or perhaps it would make sense to always install the debug symbols, GitHub Actions is for testing and debugging after all and having symbols available at all times certainly would not hurt.

shivammathur commented 5 months ago

I have tried to improve the documentation for this in https://github.com/shivammathur/setup-php/commit/1a5ac4aa9a4ee5f52acf166f3deebbd514f5735a but switching to debug by default would mean the build size would increase by 3 to 5 times for all, while a very few CI workflows use debug. Ref: https://github.com/shivammathur/php-ubuntu/releases/tag/builds