Skip to content

Commit 3e523e9

Browse files
committed
Auto merge of rust-lang#2825 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 4b0f874 + 817b750 commit 3e523e9

File tree

234 files changed

+3328
-1222
lines changed

Some content is hidden

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

234 files changed

+3328
-1222
lines changed

Cargo.lock

+4
Original file line numberDiff line numberDiff line change
@@ -4523,6 +4523,7 @@ dependencies = [
45234523
"rustc_index",
45244524
"rustc_macros",
45254525
"rustc_serialize",
4526+
"serde_json",
45264527
"smallvec",
45274528
"stable_deref_trait",
45284529
"stacker",
@@ -4826,6 +4827,7 @@ dependencies = [
48264827
"rustc_data_structures",
48274828
"rustc_errors",
48284829
"rustc_expand",
4830+
"rustc_fs_util",
48294831
"rustc_hir",
48304832
"rustc_hir_analysis",
48314833
"rustc_hir_typeck",
@@ -4950,6 +4952,7 @@ dependencies = [
49504952
"rustc_errors",
49514953
"rustc_expand",
49524954
"rustc_feature",
4955+
"rustc_fs_util",
49534956
"rustc_hir",
49544957
"rustc_hir_pretty",
49554958
"rustc_index",
@@ -5335,6 +5338,7 @@ dependencies = [
53355338
"rustc_abi",
53365339
"rustc_data_structures",
53375340
"rustc_feature",
5341+
"rustc_fs_util",
53385342
"rustc_index",
53395343
"rustc_macros",
53405344
"rustc_serialize",

compiler/rustc_borrowck/src/type_check/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22222222
}
22232223
}
22242224
}
2225+
CastKind::Transmute => {
2226+
span_mirbug!(
2227+
self,
2228+
rvalue,
2229+
"Unexpected CastKind::Transmute, which is not permitted in Analysis MIR",
2230+
);
2231+
}
22252232
}
22262233
}
22272234

compiler/rustc_builtin_macros/src/cmdline_attrs.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_ast::{self as ast, AttrItem, AttrStyle};
66
use rustc_session::parse::ParseSess;
77
use rustc_span::FileName;
88

9-
pub fn inject(mut krate: ast::Crate, parse_sess: &ParseSess, attrs: &[String]) -> ast::Crate {
9+
pub fn inject(krate: &mut ast::Crate, parse_sess: &ParseSess, attrs: &[String]) {
1010
for raw_attr in attrs {
1111
let mut parser = rustc_parse::new_parser_from_source_str(
1212
parse_sess,
@@ -36,6 +36,4 @@ pub fn inject(mut krate: ast::Crate, parse_sess: &ParseSess, attrs: &[String]) -
3636
start_span.to(end_span),
3737
));
3838
}
39-
40-
krate
4139
}

compiler/rustc_builtin_macros/src/proc_macro_harness.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ struct CollectProcMacros<'a> {
4343
}
4444

4545
pub fn inject(
46+
krate: &mut ast::Crate,
4647
sess: &Session,
4748
resolver: &mut dyn ResolverExpand,
48-
mut krate: ast::Crate,
4949
is_proc_macro_crate: bool,
5050
has_proc_macro_decls: bool,
5151
is_test_crate: bool,
5252
handler: &rustc_errors::Handler,
53-
) -> ast::Crate {
53+
) {
5454
let ecfg = ExpansionConfig::default("proc_macro".to_string());
5555
let mut cx = ExtCtxt::new(sess, ecfg, resolver, None);
5656

@@ -64,22 +64,20 @@ pub fn inject(
6464
};
6565

6666
if has_proc_macro_decls || is_proc_macro_crate {
67-
visit::walk_crate(&mut collect, &krate);
67+
visit::walk_crate(&mut collect, krate);
6868
}
6969
let macros = collect.macros;
7070

7171
if !is_proc_macro_crate {
72-
return krate;
72+
return;
7373
}
7474

7575
if is_test_crate {
76-
return krate;
76+
return;
7777
}
7878

7979
let decls = mk_decls(&mut cx, &macros);
8080
krate.items.push(decls);
81-
82-
krate
8381
}
8482

