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
Android build fix & CMake fix #2609
Conversation
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.
So what header does Android want included to get the getpwuid_r
declaration? This added test seems weird to me as we already check for those headers.
@bwalle It would be great to see "how to reproduce" description for the issue. |
To reproduce:
The declaration is just missing in the header, the problem is that the configure check just checks if the function is available at link-time, not if it's declared. Contents of
I know that the toolchain is a bit older, but we're still using that one. |
But the cmake fix should be ok, isn't it? |
See also #2058. This is a bug in the NDK fixed in later versions. |
@bwalle I see no CMake invocation in your "how to reproduce". Why did you add it to the subject? |
@snikulov Well, the CMake thing has nothing todo with Android. The check for I discovered the issue when checking whether the declaration of |
@snikulov it seems to be an omission in the cmake build @bwalle I think @MarcelRaad is spot on; this is an NDK issue that is already fixed. And if we were to add a work-around for this in our code, I don't see how this is a good such one! |
@bagder I can remove the Android patch and keep it in my local build system until we update the toolchain. Would you merge the cmake part? |
You can of course do what you want, but I still consider it a lame "fix". It just disables the use of the function so instead you'll use a function that isn't thread-safe. A more proper fix would be to instead provide a private prototype to avoid the warning when the correct function is used! The cmake fix is valid and I'll merge! |
The autotools-based build system does it, so we do it also in CMake. Bug: #2609 Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
The cmake commit is merged, the configure commit is not and needs another approach or an NDK update. If you rather stick with that patch locally, we might just as well close this PR. What do you think @bwalle ? |
I can create a new patch for the NDK issue if you advise me how you want to get it fixed, but I'm also fine with closing that PR. |
I believe a proper fix for this broken NDK would be as following (assuming I've understood this correctly): 1 - detect the lack of #ifdef HAVE_NO_GETPWUID_R_PROTO
int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
size_t buflen, struct passwd **result);
#endif |
I've updated the branch. |
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.
Looks good. I'll just let the CI tests complete first before merging to make sure there's nothing subtle there we missed...
And yes, it figured out this:
It highlights this problem: only the configure script will define I would prefer if the configure script defines name for the reverse: when the prototype is found to be missing as then we could be sure that only systems for which configure has detected a missing prototype would use this custom one. |
On our x86 Android toolchain, getpwuid_r is implemented but the header is missing: netrc.c:81:7: error: implicit declaration of function 'getpwuid_r' [-Werror=implicit-function-declaration] if(!getpwuid_r(geteuid(), &pw, pwbuf, sizeof(pwbuf), &pw_res) ^ Unfortunately, the function is used in curl_ntlm_wb.c, too, so I moved the prototype to curl_setup.h. Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
I've updated my patch. |
Thanks! |
See the individual patches.