Skip to content

fix(build): 修复非 glibc libc 平台缺少 fcloseall 导致的编译失败 - #76

Merged
xiaoxuan-yu merged 1 commit into
SPONGEMM:lab/pkufrom
wszqkzqk:fix/non-glibc-fcloseall
Oct 8, 2026
Merged

xiaoxuan-yu merged 1 commit into
SPONGEMM:lab/pkufrom
wszqkzqk:fix/non-glibc-fcloseall

Conversation

@wszqkzqk

@wszqkzqk wszqkzqk commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

问题

fcloseall() 是 glibc 的扩展函数,Android bionic、musl 等 libc 中都不存在,导致 SPONGE/control.cpp 和 SPONGE/utils/control/error.hpp 在这些平台上编译时报 use of undeclared identifier 'fcloseall'。在 Termux(bionic,ARM64)上可直接复现,是构建的阻塞点。

方案

两处 fcloseall() 统一替换为标准 C 的 fflush(NULL):它刷新所有打开的输出流,满足此处需求(错误退出前的输出刷新,以及 Clear() 的清理)。

common.h 中原有的 Apple 兼容 shim 本来就把 fcloseall 映射为 fflush(NULL),说明该行为在上游已支持的 macOS 上就是可接受的实现,因此一并移除已无用的 shim。不引入新的平台判断,Android/bionic、musl 等非 glibc 平台均可直接编译。

验证

  • macOS 上用 pixi dev-cpu(clang 22.1)全量构建通过(62/62)。
  • Android Termux(ARM64,bionic)上用 clang 21.1.8 构建并运行通过,此前正是 fcloseall 阻塞构建。

fcloseall is a glibc extension and is absent on other libcs (bionic,
musl, etc.), which breaks the build on those platforms. fflush(NULL)
provides the same flushing behavior needed here and is what the
existing Apple compatibility shim already maps fcloseall to, so it is
a tested behavior on a supported platform. The now-dead shim is
removed along with the call-site changes.

Signed-off-by: Zhou Qiankang <wszqkzqk@qq.com>
@wszqkzqk wszqkzqk changed the title fix(build): use portable stream flushing instead of glibc fcloseall fix(build): 修复非 glibc libc 平台缺少 fcloseall 导致的编译失败 Sep 29, 2026
@wszqkzqk
wszqkzqk changed the base branch from master to lab/pku September 29, 2026 05:22
@xiaoxuan-yu
xiaoxuan-yu merged commit bd75e2d into SPONGEMM:lab/pku Oct 8, 2026
41 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants