-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Wrong formatting with format_args
#44538
Comments
Actually, it seems to be a more general problem with the alignment at ARM. Since everything was okay a couple of weeks ago, there must be a breaking change in the meantime. |
@werner-matthias this looks like it'll be pretty difficult for someone else to investigate (difficult to reproduce), do you think you can help narrow down the regression range if possible? All target descriptions are in |
Ok this is the range of commits between there. The only thing that looks even slightly suspect there is #44312, @eddyb do you know if that'd affect this? Or maybe if there's bug with rvalue promotion? |
Rvalue promotion works a lot like regular @werner-matthias by "fails to address the correct bytes within |
From the patterns I observed, I would guess that there is an offset of -1. Thus, e.g., instead to address |
If it loads with 2-byte alignment that seems wrong libcore code, since |
ARM has a minimum alignment of 2 (unless it is explicitly deactivated). |
Ah that seems like something rustc doesn't know about. See #44440 - can you try setting that for your target? |
We just added support for global minimum alignment (#44440), but I'm surprised this hasn't come up before! @werner-matthias is this global minimum alignment something we should set for all our ARM targets? Or just the one you're working on? |
IHMO llvm cares about alignment, if the target description is correct, especially the data layout. I use Japaric's target description for ARM. |
From what we've seen this extra property is not in the data layout. |
A wild guess: Could the introduced global minimum alignment be exactly the reason. since it possibly overwrites the architecture's defaults? |
It's not in that range though? My change is capable of breaking things that only worked by accident before. |
Hi @werner-matthias which raspberry pi 1,2 or 3? Could you please paste or link your exact target description? |
Oh actually I think I found it. Looks like raspi 1. You should also add the |
@eddyb I'm not entirely clear on whether this is a bug in Rust, so perhaps we can close? |
triage: P-high Seems like there is something wrong with (our?) target spec. cc @japaric -- what should the target spec be? |
Summary: @werner-matthias has been using this custom target specification and running on a bare metal ARMv6 environment (Raspberry Pi). They had to use the The equivalent target that we support would be
As for the regression that @werner-matthias observed I think that may have been caused by the recent introduction of the "minimum global alignment" option to target specs. My guess is that since @werner-matthias's target spec does not have that option it's probably now defaulting to 1 whereas before llvm was providing it: it probably was 2. I need to confirm this. |
It wouldnt hurt enabling strict-align for arm-unknown-linux-gnueabi(hf), clang does for Armv6 Linux but not for Apple and BSD. I'm not sure if it's strictly required, at least for Linux on the raspi I'm pretty sure it's not. From memory there's some comments in the clang source about but I'm not sure how accurate and up to date they are. I'll try and find a link when I get a minute. |
I found this document in the Linux kernel code -- I don't know how old / valid is though -- and it says that the kernel will (try to) fix unaligned memory access, at some cost, if the bit 1 of
If that bit is set by default on all ARMv6 Linux devices then our current settings won't (or shouldn't) cause crashes. Though there's a performance penalty for having the kernel step in to fix the unaligned memory access.
But would it hurt more than having the kernel fix things? |
Checking further this can't be the cause of the regression because (1) is not in the reported commit range and (2) if min-global-align is missing in the target spec we'll get the (right) alignment value from LLVM, which is what we have always been doing. So no idea about the regression in the custom target spec. |
Sorry I meant to type wouldn't. So I agree we should add it. |
Here's the clang comment I was remembering.
|
The intention of #44440 is only to increase alignment, and only for global symbols, not memory access in general. Targets that don't set min-global-align should not see any effect at all. |
Checking in from the @rust-lang/compiler meeting -- can someone summarize what action on our part is needed, if any? Or is that still undetermined? |
I think this just used to work by accident before. Could you please open a PR for fixing the minimum alignment target spec? |
@nikomatsakis @arielb1 There's no bug in rustc here, the bug was in the out of tree target spec that was used. The take away from some of the discussion though is, we should probably add |
Yeah, I agree. The Cortex-M target already has that feature enabled for correctness (otherwise programs crash) but all the other ARM Linux targets should see perf improvements. I'd be interested in seeing an after vs before RPi benchmark -- just to get an idea of the perf "penalty" the current targets have. |
As discovered in rust-lang#44538 ARMv6 devices may or may not support unaligned memory accesses. ARMv6 Linux *seems* to have no problem with unaligned accesses but this is because the kernel is stepping in to fix each unaligned memory access -- this incurs in a performance penalty. This commit enforces aligned memory accesses on all our in-tree ARM targets that may be used with ARMv6 devices. This should improve performance of Rust programs on ARMv6 devices. For the record, clang also applies this attribute when targeting ARMv6 devices that are not running Darwin or NetBSD.
PR #45094 adds +strict-align to all the ARMv6 targets |
enable strict alignment (+strict-align) on ARMv6 As discovered in rust-lang#44538 ARMv6 devices may or may not support unaligned memory accesses. ARMv6 Linux *seems* to have no problem with unaligned accesses but this is because the kernel is stepping in to fix each unaligned memory access -- this incurs in a performance penalty. This commit enforces aligned memory accesses on all our in-tree ARM targets that may be used with ARMv6 devices. This should improve performance of Rust programs on ARMv6 devices. For the record, clang also applies this attribute when targeting ARMv6 devices that are not running Darwin or NetBSD. closes rust-lang#44538 r? @alexcrichton
Formating yields incorrect result.
I tried this code at a bare metal Raspberry Pi (
no_std
):kprint::fkprint
writes to the frame buffer using theWrite
trait.I expected to see this output:
Instead, the output is:
Meta
I'm using rustc 1.22.0-nightly (dd08c30 2017-09-12) with
xargo
, i.e.,core
is newly built.The text was updated successfully, but these errors were encountered: