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

Don't use default macos/arm64 deployment target in calculating the platform tag for fat binaries #390

Merged
merged 1 commit into from Dec 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/wheel/macosx_libfile.py
Expand Up @@ -33,6 +33,9 @@
- All structures signatures are taken form macosx header files.
- I think that binary format will be more stable than `otool` output.
and if apple introduce some changes both implementation will need to be updated.
- The system compile will set the deployment target no lower than
11.0 for arm64 builds. For "Universal 2" builds use the x86_64 deployment
target when the arm64 target is 11.0.
"""

import ctypes
Expand All @@ -53,6 +56,7 @@
LC_VERSION_MIN_MACOSX = 0x24
LC_BUILD_VERSION = 0x32

CPU_TYPE_ARM64 = 0x0100000c

mach_header_fields = [
("magic", ctypes.c_uint32), ("cputype", ctypes.c_int),
Expand Down Expand Up @@ -271,6 +275,16 @@ class FatArch(BaseClass):
try:
version = read_mach_header(lib_file, el.offset)
if version is not None:
if el.cputype == CPU_TYPE_ARM64 and len(fat_arch_list) != 1:
# Xcode will not set the deployment target below 11.0.0
# for the arm64 architecture. Ignore the arm64 deployment
# in fat binaries when the target is 11.0.0, that way
# the other architetures can select a lower deployment
# target.
# This is safe because there is no arm64 variant for
# macOS 10.15 or earlier.
if version == (11, 0, 0):
continue
versions_list.append(version)
except ValueError:
pass
Expand Down
1 change: 1 addition & 0 deletions tests/test_macosx_libfile.py
Expand Up @@ -23,6 +23,7 @@ def test_read_from_dylib():
("test_lib_multiple_fat.dylib", "10.14.0"),
("test_lib_10_10_10.dylib", "10.10.10"),
("test_lib_11.dylib", "11.0.0"),
("test_lib_10_9_universal2.dylib", "10.9.0"),
]
for file_name, ver in versions:
extracted = extract_macosx_min_system_version(
Expand Down
Binary file not shown.