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

Libc on osx now requires rust 1.24.0+ #1232

Closed
erickt opened this issue Jan 29, 2019 · 6 comments
Closed

Libc on osx now requires rust 1.24.0+ #1232

erickt opened this issue Jan 29, 2019 · 6 comments

Comments

@erickt
Copy link
Contributor

erickt commented Jan 29, 2019

The rand crate tries to maintain compatibility with rust 1.22.0, but a recent release of libc now implicitly requires 1.24.0 on osx due to this patch: #1212, which uses a constant function that was stablized in 1.24. It appears that the Travis config is trying to maintain compatibility with 1.13, but this test only runs on Linux.

Now I personally don't care what is the minimum version you want to support, but given how libc is now the most actively used dependency, you drive the minimum version of a lot of the ecosystem, so would it be possible to at least document this requirement, or setup some more test targets to make sure this doesn't happen again accidentally?

@gnzlbg
Copy link
Contributor

gnzlbg commented Jan 29, 2019

@erickt thank you for the report and sorry for the inconvenience.

We should:

  • detect whether the Rust version is >= 1.24 in our build.rs file, and define a cfg flag that is used to white-list const fns in those cases. The functions can be exposed as non-const fn in older Rust versions (or not at all).

  • run cargo build for nightly, beta, and stable, on all build bots using Rust 1.13 as the stable Rust version

I can look into implementing both of these things.

gnzlbg added a commit to gnzlbg/libc that referenced this issue Feb 7, 2019
This PR fixes the build on all platforms and all Rust version down to the
minimum Rust version supported by libc: Rust 1.13.0.

The `build.rs` is extended with logic to detect the newer Rust features used by
`libc` since Rust 1.13.0:

* Rust 1.19.0: `untagged_unions`. APIs using untagged unions are gated on
  `cfg(libc_unions)` and not available on older Rust versions.

* Rust 1.25.0: `repr(align)`. Because `repr(align)` cannot be parsed by older
  Rust versions, all uses of `repr(align)` are split into `align.rs` and
  `no_align.rs` modules, which are gated on the `cfg(libc_align)` at the top
  level. These modules sometimes contain macros that are expanded at the top
  level to avoid privacy issues (`pub(crate)` is not available in older Rust
  versions). Closes rust-lang#1242 .

* Rust : `const` `mem::size_of`. These uses are worked around with hardcoded
  constants on older Rust versions.

Also, `repr(packed)` structs cannot automatically `derive()` some traits like
`Debug`. These have been moved into `s_no_extra_traits!` and the lint of missing
`Debug` implementations on public items is silenced for these. We can manually
implement the `extra_traits` for these in a follow up PR. This is tracked in

Since `f64::to_bits` is not available in older Rust versions, its usage
has been replaced with a `transmute` to an `u64` which is what that method
does under the hood.

Closes rust-lang#1232 .
gnzlbg added a commit to gnzlbg/libc that referenced this issue Feb 7, 2019
This PR fixes the build on all platforms and all Rust version down to the
minimum Rust version supported by libc: Rust 1.13.0.

The `build.rs` is extended with logic to detect the newer Rust features used by
`libc` since Rust 1.13.0:

* Rust 1.19.0: `untagged_unions`. APIs using untagged unions are gated on
  `cfg(libc_unions)` and not available on older Rust versions.

* Rust 1.25.0: `repr(align)`. Because `repr(align)` cannot be parsed by older
  Rust versions, all uses of `repr(align)` are split into `align.rs` and
  `no_align.rs` modules, which are gated on the `cfg(libc_align)` at the top
  level. These modules sometimes contain macros that are expanded at the top
  level to avoid privacy issues (`pub(crate)` is not available in older Rust
  versions). Closes rust-lang#1242 .

* Rust : `const` `mem::size_of`. These uses are worked around with hardcoded
  constants on older Rust versions.

Also, `repr(packed)` structs cannot automatically `derive()` some traits like
`Debug`. These have been moved into `s_no_extra_traits!` and the lint of missing
`Debug` implementations on public items is silenced for these. We can manually
implement the `extra_traits` for these in a follow up PR. This is tracked in

Since `f64::to_bits` is not available in older Rust versions, its usage
has been replaced with a `transmute` to an `u64` which is what that method
does under the hood.

Closes rust-lang#1232 .
gnzlbg added a commit to gnzlbg/libc that referenced this issue Feb 7, 2019
This PR fixes the build on all platforms and all Rust version down to the
minimum Rust version supported by libc: Rust 1.13.0.

The `build.rs` is extended with logic to detect the newer Rust features used by
`libc` since Rust 1.13.0:

* Rust 1.19.0: `untagged_unions`. APIs using untagged unions are gated on
  `cfg(libc_unions)` and not available on older Rust versions.

* Rust 1.25.0: `repr(align)`. Because `repr(align)` cannot be parsed by older
  Rust versions, all uses of `repr(align)` are split into `align.rs` and
  `no_align.rs` modules, which are gated on the `cfg(libc_align)` at the top
  level. These modules sometimes contain macros that are expanded at the top
  level to avoid privacy issues (`pub(crate)` is not available in older Rust
  versions). Closes rust-lang#1242 .

