Skip to content
Draft
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
2 changes: 1 addition & 1 deletion TSRM/TSRM.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ TSRM_API bool tsrm_is_managed_thread(void);
# define __has_attribute(x) 0
#endif

#if !__has_attribute(tls_model) || defined(__FreeBSD__) || defined(__NetBSD__) \
#if defined(TSRM_WIN32) || !__has_attribute(tls_model) || defined(__FreeBSD__) || defined(__NetBSD__) \
|| defined(__MUSL__) || defined(__HAIKU__) || defined(_AIX)
# define TSRM_TLS_MODEL_ATTR
# define TSRM_TLS_MODEL_DEFAULT
Expand Down
4 changes: 2 additions & 2 deletions ext/com_dotnet/Makefile.frag.w32
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest_i.c: ext\com_dotnet\tests\comt
midl /nologo /h $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest.h /iid $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest_i.c /tlb $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest.tlb ext\com_dotnet\tests\comtest\comtest.idl

$(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest.obj $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest_i.obj: ext\com_dotnet\tests\comtest\comtest.cpp $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest_i.c
$(PHP_CL) /nologo /c /Fo$(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest.obj /I $(BUILD_DIR)\ext\com_dotnet\tests\comtest ext\com_dotnet\tests\comtest\comtest.cpp
$(PHP_CL) /nologo /c /Fo$(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest_i.obj $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest_i.c
$(PHP_CL) $(BUILD_CFLAGS) /nologo /c /Fo$(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest.obj /I $(BUILD_DIR)\ext\com_dotnet\tests\comtest ext\com_dotnet\tests\comtest\comtest.cpp
$(PHP_CL) $(BUILD_CFLAGS) /nologo /c /Fo$(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest_i.obj $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest_i.c

$(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest.dll: $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest.obj $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest_i.obj ext\com_dotnet\tests\comtest\comtest.def
"$(LINK)" /nologo /dll /out:$(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest.dll $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest.obj $(BUILD_DIR)\ext\com_dotnet\tests\comtest\comtest_i.obj /def:ext\com_dotnet\tests\comtest\comtest.def OleAut32.lib
Expand Down
5 changes: 4 additions & 1 deletion ext/intl/msgformat/msgformat_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@ U_CFUNC void umsg_parse_helper(UMessageFormat *fmt, int *count, zval **args, UCh
return;
}

/* Let ICU destroy the array with the same ABI that allocated it. */
Formattable parsed;
parsed.adoptArray(fargs, *count);

*args = (zval *)safe_emalloc(*count, sizeof(zval), 0);

// assign formattables to varargs
Expand Down Expand Up @@ -672,5 +676,4 @@ U_CFUNC void umsg_parse_helper(UMessageFormat *fmt, int *count, zval **args, UCh
break;
}
}
delete[] fargs;
}
4 changes: 2 additions & 2 deletions ext/opcache/jit/Makefile.frag.w32
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
$(BUILD_DIR)\\minilua.exe: ext\opcache\jit\ir\dynasm\minilua.c
@if exist $(BUILD_DIR)\\minilua.exe del $(BUILD_DIR)\\minilua.exe
$(PHP_CL) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\minilua.exe ext\opcache\jit\ir\dynasm\minilua.c
$(PHP_CL) $(BUILD_CFLAGS) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\minilua.exe ext\opcache\jit\ir\dynasm\minilua.c

ext\opcache\jit\ir\ir_emit_x86.h: ext\opcache\jit\ir\ir_x86.dasc $(BUILD_DIR)\\minilua.exe
@if exist ext\opcache\jit\ir\ir_emit_x86.h del ext\opcache\jit\ir\ir_emit_x86.h
$(BUILD_DIR)\\minilua.exe ext/opcache/jit/ir/dynasm/dynasm.lua $(DASM_FLAGS) -o $@ ext/opcache/jit/ir/ir_x86.dasc

$(BUILD_DIR)\\gen_ir_fold_hash.exe: ext\opcache\jit\ir\gen_ir_fold_hash.c ext\opcache\jit\ir\ir_strtab.c
@if exist $(BUILD_DIR)\\gen_ir_fold_hash.exe del $(BUILD_DIR)\\gen_ir_fold_hash.exe
$(PHP_CL) /D $(IR_TARGET) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /Fe$(BUILD_DIR)\\gen_ir_fold_hash.exe ext\opcache\jit\ir\gen_ir_fold_hash.c
$(PHP_CL) $(BUILD_CFLAGS) /D $(IR_TARGET) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /Fe$(BUILD_DIR)\\gen_ir_fold_hash.exe ext\opcache\jit\ir\gen_ir_fold_hash.c

ext\opcache\jit\ir\ir_fold_hash.h: $(BUILD_DIR)\\gen_ir_fold_hash.exe ext\opcache\jit\ir\ir_fold.h ext\opcache\jit\ir\ir.h
@if exist ext\opcache\jit\ir\ir_fold_hash.h del ext\opcache\jit\ir\ir_fold_hash.h
Expand Down
1 change: 1 addition & 0 deletions ext/pdo_firebird/pdo_firebird_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef PDO_FIREBIRD_UTILS_H
#define PDO_FIREBIRD_UTILS_H

#include <stdint.h>
#include <ibase.h>

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/Makefile.frag.w32
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ $(BUILD_DIR)\ext\standard\basic_functions.obj: $(PHP_SRC_DIR)\Zend\zend_language

$(PHP_SRC_DIR)\ext\standard\tests\helpers\bad_cmd.exe: $(PHP_SRC_DIR)\ext\standard\tests\helpers\bad_cmd.c
cd $(PHP_SRC_DIR)\ext\standard\tests\helpers
$(PHP_CL) /nologo bad_cmd.c
$(PHP_CL) $(BUILD_CFLAGS) /nologo bad_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ mbstring
if (PHP_OS_FAMILY !== 'Windows') die('skip windows only test');
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--CONFLICTS--
file
--FILE--
<?php

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Basic long path test with file I/O
if (PHP_OS_FAMILY !== 'Windows') die('skip windows only test');
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--CONFLICTS--
file
--FILE--
<?php

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
proc_open() accepts a Windows environment block larger than 32760 characters
--SKIPIF--
<?php
if (PHP_OS_FAMILY !== 'Windows') die('skip Windows only');
if (!function_exists('proc_open')) die('skip proc_open() is not available');
?>
--FILE--
<?php
$env = [
'PATH' => getenv('PATH'),
'SystemRoot' => getenv('SystemRoot'),
];
for ($index = 0; $index < 8; $index++) {
$env["PHP_TEST_ENV_$index"] = str_repeat(chr(65 + $index), 5000);
}

$process = proc_open(
[PHP_BINARY, '-n', '-r', 'echo strlen(getenv("PHP_TEST_ENV_0")), " ", strlen(getenv("PHP_TEST_ENV_7")), "\n";'],
[1 => ['pipe', 'w'], 2 => ['pipe', 'w']],
$pipes,
null,
$env
);
echo stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
var_dump(proc_close($process));
?>
--EXPECT--
5000 5000
int(0)
2 changes: 1 addition & 1 deletion win32/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ dist: all build-dist
snap: build-snap build-devel build-dist

$(BUILD_DIR)\deplister.exe: win32\build\deplister.c
$(CC) /nologo /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\deplister.exe win32\build\deplister.c imagehlp.lib
$(CC) $(BUILD_CFLAGS) /nologo /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\deplister.exe win32\build\deplister.c imagehlp.lib

install: really-install install-sdk

Expand Down
25 changes: 20 additions & 5 deletions win32/build/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ if (PHP_DEBUG == "yes") {
ARG_ENABLE('pgi', 'Generate PGO instrumented binaries', 'no');
ARG_WITH('pgo', 'Compile optimized binaries using training data from folder', 'no');
if (PHP_PGI == "yes" || PHP_PGO != "no") {
PGOMGR = PATH_PROG('pgomgr', WshShell.Environment("Process").Item("PATH"));
if (!PGOMGR) {
ERROR("--enable-pgi and --with-pgo options can only be used if PGO capable compiler is present.");
if (VS_TOOLSET || ICC_TOOLSET) {
PGOMGR = PATH_PROG('pgomgr', WshShell.Environment("Process").Item("PATH"));
if (!PGOMGR) {
ERROR("--enable-pgi and --with-pgo options can only be used if PGO capable compiler is present.");
}
} else if (CLANG_TOOLSET) {
if (!PATH_PROG('llvm-profdata', WshShell.Environment("Process").Item("PATH"), 'LLVM_PROFDATA')) {
ERROR("--enable-pgi and --with-pgo options can only be used if a PGO capable toolchain is present.");
}
}
if (PHP_PGI == "yes" && PHP_PGO != "no") {
ERROR("Use of both --enable-pgi and --with-pgo not allowed.");
Expand All @@ -63,6 +69,7 @@ DEFINE('PHP_PREFIX', PHP_PREFIX);
DEFINE("BASE_INCLUDES", "/I . /I main /I Zend /I TSRM /I ext ");

toolset_setup_common_cflags();
DEFINE("BUILD_CFLAGS", CLANG_TOOLSET ? (X64 ? "-m64" : "-m32") : "");

if (VS_TOOLSET) {
ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto');
Expand Down Expand Up @@ -106,11 +113,19 @@ setup_zts_stuff();
// CFLAGS, LDFLAGS and BUILD_DIR are defined
// Add compiler and link flags if PGO options are selected
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
if (VS_TOOLSET || ICC_TOOLSET) {
ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
} else if (CLANG_TOOLSET) {
ADD_FLAG("CFLAGS", "-fprofile-generate");
}
DEFINE("PGOPGD_DIR", "$(BUILD_DIR)");
}
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
if (VS_TOOLSET || ICC_TOOLSET) {
ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
} else if (CLANG_TOOLSET) {
ADD_FLAG("CFLAGS", "-fprofile-use=" + ((PHP_PGO.length == 0 || PHP_PGO == "yes") ? "$(BUILD_DIR)" : PHP_PGO) + "/php.profdata");
}
DEFINE("PGOPGD_DIR", ((PHP_PGO.length == 0 || PHP_PGO == "yes") ? "$(BUILD_DIR)" : PHP_PGO));
}

Expand Down
66 changes: 36 additions & 30 deletions win32/build/confutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1309,18 +1309,20 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir, duplicate_so

if(is_pgo_desired(sapiname) && (PHP_PGI == "yes" || PHP_PGO != "no")) {
// Add compiler and link flags if PGO options are selected
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2");
ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG /GENPROFILE");
ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1");
}
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2");
ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG /USEPROFILE");
ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1");
}
if (VS_TOOLSET || ICC_TOOLSET) {
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2");
ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG /GENPROFILE");
ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1");
}
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2");
ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG /USEPROFILE");
ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1");
}

ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd";
ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd";
}
}

if (MODE_PHPIZE) {
Expand Down Expand Up @@ -1525,18 +1527,20 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir, cxx_mod
ldflags = "";
if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) {
// Add compiler and link flags if PGO options are selected
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
ADD_FLAG('LDFLAGS_' + EXT, "/LTCG /GENPROFILE");
ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1");
}
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
ADD_FLAG('LDFLAGS_' + EXT, "/LTCG /USEPROFILE");
ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1");
}
if (VS_TOOLSET || ICC_TOOLSET) {
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
ADD_FLAG('LDFLAGS_' + EXT, "/LTCG /GENPROFILE");
ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1");
}
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
ADD_FLAG('LDFLAGS_' + EXT, "/LTCG /USEPROFILE");
ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1");
}

ADD_FLAG('CFLAGS_' + EXT, "/GL /O2");
ADD_FLAG('CFLAGS_' + EXT, "/GL /O2");

ldflags = " /PGD:$(PGOPGD_DIR)\\" + dllname.substring(0, dllname.indexOf(".")) + ".pgd";
ldflags = " /PGD:$(PGOPGD_DIR)\\" + dllname.substring(0, dllname.indexOf(".")) + ".pgd";
}
}

