Prohibit implicit C function declarations #71846
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
assignee = None closed_at = <Date 2017-02-06.13:45:59.719> created_at = <Date 2016-07-31.07:04:38.341> labels = ['type-feature', '3.7', 'build'] title = 'Prohibit implicit C function declarations' updated_at = <Date 2017-03-31.16:36:20.997> user = 'https://github.com/yan12125'
activity = <Date 2017-03-31.16:36:20.997> actor = 'dstufft' assignee = 'none' closed = True closed_date = <Date 2017-02-06.13:45:59.719> closer = 'yan12125' components = ['Build', 'Cross-Build'] creation = <Date 2016-07-31.07:04:38.341> creator = 'yan12125' dependencies =  files = ['43954', '43955', '46033', '46036', '46302'] hgrepos =  issue_num = 27659 keywords = ['patch'] message_count = 19.0 messages = ['271727', '271728', '271729', '271730', '271732', '278770', '278824', '278836', '283996', '284002', '284004', '285567', '285583', '286759', '287126', '287127', '287128', '287130', '287132'] nosy_count = 9.0 nosy_names = ['ronaldoussoren', 'vstinner', 'benjamin.peterson', 'ned.deily', 'xdegaye', 'python-dev', 'martin.panter', 'Alex.Willmer', 'yan12125'] pr_nums = ['552'] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue27659' versions = ['Python 3.7']
The text was updated successfully, but these errors were encountered:
Some references for crypt():
POSIX standard: http://pubs.opengroup.org/onlinepubs/9699919799/functions/crypt.html
All requires <unistd.h>.
Android does not have crypt, but the crypt module is cross-built nevertheless after this warning has been issued:
gcc and clang do not enforce the C99 rules and emit just a warning for implicit function declarations instead of the error that would be conforming to C99. This can be changed with the flag '-Werror=implicit-function-declaration' and the compilation of the crypt extension module rightly fails in that case.
I think this issue should be fixed by adding this flag to the Makefile.
(Re-use the existing issue)
Here's a patch that tries to add -Werror=implicit-function-declaration to $BASECFLAGS.
This is useful for cross-compiling. When a function is missing, the error jumps out during the build time rather than runtime.
I'd like to hear some ideas from macOS experts as in my memory macOS's build system is fragile than that on Linux.
Martin Panter: "If there is an obscure platform where we don’t include the right header file for a function, changing the warning into an error would cause the build to fail."
In my experience, calling a function which was not declared is very likely to cause a bug, or a crash in the worst case. For example, on 64-bit, if the return type is a pointer, the C compiler uses the int type by default, whereas a pointer is 32-bit, not 64-bit, and so it will immediately crash.
Martin: "If we do make it an error, it should only be so for 3.7."
Ok. I pushed the patch to Python 3.6.
@Chi Hsuan Yen: Thanks for the patch! Is this change enough to fix the crypt build issue? If yes, can we close the issue?
It is likely that the cause causes compilation errors on some platforms where we call non-existent functions or call functions with a missing header. IMHO it's a good thing to get a build error rather than a crash at runtime.
A concrete issue is that the compilation of the curses module will probably fails now on Solaris: issue bpo-13552, whereas before the build only emitted warnings. The curses module is broken for years on Solaris, and it seems like nobody is able to fix it, so it's not a big deal.