Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add documenation for updating QEMU binaries #38

Open
mooseword opened this issue Jul 8, 2021 · 1 comment
Open

Please add documenation for updating QEMU binaries #38

mooseword opened this issue Jul 8, 2021 · 1 comment

Comments

@mooseword
Copy link

I would like to help out by making PRs for keep the QEMU binaries up to date. I have been trying to no avail to build QEMU on a macOS M1 machine. Could someone help me fill out the steps to provide a guide for contributors?

Here is what I have been trying:

  1. clone the qemu project
  2. Download the diff provided by Alex. For example, viewing [v8,19/19] hvf: arm: Handle Windows 10 SMC call , and clicking the 'series' button to download diff
  3. apply the patch to qemu repo
cd /path/to/qemu/
git apply hvf-Implement-Apple-Silicon-Support.patch
  1. build qemu
  2. copy the build products to ACVM repo
cd /path/to/build/folder # right-click Products in Xcode-> Reveal in finder
cp qemu-system-aarch64 /path/to/ACVM/ACVM
cp qemu-img /path/to/ACVM/ACVM

However, I have not been able to build QEMU. I must admit this is may be due to me trying to avoid using Homebrew to install the additional build requirements. I have been able to compile everything myself except for glib. But if Homebrew is what it takes, then I will go for it.

The error I always hit when trying to build glib is when it tries to use its own libffi subproject itself, instead of using the libffi I built:

In file included from ../subprojects/libffi/src/aarch64/ffi.c:26:
subprojects/libffi/include/ffi.h:14:10: fatal error: 'ffi-aarch64.h' file not found
#include "ffi-aarch64.h"
@mooseword
Copy link
Author

Ok I have made progress, mostly thanks to upgrading to Python 3.9.6. If I make more progress, I will work on putting this together in a nicer way.

Building Embedded Binaries

Checking you can apply the patch

git clone https://gitlab.com/qemu-project/qemu.git

Look at the dates or SHAs for the patch you are trying to apply. The patches being the latest patch from alex . In my case this was May 19th, 2021.

git log --after="2021-05-18" --until="2021-05-20"

In my case, I went with 0a6f0c7

git checkout -b myPatchyBranchy
git reset --hard 0a6f0c7
git apply /path/to/your-Apple-Silicon-Support.patch

Building QEMU

Official docs

Dependencies

macOS ? (tested on 11.4 (20F71))

Python 3.9.6

Building glib will fail as previous versions of python report uname as x86_64

3.9.1

Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec  7 2020, 12:10:52) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.uname().machine
'x86_64'

3.9.6

Python 3.9.6 (v3.9.6:db3ff76da1, Jun 28 2021, 11:14:58) 
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.uname().machine
'arm64'

Setup

The combination of the following versions of libraries has been built, but not tested. These should also be built in this order.

additionally, ninja, which we will copy the executable to our bin

I used a custom directory for building out the dependencies, which may not be valid.

export $BDIR=/tmp/qemuBuildDepends


For each of the dependencies listed above (except glib), cd into their directory and run

PATH=$BDIR/bin:$PATH ./configure --prefix=$BDIR
make
make install

a. for pkg-config, add --with-internal-glib --disable-asm-optimizations to the ./configure command
b. for glib

cp your/ninja/executable $BDIR/bin
PATH=$BDIR/bin:$PATH meson _build --prefix=$BDIR
PATH=$BDIR/bin:$PATH ninja -C _build
PATH=$BDIR/bin:$PATH ninja -C _build install

Notes:
gettext takes the longest to build, at a minute or more. all others should be seconds.

cd qemu
PATH=$BDIR/bin:$PATH ./configure --prefix=$BDIR
make

ACVFM

cp qemuRepo/build/qemu-img acvmRepo/ACVM
cp qemuRepo/build/qemu-system-aarch64 acvmRepo/ACVM

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

No branches or pull requests

1 participant