classification
Title: Improve and simplify configure.ac checks
Type: enhancement Stage: patch review
Components: Build Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: christian.heimes, erlendaasland, miss-islington
Priority: normal Keywords: patch

Created on 2021-11-05 10:05 by christian.heimes, last changed 2021-11-29 14:41 by miss-islington.

Pull Requests
URL Status Linked Edit
PR 29429 merged christian.heimes, 2021-11-05 15:24
PR 29441 merged christian.heimes, 2021-11-06 16:01
PR 29442 merged christian.heimes, 2021-11-06 16:05
PR 29466 merged erlendaasland, 2021-11-08 09:24
PR 29485 merged erlendaasland, 2021-11-09 12:48
PR 29486 merged erlendaasland, 2021-11-09 13:39
PR 29500 merged erlendaasland, 2021-11-09 19:34
PR 29517 merged christian.heimes, 2021-11-10 15:06
PR 29637 merged erlendaasland, 2021-11-19 12:33
PR 29701 open erlendaasland, 2021-11-22 12:13
PR 29846 merged erlendaasland, 2021-11-29 14:08
Messages (14)
msg405780 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-05 10:05
The autoconf-based build system has room for improvements. The configure.ac script can be simplified in several places by using AS and AC macros or by defining new custom macros.

For example we have a lot of blocks that look like this:

AC_MSG_CHECKING(for chroot)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void x=chroot]])],
  [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
   AC_MSG_RESULT(yes)],
  [AC_MSG_RESULT(no)
])

