DecisionTree::dot(name, ...): skip system() shellout on iOS#2547
Merged
Conversation
Building gtsam for iOS (apple-clang, iphoneos sysroot) fails on every
DecisionTree-instantiating TU with:
DecisionTree-inl.h:1081:9: error: 'system' is unavailable: not
available on iOS
system(("dot -Tpdf " + name + ".dot -o " + name + ".pdf >& /dev/null")
^
iOS marks std::system() as `__attribute__((unavailable))` in
<stdlib.h>, so even a never-executed call site fails the compile.
The PDF rendering is a debug convenience layered on top of the .dot
file the same function always writes — keep the .dot emission
unconditional, gate just the shellout behind !TARGET_OS_IPHONE.
Callers who want a PDF on an iOS-targeted build can run
`dot -Tpdf <name>.dot -o <name>.pdf` themselves on any host that
has a shell. Behavior on every non-iOS target is unchanged.
ProfFan
approved these changes
May 29, 2026
Member
|
Cool! merging. |
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.
Problem
Building gtsam for iOS (apple-clang, iphoneos sysroot) fails on every TU that instantiates
DecisionTreewith:iOS marks
std::system()as__attribute__((unavailable))in<stdlib.h>, so even a never-executed call site fails the compile.Fix
The PDF rendering inside
DecisionTree<L, Y>::dot(const std::string& name, ...)is a debug convenience layered on top of the.dotfile the same function always writes. Keep the.dotemission unconditional, gate just thesystem(...)shellout behind!TARGET_OS_IPHONE. Callers who want a PDF on an iOS-targeted build can rundot -Tpdf <name>.dot -o <name>.pdfthemselves on any host that has a shell.<TargetConditionals.h>is added inside an#if defined(__APPLE__)guard at the top of the file so non-Apple builds don't get a missing header.Behavior change
DecisionTree::dot(name, ...)writes the.dotfile and skips the PDF rendering.TARGET_OS_IPHONEis 0 on macOS and undefined elsewhere; theelsebranch always selects, and the patch reduces to a no-op preprocessor pass.Test
Verified by rebuilding gtsam against the iphoneos26.0 SDK with apple-clang: previously the build hit ~24
error: 'system' is unavailableacrossdiscrete/Algebraic*,Discrete*, etc.; with this patch the build completes cleanly.