Skip to content

Commit 3ed6e3c

Browse files
committed
Auto merge of rust-lang#131848 - matthiaskrgr:rollup-l29a75j, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#129620 (Provide a more convinient way of developing rustc on NixOS) - rust-lang#131805 (rustc_llvm: Fix flattened CLI args) - rust-lang#131818 (Enable XRay instrumentation for LoongArch Linux targets) - rust-lang#131825 (SolverDelegate add assoc type for Infcx) - rust-lang#131833 (Add `must_use` to `CommandExt::exec`) - rust-lang#131835 (Do not run test where it cannot run) - rust-lang#131844 (Add mailmap entry for kobzol) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 86bd459 + c9f3a7d commit 3ed6e3c

File tree

17 files changed

+157
-10
lines changed

17 files changed

+157
-10
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ build/
5757
/src/tools/x/target
5858
# Created by default with `src/ci/docker/run.sh`
5959
/obj/
60+
# Created by nix dev shell / .envrc
61+
src/tools/nix-dev-shell/flake.lock
6062

6163
## ICE reports
6264
rustc-ice-*.txt

Diff for: .mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ Jakub Adam Wieczorek <[email protected]>
256256
Jakub Adam Wieczorek <[email protected]> <[email protected]>
257257
Jakub Adam Wieczorek <[email protected]> <[email protected]>
258258
Jakub Adam Wieczorek <[email protected]> <[email protected]>
259+
259260
James [Undefined] <[email protected]>
260261
261262

Diff for: compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,13 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
490490
assert(ArgsCstrBuff[ArgsCstrBuffLen - 1] == '\0');
491491
auto Arg0 = std::string(ArgsCstrBuff);
492492
buffer_offset = Arg0.size() + 1;
493-
auto ArgsCppStr =
494-
std::string(ArgsCstrBuff + buffer_offset, ArgsCstrBuffLen - 1);
493+
auto ArgsCppStr = std::string(ArgsCstrBuff + buffer_offset,
494+
ArgsCstrBuffLen - buffer_offset);
495495
auto i = 0;
496496
while (i != std::string::npos) {
497497
i = ArgsCppStr.find('\0', i + 1);
498498
if (i != std::string::npos)
499-
ArgsCppStr.replace(i, i + 1, " ");
499+
ArgsCppStr.replace(i, 1, " ");
500500
}
501501
Options.MCOptions.Argv0 = Arg0;
502502
Options.MCOptions.CommandlineArgs = ArgsCppStr;

Diff for: compiler/rustc_next_trait_solver/src/delegate.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ use rustc_type_ir::fold::TypeFoldable;
44
use rustc_type_ir::solve::{Certainty, Goal, NoSolution, SolverMode};
55
use rustc_type_ir::{self as ty, InferCtxtLike, Interner};
66

