-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Fix ui constant tests for big-endian platforms #106047
Conversation
r? @oli-obk (rustbot has picked a reviewer for you, use r? to override) |
I think I am fine with the general approach, but it seems very fragile. Without a big-endian CI runner this is bound to break again soon, in particular since there is zero documentation that even explains why we use such odd constants, or why we have these normalizing rules. |
I can certainly add some comments to why the constants are chosen - there is actually already some precedent like:
in ub-enum.rs. As to CI, I agree - it would be great to have CI running on a BE system. I'd be happy provide access to a s390x machine and/or set up CI infrastructure myself. Not sure if this would be integrated into the main CI machinery or run stand-alone - whatever the Rust community prefers. Taking a different approach - the problem is really just the "raw byte" dumps, which are provided as extra note diagnostics. Maybe it would make sense to have some more generic |
eaef4fa
to
42b061f
Compare
For reference, I've now updated the patch to follow this approach, which significantly reduces the amount of changes needed to the test cases, and should make it much less fragile. This basically consists of adding:
to all affected test case file, and updating the expected outputs. The only change apart from this is to
depending on which byte of What do you think? |
FYI @Mark-Simulacrum just pointed me to this alternative solution that I wasn't aware of: #104135. Either way would work for me ... |
42b061f
to
2cc63df
Compare
We want to have tests covering that output though. There is a bunch of subtle logic for the pointer printing and things like that which needs testing. What we could do is to disable the raw byte dump in the regular const tests (or use aggressive normalization that mostly removes the raw byte dumps), and then have little-endian-only tests that check the raw byte dumps. I'd be fine with such an approach. But I don't like the approach this PR takes right now, since it drastically reduces the test coverage of our raw byte printing.
I don't think third-party runners are a possibility. This would have to somehow run on our existing runners, e.g. via qemu. The infra team would know if we have the CI capacity for that.
The problem with that is -- how is a contributor supposed to be able to update those reference files? Basically nobody will be able to just |
2cc63df
to
326780f
Compare
I've tried to implement that approach by adding a new
It seems to me it should be possible to "bless" files for another target simply via a cross-compiler. I tried a straightforward approach using This seems a pity, as those tests likely do not actually use anything from those special crates, in particular since they are compile-time tests anyway. I'm wondering if there couldn't be a way to enable cross-target compile-time tests using some form of a stripped-down |
326780f
to
f906a20
Compare
You mean for check-pass tests, since we don't have to actually link/run them? Yeah that is true in principle, but in practice our cross-build support needs a target toolchain pretty early, so a bunch of work would be required to make that happen. Also having to run So I think for now this is a reasonable trade-off. |
@@ -1,5 +1,7 @@ | |||
// ignore-tidy-linelength | |||
// stderr-per-bitwidth |
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.
Can you check which of these files even still need stderr-per-bitwidth? I assume some of them will have bitwidth-independent output now.
You might have to also nomalize the alloc-id part of the alloc dumps for that, but that seems worth the trade-off to me.
LGTM, modulo ideally even making these tests bitwidth-independent. @oli-obk should also approve though. |
A number of tests under ui/const-ptr and ui/consts are currently failing on big-endian platforms as the binary encoding of some constants is hard-coded in the stderr test files. Fix this by providing a normalize-stderr-test rule that strips out the raw bytes hex dump, so the comparison can be done in an endianness-independent manner. Note that in most cases, this means the tests are now also independent of word size, so the 32bit and 64bit cases can be re-unified. To keep tests that verify the details of those raw bytes dumps, a new test case raw-bytes.rs performs the tests where the hex dumps were stripped out a second time, but only on little- endian platforms. In addition, src/test/ui/const-ptr/forbidden_slices.rs exposes an endian-specific difference in this diagnostic output: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean depending on which byte of D0 is not a boolean value (0 or 1). Fixed this by choosing a value of D0 that differs from 0 or 1 in all bytes. Fixes part of rust-lang#105383.
f906a20
to
73e7207
Compare
I had to be a bit more thorough in removing all raw byte dumps (including those with alloc-ids), and normalize size/align values in these output lines:
With that done, indeed for most of the tests, the 32bit and 64bit output files are now identical and can be re-unified. Patch updated accordingly. The two remaining tests where
|
We could normalize As long as we still have some tests that ensure that we print these numbers with as many leading 0s as matches the bitwidths of the current target. |
It's not always exactly 0, it's sometimes other (small) integers. The difference is always the number of leading zeros though.
Sure. I guess that could be done in another patch? Seems not directly related to this one. |
I seem to recall we are normalizing away leading
Sure, fair. Thanks for getting rid of some of the stderr-per-bitwidth, that already helps! |
@bors r+ rollup This is a good step, let's land it and iterate in follow ups |
…r=oli-obk Fix ui constant tests for big-endian platforms A number of tests under ui/const-ptr and ui/consts are currently failing on big-endian platforms as the binary encoding of some constants is hard-coded in the stderr test files. Fix this by a combination of two types of changes: - Where possible (i.e. where the particular value of a constant does not affect the purpose of the test), choose constant values that have the same encoding on big- and little-endian platforms. - Where this is not possible, provide a normalize-stderr-test rule that transforms the printed big-endian encoding of such constants into the corresponding little-endian form. Fixes part of rust-lang#105383.
…r=oli-obk Fix ui constant tests for big-endian platforms A number of tests under ui/const-ptr and ui/consts are currently failing on big-endian platforms as the binary encoding of some constants is hard-coded in the stderr test files. Fix this by a combination of two types of changes: - Where possible (i.e. where the particular value of a constant does not affect the purpose of the test), choose constant values that have the same encoding on big- and little-endian platforms. - Where this is not possible, provide a normalize-stderr-test rule that transforms the printed big-endian encoding of such constants into the corresponding little-endian form. Fixes part of rust-lang#105383.
…fee1-dead Rollup of 10 pull requests Successful merges: - rust-lang#105292 (Change a commit_if_ok call to probe) - rust-lang#105655 (Remove invalid case for mutable borrow suggestion) - rust-lang#106047 (Fix ui constant tests for big-endian platforms) - rust-lang#106061 (Enable Shadow Call Stack for Fuchsia on AArch64) - rust-lang#106164 (Move `check_region_obligations_and_report_errors` to `TypeErrCtxt`) - rust-lang#106291 (Fix incorrect suggestion for extra `&` in pattern) - rust-lang#106389 (Simplify some canonical type alias names) - rust-lang#106468 (Use FxIndexSet when updating obligation causes in `adjust_fulfillment_errors_for_expr_obligation`) - rust-lang#106549 (Use fmt named parameters in rustc_borrowck) - rust-lang#106614 (error-code docs improvements (No. 2)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
A number of tests under ui/const-ptr and ui/consts are currently failing on big-endian platforms as the binary encoding of some constants is hard-coded in the stderr test files.
Fix this by a combination of two types of changes:
Where possible (i.e. where the particular value of a constant does not affect the purpose of the test), choose constant values that have the same encoding on big- and little-endian platforms.
Where this is not possible, provide a normalize-stderr-test rule that transforms the printed big-endian encoding of such constants into the corresponding little-endian form.
Fixes part of #105383.