Skip to content

WIP: How to compile qemu-static-x86_64 #11

Open
@lars18th

Description

@lars18th

Hi,

I want to share here (only for reference, because this is not complete) how to extend this great project to compile not only qemu-* but qemu-system-x86_64 in a static version:

  • Dockerfile:
diff --git a/Dockerfile b/Dockerfile
index 830010c..3b0e51b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,3 +1,4 @@
+
 FROM alpine:3.20.3

 RUN apk update
@@ -18,6 +19,22 @@ RUN apk add\
  flex\
  bison

+# required to compile Slirp as static lib and qemu-system
+RUN apk add\
+ util-linux-static\
+ bzip2-static ncurses-static\
+ libxkbcommon-static libxkbcommon-dev\
+ libslirp-dev\
+ sdl2-dev\
+ libx11-static gtk+3.0-dev zstd-static\
+ git meson ninja-build
+
+RUN git clone https://gitlab.freedesktop.org/slirp/libslirp.git /tmp/libslirp && \
+    cd /tmp/libslirp && \
+    meson setup --default-library static build && \
+    ninja -C build install && \
+    rm -rf /tmp/libslirp
+
 # additional
 RUN apk add bash xz git patch
  • command/configure:
diff --git a/command/configure b/command/configure
index b2efbe5..cde6338 100755
--- a/command/configure
+++ b/command/configure
@@ -8,7 +8,12 @@ WORKDIR "/work/out/${QEMU_SRC_BASENAME}"
 RUN "/work/src/${QEMU_SRC_BASENAME}/configure" \
     --prefix="/work/dst/${QEMU_ARTIFACT_BASENAME}" \
     --disable-debug-info \
-    --disable-system \
+    --enable-system \
+    --target-list=x86_64-softmmu,x86_64-linux-user \
+    --enable-kvm \
+    --enable-slirp \
+    --enable-sdl \
     --disable-werror \
     --enable-linux-user \
+    --enable-strip \
     --static

This is not completed/finished because SDL is not working. It compiles, so you get a fully static version runnable, but only with ncurses interface or console. So no video (missing SDL, GTK+, VNC and SPICE).

I hope someone will continue working on it to complete the full compilation.
And perhaps the author/owner of this project will want to expand it to support the compilation of qemu-system-* binaries. Almost, you can add (with a comment) the required packages, and a secondary/alternative configure. Therefore other interested users can reuse it.

Regards.

Note: The problem, as you can imagine is the lack of static binaries of the required libraries. I suggest to request to the Alpine mantainers group to add them. For example: libslirp.a is missing, although you can compile it. But the same is not true for GTK+ dependencies or with libvncserver (required for VNC) or with spice. With them a lot of not easy to compile static libraries is the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions