Commit Graph

243 Commits

Author SHA1 Message Date
K900
d8a54461fc Merge remote-tracking branch 'origin/staging-next' into staging 2024-09-20 07:27:56 +03:00
Artturin
cd6ed2642c rustc: Correct enable-profiler linux check
remove the `isRedox` condition which was added because `stdenv.isLinux` uses `hostPlatform`, after specifying `targetPlatform` it's no longer necessary.
2024-09-19 19:15:25 +03:00
Manuel Mendez
17b3df2861 rust: Write to .cargo/config.toml instead of .cargo/config
Seeing the following new warnings pop up on stderr when cargo was bumped
to 1.78:

```
warning: `/build/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
```

which happens to break commitmsgfmt builds in nix (#320294).

closes #320294
2024-09-11 21:03:32 -04:00
Alyssa Ross
5f125d57c3 cargo,clippy,rustc,rustfmt: 1.80.1 -> 1.81.0
Fixes: CVE-2024-24576
2024-09-10 15:02:38 +02:00
Alyssa Ross
0852f8eb84 rustc: expose platform lists
Previously, it wasn't possible to access the list of platforms we can
build Rust programs for outside of buildRustPackage.  This was a
problem for packages that have optional Rust components, like
gstreamer or Meson, as there was no way to only build the Rust parts
for supported platforms.  Now it's possible to get that information
from rustc's passthru.
2024-09-03 17:47:27 +02:00
Alyssa Ross
ecba63d3e6 rustc: fix building with MinGW target
Building std requires dlltool for the target platform.
2024-08-25 17:25:00 +02:00
K900
27d4ae6645 rustc: 1.80.0 -> 1.80.1, add zlib dependency on Darwin 2024-08-09 10:29:38 +03:00
Tristan Ross
6a163e2a36 rustc: fix building with llvm (#320432) 2024-07-25 01:48:56 -04:00
Vladimír Čunát
040c460262 Revert "rustc: avoid rebuild on linux right now"
This reverts commit 68538d36ce.
2024-07-01 09:26:16 +02:00
Vladimír Čunát
68538d36ce rustc: avoid rebuild on linux right now 2024-07-01 07:32:23 +02:00
Robert Scott
4839263513 rustc: disable zerocallusedregs hardening flag on clang stdenv
to reverse breakage due to it not being supported by
clang when building for wasm32. really we should not be
using a wrapped compiler to build for wasm, but that's
a tangled knot..
2024-06-30 22:46:46 +01:00
Winter
2de1fd60fc Revert "rust: Write config.toml not config" 2024-06-23 12:32:29 -04:00
Manuel Mendez
3f7663c1d7 rust: Write to .cargo/config.toml instead of .cargo/config
Seeing the following new warnings pop up on stderr when cargo was bumped
to 1.78:

```
warning: `/build/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
```

