Commit Graph

128 Commits

Author SHA1 Message Date
Florian Klink
cbe5cf5d81 buildRustCrate: don't swallow build.rs output
This is executed curing the build, and usually quite helpful in telling
you how the build failed, if it failed.

For example, when linking against system libraries, it shows which
system lib could not be discovered, the pkg-config path used etc.

Not showing it simply removes all this, and trying to parse out the
"important" bits and only show these is probably also brittle.

The output generally isn't that spammy normally, so let's just `tee` it.
2024-07-05 21:39:08 +03:00
Ilan Joselevich
b870209e42
Merge pull request #323110 from thehabbos007/cargo-cdylib
buildRustCrate: add support for `cargo::rustc-cdylib-link-arg`
2024-07-01 21:09:25 +03:00
Ahmad Sattar
1cf6e5eaa1 buildRustCrate: add support for cargo::rustc-cdylib-link-arg 2024-07-01 09:29:46 +02:00
Florian Klink
641b2f29b6
Merge pull request #319153 from Kranzes/buildRustCrate-wasm
buildRustCrate: add support for compiling to wasm32-unknown-unknown
2024-06-30 14:05:33 +03:00
Ilan Joselevich
cc379b60f0
tests.buildRustCrate: add crateLibOutputsWasm32
Added a cross compilation test for wasm32-unknown-unknown. This also
required using crate.metadata instead of using the regex to get rid of
the hash in the library filename. It also required adding a mkCrate
argument to assertOutputs so we can override the buildRustCrate used.
2024-06-24 21:13:50 +03:00
Ilan Joselevich
cf5e2c2c9a
buildRustCrate: support cross compiling to wasm32-unknown-unknown
With this change you will finally be able to use
buildRustCrate/crate2nix to build your wasm32-unknown-unknown
rust projects.

Simply import nixpkgs like so:
```
lib = <nixpkgs/lib>;
pkgsForWasm32 = import <nixpkgs> {
  crossSystem = lib.examples.wasm32-unknown-none;
}
```
or use pkgsCross directly with
```
pkgsCross.wasm32-unknown-none.callPackage ./. { };
```
2024-06-24 19:28:33 +03:00
Ilan Joselevich
d9e5089751
Merge pull request #321220 from thehabbos007/cargo-colon
buildRustCrate: support new cargo invocation syntax for build script outputs
2024-06-21 14:21:47 +03:00
Ahmad Sattar
95bb410817 buildRustCrate: support cargo:: invocation syntax for build script outputs
In order to allow for the new `cargo::` prefix for build script outputs
we have to adjust the configure-crate bash scripts in buildRustCrate to
properly parse the new additional syntax.

These changes don't affect existing build scripts configured with the
old `cargo:` prefix.

For more information, see https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script
2024-06-21 08:29:24 +02:00
Ahmad Sattar
fb927d5019
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.
2024-06-20 14:35:49 +03:00
Ahmad Sattar
c730e033ca build-rust-crate: quote build script output env var 2024-06-14 10:23:28 +02:00
Ilan Joselevich
de9a49c390 buildRustCrate: extensions.sharedLibrary -> extensions.library
Switched to a common attribute for library file extensions:
de70971c90

This makes buildRustCrate evaluate successfully when using
pkgsCross/pkgsStatic.
2024-06-11 11:27:17 +01:00
Ryan Lahfa
ec84d47ff6
Merge pull request #274440 from bouk/missing-build-rust-env
build-rust-crate: add missing CARGO_PKG env variables
2024-01-29 17:31:54 +01:00
Bouke van der Bijl
34ad6be1cd build-rust-crate: add missing CARGO_PKG env variables
See https://doc.rust-lang.org/cargo/reference/environment-variables.html
for supported variables
2024-01-28 18:59:53 +01:00
Peter Kolloch
597f3d31d8 build-rust-crate: Allow missing hostPlatform.extensions.sharedLibrary
If you cross-build, sharedLibrary might not be set. E.g. for this
nixpkgs instance:

