Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Xcode 12.5.1 missing /usr/lib/libMobileGuestalt.dylib #1007

Open
awakecoding opened this issue Aug 11, 2021 · 7 comments · Fixed by #1109
Open

Xcode 12.5.1 missing /usr/lib/libMobileGuestalt.dylib #1007

awakecoding opened this issue Aug 11, 2021 · 7 comments · Fixed by #1109

Comments

@awakecoding
Copy link

Library
/usr/lib/libMobileGuestalt.dylib

Test Application
Xcode 12.5.1

Steps To Reproduce
Extract Xcode_12.5.1.xip, copy to /Applications/Xcode.app, run xcode-select --switch /Applications/Xcode.app

System Information
This is Ubuntu 20.04 inside WSL2, I have built the latest Darling sources myself.

When trying to run any of the Xcode command-line tools (clang, otool, lipo) I get the following error:

Darling [/usr/lib]$ clang --version
dyld: Library not loaded: /usr/lib/libMobileGestalt.dylib
  Referenced from: /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation
  Reason: image not found
abort_with_payload: reason: Library not loaded: /usr/lib/libMobileGestalt.dylib
  Referenced from: /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation
  Reason: image not found; code: 1
Abort trap: 6

I googled and found that libMobileGuestalt.dylib was part of the dyld cache in recent macOS versions, so I used dyld-shared-cache-extractor to grab it from a mac. I manually copied it over to see if it would work (it was worth a shot I guess), with the following result:

Darling [/usr/lib]$ mv libMobileGestalt.dylib2 libMobileGestalt.dylib Darling [/usr/lib]$ clang --version dyld: Library not loaded: /usr/lib/libMobileGestalt.dylib Referenced from: /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation Reason: no suitable image found. Did find: /usr/lib/libMobileGestalt.dylib: overlapping segments /usr/lib/libMobileGestalt.dylib: stat() failed with errno=22 /usr/lib/libMobileGestalt.dylib: overlapping segments abort_with_payload: reason: Library not loaded: /usr/lib/libMobileGestalt.dylib Referenced from: /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation Reason: no suitable image found. Did find: /usr/lib/libMobileGestalt.dylib: overlapping segments /usr/lib/libMobileGestalt.dylib: stat() failed with errno=22 /usr/lib/libMobileGestalt.dylib: overlapping segments; code: 1 Abort trap: 6

The docs say there is some level of support for Xcode, so was it broken recently?

@rdrpenguin04
Copy link

This is the same issue I mentioned in #1003; namely, they're missing a library that newer Xcode versions use. You can try an older version though; I only had patience to try latest when I last tried.

If you have a version of macOS that has libMobileGestalt.dylib, you could talk with the developers and get stubs made.

@awakecoding
Copy link
Author

@rdrpenguin04 I just tried following the instructions for generating the stubs on libMobileGestalt.dylib on a mac, it unfortunately fails. I guess this is a case where you need an experienced darling developer, not just someone poking around like me:

image

@rdrpenguin04
Copy link

Could @facekapow or one of the other devs maybe help with this some?

@awakecoding
Copy link
Author

Is this issue still there? I've been blocked on my initial Xcode-in-darling experimentation because of this, and I have no idea which version of Xcode was the last to work. I need at least XCode 12.x, and Xcode 13 is coming out soon.

@hasselmm
Copy link

Not sure, if libMobileGuestalt really is needed: I don't have that library on my Mac Mini with macOS 11.6, but even XCode 13.1 is running flawlessly. The tools in /Application/XCode of XCode 12.5.1 also don't seem to need that library. Rather seems to me like Darling is building compiler-rt or DVTFoundation with invalid compiler flags.

@facekapow
Copy link
Member

facekapow commented Nov 19, 2021

Actually, you do have that library on your Mac; the thing is that from macOS 11 onward, all system libraries are kept in a "dyld shared cache". Basically, all the system libraries are combined into one large binary that dyld (the dynamic linker) searches through, and they're no longer separate files on your disk. See https://iphonedev.wiki/index.php/Dyld_shared_cache, https://developer.apple.com/forums/thread/692383, and https://mjtsai.com/blog/2020/06/26/reverse-engineering-macos-11-0/ for more information.

This also poses a problem for us since our simple stub generator no longer works on macOS 11 and onward.

@slonopotamus
Copy link

So, is it fixed by #1109?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants