Skip to content

Commit

Permalink
Publish debugging symbols for public binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Jul 7, 2023
1 parent 9559c64 commit a6bcc05
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 22 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,20 @@ jobs:
# Used "set -ex" instead of hashbang since script isn't executed with hashbang
set -ex
trap "exit 1" ERR
./compile.sh -t linux64 -j 4 -g -P ${{ matrix.pm-version-major }} -c ./download_cache
./compile.sh -t linux64 -j 4 -g -P ${{ matrix.pm-version-major }} -c ./download_cache -D
- name: Create tarball
run: tar -czf ./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}.tar.gz bin

run: |
tar -czf ./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}.tar.gz bin
tar -czf ./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}-debugging-symbols.tar.gz bin-debug
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: Linux-PM${{ matrix.pm-version-major }}
path: |
./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}.tar.gz
./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}*.tar.gz
install.log
compile.sh
if-no-files-found: error
Expand Down Expand Up @@ -95,18 +97,20 @@ jobs:
export PATH="/usr/local/opt/bison/bin:$PATH"
set -ex
trap "exit 1" ERR
./compile.sh -t mac-x86-64 -j4 -g -P ${{ matrix.pm-version-major }} -c ./download_cache
./compile.sh -t mac-x86-64 -j4 -g -P ${{ matrix.pm-version-major }} -c ./download_cache -D
- name: Create tarball
run: tar -czf ./PHP-MacOS-x86_64-PM${{ matrix.pm-version-major }}.tar.gz bin
run: |
tar -czf ./PHP-MacOS-x86_64-PM${{ matrix.pm-version-major }}.tar.gz bin
tar -czf ./PHP-MacOS-x86_64-PM${{ matrix.pm-version-major }}-debugging-symbols.tar.gz bin-debug
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: MacOS-PM${{ matrix.pm-version-major }}
path: |
./PHP-MacOS-x86_64-PM${{ matrix.pm-version-major }}.tar.gz
./PHP-MacOS-x86_64-PM${{ matrix.pm-version-major }}*.tar.gz
install.log
compile.sh
if-no-files-found: error
Expand Down Expand Up @@ -147,7 +151,7 @@ jobs:
- name: Rename artifacts
run: |
mkdir temp
move php-debug-pack-*.zip temp/PHP-Windows-x64-debug-pack-PM${{ matrix.pm-version-major }}.zip
move php-debug-pack-*.zip temp/PHP-Windows-x64-PM${{ matrix.pm-version-major }}-debugging-symbols.zip
move php-*.zip temp/PHP-Windows-x64-PM${{ matrix.pm-version-major }}.zip
move temp\*.zip .
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ Bash script used to compile PHP on MacOS and Linux platforms. Make sure you have
- The `aarch64-linux-musl` toolchain is required. You can compile and install it using https://github.com/pmmp/musl-cross-make (PMMP fork includes musl-libc patches for DNS resolver config path and increasing stack size limit for LevelDB)
- It is strongly recommended that you enable abusive optimizations for Android targets (`-f` flag) for best performance.

| Script flags | Description |
|--------------|-------------------------------------------------------------------------------------------------------|
| -c | Uses the folder specified for caching downloaded tarballs, zipballs etc. |
| -d | Compiles with debugging symbols and disables optimizations (slow, but useful for debugging segfaults) |
| -g | Will compile GD2 |
| -j | Set make threads to # |
| -l | Uses the folder specified for caching compilation artifacts (useful for rapid rebuild and testing) |
| -n | Don't remove sources after completing compilation |
| -s | Will compile everything statically |
| -t | Set target |
| -v | Enable Valgrind support in PHP |
| -x | Specifies we are doing cross-compile |
| -P | Compiles extensions for the major PocketMine-MP version specified (can be `4` or `5`) |
| Script flags | Description |
|--------------|-------------------------------------------------------------------------------------------------------------|
| -c | Uses the folder specified for caching downloaded tarballs, zipballs etc. |
| -d | Compiles with debugging symbols and disables optimizations (slow, but useful for debugging segfaults) |
| -D | Compiles with separated debugging symbols, but leaves optimizations enabled (used for distributed binaries) |
| -g | Will compile GD2 |
| -j | Set make threads to # |
| -l | Uses the folder specified for caching compilation artifacts (useful for rapid rebuild and testing) |
| -n | Don't remove sources after completing compilation |
| -s | Will compile everything statically |
| -t | Set target |
| -v | Enable Valgrind support in PHP |
| -x | Specifies we are doing cross-compile |
| -P | Compiles extensions for the major PocketMine-MP version specified (can be `4` or `5`) |

### Example:

Expand Down
34 changes: 33 additions & 1 deletion compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ BASE_BUILD_DIR="$DIR/install_data"
BUILD_DIR="$BASE_BUILD_DIR/subdir"
LIB_BUILD_DIR="$BUILD_DIR/lib"
INSTALL_DIR="$DIR/bin/php7"
SYMBOLS_DIR="$DIR/bin-debug/php7"

date > "$DIR/install.log" 2>&1

Expand Down Expand Up @@ -149,8 +150,9 @@ PM_VERSION_MAJOR=""

DOWNLOAD_INSECURE="no"
DOWNLOAD_CACHE=""
SEPARATE_SYMBOLS="no"

while getopts "::t:j:sdxfgnva:P:c:l:Ji" OPTION; do
while getopts "::t:j:sdDxfgnva:P:c:l:Ji" OPTION; do

case $OPTION in
l)
Expand Down Expand Up @@ -180,6 +182,13 @@ while getopts "::t:j:sdxfgnva:P:c:l:Ji" OPTION; do
CFLAGS="$CFLAGS -g"
CXXFLAGS="$CXXFLAGS -g"
;;
D)
write_out "opt" "Compiling with separated debugging symbols, but leaving optimizations enabled"
write_out "INFO" "Recommended for building distributed binaries - for local debugging, use -d instead to disable optimizations for a better debugging experience"
SEPARATE_SYMBOLS="yes"
CFLAGS="$CFLAGS -g"
CXXFLAGS="$CXXFLAGS -g"
;;
x)
write_out "opt" "Doing cross-compile"
IS_CROSSCOMPILE="yes"
Expand Down Expand Up @@ -1294,6 +1303,29 @@ if [[ "$HAVE_XDEBUG" == "yes" ]]; then
write_out INFO "Xdebug is included, but disabled by default. To enable it, change 'xdebug.mode' in your php.ini file."
fi

function separate_symbols {
local libname="$1"
local output_dirname

output_dirname="$SYMBOLS_DIR/$(dirname $libname)"
mkdir -p "$output_dirname" >> "$DIR/install.log" 2>&1
cp "$libname" "$SYMBOLS_DIR/$libname.debug" >> "$DIR/install.log" 2>&1
strip -S "$libname" >> "$DIR/install.log" 2>&1
}

if [ "$SEPARATE_SYMBOLS" != "no" ]; then
echo -n "[INFO] Separating debugging symbols into $SYMBOLS_DIR..."
cd "$INSTALL_DIR"
find "lib" \( -name '*.so' -o -name '*.so.*' -o -name '*.dylib' -o -name '*.dylib.*' \) -print0 | while IFS= read -r -d '' file; do
separate_symbols "$file"
done
for file in "bin/"*; do
separate_symbols "$file"
done
cd "$DIR"
write_done
fi

cd "$DIR"
if [ "$DO_CLEANUP" == "yes" ]; then
write_out "INFO" "Cleaning up"
Expand Down

0 comments on commit a6bcc05

Please sign in to comment.