Skip to content

Commit 74a0748

Browse files
committed
fix(windows): capacity.cppm needs <stdlib.h>; keep bench child logs out of the measured tree
两个都是本轮自己引入的问题,CI 抓到的。 1. Windows 编译失败。`mcpp.platform.capacity` 的 Win32 分支用 malloc/free 处理 GetLogicalProcessorInformationEx 的两段式调用,但 clang 不会从 windows.h 拿到它们: error: no member named 'malloc' in the global namespace; did you mean '_alloca'? error: no type named 'free' in the global namespace 补 <stdlib.h>。POSIX 侧同一类问题上一轮已经在 Darwin 上踩过一次 (setenv/unsetenv 藏在 <_stdlib.h> 里),同样的修法。 2. bench 的 --project 模式把子进程日志写进了被测项目的根目录,于是 `bench-child.log` 被 git add -A 顺手提交了进来。 仅仅 gitignore 是治标:被测的那棵树在 --project 模式下就是用户的仓库, 往里面丢文件本身才是问题。日志改为落在 work 目录下的 logs/,按 引擎-场景命名;顺带 gitignore 兜底,并把已提交的那份删掉。
1 parent a783dc7 commit 74a0748

4 files changed

Lines changed: 18 additions & 8 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ compile_commands.json
3535
/bench/bench-work/
3636
bench-report.json
3737
bench/bench-report.json
38+
# --project mode writes the measured build's stdout/stderr next to the project
39+
bench-child.log
3840
.mcpp.toml.bench-backup

bench-child.log

Lines changed: 0 additions & 7 deletions
This file was deleted.

bench/src/runner.cppm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ public:
7171
fixture::Targets targets;
7272
};
7373

74+
// Where child stdout/stderr is collected. Always under the work root, so it
75+
// is disposable and never lands in the project being measured.
76+
std::filesystem::path log_dir() const {
77+
std::error_code ec;
78+
auto d = opt_.work_root / "logs";
79+
std::filesystem::create_directories(d, ec);
80+
return d;
81+
}
82+
7483
Instance materialise(std::string_view engine, Variant variant) const {
7584
// PROJECT MODE. The tree already exists and belongs to someone; nothing
7685
// here may create or delete it. In particular the remove_tree below must
@@ -140,7 +149,12 @@ public:
140149
Job job;
141150
job.project_dir = inst.project_dir;
142151
job.build_dir = inst.build_dir;
143-
job.log_path = inst.project_dir / "bench-child.log";
152+
// The child log goes in the WORK directory, never inside the measured
153+
// tree. In --project mode that tree is the user's repository, and a
154+
// harness that drops files into it is one `git add -A` away from
155+
// committing its own scratch (which is exactly what happened once).
156+
job.log_path = log_dir() / std::format("{}-{}.log", engine.name(),
157+
to_string(scenario));
144158
job.variant = variant;
145159
job.profile = std::string(profile);
146160
job.compiler = std::string(compiler);

src/platform/capacity.cppm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module;
3030
#define NOMINMAX
3131
#endif
3232
#include <windows.h>
33+
#include <stdlib.h> // malloc / free — clang does not get these from windows.h
3334
#elif defined(__APPLE__)
3435
#include <sys/sysctl.h>
3536
#include <sys/types.h>

0 commit comments

Comments
 (0)