From 9186d04da4ef327b947d096a50c4d604ccae4b62 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 8 May 2026 20:26:56 +0800 Subject: [PATCH] =?UTF-8?q?refactor(backend):=20=E5=B0=86=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E9=85=8D=E7=BD=AE=E9=80=89=E9=A1=B9=E4=BB=8E=20debug?= =?UTF-8?q?=5Finfo=20=E7=BB=9F=E4=B8=80=E6=9B=B4=E6=94=B9=E4=B8=BA=20debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将所有编译器后端(GCC、Clang、MSVC)中的 debug_info 参数重命名为 debug - 更新单元测试中相应的配置选项参数名称 - 修改命令行参数解析从 --debug-info 改为 --debug - 调整文档中关于调试选项的描述和示例 - 修复链接阶段不应包含调试符号的逻辑错误 - 重构内部调试变量命名从 debugInfo 改为 debug - 更新 YAML 配置文件中的调试选项键名 --- REFACTORING_README.md | 2 +- docs/COMPILER_CLI.md | 6 +- examples/tetris-sdl/cpp-src/tetris.cc | 93 +++++++++++++++---- examples/tetris-sdl/main.php | 1 + examples/tetris-sdl/php-src/tetris.stub.php | 1 + examples/win32-hello/CONFIG_PRIORITY_RULES.md | 4 +- .../YAML_CONFIG_NAMING_CONVENTION.md | 8 +- phpunit/src/Backend/BackendOptionsTest.php | 26 +++--- phpunit/src/Backend/BackendTest.php | 12 +-- src/Php/Backend/Clang.php | 12 +-- src/Php/Backend/Gcc.php | 8 +- src/Php/Backend/Msvc.php | 10 +- src/Php/CompilerBase.php | 8 +- src/Php/Constants.php | 8 +- src/Php/Translator.php | 10 +- 15 files changed, 134 insertions(+), 75 deletions(-) diff --git a/REFACTORING_README.md b/REFACTORING_README.md index 099d2639..d373b836 100644 --- a/REFACTORING_README.md +++ b/REFACTORING_README.md @@ -180,7 +180,7 @@ $linkCmd = $compiler->buildLinkCommand( ['hello.obj', 'main.obj'], 'hello.exe', [ - 'debug_info' => false, + 'debug' => false, 'no_console' => false, ] ); diff --git a/docs/COMPILER_CLI.md b/docs/COMPILER_CLI.md index f5c4a589..ac278033 100644 --- a/docs/COMPILER_CLI.md +++ b/docs/COMPILER_CLI.md @@ -274,7 +274,7 @@ cat benchmark.prof --- -### 10. `--debug-info` - 启用调试信息 +### 10. `--debug` - 启用调试模式 **类型**: 开关 @@ -283,7 +283,7 @@ cat benchmark.prof **示例**: ```bash # 启用调试信息 -./bin/compiler.php app.php --debug-info +./bin/compiler.php app.php --debug ``` --- @@ -651,7 +651,7 @@ skip: /path/to/file.php ./bin/compiler.php app.php -O3 -j 16 -p # 调试构建 -./bin/compiler.php app.php -O0 -v --debug-info +./bin/compiler.php app.php -O0 -v --debug # 扩展构建 ./bin/compiler.php ext/ -m ext -o myext -O2 -v diff --git a/examples/tetris-sdl/cpp-src/tetris.cc b/examples/tetris-sdl/cpp-src/tetris.cc index d6fa5090..39427b00 100644 --- a/examples/tetris-sdl/cpp-src/tetris.cc +++ b/examples/tetris-sdl/cpp-src/tetris.cc @@ -1,7 +1,10 @@ #include #include #include +#include +#include #include +#include using namespace php; @@ -74,6 +77,69 @@ static const SDL_Color COLORS[7] = { {255, 165, 0, 255} // L - Orange }; +static void draw_filled_rect(SDL_Renderer* renderer, int x, int y, int w, int h) { + SDL_Rect rect; + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + SDL_RenderFillRect(renderer, &rect); +} + +static void draw_seven_segment_digit(SDL_Renderer* renderer, int x, int y, int digit, int scale) { + static const bool SEGMENTS[10][7] = { + {true, true, true, true, true, true, false}, // 0 + {false, true, true, false, false, false, false}, // 1 + {true, true, false, true, true, false, true }, // 2 + {true, true, true, true, false, false, true }, // 3 + {false, true, true, false, false, true, true }, // 4 + {true, false, true, true, false, true, true }, // 5 + {true, false, true, true, true, true, true }, // 6 + {true, true, true, false, false, false, false}, // 7 + {true, true, true, true, true, true, true }, // 8 + {true, true, true, true, false, true, true } // 9 + }; + + if (digit < 0 || digit > 9) { + return; + } + + const int width = 10 * scale; + const int height = 18 * scale; + const int thickness = 2 * scale; + const int midY = y + height / 2 - thickness / 2; + + if (SEGMENTS[digit][0]) draw_filled_rect(renderer, x + thickness, y, width - 2 * thickness, thickness); + if (SEGMENTS[digit][1]) draw_filled_rect(renderer, x + width - thickness, y + thickness, thickness, height / 2 - thickness); + if (SEGMENTS[digit][2]) draw_filled_rect(renderer, x + width - thickness, y + height / 2, thickness, height / 2 - thickness); + if (SEGMENTS[digit][3]) draw_filled_rect(renderer, x + thickness, y + height - thickness, width - 2 * thickness, thickness); + if (SEGMENTS[digit][4]) draw_filled_rect(renderer, x, y + height / 2, thickness, height / 2 - thickness); + if (SEGMENTS[digit][5]) draw_filled_rect(renderer, x, y + thickness, thickness, height / 2 - thickness); + if (SEGMENTS[digit][6]) draw_filled_rect(renderer, x + thickness, midY, width - 2 * thickness, thickness); +} + +static void draw_score_number(SDL_Renderer* renderer, int x, int y, int score) { + char scoreStr[16]; + snprintf(scoreStr, sizeof(scoreStr), "%d", std::max(0, score)); + + int length = 0; + while (scoreStr[length] != '\0') { + length++; + } + + const int scale = length > 6 ? 1 : 2; + const int digitWidth = 10 * scale; + const int spacing = 4 * scale; + const int maxDigits = scale == 1 ? 12 : 6; + + int start = std::max(0, length - maxDigits); + for (int i = start; i < length; i++) { + int digit = scoreStr[i] - '0'; + int offset = i - start; + draw_seven_segment_digit(renderer, x + offset * (digitWidth + spacing), y, digit, scale); + } +} + // Simple game state - stores board data from PHP class TetrisBox : public Box { public: @@ -187,6 +253,12 @@ void php_tetris_set_board(var box, Array board) { } } +// Set score calculated by PHP game logic +void php_tetris_set_score(var box, Int score) { + auto tetris = box.toBox(); + tetris->score = (int)score; +} + // Render game - Draw board from PHP void php_tetris_render(var box, Int hWnd) { auto tetris = box.toBox(); @@ -244,26 +316,9 @@ void php_tetris_render(var box, Int hWnd) { SDL_RenderFillRect(renderer, &bar); } - // Display score value as simple horizontal bars + // Display score value as seven-segment digits SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); - int score = tetris->score; - - // Draw score digits as bars - char scoreStr[16]; - snprintf(scoreStr, sizeof(scoreStr), "%d", score); - - int yPos = panelY + 40; - for (int i = 0; scoreStr[i] != '\0' && i < 6; i++) { - int digit = scoreStr[i] - '0'; - // Each digit represented by vertical bar height - int barHeight = digit * 15 + 5; - SDL_Rect digitBar; - digitBar.x = panelX + 20 + i * 25; - digitBar.y = yPos + (150 - barHeight); - digitBar.w = 15; - digitBar.h = barHeight; - SDL_RenderFillRect(renderer, &digitBar); - } + draw_score_number(renderer, panelX + 20, panelY + 55, tetris->score); // Update the screen SDL_RenderPresent(renderer); diff --git a/examples/tetris-sdl/main.php b/examples/tetris-sdl/main.php index a4e8835c..a181e0a0 100644 --- a/examples/tetris-sdl/main.php +++ b/examples/tetris-sdl/main.php @@ -246,6 +246,7 @@ class TetrisGame // Sync to C++ tetris_set_board($this->game, $renderBoard); + tetris_set_score($this->game, $this->score); } private function handleKeyPress(int $keyCode): void diff --git a/examples/tetris-sdl/php-src/tetris.stub.php b/examples/tetris-sdl/php-src/tetris.stub.php index 1c302014..c437f595 100644 --- a/examples/tetris-sdl/php-src/tetris.stub.php +++ b/examples/tetris-sdl/php-src/tetris.stub.php @@ -21,6 +21,7 @@ function tetris_hard_drop(mixed $game): void {} // SDL 窗口和渲染函数 function tetris_poll_event(mixed $game): array {} function tetris_set_board(mixed $game, array $board): void {} +function tetris_set_score(mixed $game, int $score): void {} function tetris_render(mixed $game, int $hWnd): void {} // SDL 工具函数 diff --git a/examples/win32-hello/CONFIG_PRIORITY_RULES.md b/examples/win32-hello/CONFIG_PRIORITY_RULES.md index 4eb02413..6c55ab36 100644 --- a/examples/win32-hello/CONFIG_PRIORITY_RULES.md +++ b/examples/win32-hello/CONFIG_PRIORITY_RULES.md @@ -267,7 +267,7 @@ php bin/compiler.php test.php --cxx-std=c++17 -O2 | 配置项 | 命令行参数 | 说明 | |--------|-----------|------| | 优化级别 | `-O ` | 0-3 | -| 调试信息 | `--debug-info` | 启用调试 | +| 调试信息 | `--debug` | 启用调试 | | 性能分析 | `--profile` | 启用 profiling | | Sanitizer | `--sanitize` | 内存检测 | | 并行任务 | `-j ` | 并行编译数 | @@ -296,7 +296,7 @@ cxx-flags: ```bash # 开发时使用调试模式 -php bin/compiler.php project.yml --debug-info +php bin/compiler.php project.yml --debug # 发布时使用优化 php bin/compiler.php project.yml -O3 diff --git a/examples/win32-hello/YAML_CONFIG_NAMING_CONVENTION.md b/examples/win32-hello/YAML_CONFIG_NAMING_CONVENTION.md index 0d99fa5e..3e55e185 100644 --- a/examples/win32-hello/YAML_CONFIG_NAMING_CONVENTION.md +++ b/examples/win32-hello/YAML_CONFIG_NAMING_CONVENTION.md @@ -19,7 +19,7 @@ cxx-flags: - -Wall ld-flags: - -lm -debug-info: true +debug: true no-console: true ``` @@ -59,7 +59,7 @@ cxxflags: # 等同于 cxx-flags | `ld-flags` | `ldflags` | 链接器选项 | array/string | | `sources` | - | 源文件列表 | array | | `ignore` | - | 忽略的文件/目录 | array | -| `debug-info` | - | 启用调试信息 | boolean | +| `debug` | - | 启用调试模式 | boolean | | `no-console` | - | 隐藏控制台窗口 | boolean | **注意:** @@ -318,7 +318,7 @@ ld-flags: # ✅ 好 cxx-std: c++17 build-mode: bin -debug-info: true +debug: true # ❌ 避免 cxx_std: c++17 @@ -447,7 +447,7 @@ php bin/compiler.php project.yml --cxx-std=c++20 php bin/compiler.php project.yml --mode=ext # 启用调试信息 -php bin/compiler.php project.yml --debug-info +php bin/compiler.php project.yml --debug ``` --- diff --git a/phpunit/src/Backend/BackendOptionsTest.php b/phpunit/src/Backend/BackendOptionsTest.php index 30c935d4..f16e722c 100644 --- a/phpunit/src/Backend/BackendOptionsTest.php +++ b/phpunit/src/Backend/BackendOptionsTest.php @@ -22,7 +22,7 @@ class BackendOptionsTest extends TestCase $options = $compiler->buildCompileOptions([ 'optimize' => 2, - 'debug_info' => false, + 'debug' => false, 'cpp_std' => 'c++17', 'is_zts' => false, ]); @@ -61,7 +61,7 @@ class BackendOptionsTest extends TestCase $compiler = new Msvc($platform); $options = $compiler->buildCompileOptions([ - 'debug_info' => true, + 'debug' => true, ]); $this->assertStringContainsString('/Od', $options); // 禁用优化 @@ -159,7 +159,7 @@ class BackendOptionsTest extends TestCase $compiler = new Msvc($platform); $options = $compiler->buildLinkOptions([ - 'debug_info' => true, + 'debug' => true, ]); $this->assertStringContainsString('/DEBUG', $options); @@ -206,7 +206,7 @@ class BackendOptionsTest extends TestCase $options = $compiler->buildCompileOptions([ 'optimize' => 2, - 'debug_info' => false, + 'debug' => false, 'cpp_std' => 'c++17', ]); @@ -224,7 +224,7 @@ class BackendOptionsTest extends TestCase $compiler = new Gcc($platform); $options = $compiler->buildCompileOptions([ - 'debug_info' => true, + 'debug' => true, ]); $this->assertStringContainsString('-O0', $options); @@ -290,7 +290,7 @@ class BackendOptionsTest extends TestCase } /** - * 测试 GCC 链接选项 - 调试 + * 测试 GCC 链接选项 - 调试模式(链接时不需要 -g) */ public function testGccLinkOptionsDebug(): void { @@ -298,10 +298,11 @@ class BackendOptionsTest extends TestCase $compiler = new Gcc($platform); $options = $compiler->buildLinkOptions([ - 'debug_info' => true, + 'debug' => true, ]); - $this->assertStringContainsString('-g', $options); + // 链接时不应该包含 -g,调试信息在编译阶段已经生成 + $this->assertStringNotContainsString('-g', $options); } /** @@ -395,7 +396,7 @@ class BackendOptionsTest extends TestCase $compiler = new Clang($platform); $options = $compiler->buildLinkOptions([ - 'debug_info' => true, + 'debug' => true, 'no_console' => true, 'build_mode' => 'ext', ]); @@ -407,7 +408,7 @@ class BackendOptionsTest extends TestCase } /** - * 测试 Clang 链接选项 - Unix + * 测试 Clang 链接选项 - Unix(链接时不需要 -g) */ public function testClangLinkOptionsUnix(): void { @@ -415,12 +416,13 @@ class BackendOptionsTest extends TestCase $compiler = new Clang($platform); $options = $compiler->buildLinkOptions([ - 'debug_info' => true, + 'debug' => true, 'build_mode' => 'ext', 'rpath' => ['/usr/lib'], ]); - $this->assertStringContainsString('-g', $options); + // 链接时不应该包含 -g,调试信息在编译阶段已经生成 + $this->assertStringNotContainsString('-g', $options); $this->assertStringContainsString('-shared', $options); $this->assertStringContainsString('-Wl,-rpath', $options); } diff --git a/phpunit/src/Backend/BackendTest.php b/phpunit/src/Backend/BackendTest.php index 9070095b..5d64a9d4 100644 --- a/phpunit/src/Backend/BackendTest.php +++ b/phpunit/src/Backend/BackendTest.php @@ -135,7 +135,7 @@ class BackendTest extends TestCase $options = $compiler->buildFullCompileOptions([ 'optimize' => 2, - 'debug_info' => false, + 'debug' => false, 'sanitize' => null, 'cpp_std' => 'c++17', 'suppressed_warnings' => [ @@ -165,7 +165,7 @@ class BackendTest extends TestCase $compiler = new Msvc($platform); $options = $compiler->buildFullCompileOptions([ - 'debug_info' => true, + 'debug' => true, ]); $this->assertStringContainsString('/Od', $options); // 禁用优化 @@ -181,7 +181,7 @@ class BackendTest extends TestCase $compiler = new Msvc($platform); $options = $compiler->buildFullLinkOptions([ - 'debug_info' => true, + 'debug' => true, 'no_console' => true, 'shared' => true, ]); @@ -241,7 +241,7 @@ class BackendTest extends TestCase $options = $compiler->buildFullCompileOptions([ 'optimize' => 2, - 'debug_info' => false, + 'debug' => false, 'cpp_std' => 'c++17', 'sanitize' => 'address', 'pic' => true, @@ -263,7 +263,7 @@ class BackendTest extends TestCase $compiler = new Gcc($platform); $options = $compiler->buildFullCompileOptions([ - 'debug_info' => true, + 'debug' => true, ]); $this->assertStringContainsString('-O0', $options); @@ -361,7 +361,7 @@ class BackendTest extends TestCase $compiler = new Clang($platform); $options = $compiler->buildFullLinkOptions([ - 'debug_info' => true, + 'debug' => true, 'no_console' => true, ]); diff --git a/src/Php/Backend/Clang.php b/src/Php/Backend/Clang.php index f6c27241..7a72ae4f 100644 --- a/src/Php/Backend/Clang.php +++ b/src/Php/Backend/Clang.php @@ -123,7 +123,7 @@ class Clang extends CompilerBackend $optimizeLevel = $options['optimize'] ?? 2; // 调试模式 - if (!empty($options['debug_info'])) { + if (!empty($options['debug'])) { $cmd .= ' -O0 -g'; } else { $cmd .= ' -O' . $optimizeLevel; @@ -172,7 +172,7 @@ class Clang extends CompilerBackend $optimizeLevel = $options['optimize'] ?? 0; // 调试模式 - if (!empty($options['debug_info'])) { + if (!empty($options['debug'])) { $cmd .= ' -O0 -g'; } else { $cmd .= ' -O' . $optimizeLevel; @@ -251,7 +251,7 @@ class Clang extends CompilerBackend } // 优化级别 - if (!empty($options['debug_info'])) { + if (!empty($options['debug'])) { $cmd .= ' -O0 -g'; } else { $optimizeLevel = $options['optimize'] ?? 2; @@ -289,7 +289,7 @@ class Clang extends CompilerBackend // Windows 特定选项 if ($this->platform instanceof \PhpAot\Php\Platform\Windows) { // 调试 - if (!empty($options['debug_info'])) { + if (!empty($options['debug'])) { $cmd .= ' /DEBUG'; } @@ -342,7 +342,7 @@ class Clang extends CompilerBackend } // 优化和调试 - if (!empty($config['debug_info'])) { + if (!empty($config['debug'])) { $cmd .= ' -O0 -g'; } else { $optimizeLevel = $config['optimize'] ?? 2; @@ -389,7 +389,7 @@ class Clang extends CompilerBackend // Windows 特定选项 if ($this->platform instanceof \PhpAot\Php\Platform\Windows) { // 调试 - if (!empty($config['debug_info'])) { + if (!empty($config['debug'])) { $cmd .= ' /DEBUG'; } diff --git a/src/Php/Backend/Gcc.php b/src/Php/Backend/Gcc.php index 96e21755..19d7fc7c 100644 --- a/src/Php/Backend/Gcc.php +++ b/src/Php/Backend/Gcc.php @@ -98,7 +98,7 @@ class Gcc extends CompilerBackend $cmd .= ' -O' . $optimizeLevel; // 调试信息 - if (!empty($options['debug_info'])) { + if (!empty($options['debug'])) { $cmd .= ' -g'; } @@ -132,7 +132,7 @@ class Gcc extends CompilerBackend $cmd .= ' -O' . $optimizeLevel; // 调试信息 - if (!empty($options['debug_info'])) { + if (!empty($options['debug'])) { $cmd .= ' -g'; } @@ -176,7 +176,7 @@ class Gcc extends CompilerBackend $cmd = ''; // 优化级别 - if (!empty($options['debug_info'])) { + if (!empty($options['debug'])) { $cmd .= ' -O0 -g'; } else { $optimizeLevel = $options['optimize'] ?? 2; @@ -246,7 +246,7 @@ class Gcc extends CompilerBackend } // 优化和调试 - if (!empty($config['debug_info'])) { + if (!empty($config['debug'])) { $cmd .= ' -O0 -g'; } else { $optimizeLevel = $config['optimize'] ?? 2; diff --git a/src/Php/Backend/Msvc.php b/src/Php/Backend/Msvc.php index 37f33535..94b84dee 100644 --- a/src/Php/Backend/Msvc.php +++ b/src/Php/Backend/Msvc.php @@ -182,7 +182,7 @@ class Msvc extends CompilerBackend $cmd .= ' /OUT:' . escapeshellarg($outputFile); // 调试信息 - if (!empty($options['debug_info'])) { + if (!empty($options['debug'])) { $cmd .= ' /DEBUG'; } @@ -253,7 +253,7 @@ class Msvc extends CompilerBackend } // 优化和调试 - if (!empty($options['debug_info'])) { + if (!empty($options['debug'])) { $cmd .= ' /Od /Zi'; } else { $optimizeLevel = $options['optimize'] ?? 2; @@ -294,7 +294,7 @@ class Msvc extends CompilerBackend $cmd = ''; // 调试 - if (!empty($options['debug_info'])) { + if (!empty($options['debug'])) { $cmd .= ' /DEBUG'; } @@ -340,7 +340,7 @@ class Msvc extends CompilerBackend } // 优化和调试 - if (!empty($config['debug_info'])) { + if (!empty($config['debug'])) { $cmd .= ' /Od /Zi'; } else { $optimizeLevel = $config['optimize'] ?? 2; @@ -396,7 +396,7 @@ class Msvc extends CompilerBackend $cmd = ''; // 调试 - if (!empty($config['debug_info'])) { + if (!empty($config['debug'])) { $cmd .= ' /DEBUG'; } diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 419de89b..7120baaa 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -166,7 +166,7 @@ class CompilerBase extends \PhpAot\Core\Translator protected string $ldflags = ''; protected string $linker = 'link'; // Windows linker: link.exe or lld-link protected int $floatPrecision = 17; - protected bool $debugInfo = false; + protected bool $debug = false; protected bool $formatCode = false; protected bool $printBacktraceOnError = false; protected bool $noLiteralStrings = false; @@ -2563,7 +2563,7 @@ class CompilerBase extends \PhpAot\Core\Translator // 再添加编译选项(编译器相关) $config = [ 'optimize' => $this->optimizeLevel, - 'debug_info' => $this->debugInfo, + 'debug' => $this->debug, 'sanitize' => $this->sanitize, 'cpp_std' => $this->cxxStd, 'is_zts' => $this->isPhpZts, @@ -2582,7 +2582,7 @@ class CompilerBase extends \PhpAot\Core\Translator // 再添加链接选项(编译器相关) $config = [ - 'debug_info' => $this->debugInfo, + 'debug' => $this->debug, 'no_console' => $this->noConsole, 'build_mode' => $this->buildMode, 'sanitize' => $this->sanitize, @@ -5421,7 +5421,7 @@ class CompilerBase extends \PhpAot\Core\Translator protected function genDebugInfo(?NodeAbstract $stmt = null): string { $code = ''; - if ($this->debugInfo) { + if ($this->debug) { if ($stmt) { $code .= 'php::traceDebugInfo("' . $this->escapeString($this->file) . '", ' . $stmt->getLine() . ');' . PHP_EOL; } else { diff --git a/src/Php/Constants.php b/src/Php/Constants.php index ec52b113..133a6dc6 100644 --- a/src/Php/Constants.php +++ b/src/Php/Constants.php @@ -124,11 +124,11 @@ class Constants 'required' => false, 'defaultValue' => 0, ], - 'debug-info' => [ - 'longPrefix' => 'debug-info', - 'description' => 'Enable debug info', + 'debug' => [ + 'longPrefix' => 'debug', + 'description' => 'Enable debug mode (auto-disable optimizations, add debug symbols)', 'required' => false, - 'defaultValue' => 0, + 'noValue' => true, ], 'job' => [ 'prefix' => 'j', diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 5cb95223..90f11bc2 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -94,7 +94,7 @@ class Translator extends Preprocessor $climate->bold('OPTIONS:'); $climate->tab()->out('-O Optimization level (0-3, default: 0)'); $climate->tab()->out('-p, --profile Enable performance profiling'); - $climate->tab()->out('-d, --debug-info Enable debug info (auto-disable optimizations, add -g/-Zi)'); + $climate->tab()->out('-d, --debug Enable debug mode (auto-disable optimizations, add debug symbols)'); $climate->tab()->out('--cxx-std C++ standard version (c++17, c++20, etc.)'); $climate->tab()->out('-o, --output Output binary name (default: input basename)'); $climate->tab()->out('-v, --version Show version'); @@ -145,9 +145,9 @@ class Translator extends Preprocessor $this->maxJob = intval($this->climate->arguments->get('job')); } - // 调试信息 - if ($this->climate->arguments->defined('debug-info')) { - $this->debugInfo = true; + // 调试模式 + if ($this->climate->arguments->defined('debug')) { + $this->debug = true; } // 禁用字面量字符串优化 @@ -748,7 +748,7 @@ CODE; $objectFile, [ 'optimize' => $this->optimizeLevel, - 'debug_info' => $this->debugInfo, + 'debug' => $this->debug, 'sanitize' => $this->sanitize, 'cpp_std' => $this->cxxStd, 'is_zts' => $this->isPhpZts,