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

Update to rust master (LLVM 8.0) #115

Closed
wants to merge 51 commits into from
Closed

Update to rust master (LLVM 8.0) #115

wants to merge 51 commits into from

Conversation

TimNN
Copy link

@TimNN TimNN commented Oct 28, 2018

Better diff of the changes.

This PR contains all the patches (somewhat cleaned up) that I've been using to test compiling stock libcore.

With this PR, I can compile stock libcore with all -C opt-levels except 1 (that is, with 0, 2, 3, s and z).

Without Boats and others added 30 commits August 20, 2018 20:18
This script invokes the gdbgui graphical GDB front-end
with the Rust pretty printers loaded. The script does not install
gdbgui, that must be done manually.
Add some more wording to module documentation regarding how
`Arc::clone()` works, as some users have assumed cloning Arc's
to work via dereferencing to inner value as follows:

    use std::sync::Arc;

    let myarc = Arc::new(1);
    let myarcref = myarc.clone();

    assert!(1 == myarcref);

Instead of the actual mechanic of referencing the existing
Arc value:

    use std::sync::Arg;

    let myarc = Arc::new(1);
    let myarcref = myarc.clone();

    assert!(myarcref == &myarc); // not sure if assert could assert this
    in the real world
Make it clearer that `Arc::clone()` in fact creates a whole new
Arc with the internal pointer pointing to the same location as
the source Arc.
flip1995 and others added 10 commits September 1, 2018 17:43
Rollup of 9 pull requests

Successful merges:

 - rust-lang#53076 (set cfg(rustdoc) when rustdoc is running on a crate)
 - rust-lang#53622 (cleanup: Add main functions to some UI tests)
 - rust-lang#53769 (Also link Clippy repo in the CONTRIBUTING.md file)
 - rust-lang#53774 (Add rust-gdbgui script.)
 - rust-lang#53781 (bench: libcore: fix build failure of any.rs benchmark (use "dyn Any"))
 - rust-lang#53782 (Make Arc cloning mechanics clearer in module docs)
 - rust-lang#53790 (Add regression test for issue rust-lang#52060)
 - rust-lang#53801 (Prevent duplicated impl on foreign types)
 - rust-lang#53850 (Nuke the `const_to_allocation` query)
…oats

Add Error::source method per RFC 2504.

This implements part of RFC 2504.

