Skip to content

Commit 5f81d83

Browse files
committed
Auto merge of #2933 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 20a2a24 + 14155e9 commit 5f81d83

File tree

167 files changed

+1875
-1960
lines changed

Some content is hidden

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

167 files changed

+1875
-1960
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
env:
3939
CI_JOB_NAME: "${{ matrix.name }}"
4040
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
41+
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
4142
SCCACHE_BUCKET: rust-lang-ci-sccache2
4243
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
4344
CACHE_DOMAIN: ci-caches.rust-lang.org
@@ -143,6 +144,17 @@ jobs:
143144
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}"
144145
TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}"
145146
if: success() && !env.SKIP_JOB
147+
- name: create github artifacts
148+
run: src/ci/scripts/create-doc-artifacts.sh
149+
if: success() && !env.SKIP_JOB
150+
- name: upload artifacts to github
151+
uses: actions/upload-artifact@v3
152+
with:
153+
name: "${{ env.DOC_ARTIFACT_NAME }}"
154+
path: obj/artifacts/doc
155+
if-no-files-found: ignore
156+
retention-days: 5
157+
if: success() && !env.SKIP_JOB
146158
- name: upload artifacts to S3
147159
run: src/ci/scripts/upload-artifacts.sh
148160
env:
@@ -156,6 +168,7 @@ jobs:
156168
env:
157169
CI_JOB_NAME: "${{ matrix.name }}"
158170
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
171+
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
159172
SCCACHE_BUCKET: rust-lang-ci-sccache2
160173
DEPLOY_BUCKET: rust-lang-ci2
161174
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
@@ -557,6 +570,17 @@ jobs:
557570
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}"
558571
TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}"
559572
if: success() && !env.SKIP_JOB
573+
- name: create github artifacts
574+
run: src/ci/scripts/create-doc-artifacts.sh
575+
if: success() && !env.SKIP_JOB
576+
- name: upload artifacts to github
577+
uses: actions/upload-artifact@v3
578+
with:
579+
name: "${{ env.DOC_ARTIFACT_NAME }}"
580+
path: obj/artifacts/doc
581+
if-no-files-found: ignore
582+
retention-days: 5
583+
if: success() && !env.SKIP_JOB
560584
- name: upload artifacts to S3
561585
run: src/ci/scripts/upload-artifacts.sh
562586
env:
@@ -571,6 +595,7 @@ jobs:
571595
DIST_TRY_BUILD: 1
572596
CI_JOB_NAME: "${{ matrix.name }}"
573597
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
598+
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
574599
SCCACHE_BUCKET: rust-lang-ci-sccache2
575600
DEPLOY_BUCKET: rust-lang-ci2
576601
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
@@ -672,6 +697,17 @@ jobs:
672697
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}"
673698
TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}"
674699
if: success() && !env.SKIP_JOB
700+
- name: create github artifacts
701+
run: src/ci/scripts/create-doc-artifacts.sh
702+
if: success() && !env.SKIP_JOB
703+
- name: upload artifacts to github
704+
uses: actions/upload-artifact@v3
705+
with:
706+
name: "${{ env.DOC_ARTIFACT_NAME }}"
707+
path: obj/artifacts/doc
708+
if-no-files-found: ignore
709+
retention-days: 5
710+
if: success() && !env.SKIP_JOB
675711
- name: upload artifacts to S3
676712
run: src/ci/scripts/upload-artifacts.sh
677713
env:

compiler/rustc_codegen_gcc/src/common.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
108108
self.const_uint(self.type_u64(), i)
109109
}
110110

111+
fn const_u128(&self, i: u128) -> RValue<'gcc> {
112+
self.const_uint_big(self.type_u128(), i)
113+
}
114+
111115
fn const_usize(&self, i: u64) -> RValue<'gcc> {
112116
let bit_size = self.data_layout().pointer_size.bits();
113117
if bit_size < 64 {
@@ -254,7 +258,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
254258
// SIMD builtins require a constant value.
255259
self.bitcast_if_needed(value, typ)
256260
}
257-
261+
258262
fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
259263
self.context.new_array_access(None, base_addr, self.const_usize(offset.bytes())).get_address(None)
260264
}

