-
Notifications
You must be signed in to change notification settings - Fork 254
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
Update rustc
to nightly-2022-08-08
#595
Conversation
…or identical, though it's possible a few patterns could be relaxed.
… I kept all behavior identical, though it's possible a few `.unwrap()`s could be elided.
…. the old `rustc` code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c2rust-analyze changes look good to me.
I pushed fixes for the remaining c2rust-analyze build errors on the |
Thanks! You could've just pushed directly here, though. |
It seems atomic intrinsics were changed, so we need to update them: c2rust-testsuite CI failure. Why are we using unstable intrinsics anyways? |
As far as I remember, these correspond to atomic operations on values in the input C code. We'd introduce some pretty horrible bugs in the generated Rust if we didn't. |
Looks like it was rust-lang/rust#97423 that broke this. I'll see about a fix. |
It might be from here: c2rust/c2rust-transpile/src/translator/atomics.rs Lines 236 to 244 in df32e6c
|
72ba66c
to
12dc481
Compare
12dc481
to
cbe60c0
Compare
Now we hit an ICE on I think it may be that we need a different |
Looks like there's a new |
Yeah, I was thinking it looked related to strict provenance. Another thing, I think we shouldn't tie the transpiler to the current rustc version. That is, the |
Why do we need to cast pointer to usize? Can't we use an opaque pointer and avoid ptr to int casts? Either an extern type (unstable I think but we're using |
Oops, I forgot to save some changes before committing. I'll push a fix.
They do look wrong, but I think they're caused by the backwards-compatibility aliases which still exist: https://github.com/m-ou-se/rust/blob/4982a59986f7393ace98f63c10e6c435ffba1420/library/core/src/intrinsics.rs#L949-L965 Re: cxchg orderings, I think it's fine to change them in a follow-up PR. |
these were missed in the last round of changes
Ah, that's why the error messages are wrong. I already commented on that PR that they are wrong, though, but I do still think they're very misleading as it says nothing about them being re-exported. |
For |
If I just switch error: internal compiler error: /rustc/d394408fb38c4de61f765a3ed5189d2731a1da91/compiler/rustc_codegen_ssa/src/mir/operand.rs:120:18: not immediate: OperandRef(Pair(([0 x { [0 x i8]*, i64 }]*:[0 x { [0 x i8]*, i64 }]* bitcast (<{ i8*, [8 x i8] }>* @5 to [0 x { [0 x i8]*, i64 }]*)), (i64:i64 1)) @ TyAndLayout { ty: *const [&str], layout: Layout { size: Size(16 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: ScalarPair(Initialized { value: Pointer, valid_range: 0..=18446744073709551615 }, Initialized { value: Int(I64, false), valid_range: 0..=18446744073709551615 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(8 bytes)], memory_index: [0, 1] }, largest_niche: None, variants: Single { index: 0 } } })
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/d394408fb38c4de61f765a3ed5189d2731a1da91/compiler/rustc_errors/src/lib.rs:1392:9
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: std::panic::panic_any::<rustc_errors::ExplicitBug>
2: <rustc_errors::HandlerInner>::bug::<&alloc::string::String>
3: <rustc_errors::Handler>::bug::<&alloc::string::String>
4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
6: rustc_middle::util::bug::bug_fmt
7: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
8: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
9: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::symbol::Symbol, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>
10: rustc_codegen_llvm::base::compile_codegen_unit
11: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
12: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
13: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
14: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorGuaranteed>>
15: <rustc_interface::queries::Queries>::ongoing_codegen
16: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
17: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
18: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
19: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>> Happening here: |
Are we trying to cast |
I didn't think so, and the comments say we cast references first to pointers. |
Based on the error message, it sounds like we're trying to do something illegal with |
Adding this assertion seems to pre-empt the later error: diff --git a/dynamic_instrumentation/src/point/cast.rs b/dynamic_instrumentation/src/point/cast.rs
index 4b5db5fa..25799dba 100644
--- a/dynamic_instrumentation/src/point/cast.rs
+++ b/dynamic_instrumentation/src/point/cast.rs
@@ -29,6 +29,12 @@ pub fn cast_ptr_to_usize<'tcx>(
let arg_ty = arg.inner().ty(locals, tcx);
+ assert!(!arg_ty.is_array_slice(),
+ "{:?}: {:?} is a slice ptr",
+ arg,
+ arg_ty
+ );
+
let ptr = match arg {
// If we were given an address as a usize, no conversion is necessary
InstrumentationArg::Op(ArgKind::AddressUsize(_arg)) => {iff Is it sufficient for instrumentation to only trace scalar accesses? If so, we can add this assertion and also skip tracing these values when collecting instrumentation points. |
It would be nice to keep instrumenting slice pointers, just in case. You could have it cast |
Do we need to track both originally raw fat pointers and ones that originally were non-raw fat pointers (e.x. slices)? |
I'm not sure why this broke during the update, though, as I would've thought this was an error previously, too. |
… but now we get errors cast fat ptrs to `usize`.
…nst [(); 0]`, an opaque ptr.
I managed to fix the fat ptr to I haven't updated the snapshot yet as it's quite noisy since changing the MIR length (from |
Why |
I believe it's because |
Does that apply here? If we're immediately casting to usize, then this pointer type won't appear in any FFI signatures. And even if we push the cast into the runtime library, calls into the runtime are ordinary Rust calls, not FFI calls. |
It might not, but I wanted to err on the safe side as it doesn't really matter which opaque pointer type we pick. If a bunch of other Rust code uses this, too, I thought why not copy it. I know they used to recommend using a never type (an uninhabitable enum), but there were concerns with that over UB, so now the recommendation is an empty array. |
Works on |
Supercedes #513.
I kept behavior identical (at least I meant to) during this update, even if it may make more sense to relax a
match
or avoid an.unwrap()
now. We can fix those later if we determine it is correct to do so. These places I marked withTODO
s.I fixed almost all of the errors that came up with upgrading
rustc
; many were similar/the same to #513, but there are a few left inc2rust-analyze
that I was unsure how to handle. Someenum
s got more variants, and I'm not sure how we should handle those inmatch
es, as that's new behavior. @spernsteiner, if you can help with those, that'd be great!