diff --git a/src/wheel/macosx_libfile.py b/src/wheel/macosx_libfile.py index f8ad3cab..8918039f 100644 --- a/src/wheel/macosx_libfile.py +++ b/src/wheel/macosx_libfile.py @@ -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 @@ -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), @@ -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 diff --git a/tests/test_macosx_libfile.py b/tests/test_macosx_libfile.py index 337f0e30..614e723c 100644 --- a/tests/test_macosx_libfile.py +++ b/tests/test_macosx_libfile.py @@ -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( diff --git a/tests/testdata/macosx_minimal_system_version/test_lib_10_9_universal2.dylib b/tests/testdata/macosx_minimal_system_version/test_lib_10_9_universal2.dylib new file mode 100755 index 00000000..26ab109c Binary files /dev/null and b/tests/testdata/macosx_minimal_system_version/test_lib_10_9_universal2.dylib differ