Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Doesn't work on Big Sur #1

Open
kode54 opened this issue Apr 23, 2021 · 8 comments
Open

Doesn't work on Big Sur #1

kode54 opened this issue Apr 23, 2021 · 8 comments

Comments

@kode54
Copy link

kode54 commented Apr 23, 2021

This attempts to copy /usr/lib/libSystem.B.dylib into the bundle, which doesn't exist in the system. Nor do any of the other system dylibs, as they're in the pre-link system.

@kyr0
Copy link
Member

kyr0 commented Apr 24, 2021

Thank you for the report. This seems to strongly depend on the OS version. I wrote the script running Catalina. Maybe for Big Sur, it needs other paths. I guess the correct absolute paths on Big Sur (based on the pre-link process) can be identified by running ldd on the executable. One way of handling the issue would be to introduce a condition based on the OS version to select the correct paths depending on the version.

@kode54
Copy link
Author

kode54 commented Apr 24, 2021

otool -L does return absolute paths, but also returns paths to system libraries such as /usr/lib/libSystem.B.dylib, which doesn't exist on Big Sur. Technically, the script should be disregarding any paths under /usr/lib/, as that's immutable anyway.

@kyr0
Copy link
Member

kyr0 commented Apr 24, 2021

Hey. Yeah after I wrote my reply I took a look at the script I wrote. I remembered my code wrongly. Back in 2019 I had a list of system related libs. I thought it was still this code. But actually, I rewrote it already and it dynamically analzes the executable...
https://github.com/PCemOnMac/bundler/blob/master/rewrite_dylibs.js#L28

Are you running the script against an executable that you built on the same Big Sur system?

@kode54
Copy link
Author

kode54 commented Apr 24, 2021

Yes. It imports libraries that don't exist, because Big Sur only provides the entire contents of /usr/lib/ and /System/Library/Frameworks/ as pre-linked cache blobs for all supported architectures.

@kyr0
Copy link
Member

kyr0 commented Apr 24, 2021

I see. Yeah, that explains... so my assumption / code of the script as of now is wrong for all OS versions from Big Sur upwards probably. Do you have an idea how to deal with that on Big Sur? Unfortunately, I have no Big Sur system here to get my hands dirty :)

@kode54
Copy link
Author

kode54 commented Apr 24, 2021

Well, on Big Sur, the /usr/lib/ and /System/Library/Frameworks/ paths will be immutable, so their contents should be trusted to stay put. Anything that should be bundled will exist in other paths, such as /Library/Frameworks/, /usr/local/lib/, or /opt/homebrew/lib/.

System dylib or framework objects exist here:

% ls -lah /System/Library/dyld/
total 7731224
drwxr-xr-x   10 root  wheel   320B Jan  1  2020 .
drwxr-xr-x  133 root  wheel   4.2K Jan  1  2020 ..
-rwxr-xr-x    1 root  admin   2.4G Jan  1  2020 aot_shared_cache
-rwxr-xr-x    1 root  admin     0B Jan  1  2020 aot_shared_cache.t8027
-rwxr-xr-x    1 root  admin   2.1G Jan  1  2020 dyld_shared_cache_arm64e
-rwxr-xr-x    1 root  admin   729K Jan  1  2020 dyld_shared_cache_arm64e.map
-rwxr-xr-x    1 root  admin   2.3G Jan  1  2020 dyld_shared_cache_x86_64
-rwxr-xr-x    1 root  admin   562K Jan  1  2020 dyld_shared_cache_x86_64.map
-rwxr-xr-x    1 root  admin   2.3G Jan  1  2020 dyld_shared_cache_x86_64h
-rwxr-xr-x    1 root  admin   562K Jan  1  2020 dyld_shared_cache_x86_64h.map

@kyr0
Copy link
Member

kyr0 commented Apr 24, 2021

I see, thank you for the insight. Could you provide me an example output of otool -L run against a built and linked pcem executable on Big Sur too?

@kode54
Copy link
Author

kode54 commented Apr 24, 2021

Sure:

% otool -L pcem.arm64
pcem.arm64:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/OpenAL.framework/Versions/A/OpenAL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 164.0.0)
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 23.0.0)
	/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
	/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1000.0.0)
	/opt/homebrew/opt/wxmac/lib/libwx_osx_cocoau_xrc-3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/homebrew/opt/wxmac/lib/libwx_osx_cocoau_html-3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/homebrew/opt/wxmac/lib/libwx_osx_cocoau_qa-3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/homebrew/opt/wxmac/lib/libwx_osx_cocoau_core-3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/homebrew/opt/wxmac/lib/libwx_baseu_xml-3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/homebrew/opt/wxmac/lib/libwx_baseu_net-3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/homebrew/opt/wxmac/lib/libwx_baseu-3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib (compatibility version 15.0.0, current version 15.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)

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

No branches or pull requests

2 participants