mirror of https://github.com/bol-van/zapret/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.6 KiB
3.6 KiB
MacOS Refactoring Guide
This document describes the refactoring changes made to improve MacOS compatibility for both x86_64 and Apple Silicon (ARM64) architectures.
Overview
The refactoring includes:
- Automatic architecture detection for MacOS
- Support for both x86_64 and ARM64 architectures
- Universal binary compilation support
- Improved build system for cross-compilation
- Better binary detection and installation
Architecture Detection
Automatic Detection
The system now automatically detects the MacOS architecture:
- x86_64: Intel-based Macs
- arm64: Apple Silicon (M1, M2, etc.)
Environment Variables
MACOS_TARGET: Override the target architecture (e.g.,x86_64-apple-macos10.8)
Build Targets
Single Architecture Build
# Build for current architecture
make mac
# Build for specific architecture
MACOS_TARGET="arm64-apple-macos10.8" make mac
MACOS_TARGET="x86_64-apple-macos10.8" make mac
Universal Binary Build
# Build universal binary (x86_64 + ARM64)
make mac-universal
New Scripts
macos_arch_detect.sh
A utility script for MacOS architecture management:
# Detect architecture
./scripts/macos_arch_detect.sh detect
# Create architecture-specific links
./scripts/macos_arch_detect.sh links
# Build for current architecture
./scripts/macos_arch_detect.sh build
# Build universal binary
./scripts/macos_arch_detect.sh universal
GitHub Actions
The CI/CD pipeline now supports both architectures:
- macos-12: x86_64 builds
- macos-13: ARM64 builds
Binary Naming Convention
mac64: x86_64 binaries (legacy)mac64-arm64: ARM64 binaries- Universal binaries are created using
lipotool
Installation
Easy Install
The installer automatically detects the architecture and installs appropriate binaries:
./install_easy.sh
Manual Build
# For current architecture
make mac
# For universal binary
make mac-universal
Troubleshooting
Architecture Mismatch
If you encounter architecture mismatch errors:
-
Check current architecture:
uname -m -
Set correct target:
export MACOS_TARGET="arm64-apple-macos10.8" # for Apple Silicon export MACOS_TARGET="x86_64-apple-macos10.8" # for Intel -
Rebuild:
make clean make mac
Universal Binary Issues
If universal binary creation fails:
- Ensure both architectures are available
- Check
lipotool availability - Verify target strings are correct
Development
Adding New Components
When adding new components that need MacOS support:
- Add
mactarget to Makefile - Add
mac-universaltarget if needed - Use
$(MACOS_TARGET)variable for architecture-specific builds
Testing
Test on both architectures:
- Intel Mac:
MACOS_TARGET="x86_64-apple-macos10.8" make mac - Apple Silicon:
MACOS_TARGET="arm64-apple-macos10.8" make mac - Universal:
make mac-universal
Compatibility
Supported MacOS Versions
- Minimum: macOS 10.8 (Mountain Lion)
- Recommended: macOS 11+ (Big Sur)
Architecture Support
- ✅ x86_64 (Intel)
- ✅ arm64 (Apple Silicon)
- ✅ Universal binaries
Performance Considerations
- Single architecture binaries are smaller and faster
- Universal binaries work on both architectures but are larger
- ARM64 binaries may be faster on Apple Silicon due to native optimization
Future Improvements
- Add support for newer MacOS target versions
- Implement automatic universal binary detection
- Add architecture-specific optimization flags
- Support for cross-compilation from Linux to MacOS