From e2f7c0c24b85da8e7aab10880ec2d20530464e04 Mon Sep 17 00:00:00 2001 From: Zihan Chen Date: Mon, 18 Jul 2022 18:07:53 -0700 Subject: [PATCH] crosvm: Fix cross-compile in dev container - Fix devcontainer.json to be used by vscode correctly - Fix wayland-protocols path finding - Add missing SYSROOT env for pkg_config - Add missing linker settings TEST=native/armv7/aarch64 targets compile in dev container Change-Id: Id6fc43b2fd63d09bc46169d996387d5417ada93e Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3766822 Commit-Queue: Dennis Kempin Tested-by: Dennis Kempin Auto-Submit: Zihan Chen Reviewed-by: Dennis Kempin --- .cargo/config.toml | 8 ++++++++ .devcontainer/devcontainer.json | 4 ++-- gpu_display/build.rs | 10 ++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 98133d579c..76bfdc0a4e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -43,5 +43,13 @@ rustflags = [ [target.armv7-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc" +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" + [target.x86_64-pc-windows-gnu] runner = "wine64" + +[env] +PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf = "/usr/arm-linux-gnueabihf" +PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-gnu = "/usr/aarch64_linux_gnu" +PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-gnu = "/usr/x86_64-w64-mingw32" \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 13b8382f69..641993ada1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { - "image": "gcr.io/crosvm-packages/crosvm_dev:latest", + "image": "gcr.io/crosvm-packages/crosvm_dev:r0012", "extensions": [ - "matklad.rust-analyzer", + "rust-lang.rust-analyzer", "bungcip.better-toml", "esbenp.prettier-vscode", "ms-python.vscode-pylance", diff --git a/gpu_display/build.rs b/gpu_display/build.rs index 3568d408b3..4455c21e1d 100644 --- a/gpu_display/build.rs +++ b/gpu_display/build.rs @@ -32,15 +32,17 @@ cfg_if::cfg_if! { // Searches for the given protocol in both the system wide and bundles protocols path. fn find_protocol(name: &str) -> PathBuf { - let protocols_path = pkg_config::get_variable("wayland-protocols", "pkgdatadir") - .unwrap_or_else(|_| "/usr/share/wayland-protocols".to_owned()); let protocol_file_name = PathBuf::from(format!("{}.xml", name)); - // Prioritize the systems wayland protocols before using the bundled ones. + if let Ok(protocols_path) = pkg_config::get_variable("wayland-protocols", "pkgdatadir") { + if let Some(found) = scan_path(protocols_path, &protocol_file_name) { + return found; + } + } + let protocols_path = format!("/usr/share/wayland-protocols/stable/{}", name); if let Some(found) = scan_path(protocols_path, &protocol_file_name) { return found; } - // Use bundled protocols as a fallback. let protocol_path = Path::new("protocol").join(protocol_file_name); assert!(