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

Does not use system dylib when cross-compiling on macOS #84

Closed
kornelski opened this issue Nov 21, 2021 · 4 comments · Fixed by #85 or #181
Closed

Does not use system dylib when cross-compiling on macOS #84

kornelski opened this issue Nov 21, 2021 · 4 comments · Fixed by #85 or #181

Comments

@kornelski
Copy link
Contributor

kornelski commented Nov 21, 2021

macOS has fat binary dylibs with executable code for multiple architectures. When cross-compiling between macOS on x86 and ARM, all system libraries are usable on both architectures, including libz.1.dylib.

The current logic gives up on system zlib when target != host, which causes unnecessary static linking when the target and host are x86_64-apple-darwin and aarch64-apple-darwin.

@kornelski
Copy link
Contributor Author

Detection whether /usr/lib/libz.dylib is actually available as a fat binary is unfortunately complicated, because since macOS 11 all system libraries are part of a monolithic shared cache, and don't exist as individual files in the file system any more (library paths are merely magic keys for lookup in system cache). Apple recommends checking their existence by running dlopen, but that's highly problematic for cross-compilation. For libz it may be enough to just assume it's present.

@kornelski
Copy link
Contributor Author

Similar issue when cross-compiling to iOS. iOS has libz shared library.

@glandium
Copy link
Contributor

I don't think this is fixed. As a matter of fact I have a cross-compile job that ends up compiling zlib (and failing, because it's using clang trunk, which broke building zlib < 1.3.1).

@Byron
Copy link
Member

Byron commented Jan 26, 2024

There is now v1.1.15 of libz-sys with libz 1.3.1 in case this changes anything.

glandium added a commit to glandium/libz-sys that referenced this issue Jan 29, 2024
Really fixes rust-lang#84. This is what rust-lang#85 intended, as far as I can tell, but
the logic was such that it didn't work for cross-compiles from e.g.
Linux (apple_to_apple would be false, leading to the build_zlib path
being taken)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants