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 7 pull requests #66990

Closed
wants to merge 15 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
10 changes: 8 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ checksum = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571"
dependencies = [
"cfg-if",
"libc",
"wasi",
"wasi 0.7.0",
]

[[package]]
Expand Down Expand Up @@ -4301,7 +4301,7 @@ dependencies = [
"rustc_msan",
"rustc_tsan",
"unwind",
"wasi",
"wasi 0.9.0+wasi-snapshot-preview1",
]

[[package]]
Expand Down Expand Up @@ -5172,6 +5172,12 @@ name = "wasi"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"

[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-alloc",
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
let mut parts = version.split('.').take(2)
.filter_map(|s| s.parse::<u32>().ok());
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
if major >= 6 {
if major >= 7 {
return
}
}
panic!("\n\nbad LLVM version: {}, need >=6.0\n\n", version)
panic!("\n\nbad LLVM version: {}, need >=7.0\n\n", version)
}

fn configure_cmake(builder: &Builder<'_>,
Expand Down
2 changes: 1 addition & 1 deletion src/ci/azure-pipelines/auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- template: steps/run.yml
strategy:
matrix:
x86_64-gnu-llvm-6.0:
x86_64-gnu-llvm-7:
RUST_BACKTRACE: 1
dist-x86_64-linux: {}
dist-x86_64-linux-alt:
Expand Down
2 changes: 1 addition & 1 deletion src/ci/azure-pipelines/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- template: steps/run.yml
strategy:
matrix:
x86_64-gnu-llvm-6.0: {}
x86_64-gnu-llvm-7: {}
mingw-check: {}
x86_64-gnu-tools:
CI_ONLY_WHEN_SUBMODULES_CHANGED: 1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:16.04
FROM ubuntu:18.04

RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
Expand All @@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
llvm-6.0-tools \
llvm-7-tools \
libedit-dev \
libssl-dev \
pkg-config \
Expand All @@ -24,7 +24,7 @@ RUN sh /scripts/sccache.sh
# using llvm-link-shared due to libffi issues -- see #34486
ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--llvm-root=/usr/lib/llvm-6.0 \
--llvm-root=/usr/lib/llvm-7 \
--enable-llvm-link-shared
ENV SCRIPT python2.7 ../x.py test src/tools/tidy && python2.7 ../x.py test

Expand Down
7 changes: 7 additions & 0 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ macro_rules! throw_exhaust {
($($tt:tt)*) => { return Err(err_exhaust!($($tt)*).into()) };
}

#[macro_export]
macro_rules! throw_machine_stop {
($($tt:tt)*) => {
return Err($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)).into())
};
}

