Skip to content

Commit 5aa8f19

Browse files
committed
Auto merge of #70305 - Centril:rollup-zi13fz4, r=Centril
Rollup of 8 pull requests Successful merges: - #69080 (rustc_codegen_llvm: don't generate any type debuginfo for -Cdebuginfo=1.) - #69940 (librustc_codegen_llvm: Replace deprecated API usage) - #69942 (Increase verbosity when suggesting subtle code changes) - #69968 (rustc: keep upvars tupled in {Closure,Generator}Substs.) - #70123 (Ensure LLVM is in the link path for rustc tools) - #70159 (Update the bundled wasi-libc with libstd) - #70233 (resolve: Do not resolve visibilities on proc macro definitions twice) - #70286 (Miri error type: remove UbExperimental variant) Failed merges: r? @ghost
2 parents 8ff7850 + 07e1043 commit 5aa8f19

File tree

218 files changed

+1334
-1103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+1334
-1103
lines changed

src/bootstrap/builder.rs

+28-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
1111
use std::process::Command;
1212
use std::time::{Duration, Instant};
1313

14-
use build_helper::t;
14+
use build_helper::{output, t};
1515

1616
use crate::cache::{Cache, Interned, INTERNER};
1717
use crate::check;
@@ -23,7 +23,7 @@ use crate::install;
2323
use crate::native;
2424
use crate::test;
2525
use crate::tool;
26-
use crate::util::{self, add_lib_path, exe, libdir};
26+
use crate::util::{self, add_dylib_path, add_link_lib_path, exe, libdir};
2727
use crate::{Build, DocTests, GitRepo, Mode};
2828

2929
pub use crate::Compiler;
@@ -660,7 +660,7 @@ impl<'a> Builder<'a> {
660660
return;
661661
}
662662

663-
add_lib_path(vec![self.rustc_libdir(compiler)], &mut cmd.command);
663+
add_dylib_path(vec![self.rustc_libdir(compiler)], &mut cmd.command);
664664
}
665665

666666
/// Gets a path to the compiler specified.
@@ -698,6 +698,20 @@ impl<'a> Builder<'a> {
698698
cmd
699699
}
700700

701+
/// Return the path to `llvm-config` for the target, if it exists.
702+
///
703+
/// Note that this returns `None` if LLVM is disabled, or if we're in a
704+
/// check build or dry-run, where there's no need to build all of LLVM.
705+
fn llvm_config(&self, target: Interned<String>) -> Option<PathBuf> {
706+
if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run {
707+
let llvm_config = self.ensure(native::Llvm { target });
708+
if llvm_config.is_file() {
709+
return Some(llvm_config);
710+
}
711+
}
712+
None
713+
}
714+
701715
/// Prepares an invocation of `cargo` to be run.
702716
///
703717
/// This will create a `Command` that represents a pending execution of
@@ -1034,6 +1048,17 @@ impl<'a> Builder<'a> {
10341048
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_libdir(compiler));
10351049
}
10361050

