From 483bfdf2c6f4be2ab4540ce8379aba31d73dc476 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 5 Dec 2022 13:14:11 -0800 Subject: [PATCH] crosvm: warn that NIX_CFLAGS_COMPILE will break the build This was a bit of a headache to track down, so I'd like to add a `warnIf` to save others the hassle. If you put anything in `NIX_CFLAGS_COMPILE` (including ARM model-specific spectre mitigation flags), `build.rs` will produce an empty `constants.json`, which will then cause the `bpf` files to not be produced, which will result in errors like this at the very end of the build process: ``` error: couldn't read /build/crosvm-5a49a83/target/aarch64-unknown-linux-gnu/release/build/crosvm-44bfa298077e14a2/out/policy_output/9p_device.bpf: No su --> /build/crosvm-5a49a83/target/aarch64-unknown-linux-gnu/release/build/crosvm-44bfa298077e14a2/out/bpf_includes.in:2:15 | 2 | ...", include_bytes!("/build/crosvm-5a49a83/target/aarch64-unknown-linux-gnu/release/build/crosvm-44bfa298077e14a2/out/policy_output/9p_device.bpf") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info) ``` --- pkgs/applications/virtualization/crosvm/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/virtualization/crosvm/default.nix b/pkgs/applications/virtualization/crosvm/default.nix index 11d8f2223656f..b7e4a01e55b7f 100644 --- a/pkgs/applications/virtualization/crosvm/default.nix +++ b/pkgs/applications/virtualization/crosvm/default.nix @@ -3,7 +3,7 @@ , libcap, libdrm, libepoxy, minijail, virglrenderer, wayland, wayland-protocols }: -rustPlatform.buildRustPackage rec { +(rustPlatform.buildRustPackage rec { pname = "crosvm"; version = "107.1"; @@ -60,4 +60,9 @@ rustPlatform.buildRustPackage rec { license = licenses.bsd3; platforms = [ "aarch64-linux" "x86_64-linux" ]; }; -} +}) +.overrideAttrs (a: + lib.warnIf (a.NIX_CFLAGS_COMPILE or "" != "") + ''you have set `NIX_CFLAGS_COMPILE` to ${a.NIX_CFLAGS_COMPILE} + this may cause crosvm's build scripts to produce an empty + constants.json and then fail to complete the build'' {})