Uh oh!
There was an error while loading. Please reload this page.
Document and update i686 triples - #31632
Conversation
Keep track of differences between Clang and rust choices about default CPUs for 32-bit x86 targets.
Try to be consistently replicate Clang default CPU for i686 triples.
rust-highfive
commented
Feb 13, 2016
(rust_highfive has picked a reviewer for you, use r? to override) |
alexcrichton
commented
Feb 13, 2016
MagaTailor
commented
Feb 13, 2016
@dhuseby Either way, to avoid any potential user disappointment, the current BSD stage0 snapshot was probably built with the old codegen settings and won't run on the newly supported "i686" systems. |
ranma42
commented
Feb 14, 2016
I reproduced locally the failure in #31646. This comparison from ifletOk(mut x) = "3.1415".parse::<f64>(){assert_eq!(8.1415,{ x += 5.0; x });}fails because the 1e17: dd 4424 5c fldl 0x5c(%esp) ; load the result of parse 1e1b: d8 86 a7 200000 fadds 0x20a7(%esi) ; add 5.0 from memory 1e21: dd 542410 fstl 0x10(%esp) ; store the result 1e25: 8d 442410lea0x10(%esp),%eax 1e29: 894424 4c mov %eax,0x4c(%esp) 1e2d: 8d 86 cf 200000lea0x20cf(%esi),%eax 1e33: 89442450mov %eax,0x50(%esp) 1e37: dd 86 9f 200000 fldl 0x209f(%esi) ; load 8.1415 1e3d: d9 c9 fxch %st(1) ; exchange the two top elements of the FP stack (why???) 1e3f: da e9 fucompp ; compare the two top elements and pop bothIt is possible to fix this in several ways:
Since it does not look like the purpose of the test was to check for the rounding behaviour, I think that the test should be fixed/made more robust. |
hanna-kruppe
commented
Feb 14, 2016
This shouldn't be the only test that fails. Somehow you need to deal with this if you want a non-SSE2 target. In fact, the discussion of this problem prompted some platforms being changed to a pentium4 base CPU (though I don't know if 32 bit Darwin was among them or if it was already "yonah"). You're gonna have to deal with this somehow. The simplest possibility would be to disable the fast path on 32 bit Darwin, though this is a significant performance regression (at least an order of magnitude or two IIRC, there are float parsing benchmarks in |
bors
commented
Feb 14, 2016
⌛ Testing commit 8c840ee with merge ec1f6c7... |
bors
commented
Feb 14, 2016
💔 Test failed - auto-mac-32-opt |
| let mut base = super::apple_base::opts(); | ||
| base.cpu = "yonah".to_string(); | ||
| // Use i686 as default CPU. Clang uses the same default. | ||
| base.cpu = "i686".to_string(); |
There was a problem hiding this comment.
According to the commit message that made this a yonah
Use more specific target CPUs on Darwin
Macs don't come with anything older than a Yonah (32bit) or Core2 (64bit), so we can default to those targets. Clang does the same.
I’m not sure why clang would change their default, but macs not existing with pre-yonah hardware seems like a pretty good reason to just use a yonah.
cc @dotdash
There was a problem hiding this comment.
See my comment above: Clang defaults to yonah on i386-apple-darwin, but not on i686-apple-darwin.
There was a problem hiding this comment.
@ranma42 but if there can’t possibly be such a combination of darwin+x86 which uses anything pre-yonah, why bother (EDIT: or, rather, restrict ourselves to) targeting a decade-older CPU?
There was a problem hiding this comment.
@ranma42 Hm, where does clang do that distinction? Did you check the code or is there a command I could use to reproduce/check this (without owning a Mac that is ;-))
There was a problem hiding this comment.
Nevermind, found the command in the other PR.
There was a problem hiding this comment.
So if I'm reading the code correctly, there's some special handling for Darwin that disables the automatic CPU selection for any x86 target except for the i386 one. I wonder whether that's actually intentional.
There was a problem hiding this comment.
@nagisa I do not know why Clang restricts itself to a decade-older CPU; we are about to do it in order to be consistent with Clang. I agree with you that it is surprising to have a sub-optimal default on Mac and that is the reason why I was suggesting to provide an i386-apple-darwin triple as default target for 32-bit Mac.
There was a problem hiding this comment.
Clang in this regard seems... somewhat inconsistent? At the very least it seems fine to leave this as-is and perhaps document the oddity (to allow this PR to land)
ranma42
commented
Feb 14, 2016
@rkruppe I confirm that |
hanna-kruppe
commented
Feb 14, 2016
I'm of two minds regarding fiddling with the FPU control word. On the one hand, it's nice to not leave the performance on the table. On the other hand, it's a very low level trick that has clear disadvantages especially when the target does have SSE2 (among other things, it's slightly slower, might inhibit compiler optimizations, and might break if optimizations get better). On the gripping hand, if we had a way to guarantee that this code path is only taken on targets without SSE2, even as target specs evolve, then I'd feel a lot better about it. |
ranma42
commented
Feb 14, 2016
It might be possible to only touch the FPU control word on |
hanna-kruppe
commented
Feb 14, 2016
Wait, |
ranma42
commented
Feb 14, 2016
I should mention that LLVM does a similar fiddling with the control word when casting floating point types to integer in order to ensure truncation (see the lines after 22872 in |
hanna-kruppe
commented
Feb 14, 2016
Aw, |
ranma42
commented
Feb 15, 2016
It does not work yet ;) |
nagisa
commented
Feb 16, 2016
Note, that IMHO claiming to follow “what Clang does” is a really brittle way forward. We should…
|
ranma42
commented
Feb 16, 2016
I think it would be convenient if the meaning of |
nagisa
commented
Feb 16, 2016
Internals forum would be a good place. |
alexcrichton
commented
Mar 8, 2016
Closing due to inactivity, but feel free to resubmit with the tests fixed! |
They now (should) match the behaviour of Clang and there is a brief comment in each documenting this.
As per discussion in #31110