compiler/rustc_codegen_llvm/src/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
168168
self.const_uint(self.type_i64(), i)
169169
}
170170

171+
fn const_u128(&self, i: u128) -> &'ll Value {
172+
self.const_uint_big(self.type_i128(), i)
173+
}
174+
171175
fn const_usize(&self, i: u64) -> &'ll Value {
172176
let bit_size = self.data_layout().pointer_size.bits();
173177
if bit_size < 64 {

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D
429429
return existing_di_node;
430430
}
431431

432-
debug!("type_di_node: {:?}", t);
432+
debug!("type_di_node: {:?} kind: {:?}", t, t.kind());
433433

434434
let DINodeCreationResult { di_node, already_stored_in_typemap } = match *t.kind() {
435435
ty::Never | ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) => {

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,7 @@ fn build_enum_variant_member_di_node<'ll, 'tcx>(
412412
enum_type_and_layout.size.bits(),
413413
enum_type_and_layout.align.abi.bits() as u32,
414414
Size::ZERO.bits(),
415-
discr_value.opt_single_val().map(|value| {
416-
// NOTE(eddyb) do *NOT* remove this assert, until
417-
// we pass the full 128-bit value to LLVM, otherwise
418-
// truncation will be silent and remain undetected.
419-
assert_eq!(value as u64 as u128, value);
420-
cx.const_u64(value as u64)
421-
}),
415+
discr_value.opt_single_val().map(|value| cx.const_u128(value)),
422416
DIFlags::FlagZero,
423417
variant_member_info.variant_struct_type_di_node,
424418
)

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_data_structures::fx::FxIndexMap;
55
use rustc_data_structures::memmap::Mmap;
66
use rustc_data_structures::temp_dir::MaybeTempDir;
77
use rustc_errors::{ErrorGuaranteed, Handler};
8-
use rustc_fs_util::fix_windows_verbatim_for_gcc;
8+
use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
99
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
1010
use rustc_metadata::find_native_static_library;
1111
use rustc_metadata::fs::{copy_to_stdout, emit_wrapper_file, METADATA_FILENAME};
@@ -2682,6 +2682,30 @@ fn add_upstream_native_libraries(
26822682
}
26832683
}
26842684

2685+
// Rehome lib paths (which exclude the library file name) that point into the sysroot lib directory
2686+
// to be relative to the sysroot directory, which may be a relative path specified by the user.
2687+
//
2688+
// If the sysroot is a relative path, and the sysroot libs are specified as an absolute path, the
2689+
// linker command line can be non-deterministic due to the paths including the current working
2690+
// directory. The linker command line needs to be deterministic since it appears inside the PDB
2691+
// file generated by the MSVC linker. See https://github.com/rust-lang/rust/issues/112586.
2692+
//
2693+
// The returned path will always have `fix_windows_verbatim_for_gcc()` applied to it.
2694+
fn rehome_sysroot_lib_dir<'a>(sess: &'a Session, lib_dir: &Path) -> PathBuf {
2695+
let sysroot_lib_path = sess.target_filesearch(PathKind::All).get_lib_path();
2696+
let canonical_sysroot_lib_path =
2697+
{ try_canonicalize(&sysroot_lib_path).unwrap_or_else(|_| sysroot_lib_path.clone()) };
2698+
2699+
let canonical_lib_dir = try_canonicalize(lib_dir).unwrap_or_else(|_| lib_dir.to_path_buf());
2700+
if canonical_lib_dir == canonical_sysroot_lib_path {
2701+
// This path, returned by `target_filesearch().get_lib_path()`, has
2702+
// already had `fix_windows_verbatim_for_gcc()` applied if needed.
2703+
sysroot_lib_path
2704+
} else {
2705+
fix_windows_verbatim_for_gcc(&lib_dir)
2706+
}
2707+
}
2708+
26852709
// Adds the static "rlib" versions of all crates to the command line.
26862710
// There's a bit of magic which happens here specifically related to LTO,
26872711
// namely that we remove upstream object files.
@@ -2713,7 +2737,13 @@ fn add_static_crate<'a>(
27132737
let cratepath = &src.rlib.as_ref().unwrap().0;
27142738

27152739
let mut link_upstream = |path: &Path| {
2716-
cmd.link_rlib(&fix_windows_verbatim_for_gcc(path));
2740+
let rlib_path = if let Some(dir) = path.parent() {
2741+
let file_name = path.file_name().expect("rlib path has no file name path component");
2742+
rehome_sysroot_lib_dir(sess, &dir).join(file_name)
2743+
} else {
2744+
fix_windows_verbatim_for_gcc(path)
2745+
};
2746+
cmd.link_rlib(&rlib_path);
27172747
};
27182748

27192749
if !are_upstream_rust_objects_already_included(sess)
@@ -2782,7 +2812,7 @@ fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) {
27822812
// what its name is
27832813
let parent = cratepath.parent();
27842814
if let Some(dir) = parent {
2785-
cmd.include_path(&fix_windows_verbatim_for_gcc(dir));
2815+
cmd.include_path(&rehome_sysroot_lib_dir(sess, dir));
27862816
}
27872817
let stem = cratepath.file_stem().unwrap().to_str().unwrap();
27882818
// Convert library file-stem into a cc -l argument.

compiler/rustc_codegen_ssa/src/traits/consts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
1515
fn const_i32(&self, i: i32) -> Self::Value;
1616
fn const_u32(&self, i: u32) -> Self::Value;
1717
fn const_u64(&self, i: u64) -> Self::Value;
18+
fn const_u128(&self, i: u128) -> Self::Value;
1819
fn const_usize(&self, i: u64) -> Self::Value;
1920
fn const_u8(&self, i: u8) -> Self::Value;
2021
fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,17 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
781781
);
782782
return;
783783
}
784-
Ok(Some(ImplSource::Closure(data))) => {
785-
if !tcx.is_const_fn_raw(data.closure_def_id) {
784+
// Closure: Fn{Once|Mut}
785+
Ok(Some(ImplSource::Builtin(_)))
786+
if poly_trait_pred.self_ty().skip_binder().is_closure()
787+
&& tcx.fn_trait_kind_from_def_id(trait_id).is_some() =>
788+
{
789+
let ty::Closure(closure_def_id, substs) =
790+
*poly_trait_pred.self_ty().no_bound_vars().unwrap().kind()
791+
else {
792+
unreachable!()
793+
};
794+
if !tcx.is_const_fn_raw(closure_def_id) {
786795
self.check_op(ops::FnCallNonConst {
787796
caller,
788797
callee,

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl Qualif for NeedsNonConstDrop {
172172

173173
if !matches!(
174174
impl_src,
175-
ImplSource::ConstDestruct(_) | ImplSource::Param(_, ty::BoundConstness::ConstIfConst)
175+
ImplSource::Builtin(_) | ImplSource::Param(_, ty::BoundConstness::ConstIfConst)
176176
) {
177177
// If our const destruct candidate is not ConstDestruct or implied by the param env,
178178
// then it's bad

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
6363
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
6464
ty::Foreign(def_id) => self.print_def_path(def_id, &[]),
6565

66+
ty::Alias(ty::Weak, _) => bug!("type_name: unexpected weak projection"),
6667
ty::Alias(ty::Inherent, _) => bug!("type_name: unexpected inherent projection"),
6768
ty::GeneratorWitness(_) => bug!("type_name: unexpected `GeneratorWitness`"),
6869
ty::GeneratorWitnessMIR(..) => bug!("type_name: unexpected `GeneratorWitnessMIR`"),

0 commit comments

Comments
 (0)