.asm code to determine the optimal build configuration (32-bit/64-bit, Irvine/Native, main/_start).osxcross and Darling.Irvine32.inc library, featuring a persistent path saver for a hassle-free setup.Before using the extension, you need to install the required tools based on your operating system.
To natively compile and run ARM64 assembly on your Apple Silicon Mac, simply ensure you have the Xcode Command Line Tools installed (which provides clang, as, and ld):
xcode-select --install
If you don't have it installed, download and install MSYS2 first. Then, open your MSYS2 terminal and run the pacman command to install the required assemblers and linkers:
⚠️ Important Note:Please download MSYS2 ONLY from the official website using the button below to avoid missing dependencies or tampered binaries and copy this command.
pacman -S mingw-w64-i686-gcc mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-gdb mingw-w64-x86_64-nasm make p7zip mingw-w64-x86_64-uasm
Choose your Linux distribution below to install the required dependencies (nasm, mingw-w64, wine, uasm, binutils, ghex, etc.).
sudo apt update && sudo apt install -y nasm gcc-mingw-w64 wine binutils ghex unzip curl
sudo dnf install -y nasm mingw64-gcc wine binutils ghex unzip curl
sudo xbps-install -S nasm cross-x86_64-w64-mingw32-gcc wine binutils ghex unzip curl
sudo emerge --ask dev-lang/nasm dev-util/mingw64-toolchain app-emulation/wine-vanilla sys-devel/binutils dev-util/ghex app-arch/unzip net-misc/curl
sudo eopkg install nasm mingw-w64 wine binutils ghex unzip curl
sudo zypper install -y nasm mingw64-gcc wine binutils ghex unzip curl
sudo apk add --no-cache nasm mingw-w64-gcc wine binutils ghex unzip curl sed
pkg install nasm mingw-w64-gcc wine binutils ghex unzip curl
⚠️ UASM Manual Installation:If your distribution does not have
uasmin its official repositories, download and install it manually:curl -fsSL https://www.terraspace.co.uk/uasm257_linux64.zip -o uasm_linux.zip unzip -q uasm_linux.zip -d uasm_temp sudo mv uasm_temp/uasm /usr/local/bin/ sudo chmod +x /usr/local/bin/uasm rm -rf uasm_linux.zip uasm_tempSHA256:
d9fecb2226f66c7e48d81402fc13a67eda23507be9067a2983ee14ec7d68a94f
sudo pacman -S --needed nasm mingw-w64-gcc wine binutils ghex unzip curl
yay -S --needed uasm
🦾 ARM Execution on x86-64
Native-like ARM Support on ArchLinuxThe extension supports running ARM architecture code seamlessly on your x86-64 machine. Make sure to install the required toolchains:
sudo pacman -S aarch64-linux-gnu-binutils sudo pacman -S arm-none-eabi-binutils arm-none-eabi-gcc
🪐 RISC-V Execution & Cross-Compilation
Run RISC-V 32/64/128-bit on Arch LinuxTo enable full RISC-V support (including the experimental 128-bit mode) on your Arch-based system, install the GNU toolchain and QEMU emulators:
sudo pacman -S riscv64-linux-gnu-binutils qemu-user-static sudo pacman -S riscv64-linux-gnu-gcc riscv64-linux-gnu-glibc sudo pacman -S qemu-user
🍎 The Mach-O Bridge
macOS Cross-Compilation & Execution on Arch Linux⚠️ Note: Currently, running macOS code is officially tested and supported ONLY on Arch Linux.
This guide documents the complete workflow to transform an Arch Linux system into a full-blown development environment capable of Assembling, Linking, and Running macOS binaries (Mach-O format) natively on Linux.
🚀 Phase 1: Initial AUR Setup & Darling Environment
We begin by attempting to install the core components from the Arch User Repository (AUR).
# Using 'yay' to fetch the runner and the cross-linker yay -S darling-bin osxcross-git🔹 What Happened?
- Darling Success:
darling-bin(the Darwin/macOS emulation layer) installed successfully as a pre-compiled package.- osxcross Failure: The
osxcross-gitpackage failed due to a 404 Not Found error.
- Reason: The AUR package relies on a dead link for the
MacOSX10.11.sdk. Apple frequently removes older SDKs from its servers.🔹 Activating the Darling Kernel (Optional/User-space)
To ensure the environment is ready for execution, you might need to enable the kernel module or initialize the userspace server:
# Note: Modern Darling uses a userspace server (darlingserver), # but legacy installs might require the kernel module: yay -S darling-mach-dkms-git sudo modprobe darling-mach
🛠️ Phase 2: Manual Construction of
osxcrossTo bypass the dead SDK links, we manually build
osxcrossusing a modern SDK (11.3).1. Install Essential Dependencies
sudo pacman -S --needed clang cmake libxml2 zlib openssl pbzip2 mpdecimal2. Clone the Official Repository
git clone https://github.com/tpoechtrager/osxcross.git cd osxcross3. Fetching the SDK "The Manual Way"
We download the
MacOSX11.3.sdkfrom a verified mirror and place it in thetarballs/directory:wget -nc https://github.com/joseluisq/macosx-sdks/releases/download/11.3/MacOSX11.3.sdk.tar.xz -P tarballs/4. Initiate the Build Process
Run the build script in unattended mode (this takes several minutes depending on CPU power):
UNATTENDED=1 ./build.sh
⚙️ Phase 3: System Integration & Global Configuration
Once built, we must make the macOS tools available system-wide and ensure the linker can find its shared libraries.
1. Copying to Global Binaries
sudo cp -r target/bin/* /usr/local/bin/ sudo cp -r target/lib/* /usr/local/lib/ sudo mkdir -p /usr/local/SDK/ sudo cp -r target/SDK/* /usr/local/SDK/ 2>/dev/null || true2. Resolving Shared Library Issues (
libtapi,libxar)If the linker fails to find shared objects, we must register
/usr/local/libin the system's dynamic linker cache:# Create a new configuration file for local libraries echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/usr-local.conf # Update the linker cache sudo ldconfig
✅ Environment Verification
To confirm that your Linux system can now generate macOS binaries, verify the linker version:
x86_64-apple-darwin20.4-ld -v> Result: If the version info (e.g.,
PROJECT:ld64-711) appears without errors, your Arch-macOS Gateway is officially open! 🌍🔥
Summary of Build Commands (for extension.ts)
Step Command Assemble nasm -f macho64 code.asm -o code.oLink x86_64-apple-darwin20.4-ld code.o -o code -macosx_version_min 10.11 -lSystem -syslibroot /usr/local/SDK/MacOSX11.3.sdkRun darling ./code
Type the prefix in a .asm file and hit Tab for instant boilerplate code!
| Prefix | Description |
|---|---|
linux32-main | Linux 32-bit boilerplate using main |
linux32-start | Linux 32-bit boilerplate using _start |
linux64-main | Linux 64-bit boilerplate using main |
linux64-start / arch-start | Linux 64-bit boilerplate using _start (Prints "i use Archlinux BTW") |
| Prefix | Description |
|---|---|
win32-std-main | Win32 pure Windows API using main |
win32-std-start | Win32 pure Windows API using _start |
win64-std-main | Win64 pure Windows API using main |
win64-std-start | Win64 pure Windows API using _start |
win32-std-main-irvin | Win32 pure Windows API using main with Irvine32 |
win32-std-start-irvin | Win32 pure Windows API using _start with Irvine32 |
If your project uses the Irvine32 library, download it, extract it to a known folder, and the extension will handle the linking automatically.
.asm file in VS Code.Ctrl+Shift+P) and type Ahmed x86 ASM: Run Code.Irvine32.lib only the very first time you need it.Ctrl+Shift+P and search for Ahmed x86 ASM: Reset Irvine Library Path.