Skip to content

Commit

Permalink
feat: introduce debug symbols flag for static build (#397)
Browse files Browse the repository at this point in the history
* Introduce debug symbols flag

* Add DEBUG_SYMBOLS customization to the docs
  • Loading branch information
goossda authored Dec 17, 2023
1 parent 9410418 commit b6e2277
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion build-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ else
extraOpts="--disable-opcache-jit"
fi

if [ -n "${DEBUG_SYMBOLS}" ]; then
extraOpts="${extraOpts} --no-strip"
fi

./bin/spc doctor
./bin/spc fetch --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTENSIONS}"
# shellcheck disable=SC2086
Expand Down Expand Up @@ -116,9 +120,13 @@ if [ "${os}" = "linux" ]; then
extraExtldflags="-Wl,-z,stack-size=0x80000"
fi
if [ -z "${DEBUG_SYMBOLS}" ]; then
extraLdflags="-w -s"
fi
cd caddy/frankenphp/
go env
go build -buildmode=pie -tags "cgo netgo osusergo static_build" -ldflags "-linkmode=external -extldflags '-static-pie ${extraExtldflags}' -w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ${FRANKENPHP_VERSION} PHP ${LIBPHP_VERSION} Caddy'" -o "../../dist/${bin}"
go build -buildmode=pie -tags "cgo netgo osusergo static_build" -ldflags "-linkmode=external -extldflags '-static-pie ${extraExtldflags}' ${extraLdflags} -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ${FRANKENPHP_VERSION} PHP ${LIBPHP_VERSION} Caddy'" -o "../../dist/${bin}"
cd ../..
if [ -d "${EMBED}" ]; then
Expand Down
1 change: 1 addition & 0 deletions docs/static.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ script to customize the static build:
* `PHP_EXTENSION_LIBS`: extra libraries to build that add extra features to the extensions
* `EMBED`: path of the PHP application to embed in the binary
* `CLEAN`: when set, libphp and all its dependencies are built from scratch (no cache)
* `DEBUG_SYMBOLS`: when set, debug-symbols will not be stripped and will be added within the binary
* `RELEASE`: (maintainers only) when set, the resulting binary will be uploaded on GitHub

0 comments on commit b6e2277

Please sign in to comment.