Skip to content

Exclude unused functions from compilation units #17686

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

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,15 @@ static zend_result (*orig_post_startup_cb)(void);
static zend_result accel_post_startup(void);
static zend_result accel_finish_startup(void);

#ifndef ZEND_WIN32
# define PRELOAD_SUPPORT
#endif

#ifdef PRELOAD_SUPPORT
static void preload_shutdown(void);
static void preload_activate(void);
static void preload_restart(void);
#endif

#ifdef ZEND_WIN32
# define INCREMENT(v) InterlockedIncrement64(&ZCSG(v))
Expand Down Expand Up @@ -2713,9 +2719,11 @@ zend_result accel_activate(INIT_FUNC_ARGS)
}

zend_shared_alloc_restore_state();
#ifdef PRELOAD_SUPPORT
if (ZCSG(preload_script)) {
preload_restart();
}
#endif

#ifdef HAVE_JIT
zend_jit_restart();
Expand Down Expand Up @@ -2757,9 +2765,11 @@ zend_result accel_activate(INIT_FUNC_ARGS)
zend_jit_activate();
#endif

#ifdef PRELOAD_SUPPORT
if (ZCSG(preload_script)) {
preload_activate();
}
#endif

return SUCCESS;
}
Expand Down Expand Up @@ -3455,9 +3465,11 @@ void accel_shutdown(void)
return;
}

#ifdef PRELOAD_SUPPORT
if (ZCSG(preload_script)) {
preload_shutdown();
}
#endif

_file_cache_only = file_cache_only;

Expand Down Expand Up @@ -3566,6 +3578,7 @@ void accelerator_shm_read_unlock(void)
}

/* Preloading */
#ifdef PRELOAD_SUPPORT
static HashTable *preload_scripts = NULL;
static zend_op_array *(*preload_orig_compile_file)(zend_file_handle *file_handle, int type);

Expand Down Expand Up @@ -4665,7 +4678,6 @@ static void preload_send_header(sapi_header_struct *sapi_header, void *server_co
{
}

#ifndef ZEND_WIN32
static zend_result accel_finish_startup_preload(bool in_child)
{
zend_result ret = SUCCESS;
Expand Down
4 changes: 4 additions & 0 deletions ext/standard/proc_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ static zend_result convert_command_to_use_shell(wchar_t **cmdw, size_t cmdw_len)
}
#endif

#ifndef PHP_WIN32
/* Convert command parameter array passed as first argument to `proc_open` into command string */
static zend_string* get_command_from_array(HashTable *array, char ***argv, int num_elems)
{
Expand Down Expand Up @@ -807,6 +808,7 @@ static zend_string* get_command_from_array(HashTable *array, char ***argv, int n
(*argv)[i] = NULL;
return command;
}
#endif

static descriptorspec_item* alloc_descriptor_array(HashTable *descriptorspec)
{
Expand Down Expand Up @@ -1177,6 +1179,7 @@ static void close_all_descriptors(descriptorspec_item *descriptors, int ndesc)
}
}

#ifndef PHP_WIN32
static void efree_argv(char **argv)
{
if (argv) {
Expand All @@ -1188,6 +1191,7 @@ static void efree_argv(char **argv)
efree(argv);
}
}
#endif

/* {{{ Execute a command, with specified files used for input/output */
PHP_FUNCTION(proc_open)
Expand Down
2 changes: 2 additions & 0 deletions sapi/cli/php_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ static void print_extensions(void) /* {{{ */
#define STDERR_FILENO 2
#endif

#ifdef PHP_WRITE_STDOUT
static inline bool sapi_cli_select(php_socket_t fd)
{
fd_set wfd;
Expand All @@ -238,6 +239,7 @@ static inline bool sapi_cli_select(php_socket_t fd)

return ret != -1;
}
#endif

PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length) /* {{{ */
{
Expand Down
2 changes: 2 additions & 0 deletions sapi/phpdbg/phpdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ typedef struct {
int fd;
} php_stdio_stream_data;

#ifndef _WIN32
static ssize_t phpdbg_stdiop_write(php_stream *stream, const char *buf, size_t count) {
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;

Expand All @@ -877,6 +878,7 @@ static ssize_t phpdbg_stdiop_write(php_stream *stream, const char *buf, size_t c

return PHPDBG_G(php_stdiop_write)(stream, buf, count);
}
#endif

/* copied from sapi/cli/php_cli.c cli_register_file_handles */
void phpdbg_register_file_handles(void) /* {{{ */
Expand Down