which happens to break commitmsgfmt builds in nix (#320294).

closes #320294
2024-06-19 14:56:51 -04:00
Alyssa Ross
b00f262516 Revert "rustc: disable wasm32 if some gcc options are set"
This reverts commits 6d0ba08b97,
723100d83b, and
bf13eca852.

The underlying issue has now been fixed, so we can re-enable
wasm32-unknown-unknown on all platforms.
2024-06-15 08:02:29 +02:00
github-actions[bot]
c8c2ff3b9b Merge staging-next into staging 2024-06-10 00:02:49 +00:00
Alyssa Ross
3df6bb2c85 Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
	pkgs/applications/blockchains/polkadot/default.nix
2024-06-09 22:47:12 +01:00
Alexis Hildebrandt
755b915a15 treewide: Remove indefinite article from meta.description
nix run nixpkgs#silver-searcher -- -G '\.nix$' -0l 'description.*"[Aa]n?' pkgs \
  | xargs -0 nix run nixpkgs#gnused -- -i '' -Ee 's/(description.*")[Aa]n? (.)/\1\U\2/'
2024-06-09 23:07:45 +02:00
github-actions[bot]
afa876d6fe Merge staging-next into staging 2024-06-09 12:01:33 +00:00
Alyssa Ross
bf13eca852 rustc: disable wasm32 if some gcc options are set
This is a temporary fix to get rustc building again with these
configurations (which notably include the default aarch64-darwin one)
without causing a stdenv rebuild.  The real fix will be to avoid
passing these options through the Clang wrapper when the target is
overridden.

It could be that there are packages that need wasm32-unknown-unknown
beyond those I've marked as broken here — it's impossible to be sure
without a full rebuild.  But this should be most of them.
2024-06-09 07:20:18 +01:00
github-actions[bot]
d7993cebbc Merge staging-next into staging 2024-06-05 12:01:43 +00:00
Alyssa Ross
ddc356c1f0 buildPackages.rustc: fix cross
Fixes: 23d4f83453 ("cargo,clippy,rustc,rustfmt: 1.77.2 -> 1.78.0")
2024-06-05 09:58:33 +01:00
Artemis Tosini
8135af13f1 rustc: Add support for FreeBSD 2024-05-31 14:12:12 -07:00
Alyssa Ross
07f40e6892 rustc: don't try to use non-existent rust-lld
This removes the need to manually override Rust's default linker for
every package that builds for wasm32-unknown-unknown.
2024-05-29 23:08:09 +02:00
John Ericson
266cdd7d37 treewide: freebsd13 -> freebsd
Co-authored-by: Alyssa Ross <hi@alyssa.is>
2024-04-30 18:20:23 -04:00
Alyssa Ross
9e0eb58032 rustc: build rustdoc even when cross compiling
rustdoc is built for native builds, because it's used to run doctests,
but it wasn't built for cross builds, since they don't run doctests.
This inconsistency led to wrapRustc not working for cross-compiled
rustc, because it expected there to be a rustdoc binary.

In the interests of consistency, let's instruct the build system to
always build rustdoc.

Link: https://github.com/NixOS/nixpkgs/pull/292777#issuecomment-2048071969
Fixes: 6f8fa05acf ("wrapRustc: wrap rustdoc")
2024-04-10 23:09:42 +02:00
Alyssa Ross
6f8fa05acf wrapRustc: wrap rustdoc
We need to set -crt-static on musl for rustdoc as well, so let's unify
the wrappers.  Ideally, rather than wrapping rustdoc, we'd have
rustdoc use the wrapped rustc, but that's currently only possible with
an unstable option (--test-builder).

The options set by the wrapper, -C target-feature and --sysroot, are
supported by both rustdoc and rustc, but other flags maybe not be
supported by both, so I've introduced different environment
variables (the existing NIX_RUSTFLAGS and a new NIX_RUSTDOCFLAGS) to
allow those to be set independently.

This fixes cargo-auditable in pkgsMusl., which broke because its
doctests stopped working when -crt-static was moved to the wrapper.

Fixes: 79156bf13a ("rustc: move crt-static default override to wrapper (#291829)")
2024-03-02 13:09:07 +01:00
Alyssa Ross
79156bf13a rustc: move crt-static default override to wrapper (#291829)
Previously, when cross compiling from non-musl to musl, the crt-static
default override wouldn't be applied, because the compiler wouldn't
have been built with it due to fastCross.  Moving it to the wrapper
fixes this without having to introduce extra compiler rebuilds.  And
because the wrapper is applied even to the bootstrap rustc, we no
longer need special handling of crt-static in the Cargo expression.

Unlike --sysroot, rustc allows -C target-feature= to be passed
multiple times, with later instances taking precedence over earlier
ones.  This means that it's very easy to set the default in the
wrapper, just by our overridden default before any other arguments.

This fixes pkgsCross.aarch64-multiplatform-musl.mesa from x86_64-linux.
2024-02-28 23:10:07 +01:00
github-actions[bot]
7c48a66399 Merge master into staging-next 2024-01-05 12:01:19 +00:00
Yureka
d890c560a6 rustc: fix musl crt_static substituteInPlace path 2024-01-04 15:06:30 +01:00
Paul Lietar
8e1e16fdcb rustc: Fix building cross-compilers for no_std targets.
When building a cross-compiler, the rustc derivation does some tricks to
only build the standard library and reuse the host's compiler, leading
to much faster build time.

Unfortunately, the way the build system was invoked, it would always
build the `std` crate, whether or not the target supports it. Some
bare-metal targets only support building the `core` and `alloc` crates.

By being more vague about the build command, using `library` instead of
`library/std`, Rust's build system is able to figure out exactly which
crates to build:
https://github.com/rust-lang/rust/blob/1.74.1/src/bootstrap/compile.rs#L370-L412

Oddly enough, the install command still needs to use `library/std`, even
if building just a subset:
https://github.com/rust-lang/rust/blob/1.74.1/src/bootstrap/install.rs#L207

The following command was used to reproduce the original issue. Without
this patch, it leads to a build failure when trying to compile one of
std's dependencies. With the patch it completes succesfully and produces
a working cross-compiler.

  nix build --impure --expr '(import ./. {
    crossSystem = {
      config = "riscv32-none-elf";
      rustc.config = "riscv32imc-unknown-none-elf";
    };
  }).buildPackages.rustc'
