-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Hey all. Experienced Python programmer and beginner Rustacean here. Never heard that one before, right. Anyway, I'm super glad this project exists!
Summary
I'm on OpenBSD and am having trouble building the RustPython Virtual Machine due to (completely reasonable) assumptions about the universal nature of *nix system flags that OpenBSD does not implement or implements differently.
Detailed Explanation
The following are the variables I found that were undefined:
Errors
ENODATA: Used once inLib/shutil.pyin a conditional statement that is never reached because OpenBSD does not support extended attributes.EMULTIHOPENOLINKENOSTRENOSRETIME: Unused in RustPython and CPython.
These errors are all defined in errno.rs. This file includes a lot of provisions about operating systems but assumes that all the error codes it imports from libc and then looks for are defined. CPython's implementation of the same idea has a much more exhaustive list of error codes, but each is surrounded by #ifdef/#endif preprocessor tags, avoiding lots of errors. Unfortunately, I do not believe there's an equivalent in Rust for this, but there's gotta be a fairly painless solution out there.
Socket constants
AI_ALL: The compiler expectslibcto define this, but OpenBSD doesn't implement it.AI_PASSIVE: OpenBSD does implement this one, butlibcdoes not define it.
As far as I can tell, in fact, none of the constants for addrinfo's ai_flags are defined by libc for OpenBSD. This might be a problem with libc, but I'm not well-versed enough in the way that repository works to come to any conclusion without conjecture.
Functions
getgroups: Required once inos.rs. I found thatnix::unistddefined this function, just like on linux and android, so I added atarget_os = "openbsd"and that seemed to fix it. Perhaps other *nixes also have this problem? Might be worth looking into.os_umask: Also required once byos.rs. Fixed in a similar fashion togetgroups.
Miscellaneous system stuff
getresuidgetresgid: Yet more things that it appearslibcshould be providing for us but aren't.setresuidandsetresgidare indeed provided bylibc, but not thegets for some reason.getregid: It doesn't seem likelibcprovides this one either.SIGPWRSIGSTKFLT: Signals for power cut and stack fault, respectively. Both unused by OpenBSD. I added anothertarget_os = "openbsd"to thecfgsurrounding their occurrences. Other operating systems might have similar problems and may need to be added to thiscfg.
MetadataExt
- A lot of functions were missing from os.rs due to its inability to find the
MetadataExttrait. I just found the appropriate line and added the relevant OpenBSDuse.- Fixing this caused another issue: ModeT was not defined. I added a definition here
Conclusion
I added whatever support I could. I'm not that great at Rust; neither am I that great at *nix. But I did manage to cull down the errors from 24 to 5 in a couple of hours. I'm definitely willing to contribute to OpenBSD support in the future, assuming you folks are willing to help me out wherever my knowledge is lacking.
My personal branch for those who want to see the end results of my finagling. This should get you far less errors compiling for OpenBSD.