* Rust : `const` `mem::size_of`. These uses are worked around with hardcoded
  constants on older Rust versions.

Also, `repr(packed)` structs cannot automatically `derive()` some traits like
`Debug`. These have been moved into `s_no_extra_traits!` and the lint of missing
`Debug` implementations on public items is silenced for these. We can manually
implement the `extra_traits` for these in a follow up PR. This is tracked
in rust-lang#1243. Also, `extra_traits` does not enable `align` manually anymore.

Since `f64::to_bits` is not available in older Rust versions, its usage
has been replaced with a `transmute` to an `u64` which is what that method
does under the hood.

Closes rust-lang#1232 .
gnzlbg added a commit to gnzlbg/libc that referenced this issue Feb 7, 2019
This PR fixes the build on all platforms and all Rust version down to the
minimum Rust version supported by libc: Rust 1.13.0.

The `build.rs` is extended with logic to detect the newer Rust features used by
`libc` since Rust 1.13.0:

* Rust 1.19.0: `untagged_unions`. APIs using untagged unions are gated on
  `cfg(libc_unions)` and not available on older Rust versions.

* Rust 1.25.0: `repr(align)`. Because `repr(align)` cannot be parsed by older
  Rust versions, all uses of `repr(align)` are split into `align.rs` and
  `no_align.rs` modules, which are gated on the `cfg(libc_align)` at the top
  level. These modules sometimes contain macros that are expanded at the top
  level to avoid privacy issues (`pub(crate)` is not available in older Rust
  versions). Closes rust-lang#1242 .

* Rust : `const` `mem::size_of`. These uses are worked around with hardcoded
  constants on older Rust versions.

Also, `repr(packed)` structs cannot automatically `derive()` some traits like
`Debug`. These have been moved into `s_no_extra_traits!` and the lint of missing
`Debug` implementations on public items is silenced for these. We can manually
implement the `extra_traits` for these in a follow up PR. This is tracked
in rust-lang#1243. Also, `extra_traits` does not enable `align` manually anymore.

Since `f64::to_bits` is not available in older Rust versions, its usage
has been replaced with a `transmute` to an `u64` which is what that method
does under the hood.

Closes rust-lang#1232 .
gnzlbg added a commit to gnzlbg/libc that referenced this issue Feb 7, 2019
This PR fixes the build on all platforms and all Rust version down to the
minimum Rust version supported by libc: Rust 1.13.0.

The `build.rs` is extended with logic to detect the newer Rust features used by
`libc` since Rust 1.13.0:

* Rust 1.19.0: `untagged_unions`. APIs using untagged unions are gated on
  `cfg(libc_unions)` and not available on older Rust versions.

* Rust 1.25.0: `repr(align)`. Because `repr(align)` cannot be parsed by older
  Rust versions, all uses of `repr(align)` are split into `align.rs` and
  `no_align.rs` modules, which are gated on the `cfg(libc_align)` at the top
  level. These modules sometimes contain macros that are expanded at the top
  level to avoid privacy issues (`pub(crate)` is not available in older Rust
  versions). Closes rust-lang#1242 .

* Rust : `const` `mem::size_of`. These uses are worked around with hardcoded
  constants on older Rust versions.

Also, `repr(packed)` structs cannot automatically `derive()` some traits like
`Debug`. These have been moved into `s_no_extra_traits!` and the lint of missing
`Debug` implementations on public items is silenced for these. We can manually
implement the `extra_traits` for these in a follow up PR. This is tracked
in rust-lang#1243. Also, `extra_traits` does not enable `align` manually anymore.

Since `f64::to_bits` is not available in older Rust versions, its usage
has been replaced with a `transmute` to an `u64` which is what that method
does under the hood.

Closes rust-lang#1232 .
@bors bors closed this as completed in a17a91c Feb 8, 2019
@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 8, 2019

cc @Stebalien @erickt libc mater builds again down to Rust 1.13. There are a couple of PRs with fixes in the queue. Once those are merged I'll do a new release.

@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 8, 2019

I forgot to mention what I wanted to mention. Would you be able to test if the master branch solves your issues ? (e.g. by creating a PR to your projects that use the libc master branch and letting your CI run?).

@dhardy
Copy link

dhardy commented Feb 15, 2019

We still appear to have a problem using Rustc 1.22 on OSX: https://travis-ci.org/rust-random/rand/jobs/493719761 (use of mem::size_of as a const fn). Is this because the relevant changes are not in a release yet?

I don't have a Mac platform to test with myself.
See also: rust-random/rand#719

@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 15, 2019

Is this because the relevant changes are not in a release yet?

Yes. The changes are on master, and a release is blocked on the affected parties testing that master does not have these issues.

@dhardy
Copy link

dhardy commented Feb 15, 2019

Okay, I forced Travis to use libc master via a patch section. The test now succeeds on OSX with Rustc 1.22.0 where it didn't before. So seems to have fixed it.

Edit: see this PR. I will remove the extra commit later; it's just for testing.

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

No branches or pull requests

3 participants