1051+
// Tools that use compiler libraries may inherit the `-lLLVM` link
1052+
// requirement, but the `-L` library path is not propagated across
1053+
// separate Cargo projects. We can add LLVM's library path to the
1054+
// platform-specific environment variable as a workaround.
1055+
if mode == Mode::ToolRustc {
1056+
if let Some(llvm_config) = self.llvm_config(target) {
1057+
let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
1058+
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cargo);
1059+
}
1060+
}
1061+
10371062
if self.config.incremental {
10381063
cargo.env("CARGO_INCREMENTAL", "1");
10391064
} else {

src/bootstrap/compile.rs

-38
Original file line numberDiff line numberDiff line change
@@ -451,44 +451,6 @@ impl Step for Rustc {
451451
false,
452452
);
453453

454-
// We used to build librustc_codegen_llvm as a separate step,
455-
// which produced a dylib that the compiler would dlopen() at runtime.
456-
// This meant that we only needed to make sure that libLLVM.so was
457-
// installed by the time we went to run a tool using it - since
458-
// librustc_codegen_llvm was effectively a standalone artifact,
459-
// other crates were completely oblivious to its dependency
460-
// on `libLLVM.so` during build time.
461-
//
462-
// However, librustc_codegen_llvm is now built as an ordinary
463-
// crate during the same step as the rest of the compiler crates.
464-
// This means that any crates depending on it will see the fact
465-
// that it uses `libLLVM.so` as a native library, and will
466-
// cause us to pass `-llibLLVM.so` to the linker when we link
467-
// a binary.
468-
//
469-
// For `rustc` itself, this works out fine.
470-
// During the `Assemble` step, we call `dist::maybe_install_llvm_dylib`
471-
// to copy libLLVM.so into the `stage` directory. We then link
472-
// the compiler binary, which will find `libLLVM.so` in the correct place.
473-
//
474-
// However, this is insufficient for tools that are build against stage0
475-
// (e.g. stage1 rustdoc). Since `Assemble` for stage0 doesn't actually do anything,
476-
// we won't have `libLLVM.so` in the stage0 sysroot. In the past, this wasn't
477-
// a problem - we would copy the tool binary into its correct stage directory
478-
// (e.g. stage1 for a stage1 rustdoc built against a stage0 compiler).
479-
// Since libLLVM.so wasn't resolved until runtime, it was fine for it to
480-
// not exist while we were building it.
481-
//
482-
// To ensure that we can still build stage1 tools against a stage0 compiler,
483-
// we explicitly copy libLLVM.so into the stage0 sysroot when building
484-
// the stage0 compiler. This ensures that tools built against stage0
485-
// will see libLLVM.so at build time, making the linker happy.
486-
if compiler.stage == 0 {
487-
builder.info(&format!("Installing libLLVM.so to stage 0 ({})", compiler.host));
488-
let sysroot = builder.sysroot(compiler);
489-
dist::maybe_install_llvm_dylib(builder, compiler.host, &sysroot);
490-
}
491-
492454
builder.ensure(RustcLink {
493455
compiler: builder.compiler(compiler.stage, builder.config.build),
494456
target_compiler: compiler,

src/bootstrap/tool.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::channel;
1212
use crate::channel::GitInfo;
1313
use crate::compile;
1414
use crate::toolstate::ToolState;
15-
use crate::util::{add_lib_path, exe, CiEnv};
15+
use crate::util::{add_dylib_path, exe, CiEnv};
1616
use crate::Compiler;
1717
use crate::Mode;
1818

@@ -388,7 +388,7 @@ pub struct ErrorIndex {
388388
impl ErrorIndex {
389389
pub fn command(builder: &Builder<'_>, compiler: Compiler) -> Command {
390390
let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler }));
391-
add_lib_path(
391+
add_dylib_path(
392392
vec![PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host))],
393393
&mut cmd,
394394
);
@@ -689,7 +689,7 @@ impl<'a> Builder<'a> {
689689
}
690690
}
691691

692-
add_lib_path(lib_paths, &mut cmd);
692+
add_dylib_path(lib_paths, &mut cmd);
693693
cmd
694694
}
695695
}

src/bootstrap/util.rs

+26-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn libdir(target: &str) -> &'static str {
4040
}
4141

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

