M2Sim requires ELF binaries for execution. macOS compiles to Mach-O by default, so we need a cross-compiler to build benchmarks that can run in the simulator.
# Install the cross-compiler toolchain
brew install aarch64-elf-gcc
# Verify installation
aarch64-elf-gcc --versionNote: This installs aarch64-elf-binutils as a dependency.
# Compile to bare-metal ELF
aarch64-elf-gcc -O2 -static -nostdlib -o program.elf program.c
# Or with newlib for C library support
aarch64-elf-gcc -O2 -static -specs=nosys.specs -o program.elf program.c- Official Homebrew package
- Stable, well-maintained
- Includes binutils (objdump, etc.)
- Large installation (~1GB with dependencies)
- Build time if not bottled
If you have LLVM installed:
# Use clang with explicit target
clang --target=aarch64-elf -O2 -static -nostdlib -o program.elf program.cNote: May need additional linker configuration for bare-metal targets.
ARM provides official embedded toolchains:
brew install --cask gcc-arm-embedded
# or
brew install gcc-aarch64-embeddedAfter installation, verify:
# Check compiler
aarch64-elf-gcc --version
# Check it produces ELF
echo 'int main() { return 0; }' > test.c
aarch64-elf-gcc -O2 -static -nostdlib -e main -o test.elf test.c
file test.elf # Should show "ELF 64-bit LSB executable, ARM aarch64"
rm test.c test.elfOnce installed, use this to compile CoreMark:
cd benchmarks/coremark
aarch64-elf-gcc -O2 -static -DITERATIONS=10000 \
-DCOMPILER_FLAGS=\"-O2\" \
core_list_join.c core_main.c core_matrix.c core_state.c core_util.c \
-o coremark.elf- Issue #149: Cross-compiler setup task
- Issue #147: CoreMark integration
- Homebrew formula: https://formulae.brew.sh/formula/aarch64-elf-gcc