7-
pub trait SolverDelegate:
8-
Deref<Target: InferCtxtLike<Interner = <Self as SolverDelegate>::Interner>> + Sized
9-
{
7+
pub trait SolverDelegate: Deref<Target = <Self as SolverDelegate>::Infcx> + Sized {
8+
type Infcx: InferCtxtLike<Interner = <Self as SolverDelegate>::Interner>;
109
type Interner: Interner;
1110
fn cx(&self) -> Self::Interner {
1211
(**self).cx()

Diff for: compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub(crate) fn target() -> Target {
2323
| SanitizerSet::LEAK
2424
| SanitizerSet::MEMORY
2525
| SanitizerSet::THREAD,
26+
supports_xray: true,
2627
direct_access_external_data: Some(false),
2728
..base::linux_gnu::opts()
2829
},

Diff for: compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_musl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub(crate) fn target() -> Target {
2424
| SanitizerSet::LEAK
2525
| SanitizerSet::MEMORY
2626
| SanitizerSet::THREAD,
27+
supports_xray: true,
2728
direct_access_external_data: Some(false),
2829
..base::linux_musl::opts()
2930
},

Diff for: compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_ohos.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub(crate) fn target() -> Target {
2222
| SanitizerSet::LEAK
2323
| SanitizerSet::MEMORY
2424
| SanitizerSet::THREAD,
25+
supports_xray: true,
2526
direct_access_external_data: Some(false),
2627
..base::linux_ohos::opts()
2728
},

Diff for: compiler/rustc_trait_selection/src/solve/delegate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ impl<'tcx> Deref for SolverDelegate<'tcx> {
3636
}
3737

3838
impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<'tcx> {
39+
type Infcx = InferCtxt<'tcx>;
3940
type Interner = TyCtxt<'tcx>;
4041

4142
fn cx(&self) -> TyCtxt<'tcx> {

Diff for: library/core/tests/lazy.rs

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ fn lazy_type_inference() {
114114
}
115115

116116
#[test]
117+
#[cfg(panic = "unwind")]
117118
#[should_panic = "LazyCell instance has previously been poisoned"]
118119
fn lazy_force_mut_panic() {
119120
let mut lazy = LazyCell::<String>::new(|| panic!());

Diff for: library/std/src/os/unix/process.rs

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ pub trait CommandExt: Sealed {
154154
/// required to gracefully handle errors it is recommended to use the
155155
/// cross-platform `spawn` instead.
156156
#[stable(feature = "process_exec2", since = "1.9.0")]
157+
#[must_use]
157158
fn exec(&mut self) -> io::Error;
158159

159160
/// Set executable argument

Diff for: src/tools/nix-dev-shell/envrc-flake

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# If you want to use this as an .envrc file to create a shell with necessery components
2+
# to develop rustc, use the following command in the root of the rusr checkout:
3+
#
4+
# ln -s ./src/tools/nix-dev-shell/envrc-flake ./.envrc && echo .envrc >> .git/info/exclude
5+
6+
if nix flake show path:./src/tools/nix-dev-shell &> /dev/null; then
7+
use flake path:./src/tools/nix-dev-shell
8+
fi

Diff for: src/tools/nix-dev-shell/envrc-shell

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# If you want to use this as an .envrc file to create a shell with necessery components
2+
# to develop rustc, use the following command in the root of the rusr checkout:
3+
#
4+
# ln -s ./src/tools/nix-dev-shell/envrc-shell ./.envrc && echo .envrc >> .git/info/exclude
5+
6+
use nix ./src/tools/nix-dev-shell/shell.nix
7+

Diff for: src/tools/nix-dev-shell/flake.nix

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
description = "rustc dev shell";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils, ... }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = import nixpkgs { inherit system; };
13+
x = import ./x { inherit pkgs; };
14+
in
15+
{
16+
devShells.default = with pkgs; mkShell {
17+
name = "rustc-dev-shell";
18+
nativeBuildInputs = with pkgs; [
19+
binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
20+
];
21+
buildInputs = with pkgs; [
22+
openssl glibc.out glibc.static x
23+
];
24+
# Avoid creating text files for ICEs.
25+
RUSTC_ICE = "0";
26+
# Provide `libstdc++.so.6` for the self-contained lld.
27+
LD_LIBRARY_PATH = "${with pkgs; lib.makeLibraryPath [
28+
stdenv.cc.cc.lib
29+
]}";
30+
};
31+
}
32+
);
33+
}

Diff for: src/tools/nix-dev-shell/shell.nix

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
let
3+
x = import ./x { inherit pkgs; };
4+
in
5+
pkgs.mkShell {
6+
name = "rustc";
7+
nativeBuildInputs = with pkgs; [
8+
binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
9+
];
10+
buildInputs = with pkgs; [
11+
openssl glibc.out glibc.static x
12+
];
13+
# Avoid creating text files for ICEs.
14+
RUSTC_ICE = "0";
15+
# Provide `libstdc++.so.6` for the self-contained lld.
16+
LD_LIBRARY_PATH = "${with pkgs; lib.makeLibraryPath [
17+
stdenv.cc.cc.lib
18+
]}";
19+
}

