Skip to content

Commit af463f7

Browse files
feat(profiling): add build compatibility with PHP 8.6 (#4084)
1 parent 47bcde2 commit af463f7

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

profiling/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ fn build_zend_php_ffis(
176176
.chain([Path::new("../zend_abstract_interface")])
177177
.chain([Path::new("../")]),
178178
)
179-
.flag_if_supported("-std=c11")
180-
.flag_if_supported("-std=c17");
179+
.flag_if_supported("-std=gnu11")
180+
.flag_if_supported("-std=gnu17");
181181
#[cfg(feature = "test")]
182182
build.define("CFG_TEST", "1");
183183
build.compile("php_ffi");

profiling/src/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,10 @@ unsafe extern "C" fn parse_profiling_enabled(
916916

917917
/// Display the profiling enabled config value
918918
unsafe extern "C" fn display_profiling_enabled(ini_entry: *mut zend_ini_entry, type_: c_int) {
919+
// PHP 8.6 changed this field from u8 to bool, so the cast is redundant only on older PHP.
920+
#[allow(clippy::unnecessary_cast)]
919921
let tmp_value: *mut zend_string =
920-
if type_ as u32 == ZEND_INI_DISPLAY_ORIG && (*ini_entry).modified != 0 {
922+
if type_ as u32 == ZEND_INI_DISPLAY_ORIG && (*ini_entry).modified as u8 != 0 {
921923
if !(*ini_entry).orig_value.is_null() {
922924
(*ini_entry).orig_value
923925
} else {

profiling/src/php_ffi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ bool ddog_php_jit_enabled() {
654654
}
655655

656656
// Check opcache.jit_buffer_size, no buffer -> no JIT
657-
char *buffer_size_str = zend_ini_string("opcache.jit_buffer_size", sizeof("opcache.jit_buffer_size") - 1, 0);
657+
const char *buffer_size_str = zend_ini_string("opcache.jit_buffer_size", sizeof("opcache.jit_buffer_size") - 1, 0);
658658
if (!buffer_size_str || strlen(buffer_size_str) == 0 || strcmp(buffer_size_str, "0") == 0) {
659659
return false;
660660
}
@@ -666,7 +666,7 @@ bool ddog_php_jit_enabled() {
666666
}
667667

668668
// Finally check the opcache.jit setting
669-
char *jit_str = zend_ini_string("opcache.jit", sizeof("opcache.jit") - 1, 0);
669+
const char *jit_str = zend_ini_string("opcache.jit", sizeof("opcache.jit") - 1, 0);
670670
if (!jit_str || strlen(jit_str) == 0 ||
671671
strcmp(jit_str, "disable") == 0 ||
672672
strcmp(jit_str, "off") == 0 ||
@@ -685,6 +685,8 @@ bool ddog_php_jit_enabled() {
685685
#if PHP_VERSION_ID < 70200
686686
#define zend_parse_parameters_none_throw() \
687687
(EXPECTED(ZEND_NUM_ARGS() == 0) ? SUCCESS : zend_parse_parameters_throw(ZEND_NUM_ARGS(), ""))
688+
#elif PHP_VERSION_ID >= 80600
689+
#define zend_parse_parameters_none_throw() zend_parse_parameters_none()
688690
#endif
689691

690692
#if CFG_TRIGGER_TIME_SAMPLE

profiling/src/php_ffi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include <SAPI.h>
2+
#if PHP_VERSION_ID >= 80600
3+
#include <Zend/zend_compile.h>
4+
#endif
25
#include <Zend/zend_extensions.h>
36
#include <Zend/zend_exceptions.h>
47
#include <Zend/zend_types.h>
@@ -38,10 +41,12 @@
3841
// Used to communicate strings from C -> Rust.
3942
#include <zai_string/string.h>
4043

44+
#if PHP_VERSION_ID < 80600
4145
/* C11 allows a duplicate typedef provided they are the same, so this should be
4246
* fine as long as we compile with C11 or higher.
4347
*/
4448
typedef ZEND_RESULT_CODE zend_result;
49+
#endif
4550

4651
/**
4752
* Returns macro expansion of ZEND_EXTENSION_BUILD_ID, which bindgen cannot

0 commit comments

Comments
 (0)