From c4c46bf3f0503a457bbbbbeeba4d980b01852d80 Mon Sep 17 00:00:00 2001 From: rango Date: Thu, 30 Apr 2026 20:32:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(compiler):=20=E6=B7=BB=E5=8A=A0PHP?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E5=99=A8=E5=9F=BA=E7=A1=80=E7=B1=BB=E5=92=8C?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E7=AC=A6=E5=8F=B7=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加CompilerBase核心编译器类,支持PHP到C++代码转换 - 实现AST节点解析和表达式处理功能 - 添加跨平台编译器检测和配置支持 - 集成PhpParser进行PHP语法树解析 - 实现类型系统和变量管理功能 - 添加调试信息和错误处理机制 - 扩展.gitignore文件以忽略调试符号文件 --- .gitignore | 3 ++- src/Php/CompilerBase.php | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0d1b6e38..af8a249e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ *.o *.dll *.exe -*.obj \ No newline at end of file +*.obj +*.pdb \ No newline at end of file diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 0b5a5650..918889b7 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -2530,7 +2530,6 @@ class CompilerBase extends \PhpAot\Core\Translator if ($this->debugInfo) { $cmd .= ' /Od'; // 禁用优化(类似 gcc -O0) $cmd .= ' /Zi'; // 生成完整调试信息(类似 gcc -g) - $cmd .= ' /DEBUG'; // 链接时生成 PDB 文件 $this->climate->info('Debug mode enabled: optimizations disabled, debug info generated'); } else { // 非调试模式:使用用户指定的优化级别 @@ -2587,6 +2586,11 @@ class CompilerBase extends \PhpAot\Core\Translator if ($link) { $cmd .= ' ' . $this->parseWindowsLdflags(); + // 调试模式:链接时生成 PDB 文件 + if ($this->debugInfo) { + $cmd .= ' /DEBUG'; // 生成 PDB 调试信息文件 + } + // 对于 bin 模式且指定了 --no-console,使用 Windows 子系统(不显示控制台窗口) if ($this->buildMode === 'bin' && $this->noConsole) { $cmd .= ' /SUBSYSTEM:WINDOWS'; @@ -2698,6 +2702,11 @@ class CompilerBase extends \PhpAot\Core\Translator if ($link) { $cmd .= ' ' . $this->parseWindowsLdflags(); + // 调试模式:链接时生成 PDB 文件(Clang + lld-link/link.exe) + if ($this->debugInfo) { + $cmd .= ' /DEBUG'; // 生成 PDB 调试信息文件 + } + // 对于 bin 模式且指定了 --no-console,使用 Windows 子系统 if ($this->buildMode === 'bin' && $this->noConsole) { $cmd .= ' /SUBSYSTEM:WINDOWS';