Diff for: src/tools/nix-dev-shell/x/default.nix

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
pkgs ? import <nixpkgs> { },
3+
}:
4+
pkgs.stdenv.mkDerivation {
5+
name = "x";
6+
7+
src = ./x.rs;
8+
dontUnpack = true;
9+
10+
nativeBuildInputs = with pkgs; [ rustc ];
11+
12+
buildPhase = ''
13+
PYTHON=${pkgs.lib.getExe pkgs.python3} rustc -Copt-level=3 --crate-name x $src --out-dir $out/bin
14+
'';
15+
16+
meta = with pkgs.lib; {
17+
description = "Helper for rust-lang/rust x.py";
18+
homepage = "https://github.com/rust-lang/rust/blob/master/src/tools/x";
19+
license = licenses.mit;
20+
mainProgram = "x";
21+
};
22+
}

Diff for: src/tools/nix-dev-shell/x/x.rs

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// git clone https://github.com/rust-lang/rust/blob/0ea7ddcc35a2fcaa5da8a7dcfc118c9fb4a63b95/src/tools/x/src/main.rs
2+
// patched to stop doing python probing, stop the probe, please dont, i have a python
3+
//! Run bootstrap from any subdirectory of a rust compiler checkout.
4+
//!
5+
//! We prefer `exec`, to avoid adding an extra process in the process tree.
6+
//! However, since `exec` isn't available on Windows, we indirect through
7+
//! `exec_or_status`, which will call `exec` on unix and `status` on Windows.
8+
//!
9+
//! We use `powershell.exe x.ps1` on Windows, and `sh -c x` on Unix, those are
10+
//! the ones that call `x.py`. We use `sh -c` on Unix, because it is a standard.
11+
//! We also don't use `pwsh` on Windows, because it is not installed by default;
12+
13+
use std::env;
14+
use std::os::unix::process::CommandExt;
15+
use std::process::{self, Command};
16+
17+
fn main() {
18+
match env::args().skip(1).next().as_deref() {
19+
Some("--wrapper-version") => {
20+
println!("0.1.0");
21+
return;
22+
}
23+
_ => {}
24+
}
25+
let current = match env::current_dir() {
26+
Ok(dir) => dir,
27+
Err(err) => {
28+
eprintln!("Failed to get current directory: {err}");
29+
process::exit(1);
30+
}
31+
};
32+
33+
for dir in current.ancestors() {
34+
let candidate = dir.join("x.py");
35+
if candidate.exists() {
36+
let mut cmd = Command::new(env!("PYTHON"));
37+
cmd.arg(dir.join("x.py"));
38+
cmd.args(env::args().skip(1)).current_dir(dir);
39+
40+
let error = cmd.exec();
41+
eprintln!("Failed to invoke `{:?}`: {}", cmd, error);
42+
}
43+
}
44+
45+
eprintln!(
46+
"x.py not found. Please run inside of a checkout of `https://github.com/rust-lang/rust`."
47+
);
48+
49+
process::exit(1);
50+
}

Diff for: tests/ui/command/command-exec.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ fn main() {
2626
}
2727

2828
"exec-test2" => {
29-
Command::new("/path/to/nowhere").exec();
29+
let _ = Command::new("/path/to/nowhere").exec();
3030
println!("passed");
3131
}
3232

3333
"exec-test3" => {
34-
Command::new(&me).arg("bad\0").exec();
34+
let _ = Command::new(&me).arg("bad\0").exec();
3535
println!("passed");
3636
}
3737

3838
"exec-test4" => {
39-
Command::new(&me).current_dir("/path/to/nowhere").exec();
39+
let _ = Command::new(&me).current_dir("/path/to/nowhere").exec();
4040
println!("passed");
4141
}
4242

4343
"exec-test5" => {
4444
env::set_var("VARIABLE", "ABC");
45-
Command::new("definitely-not-a-real-binary").env("VARIABLE", "XYZ").exec();
45+
let _ = Command::new("definitely-not-a-real-binary").env("VARIABLE", "XYZ").exec();
4646
assert_eq!(env::var("VARIABLE").unwrap(), "ABC");
4747
println!("passed");
4848
}

0 commit comments

Comments
 (0)