From bb475b01d290dae4f844f632603f4b0fbe276643 Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Mon, 8 Feb 2021 13:20:57 -0800 Subject: [PATCH 1/3] qemu: do not force x86_64 cpu on darwin This change produces the following warning: ``` ... configure: line 619: sysctl: command not found ``` It's benign and sysctl is only useful on MacOS X Leopard: * https://github.com/qemu/qemu/blob/v5.2.0/configure#L615-L621 Leopard is 13 years old and is not supported by Nix. The sysctl check is removed in qemu master branch already. Plus aarch64-darwin is coming in #105026, so there's no reason to force x86_64. --- pkgs/applications/virtualization/qemu/default.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix index d83c6d350e2..933d6c293ad 100644 --- a/pkgs/applications/virtualization/qemu/default.nix +++ b/pkgs/applications/virtualization/qemu/default.nix @@ -118,8 +118,6 @@ stdenv.mkDerivation rec { "--enable-tools" "--enable-guest-agent" ] - # disable sysctl check on darwin. - ++ optional stdenv.isDarwin "--cpu=x86_64" ++ optional numaSupport "--enable-numa" ++ optional seccompSupport "--enable-seccomp" ++ optional smartcardSupport "--enable-smartcard" From d29e8f0e5970b22bdeffbf5ac0c14f893ba8b2a9 Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Mon, 8 Feb 2021 13:42:05 -0800 Subject: [PATCH 2/3] qemu: rename VERSION to QEMU_VERSION to avoid name clash In libc++ starting with LLVM8 there's `` include in `cstddef`: The following things also align: * QEMU has a file called `VERSION` in repo root * QEMU prepends repo root to include path in build * macOS has a case-insensetive filesystem All of this combined means that `VERSION` file is included as a header. Working around this be renaming `VERSION` -> `QEMU_VERSION` to resolve ambiguity. The problem really only appears on `aarch64-darwin`, since on `x86_64-darwin` there are no C++ files to compile. The workaround is harmless enough to apply. --- pkgs/applications/virtualization/qemu/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix index 933d6c293ad..1ceb238ddf9 100644 --- a/pkgs/applications/virtualization/qemu/default.nix +++ b/pkgs/applications/virtualization/qemu/default.nix @@ -108,6 +108,10 @@ stdenv.mkDerivation rec { # this script isn't marked as executable b/c it's indirectly used by meson. Needed to patch its shebang chmod +x ./scripts/shaderinclude.pl patchShebangs . + # avoid conflicts with libc++ include for + mv VERSION QEMU_VERSION + substituteInPlace meson.build \ + --replace "'VERSION'" "'QEMU_VERSION'" '' + optionalString stdenv.hostPlatform.isMusl '' NIX_CFLAGS_COMPILE+=" -D_LINUX_SYSINFO_H" ''; From 251add14cf97aa893e9934c225ee7412861bc655 Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Mon, 8 Feb 2021 13:42:49 -0800 Subject: [PATCH 3/3] qemu: only apply autoPatchelfHook on linux It fails on darwin due to missing `patchelf` and the missing ELFs: ``` /nix/store/...-auto-patchelf-hook/nix-support/setup-hook: line 220: -l: command not found ``` --- pkgs/applications/virtualization/qemu/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix index 1ceb238ddf9..92188c034d3 100644 --- a/pkgs/applications/virtualization/qemu/default.nix +++ b/pkgs/applications/virtualization/qemu/default.nix @@ -50,8 +50,9 @@ stdenv.mkDerivation rec { sha256 = "1g0pvx4qbirpcn9mni704y03n3lvkmw2c0rbcwvydyr8ns4xh66b"; }; - nativeBuildInputs = [ python python.pkgs.sphinx pkg-config flex bison meson ninja autoPatchelfHook ] - ++ optionals gtkSupport [ wrapGAppsHook ]; + nativeBuildInputs = [ python python.pkgs.sphinx pkg-config flex bison meson ninja ] + ++ optionals gtkSupport [ wrapGAppsHook ] + ++ optionals stdenv.isLinux [ autoPatchelfHook ]; buildInputs = [ zlib glib perl pixman vde2 texinfo makeWrapper lzo snappy