From fb927d5019d1c5111efcad5008ba10f53481f1d5 Mon Sep 17 00:00:00 2001 From: Ahmad Sattar Date: Thu, 6 Jun 2024 15:30:55 +0200 Subject: BuildRustCrate: proc macros must be built for build's platform When cross compiling proc macros, the proc macro needs to be built for the build platform's architecture. Without this change cross compiling from Darwin to Linux would simply fail because it tries to link to a library with a file extension that doesn't exist on the builder's platform. --- pkgs/build-support/rust/build-rust-crate/default.nix | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/rust/build-rust-crate/default.nix b/pkgs/build-support/rust/build-rust-crate/default.nix index 9ceda041b6653..dfe28cc334b5e 100644 --- a/pkgs/build-support/rust/build-rust-crate/default.nix +++ b/pkgs/build-support/rust/build-rust-crate/default.nix @@ -49,6 +49,8 @@ let filename = if lib.any (x: x == "lib" || x == "rlib") dep.crateType then "${dep.metadata}.rlib" + # Adjust lib filename for crates of type proc-macro. Proc macros are compiled/run on the build platform architecture. + else if (lib.attrByPath [ "procMacro" ] false dep) then "${dep.metadata}${stdenv.buildPlatform.extensions.library}" else "${dep.metadata}${stdenv.hostPlatform.extensions.library}"; in " --extern ${opts}${name}=${dep.lib}/lib/lib${extern}-${filename}" -- cgit 1.4.1