MFO.WriteLine("$(BUILD_DIR)\\" + libname + ": $(BUILD_DIR)\\" + dllname);
Expand Down Expand Up @@ -1569,14 +1573,16 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir, cxx_mod
ADD_FLAG("STATIC_EXT_CFLAGS", "$(CFLAGS_" + EXT + ")");
if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) {
if (!static_pgo_enabled) {
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGINSTRUMENT");
}
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGUPDATE");
}
if (VS_TOOLSET || ICC_TOOLSET) {
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGINSTRUMENT");
}
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGUPDATE");
}

ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
}
static_pgo_enabled = true;
}
}
Expand Down Expand Up @@ -3130,7 +3136,7 @@ function toolset_setup_project_tools()
}

// Try locating the manifest tool
if (VS_TOOLSET) {
if (VS_TOOLSET || CLANG_TOOLSET) {
if (!PATH_PROG('mt', WshShell.Environment("Process").Item("PATH"))) {
ERROR('mt is required')
}
Expand Down Expand Up @@ -3389,7 +3395,7 @@ function toolset_setup_common_cflags()
} else if (CLANG_TOOLSET) {
ADD_FLAG("CFLAGS", "-Wno-deprecated-declarations -Wno-microsoft-enum-forward-reference");
if (TARGET_ARCH == 'x86') {
ADD_FLAG('CFLAGS', '-m32');
ADD_FLAG('CFLAGS', '-m32 /D_USE_32BIT_TIME_T=1');
} else {
ADD_FLAG('CFLAGS', '-m64');
}
Expand Down
45 changes: 27 additions & 18 deletions win32/codepage.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ PW32CP BOOL php_win32_cp_use_unicode(void)

PW32CP wchar_t *php_win32_cp_env_any_to_w(const char* env)
{/*{{{*/
wchar_t *envw = NULL, ew[32760];
char *cur = (char *)env, *prev;
wchar_t *envw = NULL;
const char *cur = env;
size_t bin_len = 0;

if (!env) {
Expand All @@ -436,29 +436,38 @@ PW32CP wchar_t *php_win32_cp_env_any_to_w(const char* env)

do {
wchar_t *tmp;
wchar_t *new_envw;
size_t tmp_len;

tmp = php_win32_cp_any_to_w(cur);
if (tmp) {
size_t tmp_len = wcslen(tmp) + 1;
memmove(ew + bin_len, tmp, tmp_len * sizeof(wchar_t));
free(tmp);

bin_len += tmp_len;
if (!tmp) {
free(envw);
return NULL;
}

prev = cur;

} while (NULL != (cur = strchr(prev, '\0')) && cur++ && *cur && bin_len + (cur - prev) < 32760);
tmp_len = wcslen(tmp) + 1;
if (tmp_len > SIZE_MAX / sizeof(wchar_t) - bin_len - 2) {
free(tmp);
free(envw);
SET_ERRNO_FROM_WIN32_CODE(ERROR_OUTOFMEMORY);
return NULL;
}
new_envw = realloc(envw, (bin_len + tmp_len + 2) * sizeof(wchar_t));
if (!new_envw) {
free(tmp);
free(envw);
SET_ERRNO_FROM_WIN32_CODE(ERROR_OUTOFMEMORY);
return NULL;
}
envw = new_envw;
memcpy(envw + bin_len, tmp, tmp_len * sizeof(wchar_t));
bin_len += tmp_len;
free(tmp);
cur += strlen(cur) + 1;
} while (*cur);

envw = (wchar_t *) malloc((bin_len + 3) * sizeof(wchar_t));
if (!envw) {
SET_ERRNO_FROM_WIN32_CODE(ERROR_OUTOFMEMORY);
return NULL;
}
memmove(envw, ew, bin_len * sizeof(wchar_t));
envw[bin_len] = L'\0';
envw[bin_len + 1] = L'\0';
envw[bin_len + 2] = L'\0';

return envw;
}/*}}}*/
Expand Down
Loading