classification
Title: configure fails to detect fchdir() using CFLAGS="-Werror -Wall"
Type: enhancement Stage: patch review
Components: Build Versions: Python 3.7, Python 3.6, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: dilyan.palauzov, vstinner
Priority: normal Keywords: patch

Created on 2017-10-10 17:05 by dilyan.palauzov, last changed 2017-10-11 09:30 by vstinner.

Pull Requests
URL Status Linked Edit
PR 3949 open christian.heimes, 2017-10-11 08:44
Messages (9)
msg304059 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2017-10-10 17:05
These are needed only sometimes.

diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1466,6 +1466,7 @@ path_error2(path_t *path, path_t *path2)
 
 /* POSIX generic methods */
 
+#if defined(HAVE_FSYNC) || defined(HAVE_FDATASYNC) || defined(HAVE_FCHDIR)
 static int
 fildes_converter(PyObject *o, void *p)
 {
@@ -1495,6 +1496,7 @@ posix_fildes_fd(int fd, int (*func)(int))
         return (!async_err) ? posix_error() : NULL;
     Py_RETURN_NONE;
 }
+#endif
 
 
 #ifdef MS_WINDOWS
msg304073 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-10 19:38
Hi Дилян Палаузов,

> These are needed only sometimes.

Would you mind to elaborate, please?

Which platform doesn't have os.fchdir(), os.fsync() nor os.fdatasync()?
msg304075 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2017-10-10 19:48
Having 'CFLAGS="-pipe -Werror -Wall -Wextra -O3 -fno-fat-lto-objects -flto" CXXFLAGS="-pipe -Wall -Wextra -O3 -fno-fat-lto-objects -flto" LDFLAGS="-Wl,-O1,-s -flto=12" ' in config.site and running "./configure" with gcc8 prints:

checking for fchdir... no
checking for fsync... no
checking for fdatasync... no

and config.log has:

configure:11440: checking for fchdir
configure:11453: gcc -c -pipe -Werror -Wall -Wextra -O3 -fno-fat-lto-objects -flto  conftest.c >&5
conftest.c: In function 'main':
conftest.c:250:7: error: unused variable 'x' [-Werror=unused-variable]
 void *x=fchdir
       ^
cc1: all warnings being treated as errors
configure:11453: $? = 1
configure: failed program was:
| /* confdefs.h */
...
| #define HAVE_DIRFD 1
| /* end confdefs.h.  */
| #include <unistd.h>
| int
| main ()
| {
| void *x=fchdir
|   ;
|   return 0;
| }
configure:11460: result: no
msg304077 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-10 20:05
Ok. My next question is: what is your operating system? What is your operating system version?
msg304080 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2017-10-10 20:31
If I remove -Werror from CFLAGS ./configure prints:

  checking for fchdir... yes
  checking for fsync... yes
  checking for fdatasync... yes

so it is irrelevant what the OS is.
msg304081 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-10 21:14
I can reproduce the issue on Fedora 26:

haypo@selma$ ./configure CFLAGS="-Werror -Wall" 2>&1|tee log
haypo@selma$ grep fchdir log
checking for fchdir... no

The problem is not posixmodule.c. The problem is configure which emits a compiler warning.

configure.ac contains:
---
AC_MSG_CHECKING(for fchdir)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
  [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
   AC_MSG_RESULT(yes)],
  [AC_MSG_RESULT(no)
])
---

Extract of config.log, without the long confdefs.h part:
---
configure:11258: checking for fchdir
configure:11271: gcc -c -Werror -Wall -Wextra  conftest.c >&5
conftest.c: In function 'main':
conftest.c:256:7: error: unused variable 'x' [-Werror=unused-variable]
 void *x=fchdir
       ^
cc1: all warnings being treated as errors
configure:11271: $? = 1
configure: failed program was:
| /* confdefs.h */
| (...)
| /* end confdefs.h.  */
| #include <unistd.h>
| int
| main ()
| {
| void *x=fchdir
|   ;
|   return 0;
| }
configure:11278: result: no
---
msg304082 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-10 21:15
Python 2.7 is also affected by the issue.
msg304121 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2017-10-11 09:16
The patch puts in "Misc/NEWS.d/next/Core and Builtins/2017-10-11-10-42-02.bpo-31748.oaEZcq.rst":

+Support configure with -Wall by avoiding unused variables.

but likely means "-Werror" (or both)

Different people generate ./configure different ways.  Some insert runstatedir in configure, others don't.  E.g. on 14 April 2017 runstatedir was added to configure, on 9 June it was removed from configure, on 29 June it was added to configure.  It needs to be clarified once forever, whether runstatedir belongs to configure or not and then everybody has to stick to this, in order to avoid useless changes in the version control.
msg304123 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-11 09:30
"Different people generate ./configure different ways.  Some insert runstatedir in configure, others don't.  E.g. on 14 April 2017 runstatedir was added to configure, on 9 June it was removed from configure, on 29 June it was added to configure.  It needs to be clarified once forever, whether runstatedir belongs to configure or not and then everybody has to stick to this, in order to avoid useless changes in the version control."

For practical reasons, we decided to include the generated file configure in Git. You are right that not all developers use the same autoconf version, and so that the generated file includes or not the runstatedir change. I don't know how to fix this issue. If you consider that it's a bug and should be fixed, please open a new dedicated issue, since it's unrelated to your fchdir + -Werror bug.
History
Date User Action Args
2017-10-11 09:30:09vstinnersetmessages: + msg304123
2017-10-11 09:16:32dilyan.palauzovsetmessages: + msg304121
2017-10-11 08:44:09christian.heimessetkeywords: + patch
stage: patch review
pull_requests: + pull_request3924
2017-10-10 21:15:16vstinnersetmessages: + msg304082
versions: + Python 2.7, Python 3.6, Python 3.7, - Python 3.8
2017-10-10 21:14:24vstinnersetmessages: + msg304081
title: Modules/posixmodule.c: skip compiling jka4NaPmmQ37 and posix_fildes_fd -> configure fails to detect fchdir() using CFLAGS="-Werror -Wall"
2017-10-10 20:31:37dilyan.palauzovsetmessages: + msg304080
2017-10-10 20:05:13vstinnersetmessages: + msg304077
2017-10-10 19:48:03dilyan.palauzovsetmessages: + msg304075
2017-10-10 19:38:38vstinnersetnosy: + vstinner
messages: + msg304073
2017-10-10 17:05:50dilyan.palauzovcreate