diff options
author | Ahmad Sattar <thehabbos007@gmail.com> | 2024-06-06 15:30:55 +0200 |
---|---|---|
committer | Ilan Joselevich <personal@ilanjoselevich.com> | 2024-06-20 14:35:49 +0300 |
commit | fb927d5019d1c5111efcad5008ba10f53481f1d5 (patch) | |
tree | f4960d6654b5ee71f451b63bd05d14a535edf58c | |
parent | 41dcd09eb0db1c1b158bb780d5c4a4d61d5247ee (diff) |
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.
-rw-r--r-- | pkgs/build-support/rust/build-rust-crate/default.nix | 2 |
1 files changed, 2 insertions, 0 deletions
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}" |