Skip to content

Commit

Permalink
Auto merge of rust-lang#131963 - matthiaskrgr:rollup-4oapxk5, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 3 pull requests

Successful merges:

 - rust-lang#131926 (Align boolean option descriptions in `configure.py`)
 - rust-lang#131961 (compiletest: tidy up how `tidy` and `tidy` (html version) are disambiguated)
 - rust-lang#131962 (Make `llvm::set_section` take a `&CStr`)

Failed merges:

 - rust-lang#131181 (Compiletest: Custom differ)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Oct 20, 2024
2 parents bfab34a + 29f9964 commit d954b06
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ffi::CStr;

use itertools::Itertools as _;
use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods, ConstCodegenMethods};
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
Expand Down Expand Up @@ -305,7 +307,7 @@ fn generate_coverage_map<'ll>(
/// specific, well-known section and name.
fn save_function_record(
cx: &CodegenCx<'_, '_>,
covfun_section_name: &str,
covfun_section_name: &CStr,
mangled_function_name: &str,
source_hash: u64,
filenames_ref: u64,
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::cell::RefCell;
use std::ffi::CString;
use std::ffi::{CStr, CString};

use libc::c_uint;
use rustc_codegen_ssa::traits::{
Expand Down Expand Up @@ -292,10 +292,10 @@ pub(crate) fn save_cov_data_to_mod<'ll, 'tcx>(
.unwrap();
debug!("covmap var name: {:?}", covmap_var_name);

let covmap_section_name = llvm::build_string(|s| unsafe {
let covmap_section_name = CString::new(llvm::build_byte_buffer(|s| unsafe {
llvm::LLVMRustCoverageWriteMapSectionNameToString(cx.llmod, s);
})
.expect("Rust Coverage section name failed UTF-8 conversion");
}))
.expect("covmap section name should not contain NUL");
debug!("covmap section name: {:?}", covmap_section_name);

let llglobal = llvm::add_global(cx.llmod, cx.val_ty(cov_data_val), &covmap_var_name);
Expand All @@ -310,7 +310,7 @@ pub(crate) fn save_cov_data_to_mod<'ll, 'tcx>(

pub(crate) fn save_func_record_to_mod<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
covfun_section_name: &str,
covfun_section_name: &CStr,
func_name_hash: u64,
func_record_val: &'ll llvm::Value,
is_used: bool,
Expand Down Expand Up @@ -354,9 +354,9 @@ pub(crate) fn save_func_record_to_mod<'ll, 'tcx>(
/// - `__llvm_covfun` on Linux
/// - `__LLVM_COV,__llvm_covfun` on macOS (includes `__LLVM_COV,` segment prefix)
/// - `.lcovfun$M` on Windows (includes `$M` sorting suffix)
pub(crate) fn covfun_section_name(cx: &CodegenCx<'_, '_>) -> String {
llvm::build_string(|s| unsafe {
pub(crate) fn covfun_section_name(cx: &CodegenCx<'_, '_>) -> CString {
CString::new(llvm::build_byte_buffer(|s| unsafe {
llvm::LLVMRustCoverageWriteFuncSectionNameToString(cx.llmod, s);
})
.expect("Rust Coverage function record section name failed UTF-8 conversion")
}))
.expect("covfun section name should not contain NUL")
}
5 changes: 2 additions & 3 deletions compiler/rustc_codegen_llvm/src/llvm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,9 @@ impl MemoryEffects {
}
}

pub fn set_section(llglobal: &Value, section_name: &str) {
let section_name_cstr = CString::new(section_name).expect("unexpected CString error");
pub fn set_section(llglobal: &Value, section_name: &CStr) {
unsafe {
LLVMSetSection(llglobal, section_name_cstr.as_ptr());
LLVMSetSection(llglobal, section_name.as_ptr());
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ def is_value_list(key):
if option.value:
print('\t{:30} {}'.format('--{}=VAL'.format(option.name), option.desc))
else:
print('\t{:30} {}'.format('--enable-{} OR --disable-{}'.format(option.name, option.name), option.desc))
print('\t--enable-{:25} OR --disable-{}'.format(option.name, option.name))
print('\t\t' + option.desc)
print('')
print('This configure script is a thin configuration shim over the true')
print('configuration system, `config.toml`. You can explore the comments')
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ pub struct Config {
/// created in `/<build_base>/rustfix_missing_coverage.txt`
pub rustfix_coverage: bool,

/// whether to run `tidy` when a rustdoc test fails
pub has_tidy: bool,
/// whether to run `tidy` (html-tidy) when a rustdoc test fails
pub has_html_tidy: bool,

/// whether to run `enzyme` autodiff tests
pub has_enzyme: bool,
Expand Down
6 changes: 3 additions & 3 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ pub fn parse_config(args: Vec<String>) -> Config {
let run_ignored = matches.opt_present("ignored");
let with_debug_assertions = matches.opt_present("with-debug-assertions");
let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
let has_tidy = if mode == Mode::Rustdoc {
let has_html_tidy = if mode == Mode::Rustdoc {
Command::new("tidy")
.arg("--version")
.stdout(Stdio::null())
.status()
.map_or(false, |status| status.success())
} else {
// Avoid spawning an external command when we know tidy won't be used.
// Avoid spawning an external command when we know html-tidy won't be used.
false
};
let has_enzyme = matches.opt_present("has-enzyme");
Expand Down Expand Up @@ -336,7 +336,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
.opt_str("compare-mode")
.map(|s| s.parse().expect("invalid --compare-mode provided")),
rustfix_coverage: matches.opt_present("rustfix-coverage"),
has_tidy,
has_html_tidy,
has_enzyme,
channel: matches.opt_str("channel").unwrap(),
git_hash: matches.opt_present("git-hash"),
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {

let config = Arc::new(parse_config(env::args().collect()));

if !config.has_tidy && config.mode == Mode::Rustdoc {
if !config.has_html_tidy && config.mode == Mode::Rustdoc {
eprintln!("warning: `tidy` (html-tidy.org) is not installed; diffs will not be generated");
}

Expand Down
4 changes: 1 addition & 3 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore-tidy-filelength

use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::ffi::OsString;
Expand Down Expand Up @@ -1897,7 +1895,7 @@ impl<'test> TestCx<'test> {
}

fn compare_to_default_rustdoc(&mut self, out_dir: &Path) {
if !self.config.has_tidy {
if !self.config.has_html_tidy {
return;
}
println!("info: generating a diff against nightly rustdoc");
Expand Down

0 comments on commit d954b06

Please sign in to comment.