```nix
pkgs = import <nixpkgs> {
    config = { };
    crossSystem = {
        config = "riscv32-unknown-none-elf";
        rustc = {
            config = "riscv32i-unknown-none-elf";
        };
    };
}
```
2024-01-04 12:15:32 +01:00
Ryan Lahfa
7e869d89ee
Merge pull request #266787 from tvbeat/cargo-manifest-links 2023-11-19 16:14:58 +01:00
Luka Blaskovic
8ffe19c099 build-rust-crate: set CARGO_MANIFEST_LINKS if links is set 2023-11-11 06:29:50 +00:00
Alyssa Ross
e3e57b8f18 lib.systems: elaborate Rust metadata
We need this stuff to be available in lib so make-derivation.nix can
access it to construct the Meson cross file.

This has a couple of other advantages:

 - It makes Rust less special.  Now figuring out what Rust calls a
   platform is the same as figuring out what Linux or QEMU call it.

 - We can unify the schema used to define Rust targets, and the schema
   used to access those values later.  Just like you can set "config"
   or "system" in a platform definition, and then access those same
   keys on the elaborated platform, you can now set "rustcTarget" in
   your crossSystem, and then access "stdenv.hostPlatform.rustcTarget"
   in your code.

"rustcTarget", "rustcTargetSpec", "cargoShortTarget", and
"cargoEnvVarTarget" have the "rustc" and "cargo" prefixes because
these are not exposed to code by the compiler, and are not
standardized.  The arch/os/etc. variables are all named to match the
forms in the Rust target spec JSON.

The new rust.target-family only takes a list, since we don't need to
worry about backwards compatibility when that name is used.

The old APIs are all still functional with no warning for now, so that
it's possible for external code to use a single API on both 23.05 and
23.11.  We can introduce the warnings once 23.05 is EOL, and make them
hard errors when 23.11 is EOL.
2023-11-09 10:02:24 +01:00
Ryan Lahfa
b10994c38c
Merge pull request #220429 from amjoseph-nixpkgs/pr/build-rust-crate/cross/linker 2023-10-31 12:12:17 +01:00
Adam Joseph
3bd3809d0e buildRustCrate: add isMips64n32 to badPlatforms
Rust is not yet able to target the n32 ABI on mips64.

Let's add `isMips64n32` to the `meta.badPlatforms` of all
derivations created by buildRustCrate.

I use this to automatically detect which packages on my system can
be built for n32 (almost all of them) and build those using n32, and
the few packages (mainly those that depend on boost or rust) that
can't for n64.
2023-10-23 08:38:25 +00:00
Bouke van der Bijl
352ff3f226
Update pkgs/build-support/rust/build-rust-crate/default.nix
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2023-09-23 10:19:03 +02:00
Bouke van der Bijl
4270524d3f build-rust-crate: add stripExclude for .rlib 2023-09-18 16:03:04 +02:00
Felix Bühler
0a2745684e
Merge pull request #239624 from Stunkymonkey/use-optionalString-then
treewide: use optionalString instead of 'then ""'
2023-07-22 13:02:47 +02:00
Felix Buehler
6672dde558 treewide: use optionalAttrs instead of 'else {}' 2023-06-25 11:01:34 -03:00
Felix Buehler
f3719756b5 treewide: use optionalString instead of 'then ""' 2023-06-24 20:19:19 +02:00
Guillaume Girol
f8602fa508
Revert "build-rust-{crate,package}: cleanups" 2023-06-18 09:27:44 +00:00
Sandro Jäckel
ddad581c0d
build-rust-crate: cleanup with statix 2023-06-15 23:55:35 +02:00
Daniel Nagy
ca2cb9f644 treewide: "libary" -> "library" 2023-06-10 14:54:08 +01:00
Adam Joseph
42c8e4dd18 build-rust-crate: dontStrip=!release
Without this PR, unlike `RUST_LIB_BACKTRACE=1 cargo run` you won't
get line numbers in backtraces from binaries built with:

