Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #82654

Merged
merged 21 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0238986
Propagate RUSTDOCFLAGS in the environment when documenting
jyn514 Feb 20, 2021
9fafffd
Print out env vars related to Rust on (sufficiently verbose) rustc in…
pnkfelix Feb 22, 2021
fe2b93b
Rename the `tidy` binary to `rust-tidy`
jyn514 Feb 25, 2021
0d8bf72
Created experimental build.print_step_rusage setting
pnkfelix Feb 19, 2021
f2d70c5
Implementation of build.print_step_rusage.
pnkfelix Feb 19, 2021
16e08d2
fix env var name
klensy Feb 26, 2021
05140ec
Propagate `--test-args` for `x.py test src/tools/cargo`
jyn514 Feb 28, 2021
cdfff98
Try to clarify GlobalAlloc::realloc documentation comment.
vakaras Feb 28, 2021
5091209
Fix a typo in the `find_anon_type` doc
JohnTitor Feb 28, 2021
c3f88a0
Add GUI tests
GuillaumeGomez Feb 25, 2021
8aed5b4
Add more proc-macro attribute tests
Aaron1011 Feb 28, 2021
3de9b41
Rollup merge of #82309 - jyn514:rustdocflags, r=Mark-Simulacrum
JohnTitor Mar 1, 2021
9720cd1
Rollup merge of #82403 - pnkfelix:rustbuild-emit-env-vars-on-verbose-…
JohnTitor Mar 1, 2021
6c76dac
Rollup merge of #82507 - jyn514:tidy-windows, r=Mark-Simulacrum
JohnTitor Mar 1, 2021
a95c3f7
Rollup merge of #82531 - GuillaumeGomez:gui-tests-start, r=jyn514
JohnTitor Mar 1, 2021
1020ed3
Rollup merge of #82532 - pnkfelix:rustbuild-print-step-rusage, r=Mark…
JohnTitor Mar 1, 2021
b8150e7
Rollup merge of #82543 - klensy:skip-jobs, r=Mark-Simulacrum
JohnTitor Mar 1, 2021
d65b231
Rollup merge of #82622 - jyn514:cargo-test-args, r=Mark-Simulacrum
JohnTitor Mar 1, 2021
1b9f420
Rollup merge of #82628 - vakaras:realloc-doc, r=Mark-Simulacrum
JohnTitor Mar 1, 2021
cebbcf1
Rollup merge of #82630 - JohnTitor:fix-typo-in-find-anon-type-doc, r=…
JohnTitor Mar 1, 2021
e2d8efb
Rollup merge of #82643 - Aaron1011:test-macro-attrs, r=petrochenkov
JohnTitor Mar 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
run: "echo \"[CI_PR_NUMBER=$num]\""
env:
num: "${{ github.event.number }}"
if: "success() && !env.SKIP_JOBS && github.event_name == 'pull_request'"
if: "success() && !env.SKIP_JOB && github.event_name == 'pull_request'"
- name: add extra environment variables
run: src/ci/scripts/setup-environment.sh
env:
Expand Down Expand Up @@ -425,7 +425,7 @@ jobs:
run: "echo \"[CI_PR_NUMBER=$num]\""
env:
num: "${{ github.event.number }}"
if: "success() && !env.SKIP_JOBS && github.event_name == 'pull_request'"
if: "success() && !env.SKIP_JOB && github.event_name == 'pull_request'"
- name: add extra environment variables
run: src/ci/scripts/setup-environment.sh
env:
Expand Down Expand Up @@ -532,7 +532,7 @@ jobs:
run: "echo \"[CI_PR_NUMBER=$num]\""
env:
num: "${{ github.event.number }}"
if: "success() && !env.SKIP_JOBS && github.event_name == 'pull_request'"
if: "success() && !env.SKIP_JOB && github.event_name == 'pull_request'"
- name: add extra environment variables
run: src/ci/scripts/setup-environment.sh
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rustc_middle::ty::{self, Region, TyCtxt};
/// { x.push(y); }
/// ```
/// The function returns the nested type corresponding to the anonymous region
/// for e.g., `&u8` and Vec<`&u8`.
/// for e.g., `&u8` and `Vec<&u8>`.
pub(crate) fn find_anon_type(
tcx: TyCtxt<'tcx>,
region: Region<'tcx>,
Expand Down
6 changes: 6 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ changelog-seen = 2
# tracking over time)
#print-step-timings = false

# Print out resource usage data for each rustbuild step, as defined by the Unix
# struct rusage. (Note that this setting is completely unstable: the data it
# captures, what platforms it supports, the format of its associated output, and
# this setting's very existence, are all subject to change.)
#print-step-rusage = false

# =============================================================================
# General install configuration options
# =============================================================================
Expand Down
7 changes: 5 additions & 2 deletions library/core/src/alloc/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub unsafe trait GlobalAlloc {
/// this allocator,
///
/// * `layout` must be the same layout that was used
/// to allocate that block of memory,
/// to allocate that block of memory.
#[stable(feature = "global_alloc", since = "1.28.0")]
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout);

Expand Down Expand Up @@ -167,7 +167,10 @@ pub unsafe trait GlobalAlloc {
/// and should be considered unusable (unless of course it was
/// transferred back to the caller again via the return value of
/// this method). The new memory block is allocated with `layout`, but
/// with the `size` updated to `new_size`.
/// with the `size` updated to `new_size`. This new layout should be
/// used when deallocating the new memory block with `dealloc`. The range
/// `0..min(layout.size(), new_size)` of the new memory block is
/// guaranteed to have the same values as the original block.
///
/// If this method returns null, then ownership of the memory
/// block has not been transferred to this allocator, and the
Expand Down
88 changes: 85 additions & 3 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ fn main() {
}

if verbose > 1 {
let rust_env_vars =
env::vars().filter(|(k, _)| k.starts_with("RUST") || k.starts_with("CARGO"));
for (i, (k, v)) in rust_env_vars.enumerate() {
eprintln!("rustc env[{}]: {:?}={:?}", i, k, v);
}
eprintln!("rustc working directory: {}", env::current_dir().unwrap().display());
eprintln!(
"rustc command: {:?}={:?} {:?}",
bootstrap::util::dylib_path_var(),
Expand All @@ -155,16 +161,24 @@ fn main() {
cmd.status().expect(&errmsg)
};

if env::var_os("RUSTC_PRINT_STEP_TIMINGS").is_some() {
if env::var_os("RUSTC_PRINT_STEP_TIMINGS").is_some()
|| env::var_os("RUSTC_PRINT_STEP_RUSAGE").is_some()
{
if let Some(crate_name) = crate_name {
let dur = start.elapsed();
let is_test = args.iter().any(|a| a == "--test");
// If the user requested resource usage data, then
// include that in addition to the timing output.
let rusage_data =
env::var_os("RUSTC_PRINT_STEP_RUSAGE").and_then(|_| format_rusage_data());
eprintln!(
"[RUSTC-TIMING] {} test:{} {}.{:03}",
"[RUSTC-TIMING] {} test:{} {}.{:03}{}{}",
crate_name,
is_test,
dur.as_secs(),
dur.subsec_millis()
dur.subsec_millis(),
if rusage_data.is_some() { " " } else { "" },
rusage_data.unwrap_or(String::new()),
);
}
}
Expand Down Expand Up @@ -192,3 +206,71 @@ fn main() {
}
}
}

#[cfg(not(unix))]
/// getrusage is not available on non-unix platforms. So for now, we do not
/// bother trying to make a shim for it.
fn format_rusage_data() -> Option<String> {
None
}

#[cfg(unix)]
/// Tries to build a string with human readable data for several of the rusage
/// fields. Note that we are focusing mainly on data that we believe to be
/// supplied on Linux (the `rusage` struct has other fields in it but they are
/// currently unsupported by Linux).
fn format_rusage_data() -> Option<String> {
let rusage: libc::rusage = unsafe {
let mut recv = std::mem::zeroed();
// -1 is RUSAGE_CHILDREN, which means to get the rusage for all children
// (and grandchildren, etc) processes that have respectively terminated
// and been waited for.
let retval = libc::getrusage(-1, &mut recv);
if retval != 0 {
return None;
}
recv
};
// Mac OS X reports the maxrss in bytes, not kb.
let divisor = if env::consts::OS == "macos" { 1024 } else { 1 };
let maxrss = rusage.ru_maxrss + (divisor - 1) / divisor;

let mut init_str = format!(
"user: {USER_SEC}.{USER_USEC:03} \
sys: {SYS_SEC}.{SYS_USEC:03} \
max rss (kb): {MAXRSS}",
USER_SEC = rusage.ru_utime.tv_sec,
USER_USEC = rusage.ru_utime.tv_usec,
SYS_SEC = rusage.ru_stime.tv_sec,
SYS_USEC = rusage.ru_stime.tv_usec,
MAXRSS = maxrss
);

// The remaining rusage stats vary in platform support. So we treat
// uniformly zero values in each category as "not worth printing", since it
// either means no events of that type occurred, or that the platform
// does not support it.

let minflt = rusage.ru_minflt;
let majflt = rusage.ru_majflt;
if minflt != 0 || majflt != 0 {
init_str.push_str(&format!(" page reclaims: {} page faults: {}", minflt, majflt));
}

let inblock = rusage.ru_inblock;
let oublock = rusage.ru_oublock;
if inblock != 0 || oublock != 0 {
init_str.push_str(&format!(" fs block inputs: {} fs block outputs: {}", inblock, oublock));
}

let nvcsw = rusage.ru_nvcsw;
let nivcsw = rusage.ru_nivcsw;
if nvcsw != 0 || nivcsw != 0 {
init_str.push_str(&format!(
" voluntary ctxt switches: {} involuntary ctxt switches: {}",
nvcsw, nivcsw
));
}

return Some(init_str);
}
34 changes: 25 additions & 9 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,12 @@ impl<'a> Builder<'a> {
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
// #71458.
let mut rustdocflags = rustflags.clone();
rustdocflags.propagate_cargo_env("RUSTDOCFLAGS");
if stage == 0 {
rustdocflags.env("RUSTDOCFLAGS_BOOTSTRAP");
} else {
rustdocflags.env("RUSTDOCFLAGS_NOT_BOOTSTRAP");
}

if let Ok(s) = env::var("CARGOFLAGS") {
cargo.args(s.split_whitespace());
Expand Down Expand Up @@ -1259,6 +1265,10 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_PRINT_STEP_TIMINGS", "1");
}

if self.config.print_step_rusage {
cargo.env("RUSTC_PRINT_STEP_RUSAGE", "1");
}

if self.config.backtrace_on_ice {
cargo.env("RUSTC_BACKTRACE_ON_ICE", "1");
}
Expand Down Expand Up @@ -1544,21 +1554,27 @@ impl<'a> Builder<'a> {
mod tests;

#[derive(Debug, Clone)]
struct Rustflags(String);
struct Rustflags(String, TargetSelection);

impl Rustflags {
fn new(target: TargetSelection) -> Rustflags {
let mut ret = Rustflags(String::new());
let mut ret = Rustflags(String::new(), target);
ret.propagate_cargo_env("RUSTFLAGS");
ret
}

/// By default, cargo will pick up on various variables in the environment. However, bootstrap
/// reuses those variables to pass additional flags to rustdoc, so by default they get overriden.
/// Explicitly add back any previous value in the environment.
///
/// `prefix` is usually `RUSTFLAGS` or `RUSTDOCFLAGS`.
fn propagate_cargo_env(&mut self, prefix: &str) {
// Inherit `RUSTFLAGS` by default ...
ret.env("RUSTFLAGS");
self.env(prefix);

// ... and also handle target-specific env RUSTFLAGS if they're
// configured.
let target_specific = format!("CARGO_TARGET_{}_RUSTFLAGS", crate::envify(&target.triple));
ret.env(&target_specific);

ret
// ... and also handle target-specific env RUSTFLAGS if they're configured.
let target_specific = format!("CARGO_TARGET_{}_{}", crate::envify(&self.1.triple), prefix);
self.env(&target_specific);
}

fn env(&mut self, env: &str) {
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ pub struct Config {
pub verbose_tests: bool,
pub save_toolstates: Option<PathBuf>,
pub print_step_timings: bool,
pub print_step_rusage: bool,
pub missing_tools: bool,

// Fallback musl-root for all targets
Expand Down Expand Up @@ -380,6 +381,7 @@ struct Build {
configure_args: Option<Vec<String>>,
local_rebuild: Option<bool>,
print_step_timings: Option<bool>,
print_step_rusage: Option<bool>,
check_stage: Option<u32>,
doc_stage: Option<u32>,
build_stage: Option<u32>,
Expand Down Expand Up @@ -679,6 +681,7 @@ impl Config {
set(&mut config.configure_args, build.configure_args);
set(&mut config.local_rebuild, build.local_rebuild);
set(&mut config.print_step_timings, build.print_step_timings);
set(&mut config.print_step_rusage, build.print_step_rusage);

// See https://github.com/rust-lang/compiler-team/issues/326
config.stage = match config.cmd {
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ impl Step for Cargo {
if !builder.fail_fast {
cargo.arg("--no-fail-fast");
}
cargo.arg("--").args(builder.config.cmd.test_args());

// Don't run cross-compile tests, we may not have cross-compiled libstd libs
// available.
Expand Down
8 changes: 7 additions & 1 deletion src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Step for ToolBuild {
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
let compiler = self.compiler;
let target = self.target;
let tool = self.tool;
let mut tool = self.tool;
let path = self.path;
let is_optional_tool = self.is_optional_tool;

Expand Down Expand Up @@ -208,6 +208,12 @@ impl Step for ToolBuild {
None
}
} else {
// HACK(#82501): on Windows, the tools directory gets added to PATH when running tests, and
// compiletest confuses HTML tidy with the in-tree tidy. Name the in-tree tidy something
// different so the problem doesn't come up.
if tool == "tidy" {
tool = "rust-tidy";
}
let cargo_out =
builder.cargo_out(compiler, self.mode, target).join(exe(tool, compiler.host));
let bin = builder.tools_dir(compiler).join(exe(tool, compiler.host));
Expand Down
2 changes: 1 addition & 1 deletion src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ x--expand-yaml-anchors--remove:
run: echo "[CI_PR_NUMBER=$num]"
env:
num: ${{ github.event.number }}
if: success() && !env.SKIP_JOBS && github.event_name == 'pull_request'
if: success() && !env.SKIP_JOB && github.event_name == 'pull_request'

- name: add extra environment variables
run: src/ci/scripts/setup-environment.sh
Expand Down
11 changes: 11 additions & 0 deletions src/test/rustdoc-gui/search-input-mobile.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Test to ensure that you can click on the search input, whatever the width.
// The PR which fixed it is: https://github.com/rust-lang/rust/pull/81592
goto: file://|DOC_PATH|/index.html
size: (463, 700)
// We first check that the search input isn't already focused.
assert-false: ("input.search-input:focus")
click: "input.search-input"
reload:
size: (750, 700)
click: "input.search-input"
assert: ("input.search-input:focus")
26 changes: 26 additions & 0 deletions src/test/rustdoc-gui/shortcuts.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Check that the various shortcuts are working.
goto: file://|DOC_PATH|/index.html
// We first check that the search input isn't already focused.
assert-false: "input.search-input:focus"
press-key: "s"
assert: "input.search-input:focus"
press-key: "Escape"
assert-false: "input.search-input:focus"
// We now check for the help popup.
press-key: "?"
assert: ("#help", {"display": "flex"})
assert-false: "#help.hidden"
press-key: "Escape"
assert: ("#help.hidden", {"display": "none"})
// Check for the themes list.
assert: ("#theme-choices", {"display": "none"})
press-key: "t"
assert: ("#theme-choices", {"display": "block"})
press-key: "t"
// We ensure that 't' hides back the menu.
assert: ("#theme-choices", {"display": "none"})
press-key: "t"
assert: ("#theme-choices", {"display": "block"})
press-key: "Escape"
// We ensure that 'Escape' hides the menu too.
assert: ("#theme-choices", {"display": "none"})
26 changes: 26 additions & 0 deletions src/test/ui/proc-macro/attr-complex-fn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// check-pass
// compile-flags: -Z span-debug --error-format human
// aux-build:test-macros.rs

#![feature(stmt_expr_attributes)]
#![feature(custom_inner_attributes)]
#![feature(rustc_attrs)]

#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;

#[macro_use]
extern crate test_macros;

trait MyTrait<T> {}
struct MyStruct<const N: bool>;

#[print_attr]
fn foo<T: MyTrait<MyStruct<{ true }>>>() {}

impl<T> MyTrait<T> for MyStruct<{true}> {
#![print_attr]
#![rustc_dummy]
}

fn main() {}
Loading