fix: build-std on 32 bit arm with 64 bit time - #157609
Conversation
| tv_usec: dur.subsec_micros() as libc::suseconds_t, | ||
| // If building 32 bit GNU platforms with 64 bit time, we need to call into here | ||
| // since `tv_usec` will in that case be an i64 aliased to __suseconds64_t | ||
| tv_usec: (dur.subsec_micros() as libc::suseconds_t).into(), |
There was a problem hiding this comment.
There is no reason to use as libc::suseconds_t if we ignore it anyways
| tv_usec: (dur.subsec_micros() as libc::suseconds_t).into(), | |
| tv_usec: dur.subsec_micros().into(), |
There was a problem hiding this comment.
We can not use .into() directly here since subsec_micros returns an unsigned integer.
dacadfc to
538573a
Compare
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @jhpratt (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
|
Stepping away from reviews temporarily. @rustbot reroll |
|
@bors squash |
This comment has been minimized.
This comment has been minimized.
* fix: build-std on 32 bit arm with 64 bit time The libc crate has support for building with 64 bit time on 32 bit platforms using the `RUST_LIBC_UNSTABLE_GNU_TIME_BITS` environment variable. Convert the tv_usec field to i64 via `into` in this case since `suseconds_t` is still defined as an i32 when this environment variable is set. * Use placeholder as target type This allows us to rely on the compiler to infer the correct target type, mirroring the approach used in `sys/net/connection/socket/solid.rs`.
|
🔨 2 commits were squashed into f846f11. |
538573a to
f846f11
Compare
|
@bors r+ rollup |
…uwer Rollup of 12 pull requests Successful merges: - #160336 (Move attributes out of rustc_hir) - #160715 (ignore tests with the GCC backend if we can't find `libgccjit.so` for the target) - #157609 (fix: build-std on 32 bit arm with 64 bit time) - #160613 (Add regression test for unsized non-last struct field with overlapping impls) - #160658 (miri: implement more restrictive trivial-ABI checks) - #160704 (sort lint names in lint pass declarations) - #160707 (Add regression test for higher ranked fn pointer impl not general enough) - #160713 (Add regression test for #135287) - #160720 (triagebot: add ubiratan to infra-ci) - #160747 (rustc_errors: remove unused code) - #160751 (Add regression test for incremental borrowck ICE with generic const exprs) - #160753 (rustc_lint: remove unused rustc_attrs feature) Failed merges: - #158835 (rustc_passes: lint unused `#[path]` attributes on inline modules)
Rollup merge of #157609 - guoxe:fix_build_std_arm32_gnu_time_bits64, r=Mark-Simulacrum fix: build-std on 32 bit arm with 64 bit time Infer target type of `tv_usec`. The libc crate has support for building with 64 bit time on 32 bit platforms, configurable currently via environment variable or cfg directives. When building using 64 bit time, the tv_usec field will be aliased to `__suseconds64_t` instead of `suseconds_t` causing the `build-std` feature to not be able to build the standard library due to a type mismatch. Adopting the same convention as in https://github.com/rust-lang/rust/blob/1b29cfdbee8ee37333f4b24afb936350eb57e705/library/std/src/sys/net/connection/socket/solid.rs#L151 fixes the issue, supporting 64 bit time on 32 bit arm platforms. Another option would be using cfg attributes for this but from what I can tell there are no existing such attributes for time bits in the std and they would essentially duplicate the ones already present in the libc crate https://github.com/rust-lang/libc/blob/e27c7f1e2b281d7c551e6b394b897b4ff0a230e6/build.rs#L16
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#160336 (Move attributes out of rustc_hir) - rust-lang/rust#160715 (ignore tests with the GCC backend if we can't find `libgccjit.so` for the target) - rust-lang/rust#157609 (fix: build-std on 32 bit arm with 64 bit time) - rust-lang/rust#160613 (Add regression test for unsized non-last struct field with overlapping impls) - rust-lang/rust#160658 (miri: implement more restrictive trivial-ABI checks) - rust-lang/rust#160704 (sort lint names in lint pass declarations) - rust-lang/rust#160707 (Add regression test for higher ranked fn pointer impl not general enough) - rust-lang/rust#160713 (Add regression test for rust-lang/rust#135287) - rust-lang/rust#160720 (triagebot: add ubiratan to infra-ci) - rust-lang/rust#160747 (rustc_errors: remove unused code) - rust-lang/rust#160751 (Add regression test for incremental borrowck ICE with generic const exprs) - rust-lang/rust#160753 (rustc_lint: remove unused rustc_attrs feature) Failed merges: - rust-lang/rust#158835 (rustc_passes: lint unused `#[path]` attributes on inline modules)
Infer target type of
tv_usec.The libc crate has support for building with 64 bit time on 32 bit
platforms, configurable currently via environment variable or cfg directives.
When building using 64 bit time, the tv_usec field will be aliased to
__suseconds64_tinstead ofsuseconds_tcausing thebuild-stdfeature to not be able to build the standard library due to a type mismatch.Adopting the same convention as in
rust/library/std/src/sys/net/connection/socket/solid.rs
Line 151 in 1b29cfd
Another option would be using cfg attributes for this but from what I can tell there are no existing such attributes for time bits in the std and they would essentially duplicate the ones already present in the libc crate https://github.com/rust-lang/libc/blob/e27c7f1e2b281d7c551e6b394b897b4ff0a230e6/build.rs#L16