-
Notifications
You must be signed in to change notification settings - Fork 1
Building on M1 Mac
SamJakob edited this page Apr 3, 2023
·
18 revisions
You should be able to follow the instructions in the project README file to automatically set up and install the build chain (in a prefix within the repository). If you encounter problems, please proceed with Install the build chain (manual steps).
Once you have the build chain set up, just follow Building GNU-EFI
and Install remaining dependencies.
Compile x86_64-elf-binutils
with the tools we require, then compile the cross-compiler (x86_64-elf-gcc
) without a hosted standard library.
- Install
x86_64-elf-binutils
in interactive mode. We need to add--enable-targets=all
to get EFI app support:brew install --build-from-source x86_64-elf-binutils -i # after you ran brew install, it should have displayed a message indicating # which prefix to install to. ./configure --enable-targets=all --target="x86_64-elf" --disable-nls --prefix="<< the prefix from brew install >>" make make install exit
- Next, run a similar procedure for the GCC ELF cross-compile toolchain:
brew install x86_64-elf-gcc --build-from-source -i # gcc misbehaves if you don't install from a sub-directory mkdir x86_64-elf-gcc-build; cd x86_64-elf-gcc-build # after you ran brew install, it should have displayed a message indicating # which prefix to install to. ../configure --target=x86_64-elf --prefix="<< the prefix from brew install >>" --disable-nls --without-isl --without-headers --enable-languages=c,c++ --with-as="$(which x86_64-elf-as)" --with-ld="$(which x86_64-elf-ld)" --disable-hosted-libstdcxx # now make gcc and libgcc make all-gcc make install-gcc make all-target-libgcc make install-target-libgcc exit
Build the patched copy of gnu-efi
3.0.14 in third-party/gnu-efi
.
- If you don't already have Homebrew installed, I'd highly recommend installing it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Grab a supplementary ELF header (
elf.h
) file with:curl https://gist.githubusercontent.com/SamJakob/8b0de39e1d1fcde5c7df204d7e2d899b/raw/elf.h | sudo tee /usr/local/include/elf.h
I've modified this file based on suggestions in a reply such that it compiles on macOS 11.
- Build
gnu-efi
with:export CROSS_COMPILE="x86_64-elf-" export CFLAGS='-I /usr/local/include' make sudo ARCH=x86_64 make install
Then, install the remaining build-system dependencies
brew install dosfstools
brew install mtools
Credits:
- original
elf.h
for macOS: https://gist.github.com/mlafeldt/3885346 - (lunablanca) build gnu-efi for M1 Mac: https://translate.google.com/translate?hl=en&sl=ja&u=https://lunablanca.net/build-gnu-efi-m1/&prev=search&pto=aue