```
nix build -f Cargo.nix --arg release false
```

This PR fixes that.
2023-04-12 15:24:50 -04:00
Adam Joseph
6406751e1c build-rust-crate: point rustc to the correct linker
I've been having problems with cross-compiled builds of crate2nix'ed
crates failing at the final link step because rustc defaults to `cc`
(from $PATH) as the linker.  This is, of course, the buildPlatform's
linker.  See example below.

Let's tell rustc unambiguously to use the target platform linker.

I've added the flag *before* `baseRustcOpts` because that includes
`extraRustcOpts`.  This ensures that users of the package can
override this with their own `-C linker` choice.

Unfortunately because build-rust-crate (currently) sets
binary-crate-specific flags when building library crates, this
causes a global rebuild of everything that uses buildRustCrate.

```
rust_html2text> Building html2text (src/main.rs)
rust_html2text> Running rustc --crate-name html2text src/main.rs --crate-type bin -C opt-level=3 -C codegen-units=1 --remap-path-prefix=/build=/ --extern argparse=/nix/store/y4m00swv4aka73vfl9rbb2abq7y1vmg6-rust_argparse-0.2.2-aarch64-unknown-linux-gnu-lib/lib/libargparse-5dc9592bf7.rlib --extern html2text=/nix/store/j3p1pgh3iyjdhp8681zab7yjwpzs4kg2-rust_html2text-0.4.4-aarch64-unknown-linux-gnu-lib/lib/libhtml2text-d6e376dd78.rlib --cfg feature="default" --target aarch64-unknown-linux-gnu --edition 2021 --out-dir target/bin -L dependency=target/deps --cap-lints allow --color always
rust_html2text> error: linking with `cc` failed: exit status: 1
rust_html2text>   |
rust_html2text>   = note: "cc" "/build/rustcgg6BNC/symbols.o" "target/bin/html2text.html2text.a6551786-cgu.0.rcgu.o" "target/bin/html2text.82b4749yb02lf9k.rcgu.o" "-Wl,--as-needed" "-L" "target/deps" "-L" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/nix/store/j3p1pgh3iyjdhp8681zab7yjwpzs4kg2-rust_html2text-0.4.4-aarch64-unknown-linux-gnu-lib/lib/libhtml2text-d6e376dd78.rlib" "/nix/store/rbal9imr15fb674mwjjhd75p45ajql25-rust_unicode-width-0.1.10-aarch64-unknown-linux-gnu-lib/lib/libunicode_width-a3b8f6ce6d.rlib" "/nix/store/5j6pf8bbk3920klpn2zlv4q6d0bbjk26-rust_html5ever-0.26.0-aarch64-unknown-linux-gnu-lib/lib/libhtml5ever-7c514c0d78.rlib" "/nix/store/2k5ncqkn1ngq1q7mjccsh3di2r9x7b3m-rust_log-0.4.17-aarch64-unknown-linux-gnu-lib/lib/liblog-bbb1d2abad.rlib" "/nix/store/yklfi1k7iaw4khbay1avvgmrrnb3sw8f-rust_markup5ever-0.11.0-aarch64-unknown-linux-gnu-lib/lib/libmarkup5ever-fa92c5d6d6.rlib" "/nix/store/cp0raar4bvl551n7521rrvk8cka9dkcv-rust_string_cache-0.8.4-aarch64-unknown-linux-gnu-lib/lib/libstring_cache-3ae24c7e2e.rlib" "/nix/store/w45v78l58wcpnwrhf83ysix1nb3177d3-rust_precomputed-hash-0.1.1-aarch64-unknown-linux-gnu-lib/lib/libprecomputed_hash-dc2ae88c2c.rlib" "/nix/store/d5gv2frk6aav6y9hwv0w6a8fw3wd2sh3-rust_serde-1.0.152-aarch64-unknown-linux-gnu-lib/lib/libserde-881972cdc0.rlib" "/nix/store/zapn48k4pfma65s304xfpqakprl0lz0n-rust_parking_lot-0.12.1-aarch64-unknown-linux-gnu-lib/lib/libparking_lot-a8eeb0af3b.rlib" "/nix/store/5jjayhj13mcy52ybdagvmdqvp2i2kfc6-rust_parking_lot_core-0.9.5-aarch64-unknown-linux-gnu-lib/lib/libparking_lot_core-7b731df3c6.rlib" "/nix/store/nka1dv01my0ivfpv14jc3969lala9yj0-rust_libc-0.2.139-aarch64-unknown-linux-gnu-lib/lib/liblibc-7a4e291ec8.rlib" "/nix/store/40i3315py200bzjd9nzds6l73drfs5rq-rust_cfg-if-1.0.0-aarch64-unknown-linux-gnu-lib/lib/libcfg_if-36a232ac81.rlib" "/nix/store/mj38xbiskkz39gdwm6sg4xr73k3wiixh-rust_smallvec-1.10.0-aarch64-unknown-linux-gnu-lib/lib/libsmallvec-e668ae4802.rlib" "/nix/store/j15ldgxp88dz06cgfl6ksvbnhk5kg1l7-rust_lock_api-0.4.9-aarch64-unknown-linux-gnu-lib/lib/liblock_api-bd3f4cafbe.rlib" "/nix/store/w7f8q6idl5pl7hssfq0gn2h7nr33556g-rust_scopeguard-1.1.0-aarch64-unknown-linux-gnu-lib/lib/libscopeguard-2ef121592d.rlib" "/nix/store/4vsr3kifpdb1dkac5j2l9rafjsypcdj6-rust_once_cell-1.17.0-aarch64-unknown-linux-gnu-lib/lib/libonce_cell-8a9caa1812.rlib" "/nix/store/sivn38f9bffq7pwiwhrisbpk16slci51-rust_phf-0.10.1-aarch64-unknown-linux-gnu-lib/lib/libphf-c5c68bbc03.rlib" "/nix/store/dfl1c90pddaf9kqpdpmy546s21vmgy90-rust_phf_shared-0.10.0-aarch64-unknown-linux-gnu-lib/lib/libphf_shared-0da64f265f.rlib" "/nix/store/vcq3zp2l7bjldknvg3894nvmafndl4p3-rust_siphasher-0.3.10-aarch64-unknown-linux-gnu-lib/lib/libsiphasher-57560c9ade.rlib" "/nix/store/ysycp6rj77l0ymdrvcndpdykidyhjapd-rust_tendril-0.4.3-aarch64-unknown-linux-gnu-lib/lib/libtendril-c7a013fefe.rlib" "/nix/store/fgc3j0s0rlpmgi4avy0gvkcwx813v74v-rust_utf-8-0.7.6-aarch64-unknown-linux-gnu-lib/lib/libutf8-a31a1dfa96.rlib" "/nix/store/vkqy90dmg0h4qkmcfr8nfa8l8nv3b0wa-rust_futf-0.1.5-aarch64-unknown-linux-gnu-lib/lib/libfutf-74eb51f206.rlib" "/nix/store/lpy11ncw9hjp8514y6qh5dalz73cammg-rust_new_debug_unreachable-1.0.4-aarch64-unknown-linux-gnu-lib/lib/libdebug_unreachable-798bc09edd.rlib" "/nix/store/972pbraa9nx2w2r9rgw9ihxcnnyjj7pq-rust_mac-0.1.1-aarch64-unknown-linux-gnu-lib/lib/libmac-5f22857ac1.rlib" "/nix/store/y4m00swv4aka73vfl9rbb2abq7y1vmg6-rust_argparse-0.2.2-aarch64-unknown-linux-gnu-lib/lib/libargparse-5dc9592bf7.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd-6dfb26da5641245c.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libpanic_unwind-17fe203b55bc0ad4.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libobject-fcd32571c597d1d2.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libmemchr-9bea2c040bb6c3bb.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libaddr2line-50f1168d6595a5a4.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libgimli-ab3cce9cf22eb54e.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_demangle-195cb4e110dfcf64.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd_detect-6e60da103a3086ca.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libhashbrown-1967902c6f47ed4d.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libminiz_oxide-e67a9163a25e7f3e.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libadler-3815f9058309549d.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-761ef9e339906fe9.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libunwind-8882f6e2dc28b312.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcfg_if-50cea0e51cd18705.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/liblibc-da1cdc1aff291994.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/liballoc-7019f3ab0cdf1cfd.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_std_workspace_core-1944b99f47799b69.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcore-06b1d7727c68137a.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcompiler_builtins-bc101476bec73dcf.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-o" "target/bin/html2text" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs"
rust_html2text>   = note: /nix/store/2arn2lz66q49qhiyldkahiphfmzlixdf-binutils-2.40/bin/ld: target/bin/html2text.html2text.a6551786-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
rust_html2text>           /nix/store/2arn2lz66q49qhiyldkahiphfmzlixdf-binutils-2.40/bin/ld: target/bin/html2text.html2text.a6551786-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
rust_html2text>           /nix/store/2arn2lz66q49qhiyldkahiphfmzlixdf-binutils-2.40/bin/ld: target/bin/html2text.html2text.a6551786-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
rust_html2text>           /nix/store/2arn2lz66q49qhiyldkahiphfmzlixdf-binutils-2.40/bin/ld: target/bin/html2text.html2text.a6551786-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
```
2023-03-09 19:45:33 -08:00
cidkidnix
856936abc8 buildRustCrate: add libiconv to nativeBuildInputs on darwin
Fixes linker errors while building build.rs where it tries to link libiconv but cannot find it.

