1# Experimental QEMU8 build system 2 3This is a build of QEMU8 from scratch on Linux, using AOSP-specific compiler 4toolchain and sysroot (based on an old glibc-2.17 to ensure the generated 5binaries run on a vast number of distributions). 6 7## Prerequisite: 8 9Ensure podman is installed with `sudo apt-get install podman` 10 11## Reproducing a build in AOSP 12 13This secion is about rebuilding QEMU with AOSP toolchain (with the `repo` tool). 14Information about how to iterate on this build can be found in the next section. 15 16If you have an AOSP checkout, run: 17 18```sh 19$ANDROID_BUILD_TOP/device/google/cuttlefish_vmm/qemu/scripts/rebuild_in_container.sh 20``` 21 22This will create a clean source checkout of QEMU and all relevant 23dependencies, and starts a build isolated in a podman container. 24 25If you don't have an AOSP checkout, run: 26 27```sh 28mkdir cuttlefish_vmm 29cd cuttlefish_vmm 30repo init --manifest-url https://android.googlesource.com/device/google/cuttlefish_vmm \ 31 --manifest-name=qemu/manifest.xml 32repo sync -j 12 33qemu/scripts/rebuild_in_container.sh --from_existing_sources 34``` 35 36`--from_existing_sources` also makes possible to reuse an existing QEMU source checkout 37to iterate faster. 38 39The result is a portable QEMU archive that can be 40found in `/tmp/qemu-build-output/qemu-portable.tar.gz` 41 42## Development process 43 44QEMU assembles many source trees that use git submodules. Hence it is more convenient 45to iterate on a checkout based on `git submodules` for development, and to capture the 46state in a `repo` manifest before submitting the changes to AOSP. 47 48 49```sh 50git clone sso://experimental-qemu-build-internal.googlesource.com/qemu-build qemu 51cd qemu 52git submodule update --init --depth 1 --recursive --jobs 4 53``` 54 55You can build without isolation with: 56 57```sh 58qemu/scripts/rebuild.sh --build-dir ~/qemu-build.out 59``` 60 61You can also build in a container with: 62 63```sh 64qemu/scripts/rebuild_in_container.sh --from_existing_sources 65``` 66 67After sucessfull build the ASOP binaries can be updated with: 68 69```sh 70tar -xvf /tmp/qemu-build-output/qemu-portable.tar.gz \ 71 -C $ANDROID_BUILD_TOP/device/google/cuttlefish_vmm/qemu/x86_64-linux-gnu 72``` 73 74This makes possible to upvert a dependency such as `qemu` and 75regenerate the repo manifest from the submodule tree. 76 77```sh 78python3 qemu/scripts/genrepo.py . --repo_manifest qemu/manifest.xml 79``` 80 81## Check your code before submit 82 83The following script run pytype and pyformat. 84 85```sh 86scripts/check.sh 87``` 88 89## Regenerate Cargo crates list 90 91Cargo crates are checked-in as part of the source tree and enumerated by 92`qemu/third_party/.cargo/config.toml`. This file hase be regenerated when 93`qemu/third_party/rust/crate` changes with the following command line: 94 95```sh 96ls qemu/third_party/rust/crates | awk ' 97 BEGIN {print "[patch.crates-io]"} 98 {print $1 " = { path = \"rust/crates/" $1 "\" }"}' > qemu/third_party/.cargo/config.toml 99```