-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
fs::metadata() crashes on FreeBSD 12 due to layout change in stat.h #42681
Comments
I would like to point a pre-RFC discussion about introducing a way in Rust to permit libc to represent differents layouts per OS version. I think there is need to move forward. |
We discussed this at libs triage today and the conclusion was that this is indeed bad! We would be fine in the very near future adding dynamic detection to do the right thing at runtime. In the long term we decided to see how @semarie's rfc plays out. |
Is there a quick fix for this? This stops me from building a few (probably many) crates.. |
Here's a temporary fix for those who can't wait |
@johalun Thanks for a workaround ! 🍺 |
Hi! I prepared a patch to support the two breaking changes in FreeBSD 12.x (see rust-lang/libc#721). I tested them successfully on FreeBSD 10.3 and FreeBSD 12.0, using the testsuites of However, I'm not sure my solution around |
In FreeBSD 12.x, several ABI were changed in an incompatible way: * Inodes were changed from 32-bit to 64-bit. This affects `struct stat` and `struct dirent` structures in Rust libc. https://svnweb.freebsd.org/base?view=revision&revision=318736 * Time-related members of `struct kevent` were changed to 64-bit. Again, this affects the definition of the same structure in Rust libc. https://svnweb.freebsd.org/base?view=revision&revision=320043 Currently, a Rust program compiled on FreeBSD 11.x will work on FreeBSD 12.x thanks to symbol versioning. Unfortunately, a program compiled on FreeBSD 12.x will break. Until Rust gains support for target versions, we need to detect the correct structures to use, based on the build host. This won't make it possible to build a FreeBSD 11 executable on a FreeBSD 12 host, but it is good enough when the build and target hosts are the same. This patch introduces a build script which uses freebsd-version(1) to detect the version. When it is 12 or more, it defines the `freebsd12_abi` feature. Modules in `src/unix/bsd/freebsdlike/freebsd` were reorganized. They are now split based on this ABI version instead of the target architecture. For instance, `struct stat` is defined once in `freebsd12.rs` for all architectures. `struct kevent` grew a new member, `ext` in FreeBSD 12.x. To avoid too much pain to users of this structure, both flavors (`freebsd11.rs` and `freebsd12.rs`) now have the `ext` member. In the case of `freebsd11`, this is a 0-length array. To help initialize the structure, one can use the `libc::KEVENT_EXT_ZEROED` constant. Fixes rust-lang/rust#42681.
@dumbbell there's an ongoing discussion about the fact that Rust has inadvertently baked in UBs on !Linux platforms by creating its own private copies of system headers, that are essentially an arbitrary version. rust-lang/libc#570 (comment) Cargo needs to grow support for doing the equivalent of parsing uname -K and passing that as target_os_version. For the time being I've accepted that when compiling I need to just append the following 3 lines to the Cargo.toml of any root crate when building on HEAD: [patch.crates-io] |
Actually - although I managed to get jsonrpc_http_server bits to work yesterday by patching some of the dependent ports and then using [patch.crates-io] overrides, today I tried building netmap_sys with user libs which failed in the gcc crate, presumably because of something in libstd. I tried installing the FreeBSD port, but the cargo in that version wouldn't let me override libc (if that's something only available in nightlies you really need to make it standard) so although it compiled the binary didn't actually work. I've lost too much time on this to consider Rust a viable option for any near-term deadlines and have concluded that Rust really isn't cross-platform outside of tier 1 targets right now. |
Here's a fun thing. @johalun's amazing method of patching Mesa OpenGL driver loading. Running
And no,
The ports/pkg rustc, compiled normally with the same |
This follows the same method as other platforms like OSX and NetBSD. This fixes rustup and building from git (once libc is updated for bootstrap) on FreeBSD12 post-ino64 in freebsd/freebsd-src@f713b08. It also avoids having to hotpatch the stage0 compiler on FreeBSD12 to build rust. The only real pitfall is that this will prevent interaction with inodes that have an ino_t above the 32-bit limit due to truncation. On the other hand Rust won't work at all on 12 without doing this currently. In general it should not be a problem for users and if they need 64-bit ino_t they can use a patched libc, rather than the current state of affairs in requiring a patched libc to use Rust on 12. A better, or complementary, approach would be something like proposed in rust-lang/rfcs#2048 to allow targetting a specific version of FreeBSD. This would allow Rust to default to this compatibility mode by targetting FreeBSD10 and still allow targetting FreeBSD12 for 64-bit ino_t. Fixes rust-lang/rust#42681
This follows the same method as other platforms like OSX and NetBSD. This fixes rustup and building from git (once libc is updated for bootstrap) on FreeBSD12 post-ino64 in freebsd/freebsd-src@f713b08. It also avoids having to hotpatch the stage0 compiler on FreeBSD12 to build rust. The only real pitfall is that this will prevent interaction with inodes that have an ino_t above the 32-bit limit due to truncation. On the other hand Rust won't work at all on 12 without doing this currently. In general it should not be a problem for users and if they need 64-bit ino_t they can use a patched libc, rather than the current state of affairs in requiring a patched libc to use Rust on 12. A better, or complementary, approach would be something like proposed in rust-lang/rfcs#2048 to allow targetting a specific version of FreeBSD. This would allow Rust to default to this compatibility mode by targetting FreeBSD10 and still allow targetting FreeBSD12 for 64-bit ino_t. The symbol versions used were taken from the old version in freebsd/freebsd-src@f713b08#diff-61a32fcfb7ecd4517665fed591813c57 and freebsd/freebsd-src@f713b08#diff-7f67ccf8b5f44ff2f54eaab0207abb8d. Fixes rust-lang/rust#42681
This follows the same method as other platforms like OSX and NetBSD. This fixes rustup and building from git (once libc is updated for bootstrap) on FreeBSD12 post-ino64 in freebsd/freebsd-src@f713b08. It also avoids having to hotpatch the stage0 compiler, and HOME/.cargo libc files on FreeBSD12 to build rust. The only real pitfall is that this will prevent interaction with inodes that have an ino_t above the 32-bit limit due to truncation. On the other hand Rust won't work at all on 12 without doing this currently. In general it should not be a problem for users and if they need 64-bit ino_t they can use a patched libc, rather than the current state of affairs in requiring a patched libc to use Rust on 12. A better, or complementary, approach would be something like proposed in rust-lang/rfcs#2048 to allow targetting a specific version of FreeBSD. This would allow Rust to default to this compatibility mode by targetting FreeBSD10 and still allow targetting FreeBSD12 for 64-bit ino_t. The symbol versions used were taken from the old version in freebsd/freebsd-src@f713b08#diff-61a32fcfb7ecd4517665fed591813c57 and freebsd/freebsd-src@f713b08#diff-7f67ccf8b5f44ff2f54eaab0207abb8d. Fixes rust-lang/rust#42681
This follows the same method as other platforms like OSX and NetBSD. This fixes rustup and building from git (once libc is updated for bootstrap) on FreeBSD12 post-ino64 in freebsd/freebsd-src@f713b08. It also avoids having to hotpatch the stage0 compiler, and HOME/.cargo libc files on FreeBSD12 to build rust. The only real pitfall is that this will prevent interaction with inodes that have an ino_t above the 32-bit limit due to truncation. On the other hand Rust won't work at all on 12 without doing this currently. In general it should not be a problem for users and if they need 64-bit ino_t they can use a patched libc, rather than the current state of affairs in requiring a patched libc to use Rust on 12. A better, or complementary, approach would be something like proposed in rust-lang/rfcs#2048 to allow targetting a specific version of FreeBSD. This would allow Rust to default to this compatibility mode by targetting FreeBSD10 and still allow targetting FreeBSD12 for 64-bit ino_t. The symbol versions used were taken from the old version in freebsd/freebsd-src@f713b08#diff-61a32fcfb7ecd4517665fed591813c57 and freebsd/freebsd-src@f713b08#diff-7f67ccf8b5f44ff2f54eaab0207abb8d. The scope of functions versioned here differs from other platforms as not all structs were modified that were on others, such as DIR for `opendir`, `telldir`, etc.. Fixes rust-lang/rust#42681
This follows the same method as other platforms like OSX and NetBSD. This fixes rustup and building from git (once libc is updated for bootstrap) on FreeBSD12 post-ino64 in freebsd/freebsd-src@f713b08. It also avoids having to hotpatch the stage0 compiler, and HOME/.cargo libc files on FreeBSD12 to build rust. The only real pitfall is that this will prevent interaction with inodes that have an ino_t above the 32-bit limit due to truncation. On the other hand Rust won't work at all on 12 without doing this currently. In general it should not be a problem for users and if they need 64-bit ino_t they can use a patched libc, rather than the current state of affairs in requiring a patched libc to use Rust on 12. A better, or complementary, approach would be something like proposed in rust-lang/rfcs#2048 to allow targetting a specific version of FreeBSD. This would allow Rust to default to this compatibility mode by targetting FreeBSD10 and still allow targetting FreeBSD12 for 64-bit ino_t. The symbol versions used were taken from the old version in freebsd/freebsd-src@f713b08#diff-61a32fcfb7ecd4517665fed591813c57 and freebsd/freebsd-src@f713b08#diff-7f67ccf8b5f44ff2f54eaab0207abb8d. The scope of functions versioned here differs from other platforms as not all structs were modified that were on others, such as DIR for `opendir`, `telldir`, etc. Only functions using dirent, stat, glob_t, and dev_t need the changes. Fixes rust-lang/rust#42681
This follows the same method as other platforms like OSX and NetBSD. This will fix rustup and building from git (once libc is updated for bootstrap) on FreeBSD12 post-ino64 in freebsd/freebsd-src@f713b08. It also avoids having to hotpatch the stage0 compiler, and HOME/.cargo libc files on FreeBSD12 to build rust. The only real pitfall is that this will prevent interaction with inodes that have an ino_t above the 32-bit limit due to truncation. On the other hand Rust won't work at all on 12 without doing this currently. In general it should not be a problem for users and if they need 64-bit ino_t they can use a patched libc, rather than the current state of affairs in requiring a patched libc to use Rust on 12. A better, or complementary, approach would be something like proposed in rust-lang/rfcs#2048 to allow targetting a specific version of FreeBSD. This would allow Rust to default to this compatibility mode by targetting FreeBSD10 and still allow targetting FreeBSD12 for 64-bit ino_t. The symbol versions used were taken from the old version in freebsd/freebsd-src@f713b08#diff-61a32fcfb7ecd4517665fed591813c57 and freebsd/freebsd-src@f713b08#diff-7f67ccf8b5f44ff2f54eaab0207abb8d. The scope of functions versioned here differs from other platforms as not all structs were modified that were on others, such as DIR for `opendir`, `telldir`, etc. Only functions using dirent, stat, glob_t, and dev_t need the changes. Fixes rust-lang/rust#42681
Use pre-ino64 FreeBSD symbols to resolve binary compatibility. This follows the same method as other platforms like OSX and NetBSD. This will fix rustup and building from git (once libc is updated for bootstrap) on FreeBSD12 post-ino64 in freebsd/freebsd-src@f713b08. It also avoids having to hotpatch the stage0 compiler, and HOME/.cargo libc files on FreeBSD12 to build rust. The only real pitfall is that this will prevent interaction with inodes that have an ino_t above the 32-bit limit due to truncation. On the other hand Rust won't work at all on 12 without doing this currently. In general it should not be a problem for users and if they need 64-bit ino_t they can use a patched libc, rather than the current state of affairs in requiring a patched libc to use Rust on 12. A better, or complementary, approach would be something like proposed in rust-lang/rfcs#2048 to allow targetting a specific version of FreeBSD. This would allow Rust to default to this compatibility mode by targetting FreeBSD10 and still allow targetting FreeBSD12 for 64-bit ino_t. The symbol versions used were taken from the old version in freebsd/freebsd-src@f713b08#diff-61a32fcfb7ecd4517665fed591813c57 and freebsd/freebsd-src@f713b08#diff-7f67ccf8b5f44ff2f54eaab0207abb8d. The scope of functions versioned here differs from other platforms as not all structs were modified that were on others, such as DIR for `opendir`, `telldir`, etc. Only functions using dirent, stat, glob_t, and dev_t need the changes. Fixes rust-lang/rust#42681
Technically this is not fixed yet as I need to update the submodule and the bootstrap needs to get the fix. Will be a few days. |
Update libc to 0.2.39 CC #42681 r? @alexcrichton
The last piece for this should be updating the src/stage0.txt beta used. I am testing that now. |
…xcrichton Update beta to version with fixed FreeBSD support from rust-lang#49023. Fixes rust-lang#42681 r? @alexcrichton
The ABI patch and bootstrap patching are no longer needed on head after fixes fully upstreamed in rust-lang/rust#42681. git-svn-id: svn+ssh://svn.freebsd.org/ports/head@465189 35697150-7ecd-e111-bb59-0022644237b5
The ABI patch and bootstrap patching are no longer needed on head after fixes fully upstreamed in rust-lang/rust#42681. git-svn-id: svn+ssh://svn.freebsd.org/ports/head@465189 35697150-7ecd-e111-bb59-0022644237b5
The ABI patch and bootstrap patching are no longer needed on head after fixes fully upstreamed in rust-lang/rust#42681.
The ABI patch and bootstrap patching are no longer needed on head after fixes fully upstreamed in rust-lang/rust#42681. git-svn-id: svn+ssh://svn.freebsd.org/ports/head@465189 35697150-7ecd-e111-bb59-0022644237b5
The layout of
struct stat
used to be this in FreeBSD 11, in FreeBSD 12 it's now this. This causes the FreeBSD-specific implementation ofstd::fs::metadata()
to crash for 1.18 and nightly as of 17/06/15, as it's stack frame get's boiled up.Can be reproduced via
Downstream this appeared in alacritty/alacritty#618
The text was updated successfully, but these errors were encountered: