Skip to content
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

Rustup to "rustc 1.59.0-nightly (78fd0f633 2021-12-29)" #112

Merged
merged 34 commits into from
Dec 30, 2021

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Dec 30, 2021

There were a couple of conflicts I had to resolve. If you want I can do a PR to sync it the other way around too.

cjgillot and others added 28 commits September 30, 2021 20:22
Before this commit all vtables would have the same name "vtable" in
debuginfo. Now they get a name that identifies the implementing type
and the trait that is being implemented.
…esleywiser

Create more accurate debuginfo for vtables.

Before this PR all vtables would have the same name (`"vtable"`) in debuginfo. Now they get an unambiguous name that identifies the implementing type and the trait that is being implemented.

This is only one of several possible improvements:
- This PR describes vtables as arrays of `*const u8` pointers. It would nice to describe them as structs where function pointer is represented by a field with a name indicative of the method it maps to. However, this requires coming up with a naming scheme that avoids clashes between methods with the same name (which is possible if the vtable contains multiple traits).
- The PR does not update the debuginfo we generate for the vtable-pointer field in a fat `dyn` pointer. Right now there does not seem to be an easy way of getting ahold of a vtable-layout without also knowing the concrete self-type of a trait object.

r? `@wesleywiser`
As per the libs team decision in #58935.

Closes #58935
This commit adds LLVM Control Flow Integrity (CFI) support to the Rust
compiler. It initially provides forward-edge control flow protection for
Rust-compiled code only by aggregating function pointers in groups
identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled
code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code
share the same virtual address space) will be provided in later work as
part of this project by defining and using compatible type identifiers
(see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e.,
-Clto).
Add LLVM CFI support to the Rust compiler

This PR adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).

Thank you, `@eddyb` and `@pcc,` for all the help!
fix sparc64 ABI for aggregates with floating point members

Fixes #86163
We already use the object crate for generating uncompressed .rmeta
metadata object files. This switches the generation of compressed
.rustc object files to use the object crate as well. These have
slightly different requirements in that .rmeta should be completely
excluded from any final compilation artifacts, while .rustc should
be part of shared objects, but not loaded into memory.

The primary motivation for this change is #90326: In LLVM 14, the
current way of setting section flags (and in particular, preventing
the setting of SHF_ALLOC) will no longer work. There are other ways
we could work around this, but switching to the object crate seems
like the most elegant, as we already use it for .rmeta, and as it
makes this independent of the codegen backend. In particular, we
don't need separate handling in codegen_llvm and codegen_gcc.
codegen_cranelift should be able to reuse the implementation as
well, though I have omitted that here, as it is not based on
codegen_ssa.

This change mostly extracts the existing code for .rmeta handling
to allow using it for .rustc as well, and adjust the codegen
infrastructure to handle the metadata object file separately: We
no longer create a backend-specific module for it, and directly
produce the compiled module instead.

This does not fix #90326 by itself yet, as .llvmbc will need to be
handled separately.
Also restricts r8-r14 from being used on Thumb1 targets as per #90736.
Use object crate for .rustc metadata generation

We already use the object crate for generating uncompressed .rmeta
metadata object files. This switches the generation of compressed
.rustc object files to use the object crate as well. These have
slightly different requirements in that .rmeta should be completely
excluded from any final compilation artifacts, while .rustc should
be part of shared objects, but not loaded into memory.

The primary motivation for this change is #90326: In LLVM 14, the
current way of setting section flags (and in particular, preventing
the setting of SHF_ALLOC) will no longer work. There are other ways
we could work around this, but switching to the object crate seems
like the most elegant, as we already use it for .rmeta, and as it
makes this independent of the codegen backend. In particular, we
don't need separate handling in codegen_llvm and codegen_gcc.
codegen_cranelift should be able to reuse the implementation as
well, though I have omitted that here, as it is not based on
codegen_ssa.

This change mostly extracts the existing code for .rmeta handling
to allow using it for .rustc as well, and adjusts the codegen
infrastructure to handle the metadata object file separately: We
no longer create a backend-specific module for it, and directly
produce the compiled module instead.

This does not `fix` #90326 by itself yet, as .llvmbc will need to be
handled separately.

r? `@nagisa`
Remove the reg_thumb register class for asm! on ARM

Also restricts r8-r14 from being used on Thumb1 targets as per #90736.

cc ``@Lokathor``

r? ``@joshtriplett``
They are also removed from the prelude as per the decision in
rust-lang/rust#87228.

stdarch and compiler-builtins are updated to work with the new, stable
asm! and global_asm! macros.
The resulting profile will include the crate name and will be stored in
the `--out-dir` directory.

This implementation makes it convenient to use LLVM time trace together
with cargo, in the contrast to the previous implementation which would
overwrite profiles or store them in `.cargo/registry/..`.
Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`

The resulting profile will include the crate name and will be stored in
the `--out-dir` directory.

This implementation makes it convenient to use LLVM time trace together
with cargo, in the contrast to the previous implementation which would
overwrite profiles or store them in `.cargo/registry/..`.
Remove `SymbolStr`

This was originally proposed in rust-lang/rust#74554 (comment). As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.

Best reviewed one commit at a time.

r? `@oli-obk`
// metadata doesn't get loaded into memory.
let directive = format!(".section {}", section_name);
context.add_top_level_asm(None, &directive);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cg_ssa now has builtin support for writing the dylib metadata object.

Support for portable-simd isn't implemented yet
These only finish in reasonable time with optimizations enabled.

This patch file is copied from cg_clif.
@bjorn3
Copy link
Member Author

bjorn3 commented Dec 30, 2021

Is this pre-existing?

failures:

---- slice::test_is_sorted stdout ----
---- slice::test_is_sorted stderr ----
thread 'main' panicked at 'attempt to create unaligned or null slice', /home/runner/work/rustc_codegen_gcc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/core/src/slice/raw.rs:141:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    slice::test_is_sorted

test result: FAILED. 1381 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 16.79s

error: test failed, to rerun pass '--lib'

@antoyo
Copy link
Contributor

antoyo commented Dec 30, 2021

libcore's test used to all pass. Maybe that's a new test that found a new bug as it previously only ran 1337 tests and this PR runs 1382 tests.

@bjorn3
Copy link
Member Author

bjorn3 commented Dec 30, 2021

Shall I disable it for now?

@antoyo
Copy link
Contributor

antoyo commented Dec 30, 2021

Yes!

@antoyo
Copy link
Contributor

antoyo commented Dec 30, 2021

Thanks! Is this ready to be reviewed and merged?

@bjorn3
Copy link
Member Author

bjorn3 commented Dec 30, 2021

Yes it is.

@antoyo antoyo merged commit 45b82cd into rust-lang:master Dec 30, 2021
@bjorn3 bjorn3 deleted the rustup branch December 30, 2021 18:22
@bjorn3 bjorn3 restored the rustup branch December 30, 2021 18:49
@bjorn3 bjorn3 deleted the rustup branch January 25, 2022 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.