diff --git a/crates/red_knot_python_semantic/Cargo.toml b/crates/red_knot_python_semantic/Cargo.toml index 862f6f2689..4dbeee7bc3 100644 --- a/crates/red_knot_python_semantic/Cargo.toml +++ b/crates/red_knot_python_semantic/Cargo.toml @@ -38,7 +38,12 @@ test-case = { workspace = true } [build-dependencies] path-slash = { workspace = true } walkdir = { workspace = true } -zip = { workspace = true, features = ["zstd", "deflate"] } + +[target.'cfg(not(target_arch = "powerpc64"))'.build-dependencies] +zip = { workspace = true, features = ["deflate", "zstd"] } + +[target.'cfg(target_arch = "powerpc64")'.build-dependencies] +zip = { workspace = true, features = ["deflate"] } [dev-dependencies] ruff_db = { workspace = true, features = ["os", "testing"] } diff --git a/crates/red_knot_python_semantic/build.rs b/crates/red_knot_python_semantic/build.rs index 4b1785dc05..4165617dfe 100644 --- a/crates/red_knot_python_semantic/build.rs +++ b/crates/red_knot_python_semantic/build.rs @@ -30,11 +30,17 @@ fn zip_dir(directory_path: &str, writer: File) -> ZipResult { // We can't use `#[cfg(...)]` here because the target-arch in a build script is the // architecture of the system running the build script and not the architecture of the build-target. // That's why we use the `TARGET` environment variable here. - let target = std::env::var("TARGET").unwrap(); - let method = if target.contains("wasm32") || target.contains("powerpc64") { - CompressionMethod::Deflated - } else { - CompressionMethod::Zstd + #[cfg(target_arch = "powerpc64")] + let method = CompressionMethod::Deflated; + + #[cfg(not(target_arch = "powerpc64"))] + let method = { + let target = std::env::var("TARGET").unwrap(); + if target.contains("wasm32") || target.contains("powerpc64") { + CompressionMethod::Deflated + } else { + CompressionMethod::Zstd + } }; let options = FileOptions::default()