2024-01-04 10:18:33 +00:00
Alyssa Ross
989723ecf2 rustc-wasm32: merge into rustc
Since wasm32-unknown-unknown doesn't require any extra
platform-specific dependencies (e.g. libc), we might as well just
always include in with rustc.  We could also include other targets
fitting these criteria, but I wasn't able to find any others that
actually build (not even wasm64-unknown-unknown).

The old rustc-wasm32 package disabled documentation, but we don't
actually need to do that — we just need to allow for some broken links
in the wasm32-unknown-unknown documentation.  Broken links in
documentation are an upstream issue anyway.  There's no need we need
to fail our build for them.
2023-12-05 15:09:28 +01:00
Alyssa Ross
8929ba838f rustc: use the wrapper for fastCross sysroot
This avoids having two layers of wrapper for cross rustc.
2023-11-30 09:23:06 +00:00
Alyssa Ross
8b51cdd3be rustc: add a compiler wrapper
We keep running into situations where we can't get the right
combination of rustc flags through build systems into rustc.
RUSTFLAGS is the only variable supported across build systems, but if
RUSTFLAGS is set, Cargo will ignore all other ways of specifying rustc
flags, including the target-specific ones, which we need to make
dynamic musl builds work.  (This is why pkgsCross.musl64.crosvm is
currently broken — it works if you unset separateDebugInfo, which
causes RUSTFLAGS not to be set.)

So, we need to do the same thing we do for C and C++ compilers, and
add a compiler wrapper so we can inject the flags we need, regardless
of the build system.

Currently the wrapper only supports a single mechanism for injecting
flags — the NIX_RUSTFLAGS environment variable.  As time goes on,
we'll probably want to add additional features, like target-specific
environment variables.
2023-11-30 09:23:06 +00:00
Alyssa Ross
e9ca6038eb rustc,cargo: 1.73.0 -> 1.74.0
The BOOTSTRAP_ARGS patch is no longer necessary since
863d2fddd79 ("Pass `-jN` from Make to `BOOTSTRAP_ARGS`").

We now have to set sysconfdir, because since
350ead87205 ("add sanity checks for user write access on `x install`"),
the build system will check it can write there, even though nothing
actually gets installed there.  (Previously it defaulted to /etc.)
2023-11-17 10:52:01 +01:00
Weijia Wang
c1eb661271 Merge branch 'master' into staging-next 2023-11-12 22:13:26 +01:00
Adam Joseph
b6a3fabcc1 rust: allow building/git-bisecting without tarballs
This commit adds the machinery required to get our `rustc.nix` to
work using upstream's git repository, directly, without them waving
dead chickens over it and performing whatever other occult rituals
are involved in creating a release tarball.

