Skip to content

fix: drop <filesystem> from the ptobc public header - #1433

Open
jimmychou0 wants to merge 1 commit into
hw-native-sys:mainfrom
jimmychou0:zjm/ptobc-drop-filesystem
Open

fix: drop <filesystem> from the ptobc public header#1433
jimmychou0 wants to merge 1 commit into
hw-native-sys:mainfrom
jimmychou0:zjm/ptobc-drop-filesystem

Conversation

@jimmychou0

@jimmychou0 jimmychou0 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the G.FIL.02 fix merged in #1423 / !186: canonicalizeIoPath leaked #include <filesystem> and a std::filesystem::path return type into the public header ptobc/ptobc_format.h, so any out-of-tree consumer compiled with a pre-C++17 toolchain (GCC <= 7, or a cross/device toolchain without full C++17 headers) failed with:

fatal error: 'filesystem' file not found

Changes:

  • ptobc_format.h: remove #include <filesystem>; declare std::string canonicalizeIoPath(const std::string&) — the public header is back to basic-stdlib includes only.
  • ptobc_format.cpp: normalize lexically with llvm::sys::path::remove_dots (SmallString, remove_dot_dot=true). LLVM is already a dependency of ptobc_lib (links MLIRSupportLLVMSupport), so no new linkage. Symlink/absolute resolution is intentionally left to the stream open, which still reports unreachable paths, so the G.FIL.02 normalization requirement is preserved.

In-tree builds were never affected (global CMAKE_CXX_STANDARD 17, GCC >= 11 in CI); this only restores usability of the installed headers for consumers on older toolchains.

Test plan

  • 144 host, LLVM 19.1.7 assert build: full build warning/error-free under -Werror.
  • CTest 69/69 (45 PTO/PTODSL + 23 PTOBC + smoke).
  • ptobc encode ... -o ./sub/../enc.ptobc then decode ./sub/../enc.ptobc round trip: dot-path normalized correctly, output written to the right location; bad-input path still errors at open/magic check.
  • Changed-code compliance checker: 0 errors / 0 warnings on the two files.

Follow-up to the G.FIL.02 fix: canonicalizeIoPath leaked
std::filesystem::path and #include <filesystem> into ptobc_format.h,
so any out-of-tree consumer on a pre-C++17 toolchain (GCC <= 7 or a
stripped cross toolchain) failed with "'filesystem' file not found".

Switch the helper to std::string and normalize lexically with
llvm::sys::path::remove_dots (LLVM is already a dependency of
ptobc_lib), keeping <filesystem> out of the installed headers.
Symlink/absolute resolution is intentionally left to the stream open,
which still reports unreachable paths.

Validated on the 144 host (LLVM 19.1.7 assert build): full build clean
under -Werror, CTest 69/69, and an encode/decode round trip through a
"./sub/../" path writes to the normalized location.
@jimmychou0
jimmychou0 marked this pull request as ready for review September 2, 2026 02:42
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.

1 participant