75+
/// Adds a list of lookup paths to `cmd`'s link library lookup path.
76+
pub fn add_link_lib_path(path: Vec<PathBuf>, cmd: &mut Command) {
77+
let mut list = link_lib_path();
78+
for path in path {
79+
list.insert(0, path);
80+
}
81+
cmd.env(link_lib_path_var(), t!(env::join_paths(list)));
82+
}
83+
84+
/// Returns the environment variable which the link library lookup path
85+
/// resides in for this platform.
86+
fn link_lib_path_var() -> &'static str {
87+
if cfg!(target_env = "msvc") { "LIB" } else { "LIBRARY_PATH" }
88+
}
89+
90+
/// Parses the `link_lib_path_var()` environment variable, returning a list of
91+
/// paths that are members of this lookup path.
92+
fn link_lib_path() -> Vec<PathBuf> {
93+
let var = match env::var_os(link_lib_path_var()) {
94+
Some(v) => v,
95+
None => return vec![],
96+
};
97+
env::split_paths(&var).collect()
98+
}
99+
75100
/// `push` all components to `buf`. On windows, append `.exe` to the last component.
76101
pub fn push_exe_path(mut buf: PathBuf, components: &[&str]) -> PathBuf {
77102
let (&file, components) = components.split_last().expect("at least one component required");

src/ci/docker/dist-various-2/build-wasi-toolchain.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export PATH=`pwd`/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH
1212
git clone https://github.com/CraneStation/wasi-libc
1313

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

1818
cd ..

src/librustc/mir/interpret/error.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,6 @@ impl fmt::Debug for InvalidProgramInfo<'_> {
319319
pub enum UndefinedBehaviorInfo {
320320
/// Free-form case. Only for errors that are never caught!
321321
Ub(String),
322-
/// Free-form case for experimental UB. Only for errors that are never caught!
323-
UbExperimental(String),
324322
/// Unreachable code was executed.
325323
Unreachable,
326324
/// An enum discriminant was set to a value which was outside the range of valid values.
@@ -381,7 +379,7 @@ impl fmt::Debug for UndefinedBehaviorInfo {
381379
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
382380
use UndefinedBehaviorInfo::*;
383381
match self {
384-
Ub(msg) | UbExperimental(msg) => write!(f, "{}", msg),
382+
Ub(msg) => write!(f, "{}", msg),
385383
Unreachable => write!(f, "entering unreachable code"),
386384
InvalidDiscriminant(val) => write!(f, "encountering invalid enum discriminant {}", val),
387385
BoundsCheckFailed { ref len, ref index } => write!(
@@ -563,8 +561,7 @@ impl InterpError<'_> {
563561
InterpError::MachineStop(_)
564562
| InterpError::Unsupported(UnsupportedOpInfo::Unsupported(_))
565563
| InterpError::UndefinedBehavior(UndefinedBehaviorInfo::ValidationFailure(_))
566-
| InterpError::UndefinedBehavior(UndefinedBehaviorInfo::Ub(_))
567-
| InterpError::UndefinedBehavior(UndefinedBehaviorInfo::UbExperimental(_)) => true,
564+
| InterpError::UndefinedBehavior(UndefinedBehaviorInfo::Ub(_)) => true,
568565
_ => false,
569566
}
570567
}

src/librustc/traits/query.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
229229
// (T1..Tn) and closures have same properties as T1..Tn --
230230
// check if *any* of those are trivial.
231231
ty::Tuple(ref tys) => tys.iter().all(|t| trivial_dropck_outlives(tcx, t.expect_ty())),
232-
ty::Closure(def_id, ref substs) => {
233-
substs.as_closure().upvar_tys(def_id, tcx).all(|t| trivial_dropck_outlives(tcx, t))
232+
ty::Closure(_, ref substs) => {
233+
substs.as_closure().upvar_tys().all(|t| trivial_dropck_outlives(tcx, t))
234234
}
235235

236236
ty::Adt(def, _) => {

src/librustc/ty/instance.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl<'tcx> Instance<'tcx> {
341341
substs: ty::SubstsRef<'tcx>,
342342
requested_kind: ty::ClosureKind,
343343
) -> Instance<'tcx> {
344-
let actual_kind = substs.as_closure().kind(def_id, tcx);
344+
let actual_kind = substs.as_closure().kind();
345345

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

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

375-
let sig = substs.as_closure().sig(closure_did, tcx);
375+
let sig = substs.as_closure().sig();
376376
let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
377377
assert_eq!(sig.inputs().len(), 1);
378378
let substs = tcx.mk_substs_trait(self_ty, &[sig.inputs()[0].into()]);

src/librustc/ty/layout.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
628628

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

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

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

20972097
// Tuples, generators and closures.
2098-
ty::Closure(def_id, ref substs) => {
2099-
substs.as_closure().upvar_tys(def_id, tcx).nth(i).unwrap()
2100-
}
2098+
ty::Closure(_, ref substs) => substs.as_closure().upvar_tys().nth(i).unwrap(),
21012099

21022100
ty::Generator(def_id, ref substs, _) => match this.variants {
21032101
Variants::Single { index } => substs
@@ -2111,7 +2109,7 @@ where
21112109
if i == discr_index {
21122110
return discr_layout(discr);
21132111
}
2114-
substs.as_generator().prefix_tys(def_id, tcx).nth(i).unwrap()
2112+
substs.as_generator().prefix_tys().nth(i).unwrap()
21152113
}
21162114
},
21172115

@@ -2298,7 +2296,7 @@ impl<'tcx> ty::Instance<'tcx> {
22982296
sig
22992297
}
23002298
ty::Closure(def_id, substs) => {
2301-
let sig = substs.as_closure().sig(def_id, tcx);
2299+
let sig = substs.as_closure().sig();
23022300

23032301
let env_ty = tcx.closure_env_ty(def_id, substs).unwrap();
23042302
sig.map_bound(|sig| tcx.mk_fn_sig(
@@ -2309,8 +2307,8 @@ impl<'tcx> ty::Instance<'tcx> {
23092307
sig.abi
23102308
))
23112309
}
2312-
ty::Generator(def_id, substs, _) => {
2313-
let sig = substs.as_generator().poly_sig(def_id, tcx);
2310+
ty::Generator(_, substs, _) => {
2311+
let sig = substs.as_generator().poly_sig();
23142312

23152313
let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv);
23162314
let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty);

src/librustc/ty/outlives.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ fn compute_components(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, out: &mut SmallVec<[Compo
6161
// in the `subtys` iterator (e.g., when encountering a
6262
// projection).
6363
match ty.kind {
64-
ty::Closure(def_id, ref substs) => {
65-
for upvar_ty in substs.as_closure().upvar_tys(def_id, tcx) {
64+
ty::Closure(_, ref substs) => {
65+
for upvar_ty in substs.as_closure().upvar_tys() {
6666
compute_components(tcx, upvar_ty, out);
6767
}
6868
}
6969

70-
ty::Generator(def_id, ref substs, _) => {
70+
ty::Generator(_, ref substs, _) => {
7171
// Same as the closure case
72-
for upvar_ty in substs.as_generator().upvar_tys(def_id, tcx) {
72+
for upvar_ty in substs.as_generator().upvar_tys() {
7373
compute_components(tcx, upvar_ty, out);
7474
}
7575

0 commit comments

Comments
 (0)