3
0
Fork 0
forked from mirrors/nixpkgs
Commit graph

433 commits

Author SHA1 Message Date
Alex Martens bac7ee3208 rustc: fix build for no_std targets 2022-10-07 07:35:29 -07:00
github-actions[bot] e879e7d54e
Merge master into staging-next 2022-10-02 00:04:43 +00:00
Vladimír Čunát 292756e9ff
Merge #190093: rustc: propagate libiconv on darwin
...into staging
2022-09-28 09:45:11 +02:00
figsoda dc19b95eff rustPlatform.buildRustPackage: remove unused function 2022-09-26 21:53:37 -04:00
Ivar Scholten 987d32bbac buildRustPackage: dont rely on NIX_BUILD_TOP in cargoSetupPostPatchHook
This breaks the builder when a nix-shell or keepBuildTree is used. The
issue occurs because paths to cargo lockfiles are read with NIX_BUILD_TOP,
which is not reliable.

This breaks a nix-shell because NIX_BUILD_TOP simply is not set, causing
an invalid path to be used. This can be worked around using
NIX_BUILD_TOP=$PWD, but that obviously is not great.

This breaks keepBuildTree because it changes the working directory to a
different path than NIX_BUILD_TOP. Since the lockfiles are copied based
on the working directory, but read based on NIX_BUILD_TOP, this causes
the hook to not be able to find them.

This was solved by both reading these files based on the working directory,
using absolute paths to avoid having to traverse back in the directory tree.

