Skip to content

Commit

Permalink
Auto merge of rust-lang#70305 - Centril:rollup-zi13fz4, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - rust-lang#69080 (rustc_codegen_llvm: don't generate any type debuginfo for -Cdebuginfo=1.)
 - rust-lang#69940 (librustc_codegen_llvm: Replace deprecated API usage)
 - rust-lang#69942 (Increase verbosity when suggesting subtle code changes)
 - rust-lang#69968 (rustc: keep upvars tupled in {Closure,Generator}Substs.)
 - rust-lang#70123 (Ensure LLVM is in the link path for rustc tools)
 - rust-lang#70159 (Update the bundled wasi-libc with libstd)
 - rust-lang#70233 (resolve: Do not resolve visibilities on proc macro definitions twice)
 - rust-lang#70286 (Miri error type: remove UbExperimental variant)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Mar 23, 2020
2 parents 8ff7850 + 07e1043 commit 5aa8f19
Show file tree
Hide file tree
Showing 218 changed files with 1,334 additions and 1,103 deletions.
31 changes: 28 additions & 3 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use std::time::{Duration, Instant};

use build_helper::t;
use build_helper::{output, t};

use crate::cache::{Cache, Interned, INTERNER};
use crate::check;
Expand All @@ -23,7 +23,7 @@ use crate::install;
use crate::native;
use crate::test;
use crate::tool;
use crate::util::{self, add_lib_path, exe, libdir};
use crate::util::{self, add_dylib_path, add_link_lib_path, exe, libdir};
use crate::{Build, DocTests, GitRepo, Mode};

pub use crate::Compiler;
Expand Down Expand Up @@ -660,7 +660,7 @@ impl<'a> Builder<'a> {
return;
}

add_lib_path(vec![self.rustc_libdir(compiler)], &mut cmd.command);
add_dylib_path(vec![self.rustc_libdir(compiler)], &mut cmd.command);
}

/// Gets a path to the compiler specified.
Expand Down Expand Up @@ -698,6 +698,20 @@ impl<'a> Builder<'a> {
cmd
}

/// Return the path to `llvm-config` for the target, if it exists.
///
/// Note that this returns `None` if LLVM is disabled, or if we're in a
/// check build or dry-run, where there's no need to build all of LLVM.
fn llvm_config(&self, target: Interned<String>) -> Option<PathBuf> {
if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run {
let llvm_config = self.ensure(native::Llvm { target });
if llvm_config.is_file() {
return Some(llvm_config);
}
}
None
}

/// Prepares an invocation of `cargo` to be run.
///
/// This will create a `Command` that represents a pending execution of
Expand Down Expand Up @@ -1034,6 +1048,17 @@ impl<'a> Builder<'a> {
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_libdir(compiler));
}

// Tools that use compiler libraries may inherit the `-lLLVM` link
// requirement, but the `-L` library path is not propagated across
// separate Cargo projects. We can add LLVM's library path to the
// platform-specific environment variable as a workaround.
if mode == Mode::ToolRustc {
if let Some(llvm_config) = self.llvm_config(target) {
let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cargo);
}
}

if self.config.incremental {
cargo.env("CARGO_INCREMENTAL", "1");
} else {
Expand Down
38 changes: 0 additions & 38 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,44 +451,6 @@ impl Step for Rustc {
false,
);

// We used to build librustc_codegen_llvm as a separate step,
// which produced a dylib that the compiler would dlopen() at runtime.
// This meant that we only needed to make sure that libLLVM.so was
// installed by the time we went to run a tool using it - since
// librustc_codegen_llvm was effectively a standalone artifact,
// other crates were completely oblivious to its dependency
// on `libLLVM.so` during build time.
//
// However, librustc_codegen_llvm is now built as an ordinary
// crate during the same step as the rest of the compiler crates.
// This means that any crates depending on it will see the fact
// that it uses `libLLVM.so` as a native library, and will
// cause us to pass `-llibLLVM.so` to the linker when we link
// a binary.
//
// For `rustc` itself, this works out fine.
// During the `Assemble` step, we call `dist::maybe_install_llvm_dylib`
// to copy libLLVM.so into the `stage` directory. We then link
// the compiler binary, which will find `libLLVM.so` in the correct place.
//
// However, this is insufficient for tools that are build against stage0
// (e.g. stage1 rustdoc). Since `Assemble` for stage0 doesn't actually do anything,
// we won't have `libLLVM.so` in the stage0 sysroot. In the past, this wasn't
// a problem - we would copy the tool binary into its correct stage directory
// (e.g. stage1 for a stage1 rustdoc built against a stage0 compiler).
// Since libLLVM.so wasn't resolved until runtime, it was fine for it to
// not exist while we were building it.
//
// To ensure that we can still build stage1 tools against a stage0 compiler,
// we explicitly copy libLLVM.so into the stage0 sysroot when building
// the stage0 compiler. This ensures that tools built against stage0
// will see libLLVM.so at build time, making the linker happy.
if compiler.stage == 0 {
builder.info(&format!("Installing libLLVM.so to stage 0 ({})", compiler.host));
let sysroot = builder.sysroot(compiler);
dist::maybe_install_llvm_dylib(builder, compiler.host, &sysroot);
}

builder.ensure(RustcLink {
compiler: builder.compiler(compiler.stage, builder.config.build),
target_compiler: compiler,
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::channel;
use crate::channel::GitInfo;
use crate::compile;
use crate::toolstate::ToolState;
use crate::util::{add_lib_path, exe, CiEnv};
use crate::util::{add_dylib_path, exe, CiEnv};
use crate::Compiler;
use crate::Mode;

Expand Down Expand Up @@ -388,7 +388,7 @@ pub struct ErrorIndex {
impl ErrorIndex {
pub fn command(builder: &Builder<'_>, compiler: Compiler) -> Command {
let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler }));
add_lib_path(
add_dylib_path(
vec![PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host))],
&mut cmd,
);
Expand Down Expand Up @@ -689,7 +689,7 @@ impl<'a> Builder<'a> {
}
}

add_lib_path(lib_paths, &mut cmd);
add_dylib_path(lib_paths, &mut cmd);
cmd
}
}
27 changes: 26 additions & 1 deletion src/bootstrap/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn libdir(target: &str) -> &'static str {
}

