aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Labatut <plabatut@google.com>2023-11-17 16:18:50 +0100
committerPierre Labatut <plabatut@google.com>2023-11-17 16:26:06 +0100
commit72c254699fb46efa2a14d249a67a654d23245c30 (patch)
tree4d3a1fb79fbe9680b2509d62e56ea720570b2962
parent32e6044366ccc4e564f1c94d4a1e218e09d99e73 (diff)
downloadcuttlefish_vmm-72c254699fb46efa2a14d249a67a654d23245c30.tar.gz
Add virglrenderer to QEMU.
This enables to use launch_cvd --gpu_mode=drm_virgl. libgbm.so is used from the system as it is made available by mesa which is a large project that would be difficult to add to AOSP. Bug: b/309616187 Change-Id: I6126b041dbf9bff9dfbd3c5a179f144a6babb54d
-rw-r--r--qemu/README.md15
-rw-r--r--qemu/manifest.xml5
-rw-r--r--qemu/scripts/genrepo.py6
-rwxr-xr-xqemu/scripts/rebuild.py115
4 files changed, 126 insertions, 15 deletions
diff --git a/qemu/README.md b/qemu/README.md
index 878bcd3..f03c984 100644
--- a/qemu/README.md
+++ b/qemu/README.md
@@ -46,13 +46,16 @@ The build has been tested with a small Debian10 image e.g.:
```sh
mkdir /tmp/qemu-build
-podman run --interactive --tty --name qemu-build \
- --volume .:/src:O \
- --volume /tmp/qemu-build:/out \
- docker.io/debian:10-slim
+podman run --replace --pids-limit=-1 \
+ --interactive --tty \
+ --name qemu-build \
+ --volume .:/src:O \
+ --volume /tmp/qemu-build:/out \
+ docker.io/debian:10-slim
apt-get update
-apt-get -qy install autoconf libtool texinfo
-/src/qemu/scripts/rebuild.sh --build-dir /out --run-tests
+apt-get -qy install autoconf libtool texinfo libgbm-dev
+
+/src/qemu/third_party/python/bin/python3 /src/qemu/scripts/rebuild.py --build-dir /out --run-tests
```
Note: `/src` is mounted with a file overlay so that cargo can write
diff --git a/qemu/manifest.xml b/qemu/manifest.xml
index 4d12bee..f7a6e94 100644
--- a/qemu/manifest.xml
+++ b/qemu/manifest.xml
@@ -16,8 +16,10 @@
<project path="qemu/third_party/flatbuffers" name="platform/external/flatbuffers" revision="baf9b3a15e291a0c76850a50f994c5947c3f5e5e" />
<project path="qemu/third_party/gfxstream" name="platform/hardware/google/gfxstream" revision="ea8f75f109f79a281627c3dd928df6a44600ab24" />
<project path="qemu/third_party/glib" name="platform/external/bluetooth/glib" revision="180713772f4e7bcdddf2c793f2f34a498184ed15" />
+ <project path="qemu/third_party/glib/subprojects/gvdb" name="platform/external/gvdb" revision="0854af0fdb6d527a8d1999835ac2c5059976c210" />
<project path="qemu/third_party/googletest" name="platform/external/googletest" revision="276e32ec333e05bff6dc7d20218a8d9152623222" />
<project path="qemu/third_party/libdrm" name="platform/external/libdrm" revision="ed0a0cde4ea44f6295786900a9f42afd78713677" />
+ <project path="qemu/third_party/libepoxy" name="platform/external/libepoxy" revision="2df68f811fc1a5f0a6d372ecdb887333ad3f540f" />
<project path="qemu/third_party/libffi" name="platform/external/libffi" revision="a8011b453bea48ac68b8c37545b4f04aaf6a9ffc" />
<project path="qemu/third_party/libpciaccess" name="platform/external/libpciaccess" revision="c716a921b7b970ff1fcd4ad34974877c29d103f0" />
<project path="qemu/third_party/libslirp" name="trusty/external/qemu-libslirp" revision="3ad1710a96678fe79066b1469cead4058713a1d9" />
@@ -50,5 +52,6 @@
<project path="qemu/third_party/rust/crates/unicode-ident" name="platform/external/rust/crates/unicode-ident" revision="2114a5cf0e82708cff6885a24be1995903c94738" />
<project path="qemu/third_party/rust/crates/zerocopy" name="platform/external/rust/crates/zerocopy" revision="738d78f6696da049502fc4436a70ca8799e1569e" />
<project path="qemu/third_party/rust/crates/zerocopy-derive" name="platform/external/rust/crates/zerocopy-derive" revision="e31ff4fde30f2bef09ae8f20b93d57b9040c7c1c" />
+ <project path="qemu/third_party/virglrenderer" name="platform/external/virglrenderer" revision="1b9067d7ba66296ce910441f66918edb50b00380" />
<project path="qemu/third_party/zlib" name="platform/external/zlib" revision="81774276a9cbf47177a1b7555bb6e3ec73bdcd25" />
-</manifest>
+</manifest> \ No newline at end of file
diff --git a/qemu/scripts/genrepo.py b/qemu/scripts/genrepo.py
index 099eeab..0884c0c 100644
--- a/qemu/scripts/genrepo.py
+++ b/qemu/scripts/genrepo.py
@@ -130,6 +130,12 @@ REPO_MAPPING = {
"https://gitlab.gnome.org/GNOME/gvdb.git": (
"https://android.googlesource.com/platform/external/gvdb"
),
+ "https://github.com/anholt/libepoxy.git": (
+ "https://android.googlesource.com/platform/external/libepoxy"
+ ),
+ "https://gitlab.freedesktop.org/virgl/virglrenderer.git": (
+ "https://android.googlesource.com/platform/external/virglrenderer"
+ ),
}
diff --git a/qemu/scripts/rebuild.py b/qemu/scripts/rebuild.py
index 229965b..0a4eede 100755
--- a/qemu/scripts/rebuild.py
+++ b/qemu/scripts/rebuild.py
@@ -54,9 +54,9 @@ def create_dev_environment(
"AR": f"{binprefix}llvm-ar",
"NM": f"{binprefix}llvm-nm",
"PKG_CONFIG_PATH": ":".join([
- f"{install_dir}/usr/local/lib/pkgconfig",
f"{install_dir}/usr/lib/x86_64-linux-gnu/pkgconfig",
f"{install_dir}/usr/lib/pkgconfig",
+ f"{sysroot}/usr/lib/pkgconfig",
]),
"PATH": f"{install_dir}/usr/bin:{path}",
"LD_LIBRARY_PATH": ":".join([
@@ -108,10 +108,10 @@ def generate_shell_command(
result = ""
result_wrap = False
if build_dir:
- result += f"cd {build_dir} && "
+ result += f"cd {build_dir} && \\\n"
result_wrap = True
if environ:
- result += " ".join(environ) + " "
+ result += " \\\n".join(environ) + " \\\n"
result += " ".join(shlex.quote(c) for c in cmd_args)
if result_wrap:
@@ -801,20 +801,29 @@ def build_task_for_libdrm(build: BuildConfig):
)
+@project.task([])
+def build_task_for_egl(build: BuildConfig):
+ build.copy_dir(
+ build.third_party_dir / "egl" / "api" / "KHR",
+ build.sysroot_dir / "usr" / "include" / "KHR",
+ )
+ build.copy_dir(
+ build.third_party_dir / "egl" / "api" / "EGL",
+ build.sysroot_dir / "usr" / "include" / "EGL",
+ )
+
+
@project.task([
build_task_for_meson,
build_task_for_aemu_base,
build_task_for_flatbuffers,
+ build_task_for_egl,
build_task_for_libdrm,
])
def build_task_for_gfxstream(build: BuildConfig):
dir_name = Path("gfxstream")
src_dir = build.third_party_dir / dir_name
build_dir = build.make_subdir(dir_name)
- build.copy_dir(
- build.third_party_dir / "egl" / "api" / "EGL",
- build.sysroot_dir / "usr" / "include" / "EGL",
- )
build.run(
[
"meson",
@@ -889,6 +898,93 @@ def build_task_for_rutabaga(build: BuildConfig):
)
+@project.task([])
+def build_task_for_libgbm(build: BuildConfig):
+ # gbm is part of mesa which is a large project.
+ # The dependency is taken fron the system.
+ build.copy_file(
+ "/usr/lib/x86_64-linux-gnu/libgbm.so.1",
+ build.install_dir / "usr/lib/libgbm.so.1",
+ )
+ build.copy_file(
+ "/usr/lib/x86_64-linux-gnu/libgbm.so",
+ build.install_dir / "usr/lib/libgbm.so",
+ )
+ build.copy_file(
+ "/usr/lib/x86_64-linux-gnu/libgbm.so.1.0.0",
+ build.install_dir / "usr/lib/libgbm.so.1.0.0",
+ )
+ build.copy_file(
+ "/usr/lib/x86_64-linux-gnu/pkgconfig/gbm.pc",
+ build.install_dir / "usr/lib/pkgconfig/gbm.pc",
+ )
+ build.copy_file("/usr/include/gbm.h", build.install_dir / "usr/include/gbm.h")
+
+
+@project.task([
+ build_task_for_egl,
+ build_task_for_libgbm,
+ build_task_for_meson,
+ build_task_for_ninja,
+])
+def build_task_for_libepoxy(build: BuildConfig):
+ src_dir = build.third_party_dir / "libepoxy"
+ build_dir = build.make_subdir(Path("libepoxy"))
+ build.run(
+ [
+ "meson",
+ "setup",
+ "--prefix=%s/usr" % build.install_dir,
+ "--libdir=%s/usr/lib" % build.install_dir,
+ "-Dtests=false",
+ build_dir,
+ src_dir,
+ ],
+ )
+
+ build.run(["ninja", "install"], build_dir)
+ # There is a bug in`qemu/third_party/libepoxy/src/meson.build`
+ # that result in a corrupted line `Requires.private: x11,` in `epoxy.pc`.
+ # This is not valid and causes the failure:
+ # `Empty package name in Requires or Conflicts in file '[...]epoxy.pc'`
+ # This is because 'x11' is found as an implicit dependency and the
+ # pkgconfig specification in the meson file adds an empty element.
+ # Until a better solution is found, remove the dependency.
+ build.run([
+ "sed",
+ "-i",
+ "s/Requires.private: x11, $//g",
+ build.install_dir / "usr/lib/pkgconfig/epoxy.pc",
+ ])
+
+
+@project.task([
+ build_task_for_egl,
+ build_task_for_libdrm,
+ build_task_for_libepoxy,
+ build_task_for_libgbm,
+ build_task_for_meson,
+ build_task_for_ninja,
+])
+def build_task_for_virglrenderer(build: BuildConfig):
+ src_dir = build.third_party_dir / "virglrenderer"
+ build_dir = build.make_subdir(Path("virglrenderer"))
+ build.run(
+ [
+ "meson",
+ "setup",
+ "--prefix=%s/usr" % build.install_dir,
+ "--libdir=%s/usr/lib" % build.install_dir,
+ "-Dplatforms=egl",
+ "-Dtests=false",
+ build_dir,
+ src_dir,
+ ],
+ )
+
+ build.run(["ninja", "install"], build_dir)
+
+
@project.task([
build_task_for_make,
build_task_for_libslirp,
@@ -898,6 +994,7 @@ def build_task_for_rutabaga(build: BuildConfig):
build_task_for_pkg_config,
build_task_for_rutabaga,
build_task_for_gfxstream,
+ build_task_for_virglrenderer,
])
def build_task_for_qemu(build: BuildConfig):
target_list = [
@@ -912,11 +1009,11 @@ def build_task_for_qemu(build: BuildConfig):
"--prefix=/usr",
"--target-list=%s" % ",".join(target_list),
"--disable-plugins",
+ "--enable-virglrenderer",
# Cuttlefish is packaged in host archives that are assembled in
# `$ANDROID_BUILD_TOP/out/host/linux-x86`.
# Binaries are in `./bin` and resources are in `./usr/share` which is
# different from QEMU default expectations. Details in b/296286524.
-
# Move the binary directory up by one. This path is relative to
# `--prefix` above.
"-Dbindir=../bin",
@@ -946,6 +1043,8 @@ def build_task_for_qemu_portable(build: BuildConfig):
bin_dir = package_dir / "bin"
files = [
"dest-install/usr/lib/libz.so.1",
+ "dest-install/usr/lib/libepoxy.so.0",
+ "dest-install/usr/lib/libvirglrenderer.so.1",
"dest-install/usr/lib/librutabaga_gfx_ffi.so.0",
"dest-install/usr/lib64/libc++.so.1",
]