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 5 pull requests #113554

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
}
};
let llval = unsafe {
llvm::LLVMRustConstInBoundsGEP2(
llvm::LLVMConstInBoundsGEP2(
self.type_i8(),
self.const_bitcast(base_addr, self.type_i8p_ext(base_addr_space)),
&self.const_usize(offset.bytes()),
Expand Down Expand Up @@ -320,7 +320,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {

fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
unsafe {
llvm::LLVMRustConstInBoundsGEP2(
llvm::LLVMConstInBoundsGEP2(
self.type_i8(),
self.const_bitcast(base_addr, self.type_i8p()),
&self.const_usize(offset.bytes()),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ extern "C" {
pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;

// Constant expressions
pub fn LLVMRustConstInBoundsGEP2<'a>(
pub fn LLVMConstInBoundsGEP2<'a>(
ty: &'a Type,
ConstantVal: &'a Value,
ConstantIndices: *const &'a Value,
Expand Down
27 changes: 22 additions & 5 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1453,13 +1453,13 @@ mod signal_handler {
/// When an error signal (such as SIGABRT or SIGSEGV) is delivered to the
/// process, print a stack trace and then exit.
pub(super) fn install() {
use std::alloc::{alloc, Layout};

unsafe {
const ALT_STACK_SIZE: usize = libc::MINSIGSTKSZ + 64 * 1024;
let alt_stack_size: usize = min_sigstack_size() + 64 * 1024;
let mut alt_stack: libc::stack_t = std::mem::zeroed();
alt_stack.ss_sp =
std::alloc::alloc(std::alloc::Layout::from_size_align(ALT_STACK_SIZE, 1).unwrap())
as *mut libc::c_void;
alt_stack.ss_size = ALT_STACK_SIZE;
alt_stack.ss_sp = alloc(Layout::from_size_align(alt_stack_size, 1).unwrap()).cast();
alt_stack.ss_size = alt_stack_size;
libc::sigaltstack(&alt_stack, std::ptr::null_mut());

let mut sa: libc::sigaction = std::mem::zeroed();
Expand All @@ -1469,6 +1469,23 @@ mod signal_handler {
libc::sigaction(libc::SIGSEGV, &sa, std::ptr::null_mut());
}
}

/// Modern kernels on modern hardware can have dynamic signal stack sizes.
#[cfg(any(target_os = "linux", target_os = "android"))]
fn min_sigstack_size() -> usize {
const AT_MINSIGSTKSZ: core::ffi::c_ulong = 51;
let dynamic_sigstksz = unsafe { libc::getauxval(AT_MINSIGSTKSZ) };
// If getauxval couldn't find the entry, it returns 0,
// so take the higher of the "constant" and auxval.
// This transparently supports older kernels which don't provide AT_MINSIGSTKSZ
libc::MINSIGSTKSZ.max(dynamic_sigstksz as _)
}

/// Not all OS support hardware where this is needed.
#[cfg(not(any(target_os = "linux", target_os = "android")))]
fn min_sigstack_size() -> usize {
libc::MINSIGSTKSZ
}
}

#[cfg(not(all(unix, any(target_env = "gnu", target_os = "macos"))))]
Expand Down
11 changes: 0 additions & 11 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1616,17 +1616,6 @@ extern "C" void LLVMRustSetLinkage(LLVMValueRef V,
LLVMSetLinkage(V, fromRust(RustLinkage));
}

// FIXME: replace with LLVMConstInBoundsGEP2 when bumped minimal version to llvm-14
extern "C" LLVMValueRef LLVMRustConstInBoundsGEP2(LLVMTypeRef Ty,
LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices,
unsigned NumIndices) {
ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
NumIndices);
Constant *Val = unwrap<Constant>(ConstantVal);
return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
}

extern "C" bool LLVMRustConstIntGetZExtValue(LLVMValueRef CV, uint64_t *value) {
auto C = unwrap<llvm::ConstantInt>(CV);
if (C->getBitWidth() > 64)
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _download(path, url, probably_big, verbose, exception):
print("downloading {}".format(url), file=sys.stderr)

try:
if probably_big or verbose:
if (probably_big or verbose) and "GITHUB_ACTIONS" not in os.environ:
option = "-#"
else:
option = "-s"
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl Step for Std {
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
add_to_sysroot(&builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
}
drop(_guard);

// don't run on std twice with x.py clippy
// don't check test dependencies if we haven't built libtest
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ def quit_if_file_exists(file):
# If 'config.toml' already exists, exit the script at this point
quit_if_file_exists('config.toml')

if "GITHUB_ACTIONS" in os.environ:
print("::group::Configure the build")
p("processing command line")
# Parse all known arguments into a configuration structure that reflects the
# TOML we're going to write out
Expand All @@ -572,3 +574,5 @@ def quit_if_file_exists(file):

p("")
p("run `python {}/x.py --help`".format(rust_dir))
if "GITHUB_ACTIONS" in os.environ:
print("::endgroup::")
4 changes: 3 additions & 1 deletion src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,9 @@ impl Step for Src {

/// Creates the `rust-src` installer component
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
builder.update_submodule(&Path::new("src/llvm-project"));
if !builder.config.dry_run() {
builder.update_submodule(&Path::new("src/llvm-project"));
}

let tarball = Tarball::new_targetless(builder, "rust-src");

Expand Down
17 changes: 13 additions & 4 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl Step for TheBook {
let shared_assets = builder.ensure(SharedAssets { target });

// build the redirect pages
builder.msg_doc(compiler, "book redirect pages", target);
let _guard = builder.msg_doc(compiler, "book redirect pages", target);
for file in t!(fs::read_dir(builder.src.join(&relative_path).join("redirects"))) {
let file = t!(file);
let path = file.path();
Expand Down Expand Up @@ -306,7 +306,7 @@ impl Step for Standalone {
fn run(self, builder: &Builder<'_>) {
let target = self.target;
let compiler = self.compiler;
builder.msg_doc(compiler, "standalone", target);
let _guard = builder.msg_doc(compiler, "standalone", target);
let out = builder.doc_out(target);
t!(fs::create_dir_all(&out));

Expand Down Expand Up @@ -812,8 +812,6 @@ macro_rules! tool_doc {
SourceType::Submodule
};

builder.msg_doc(compiler, stringify!($tool).to_lowercase(), target);

// Symlink compiler docs to the output directory of rustdoc documentation.
let out_dirs = [
builder.stage_out(compiler, Mode::ToolRustc).join(target.triple).join("doc"),
Expand Down Expand Up @@ -852,6 +850,8 @@ macro_rules! tool_doc {
cargo.rustdocflag("--show-type-layout");
cargo.rustdocflag("--generate-link-to-definition");
cargo.rustdocflag("-Zunstable-options");

let _guard = builder.msg_doc(compiler, stringify!($tool).to_lowercase(), target);
builder.run(&mut cargo.into());
}
}
Expand Down Expand Up @@ -1073,7 +1073,16 @@ impl Step for RustcBook {
// config.toml), then this needs to explicitly update the dylib search
// path.
builder.add_rustc_lib_path(self.compiler, &mut cmd);
let doc_generator_guard = builder.msg(
Kind::Run,
self.compiler.stage,
"lint-docs",
self.compiler.host,
self.target,
);
builder.run(&mut cmd);
drop(doc_generator_guard);

// Run rustbook/mdbook to generate the HTML pages.
builder.ensure(RustbookSrc {
target: self.target,
Expand Down
9 changes: 7 additions & 2 deletions src/bootstrap/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
process::{Command, Stdio},
};

use build_helper::util::try_run;
use build_helper::{ci::CiEnv, util::try_run};
use once_cell::sync::OnceCell;
use xz2::bufread::XzDecoder;

Expand Down Expand Up @@ -213,7 +213,6 @@ impl Config {
// Try curl. If that fails and we are on windows, fallback to PowerShell.
let mut curl = Command::new("curl");
curl.args(&[
"-#",
"-y",
"30",
"-Y",
Expand All @@ -224,6 +223,12 @@ impl Config {
"3",
"-SRf",
]);
// Don't print progress in CI; the \r wrapping looks bad and downloads don't take long enough for progress to be useful.
if CiEnv::is_ci() {
curl.arg("-s");
} else {
curl.arg("--progress-bar");
}
curl.arg(url);
let f = File::create(tempfile).unwrap();
curl.stdout(Stdio::from(f));
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,7 @@ impl Build {
}
}

#[must_use = "Groups should not be dropped until the Step finishes running"]
fn msg_check(
&self,
what: impl Display,
Expand All @@ -1012,6 +1013,7 @@ impl Build {
self.msg(Kind::Check, self.config.stage, what, self.config.build, target)
}

#[must_use = "Groups should not be dropped until the Step finishes running"]
fn msg_doc(
&self,
compiler: Compiler,
Expand All @@ -1021,6 +1023,7 @@ impl Build {
self.msg(Kind::Doc, compiler.stage, what, compiler.host, target.into())
}

#[must_use = "Groups should not be dropped until the Step finishes running"]
fn msg_build(
&self,
compiler: Compiler,
Expand All @@ -1033,6 +1036,7 @@ impl Build {
/// Return a `Group` guard for a [`Step`] that is built for each `--stage`.
///
/// [`Step`]: crate::builder::Step
#[must_use = "Groups should not be dropped until the Step finishes running"]
fn msg(
&self,
action: impl Into<Kind>,
Expand All @@ -1059,6 +1063,7 @@ impl Build {
/// Return a `Group` guard for a [`Step`] that is only built once and isn't affected by `--stage`.
///
/// [`Step`]: crate::builder::Step
#[must_use = "Groups should not be dropped until the Step finishes running"]
fn msg_unstaged(
&self,
action: impl Into<Kind>,
Expand All @@ -1070,6 +1075,7 @@ impl Build {
self.group(&msg)
}

#[must_use = "Groups should not be dropped until the Step finishes running"]
fn msg_sysroot_tool(
&self,
action: impl Into<Kind>,
Expand Down
Loading
Loading