fix(build): 修复Windows下编译器选择逻辑

- 修改Windows下编译器优先级顺序为:PHPX_CC环境变量 > cl (MSVC, 默认) > clang
- 移除Clang作为默认首选编译器的逻辑
- 添加MSVC作为默认编译器的稳定性说明
- 更新相关注释以反映新的编译器选择策略
pull/1/head
韩天峰 4 months ago
parent 08890ea630
commit a792990553
  1. 8
      src/Php/CompilerBase.php

@ -308,19 +308,15 @@ class CompilerBase extends \PhpAot\Core\Translator
if ($this->isWindows) { if ($this->isWindows) {
// Windows 下检测使用哪个编译器 // Windows 下检测使用哪个编译器
// 优先级:环境变量 PHPX_CC > clang > cl (MSVC) // 优先级:环境变量 PHPX_CC > cl (MSVC, 默认) > clang
$compilerEnv = getenv('PHPX_CC'); $compilerEnv = getenv('PHPX_CC');
if ($compilerEnv) { if ($compilerEnv) {
// 用户通过环境变量指定编译器 // 用户通过环境变量指定编译器
$this->cppCompiler = $compilerEnv; $this->cppCompiler = $compilerEnv;
$this->climate->info("Using compiler from PHPX_CC: {$this->cppCompiler}"); $this->climate->info("Using compiler from PHPX_CC: {$this->cppCompiler}");
} elseif ($this->isClangAvailable()) {
// 优先使用 Clang(如果可用)
$this->cppCompiler = 'clang++';
$this->climate->info('Using Clang compiler (clang++)');
} else { } else {
// 默认使用 MSVC // 默认使用 MSVC(更稳定,与链接器兼容)
$this->cppCompiler = 'cl'; $this->cppCompiler = 'cl';
$this->climate->info('Using MSVC compiler (cl)'); $this->climate->info('Using MSVC compiler (cl)');
} }

Loading…
Cancel
Save