* Adds `Error::source`, a replacement for `Error::cause` with the "right" signature, which will be instantly stable.
* Deprecates `Error::cause` in 1.33 (this choice was based on the precedent in rust-lang#52994, which we haven't finalized).
* Redefines `Error::cause` to delegate to `Error::source` (the delegation can only go in this direction, not the other).

@rfcbot fcp merge
refactor match guard

This is the first step to implement RFC 2294: if-let-guard. Tracking issue: rust-lang#51114

The second step should be introducing another variant `IfLet` in the Guard enum. I separated them into 2 PRs for the convenience of reviewers.

r? @petrochenkov
Various small diagnostic and code clean up

 - Point at def span on incorrect `panic` or `oom` function
 - Use structured suggestion instead of note for `+=` that can be performed on a dereference of the left binding
 - Small code formatting cleanup
Fix of bug introduced by rust-lang#53762 (tool_lints)

Before implementing backwards compat for tool lints, the `Tool` case when parsing cmdline lints was unreachable. This changed with rust-lang#53762.

This fix is needed for rls test-pass. (@nrc)

r? @Manishearth
@TimNN TimNN changed the title Update to rust master Update to rust master (LLVM 8.0) Oct 28, 2018
@TimNN
Copy link
Author

TimNN commented Oct 28, 2018

I fixed the issue introduced while rebasing (see #92 (comment)) and can now indeed compile stock libcore for every optimization level except -O1. Note that I'm using a target specification for the atmega32u4.

@shepmaster
Copy link
Member

Note that we are unlikely to actually merge this — we tend to just rebase and force-push master since the project as a whole is in such an unstable state. This helps keep the master branch closer to the final PR(s) that we will eventually make.

@shepmaster
Copy link
Member

I see there's some LLVM submodule updates — have all of those changes been isolated into some state to be submitted into LLVM master? @dylanmckay can push directly to LLVM, as I understand it, so once we have PRs and tests they can start being upstreamed.

@TimNN
Copy link
Author

TimNN commented Oct 28, 2018

Note that we are unlikely to actually merge this — we tend to just rebase and force-push master

Sure, that's fine.

I see there's some LLVM submodule updates — have all of those changes been isolated into some state to be submitted into LLVM master?

There are currently five independent patches in separate commits, each to fix one issue reported in this repo. Some are published on reviews.llvm.org. Which issue / review number is linked from the individual commit messages.

I believe that the three AVR specific patches can be more or less submitted as-is, although they should be reviewed by someone with more LLVM knowledge.

The two general LLVM patches (which are also the ones published on reviews.llvm.org) I'm not really sure about. D53485 can probably submitted as-is, although it may not cover all the cases (see my comments in the review). D53106 is more complex, and would require some careful review from LLVM people, I believe.

@TimNN
Copy link
Author

TimNN commented Nov 1, 2018

So, today I managed to actually compile and flash a program (that would blink SOS on panic) to an Arduino Leonardo 🎉.

There appear to be some outstanding issues (missing things from compiler_builtins1, some LLVM issues2), but using the following worked around them:

[profile.release]
panic = "abort" 
codegen-units = 1
lto = true

1: some symbols are missing (the most serious ones are probably 32 bit shifts), another instance of "ran out of registers" when attempting to implement 128 division, and likely some incorrect calling conventions.
2: Compiling with LTO and multiple codegen units triggered an Assertion failed: (CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!"), function getCast, file lib/IR/Constants.cpp, line 1512.

@dylanmckay
Copy link
Member

Wow, this is great! I mean, really great! Thanks @TimNN

Thanks for [adding support for the program memory data layout field])34e01a2), now I don't have to!

Also, I'm going to be pretty inactive the next two weeks or so, exam period. I have no problems delegating commit decisions (like whether this is ready to be force-pushed to avr-support) to pair of you, if you both are in agreement. I've just verified, and yes @shepmaster has full write access to all repositories in the organisation. Also, I still will be checking GH from time-to-time but if something's important feel free to hit me up at [email protected] and I'll see it straight away.

I believe that the three AVR specific patches can be more or less submitted as-is, although they should be reviewed by someone with more LLVM knowledge.

I can do that, although it'll be in 2~weeks. I guess, we have to maintain a custom fork anyway so long as D53485 and D53106 haven't been committed. Notably, one of those does not currently have a reviewer assigned to it.

@dylanmckay
Copy link
Member

So, today I managed to actually compile and flash a program (that would blink SOS on panic) to an Arduino Leonardo tada.

(that would blink SOS on panic)

That's so much cooler than my lame loop { }. I think we need a rustc -C panic=sos. I expect patches by tomorrow 😛

some symbols are missing (the most serious ones are probably 32 bit shifts)

That's one particularly curly bug, described at avr-llvm/llvm#163.

@dylanmckay
Copy link
Member

Raised #116 to track all the LLVM patches to be upstreamed. Assigned to myself.

@TimNN
Copy link
Author

TimNN commented Nov 2, 2018

That's one particularly curly bug, described at avr-llvm/llvm#163.

Note that by now, it is extremely easy to add the missing symbols to compiler_builtins: It requires about 20 lines of glue-code and 0 lines of actual implementation. I'll open a PR there.

@shepmaster
Copy link
Member

I got enough stuff compiling again that my pure Rust (and a tiny bit of assembly) code with blinking the LED and two-way serial communication is back up and running.

Next will be checking the official AVR blink and then ensuring the two branches have the same interesting commits.

@shepmaster
Copy link
Member

I've pushed up the forked LLVM and force-pushed this code (more-or-less) to the avr-support branch, thanks so much!

@shepmaster shepmaster closed this Nov 3, 2018
@TimNN TimNN deleted the avr branch August 7, 2022 17:52
@TimNN TimNN restored the avr branch August 7, 2022 17:57
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.