-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
openpty/forkpty build failure using nix package manager macOS environment #78208
Comments
I can't really figure out why, but the <util.h> import in posixmodule.c seems to get skipped since python 3.7. The condition doesn't look entirely correct in case libutil.h is also available on macOS, however this has not changed since 3.6 and it worked fine there while both where available. Part of the configure log: checking pty.h usability... no Build error: ./Modules/posixmodule.c:5924:9: error: implicit declaration of function 'openpty' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
^
./Modules/posixmodule.c:5924:9: note: did you mean 'openat'?
/nix/store/q819d3vjz7vswpvkrfa9gck3ys8rmvcj-Libsystem-osx-10.11.6/include/sys/fcntl.h:480:5: note: 'openat' declared here
int openat(int, const char *, int, ...) __DARWIN_NOCANCEL(openat) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
^
./Modules/posixmodule.c:5924:9: warning: this function declaration is not a prototype [-Wstrict-prototypes]
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
^
./Modules/posixmodule.c:6018:11: error: implicit declaration of function 'forkpty' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
pid = forkpty(&master_fd, NULL, NULL, NULL);
^
./Modules/posixmodule.c:6018:11: warning: this function declaration is not a prototype [-Wstrict-prototypes]
2 warnings and 2 errors generated.
make: *** [Makefile:1793: Modules/posixmodule.o] Error 1 |
I don't see this build failure. Can you say where you find libutil.h installed on macOS and what version of macOS this is? It doesn't seem to be part of the standard Apple-supplied /usr/include header files installed by xcode-select --install for macOS 10.13 at least? |
This is a build using the nix package manager, we use all of the opensource components provided by apple instead of relying on xcode. The libutil.h that's found in this case is the one from the 10.11.6 sources. |
Even on macOS 10.11.6, libutil.h is not installed and posixmodule.c builds just fine. So I don't think that the presence of something in opensource.apple.com necessarily means it was installed in place in a standard system. I'm not saying yet that we shouldn't change the tests along the line you suggest in the PR. But I really would like to understand first why we should make a change when as far as I recall this issue has never come up before. |
The headers end up in the build environment because of Libsystem which is part of our base environment. But yes, this is also the case with 3.6 and that builds just fine so I'm not sure why it's failing now. These are the logs from our build service for reference: |
It's failing in 3.7 because of the change introduced in bpo-27659 to prohibit implicit C function declarations by adding the -Werror=implicit-function-declaration to compiles. |
Oh interesting, so it only used to worked by accident. I should have looked at the 3.6 log more closely. |
The explicit conditional on __APPLE__ can be avoided with the attached patch. (Tested on NixOS and macOS with Nixpkgs.) |
Thanks for the suggested patch but I am not persuaded that there is a problem needing fixing on the Python side. As I see it, Python's posixmodule builds fine in the environments we claim to support, including macOS, and has for a long time. It appears that the build failure reported here is because Nix is not properly emulating a macOS build environment and that builds under Nix have been producing warnings prior to 3.7 so it's not a new issue. Rather than trying to patch around the Nix problem on the Python side, and potentially introducing problems on platforms that Python "officially" supports, it seems to me the better options are for either (1) Nix to better emulate a real macOS build environment by supplying a more correct set of header files (which also might help other third-party packages trying to use Nix for macOS builds); or, if that is not possible, (2) to carry a local patch for Python when building under Nix. I'm open to persuasion but it would have to be a very compelling argument. We have never claimed to support macOS builds on anything other than Apple-supplied macOS development environments running on macOS and I don't see that changing. |
I understand the desirability of avoiding potential problems on supported platforms (given that you can not test building Python on all of them) and recognize that both options you have given are reasonable, but as I see it posixmodule.c incorrectly uses autoconf checks for the presence of header files to infer the platform: it assumes that libutil.h can not exist on macOS. It should either include all found relevant headers, as proposed in my patch or done e.g. in dropbear [1] and gnulib [2], or it should dispatch on the platform directly as LnL7 has proposed (although in this case it should no longer use the autoconf check on macOS). [1] https://secure.ucc.asn.au/hg/dropbear/file/DROPBEAR_2018.76/includes.h |
Even tho it's headers are not /usr/lib/libutil.dylib is available on every macOS system. Unlike on bsd this doesn't include the relevant symbols for openpty/forkpty, that's why I used an __APPLE__ condition but including both also works fine. Assuming it's headers are not available doesn't seem like a good assumption, even tho they won't be in most cases. |
I agree with Ned that we shouldn't add code to deal with non-standard compiler setups, correctly supporting macOS is hard enough as it is. That said, the attached patch (but not PR8056) looks fine to me, it includes all possibly relevant headers files (as mentioned in msg320933) and that should be ok. The PR is not acceptable because it unnecessarily contains macOS specific code. |
Either patch looks fine to me, should I close the pull request? |
Still seems to be a problem with everything up to Py3.11. |
Yesterday I tried building the HEAD using MacOS 13.2.1 (Ventura) and everything went fine. I thought we could just identify the commit that incidentally fixed this issue and backport it. To identify the commit, I went to main and ran a git bisect using HEAD and HEAD~5506*. The results of my search pointed to this commit 04f6733275. I tried to cherry-pick it to 3.11, but there are too many conflicts in files I don't understand. Personally, I don't think backporting this is worth the effort. *I ended up with 5506 because it was the sum of commits ahead and behind |
This can probably be closed. As of NixOS/nixpkgs#346043, macOS support in nixpkgs looks more like a native toolchain (while still building from a bootstrap tarball). Consequently, the |
Yes, was just coming here to say that :) As of the just‐merged NixOS/nixpkgs#353873 we no longer patch Python for this, so unless this affects any non‐Nixpkgs environments, I think this can safely be closed. |
Thanks for chiming in Randy and Emily; closing as outdated. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: