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

Provide SYS_statx for more target_arch/target_env #1577

Merged
merged 2 commits into from
Nov 22, 2019

Conversation

oxalica
Copy link
Contributor

@oxalica oxalica commented Oct 31, 2019

Fixes #1545

The syscall statx is provided by Linux Kernel, so it should be available on any target_env/target_arch, not only some arch on gnu.

Syscall ids are got from this commit of musl, except for hexagon, which is got from Linux Kernel (make O=build ARCH=hexagon headers).

Not tested yet

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @gnzlbg (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 31, 2019

error: invalid application of 'sizeof' to incomplete type 'struct statx'

You probably need to update the musl headers or the musl-sanitized linux kernel headers for this to work. The current kernel headers used by libc do not contain statx.

@oxalica oxalica changed the title Provide SYS_statx and structs for more target_arch/target_env Provide SYS_statx for more target_arch/target_env Oct 31, 2019
@oxalica
Copy link
Contributor Author

oxalica commented Nov 1, 2019

@gnzlbg
The constant SYS_statx is available on latest musl, and seems first introduced in v1.1.19, while the ci use musl v1.1.15.

Maybe need to upgrade?

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 6, 2019

Maybe need to upgrade?

The current musl version used by libc on most targets is here: https://github.com/rust-lang/libc/blob/master/ci/install-musl.sh#L8

and the linux kernel that these targets support is here:

https://github.com/rust-lang/libc/blob/master/ci/install-musl.sh#L75

However, for some targets (e.g. the mips ones), the latest available musl version in their toolchains is older, e.g., the mips 32-bit target only support musl 1.1.15: https://github.com/rust-lang/libc/blob/master/ci/docker/mips-unknown-linux-musl/Dockerfile#L14

I doubt there is a new toolchain for these targets, but if there is, sure, we could update. Otherwise, just do not expose the feature in those targets.

@oxalica
Copy link
Contributor Author

oxalica commented Nov 7, 2019

@gnzlbg

Why we use OpenWrt snapshots instead of building from souce only in mips{el,}?
Can we install them in the same way as others?

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 19, 2019

Why we use OpenWrt snapshots instead of building from souce only in mips{el,}?

Probably because building the toolchain from source takes a long time. You can try to change those to build from source though, but given everything that OpenWrt provides it might take a while.

@gnzlbg gnzlbg closed this Nov 19, 2019
@gnzlbg gnzlbg reopened this Nov 19, 2019
bors added a commit that referenced this pull request Nov 20, 2019
Upgrade to musl 1.1.24 in CI

Required by #1577

Note that in musl 1.1.24, `struct sched_param` from `sched.h` has changed and some fields became reserved. So [these fields](https://github.com/rust-lang/libc/blob/13d4a5da2eafd82d3ebb2acb729d8b8c9148fb1f/src/unix/linux_like/mod.rs#L97) are outdated. I'm not sure if we should rename them, since they are in public API.

I simply skip `struct sched_param` from the test now.

Here's the diff between musl 1.1.23 and 1.1.24
```
diff --git a/include/sched.h b/include/sched.h
index 05d40b1e..7e470d3a 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -18,10 +18,12 @@ extern "C" {

 struct sched_param {
        int sched_priority;
-       int sched_ss_low_priority;
-       struct timespec sched_ss_repl_period;
-       struct timespec sched_ss_init_budget;
-       int sched_ss_max_repl;
+       int __reserved1;
+       struct {
+               time_t __reserved1;
+               long __reserved2;
+       } __reserved2[2];
+       int __reserved3;
 };
```
@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 21, 2019

IIUC this is blocked by #1588 , right?

@oxalica
Copy link
Contributor Author

oxalica commented Nov 21, 2019 via email

bors added a commit that referenced this pull request Nov 21, 2019
Upgrade to musl 1.1.24 in CI

Required by #1577

Note that in musl 1.1.24, `struct sched_param` from `sched.h` has changed and some fields became reserved. So [these fields](https://github.com/rust-lang/libc/blob/13d4a5da2eafd82d3ebb2acb729d8b8c9148fb1f/src/unix/linux_like/mod.rs#L97) are outdated. I'm not sure if we should rename them, since they are in public API.

I simply skip `struct sched_param` from the test now.

Here's the diff between musl 1.1.23 and 1.1.24
```
diff --git a/include/sched.h b/include/sched.h
index 05d40b1e..7e470d3a 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -18,10 +18,12 @@ extern "C" {

 struct sched_param {
        int sched_priority;
-       int sched_ss_low_priority;
-       struct timespec sched_ss_repl_period;
-       struct timespec sched_ss_init_budget;
-       int sched_ss_max_repl;
+       int __reserved1;
+       struct {
+               time_t __reserved1;
+               long __reserved2;
+       } __reserved2[2];
+       int __reserved3;
 };
```
@oxalica
Copy link
Contributor Author

oxalica commented Nov 22, 2019

Rebased

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 22, 2019

Thanks! @bors: r+

@bors
Copy link
Contributor

bors commented Nov 22, 2019

📌 Commit d211ebf has been approved by gnzlbg

@bors
Copy link
Contributor

bors commented Nov 22, 2019

⌛ Testing commit d211ebf with merge 48e4bb9...

bors added a commit that referenced this pull request Nov 22, 2019
Provide SYS_statx for more target_arch/target_env

Fixes #1545

The syscall `statx` is provided by Linux Kernel, so it should be available on any `target_env`/`target_arch`, not only some arch on `gnu`.

Syscall ids are got from [this commit of musl](http://git.etalabs.net/cgit/musl/commit/?id=9864f60e929100e253fc813bd4105d6dd7652787), except for hexagon, which is got from Linux Kernel (`make O=build ARCH=hexagon headers`).

**Not tested yet**
@bors
Copy link
Contributor

bors commented Nov 22, 2019

☀️ Test successful - checks-cirrus-freebsd-10, checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, status-azure
Approved by: gnzlbg
Pushing 48e4bb9 to master...

@bors bors merged commit d211ebf into rust-lang:master Nov 22, 2019
@oxalica oxalica deleted the statx-syscall branch November 22, 2019 18:04
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jan 8, 2020
Try statx for all linux-gnu target.

After rust-lang/libc#1577, which is contained in `libc` 0.2.66,  provides `SYS_statx` for all Linux platform, so we can try to use `statx` for ~all Linux target~ all linux-gnu targets.

Unfortunately, `struct statx` and `fn statx` is not a part of public interface of musl (currently), ~we still need to invoke it through `syscall`~ we does **not** support statx for musl or other libc impls currently.

Previous PR: rust-lang#65094

cc @alexcrichton
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

Successfully merging this pull request may close these issues.

statx should be available on more platform/architecture
4 participants