Rust executable build for Darwin need libiconv, and indeed buildInputs already has this case handled.
So why is another change needed? Suppose we are cross compiling from Darwin (the build platform) to something else, and the package has a build.rs build script.
The build script is built for the build platform (Darwin) and is also a regular Rust executable, needing libiconv, but due to cross compilation (and strict deps) we need an extra nativeBuildInput.
2023-03-08 14:39:25 -06:00
Felix Buehler
cdb39a86e0 treewide: use optionalString 2023-02-13 21:52:34 +01:00
Adam Joseph
eb98fefe24 build-rust-crate: handle ILP32 platforms correctly
This commit corrects the value of `CARGO_CFG_TARGET_POINTER_WIDTH`
for ILP32 machines like the Apple Watch and mips64n32.
2023-01-23 12:10:58 -08:00
Mateusz Kowalczyk
22770e2381 buildRustCrate: fixup integration test mod name
Fixes #204051. I have tried this on the reproducer stated in the ticket.

```
[nix-develop]$ $(nix-build  -I nixpkgs=/home/shana/programming/nixpkgs --no-out-link)/tests/foo

running 1 test
test check_module_name ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
```
2023-01-14 14:18:09 -05:00
Artturin
2eeb34c273 treewide: {build,host,target}Platform -> stdenv.{build,host,target}Platform 2023-01-09 21:13:22 +02:00
figsoda
ec8cb34358 treewide: fix typos 2022-12-17 19:39:44 -05:00
Artturin
05a2dfd674 lib.replaceChars: warn about being a deprecated alias
replaceStrings has been in nix since 2015(nix 1.10)