mod error;
mod value;
mod allocation;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub fn target_machine_factory(sess: &Session, optlvl: config::OptLevel, find_fea
let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes;

let asm_comments = sess.asm_comments();

let relax_elf_relocations = sess.target.target.options.relax_elf_relocations;
Arc::new(move || {
let tm = unsafe {
llvm::LLVMRustCreateTargetMachine(
Expand All @@ -183,6 +183,7 @@ pub fn target_machine_factory(sess: &Session, optlvl: config::OptLevel, find_fea
singlethread,
asm_comments,
emit_stack_size_section,
relax_elf_relocations,
)
};

Expand Down
31 changes: 5 additions & 26 deletions src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,32 +442,11 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
let is_left = name == "rotate_left";
let val = args[0].immediate();
let raw_shift = args[1].immediate();
if llvm_util::get_major_version() >= 7 {
// rotate = funnel shift with first two args the same
let llvm_name = &format!("llvm.fsh{}.i{}",
if is_left { 'l' } else { 'r' }, width);
let llfn = self.get_intrinsic(llvm_name);
self.call(llfn, &[val, val, raw_shift], None)
} else {
// rotate_left: (X << (S % BW)) | (X >> ((BW - S) % BW))
// rotate_right: (X << ((BW - S) % BW)) | (X >> (S % BW))
let width = self.const_uint(
self.type_ix(width),
width,
);
let shift = self.urem(raw_shift, width);
let width_minus_raw_shift = self.sub(width, raw_shift);
let inv_shift = self.urem(width_minus_raw_shift, width);
let shift1 = self.shl(
val,
if is_left { shift } else { inv_shift },
);
let shift2 = self.lshr(
val,
if !is_left { shift } else { inv_shift },
);
self.or(shift1, shift2)
}
// rotate = funnel shift with first two args the same
let llvm_name = &format!("llvm.fsh{}.i{}",
if is_left { 'l' } else { 'r' }, width);
let llfn = self.get_intrinsic(llvm_name);
self.call(llfn, &[val, val, raw_shift], None)
},
"saturating_add" | "saturating_sub" => {
let is_add = name == "saturating_add";
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_codegen_llvm/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,8 @@ extern "C" {
TrapUnreachable: bool,
Singlethread: bool,
AsmComments: bool,
EmitStackSizeSection: bool)
EmitStackSizeSection: bool,
RelaxELFRelocations: bool)
-> Option<&'static mut TargetMachine>;
pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
pub fn LLVMRustAddBuilderLibraryInfo(PMB: &'a PassManagerBuilder,
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ impl<'a> Linker for GccLinker<'a> {

fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType) {
// Symbol visibility in object files typically takes care of this.
if crate_type == CrateType::Executable {
if crate_type == CrateType::Executable &&
self.sess.target.target.options.override_export_symbols.is_none() {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ E0622: include_str!("./error_codes/E0622.md"),
E0623: include_str!("./error_codes/E0623.md"),
E0624: include_str!("./error_codes/E0624.md"),
E0626: include_str!("./error_codes/E0626.md"),
E0631: include_str!("./error_codes/E0631.md"),
E0633: include_str!("./error_codes/E0633.md"),
E0635: include_str!("./error_codes/E0635.md"),
E0636: include_str!("./error_codes/E0636.md"),
Expand Down Expand Up @@ -580,7 +581,6 @@ E0745: include_str!("./error_codes/E0745.md"),
// rustc_const_unstable attribute must be paired with stable/unstable
// attribute
E0630,
E0631, // type mismatch in closure arguments
E0632, // cannot provide explicit generic arguments when `impl Trait` is
// used in argument position
E0634, // type has conflicting packed representaton hints
Expand Down
27 changes: 27 additions & 0 deletions src/librustc_error_codes/error_codes/E0631.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
This error indicates a type mismatch in closure arguments.

Erroneous code example:

```compile_fail,E0631
fn foo<F: Fn(i32)>(f: F) {
}

fn main() {
foo(|x: &str| {});
}
```

The error occurs because `foo` accepts a closure that takes an `i32` argument,
but in `main`, it is passed a closure with a `&str` argument.

This can be resolved by changing the type annotation or removing it entirely
if it can be inferred.

```
fn foo<F: Fn(i32)>(f: F) {
}

fn main() {
foo(|x: i32| {});
}
```
23 changes: 13 additions & 10 deletions src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,23 +1065,26 @@ where
variant_index: VariantIdx,
dest: PlaceTy<'tcx, M::PointerTag>,
) -> InterpResult<'tcx> {
let variant_scalar = Scalar::from_u32(variant_index.as_u32()).into();

// Layout computation excludes uninhabited variants from consideration
// therefore there's no way to represent those variants in the given layout.
if dest.layout.for_variant(self, variant_index).abi.is_uninhabited() {
throw_ub!(Unreachable);
}

match dest.layout.variants {
layout::Variants::Single { index } => {
if index != variant_index {
throw_ub!(InvalidDiscriminant(variant_scalar));
}
assert_eq!(index, variant_index);
}
layout::Variants::Multiple {
discr_kind: layout::DiscriminantKind::Tag,
discr: ref discr_layout,
discr_index,
..
} => {
if !dest.layout.ty.variant_range(*self.tcx).unwrap().contains(&variant_index) {
throw_ub!(InvalidDiscriminant(variant_scalar));
}
// No need to validate that the discriminant here because the
// `TyLayout::for_variant()` call earlier already checks the variant is valid.

let discr_val =
dest.layout.ty.discriminant_for_variant(*self.tcx, variant_index).unwrap().val;

Expand All @@ -1104,9 +1107,9 @@ where
discr_index,
..
} => {
if !variant_index.as_usize() < dest.layout.ty.ty_adt_def().unwrap().variants.len() {
throw_ub!(InvalidDiscriminant(variant_scalar));
}
// No need to validate that the discriminant here because the
// `TyLayout::for_variant()` call earlier already checks the variant is valid.

if variant_index != dataful_variant {
let variants_start = niche_variants.start().as_u32();
let variant_index_relative = variant_index.as_u32()
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ impl<'a> Parser<'a> {

let (variants, _) = self.parse_delim_comma_seq(
token::Brace,
|p| p.parse_enum_item(),
|p| p.parse_enum_variant(),
).map_err(|e| {
self.recover_stmt();
e
Expand All @@ -1337,7 +1337,7 @@ impl<'a> Parser<'a> {
Ok((id, ItemKind::Enum(enum_definition, generics), None))
}

fn parse_enum_item(&mut self) -> PResult<'a, Option<Variant>> {
fn parse_enum_variant(&mut self) -> PResult<'a, Option<Variant>> {
let variant_attrs = self.parse_outer_attributes()?;
let vlo = self.token.span;

Expand Down
6 changes: 6 additions & 0 deletions src/librustc_target/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,9 @@ pub struct TargetOptions {

/// LLVM ABI name, corresponds to the '-mabi' parameter available in multilib C compilers
pub llvm_abiname: String,

/// Whether or not RelaxElfRelocation flag will be passed to the linker
pub relax_elf_relocations: bool,
}

impl Default for TargetOptions {
Expand Down Expand Up @@ -890,6 +893,7 @@ impl Default for TargetOptions {
merge_functions: MergeFunctions::Aliases,
target_mcount: "mcount".to_string(),
llvm_abiname: "".to_string(),
relax_elf_relocations: false,
}
}
}
Expand Down Expand Up @@ -1207,6 +1211,7 @@ impl Target {
key!(merge_functions, MergeFunctions)?;
key!(target_mcount);
key!(llvm_abiname);
key!(relax_elf_relocations, bool);

if let Some(array) = obj.find("abi-blacklist").and_then(Json::as_array) {
for name in array.iter().filter_map(|abi| abi.as_string()) {
Expand Down Expand Up @@ -1426,6 +1431,7 @@ impl ToJson for Target {
target_option_val!(merge_functions);
target_option_val!(target_mcount);
target_option_val!(llvm_abiname);
target_option_val!(relax_elf_relocations);

if default.abi_blacklist != self.options.abi_blacklist {
d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter()
Expand Down
Loading