No chickens, live or dead, were harmed in the creation of this
commit.
2023-11-11 22:12:40 -08: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
Vladimír Čunát
d811555465 Merge branch 'staging' into staging-next 2023-10-26 10:36:50 +02:00
Robin Gloster
e5d552f5b9 treewide: update globin's maintainership 2023-10-24 13:09:45 +02:00
Ryan Lahfa
5829a85d6f Merge pull request #257950 from RaitoBezarius/rustc-clang 2023-10-12 02:26:16 +02:00
Alyssa Ross
c11cb00a1e rustc: 1.72.1 -> 1.73.0
This upgrade unfortunately removes MIPS support, as it has been
dropped to Tier 3[1] and so bootstrap tarballs are no longer provided.

It looks like it was dropped due to multiple codegen bugs, and lack of
maintenance, so bringing it back would probably involve engaging with
Rust/LLVM upstream on those.

[1]: https://github.com/rust-lang/compiler-team/issues/648
2023-10-10 14:42:30 +00:00
Anderson Torres
a9d73dea16 treewide: remove cstrahan from meta.maintainers - part 2
19 files modified with this removal
2023-10-04 22:20:58 -03:00
Raito Bezarius
6783b22c9e rustc: support clang-based stdenv
Previously, we were passing `cc` and `c++` all the time to rustc bootstrap process.

This was wrong because `cc-rs` relies on the name of the compiler to detect whether this is Clang or a GNU GCC.

Related:

[1]: df2f86ceaf/src/lib.rs (L3334)
[2]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Missing.20dynamic.20libraries.20when.20bootstrapping.20Rust/near/377914373
2023-09-29 05:13:17 +02:00
Asad Mehmood
9ee10432a4 rust: cargo: Use rustc and cargo built on Build
When cross-compiling a rust package, all we need is the std library compiled
for the target. This uses the final stage compiler which was built for Build
and then uses that as a stage0 compiler for target std library.

It also copies the rust binary from pkgsBuildBuild so that it find the new
lib/rustlib directory.

We also need to create a cargo wrapper which will use the "new" rust compiler

Also makes sure man pages and doc pages are propagated

Co-authored-by: Alyssa Ross <hi@alyssa.is>
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Co-authored-by: Rick van Schijndel <Mindavi@users.noreply.github.com>
2023-09-10 14:48:39 +02:00
figsoda
45e33f6672 rustc: build rust-analyzer-proc-macro-srv
It was incorrectly removed in https://github.com/NixOS/nixpkgs/pull/243283
2023-07-24 14:35:23 -04:00
figsoda
8f4874ca39 rustc: 1.70.0 -> 1.71.0
https://blog.rust-lang.org/2023/07/13/Rust-1.71.0.html

https://github.com/rust-lang/rust/releases/tag/1.71.0
2023-07-14 10:16:41 -04:00
Randy Eckenrode
93320f3e30 rustc: link libc++abi on Darwin 2023-07-08 07:33:04 -06:00
Alyssa Ross
f2e0e190f5 rustc: mark supported on loongarch64
loongarch64 is tier 2 with host tools.
2023-06-25 13:23:47 +00:00
Ben Wolsieffer
87ebad10d6 rustc: add armv6l-linux to platforms
armv6l-linux was incorrectly added to the list of platforms without host
tools in #227987. arm-unknown-linux-gnueabihf is present in the list of
Tier 2 targets with host tools, and this target corresponds to our
armv6l-linux platform.
2023-06-15 16:56:55 -04:00
Alyssa Ross
adb54ab7bd rustc: remove unused argument 2023-05-22 21:46:08 +00:00