Skip to content

Commit

Permalink
Auto merge of rust-lang#134864 - Zalathar:rollup-suc8ay9, r=Zalathar
Browse files Browse the repository at this point in the history
Rollup of 3 pull requests

Successful merges:

 - rust-lang#134849 (compiletest: Slightly simplify the handling of debugger directive prefixes)
 - rust-lang#134850 (Document virality of `feature(rustc_private)`)
 - rust-lang#134852 (Added a codegen test for optimization with const arrays)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Dec 29, 2024
2 parents b76036c + 0a52407 commit 0b63477
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
7 changes: 5 additions & 2 deletions src/doc/unstable-book/src/language-features/rustc-private.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The tracking issue for this feature is: [#27812]

------------------------

This feature allows access to unstable internal compiler crates.
This feature allows access to unstable internal compiler crates such as `rustc_driver`.

Additionally it changes the linking behavior of crates which have this feature enabled. It will prevent linking to a dylib if there's a static variant of it already statically linked into another dylib dependency. This is required to successfully link to `rustc_driver`.
The presence of this feature changes the way the linkage format for dylibs is calculated in a way
that is necessary for linking against dylibs that statically link `std` (such as `rustc_driver`).
This makes this feature "viral" in linkage; its use in a given crate makes its use required in
dependent crates which link to it (including integration tests, which are built as separate crates).
25 changes: 8 additions & 17 deletions src/tools/compiletest/src/runtest/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@ pub(super) struct DebuggerCommands {
}

impl DebuggerCommands {
pub fn parse_from(
file: &Path,
config: &Config,
debugger_prefixes: &[&str],
) -> Result<Self, String> {
let directives = debugger_prefixes
.iter()
.map(|prefix| (format!("{prefix}-command"), format!("{prefix}-check")))
.collect::<Vec<_>>();
pub fn parse_from(file: &Path, config: &Config, debugger_prefix: &str) -> Result<Self, String> {
let command_directive = format!("{debugger_prefix}-command");
let check_directive = format!("{debugger_prefix}-check");

let mut breakpoint_lines = vec![];
let mut commands = vec![];
Expand All @@ -48,14 +42,11 @@ impl DebuggerCommands {
continue;
};

for &(ref command_directive, ref check_directive) in &directives {
config
.parse_name_value_directive(&line, command_directive)
.map(|cmd| commands.push(cmd));

config
.parse_name_value_directive(&line, check_directive)
.map(|cmd| check_lines.push((line_no, cmd)));
if let Some(command) = config.parse_name_value_directive(&line, &command_directive) {
commands.push(command);
}
if let Some(pattern) = config.parse_name_value_directive(&line, &check_directive) {
check_lines.push((line_no, pattern));
}
}

Expand Down
12 changes: 3 additions & 9 deletions src/tools/compiletest/src/runtest/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,8 @@ impl TestCx<'_> {
return;
}

let prefixes = {
static PREFIXES: &[&str] = &["cdb", "cdbg"];
// No "native rust support" variation for CDB yet.
PREFIXES
};

// Parse debugger commands etc from test files
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, prefixes)
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "cdb")
.unwrap_or_else(|e| self.fatal(&e));

// https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-commands
Expand Down Expand Up @@ -137,7 +131,7 @@ impl TestCx<'_> {
}

fn run_debuginfo_gdb_test_no_opt(&self) {
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["gdb"])
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "gdb")
.unwrap_or_else(|e| self.fatal(&e));
let mut cmds = dbg_cmds.commands.join("\n");

Expand Down Expand Up @@ -403,7 +397,7 @@ impl TestCx<'_> {
}

// Parse debugger commands etc from test files
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["lldb"])
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "lldb")
.unwrap_or_else(|e| self.fatal(&e));

// Write debugger script:
Expand Down
15 changes: 15 additions & 0 deletions tests/codegen/const-array.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ compile-flags: -O

#![crate_type = "lib"]

const LUT: [u8; 2] = [1, 1];

// CHECK-LABEL: @decode
#[no_mangle]
pub fn decode(i: u8) -> u8 {
// CHECK: start:
// CHECK-NEXT: icmp
// CHECK-NEXT: select
// CHECK-NEXT: ret
if i < 2 { LUT[i as usize] } else { 2 }
}

0 comments on commit 0b63477

Please sign in to comment.