Fixes: #138554
2022-09-25 16:17:36 +02:00
Benjamin Hipple 1066f0ef92
Merge pull request #178964 from linsui/cargo
fetch-cargo-tarball: allow use index mirror
2022-09-17 12:04:27 -04:00
Adam Joseph 31e5930b57 default-crate-overrides.nix: add pangocairo-sys 2022-09-10 02:06:30 -07:00
Adam Joseph 2ab5cfe7ce default-crate-overrides.nix: import pango 2022-09-10 02:06:29 -07:00
Adam Joseph 02de33cacd default-crate-overrides.nix: add atk-sys 2022-09-09 19:51:43 -07:00
Adam Joseph c804cea71d default-crate-overrides.nix: add {gtk4,gdk4,gsk4}-sys 2022-09-09 18:58:59 -07:00
Adam Joseph 4ceec72751 default-crate-overrides.nix: add cairo-sys-rs 2022-09-09 18:58:21 -07:00
Winter b6fc00b8f4 rustc: propagate libiconv on darwin
Rust binaries are unconditionally linked to libiconv on Darwin (see https://github.com/rust-lang/libc/issues/2870). We already add it as a dependency in `buildRustPackage`, so let's go a step further and propagate it.
2022-09-06 23:17:56 -04:00
John Ericson 6a0d3815a3
Merge pull request #187975 from marius851000/rustRequiredFeatures
buildRustCrate: Do not compile binaries if all the requiredFeatures aren't enabled.
2022-08-25 17:45:52 -04:00
Bernardo Meurer fbd067fef0
Merge pull request #187841 from amjoseph-nixpkgs/pr/rust/toTargetArch
build-support/rust: toTargetArch: strip off endianness
2022-08-25 10:22:34 -03:00
marius david 3291bda7b6 buildRustCrate: Do not compile binaries if all the requiredFeatures aren't enabled. 2022-08-23 13:09:33 +02:00
Adam Joseph 8682bd0a81 build-support/rust: toTargetArch: strip off endianness
`toTargetArch` in `pkgs/build-support/rust/lib/default.nix` is used to
set `CARGO_CFG_TARGET_ARCH`.  This environment variable is supposed to
be the `<arch>` portion of an LLVM-style platform name:

```
<arch><sub>-<kernel>-<libc><abi>
```

Note that the pointer-width (the "64" in "x86_64" and "mips64") is
part of `<arch>`, but the endianness (the `_be` in `aarch64_be`) is
*not*.

Unfortunately at the moment nixpkgs' parsed `cpuType` has no way to
query for the three subparts (name, pointer-width, and
subarch/endianness), nor any way to ask for just the first two parts.

For now, this commit simply fixes the problem in the two cases that
matter: `mips64el` and `powerpc64le`, which I believe are the only two
platforms supported by both rust and nixpkgs which have a
"subarchitecture".
2022-08-22 02:27:06 -07:00
linsui 7d8f9ee62e build-rust-package: cargoSha256 and cargoHash must not be null 2022-08-21 17:09:09 +08:00
linsui 51a6ac79d2 fetch-cargo-tarball: fix for packages without dep 2022-08-21 16:28:28 +08:00
linsui 656e3022f4 fetch-cargo-tarball: allow use index mirror 2022-08-21 16:28:28 +08:00
Adam Joseph 6d9a490980 default-crate-overrides.nix: remove unnecessary attrs from previous commit
Sorry, I should have removed these before submitting https://github.com/NixOS/nixpkgs/pull/186748
2022-08-15 01:08:13 -07:00
github-actions[bot] 4e717ab958
Merge staging-next into staging 2022-08-15 06:01:47 +00:00
Adam Joseph 58e5bd56d6 default-crate-overrides.nix: add libevdev for evdev-rs 2022-08-14 21:20:55 -07:00
Yureka 51c62063e3 cargoSetupHook: set crt-static
Tell rust if we want our binaries linked statically or dynamically.
Otherwise the compiler will always produce statically linked binaries for musl
targets, as this is the default.
2022-08-13 15:25:41 +02:00
Yureka 66ac47bdf6 cargoSetupHook: remove unneeded rustflags for aarch64+static cross
The linked issue was resolved upstream and the `-lgcc` is no longer required
since https://github.com/rust-lang/compiler-builtins/pull/377 was merged.
2022-08-13 15:24:14 +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
Martin Weinelt b4988e25b5 maturin: 0.12.9 -> 0.13.0 2022-07-21 22:35:32 +02:00
John Ericson 39811b1da9 build-support/rust/lib: make arch and os functions respect target JSON 2022-07-18 22:54:19 -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
Artturin 9ca1379bdf fetchCargoTarball: allow adding nativeBuildInputs 2022-05-28 21:55:39 +03:00
Artturin 36ad5b9b96 buildRustPackage: add missing attr to remove
cargoUpdateHook is used in cargoDeps
2022-05-28 21:06:27 +03:00
sternenseemann 357da6c296 buildRustPackage: make cargoDeps logic easier to follow
The old logic flow had the structure

  if ( … ) {
    if ( … ) {
      …
    } else {
      …
    }
  } else {
    …
  }

which is quite hard to follow in Nix. Instead we ensure that no if
expression is inside a then branch.

This change is zero rebuild, as no logic was changed.
2022-05-13 08:18:39 +10: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
Yusuf Bera Ertan e2a3a3c690
default-crate-overrides: only add Security to propagatedBuildInputs on darwin for security-framework-sys 2022-04-28 21:24:46 +03: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
sohalt 3619ffaeb6 rust: fix importCargoLock for repositories without toplevel Cargo.toml
Some crates do not have a Cargo.toml at the top-level, but only in
nested directories. Before this change importCargoLock used to fail with:

error: manifest path `/nix/store/some-store-path/Cargo.toml` does not exist
2022-03-17 00:15:56 -04:00
Guillaume Girol bedabfbcef rustPlatform.bindgenHook: init 2022-02-22 19:37:07 +01:00
github-actions[bot] b74b591fbe
Merge master into staging-next 2022-01-20 00:01:46 +00: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
K900 deb7e771aa rust/hooks: ensure the build output ends up in the right place
Otherwise cargoInstallHook can fail to find and actually install it.
2021-12-26 11:04:07 +03:00
John Ericson f721e0f849
Merge pull request #145107 from Ericson2314/buildRustCrate-sysroot
build-support/rust: Fix sysroot for cross
2021-11-24 18:44:13 -05:00
Andreas Rammhold 48de1b8ed8
Merge pull request #142699 from steveeJ-forks/fix-import-cargo-lock
rust: find nested packages in git repositories
2021-11-17 13:31:57 +01:00
John Ericson 05efb8ed91 build-support/rust/sysroot/src: Use dont* instead of phase list
Making this separate commit because the original was moved out just the
way it was done before.
2021-11-08 21:38:58 +00:00
John Ericson c9c3de0131 Update script as rust-src layout has changed
Use stub lib so `core` and `alloc` are handled symmetrically.
2021-11-08 20:38:59 +00:00
John Ericson cbd00bab80 build-support/rust: Split out sysroot src derivation
Hoping to make it usable for `buildRustCrate` too.
2021-11-08 20:38:59 +00:00
John Ericson 4f81865aa1 Merge remote-tracking branch 'upstream/master' into staging-next 2021-11-07 20:51:04 +00:00
John Ericson 18ed048c7b build-support/rust: Organize
- `toRustTarget` and friends pulled out from rust tools into rust
   library. Since they don't depend on any packages they can be more
   widely useable.

 - `build-rust-package` gets its own directory

 - `fetch-cargo-tarball` gets its own directory
2021-11-07 14:16:49 -05:00
Alyssa Ross 3f01b576af
Merge remote-tracking branch 'nixpkgs/staging-next' into staging
Conflicts:
	nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
	nixos/doc/manual/release-notes/rl-2111.section.md
2021-10-28 16:07:38 +00:00
github-actions[bot] a1e570b43e
Merge master into staging-next 2021-10-28 00:01:36 +00:00
Kerstin Humm 5df2d4d345
default-crate-overrides: remove two crates that are probably irrelevant 2021-10-27 22:29:10 +02:00
Kerstin Humm f1bacf5b07 default-crate-overrides: expat-sys, glib-sys, libudev-sys, sdl2-sys, servo-fontconfig, skia-bindings 2021-10-28 03:07:33 +09:00
figsoda 5a08a28803 rustPlatform: add support for features 2021-10-27 08:08:03 -04:00
Stefan Junker 445510ed69 rust/import-cargo-lock: hopefully make nested crate test work on macos 2021-10-25 01:11:45 +02:00
Stefan Junker f9a340a916 rust/import-cargo-lock: add test git-dependency-rev-non-workspace-nested-crate 2021-10-24 20:27:42 +02:00
Stefan Junker b2aa19efe7 rust: find nested packages in git repositories
this mimics the heuristic cargo uses for finding crates in their git
repositories ([cargo-issue-1462]).

[cargo-issue-1462]: https://github.com/rust-lang/cargo/issues/1462
2021-10-24 01:52:44 +02:00
github-actions[bot] 2d8f645c79
Merge master into staging-next 2021-10-20 06:01:15 +00:00
figsoda f441e6b7f4 buildRustPackage,fetchCargoTarball: accept empty hashes 2021-10-19 20:56:46 -04:00
figsoda 836e6d3e02 buildRustPackage: remove unused arguments, minor styling changes 2021-10-19 20:11:28 -04:00
figsoda d81f8fa0a4
Merge pull request #138822 from figsoda/fix-cargo-check-type
[staging] rustPlatform.cargoCheckHook: respect cargoCheckType
2021-10-11 15:54:00 -04: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
figsoda 22efdc986c rustPlatform.cargoCheckHook: respect cargoCheckType 2021-09-21 13:00:25 -04:00
Bruno Bigras c426b46aee defaultCrateOverrides: add rdkafka-sys 2021-09-21 12:07:25 -04:00
Daniël de Kok 24b5074348
Merge pull request #137395 from dermetfan/cargo-lock-restricted
importCargoLock: introduce alternative parameter `lockFileContents`
2021-09-20 18:05:08 +02:00
Robin Stumm d3018c4522 importCargoLock: introduce alternative parameter lockFileContents
In restricted mode (and therefore with flakes) `builtins.readFile` may not be the result of `builtins.toFile`,
making it impossible to use a generated lockFile (with or without IFD),
and thereby causing evaluation to fail if `system != builtins.currentSystem` on Hydra
so the jobs are not delegated to eligible build machines that support that system.

This is done in a way that avoids rebuilds.
2021-09-20 14:54:40 +02:00
Daniël de Kok 6f2ce2a65e treewide: remove danieldk as maintainer from a set of packages
I currently do not have much time to work on nixpkgs. Remove
myself as a maintainer from a bunch of packages to avoid that
people are waiting on me for a review.
2021-09-12 14:42:12 +00:00
Sandro bcced5deff
Merge pull request #137204 from SuperSandro2000/fetchCargoTarball
rust.fetchCargoTarball: remove phases
2021-09-11 19:31:03 +02:00
Jörg Thalheim f21712edaa importCargoLock: add docs how to run these tests 2021-09-11 11:14:58 +02:00
Yureka 34cc1821db
importCargoLock: add tests for branch and tag 2021-09-11 09:19:18 +02:00
Yureka 00b1ac5b23 importCargoLock: git deps with rev, branch or tag
Previously importCargoLog only recognized git dependencies with `rev =`.
This adds support for git dependencies with `branch =` or `tag =`.
2021-09-10 23:00:46 +02:00
Sandro Jäckel 012685943f
rust.fetchCargoTarball: remove phases 2021-09-09 19:17:48 +02:00
happysalada c9f0c6f115 build-rust-crate: add global libiconv darwin buildInputs 2021-09-04 12:03:36 +09:00
happysalada 0585c981f1 build-rust-crate: nixpkgs-fmt 2021-09-04 12:03:36 +09:00
happysalada 0e8d59e3cb default-crate-overrides: nixpkgs-fmt 2021-09-04 12:03:36 +09:00
Robin Stumm 3bdfca4491 buildRustPackage: remove unused parameter 2021-08-20 12:46:05 +02:00
Robert Hensing a13aa64bd3 build-support/rust: remove unused runCommandNoCC 2021-08-15 17:36:41 +02:00
tekeri 2419ea4aff rust: fix build of pam-sys package 2021-08-15 15:55:20 +09:00
Romanos Skiadas 23dd37dd5e rustPlatform.importCargoLock: add an assert for old Cargo.locks
near the end of 2019, the default Cargo.lock format was changed to
[[package]]
checksum = ...

This is what importCargoLock assumes. If the crate had not been `cargo
update`'d with a more recent toolchain than the one with the new
format as default, importCargoLock would fail when trying to access
pkg.checksum.

I ran into such a case (shamefully, in my own crate) and it took me a
while to figure out what was going on, so here is an assert with a
more user friendly message and a hint.
2021-07-18 18:19:50 +03:00
pandaman64 c39040195f build-rust-crate: disable incremental builds
According to rustc implementation[1], `-C incremental=no` enables
incremental builds with directory name `no`. This patch removes the
`-C incremental` argument to disable incremental builds.

[1]: ee86f96ba1/compiler/rustc_session/src/options.rs (L918-L919)
2021-07-09 22:55:38 +09:00
Daniël de Kok 1da0b1dbc9
Merge pull request #122158 from danieldk/import-cargo-lock
rustPlatform.buildRustPackage: support direct use of Cargo.lock
2021-05-28 12:07:25 +02:00
Daniël de Kok d3769e43c3 rustPlatform.importCargoLock: add test cases for importCargoLock 2021-05-28 08:01:28 +02:00
Daniël de Kok b3969f3ad7 rustPlatform.buildRustPackage: support direct use of Cargo.lock
This change introduces the cargoLock argument to buildRustPackage,
which can be used in place of cargo{Sha256,Hash} or cargoVendorDir. It
uses the importCargoLock function to build the vendor
directory. Differences compared to cargo{Sha256,Hash}:

- Requires a Cargo.lock file.
- Does not require a Cargo hash.
- Retrieves all dependencies as fixed-output derivations.

This makes buildRustPackage much easier to use as part of a Rust
project, since it does not require updating cargo{Sha256,Hash} for
every change to the lock file.
2021-05-28 08:01:28 +02:00
Daniël de Kok 2f46d77e28 rustPlatform.importCargoLock: init
This function can be used to create an output path that is a cargo
vendor directory. In contrast to e.g. fetchCargoTarball all the
dependent crates are fetched using fixed-output derivations. The
hashes for the fixed-output derivations are gathered from the
Cargo.lock file.

Usage is very simple, e.g.:

importCargoLock {
  lockFile = ./Cargo.lock;
}

would use the lockfile from the current directory.

The implementation of this function is based on Eelco Dolstra's
import-cargo:

https://github.com/edolstra/import-cargo/blob/master/flake.nix

Compared to upstream:

- We use fetchgit in place of builtins.fetchGit.
- Sync to current cargo vendoring.
2021-05-28 08:01:25 +02:00
Daniël de Kok 7eddab91f5
Merge pull request #123867 from danieldk/maturin-0.10.5
maturin: 0.10.4 -> 0.10.6
2021-05-25 16:01:47 +02:00
Daniël de Kok 11307c1d47 maturinBuildHook: add rustc to deps
maturin 0.10.5 uses rustc -vV to find the host:

e886c85f5a

We now need to make rustc visible to the hook for maturin to work
properly.
2021-05-21 07:51:27 +02:00
Pavol Rusnak 252bf94a74 rust: 1.51.0 -> 1.52.0 2021-05-08 11:42:10 -07:00
Andrew Childs 7869d16545 llvmPackages: Multuple outputs for everythting
Also begin to start work on cross compilation, though that will have to
be finished later.

The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.

Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.

----

Other misc notes, highly incomplete

- lvm-config-native and llvm-config are put in `dev` because they are
  tools just for build time.

- Clang no longer has an lld dep. That was introduced in
  db29857eb3, but if clang needs help
  finding lld when it is used we should just pass it flags / put in the
  resource dir. Providing it at build time increases critical path
  length for no good reason.

----

A note on `nativeCC`:

`stdenv` takes tools from the previous stage, so:

1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`

while:

1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
2021-04-30 05:41:00 +00:00
zseri ff5ff66ef3 build-rust-crate: disable incremental builds 2021-04-08 10:45:56 +02:00
Jonathan Ringer 042adf08d1 cargo/hooks: allow hooks to be disabled 2021-03-08 19:17:03 +01:00
Ana Hobden a84cb88c47 rustPlatform.buildRustPackage: support debug builds
Signed-off-by: Ana Hobden <operator@hoverbear.org>
2021-03-04 07:16:29 -08:00
Max Hausch ebe3ae4d4d
buildRustPackage: Add cargoTestFlags
This makes it possible to pass flags to `cargo test`, which is needed if
a crate is compiled with custom feature flags.
2021-03-02 09:45:26 +01:00
Daniël de Kok c50a347cb5 buildRustPackage: use checkType argument
The `checkType` argument of buildRustPackage was not used anymore
since the refactoring of `buildRustPackage` into hooks. This was
an oversight that is fixed by this change.

The check type can also be passed directly to cargoCheckHook using the
`cargoCheckType` environment variable.
2021-02-26 11:57:27 +01:00
Frederik Rietdijk c456a2512f Merge master into staging-next 2021-02-26 10:25:13 +01:00
Daniël de Kok 1df80d2bad diesel-cli: use comma-separated features, use buildAndTestSubdir 2021-02-16 08:09:17 +01:00
Daniël de Kok 087ab3db9c buildRustPackage: handle cargoBuildFlags in cargoBuildHook 2021-02-16 08:09:17 +01:00
Daniël de Kok 05e40e79a8 buildRustPackage: factor out check phase to cargoCheckHook
API change:

`cargoParallelTestThreads` suggests that this attribute sets the
number of threads used during tests, while it is actually a boolean
option (use 1 thread or NIX_BUILD_CORES threads). In the hook, this
is replaced by a more canonical name `dontUseCargoParallelTests`.
2021-02-16 08:09:15 +01:00
Daniël de Kok 9757c7101a buildRustPackage: factor out install phase to cargoInstallHook 2021-02-15 12:17:18 +01:00