-
Notifications
You must be signed in to change notification settings - Fork 1.1k
pwrite64()
is missing for uclibc targets
#2130
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
Comments
Thanks for reporting, yeah, I think there's no reason to disable |
I tested with a custom copy of |
Anytime :) |
@drmikehenry Could you please share an example of how you consumed this fix? I tried playing with I created a PR to rust to update the Thanks |
@zvirja I'd be happy to post the steps I followed once I retrieve them from the office early next week. Mostly I just followed somebody's tutorial on re-compiling the Rust standard library, but there are indeed a number of steps involved and without notes I'd be lost :-) |
@zvirja I'm having trouble replicating this change with my home setup, but it appears that your pull request has gone through already, so perhaps you can use a new nightly toolchain to get the libc updates. |
@zvirja You probably won't need this if you use the very latest Rust sources; commit First, install a nightly toolchain and make it the default: rustup install nightly-2021-03-01
rustup default nightly-2021-03-01 Clone Rust sources and enter mkdir -p ~/projects/custom-std
cd ~/projects/custom-std
git clone https://github.com/rust-lang/rust
cd rust Optionally, checkout a branch or commit hash as the desired starting point, perhaps using the hash from the active compiler: rustc -vV | grep commit-hash with output:
Checkout this commit: git checkout e37a13cc3594004663738bd18d8100e6db9666cf Initialize and update the submodules: git submodule init
git submodule update For use with Cargo's build-std feature, the Rust sources need to live in the expected location below cd ~/.rustup/toolchains/nightly-2021-03-01-x86_64-unknown-linux-gnu/lib/rustlib
mkdir -p src
cd src If there's already a mv rust rust.orig Create a symlink to the cloned Rust sources: ln -s ~/projects/custom-std/rust rust Create an example project to test: cd ~/projects
cargo new hello-custom-std
cd hello-custom-std Add the following to [profile.release]
panic = "abort" At this point, Cargo's build-std feature should work: cargo build \
-Z build-std=panic_abort,std \
-Z build-std-features=panic_immediate_abort \
--target x86_64-unknown-linux-gnu \
--release Building with Xargo should work as well, if a [dependencies]
std = {default-features=false, features=["panic_immediate_abort"]} Then install Xargo and build: cargo install xargo
xargo build \
--target x86_64-unknown-linux-gnu \
--release With Xargo, it's not necessary to place the sources below export XARGO_RUST_SRC=$HOME/projects/custom-std/rust/library You might need to remove To use cd ~/projects
git clone https://github.com/rust-lang/libc
cd libc
git checkout 0.2.92 Edit the Rust standard library's cd ~/projects/custom-std/rust
git diff library/std/Cargo.toml with sample output: diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml
index 275fcc4c292..8a82c66b250 100644
--- a/library/std/Cargo.toml
+++ b/library/std/Cargo.toml
@@ -16,7 +16,7 @@ cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core" }
-libc = { version = "0.2.85", default-features = false, features = ['rustc-dep-of-std'] }
+libc = { version = "=0.2.92", default-features = false, features = ['rustc-dep-of-std'], path = "../../../../libc" }
compiler_builtins = { version = "0.1.39" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" } The change involves requesting It may be necessary to clean the workspace and remove the rm -rf ~/.xargo
cargo clean
xargo build \
--target x86_64-unknown-linux-gnu \
--release The indication that the local copies are being used is in these lines of output:
The reason I couldn't replicate this earlier is that I'd been using |
When I upgraded to a recent toolchain (2021-03-25) and updated some crates to today's latest as a result, I started getting errors about missing
libc::pwrite64()
for my uclibc-based target. I haven't tracked it all the way back to see when the error first started happening, but I think the issue is that the standard library source requirespwrite64()
for non-Android Linux:https://github.com/rust-lang/rust/blob/48691ea6e639640f110b43e33d4aba1f07e7415c/library/std/src/sys/unix/fd.rs#L167-L183
Whereas
pwrite64()
is disallowed for uclibc in thelibc
crate:libc/src/unix/linux_like/mod.rs
Lines 1671 to 1685 in f913fc5
However, the companion function
pread64()
is permitted for uclibc:libc/src/unix/linux_like/mod.rs
Lines 1543 to 1548 in f913fc5
The actual
pwrite64()
function is available on my uclibc target. Considering thatlibc
contains aSYS_pwrite64
value for uclibc targets, I suspect this is just an oversight in thelibc
crate, and thatpwrite64()
was not intended to be caveated bycfg(not(target_env = "uclibc"))
. Unless there is some other reason for disallowingpwrite64()
on uclibc-based Linux targets, could this function be promoted to work for uclibc variants?The text was updated successfully, but these errors were encountered: