-
Notifications
You must be signed in to change notification settings - Fork 1k
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
musl: add more syscall constants #4028
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! Current nightly has a bug on s390x & sparc so I can't merge now, should be fixed tomorrow.
@tgross35 I can come up with a Python script to make these lists more consistent either with MUSL upstream or the Linux sources upstream. What do you think about that? |
Thanks for offering! I am in favor of better comparison against sources but I'm not sure what would be best here. A script to compare syscalls would be somewhat limited, but it would be great to do something like compare against bindgen's output. Happy to discuss something more in an issue if you're up for helping out, our tests could definitely be improved in a variety of ways. |
(backport <rust-lang#4028>) (cherry picked from commit 9aa7e35)
(backport <rust-lang#4028>) (cherry picked from commit 9aa7e35)
(backport <rust-lang#4028>) (cherry picked from commit 9aa7e35)
(backport <rust-lang#4028>) (cherry picked from commit 9aa7e35)
@tgross35 I had a Python script that looked like this and used the import re
from pathlib import Path
def convert_to_rust(input_file, output_file):
# Updated pattern to capture the entire value/expression
pattern = r'#define\s+__NR_(\w+)\s+(\(?\s*(?:0x[0-9a-fA-F]+)?\s*\+?\s*\d+\s*\)?|\d+)'
# Read input file and convert to Rust format
with open(input_file, 'r') as infile, open(output_file, 'w') as outfile:
for line in infile:
match = re.match(pattern, line.strip())
if match:
syscall_name, value = match.groups()
# Keep the value exactly as is, just remove any extra whitespace
value = ''.join(value.split())
# Convert snake_case to the Rust SYS_ format
rust_line = f'pub const SYS_{syscall_name}: ::c_long = {value};\n'
outfile.write(rust_line)
def run(input_file):
print("Running for file: ", input_file)
output_file = input_file.parent / 'syscalls.rs'
convert_to_rust(input_file, output_file)
print(f"Successfully converted {input_file} to {output_file}")
print("===============================\n\n\n")
def main():
paths = Path('.').rglob('**/syscall.h.in')
for path in paths:
print(path)
run(path)
if __name__ == '__main__':
main() |
I hit a compilation issue where the
SYS_rseq
constant is not defined for some musl targets. For this PR I compared with upstreamsyscall.h.in
files and added constants that I found where missing.I wanted to double check if this is something we can easily adjust. If a PR like this is accepted, I can also see to adjust more of the remaining files that I haven't touched yet, and potentially write a small script for the conversion.
The changes in s390x are a little bigger because the integers were in relatively random order.
References:
riscv64
x86_64
powerpc64
aarch64
s390x