so it is safe to remove the fallback

d6d5885c15
2022-12-15 22:25:51 +02:00
John Ericson
fde3b57055 buildRustCrate: Support cargo:rustc-link-arg and some friends from build.rs
See https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-link-argfor details. We are supporting:

 - `cargo:rustc-link-arg`
 - `cargo:rustc-link-arg-bins`
 - `cargo:rustc-link-arg-lib`

at this time.

`cargo:rustc-link-arg-bin` is left as future work because the per-binary
flag keeping is more difficult.
2022-11-30 11:40:50 -05:00
Mateusz Kowalczyk
233205c464
rustBuildCrate: properly handle cargo env pragmas with spaces
There are two problems: first that we end up splitting on spaces in the
loop. Even when that is fixed, we still would split on spaces in the
`export` inside the loop. We need to guard against both.

Fixes #199298

Confirmed that it fixes the case mentioned in the ticket:

```console
[nix-develop]$ $(nix-build -I nixpkgs=/home/shana/programming/nixpkgs Cargo.nix -A rootCrate.build  --no-out-link)/bin/nix-rustc-env-escape-repro
Expecting three words, got: first second third
```

I think this is going to cause a rebuild of every Rust package even if
they were unaffected, not much we can do here.
2022-11-03 14:49:24 +09:00
marius david
3291bda7b6 buildRustCrate: Do not compile binaries if all the requiredFeatures aren't enabled. 2022-08-23 13:09:33 +02:00
John Ericson
cc29693a09 buildRustCrate: Add support for standard library deps
We are replicating one mechanism behind `-Z build-std`.

