From ce50daa87a7cee263958d2f585980d93bd70c951 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 7 Oct 2026 19:03:02 +0800 Subject: [PATCH] =?UTF-8?q?refactor(build):=20=E6=9E=84=E5=BB=BA=E4=BA=A7?= =?UTF-8?q?=E7=89=A9=E7=9B=AE=E5=BD=95=E5=8E=BB=E6=8E=89=20=5Fmlir=20?= =?UTF-8?q?=E5=90=8E=E7=BC=80=EF=BC=88temp/output=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TempDir/OutputDir 回归 {BuildDir}/temp 与 {BuildDir}/output,与 TPC 及项目脚本预期一致;mlir_dir_suffix() 仅保留给 includes 二进制缓存(其布局为 sha1 子目录,与 TPC 的扁平 obj 缓存不同,合并会混淆)。 --- App/lib/Phase/Phase2/__init__.vp | 2 +- App/lib/Projectrans/Config.vp | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/App/lib/Phase/Phase2/__init__.vp b/App/lib/Phase/Phase2/__init__.vp index ca8fd8d..2134031 100644 --- a/App/lib/Phase/Phase2/__init__.vp +++ b/App/lib/Phase/Phase2/__init__.vp @@ -1433,7 +1433,7 @@ def RunMultiFileProject(mb: memhub.MemBuddy*, source_dir: str, temp_dir: str, ou string.strcpy(final_obj_paths, main_obj_path) fop_pos = mlen - # Merge the App non-main modules' .obj (obj_paths, space-separated) compiled by Phase B/B+. + # Merge the App non-main modules' .obj (obj_paths, space-separated) compiled by Phase B/B+. # final_obj_paths must include main_obj + reachable includes + App deps, else linking hits undefined symbols. if obj_pos > 0: if fop_pos + obj_pos + 1 < OBJ_PATHS_SIZE + 512: diff --git a/App/lib/Projectrans/Config.vp b/App/lib/Projectrans/Config.vp index ea5aa7a..ddb47a4 100644 --- a/App/lib/Projectrans/Config.vp +++ b/App/lib/Projectrans/Config.vp @@ -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 +# "..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"