8583
impl<'a> CollectProcMacros<'a> {

compiler/rustc_builtin_macros/src/standard_library_imports.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ use rustc_span::DUMMY_SP;
99
use thin_vec::thin_vec;
1010

1111
pub fn inject(
12-
mut krate: ast::Crate,
12+
krate: &mut ast::Crate,
13+
pre_configured_attrs: &[ast::Attribute],
1314
resolver: &mut dyn ResolverExpand,
1415
sess: &Session,
15-
) -> ast::Crate {
16+
) -> usize {
17+
let orig_num_items = krate.items.len();
1618
let edition = sess.parse_sess.edition;
1719

1820
// the first name in this list is the crate name of the crate with the prelude
19-
let names: &[Symbol] = if attr::contains_name(&krate.attrs, sym::no_core) {
20-
return krate;
21-
} else if attr::contains_name(&krate.attrs, sym::no_std) {
22-
if attr::contains_name(&krate.attrs, sym::compiler_builtins) {
21+
let names: &[Symbol] = if attr::contains_name(pre_configured_attrs, sym::no_core) {
22+
return 0;
23+
} else if attr::contains_name(pre_configured_attrs, sym::no_std) {
24+
if attr::contains_name(pre_configured_attrs, sym::compiler_builtins) {
2325
&[sym::core]
2426
} else {
2527
&[sym::core, sym::compiler_builtins]
@@ -88,6 +90,5 @@ pub fn inject(
8890
);
8991

9092
krate.items.insert(0, use_item);
91-
92-
krate
93+
krate.items.len() - orig_num_items
9394
}

compiler/rustc_builtin_macros/src/test_harness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct TestCtxt<'a> {
3737

3838
/// Traverse the crate, collecting all the test functions, eliding any
3939
/// existing main functions, and synthesizing a main test harness
40-
pub fn inject(sess: &Session, resolver: &mut dyn ResolverExpand, krate: &mut ast::Crate) {
40+
pub fn inject(krate: &mut ast::Crate, sess: &Session, resolver: &mut dyn ResolverExpand) {
4141
let span_diagnostic = sess.diagnostic();
4242
let panic_strategy = sess.panic_strategy();
4343
let platform_panic_strategy = sess.target.panic_strategy;

compiler/rustc_codegen_cranelift/src/base.rs

+4
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ fn codegen_stmt<'tcx>(
709709
let operand = codegen_operand(fx, operand);
710710
operand.coerce_dyn_star(fx, lval);
711711
}
712+
Rvalue::Cast(CastKind::Transmute, ref operand, _to_ty) => {
713+
let operand = codegen_operand(fx, operand);
714+
lval.write_cvalue_transmute(fx, operand);
715+
}
712716
Rvalue::Discriminant(place) => {
713717
let place = codegen_place(fx, place);
714718
let value = place.to_cvalue(fx);

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -557,16 +557,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
557557
fx.bcx.ins().band(ptr, mask);
558558
}
559559

560-
sym::transmute => {
561-
intrinsic_args!(fx, args => (from); intrinsic);
562-
563-
if ret.layout().abi.is_uninhabited() {
564-
crate::base::codegen_panic(fx, "Transmuting to uninhabited type.", source_info);
565-
return;
566-
}
567-
568-
ret.write_cvalue_transmute(fx, from);
569-
}
570560
sym::write_bytes | sym::volatile_set_memory => {
571561
intrinsic_args!(fx, args => (dst, val, count); intrinsic);
572562
let val = val.load_scalar(fx);

compiler/rustc_codegen_llvm/src/back/archive.rs

+25-14
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
189189
path.push(lib_name);
190190
path
191191
};
192+
// dlltool target architecture args from:
193+
// https://github.com/llvm/llvm-project-release-prs/blob/llvmorg-15.0.6/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp#L69
194+
let (dlltool_target_arch, dlltool_target_bitness) = match sess.target.arch.as_ref() {
195+
"x86_64" => ("i386:x86-64", "--64"),
196+
"x86" => ("i386", "--32"),
197+
"aarch64" => ("arm64", "--64"),
198+
"arm" => ("arm", "--32"),
199+
_ => panic!("unsupported arch {}", sess.target.arch),
200+
};
192201
let result = std::process::Command::new(dlltool)
193202
.args([
194203
"-d",
@@ -197,6 +206,10 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
197206
lib_name,
198207
"-l",
199208
output_path.to_str().unwrap(),
209+
"-m",
210+
dlltool_target_arch,
211+
"-f",
212+
dlltool_target_bitness,
200213
"--no-leading-underscore",
201214
"--temp-prefix",
202215
temp_prefix.to_str().unwrap(),
@@ -422,24 +435,22 @@ fn find_binutils_dlltool(sess: &Session) -> OsString {
422435
return dlltool_path.clone().into_os_string();
423436
}
424437

425-
let mut tool_name: OsString = if sess.host.arch != sess.target.arch {
426-
// We are cross-compiling, so we need the tool with the prefix matching our target
427-
if sess.target.arch == "x86" {
428-
"i686-w64-mingw32-dlltool"
429-
} else {
430-
"x86_64-w64-mingw32-dlltool"
431-
}
438+
let tool_name: OsString = if sess.host.options.is_like_windows {
439+
// If we're compiling on Windows, always use "dlltool.exe".
440+
"dlltool.exe"
432441
} else {
433-
// We are not cross-compiling, so we just want `dlltool`
434-
"dlltool"
442+
// On other platforms, use the architecture-specific name.
443+
match sess.target.arch.as_ref() {
444+
"x86_64" => "x86_64-w64-mingw32-dlltool",
445+
"x86" => "i686-w64-mingw32-dlltool",
446+
"aarch64" => "aarch64-w64-mingw32-dlltool",
447+
448+
// For non-standard architectures (e.g., aarch32) fallback to "dlltool".
449+
_ => "dlltool",
450+
}
435451
}
436452
.into();
437453

438-
if sess.host.options.is_like_windows {
439-
// If we're compiling on Windows, add the .exe suffix
440-
tool_name.push(".exe");
441-
}
442-
443454
// NOTE: it's not clear how useful it is to explicitly search PATH.
444455
for dir in env::split_paths(&env::var_os("PATH").unwrap_or_default()) {
445456
let full_path = dir.join(&tool_name);

compiler/rustc_codegen_llvm/src/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
378378
}
379379
}
380380

381-
_ => bug!("unknown intrinsic '{}'", name),
381+
_ => bug!("unknown intrinsic '{}' -- should it have been lowered earlier?", name),
382382
};
383383

384384
if !fn_abi.ret.is_ignore() {

compiler/rustc_codegen_llvm/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,12 @@ impl CodegenBackend for LlvmCodegenBackend {
361361
.expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>")
362362
.join(sess);
363363

364-
sess.time("llvm_dump_timing_file", || {
365-
if sess.opts.unstable_opts.llvm_time_trace {
364+
if sess.opts.unstable_opts.llvm_time_trace {
365+
sess.time("llvm_dump_timing_file", || {
366366
let file_name = outputs.with_extension("llvm_timings.json");
367367
llvm_util::time_trace_profiler_finish(&file_name);
368-
}
369-
});
368+
});
369+
}
370370

371371
Ok((codegen_results, work_products))
372372
}

0 commit comments

Comments
 (0)