refactor(build): 构建产物目录去掉 _mlir 后缀(temp/output)

TempDir/OutputDir 回归 {BuildDir}/temp 与 {BuildDir}/output,与 TPC 及项目脚本预期一致;mlir_dir_suffix() 仅保留给 includes 二进制缓存(其布局为 sha1 子目录,与 TPC 的扁平 obj 缓存不同,合并会混淆)。
This commit is contained in:
TermiNexus committed 2026-10-07 19:03:02 +08:00
1 parent 3b4bd1c6dc
commit ce50daa87a
2 files changed
+12 -11

No files matched your search

+11 -10
View File
@@ -354,19 +354,17 @@ def resolve_paths(project_dir: str) -> int:
SourceDir = _join_path(SourceDir, project_dir)
BuildDir = _join_path(BuildDir, project_dir)
# TempDir = {BuildDir}/temp (single-track MLIR always appends the _mlir isolation suffix)
# TempDir = {BuildDir}/temp; OutputDir = {BuildDir}/output
if BuildDir is not None:
bd_len: sizet = string.strlen(BuildDir)
suf_dir: str = mlir_dir_suffix()
suf_dir_len: sizet = string.strlen(suf_dir)
temp_buf: str = _mbuddy.alloc(bd_len + suf_dir_len + 8)
temp_buf: str = _mbuddy.alloc(bd_len + 8)
if temp_buf is not None:
viperlib.snprintf(temp_buf, bd_len + suf_dir_len + 8, "%s/temp%s", BuildDir, suf_dir)
viperlib.snprintf(temp_buf, bd_len + 8, "%s/temp", BuildDir)
TempDir = temp_buf
# OutputDir = {BuildDir}/output
output_buf: str = _mbuddy.alloc(bd_len + suf_dir_len + 8)
output_buf: str = _mbuddy.alloc(bd_len + 8)
if output_buf is not None:
viperlib.snprintf(output_buf, bd_len + suf_dir_len + 8, "%s/output%s", BuildDir, suf_dir)
viperlib.snprintf(output_buf, bd_len + 8, "%s/output", BuildDir)
OutputDir = output_buf
# includes paths may be of the form ../includes, resolved against project_dir.
@@ -545,10 +543,13 @@ def get_includes_binary_dir() -> str:
return buf
# Directory isolation suffix for single-track MLIR.
# Emitter is always mlirlite, so the suffix is "_mlir": Temp/Output/includes caches live under *_mlir, separate from old LLVM caches.
# Directory isolation suffix for the includes binary cache only.
# TempDir/OutputDir are plain {BuildDir}/temp and {BuildDir}/output (same layout as TPC and as
# the project scripts expect). The includes cache keeps "_mlir": it holds MLIR-era artifacts
# (sha1 subdirectories) while TPC's includes cache at {IncludesDir}.binary/ holds flat
# "<sha1>.<triple>.pic.obj" files, so sharing one directory would mix the two layouts.
def mlir_dir_suffix() -> str:
"""Directory isolation suffix for the MLIR backend (always "_mlir")."""
"""Directory isolation suffix for the includes cache of the MLIR backend (always "_mlir")."""
return "_mlir"