Some simple information syncing
This commit is contained in:
@@ -27,7 +27,7 @@ import lib.Projectrans.Config as Config
|
||||
# ============================================================
|
||||
|
||||
# 全局 mbuddy 指针
|
||||
_mbuddy: memhub.MemManager | t.CPtr
|
||||
_mbuddy: memhub.MemBuddy | t.CPtr
|
||||
|
||||
# 源代码缓冲区大小(1MB)
|
||||
SRC_BUF_SIZE: t.CDefine = 1048576
|
||||
@@ -270,26 +270,11 @@ def compile_ll_to_obj(ir_path: str, output_dir: str, module_name: str, cc_cmd: s
|
||||
return 1
|
||||
viperlib.snprintf(cmd, cmd_len, "%s %s -o %s %s", cc_cmd, cc_flags, obj_path, ir_path)
|
||||
|
||||
result: subprocess.CompletedProcess | t.CPtr = subprocess.run(cmd, True, True)
|
||||
if result is None:
|
||||
# 用 stdlib.system() 直接在控制台运行,输出直接显示
|
||||
# 避免 subprocess 管道捕获丢失输出
|
||||
sys_ret: int = stdlib.system(cmd)
|
||||
if sys_ret != 0:
|
||||
fb: t.CChar | t.CPtr = VLogger.fmt_buf()
|
||||
if fb is not None:
|
||||
viperlib.snprintf(fb, 1024, "subprocess.run 返回 None: %s", module_name)
|
||||
VLogger.error(fb, "LLC")
|
||||
return 1
|
||||
if result.returncode != 0:
|
||||
# 先直接输出 llc 的具体错误信息(VLogger.error 会 sys.exit,必须先输出)
|
||||
# 注意: subprocess 在 Windows 下将 stderr 合并到 stdout(si.hStdError = stdout_write)
|
||||
# 因此 result.stderr 总是 None,错误信息在 result.stdout 中
|
||||
# stdout 通常已含换行符,不再额外加 \n
|
||||
if result.stdout is not None:
|
||||
stdio.printf("%s", result.stdout)
|
||||
stdio.fflush(0)
|
||||
if result.stderr is not None:
|
||||
stdio.printf("%s", result.stderr)
|
||||
stdio.fflush(0)
|
||||
# 最后输出编译失败摘要(VLogger.error 会 sys.exit)
|
||||
fb = VLogger.fmt_buf()
|
||||
if fb is not None:
|
||||
viperlib.snprintf(fb, 1024, "编译失败 (module=%s, cmd=%s)", module_name, cmd)
|
||||
VLogger.error(fb, "LLC")
|
||||
@@ -524,23 +509,13 @@ def link_objs_to_exe(obj_paths: str, obj_paths_len: t.CSizeT,
|
||||
viperlib.snprintf(cmd, cmd_len, "%s %s -o %s %s",
|
||||
linker_cmd, obj_paths, linker_output, linker_flags)
|
||||
|
||||
result: subprocess.CompletedProcess | t.CPtr = subprocess.run(cmd, True, True)
|
||||
if result is None:
|
||||
VLogger.error("subprocess.run 返回 None", "link")
|
||||
return 1
|
||||
if result.returncode != 0:
|
||||
# 先直接输出 linker 的具体错误信息(VLogger.error 会 sys.exit,必须先输出)
|
||||
# stdout/stderr 通常已含换行符,不再额外加 \n
|
||||
if result.stdout is not None:
|
||||
stdio.printf("%s", result.stdout)
|
||||
stdio.fflush(0)
|
||||
if result.stderr is not None:
|
||||
stdio.printf("%s", result.stderr)
|
||||
stdio.fflush(0)
|
||||
# 最后输出链接失败摘要(VLogger.error 会 sys.exit)
|
||||
# 用 stdlib.system() 直接在控制台运行链接,输出直接显示
|
||||
# 避免 subprocess 管道捕获丢失输出(TransPyV 标准句柄可能无效)
|
||||
sys_ret: int = stdlib.system(cmd)
|
||||
if sys_ret != 0:
|
||||
fb: t.CChar | t.CPtr = VLogger.fmt_buf()
|
||||
if fb is not None:
|
||||
viperlib.snprintf(fb, 1024, "链接失败,返回码: %d, 命令: %s", result.returncode, cmd)
|
||||
viperlib.snprintf(fb, 1024, "链接失败,返回码: %d, 命令: %s", sys_ret, cmd)
|
||||
VLogger.error(fb, "link")
|
||||
return 1
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user