diff options
Diffstat (limited to 'pkgs/development/compilers/rust')
-rw-r--r-- | pkgs/development/compilers/rust/1_78.nix | 59 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/binary.nix | 100 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/bootstrap.nix | 14 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/cargo-auditable-cargo-wrapper.nix | 24 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/cargo-auditable.nix | 60 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/cargo.nix | 85 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/cargo_cross.nix | 14 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/clippy.nix | 46 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/default.nix | 106 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/make-rust-platform.nix | 40 | ||||
-rwxr-xr-x | pkgs/development/compilers/rust/print-hashes.sh | 43 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/rust-lib-src.nix | 6 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/rust-src.nix | 21 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/rustc.nix | 300 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/rustfmt.nix | 44 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/setup-hook.sh | 4 |
16 files changed, 0 insertions, 966 deletions
diff --git a/pkgs/development/compilers/rust/1_78.nix b/pkgs/development/compilers/rust/1_78.nix deleted file mode 100644 index 3ce368e8d99f..000000000000 --- a/pkgs/development/compilers/rust/1_78.nix +++ /dev/null @@ -1,59 +0,0 @@ -# New rust versions should first go to staging. -# Things to check after updating: -# 1. Rustc should produce rust binaries on x86_64-linux, aarch64-linux and x86_64-darwin: -# i.e. nix-shell -p fd or @GrahamcOfBorg build fd on github -# This testing can be also done by other volunteers as part of the pull -# request review, in case platforms cannot be covered. -# 2. The LLVM version used for building should match with rust upstream. -# Check the version number in the src/llvm-project git submodule in: -# https://github.com/rust-lang/rust/blob/<version-tag>/.gitmodules -# 3. Firefox and Thunderbird should still build on x86_64-linux. - -{ stdenv, lib -, newScope, callPackage -, CoreFoundation, Security, SystemConfiguration -, pkgsBuildTarget, pkgsBuildBuild, pkgsBuildHost, pkgsTargetTarget -, makeRustPlatform -, wrapRustcWith -, llvmPackages_18, llvm_18 -} @ args: - -import ./default.nix { - rustcVersion = "1.78.0"; - rustcSha256 = "/1RII6XLJ/JzgShXfx5+AO6PTIPyo0h4GuT8NV6R1ak="; - - llvmSharedForBuild = pkgsBuildBuild.llvmPackages_18.libllvm.override { enableSharedLibraries = true; }; - llvmSharedForHost = pkgsBuildHost.llvmPackages_18.libllvm.override { enableSharedLibraries = true; }; - llvmSharedForTarget = pkgsBuildTarget.llvmPackages_18.libllvm.override { enableSharedLibraries = true; }; - - # For use at runtime - llvmShared = llvm_18.override { enableSharedLibraries = true; }; - - # Expose llvmPackages used for rustc from rustc via passthru for LTO in Firefox - llvmPackages = llvmPackages_18; - - # Note: the version MUST be one version prior to the version we're - # building - bootstrapVersion = "1.77.2"; - - # fetch hashes by running `print-hashes.sh ${bootstrapVersion}` - bootstrapHashes = { - i686-unknown-linux-gnu = "168e653fbc30b3a80801bc7735a79ff644651618434234959925f669bf77d1a2"; - x86_64-unknown-linux-gnu = "b7d12b1b162c36c1fd5234b4b16856aa7eafca91d17c49787f6487cb26f4062d"; - x86_64-unknown-linux-musl = "2e08fe23c4837a780a40ebfac601760cd6297581d21eae2f88cb59060243a375"; - arm-unknown-linux-gnueabihf = "9f14a31dbef0153c0a7463a79cf8f9e8295b355354de41aa054953027beb70d7"; - armv7-unknown-linux-gnueabihf = "b37649399081228244b3ff3acc6047f6c138e602c721cd500efe43715d043c5e"; - aarch64-unknown-linux-gnu = "297c6201edd42e580f242fcd75b521b0392f6f3be02cf03ca76690fece4a74da"; - aarch64-unknown-linux-musl = "fdd9c485f93c73a085c113b4f0fbad0989f79153079d394ec4bbac2b3804f71b"; - x86_64-apple-darwin = "16bbbfcf0c982b35271d8904977d80fda1bb7caa7f898abceed3569a867d9cea"; - aarch64-apple-darwin = "415bb2bc198feb0f2d8329e33c57d0890bbd57977d1ae48b17f6c7e1f632eaa7"; - powerpc64le-unknown-linux-gnu = "79582acb339bd2d79fef095b977049049ffa04616011f1af1793fb8e98194b19"; - riscv64gc-unknown-linux-gnu = "300fe4861e2d1f6e4c4f5e36ae7997beca8a979343a7f661237ab78a37a54648"; - }; - - selectRustPackage = pkgs: pkgs.rust_1_78; - - rustcPatches = [ ]; -} - -(builtins.removeAttrs args [ "llvmPackages_18" "llvm_18"]) diff --git a/pkgs/development/compilers/rust/binary.nix b/pkgs/development/compilers/rust/binary.nix deleted file mode 100644 index d1df1c542e98..000000000000 --- a/pkgs/development/compilers/rust/binary.nix +++ /dev/null @@ -1,100 +0,0 @@ -{ lib, stdenv, makeWrapper, wrapRustc, bash, curl, darwin, zlib -, autoPatchelfHook, gcc -, version -, src -, platform -, versionType -}: - -let - inherit (lib) optionalString; - inherit (darwin.apple_sdk.frameworks) Security; - - bootstrapping = versionType == "bootstrap"; - - installComponents - = "rustc,rust-std-${platform}" - + (optionalString bootstrapping ",cargo") - ; -in - -rec { - rustc-unwrapped = stdenv.mkDerivation { - pname = "rustc-${versionType}"; - - inherit version; - inherit src; - - meta = with lib; { - homepage = "https://www.rust-lang.org/"; - sourceProvenance = with sourceTypes; [ binaryNativeCode ]; - description = "Safe, concurrent, practical language"; - maintainers = with maintainers; [ qknight ]; - license = [ licenses.mit licenses.asl20 ]; - }; - - nativeBuildInputs = lib.optional (!stdenv.isDarwin) autoPatchelfHook; - buildInputs = [ bash ] - ++ lib.optionals (!stdenv.isDarwin) [ gcc.cc.lib zlib ] - ++ lib.optional stdenv.isDarwin Security; - - postPatch = '' - patchShebangs . - ''; - - installPhase = '' - ./install.sh --prefix=$out \ - --components=${installComponents} - - # Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc - # (or similar) here. It causes strange effects where rustc loads - # the wrong libraries in a bootstrap-build causing failures that - # are very hard to track down. For details, see - # https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943 - ''; - - # The strip tool in cctools 973.0.1 and up appears to break rlibs in the - # binaries. The lib.rmeta object inside the ar archive should contain an - # .rmeta section, but it is removed. Luckily, this doesn't appear to be an - # issue for Rust builds produced by Nix. - dontStrip = true; - - setupHooks = ./setup-hook.sh; - }; - - rustc = wrapRustc rustc-unwrapped; - - cargo = stdenv.mkDerivation { - pname = "cargo-${versionType}"; - - inherit version; - inherit src; - - meta = with lib; { - homepage = "https://doc.rust-lang.org/cargo/"; - sourceProvenance = with sourceTypes; [ binaryNativeCode ]; - description = "Rust package manager"; - maintainers = with maintainers; [ qknight ]; - license = [ licenses.mit licenses.asl20 ]; - }; - - nativeBuildInputs = [ makeWrapper ] - ++ lib.optional (!stdenv.isDarwin) autoPatchelfHook; - buildInputs = [ bash ] - ++ lib.optional (!stdenv.isDarwin) gcc.cc.lib - ++ lib.optional stdenv.isDarwin Security; - - postPatch = '' - patchShebangs . - ''; - - installPhase = '' - patchShebangs ./install.sh - ./install.sh --prefix=$out \ - --components=cargo - - wrapProgram "$out/bin/cargo" \ - --suffix PATH : "${rustc}/bin" - ''; - }; -} diff --git a/pkgs/development/compilers/rust/bootstrap.nix b/pkgs/development/compilers/rust/bootstrap.nix deleted file mode 100644 index 97ac69270252..000000000000 --- a/pkgs/development/compilers/rust/bootstrap.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ stdenv, fetchurl, callPackage, version, hashes }: - -let - platform = stdenv.hostPlatform.rust.rustcTarget; - - src = fetchurl { - url = "https://static.rust-lang.org/dist/rust-${version}-${platform}.tar.gz"; - sha256 = hashes.${platform} or (throw "missing bootstrap url for platform ${platform}"); - }; - -in callPackage ./binary.nix - { inherit version src platform; - versionType = "bootstrap"; - } diff --git a/pkgs/development/compilers/rust/cargo-auditable-cargo-wrapper.nix b/pkgs/development/compilers/rust/cargo-auditable-cargo-wrapper.nix deleted file mode 100644 index 6e982aee01a3..000000000000 --- a/pkgs/development/compilers/rust/cargo-auditable-cargo-wrapper.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ lib, runCommand, makeBinaryWrapper, rust-audit-info, cargo, cargo-auditable }: - -if cargo-auditable.meta.broken then - cargo -else -runCommand "auditable-${cargo.name}" { - nativeBuildInputs = [ makeBinaryWrapper ]; - - passthru.tests = runCommand "rust-audit-info-test" { - nativeBuildInputs = [ rust-audit-info ]; - } '' - rust-audit-info ${lib.getBin rust-audit-info}/bin/rust-audit-info > $out - ''; - - meta = cargo-auditable.meta // { - mainProgram = "cargo"; - }; -} '' - mkdir -p $out/bin - makeWrapper ${cargo}/bin/cargo $out/bin/cargo \ - --set CARGO_AUDITABLE_IGNORE_UNSUPPORTED 1 \ - --prefix PATH : ${lib.makeBinPath [ cargo cargo-auditable ]} \ - --add-flags auditable -'' diff --git a/pkgs/development/compilers/rust/cargo-auditable.nix b/pkgs/development/compilers/rust/cargo-auditable.nix deleted file mode 100644 index 0fa6098934c1..000000000000 --- a/pkgs/development/compilers/rust/cargo-auditable.nix +++ /dev/null @@ -1,60 +0,0 @@ -{ lib, buildPackages, fetchFromGitHub, fetchpatch, makeRustPlatform, installShellFiles, stdenv }: - -let - args = rec { - pname = "cargo-auditable"; - version = "0.6.2"; - - src = fetchFromGitHub { - owner = "rust-secure-code"; - repo = pname; - rev = "v${version}"; - sha256 = "sha256-ERIzx9Fveanq7/aWcB2sviTxIahvSu0sTwgpGf/aYE8="; - }; - - patches = [ - (fetchpatch { - name = "rust-1.77-tests.patch"; - url = "https://github.com/rust-secure-code/cargo-auditable/commit/5317a27244fc428335c4e7a1d066ae0f65f0d496.patch"; - hash = "sha256-UblGseiSC/2eE4rcnTgYzxAMrutHFSdxKTHqKj1mX5o="; - }) - ]; - - cargoHash = "sha256-4o3ctun/8VcBRuj+j0Yaawdkyn6Z6LPp+FTyhPxQWU8="; - - meta = with lib; { - description = "Tool to make production Rust binaries auditable"; - mainProgram = "cargo-auditable"; - homepage = "https://github.com/rust-secure-code/cargo-auditable"; - changelog = "https://github.com/rust-secure-code/cargo-auditable/blob/v${version}/cargo-auditable/CHANGELOG.md"; - license = with licenses; [ mit /* or */ asl20 ]; - maintainers = with maintainers; [ figsoda ]; - broken = stdenv.hostPlatform != stdenv.buildPlatform; - }; - }; - - rustPlatform = makeRustPlatform { - inherit (buildPackages) rustc; - cargo = buildPackages.cargo.override { - auditable = false; - }; - }; - - bootstrap = rustPlatform.buildRustPackage (args // { - auditable = false; - }); -in - -rustPlatform.buildRustPackage.override { cargo-auditable = bootstrap; } (args // { - nativeBuildInputs = [ - installShellFiles - ]; - - postInstall = '' - installManPage cargo-auditable/cargo-auditable.1 - ''; - - passthru = { - inherit bootstrap; - }; -}) diff --git a/pkgs/development/compilers/rust/cargo.nix b/pkgs/development/compilers/rust/cargo.nix deleted file mode 100644 index b0c40c5760cb..000000000000 --- a/pkgs/development/compilers/rust/cargo.nix +++ /dev/null @@ -1,85 +0,0 @@ -{ lib, stdenv, pkgsBuildHost, pkgsHostHost -, file, curl, pkg-config, python3, openssl, cmake, zlib -, installShellFiles, makeWrapper, rustPlatform, rustc -, CoreFoundation, Security -, auditable ? !cargo-auditable.meta.broken -, cargo-auditable -, pkgsBuildBuild -}: - -rustPlatform.buildRustPackage.override { - cargo-auditable = cargo-auditable.bootstrap; -} ({ - pname = "cargo"; - inherit (rustc.unwrapped) version src; - - # the rust source tarball already has all the dependencies vendored, no need to fetch them again - cargoVendorDir = "vendor"; - buildAndTestSubdir = "src/tools/cargo"; - - inherit auditable; - - passthru = { - rustc = rustc; - inherit (rustc.unwrapped) tests; - }; - - # changes hash of vendor directory otherwise - dontUpdateAutotoolsGnuConfigScripts = true; - - nativeBuildInputs = [ - pkg-config cmake installShellFiles makeWrapper - (lib.getDev pkgsHostHost.curl) - zlib - ]; - buildInputs = [ file curl python3 openssl zlib ] - ++ lib.optionals stdenv.isDarwin [ CoreFoundation Security ]; - - # cargo uses git-rs which is made for a version of libgit2 from recent master that - # is not compatible with the current version in nixpkgs. - #LIBGIT2_SYS_USE_PKG_CONFIG = 1; - - # fixes: the cargo feature `edition` requires a nightly version of Cargo, but this is the `stable` channel - RUSTC_BOOTSTRAP = 1; - - postInstall = '' - wrapProgram "$out/bin/cargo" --suffix PATH : "${rustc}/bin" - - installManPage src/tools/cargo/src/etc/man/* - - installShellCompletion --bash --name cargo \ - src/tools/cargo/src/etc/cargo.bashcomp.sh - - installShellCompletion --zsh src/tools/cargo/src/etc/_cargo - ''; - - checkPhase = '' - # Disable cross compilation tests - export CFG_DISABLE_CROSS_TESTS=1 - cargo test - ''; - - # Disable check phase as there are failures (4 tests fail) - doCheck = false; - - doInstallCheck = !stdenv.hostPlatform.isStatic && stdenv.hostPlatform.isElf; - installCheckPhase = '' - runHook preInstallCheck - readelf -a $out/bin/.cargo-wrapped | grep -F 'Shared library: [libcurl.so' - runHook postInstallCheck - ''; - - meta = with lib; { - homepage = "https://crates.io"; - description = "Downloads your Rust project's dependencies and builds your project"; - mainProgram = "cargo"; - maintainers = teams.rust.members; - license = [ licenses.mit licenses.asl20 ]; - platforms = platforms.unix; - # https://github.com/alexcrichton/nghttp2-rs/issues/2 - broken = stdenv.hostPlatform.isx86 && stdenv.buildPlatform != stdenv.hostPlatform; - }; -} -// lib.optionalAttrs (stdenv.buildPlatform.rust.rustcTarget != stdenv.hostPlatform.rust.rustcTarget) { - HOST_PKG_CONFIG_PATH="${pkgsBuildBuild.pkg-config}/bin/pkg-config"; -}) diff --git a/pkgs/development/compilers/rust/cargo_cross.nix b/pkgs/development/compilers/rust/cargo_cross.nix deleted file mode 100644 index ba7651e63bdb..000000000000 --- a/pkgs/development/compilers/rust/cargo_cross.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ runCommand, stdenv, lib, pkgsBuildBuild, makeShellWrapper, rustc, ... }: - -runCommand "${stdenv.targetPlatform.config}-cargo-${lib.getVersion pkgsBuildBuild.cargo}" { - # Use depsBuildBuild or it tries to use target-runtimeShell - depsBuildBuild = [ makeShellWrapper ]; - - inherit (pkgsBuildBuild.cargo) meta; -} '' - mkdir -p $out/bin - ln -s ${pkgsBuildBuild.cargo}/share $out/share - - makeWrapper "${pkgsBuildBuild.cargo}/bin/cargo" "$out/bin/cargo" \ - --prefix PATH : "${rustc}/bin" - '' diff --git a/pkgs/development/compilers/rust/clippy.nix b/pkgs/development/compilers/rust/clippy.nix deleted file mode 100644 index beee43323dad..000000000000 --- a/pkgs/development/compilers/rust/clippy.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ stdenv, lib, rustPlatform, rustc, Security, patchelf }: - -rustPlatform.buildRustPackage { - pname = "clippy"; - inherit (rustc) version src; - - separateDebugInfo = true; - - # the rust source tarball already has all the dependencies vendored, no need to fetch them again - cargoVendorDir = "vendor"; - buildAndTestSubdir = "src/tools/clippy"; - - # changes hash of vendor directory otherwise - dontUpdateAutotoolsGnuConfigScripts = true; - - buildInputs = [ rustc.llvm ] - ++ lib.optionals stdenv.isDarwin [ Security ]; - - # fixes: error: the option `Z` is only accepted on the nightly compiler - RUSTC_BOOTSTRAP = 1; - - # Without disabling the test the build fails with: - # error: failed to run custom build command for `rustc_llvm v0.0.0 - # (/private/tmp/nix-build-clippy-1.36.0.drv-0/rustc-1.36.0-src/src/librustc_llvm) - doCheck = false; - - # Clippy uses the rustc_driver and std private libraries, and Rust's build process forces them to have - # an install name of `@rpath/...` [0] [1] instead of the standard on macOS, which is an absolute path - # to itself. - # - # [0]: https://github.com/rust-lang/rust/blob/f77f4d55bdf9d8955d3292f709bd9830c2fdeca5/src/bootstrap/builder.rs#L1543 - # [1]: https://github.com/rust-lang/rust/blob/f77f4d55bdf9d8955d3292f709bd9830c2fdeca5/compiler/rustc_codegen_ssa/src/back/linker.rs#L323-L331 - preFixup = lib.optionalString stdenv.isDarwin '' - install_name_tool -add_rpath "${rustc.unwrapped}/lib" "$out/bin/clippy-driver" - install_name_tool -add_rpath "${rustc.unwrapped}/lib" "$out/bin/cargo-clippy" - ''; - - meta = with lib; { - homepage = "https://rust-lang.github.io/rust-clippy/"; - description = "Bunch of lints to catch common mistakes and improve your Rust code"; - mainProgram = "cargo-clippy"; - maintainers = with maintainers; [ basvandijk ] ++ teams.rust.members; - license = with licenses; [ mit asl20 ]; - platforms = platforms.unix; - }; -} diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix deleted file mode 100644 index 31501e668c89..000000000000 --- a/pkgs/development/compilers/rust/default.nix +++ /dev/null @@ -1,106 +0,0 @@ -{ rustcVersion -, rustcSha256 -, enableRustcDev ? true -, bootstrapVersion -, bootstrapHashes -, selectRustPackage -, rustcPatches ? [] -, llvmShared -, llvmSharedForBuild -, llvmSharedForHost -, llvmSharedForTarget -, llvmPackages # Exposed through rustc for LTO in Firefox -}: -{ stdenv, lib -, newScope, callPackage -, CoreFoundation, Security, SystemConfiguration -, pkgsBuildBuild -, pkgsBuildHost -, pkgsBuildTarget -, pkgsTargetTarget -, makeRustPlatform -, wrapRustcWith -}: - -let - # Use `import` to make sure no packages sneak in here. - lib' = import ../../../build-support/rust/lib { - inherit lib stdenv pkgsBuildHost pkgsBuildTarget pkgsTargetTarget; - }; - # Allow faster cross compiler generation by reusing Build artifacts - fastCross = (stdenv.buildPlatform == stdenv.hostPlatform) && (stdenv.hostPlatform != stdenv.targetPlatform); -in -{ - lib = lib'; - - # Backwards compat before `lib` was factored out. - inherit (lib') toTargetArch toTargetOs toRustTarget toRustTargetSpec IsNoStdTarget toRustTargetForUseInEnvVars envVars; - - # This just contains tools for now. But it would conceivably contain - # libraries too, say if we picked some default/recommended versions to build - # by Hydra. - # - # In the end game, rustc, the rust standard library (`core`, `std`, etc.), - # and cargo would themselves be built with `buildRustCreate` like - # everything else. Tools and `build.rs` and procedural macro dependencies - # would be taken from `buildRustPackages` (and `bootstrapRustPackages` for - # anything provided prebuilt or their build-time dependencies to break - # cycles / purify builds). In this way, nixpkgs would be in control of all - # bootstrapping. - packages = { - prebuilt = callPackage ./bootstrap.nix { - version = bootstrapVersion; - hashes = bootstrapHashes; - }; - stable = lib.makeScope newScope (self: let - # Like `buildRustPackages`, but may also contain prebuilt binaries to - # break cycle. Just like `bootstrapTools` for nixpkgs as a whole, - # nothing in the final package set should refer to this. - bootstrapRustPackages = if fastCross - then pkgsBuildBuild.rustPackages - else - self.buildRustPackages.overrideScope (_: _: - lib.optionalAttrs (stdenv.buildPlatform == stdenv.hostPlatform) - (selectRustPackage pkgsBuildHost).packages.prebuilt); - bootRustPlatform = makeRustPlatform bootstrapRustPackages; - in { - # Packages suitable for build-time, e.g. `build.rs`-type stuff. - buildRustPackages = (selectRustPackage pkgsBuildHost).packages.stable // { __attrsFailEvaluation = true; }; - # Analogous to stdenv - rustPlatform = makeRustPlatform self.buildRustPackages; - rustc-unwrapped = self.callPackage ./rustc.nix ({ - version = rustcVersion; - sha256 = rustcSha256; - inherit enableRustcDev; - inherit llvmShared llvmSharedForBuild llvmSharedForHost llvmSharedForTarget llvmPackages fastCross; - - patches = rustcPatches; - - # Use boot package set to break cycle - inherit (bootstrapRustPackages) cargo rustc rustfmt; - }); - rustc = wrapRustcWith { - inherit (self) rustc-unwrapped; - sysroot = if fastCross then self.rustc-unwrapped else null; - }; - rustfmt = self.callPackage ./rustfmt.nix { - inherit Security; - inherit (self.buildRustPackages) rustc; - }; - cargo = if (!fastCross) then self.callPackage ./cargo.nix { - # Use boot package set to break cycle - rustPlatform = bootRustPlatform; - inherit CoreFoundation Security; - } else self.callPackage ./cargo_cross.nix {}; - cargo-auditable = self.callPackage ./cargo-auditable.nix { }; - cargo-auditable-cargo-wrapper = self.callPackage ./cargo-auditable-cargo-wrapper.nix { }; - clippy = self.callPackage ./clippy.nix { - # We want to use self, not buildRustPackages, so that - # buildPackages.clippy uses the cross compiler and supports - # linting for the target platform. - rustPlatform = makeRustPlatform self; - inherit Security; - }; - }); - }; -} diff --git a/pkgs/development/compilers/rust/make-rust-platform.nix b/pkgs/development/compilers/rust/make-rust-platform.nix deleted file mode 100644 index 6ed724aae821..000000000000 --- a/pkgs/development/compilers/rust/make-rust-platform.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ lib, buildPackages, callPackage, callPackages, cargo-auditable, stdenv, runCommand }@prev: - -{ rustc -, cargo -, cargo-auditable ? prev.cargo-auditable -, stdenv ? prev.stdenv -, ... -}: - -rec { - rust = { - rustc = lib.warn "rustPlatform.rust.rustc is deprecated. Use rustc instead." rustc; - cargo = lib.warn "rustPlatform.rust.cargo is deprecated. Use cargo instead." cargo; - }; - - fetchCargoTarball = buildPackages.callPackage ../../../build-support/rust/fetch-cargo-tarball { - git = buildPackages.gitMinimal; - inherit cargo; - }; - - buildRustPackage = callPackage ../../../build-support/rust/build-rust-package { - inherit stdenv cargoBuildHook cargoCheckHook cargoInstallHook cargoNextestHook cargoSetupHook - fetchCargoTarball importCargoLock rustc cargo cargo-auditable; - }; - - importCargoLock = buildPackages.callPackage ../../../build-support/rust/import-cargo-lock.nix { inherit cargo; }; - - rustcSrc = callPackage ./rust-src.nix { - inherit runCommand rustc; - }; - - rustLibSrc = callPackage ./rust-lib-src.nix { - inherit runCommand rustc; - }; - - # Hooks - inherit (callPackages ../../../build-support/rust/hooks { - inherit stdenv cargo rustc; - }) cargoBuildHook cargoCheckHook cargoInstallHook cargoNextestHook cargoSetupHook maturinBuildHook bindgenHook; -} diff --git a/pkgs/development/compilers/rust/print-hashes.sh b/pkgs/development/compilers/rust/print-hashes.sh deleted file mode 100755 index ebf8d900bb3b..000000000000 --- a/pkgs/development/compilers/rust/print-hashes.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# All rust-related downloads can be found at -# https://static.rust-lang.org/dist/index.html. To find the date on -# which a particular thing was last updated, look for the *-date.txt -# file, e.g. -# https://static.rust-lang.org/dist/channel-rust-beta-date.txt - -PLATFORMS=( - i686-unknown-linux-gnu - x86_64-unknown-linux-gnu - x86_64-unknown-linux-musl - arm-unknown-linux-gnueabihf - armv7-unknown-linux-gnueabihf - aarch64-unknown-linux-gnu - aarch64-unknown-linux-musl - x86_64-apple-darwin - aarch64-apple-darwin - powerpc64le-unknown-linux-gnu - riscv64gc-unknown-linux-gnu -) -BASEURL=https://static.rust-lang.org/dist -VERSION=${1:-} -DATE=${2:-} - -if [[ -z $VERSION ]] -then - echo "No version supplied" - exit -1 -fi - -if [[ -n $DATE ]] -then - BASEURL=$BASEURL/$DATE -fi - -for PLATFORM in "${PLATFORMS[@]}" -do - URL="$BASEURL/rust-$VERSION-$PLATFORM.tar.gz.sha256" - SHA256=$(curl -sSfL $URL | cut -d ' ' -f 1) - echo "$PLATFORM = \"$SHA256\";" -done diff --git a/pkgs/development/compilers/rust/rust-lib-src.nix b/pkgs/development/compilers/rust/rust-lib-src.nix deleted file mode 100644 index aa914338639d..000000000000 --- a/pkgs/development/compilers/rust/rust-lib-src.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ runCommand, rustc }: - -runCommand "rust-lib-src" { } '' - tar --strip-components=1 -xzf ${rustc.src} - mv library $out -'' diff --git a/pkgs/development/compilers/rust/rust-src.nix b/pkgs/development/compilers/rust/rust-src.nix deleted file mode 100644 index 69bdb37ac2fd..000000000000 --- a/pkgs/development/compilers/rust/rust-src.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ lib, runCommand, rustc, minimalContent ? true }: - -runCommand "rust-src" { } '' - tar -xzf ${rustc.src} - mv rustc-${rustc.version}-src $out - rm -rf $out/{${lib.concatStringsSep "," ([ - "ci" - "doc" - "etc" - "grammar" - "llvm-project" - "llvm-emscripten" - "rtstartup" - "rustllvm" - "test" - "vendor" - ] ++ lib.optionals minimalContent [ - "tools" - "stdarch" - ])}} -'' diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix deleted file mode 100644 index e00ba329ccdc..000000000000 --- a/pkgs/development/compilers/rust/rustc.nix +++ /dev/null @@ -1,300 +0,0 @@ -{ lib, stdenv, removeReferencesTo, pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget, targetPackages -, llvmShared, llvmSharedForBuild, llvmSharedForHost, llvmSharedForTarget, llvmPackages -, fetchurl, file, python3 -, darwin, cargo, cmake, rustc, rustfmt -, pkg-config, openssl, xz -, libiconv -, which, libffi -, withBundledLLVM ? false -, enableRustcDev ? true -, version -, sha256 -, patches ? [] -, fd -, ripgrep -, wezterm -, firefox -, thunderbird -# This only builds std for target and reuses the rustc from build. -, fastCross -, lndir -, makeWrapper -}: - -let - inherit (lib) optionals optional optionalString concatStringsSep; - inherit (darwin.apple_sdk.frameworks) Security; -in stdenv.mkDerivation (finalAttrs: { - pname = "${targetPackages.stdenv.cc.targetPrefix}rustc"; - inherit version; - - src = fetchurl { - url = "https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"; - inherit sha256; - # See https://nixos.org/manual/nixpkgs/stable/#using-git-bisect-on-the-rust-compiler - passthru.isReleaseTarball = true; - }; - - __darwinAllowLocalNetworking = true; - - # rustc complains about modified source files otherwise - dontUpdateAutotoolsGnuConfigScripts = true; - - # Running the default `strip -S` command on Darwin corrupts the - # .rlib files in "lib/". - # - # See https://github.com/NixOS/nixpkgs/pull/34227 - # - # Running `strip -S` when cross compiling can harm the cross rlibs. - # See: https://github.com/NixOS/nixpkgs/pull/56540#issuecomment-471624656 - stripDebugList = [ "bin" ]; - - # The Rust pkg-config crate does not support prefixed pkg-config executables[1], - # but it does support checking these idiosyncratic PKG_CONFIG_${TRIPLE} - # environment variables. - # [1]: https://github.com/rust-lang/pkg-config-rs/issues/53 - "PKG_CONFIG_${builtins.replaceStrings ["-"] ["_"] stdenv.buildPlatform.rust.rustcTarget}" = - "${pkgsBuildHost.stdenv.cc.targetPrefix}pkg-config"; - - NIX_LDFLAGS = toString ( - # when linking stage1 libstd: cc: undefined reference to `__cxa_begin_catch' - optional (stdenv.isLinux && !withBundledLLVM) "--push-state --as-needed -lstdc++ --pop-state" - ++ optional (stdenv.isDarwin && !withBundledLLVM) "-lc++ -lc++abi" - ++ optional stdenv.isDarwin "-rpath ${llvmSharedForHost}/lib"); - - # Increase codegen units to introduce parallelism within the compiler. - RUSTFLAGS = "-Ccodegen-units=10"; - - RUSTDOCFLAGS = "-A rustdoc::broken-intra-doc-links"; - - # We need rust to build rust. If we don't provide it, configure will try to download it. - # Reference: https://github.com/rust-lang/rust/blob/master/src/bootstrap/configure.py - configureFlags = let - prefixForStdenv = stdenv: "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}"; - ccPrefixForStdenv = stdenv: "${prefixForStdenv stdenv}${if (stdenv.cc.isClang or false) then "clang" else "cc"}"; - cxxPrefixForStdenv = stdenv: "${prefixForStdenv stdenv}${if (stdenv.cc.isClang or false) then "clang++" else "c++"}"; - setBuild = "--set=target.${stdenv.buildPlatform.rust.rustcTarget}"; - setHost = "--set=target.${stdenv.hostPlatform.rust.rustcTarget}"; - setTarget = "--set=target.${stdenv.targetPlatform.rust.rustcTarget}"; - ccForBuild = ccPrefixForStdenv pkgsBuildBuild.targetPackages.stdenv; - cxxForBuild = cxxPrefixForStdenv pkgsBuildBuild.targetPackages.stdenv; - ccForHost = ccPrefixForStdenv pkgsBuildHost.targetPackages.stdenv; - cxxForHost = cxxPrefixForStdenv pkgsBuildHost.targetPackages.stdenv; - ccForTarget = ccPrefixForStdenv pkgsBuildTarget.targetPackages.stdenv; - cxxForTarget = cxxPrefixForStdenv pkgsBuildTarget.targetPackages.stdenv; - in [ - "--sysconfdir=${placeholder "out"}/etc" - "--release-channel=stable" - "--set=build.rustc=${rustc}/bin/rustc" - "--set=build.cargo=${cargo}/bin/cargo" - ] ++ lib.optionals (!(finalAttrs.src.passthru.isReleaseTarball or false)) [ - # release tarballs vendor the rustfmt source; when - # git-bisect'ing from upstream's git repo we must prevent - # attempts to download the missing source tarball - "--set=build.rustfmt=${rustfmt}/bin/rustfmt" - ] ++ [ - "--tools=rustc,rustdoc,rust-analyzer-proc-macro-srv" - "--enable-rpath" - "--enable-vendor" - "--build=${stdenv.buildPlatform.rust.rustcTargetSpec}" - "--host=${stdenv.hostPlatform.rust.rustcTargetSpec}" - # std is built for all platforms in --target. - "--target=${concatStringsSep "," ([ - stdenv.targetPlatform.rust.rustcTargetSpec - - # Other targets that don't need any extra dependencies to build. - # Temporarily broken if some global compiler flags are set: - # https://github.com/NixOS/nixpkgs/pull/317273 - ] ++ optionals (!fastCross && !lib.any (a: lib.hasAttr a stdenv.hostPlatform.gcc) [ "cpu" "float-abi" "fpu" ] && stdenv.hostPlatform.gcc.thumb or true) [ - "wasm32-unknown-unknown" - - # (build!=target): When cross-building a compiler we need to add - # the build platform as well so rustc can compile build.rs - # scripts. - ] ++ optionals (stdenv.buildPlatform != stdenv.targetPlatform && !fastCross) [ - stdenv.buildPlatform.rust.rustcTargetSpec - - # (host!=target): When building a cross-targeting compiler we - # need to add the host platform as well so rustc can compile - # build.rs scripts. - ] ++ optionals (stdenv.hostPlatform != stdenv.targetPlatform && !fastCross) [ - stdenv.hostPlatform.rust.rustcTargetSpec - ])}" - - "${setBuild}.cc=${ccForBuild}" - "${setHost}.cc=${ccForHost}" - "${setTarget}.cc=${ccForTarget}" - - "${setBuild}.linker=${ccForBuild}" - "${setHost}.linker=${ccForHost}" - "${setTarget}.linker=${ccForTarget}" - - "${setBuild}.cxx=${cxxForBuild}" - "${setHost}.cxx=${cxxForHost}" - "${setTarget}.cxx=${cxxForTarget}" - - "${setBuild}.crt-static=${lib.boolToString stdenv.buildPlatform.isStatic}" - "${setHost}.crt-static=${lib.boolToString stdenv.hostPlatform.isStatic}" - "${setTarget}.crt-static=${lib.boolToString stdenv.targetPlatform.isStatic}" - ] ++ optionals (!withBundledLLVM) [ - "--enable-llvm-link-shared" - "${setBuild}.llvm-config=${llvmSharedForBuild.dev}/bin/llvm-config" - "${setHost}.llvm-config=${llvmSharedForHost.dev}/bin/llvm-config" - "${setTarget}.llvm-config=${llvmSharedForTarget.dev}/bin/llvm-config" - ] ++ optionals fastCross [ - # Since fastCross only builds std, it doesn't make sense (and - # doesn't work) to build a linker. - "--disable-llvm-bitcode-linker" - ] ++ optionals (stdenv.isLinux && !stdenv.targetPlatform.isRedox) [ - "--enable-profiler" # build libprofiler_builtins - ] ++ optionals stdenv.buildPlatform.isMusl [ - "${setBuild}.musl-root=${pkgsBuildBuild.targetPackages.stdenv.cc.libc}" - ] ++ optionals stdenv.hostPlatform.isMusl [ - "${setHost}.musl-root=${pkgsBuildHost.targetPackages.stdenv.cc.libc}" - ] ++ optionals stdenv.targetPlatform.isMusl [ - "${setTarget}.musl-root=${pkgsBuildTarget.targetPackages.stdenv.cc.libc}" - ] ++ optionals stdenv.targetPlatform.rust.isNoStdTarget [ - "--disable-docs" - ] ++ optionals (stdenv.isDarwin && stdenv.isx86_64) [ - # https://github.com/rust-lang/rust/issues/92173 - "--set rust.jemalloc" - ]; - - # if we already have a rust compiler for build just compile the target std - # library and reuse compiler - buildPhase = if fastCross then " - runHook preBuild - - mkdir -p build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-{std,rustc}/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/ - ln -s ${rustc.unwrapped}/lib/rustlib/${stdenv.hostPlatform.rust.rustcTargetSpec}/libstd-*.so build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-std/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/libstd.so - ln -s ${rustc.unwrapped}/lib/rustlib/${stdenv.hostPlatform.rust.rustcTargetSpec}/librustc_driver-*.so build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-rustc/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/librustc.so - ln -s ${rustc.unwrapped}/bin/rustc build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-rustc/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/rustc-main - touch build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-std/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/.libstd.stamp - touch build/${stdenv.hostPlatform.rust.rustcTargetSpec}/stage0-rustc/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/.librustc.stamp - python ./x.py --keep-stage=0 --stage=1 build library - - runHook postBuild - " else null; - - installPhase = if fastCross then '' - runHook preInstall - - python ./x.py --keep-stage=0 --stage=1 install library/std - mkdir -v $out/bin $doc $man - ln -s ${rustc.unwrapped}/bin/{rustc,rustdoc} $out/bin - ln -s ${rustc.unwrapped}/lib/rustlib/{manifest-rust-std-,}${stdenv.hostPlatform.rust.rustcTargetSpec} $out/lib/rustlib/ - echo rust-std-${stdenv.hostPlatform.rust.rustcTargetSpec} >> $out/lib/rustlib/components - lndir ${rustc.doc} $doc - lndir ${rustc.man} $man - - runHook postInstall - '' else null; - - # the rust build system complains that nix alters the checksums - dontFixLibtool = true; - - inherit patches; - - postPatch = '' - patchShebangs src/etc - - # rust-lld is the name rustup uses for its bundled lld, so that it - # doesn't conflict with any system lld. This is not an - # appropriate default for Nixpkgs, where there is no rust-lld. - substituteInPlace compiler/rustc_target/src/spec/*/*.rs \ - --replace-quiet '"rust-lld"' '"lld"' - - ${optionalString (!withBundledLLVM) "rm -rf src/llvm"} - - # Useful debugging parameter - # export VERBOSE=1 - '' + lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) '' - # See https://github.com/jemalloc/jemalloc/issues/1997 - # Using a value of 48 should work on both emulated and native x86_64-darwin. - export JEMALLOC_SYS_WITH_LG_VADDR=48 - '' + lib.optionalString (!(finalAttrs.src.passthru.isReleaseTarball or false)) '' - mkdir .cargo - cat > .cargo/config <<\EOF - [source.crates-io] - replace-with = "vendored-sources" - [source.vendored-sources] - directory = "vendor" - EOF - ''; - - # rustc unfortunately needs cmake to compile llvm-rt but doesn't - # use it for the normal build. This disables cmake in Nix. - dontUseCmakeConfigure = true; - - depsBuildBuild = [ pkgsBuildHost.stdenv.cc pkg-config ]; - - nativeBuildInputs = [ - file python3 rustc cmake - which libffi removeReferencesTo pkg-config xz - ] - ++ optionals fastCross [ lndir makeWrapper ]; - - buildInputs = [ openssl ] - ++ optionals stdenv.isDarwin [ libiconv Security ] - ++ optional (!withBundledLLVM) llvmShared; - - outputs = [ "out" "man" "doc" ]; - setOutputFlags = false; - - postInstall = lib.optionalString (enableRustcDev && !fastCross) '' - # install rustc-dev components. Necessary to build rls, clippy... - python x.py dist rustc-dev - tar xf build/dist/rustc-dev*tar.gz - cp -r rustc-dev*/rustc-dev*/lib/* $out/lib/ - rm $out/lib/rustlib/install.log - for m in $out/lib/rustlib/manifest-rust* - do - sort --output=$m < $m - done - - '' + '' - # remove references to llvm-config in lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so - # and thus a transitive dependency on ncurses - find $out/lib -name "*.so" -type f -exec remove-references-to -t ${llvmShared} '{}' '+' - - # remove uninstall script that doesn't really make sense for Nix. - rm $out/lib/rustlib/uninstall.sh - ''; - - configurePlatforms = []; - - enableParallelBuilding = true; - - setupHooks = ./setup-hook.sh; - - requiredSystemFeatures = [ "big-parallel" ]; - - passthru = { - llvm = llvmShared; - inherit llvmPackages; - tests = { - inherit fd ripgrep wezterm; - } // lib.optionalAttrs stdenv.hostPlatform.isLinux { inherit firefox thunderbird; }; - }; - - meta = with lib; { - homepage = "https://www.rust-lang.org/"; - description = "Safe, concurrent, practical language"; - maintainers = with maintainers; [ havvy ] ++ teams.rust.members; - license = [ licenses.mit licenses.asl20 ]; - platforms = [ - # Platforms with host tools from - # https://doc.rust-lang.org/nightly/rustc/platform-support.html - "x86_64-darwin" "i686-darwin" "aarch64-darwin" - "i686-freebsd" "x86_64-freebsd" - "x86_64-solaris" - "aarch64-linux" "armv6l-linux" "armv7l-linux" "i686-linux" - "loongarch64-linux" "powerpc64-linux" "powerpc64le-linux" - "riscv64-linux" "s390x-linux" "x86_64-linux" - "aarch64-netbsd" "armv7l-netbsd" "i686-netbsd" "powerpc-netbsd" - "x86_64-netbsd" - "i686-openbsd" "x86_64-openbsd" - "i686-windows" "x86_64-windows" - ]; - }; -}) diff --git a/pkgs/development/compilers/rust/rustfmt.nix b/pkgs/development/compilers/rust/rustfmt.nix deleted file mode 100644 index ab58a172a6b2..000000000000 --- a/pkgs/development/compilers/rust/rustfmt.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ lib, stdenv, rustPlatform, rustc, Security, asNightly ? false }: - -rustPlatform.buildRustPackage rec { - pname = "rustfmt" + lib.optionalString asNightly "-nightly"; - inherit (rustc) version src; - - # the rust source tarball already has all the dependencies vendored, no need to fetch them again - cargoVendorDir = "vendor"; - buildAndTestSubdir = "src/tools/rustfmt"; - - # changes hash of vendor directory otherwise - dontUpdateAutotoolsGnuConfigScripts = true; - - buildInputs = [ - rustc.llvm - ] ++ lib.optional stdenv.isDarwin Security; - - # rustfmt uses the rustc_driver and std private libraries, and Rust's build process forces them to have - # an install name of `@rpath/...` [0] [1] instead of the standard on macOS, which is an absolute path - # to itself. - # - # [0]: https://github.com/rust-lang/rust/blob/f77f4d55bdf9d8955d3292f709bd9830c2fdeca5/src/bootstrap/builder.rs#L1543 - # [1]: https://github.com/rust-lang/rust/blob/f77f4d55bdf9d8955d3292f709bd9830c2fdeca5/compiler/rustc_codegen_ssa/src/back/linker.rs#L323-L331 - preFixup = lib.optionalString stdenv.isDarwin '' - install_name_tool -add_rpath "${rustc.unwrapped}/lib" "$out/bin/rustfmt" - install_name_tool -add_rpath "${rustc.unwrapped}/lib" "$out/bin/git-rustfmt" - ''; - - # As of 1.0.0 and rustc 1.30 rustfmt requires a nightly compiler - RUSTC_BOOTSTRAP = 1; - - # As of rustc 1.45.0, these env vars are required to build rustfmt (due to - # https://github.com/rust-lang/rust/pull/72001) - CFG_RELEASE = rustc.version; - CFG_RELEASE_CHANNEL = if asNightly then "nightly" else "stable"; - - meta = with lib; { - description = "Tool for formatting Rust code according to style guidelines"; - homepage = "https://github.com/rust-lang-nursery/rustfmt"; - license = with licenses; [ mit asl20 ]; - mainProgram = "rustfmt"; - maintainers = with maintainers; [ globin basvandijk ]; - }; -} diff --git a/pkgs/development/compilers/rust/setup-hook.sh b/pkgs/development/compilers/rust/setup-hook.sh deleted file mode 100644 index 5d4eb642fec0..000000000000 --- a/pkgs/development/compilers/rust/setup-hook.sh +++ /dev/null @@ -1,4 +0,0 @@ -# Fix 'failed to open: /homeless-shelter/.cargo/.package-cache' in rust 1.36. -if [[ -z ${IN_NIX_SHELL-} && -z ${CARGO_HOME-} ]]; then - export CARGO_HOME=$TMPDIR -fi |