fix: drop <filesystem> from the ptobc public header - #1433
Open
jimmychou0 wants to merge 1 commit into
Open
Conversation
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
marked this pull request as ready for review
September 2, 2026 02:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to the G.FIL.02 fix merged in #1423 / !186:
canonicalizeIoPathleaked#include <filesystem>and astd::filesystem::pathreturn type into the public headerptobc/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:Changes:
ptobc_format.h: remove#include <filesystem>; declarestd::string canonicalizeIoPath(const std::string&)— the public header is back to basic-stdlib includes only.ptobc_format.cpp: normalize lexically withllvm::sys::path::remove_dots(SmallString,remove_dot_dot=true). LLVM is already a dependency ofptobc_lib(linksMLIRSupport→LLVMSupport), 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
-Werror.ptobc encode ... -o ./sub/../enc.ptobcthendecode ./sub/../enc.ptobcround trip: dot-path normalized correctly, output written to the right location; bad-input path still errors at open/magic check.