You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
configure fails to detect fchdir() using CFLAGS="-Werror -Wall" #75929
changed the title [-]Modules/posixmodule.c: skip compiling jka4NaPmmQ37 and posix_fildes_fd[/-][+]configure fails to detect fchdir() using CFLAGS="-Werror -Wall"[/+]on Oct 10, 2017
+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.
"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.
Still reproducible on 3.16.0a1+dev (Apple clang 21, GCC 14).
The PY_CHECK_FUNC macro uses expression void *x=$1 to check for name declaration.
It has side effects: an unused variable and a function pointer to void* conversion that isn't valid ISO C. With CFLAGS="-Werror -Wall", ~40 checks (num is different per platform) report no for functions that exist (including fchdir).
We can change the expression to (void)$1, the idiom AC_CHECK_DECL uses. It still fails to compile when the name isn't declared but it doesn't have those effects, so those ~40 false negatives go away.
With the change configure under -Werror -Wall still gets other ~15 cpython checks wrong + autoconf's own AC_CHECK_FUNCS.
Activity
dilyanpalauzov commentedon Oct 10, 2017
These are needed only sometimes.
vstinner commentedon Oct 10, 2017
Hi Дилян Палаузов,
Would you mind to elaborate, please?
Which platform doesn't have os.fchdir(), os.fsync() nor os.fdatasync()?
dilyanpalauzov commentedon Oct 10, 2017
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:
vstinner commentedon Oct 10, 2017
Ok. My next question is: what is your operating system? What is your operating system version?
dilyanpalauzov commentedon Oct 10, 2017
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.
vstinner commentedon Oct 10, 2017
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:
---
Extract of config.log, without the long confdefs.h part:
---
[-]Modules/posixmodule.c: skip compiling jka4NaPmmQ37 and posix_fildes_fd[/-][+]configure fails to detect fchdir() using CFLAGS="-Werror -Wall"[/+]vstinner commentedon Oct 10, 2017
Python 2.7 is also affected by the issue.
dilyanpalauzov commentedon Oct 11, 2017
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.
vstinner commentedon Oct 11, 2017
"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.
vasiliyk commentedon Oct 23, 2026
Still reproducible on 3.16.0a1+dev (Apple clang 21, GCC 14).
The
PY_CHECK_FUNCmacro uses expressionvoid *x=$1to check for name declaration.It has side effects: an unused variable and a function pointer to
void*conversion that isn't valid ISO C. WithCFLAGS="-Werror -Wall", ~40 checks (num is different per platform) reportnofor functions that exist (includingfchdir).We can change the expression to
(void)$1, the idiomAC_CHECK_DECLuses. It still fails to compile when the name isn't declared but it doesn't have those effects, so those ~40 false negatives go away.With the change configure under
-Werror -Wallstill gets other ~15 cpython checks wrong + autoconf's ownAC_CHECK_FUNCS.Do we want to make the change anyway?
vstinner commentedon Nov 4, 2026
Using
(void)$1sounds correct to me. Go ahead and propose a PR. You can cc me if you want a review.gh-75929: Fix configure function checks under -Wall -Werror (#161343)
[3.15] gh-75929: Fix configure function checks under -Wall -Werror (G…
[3.14] gh-75929: Fix configure function checks under -Wall -Werror (G…