Skip to content

fix: iOS compilation issues (fat binary and runtime symbols)#128

Open
YubinghanBai wants to merge 1 commit intothewh1teagle:mainfrom
YubinghanBai:fix-ios-build
Open

fix: iOS compilation issues (fat binary and runtime symbols)#128
YubinghanBai wants to merge 1 commit intothewh1teagle:mainfrom
YubinghanBai:fix-ios-build

Conversation

@YubinghanBai
Copy link

This commit fixes two major iOS compilation issues:

  1. Fat Binary Support: iOS precompiled libraries (.a files) in xcframework are universal binaries containing multiple architectures (x86_64, arm64). Rust linker doesn't support linking fat binaries directly, causing "Unsupported archive identifier" errors.

    Solution: Added extract_thin_lib_for_ios() function to detect and extract the specific architecture needed for each target using lipo.

  2. Missing Runtime Symbols: iOS linking failed with undefined symbols:

    • ___chkstk_darwin: C++ stack check function
    • ___isPlatformVersionAtLeast: iOS platform version check

    Solution:

    • Added ios_link_search_path() to locate clang runtime libraries
    • Link libclang_rt.ios.a (or libclang_rt.iossim.a for simulator)
    • Set minimum iOS deployment target via -platform_version linker flag

Tested on:

  • aarch64-apple-ios (iOS device)
  • aarch64-apple-ios-sim (iOS simulator)

Fixes #67

This commit fixes two major iOS compilation issues:

1. **Fat Binary Support**: iOS precompiled libraries (.a files) in xcframework
   are universal binaries containing multiple architectures (x86_64, arm64).
   Rust linker doesn't support linking fat binaries directly, causing
   "Unsupported archive identifier" errors.

   Solution: Added extract_thin_lib_for_ios() function to detect and extract
   the specific architecture needed for each target using lipo.

2. **Missing Runtime Symbols**: iOS linking failed with undefined symbols:
   - ___chkstk_darwin: C++ stack check function
   - ___isPlatformVersionAtLeast: iOS platform version check

   Solution:
   - Added ios_link_search_path() to locate clang runtime libraries
   - Link libclang_rt.ios.a (or libclang_rt.iossim.a for simulator)
   - Set minimum iOS deployment target via -platform_version linker flag

Tested on:
- aarch64-apple-ios (iOS device)
- aarch64-apple-ios-sim (iOS simulator)

Fixes thewh1teagle#67
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

Successfully merging this pull request may close these issues.

Fix build for IOS

1 participant