Hi Alexis, Note that $(which printf) will not work reliably as printf can be a shell > built-in as is the case for macOS' default shell, i.e. zsh.
The use of which(1) here is unnecessary, as your script only needs to run on macOS. You can soundly assume that the executable version of printfc(1) exists at /usr/bin/printf. I forgot to mention too, clang(1) can be used to produce useful location information: *λ clang -print-search-dirs* programs: =/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin libraries: =/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0 *λ clang -print-libgcc-file-name* /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.builtins-x86_64.a Also, remember you can always select a version of C/C++ to compile with via `clang -std=…` (though I'm guessing everyone here already knows this). — John On Tue, 24 Feb 2026 at 21:20, Alexis <[email protected]> wrote: > Hi Branden, > > > Partly. What I need to know at this point is an easy way from a shell > > script to ask the system what its libc implementation is, when it's > > "libSystem.dylib" in particular.I don't know if there's any such thing > > as running an alternative libc on a macOS/Darwin system--maybe the > > system crashes; maybe Apple activates a kill switch in your Mac; or > > maybe things work more or less fine. > > what I propose might be too simple, especially in the light of John's > message, but one way to determine if the libc implementation is > libSystem.dylib could be: otool -L $(which printf) > > otool(1) is macOS's equivalent of ldd(1) and with the -L option it > "display[s] the names and version numbers of the shared libraries that > the object file uses, as well as the shared library ID if the file is > a shared library." — otool(1) > > for macOS (run in bash): > otool -L $(which printf) > /usr/bin/printf: > /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current > version 1356.0.0) > > for groff's build environment in nixpkgs on macOS (run in bash): > otool -L $(which printf) > /nix/store/sqv8nbx301w2xg2iqzim7hraid6ki1la-coreutils-9.8/bin/printf: > > /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation > (compatibility version 150.0.0, current version 2420.0.0) > > /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices > (compatibility version 1.0.0, current version 1226.0.0) > > /nix/store/rxfgl0ph6lk1h0py159gc74w6282q224-gmp-with-cxx-6.3.0/lib/libgmp.10.dylib > (compatibility version 16.0.0, current version 16.0.0) > /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current > version 1345.100.2) > > Note that $(which printf) will not work reliably as printf can be > a shell built-in as is the case for macOS' default shell, i.e. zsh. > > > Best > Alexis > >