The block has an issue, too. It does not use AC_CACHE to cache the result. The entire block can be replaced by a custom macro that takes care of everything and implements correct caching:

  PY_CHECK_FUNC([chroot], [#include <unistd.h>])

We can also move several library and header checks from setup.py into configure.ac, e.g. check for soundcard.h or gdbm libs and headers.
msg405799 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-05 14:07
The first PR adds helper macros, AC_CACHE_CHECK() [1] and AS_VAR_IF() [2]. It also unified internal variables to use format "ac_cv_func_$funcname", "ac_cv_func_lib_$library_$funcname", or "ac_cv_header_$headername_h". "ac_cv" stands for autoconf cached value.

AC_CACHE_CHECK() replaces AC_MSG_CHECKING() and AC_MSG_RESULT(). The syntax is AC_CACHE_CHECK([text], [cache variable], [body]) where body is only excecuted when the cache variable is not set. The body has to set the cache variable to yes or no. Any output and AC_DEFINE must occur outside the body.

AS_VAR_IF() is a nicer way to write if test $variable = value; then; fi.

[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Caching-Results.html#Caching-Results
[2] https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Polymorphic-Variables.html
msg405865 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-06 16:57
GH-29441 introduces forward compatibility issues with autoconf 2.71. I took the output of autoupdate and resolved all warnings.
msg405896 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-07 10:18
New changeset be3cd5c05d9fb1d1cdb55cb98ca6ef8f866774be by Christian Heimes in branch 'main':
bpo-45723: Detect missing pkg-config (GH-29442)
https://github.com/python/cpython/commit/be3cd5c05d9fb1d1cdb55cb98ca6ef8f866774be
msg405932 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-08 07:06
New changeset 57c50c9c7c701a8301c5a89b2b2d050550f62022 by Christian Heimes in branch 'main':
bpo-45723: Add helper macros and more caching to configure.ac (GH-29429)
https://github.com/python/cpython/commit/57c50c9c7c701a8301c5a89b2b2d050550f62022
msg405977 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-08 17:58
New changeset 9bd0cf5970997b63d296e30d51e7bb9a15dcabaf by Erlend Egeberg Aasland in branch 'main':
bpo-45723: Add macro for disabling/enabling CC warnings (GH-29466)
https://github.com/python/cpython/commit/9bd0cf5970997b63d296e30d51e7bb9a15dcabaf
msg405978 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-08 18:31
New changeset cbab997efb3ba5123dc8d9f706184fa8e634b3ec by Christian Heimes in branch 'main':
bpo-45723: Prepare support for autoconf 2.71 (GH-29441)
https://github.com/python/cpython/commit/cbab997efb3ba5123dc8d9f706184fa8e634b3ec
msg406021 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-11-09 13:45
AC_CHECK_TYPE is obsolete and it's use is discouraged. There are some gotchas we need to check before switching to AC_CHECK_TYPES.

See:
- https://www.gnu.org/software/autoconf/manual/autoconf-2.70/html_node/Obsolete-Macros.html
- https://www.gnu.org/software/autoconf/manual/autoconf-2.70/html_node/Generic-Types.html
msg406027 - (view) Author: miss-islington (miss-islington) Date: 2021-11-09 15:33
New changeset 185533639d6eddd42a28f9e3517067bd877e34c5 by Erlend Egeberg Aasland in branch 'main':
bpo-45723: Remove obsolete AC_EXEEXT from configure.ac (GH-29486)
https://github.com/python/cpython/commit/185533639d6eddd42a28f9e3517067bd877e34c5
msg406054 - (view) Author: miss-islington (miss-islington) Date: 2021-11-09 21:06
New changeset 49171aa91ab78c2608a26e5a75cdceab3bad6176 by Erlend Egeberg Aasland in branch 'main':
bpo-45723: Remove dead code for obsolete `--with-dyld` option (GH-29500)
https://github.com/python/cpython/commit/49171aa91ab78c2608a26e5a75cdceab3bad6176
msg406104 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-10 15:30
New changeset 76d14fac72479e0f5f5b144d6968ecd9e594db34 by Erlend Egeberg Aasland in branch 'main':
bpo-45723: Improve and simplify more configure.ac checks (GH-29485)
https://github.com/python/cpython/commit/76d14fac72479e0f5f5b144d6968ecd9e594db34
msg406137 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-10 22:02
New changeset fc9b62281931da8d20f85d5ed44cfc24f068d3f4 by Christian Heimes in branch 'main':
bpo-45723: Add --with-pkg-config to configure (GH-29517)
https://github.com/python/cpython/commit/fc9b62281931da8d20f85d5ed44cfc24f068d3f4
msg406745 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-22 08:05
New changeset db2277a114463d30a58d9066f2b47f7a53a1488c by Erlend Egeberg Aasland in branch 'main':
bpo-45723: Add helpers for save/restore env (GH-29637)
https://github.com/python/cpython/commit/db2277a114463d30a58d9066f2b47f7a53a1488c
msg407281 - (view) Author: miss-islington (miss-islington) Date: 2021-11-29 14:41
New changeset c1dec9540ab04691f8d4a131671e069913e6eee3 by Erlend Egeberg Aasland in branch 'main':
bpo-45723: Sort the grand AC_CHECK_HEADERS check (GH-29846)
https://github.com/python/cpython/commit/c1dec9540ab04691f8d4a131671e069913e6eee3
History
Date User Action Args
2021-11-29 14:41:22miss-islingtonsetmessages: + msg407281
2021-11-29 14:08:09erlendaaslandsetpull_requests: + pull_request28075
2021-11-22 12:13:20erlendaaslandsetpull_requests: + pull_request27937
2021-11-22 08:05:15christian.heimessetmessages: + msg406745
2021-11-19 12:33:18erlendaaslandsetpull_requests: + pull_request27868
2021-11-10 22:02:27christian.heimessetmessages: + msg406137
2021-11-10 15:30:28christian.heimessetmessages: + msg406104
2021-11-10 15:06:38christian.heimessetpull_requests: + pull_request27769
2021-11-09 21:06:06miss-islingtonsetmessages: + msg406054
2021-11-09 19:34:03erlendaaslandsetpull_requests: + pull_request27749
2021-11-09 15:33:10miss-islingtonsetnosy: + miss-islington
messages: + msg406027
2021-11-09 13:45:36erlendaaslandsetmessages: + msg406021
2021-11-09 13:39:09erlendaaslandsetpull_requests: + pull_request27737
2021-11-09 12:48:53erlendaaslandsetpull_requests: + pull_request27736
2021-11-08 18:31:22christian.heimessetmessages: + msg405978
2021-11-08 17:58:32christian.heimessetmessages: + msg405977
2021-11-08 09:24:37erlendaaslandsetpull_requests: + pull_request27719
2021-11-08 09:18:34erlendaaslandsetnosy: + erlendaasland
2021-11-08 07:06:40christian.heimessetmessages: + msg405932
2021-11-07 10:18:49christian.heimessetmessages: + msg405896
2021-11-06 16:57:12christian.heimessetmessages: + msg405865
2021-11-06 16:05:00christian.heimessetpull_requests: + pull_request27697
2021-11-06 16:01:38christian.heimessetpull_requests: + pull_request27696
2021-11-05 15:24:24christian.heimessetkeywords: + patch
stage: patch review
pull_requests: + pull_request27684
2021-11-05 14:07:39christian.heimessetmessages: + msg405799
2021-11-05 10:05:47christian.heimescreate