There isn't yet crate2nix support for this, but one can (and I do) add
the missing stdlib deps (for this feature to pick up) with overrides.
2022-08-01 15:34:49 -04:00
Ben Wolsieffer
882741f632 tests.buildRustCrate: add rcgen test
rcgen depends on ring, and therefore exercises support for static libraries
2022-06-14 20:09:33 -04:00
Ben Wolsieffer
a6bbe3f794 buildRustCrate: pass link flags when building libraries
With Rust 1.61, it is necessary to link to external static/dynamic libaries
when building the rlib that uses them, rather than when linking the final
binary. In fact, it is no longer necessary to specify the libraries to link
when building the final binary, but the library search path flags must still
be included.
2022-06-14 20:09:33 -04:00
ilkecan
d6bd313f07 buildRustCrate: set meta.mainProgram to crateName 2022-05-05 14:25:27 +00:00
David Scherer
13a9006ec3 Fix determinism by defaulting codegenUnits to 1, not NIX_BUILD_CORES 2022-05-01 11:48:32 -04:00
Mateusz Kowalczyk
f6897d23f4 buildRustCrate: make codegen-units configurable
This parameter is being set to `$NIX_BUILD_CORES` by default. This is a
standard practice but there's a suspicion that this can produce broken
builds. For some details see
https://github.com/cargo2nix/cargo2nix/issues/184 . As a
work-around/test, it'd be good if codegen-units can be set to something
constant, such as `1`. This PR allows it.

Note that the default of `$NIX_BUILD_CORES` is preserved so this MR
causes no change in default behaviour and no rebuilds.
2022-05-01 11:48:32 -04:00
Faye Duxovni
bc5e8ae506 buildRustCrate: don't try to set CARGO_FEATURE_ variables for dep: features
These features are internal-only, have special characters that bash
doesn't support in variable names, and aren't normally given
environment variables by cargo as far as I can tell.
2022-04-16 06:53:45 -04:00
Andreas Rammhold
31e5b8dc21
Remove myself from maintainers
I don't have time and energy to deal with all of this anymore.
2022-01-20 00:24:52 +01:00
John Ericson
811f849961 buildRustCrate: Don't override the linker during cross
lld is sometimes need. The caller can do that instead.
2021-10-06 16:59:53 -04:00
John Ericson
4430761186 buildRustCrate: Add extraRustcOptsForBuild
`extraRustcOpts` should not be used for build.rs, lest it contain
host-platform-specific options during cross builds.
2021-10-06 16:59:52 -04:00
John Ericson
0ee5640d78 buildRustCrate: Fix extra cross args
Do proper list separation, use ld not cc because rustc doesn't `-Wl,`.
2021-10-06 16:59:19 -04:00