/// Adds a list of lookup paths to `cmd`'s dynamic library lookup path.
pub fn add_lib_path(path: Vec<PathBuf>, cmd: &mut Command) {
pub fn add_dylib_path(path: Vec<PathBuf>, cmd: &mut Command) {
let mut list = dylib_path();
for path in path {
list.insert(0, path);
Expand Down Expand Up @@ -72,6 +72,31 @@ pub fn dylib_path() -> Vec<PathBuf> {
env::split_paths(&var).collect()
}

/// Adds a list of lookup paths to `cmd`'s link library lookup path.
pub fn add_link_lib_path(path: Vec<PathBuf>, cmd: &mut Command) {
let mut list = link_lib_path();
for path in path {
list.insert(0, path);
}
cmd.env(link_lib_path_var(), t!(env::join_paths(list)));
}

/// Returns the environment variable which the link library lookup path
/// resides in for this platform.
fn link_lib_path_var() -> &'static str {
if cfg!(target_env = "msvc") { "LIB" } else { "LIBRARY_PATH" }
}

/// Parses the `link_lib_path_var()` environment variable, returning a list of
/// paths that are members of this lookup path.
fn link_lib_path() -> Vec<PathBuf> {
let var = match env::var_os(link_lib_path_var()) {
Some(v) => v,
None => return vec![],
};
env::split_paths(&var).collect()
}

/// `push` all components to `buf`. On windows, append `.exe` to the last component.
pub fn push_exe_path(mut buf: PathBuf, components: &[&str]) -> PathBuf {
let (&file, components) = components.split_last().expect("at least one component required");
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/dist-various-2/build-wasi-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export PATH=`pwd`/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH
git clone https://github.com/CraneStation/wasi-libc

cd wasi-libc
git reset --hard 1fad33890a5e299027ce0eab7b6ad5260585e347
git reset --hard 9efc2f428358564fe64c374d762d0bfce1d92507
make -j$(nproc) INSTALL_DIR=/wasm32-wasi install

cd ..
Expand Down
7 changes: 2 additions & 5 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ impl fmt::Debug for InvalidProgramInfo<'_> {
pub enum UndefinedBehaviorInfo {
/// Free-form case. Only for errors that are never caught!
Ub(String),
/// Free-form case for experimental UB. Only for errors that are never caught!
UbExperimental(String),
/// Unreachable code was executed.
Unreachable,
/// An enum discriminant was set to a value which was outside the range of valid values.
Expand Down Expand Up @@ -381,7 +379,7 @@ impl fmt::Debug for UndefinedBehaviorInfo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use UndefinedBehaviorInfo::*;
match self {
Ub(msg) | UbExperimental(msg) => write!(f, "{}", msg),
Ub(msg) => write!(f, "{}", msg),
Unreachable => write!(f, "entering unreachable code"),
InvalidDiscriminant(val) => write!(f, "encountering invalid enum discriminant {}", val),
BoundsCheckFailed { ref len, ref index } => write!(
Expand Down Expand Up @@ -563,8 +561,7 @@ impl InterpError<'_> {
InterpError::MachineStop(_)
| InterpError::Unsupported(UnsupportedOpInfo::Unsupported(_))
| InterpError::UndefinedBehavior(UndefinedBehaviorInfo::ValidationFailure(_))
| InterpError::UndefinedBehavior(UndefinedBehaviorInfo::Ub(_))
| InterpError::UndefinedBehavior(UndefinedBehaviorInfo::UbExperimental(_)) => true,
| InterpError::UndefinedBehavior(UndefinedBehaviorInfo::Ub(_)) => true,
_ => false,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
// (T1..Tn) and closures have same properties as T1..Tn --
// check if *any* of those are trivial.
ty::Tuple(ref tys) => tys.iter().all(|t| trivial_dropck_outlives(tcx, t.expect_ty())),
ty::Closure(def_id, ref substs) => {
substs.as_closure().upvar_tys(def_id, tcx).all(|t| trivial_dropck_outlives(tcx, t))
ty::Closure(_, ref substs) => {
substs.as_closure().upvar_tys().all(|t| trivial_dropck_outlives(tcx, t))
}

ty::Adt(def, _) => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl<'tcx> Instance<'tcx> {
substs: ty::SubstsRef<'tcx>,
requested_kind: ty::ClosureKind,
) -> Instance<'tcx> {
let actual_kind = substs.as_closure().kind(def_id, tcx);
let actual_kind = substs.as_closure().kind();

match needs_fn_once_adapter_shim(actual_kind, requested_kind) {
Ok(true) => Instance::fn_once_adapter_instance(tcx, def_id, substs),
Expand Down Expand Up @@ -372,7 +372,7 @@ impl<'tcx> Instance<'tcx> {

let self_ty = tcx.mk_closure(closure_did, substs);

let sig = substs.as_closure().sig(closure_did, tcx);
let sig = substs.as_closure().sig();
let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
assert_eq!(sig.inputs().len(), 1);
let substs = tcx.mk_substs_trait(self_ty, &[sig.inputs()[0].into()]);
Expand Down
20 changes: 9 additions & 11 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {

ty::Generator(def_id, substs, _) => self.generator_layout(ty, def_id, substs)?,

ty::Closure(def_id, ref substs) => {
let tys = substs.as_closure().upvar_tys(def_id, tcx);
ty::Closure(_, ref substs) => {
let tys = substs.as_closure().upvar_tys();
univariant(
&tys.map(|ty| self.layout_of(ty)).collect::<Result<Vec<_>, _>>()?,
&ReprOptions::default(),
Expand Down Expand Up @@ -1402,7 +1402,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
// Build a prefix layout, including "promoting" all ineligible
// locals as part of the prefix. We compute the layout of all of
// these fields at once to get optimal packing.
let discr_index = substs.as_generator().prefix_tys(def_id, tcx).count();
let discr_index = substs.as_generator().prefix_tys().count();

// `info.variant_fields` already accounts for the reserved variants, so no need to add them.
let max_discr = (info.variant_fields.len() - 1) as u128;
Expand All @@ -1419,7 +1419,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
.map(|ty| self.layout_of(ty));
let prefix_layouts = substs
.as_generator()
.prefix_tys(def_id, tcx)
.prefix_tys()
.map(|ty| self.layout_of(ty))
.chain(iter::once(Ok(discr_layout)))
.chain(promoted_layouts)
Expand Down Expand Up @@ -2095,9 +2095,7 @@ where
ty::Str => tcx.types.u8,

// Tuples, generators and closures.
ty::Closure(def_id, ref substs) => {
substs.as_closure().upvar_tys(def_id, tcx).nth(i).unwrap()
}
ty::Closure(_, ref substs) => substs.as_closure().upvar_tys().nth(i).unwrap(),

ty::Generator(def_id, ref substs, _) => match this.variants {
Variants::Single { index } => substs
Expand All @@ -2111,7 +2109,7 @@ where
if i == discr_index {
return discr_layout(discr);
}
substs.as_generator().prefix_tys(def_id, tcx).nth(i).unwrap()
substs.as_generator().prefix_tys().nth(i).unwrap()
}
},

Expand Down Expand Up @@ -2298,7 +2296,7 @@ impl<'tcx> ty::Instance<'tcx> {
sig
}
ty::Closure(def_id, substs) => {
let sig = substs.as_closure().sig(def_id, tcx);
let sig = substs.as_closure().sig();

let env_ty = tcx.closure_env_ty(def_id, substs).unwrap();
sig.map_bound(|sig| tcx.mk_fn_sig(
Expand All @@ -2309,8 +2307,8 @@ impl<'tcx> ty::Instance<'tcx> {
sig.abi
))
}
ty::Generator(def_id, substs, _) => {
let sig = substs.as_generator().poly_sig(def_id, tcx);
ty::Generator(_, substs, _) => {
let sig = substs.as_generator().poly_sig();

let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv);
let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty);
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/ty/outlives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ fn compute_components(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, out: &mut SmallVec<[Compo
// in the `subtys` iterator (e.g., when encountering a
// projection).
match ty.kind {
ty::Closure(def_id, ref substs) => {
for upvar_ty in substs.as_closure().upvar_tys(def_id, tcx) {
ty::Closure(_, ref substs) => {
for upvar_ty in substs.as_closure().upvar_tys() {
compute_components(tcx, upvar_ty, out);
}
}

ty::Generator(def_id, ref substs, _) => {
ty::Generator(_, ref substs, _) => {
// Same as the closure case
for upvar_ty in substs.as_generator().upvar_tys(def_id, tcx) {
for upvar_ty in substs.as_generator().upvar_tys() {
compute_components(tcx, upvar_ty, out);
}

Expand Down
Loading

0 comments on commit 5aa8f19

Please sign in to comment.