修复 Godot 原生插件的 MSVC 编译兼容性
Project CI / Frontend tests (push) Failing after 6s
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Failing after 17s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Failing after 18s
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Failing after 18s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Failing after 19s
Project CI / AI game creator shell Rust smoke (pull_request) Failing after 17s
Project CI / AI game creator shell Rust crates (pull_request) Failing after 16s
Project CI / Native shell tests (pull_request) Failing after 15s
Project CI / Backend tests (pull_request) Failing after 16s
Project CI / Frontend tests (pull_request) Failing after 6s
Project CI / AI game creator shell web tests (pull_request) Failing after 12s
Project CI / Repository checks (pull_request) Failing after 12s
Project CI / AI game creator shell Rust shard 1/4 (push) Failing after 19s
Project CI / AI game creator shell Rust shard 3/4 (push) Failing after 19s
Project CI / AI game creator shell Rust shard 4/4 (push) Failing after 19s
Project CI / AI game creator shell Rust shard 2/4 (push) Failing after 19s
Project CI / AI game creator shell Rust crates (push) Failing after 20s
Project CI / AI game creator shell Rust smoke (push) Failing after 20s
Project CI / Backend tests (push) Failing after 20s
Project CI / Native shell tests (push) Failing after 19s
Project CI / AI game creator shell web tests (push) Failing after 12s
Project CI / Repository checks (push) Failing after 12s

将 ABI 存储改为 C11 显式 16 字节对齐并保留 128 字节容量
补充 Windows 编译环境要求与 MSVC 对齐问题排障说明
This commit was merged in pull request #435.
This commit is contained in:
2026-09-20 19:39:12 +08:00
parent cde34428f9
commit a2acfa9a6f
3 changed files with 10 additions and 2 deletions
@@ -1,5 +1,10 @@
# 踩坑与排障记录
## Godot 原生插件在 MSVC C 模式下的对齐声明
- `native.c` 若首先报 `max_align_t` 语法错误,后面的 `Storage``retained_script` 等未声明通常是连带错误。MSVC C 模式不提供该类型;ABI 存储使用 C11 `_Alignas(16)` 显式对齐并保持 128 字节容量,通过实际 MSVC DLL 构建验证,不逐条修补连带错误。
- `No C compiler found` 则属于开发环境问题:先初始化 Visual Studio x64 开发环境,同时设置 PATH、INCLUDE 与 LIB,再运行构建。只把 `cl.exe` 所在目录加到 PATH 不足以提供头文件和链接库。
## Rust 同步回调的测试记录按线程隔离
- `shared-contracts` 的资源 kind reporter 是进程级回调。仅给注册和断言加锁,无法阻止其他并行 manifest 测试触发该回调,导致日志数量和内容断言偶发混入其他测试记录。
@@ -33,6 +33,8 @@ DLL 原件随 AGC 安装包放在插件资源目录中;Godot Windows 加载器
## 分发与描述文件
- Windows 原生构建使用 x64 C11 编译器;MSVC 需先初始化 Visual Studio 的 x64 开发环境,以同时提供 PATH、INCLUDE 与 LIB。ABI 临时存储使用 128 字节、C11 `_Alignas(16)` 显式对齐,不依赖 MSVC C 模式未提供的 `max_align_t`;定向验证运行 `plugins/agc-godot-editor/native/gdextension/build.ps1 -Compiler cl.exe`
- 安装资源布局为 `plugins/agc-godot-editor/native/gdextension/bin/win-x64/agc_godot_editor.dll`,邻接元数据记录协议、构建身份和 DLL SHA256。开发模式允许宿主提供仓库插件目录中的同结构产物;RPC 不接受自定义 DLL 候选。
- 缓存根仅由宿主提供,为其私有配置目录下的 `godot-editor-runtime`;按 `PID + startedFileTime + buildId` 隔离,所有路径分量受控且拒绝链接/reparse point。复制前验证安装原件及元数据,缓存已有文件必须匹配来源、归属及 SHA,不能加载被替换的同名文件。受管描述同时保留原件与加载副本身份,重启恢复不得把工程给出的任意 DLL 路径当作受信任来源。
- 实际模块核验同时覆盖加载副本及 Godot 在同目录生成的精确 `~agc_godot_editor.dll`,要求规范化路径和 DLL 字节身份一致。确认原生卸载后,只清理本实例、本构建、内容未变的缓存文件;不能跨编辑器删除或复用影子副本。安装位置更新和实例 PID 重用都必须重新验证。
@@ -9,9 +9,10 @@
#include "gdextension_interface.h"
#include "embedded_bridge.h"
/* Windows x64 ABI storage is deliberately oversized and naturally aligned.
/* Windows x64 ABI storage is deliberately oversized and 16-byte aligned.
* Explicit C11 alignment also works with MSVC C, which lacks max_align_t.
* Objects are constructed/destructed solely through the official interface. */
typedef union { max_align_t alignment; unsigned char bytes[128]; } Storage;
typedef struct { _Alignas(16) unsigned char bytes[128]; } Storage;
static GDExtensionInterfacePrintWarning api_warning;
static GDExtensionInterfaceVariantCall api_call;
static GDExtensionInterfaceVariantDestroy api_destroy;