Skip to content

xcbuild.xcrun: issues in fallback handling #376958

Description

@niklaskorz

Moving this to an issue before I start working on it, as I might not immediately get to it and then forget about the issue description on Matrix:

[@emilazy]:
we do already shadow the rest of the Xcode tools
which has caused some problems with xcrun (can I snipe you into implementing the fix for those)

first issue is that we implemented fallback handling so that if /usr/bin is in the $PATH then stuff like git will use Xcode if you don't have it Nix-ly. but we did it not quite right, missing paths etc.

we should instead remove this special case and replace it by a simpler one: if the executable we find is itself an xcrun stub (like /usr/bin/git), call out to /usr/bin/xcrun instead
(we know stubs can be detected because Apple's library that they use for xcrun has a function for it that it uses)

the second issue is

[@reckenrode]:
It doesn’t support absolute paths with symlinks, but Apple’s does. It apparently broke someone’s CMake setup. There’s an upstream issue about it.
I also hit it when working on the SDK update. That’s why xcodebuild uses a wrapper. It can be dropped if that bug is fixed.

Additional information by Emily:

btw, the caveat to "(we know stubs can be detected because Apple's library that they use for xcrun has a function for it that it uses)" is that the library is private
we could probably just add a declaration and use it but it might be nicer to figure out how to detect them ourselves
/usr/bin/clang and /usr/bin/git are identical, so I guess it could literally just be checking the hash :)
but I'm hoping they left a more obvious clue somewhere, since that hash can presumably also change
ah, if you strings -a it has an embedded plist identifying itself as com.apple.dt.xcode_select.tool-shim
so maybe find out the "correct" way to get at that plist
oh, it also just plain has a section called __xcrun_shim
(does macOS ship with any nice libraries to look at Mach-O files?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: darwinRunning or building packages on Darwin

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions