Skip to content

Commit

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

Rollup of 7 pull requests

Successful merges:

 - rust-lang#113386 (style-guide: Expand example of combinable expressions to include arrays)
 - rust-lang#113523 (Reuse LLVMConstInBoundsGEP2)
 - rust-lang#113528 (Dynamically size sigaltstk in rustc)
 - rust-lang#113543 (Remove `rustc_llvm` from llvm-stamp nags)
 - rust-lang#113548 (Update books)
 - rust-lang#113551 (bootstrap: Don't print "Skipping" twice)
 - rust-lang#113556 (Don't use serde-derive in the rls shim)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jul 11, 2023
2 parents 1d4f5af + ad4f303 commit fcaf04e
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 39 deletions.
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3021,7 +3021,6 @@ dependencies = [
name = "rls"
version = "2.0.0"
dependencies = [
"serde",
"serde_json",
]

Expand Down
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
10 changes: 7 additions & 3 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::process::Command;
use std::time::{Duration, Instant};

use crate::cache::{Cache, Interned, INTERNER};
use crate::config::{SplitDebuginfo, TargetSelection};
use crate::config::{DryRun, SplitDebuginfo, TargetSelection};
use crate::doc;
use crate::flags::{Color, Subcommand};
use crate::install;
Expand Down Expand Up @@ -281,11 +281,15 @@ impl StepDescription {

fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
if builder.config.exclude.iter().any(|e| pathset.has(&e, builder.kind)) {
println!("Skipping {:?} because it is excluded", pathset);
if !matches!(builder.config.dry_run, DryRun::SelfCheck) {
println!("Skipping {:?} because it is excluded", pathset);
}
return true;
}

if !builder.config.exclude.is_empty() {
if !builder.config.exclude.is_empty()
&& !matches!(builder.config.dry_run, DryRun::SelfCheck)
{
builder.verbose(&format!(
"{:?} not skipped for {:?} -- not in {:?}",
pathset, self.name, builder.config.exclude
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
Submodule book updated 1 files
+1 −1 src/ch08-02-strings.md
2 changes: 1 addition & 1 deletion src/doc/edition-guide
2 changes: 1 addition & 1 deletion src/doc/embedded-book
2 changes: 1 addition & 1 deletion src/doc/nomicon
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide
Submodule rustc-dev-guide updated 50 files
+1 −1 README.md
+2 −2 src/SUMMARY.md
+1 −1 src/appendix/background.md
+4 −4 src/backend/updating-llvm.md
+2 −2 src/bug-fix-procedure.md
+18 −18 src/building/bootstrapping.md
+7 −7 src/building/build-install-distribution-artifacts.md
+6 −6 src/building/compiler-documenting.md
+114 −39 src/building/how-to-build-and-run.md
+2 −2 src/building/new-target.md
+1 −1 src/building/prerequisites.md
+24 −24 src/building/suggested.md
+2 −2 src/closure.md
+0 −3 src/compiler-src.md
+1 −1 src/constants.md
+72 −74 src/contributing.md
+4 −4 src/conventions.md
+77 −0 src/diagnostics.md
+1 −1 src/diagnostics/error-codes.md
+6 −5 src/diagnostics/translation.md
+6 −35 src/feature-gates.md
+2 −2 src/fuzzing.md
+2 −2 src/getting-started.md
+6 −6 src/git.md
+2 −2 src/identifiers.md
+56 −32 src/implementing_new_features.md
+7 −8 src/llvm-coverage-instrumentation.md
+5 −6 src/mir/optimizations.md
+1 −1 src/notification-groups/cleanup-crew.md
+1 −1 src/overview.md
+0 −2 src/parallel-rustc.md
+5 −5 src/profiling.md
+1 −1 src/profiling/with_perf.md
+2 −2 src/profiling/wpa_profiling.md
+1 −1 src/query.md
+1 −1 src/rustc-driver.md
+3 −1 src/rustdoc-internals.md
+5 −5 src/rustdoc.md
+1 −1 src/sanitizers.md
+3 −3 src/solve/trait-solving.md
+4 −4 src/stability.md
+1 −1 src/stabilization_guide.md
+3 −3 src/tests/adding.md
+3 −3 src/tests/ci.md
+5 −6 src/tests/compiletest.md
+1 −1 src/tests/docker.md
+1 −1 src/tests/headers.md
+30 −31 src/tests/intro.md
+32 −23 src/tests/running.md
+3 −3 src/tests/ui.md
10 changes: 10 additions & 0 deletions src/doc/style-guide/src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,16 @@ foo(|param| {
action();
foo(param)
})

let x = combinable([
an_expr,
another_expr,
]);

let arr = [combinable(
an_expr,
another_expr,
)];
```

Such behaviour should extend recursively, however, tools may choose to limit the
Expand Down
1 change: 0 additions & 1 deletion src/tools/rls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ edition = "2021"
license = "Apache-2.0/MIT"

[dependencies]
serde = { version = "1.0.143", features = ["derive"] }
serde_json = "1.0.83"
9 changes: 5 additions & 4 deletions src/tools/rls/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This is a small stub that replaces RLS to alert the user that RLS is no
//! longer available.

use serde::Deserialize;
use serde_json::Value;
use std::error::Error;
use std::io::BufRead;
use std::io::Write;
Expand All @@ -21,7 +21,6 @@ fn main() {
}
}

#[derive(Deserialize)]
struct Message {
method: Option<String>,
}
Expand Down Expand Up @@ -88,8 +87,10 @@ fn read_message_raw<R: BufRead>(reader: &mut R) -> Result<String, Box<dyn Error>

fn read_message<R: BufRead>(reader: &mut R) -> Result<Message, Box<dyn Error>> {
let m = read_message_raw(reader)?;
match serde_json::from_str(&m) {
Ok(m) => Ok(m),
match serde_json::from_str::<Value>(&m) {
Ok(message) => Ok(Message {
method: message.get("method").and_then(|value| value.as_str().map(String::from)),
}),
Err(e) => Err(format!("failed to parse message {m}\n{e}").into()),
}
}
Expand Down
4 changes: 0 additions & 4 deletions triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,6 @@ message = "This PR changes src/bootstrap/defaults/config.codegen.toml. If approp

[mentions."src/bootstrap/llvm.rs"]
message = "This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp."
[mentions."compiler/rustc_llvm/build.rs"]
message = "This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp."
[mentions."compiler/rustc_llvm/llvm-wrapper"]
message = "This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp."

[mentions."tests/ui/deriving/deriving-all-codegen.stdout"]
message = "Changes to the code generated for builtin derived traits."
Expand Down

0 comments on commit fcaf04e

Please sign in to comment.