xref: /third_party/python/Doc/using/configure.rst (revision 7db96d56)
1****************
2Configure Python
3****************
4
5.. _configure-options:
6
7Configure Options
8=================
9
10List all ``./configure`` script options using::
11
12    ./configure --help
13
14See also the :file:`Misc/SpecialBuilds.txt` in the Python source distribution.
15
16General Options
17---------------
18
19.. cmdoption:: --enable-loadable-sqlite-extensions
20
21   Support loadable extensions in the :mod:`_sqlite` extension module (default
22   is no).
23
24   See the :meth:`sqlite3.Connection.enable_load_extension` method of the
25   :mod:`sqlite3` module.
26
27   .. versionadded:: 3.6
28
29.. cmdoption:: --disable-ipv6
30
31   Disable IPv6 support (enabled by default if supported), see the
32   :mod:`socket` module.
33
34.. cmdoption:: --enable-big-digits=[15|30]
35
36   Define the size in bits of Python :class:`int` digits: 15 or 30 bits.
37
38   By default, the digit size is 30.
39
40   Define the ``PYLONG_BITS_IN_DIGIT`` to ``15`` or ``30``.
41
42   See :data:`sys.int_info.bits_per_digit <sys.int_info>`.
43
44.. cmdoption:: --with-cxx-main
45.. cmdoption:: --with-cxx-main=COMPILER
46
47   Compile the Python ``main()`` function and link Python executable with C++
48   compiler: ``$CXX``, or *COMPILER* if specified.
49
50.. cmdoption:: --with-suffix=SUFFIX
51
52   Set the Python executable suffix to *SUFFIX*.
53
54   The default suffix is ``.exe`` on Windows and macOS (``python.exe``
55   executable), ``.js`` on Emscripten node, ``.html`` on Emscripten browser,
56   ``.wasm`` on WASI, and an empty string on other platforms (``python``
57   executable).
58
59   .. versionchanged:: 3.11
60      The default suffix on WASM platform is one of ``.js``, ``.html``
61      or ``.wasm``.
62
63.. cmdoption:: --with-tzpath=<list of absolute paths separated by pathsep>
64
65   Select the default time zone search path for :data:`zoneinfo.TZPATH`.
66   See the :ref:`Compile-time configuration
67   <zoneinfo_data_compile_time_config>` of the :mod:`zoneinfo` module.
68
69   Default: ``/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo``.
70
71   See :data:`os.pathsep` path separator.
72
73   .. versionadded:: 3.9
74
75.. cmdoption:: --without-decimal-contextvar
76
77   Build the ``_decimal`` extension module using a thread-local context rather
78   than a coroutine-local context (default), see the :mod:`decimal` module.
79
80   See :data:`decimal.HAVE_CONTEXTVAR` and the :mod:`contextvars` module.
81
82   .. versionadded:: 3.9
83
84.. cmdoption:: --with-dbmliborder=<list of backend names>
85
86   Override order to check db backends for the :mod:`dbm` module
87
88   A valid value is a colon (``:``) separated string with the backend names:
89
90   * ``ndbm``;
91   * ``gdbm``;
92   * ``bdb``.
93
94.. cmdoption:: --without-c-locale-coercion
95
96   Disable C locale coercion to a UTF-8 based locale (enabled by default).
97
98   Don't define the ``PY_COERCE_C_LOCALE`` macro.
99
100   See :envvar:`PYTHONCOERCECLOCALE` and the :pep:`538`.
101
102.. cmdoption:: --with-platlibdir=DIRNAME
103
104   Python library directory name (default is ``lib``).
105
106   Fedora and SuSE use ``lib64`` on 64-bit platforms.
107
108   See :data:`sys.platlibdir`.
109
110   .. versionadded:: 3.9
111
112.. cmdoption:: --with-wheel-pkg-dir=PATH
113
114   Directory of wheel packages used by the :mod:`ensurepip` module
115   (none by default).
116
117   Some Linux distribution packaging policies recommend against bundling
118   dependencies. For example, Fedora installs wheel packages in the
119   ``/usr/share/python-wheels/`` directory and don't install the
120   :mod:`ensurepip._bundled` package.
121
122   .. versionadded:: 3.10
123
124.. cmdoption:: --with-pkg-config=[check|yes|no]
125
126   Whether configure should use :program:`pkg-config` to detect build
127   dependencies.
128
129   * ``check`` (default): :program:`pkg-config` is optional
130   * ``yes``: :program:`pkg-config` is mandatory
131   * ``no``: configure does not use :program:`pkg-config` even when present
132
133   .. versionadded:: 3.11
134
135.. cmdoption:: --enable-pystats
136
137   Turn on internal statistics gathering.
138
139   The statistics will be dumped to a arbitrary (probably unique) file in
140   ``/tmp/py_stats/``, or ``C:\temp\py_stats\`` on Windows.
141
142   Use ``Tools/scripts/summarize_stats.py`` to read the stats.
143
144   .. versionadded:: 3.11
145
146WebAssembly Options
147-------------------
148
149.. cmdoption:: --with-emscripten-target=[browser|node]
150
151   Set build flavor for ``wasm32-emscripten``.
152
153   * ``browser`` (default): preload minimal stdlib, default MEMFS.
154   * ``node``: NODERAWFS and pthread support.
155
156   .. versionadded:: 3.11
157
158.. cmdoption:: --enable-wasm-dynamic-linking
159
160   Turn on dynamic linking support for WASM.
161
162   Dynamic linking enables ``dlopen``. File size of the executable
163   increases due to limited dead code elimination and additional features.
164
165   .. versionadded:: 3.11
166
167.. cmdoption:: --enable-wasm-pthreads
168
169   Turn on pthreads support for WASM.
170
171   .. versionadded:: 3.11
172
173
174Install Options
175---------------
176
177.. cmdoption:: --prefix=PREFIX
178
179   Install architecture-independent files in PREFIX. On Unix, it
180   defaults to :file:`/usr/local`.
181
182   This value can be retrived at runtime using :data:`sys.prefix`.
183
184   As an example, one can use ``--prefix="$HOME/.local/"`` to install
185   a Python in its home directory.
186
187.. cmdoption:: --exec-prefix=EPREFIX
188
189   Install architecture-dependent files in EPREFIX, defaults to :option:`--prefix`.
190
191   This value can be retrived at runtime using :data:`sys.exec_prefix`.
192
193.. cmdoption:: --disable-test-modules
194
195   Don't build nor install test modules, like the :mod:`test` package or the
196   :mod:`_testcapi` extension module (built and installed by default).
197
198   .. versionadded:: 3.10
199
200.. cmdoption:: --with-ensurepip=[upgrade|install|no]
201
202   Select the :mod:`ensurepip` command run on Python installation:
203
204   * ``upgrade`` (default): run ``python -m ensurepip --altinstall --upgrade``
205     command.
206   * ``install``: run ``python -m ensurepip --altinstall`` command;
207   * ``no``: don't run ensurepip;
208
209   .. versionadded:: 3.6
210
211
212Performance options
213-------------------
214
215Configuring Python using ``--enable-optimizations --with-lto`` (PGO + LTO) is
216recommended for best performance.
217
218.. cmdoption:: --enable-optimizations
219
220   Enable Profile Guided Optimization (PGO) using :envvar:`PROFILE_TASK`
221   (disabled by default).
222
223   The C compiler Clang requires ``llvm-profdata`` program for PGO. On
224   macOS, GCC also requires it: GCC is just an alias to Clang on macOS.
225
226   Disable also semantic interposition in libpython if ``--enable-shared`` and
227   GCC is used: add ``-fno-semantic-interposition`` to the compiler and linker
228   flags.
229
230   .. versionadded:: 3.6
231
232   .. versionchanged:: 3.10
233      Use ``-fno-semantic-interposition`` on GCC.
234
235.. envvar:: PROFILE_TASK
236
237   Environment variable used in the Makefile: Python command line arguments for
238   the PGO generation task.
239
240   Default: ``-m test --pgo --timeout=$(TESTTIMEOUT)``.
241
242   .. versionadded:: 3.8
243
244.. cmdoption:: --with-lto=[full|thin|no|yes]
245
246   Enable Link Time Optimization (LTO) in any build (disabled by default).
247
248   The C compiler Clang requires ``llvm-ar`` for LTO (``ar`` on macOS), as well
249   as an LTO-aware linker (``ld.gold`` or ``lld``).
250
251   .. versionadded:: 3.6
252
253   .. versionadded:: 3.11
254      To use ThinLTO feature, use ``--with-lto=thin`` on Clang.
255
256.. cmdoption:: --with-computed-gotos
257
258   Enable computed gotos in evaluation loop (enabled by default on supported
259   compilers).
260
261.. cmdoption:: --without-pymalloc
262
263   Disable the specialized Python memory allocator :ref:`pymalloc <pymalloc>`
264   (enabled by default).
265
266   See also :envvar:`PYTHONMALLOC` environment variable.
267
268.. cmdoption:: --without-doc-strings
269
270   Disable static documentation strings to reduce the memory footprint (enabled
271   by default). Documentation strings defined in Python are not affected.
272
273   Don't define the ``WITH_DOC_STRINGS`` macro.
274
275   See the ``PyDoc_STRVAR()`` macro.
276
277.. cmdoption:: --enable-profiling
278
279   Enable C-level code profiling with ``gprof`` (disabled by default).
280
281
282.. _debug-build:
283
284Python Debug Build
285------------------
286
287A debug build is Python built with the :option:`--with-pydebug` configure
288option.
289
290Effects of a debug build:
291
292* Display all warnings by default: the list of default warning filters is empty
293  in the :mod:`warnings` module.
294* Add ``d`` to :data:`sys.abiflags`.
295* Add :func:`sys.gettotalrefcount` function.
296* Add :option:`-X showrefcount <-X>` command line option.
297* Add :envvar:`PYTHONTHREADDEBUG` environment variable.
298* Add support for the ``__lltrace__`` variable: enable low-level tracing in the
299  bytecode evaluation loop if the variable is defined.
300* Install :ref:`debug hooks on memory allocators <default-memory-allocators>`
301  to detect buffer overflow and other memory errors.
302* Define ``Py_DEBUG`` and ``Py_REF_DEBUG`` macros.
303* Add runtime checks: code surrounded by ``#ifdef Py_DEBUG`` and ``#endif``.
304  Enable ``assert(...)`` and ``_PyObject_ASSERT(...)`` assertions: don't set
305  the ``NDEBUG`` macro (see also the :option:`--with-assertions` configure
306  option). Main runtime checks:
307
308  * Add sanity checks on the function arguments.
309  * Unicode and int objects are created with their memory filled with a pattern
310    to detect usage of uninitialized objects.
311  * Ensure that functions which can clear or replace the current exception are
312    not called with an exception raised.
313  * Check that deallocator functions don't change the current exception.
314  * The garbage collector (:func:`gc.collect` function) runs some basic checks
315    on objects consistency.
316  * The :c:macro:`Py_SAFE_DOWNCAST()` macro checks for integer underflow and
317    overflow when downcasting from wide types to narrow types.
318
319See also the :ref:`Python Development Mode <devmode>` and the
320:option:`--with-trace-refs` configure option.
321
322.. versionchanged:: 3.8
323   Release builds and debug builds are now ABI compatible: defining the
324   ``Py_DEBUG`` macro no longer implies the ``Py_TRACE_REFS`` macro (see the
325   :option:`--with-trace-refs` option), which introduces the only ABI
326   incompatibility.
327
328
329Debug options
330-------------
331
332.. cmdoption:: --with-pydebug
333
334   :ref:`Build Python in debug mode <debug-build>`: define the ``Py_DEBUG``
335   macro (disabled by default).
336
337.. cmdoption:: --with-trace-refs
338
339   Enable tracing references for debugging purpose (disabled by default).
340
341   Effects:
342
343   * Define the ``Py_TRACE_REFS`` macro.
344   * Add :func:`sys.getobjects` function.
345   * Add :envvar:`PYTHONDUMPREFS` environment variable.
346
347   This build is not ABI compatible with release build (default build) or debug
348   build (``Py_DEBUG`` and ``Py_REF_DEBUG`` macros).
349
350   .. versionadded:: 3.8
351
352.. cmdoption:: --with-assertions
353
354   Build with C assertions enabled (default is no): ``assert(...);`` and
355   ``_PyObject_ASSERT(...);``.
356
357   If set, the ``NDEBUG`` macro is not defined in the :envvar:`OPT` compiler
358   variable.
359
360   See also the :option:`--with-pydebug` option (:ref:`debug build
361   <debug-build>`) which also enables assertions.
362
363   .. versionadded:: 3.6
364
365.. cmdoption:: --with-valgrind
366
367   Enable Valgrind support (default is no).
368
369.. cmdoption:: --with-dtrace
370
371   Enable DTrace support (default is no).
372
373   See :ref:`Instrumenting CPython with DTrace and SystemTap
374   <instrumentation>`.
375
376   .. versionadded:: 3.6
377
378.. cmdoption:: --with-address-sanitizer
379
380   Enable AddressSanitizer memory error detector, ``asan`` (default is no).
381
382   .. versionadded:: 3.6
383
384.. cmdoption:: --with-memory-sanitizer
385
386   Enable MemorySanitizer allocation error detector, ``msan`` (default is no).
387
388   .. versionadded:: 3.6
389
390.. cmdoption:: --with-undefined-behavior-sanitizer
391
392   Enable UndefinedBehaviorSanitizer undefined behaviour detector, ``ubsan``
393   (default is no).
394
395   .. versionadded:: 3.6
396
397
398Linker options
399--------------
400
401.. cmdoption:: --enable-shared
402
403   Enable building a shared Python library: ``libpython`` (default is no).
404
405.. cmdoption:: --without-static-libpython
406
407   Do not build ``libpythonMAJOR.MINOR.a`` and do not install ``python.o``
408   (built and enabled by default).
409
410   .. versionadded:: 3.10
411
412
413Libraries options
414-----------------
415
416.. cmdoption:: --with-libs='lib1 ...'
417
418   Link against additional libraries (default is no).
419
420.. cmdoption:: --with-system-expat
421
422   Build the :mod:`pyexpat` module using an installed ``expat`` library
423   (default is no).
424
425.. cmdoption:: --with-system-ffi
426
427   Build the :mod:`_ctypes` extension module using an installed ``ffi``
428   library, see the :mod:`ctypes` module (default is system-dependent).
429
430.. cmdoption:: --with-system-libmpdec
431
432   Build the ``_decimal`` extension module using an installed ``mpdec``
433   library, see the :mod:`decimal` module (default is no).
434
435   .. versionadded:: 3.3
436
437.. cmdoption:: --with-readline=editline
438
439   Use ``editline`` library for backend of the :mod:`readline` module.
440
441   Define the ``WITH_EDITLINE`` macro.
442
443   .. versionadded:: 3.10
444
445.. cmdoption:: --without-readline
446
447   Don't build the :mod:`readline` module (built by default).
448
449   Don't define the ``HAVE_LIBREADLINE`` macro.
450
451   .. versionadded:: 3.10
452
453.. cmdoption:: --with-libm=STRING
454
455   Override ``libm`` math library to *STRING* (default is system-dependent).
456
457.. cmdoption:: --with-libc=STRING
458
459   Override ``libc`` C library to *STRING* (default is system-dependent).
460
461.. cmdoption:: --with-openssl=DIR
462
463   Root of the OpenSSL directory.
464
465   .. versionadded:: 3.7
466
467.. cmdoption:: --with-openssl-rpath=[no|auto|DIR]
468
469   Set runtime library directory (rpath) for OpenSSL libraries:
470
471   * ``no`` (default): don't set rpath;
472   * ``auto``: auto-detect rpath from :option:`--with-openssl` and
473     ``pkg-config``;
474   * *DIR*: set an explicit rpath.
475
476   .. versionadded:: 3.10
477
478
479Security Options
480----------------
481
482.. cmdoption:: --with-hash-algorithm=[fnv|siphash13|siphash24]
483
484   Select hash algorithm for use in ``Python/pyhash.c``:
485
486   * ``siphash13`` (default);
487   * ``siphash24``;
488   * ``fnv``.
489
490   .. versionadded:: 3.4
491
492   .. versionadded:: 3.11
493      ``siphash13`` is added and it is the new default.
494
495.. cmdoption:: --with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2
496
497   Built-in hash modules:
498
499   * ``md5``;
500   * ``sha1``;
501   * ``sha256``;
502   * ``sha512``;
503   * ``sha3`` (with shake);
504   * ``blake2``.
505
506   .. versionadded:: 3.9
507
508.. cmdoption:: --with-ssl-default-suites=[python|openssl|STRING]
509
510   Override the OpenSSL default cipher suites string:
511
512   * ``python`` (default): use Python's preferred selection;
513   * ``openssl``: leave OpenSSL's defaults untouched;
514   * *STRING*: use a custom string
515
516   See the :mod:`ssl` module.
517
518   .. versionadded:: 3.7
519
520   .. versionchanged:: 3.10
521
522      The settings ``python`` and *STRING* also set TLS 1.2 as minimum
523      protocol version.
524
525macOS Options
526-------------
527
528See ``Mac/README.rst``.
529
530.. cmdoption:: --enable-universalsdk
531.. cmdoption:: --enable-universalsdk=SDKDIR
532
533   Create a universal binary build. *SDKDIR* specifies which macOS SDK should
534   be used to perform the build (default is no).
535
536.. cmdoption:: --enable-framework
537.. cmdoption:: --enable-framework=INSTALLDIR
538
539   Create a Python.framework rather than a traditional Unix install. Optional
540   *INSTALLDIR* specifies the installation path (default is no).
541
542.. cmdoption:: --with-universal-archs=ARCH
543
544   Specify the kind of universal binary that should be created. This option is
545   only valid when :option:`--enable-universalsdk` is set.
546
547   Options:
548
549   * ``universal2``;
550   * ``32-bit``;
551   * ``64-bit``;
552   * ``3-way``;
553   * ``intel``;
554   * ``intel-32``;
555   * ``intel-64``;
556   * ``all``.
557
558.. cmdoption:: --with-framework-name=FRAMEWORK
559
560   Specify the name for the python framework on macOS only valid when
561   :option:`--enable-framework` is set (default: ``Python``).
562
563
564Cross Compiling Options
565-----------------------
566
567Cross compiling, also known as cross building, can be used to build Python
568for another CPU architecture or platform. Cross compiling requires a Python
569interpreter for the build platform. The version of the build Python must match
570the version of the cross compiled host Python.
571
572.. cmdoption:: --build=BUILD
573
574   configure for building on BUILD, usually guessed by :program:`config.guess`.
575
576.. cmdoption:: --host=HOST
577
578   cross-compile to build programs to run on HOST (target platform)
579
580.. cmdoption:: --with-build-python=path/to/python
581
582   path to build ``python`` binary for cross compiling
583
584   .. versionadded:: 3.11
585
586.. cmdoption:: CONFIG_SITE=file
587
588   An environment variable that points to a file with configure overrides.
589
590   Example *config.site* file::
591
592      # config.site-aarch64
593      ac_cv_buggy_getaddrinfo=no
594      ac_cv_file__dev_ptmx=yes
595      ac_cv_file__dev_ptc=no
596
597
598Cross compiling example::
599
600   CONFIG_SITE=config.site-aarch64 ../configure \
601       --build=x86_64-pc-linux-gnu \
602       --host=aarch64-unknown-linux-gnu \
603       --with-build-python=../x86_64/python
604
605
606Python Build System
607===================
608
609Main files of the build system
610------------------------------
611
612* :file:`configure.ac` => :file:`configure`;
613* :file:`Makefile.pre.in` => :file:`Makefile` (created by :file:`configure`);
614* :file:`pyconfig.h` (created by :file:`configure`);
615* :file:`Modules/Setup`: C extensions built by the Makefile using
616  :file:`Module/makesetup` shell script;
617* :file:`setup.py`: C extensions built using the :mod:`distutils` module.
618
619Main build steps
620----------------
621
622* C files (``.c``) are built as object files (``.o``).
623* A static ``libpython`` library (``.a``) is created from objects files.
624* ``python.o`` and the static ``libpython`` library are linked into the
625  final ``python`` program.
626* C extensions are built by the Makefile (see :file:`Modules/Setup`)
627  and ``python setup.py build``.
628
629Main Makefile targets
630---------------------
631
632* ``make``: Build Python with the standard library.
633* ``make platform:``: build the ``python`` program, but don't build the
634  standard library extension modules.
635* ``make profile-opt``: build Python using Profile Guided Optimization (PGO).
636  You can use the configure :option:`--enable-optimizations` option to make
637  this the default target of the ``make`` command (``make all`` or just
638  ``make``).
639* ``make buildbottest``: Build Python and run the Python test suite, the same
640  way than buildbots test Python. Set ``TESTTIMEOUT`` variable (in seconds)
641  to change the test timeout (1200 by default: 20 minutes).
642* ``make install``: Build and install Python.
643* ``make regen-all``: Regenerate (almost) all generated files;
644  ``make regen-stdlib-module-names`` and ``autoconf`` must be run separately
645  for the remaining generated files.
646* ``make clean``: Remove built files.
647* ``make distclean``: Same than ``make clean``, but remove also files created
648  by the configure script.
649
650C extensions
651------------
652
653Some C extensions are built as built-in modules, like the ``sys`` module.
654They are built with the ``Py_BUILD_CORE_BUILTIN`` macro defined.
655Built-in modules have no ``__file__`` attribute::
656
657    >>> import sys
658    >>> sys
659    <module 'sys' (built-in)>
660    >>> sys.__file__
661    Traceback (most recent call last):
662      File "<stdin>", line 1, in <module>
663    AttributeError: module 'sys' has no attribute '__file__'
664
665Other C extensions are built as dynamic libraries, like the ``_asyncio`` module.
666They are built with the ``Py_BUILD_CORE_MODULE`` macro defined.
667Example on Linux x86-64::
668
669    >>> import _asyncio
670    >>> _asyncio
671    <module '_asyncio' from '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'>
672    >>> _asyncio.__file__
673    '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'
674
675:file:`Modules/Setup` is used to generate Makefile targets to build C extensions.
676At the beginning of the files, C extensions are built as built-in modules.
677Extensions defined after the ``*shared*`` marker are built as dynamic libraries.
678
679The :file:`setup.py` script only builds C extensions as shared libraries using
680the :mod:`distutils` module.
681
682The :c:macro:`PyAPI_FUNC()`, :c:macro:`PyAPI_API()` and
683:c:macro:`PyMODINIT_FUNC()` macros of :file:`Include/pyport.h` are defined
684differently depending if the ``Py_BUILD_CORE_MODULE`` macro is defined:
685
686* Use ``Py_EXPORTED_SYMBOL`` if the ``Py_BUILD_CORE_MODULE`` is defined
687* Use ``Py_IMPORTED_SYMBOL`` otherwise.
688
689If the ``Py_BUILD_CORE_BUILTIN`` macro is used by mistake on a C extension
690built as a shared library, its ``PyInit_xxx()`` function is not exported,
691causing an :exc:`ImportError` on import.
692
693
694Compiler and linker flags
695=========================
696
697Options set by the ``./configure`` script and environment variables and used by
698``Makefile``.
699
700Preprocessor flags
701------------------
702
703.. envvar:: CONFIGURE_CPPFLAGS
704
705   Value of :envvar:`CPPFLAGS` variable passed to the ``./configure`` script.
706
707   .. versionadded:: 3.6
708
709.. envvar:: CPPFLAGS
710
711   (Objective) C/C++ preprocessor flags, e.g. ``-I<include dir>`` if you have
712   headers in a nonstandard directory ``<include dir>``.
713
714   Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's
715   value for setup.py to be able to build extension modules using the
716   directories specified in the environment variables.
717
718.. envvar:: BASECPPFLAGS
719
720   .. versionadded:: 3.4
721
722.. envvar:: PY_CPPFLAGS
723
724   Extra preprocessor flags added for building the interpreter object files.
725
726   Default: ``$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)``.
727
728   .. versionadded:: 3.2
729
730Compiler flags
731--------------
732
733.. envvar:: CC
734
735   C compiler command.
736
737   Example: ``gcc -pthread``.
738
739.. envvar:: MAINCC
740
741   C compiler command used to build the ``main()`` function of programs like
742   ``python``.
743
744   Variable set by the :option:`--with-cxx-main` option of the configure
745   script.
746
747   Default: ``$(CC)``.
748
749.. envvar:: CXX
750
751   C++ compiler command.
752
753   Used if the :option:`--with-cxx-main` option is used.
754
755   Example: ``g++ -pthread``.
756
757.. envvar:: CFLAGS
758
759   C compiler flags.
760
761.. envvar:: CFLAGS_NODIST
762
763   :envvar:`CFLAGS_NODIST` is used for building the interpreter and stdlib C
764   extensions.  Use it when a compiler flag should *not* be part of the
765   distutils :envvar:`CFLAGS` once Python is installed (:issue:`21121`).
766
767   In particular, :envvar:`CFLAGS` should not contain:
768
769   * the compiler flag ``-I`` (for setting the search path for include files).
770     The ``-I`` flags are processed from left to right, and any flags in
771     :envvar:`CFLAGS` would take precedence over user- and package-supplied ``-I``
772     flags.
773
774   * hardening flags such as ``-Werror`` because distributions cannot control
775     whether packages installed by users conform to such heightened
776     standards.
777
778   .. versionadded:: 3.5
779
780.. envvar:: EXTRA_CFLAGS
781
782   Extra C compiler flags.
783
784.. envvar:: CONFIGURE_CFLAGS
785
786   Value of :envvar:`CFLAGS` variable passed to the ``./configure``
787   script.
788
789   .. versionadded:: 3.2
790
791.. envvar:: CONFIGURE_CFLAGS_NODIST
792
793   Value of :envvar:`CFLAGS_NODIST` variable passed to the ``./configure``
794   script.
795
796   .. versionadded:: 3.5
797
798.. envvar:: BASECFLAGS
799
800   Base compiler flags.
801
802.. envvar:: OPT
803
804   Optimization flags.
805
806.. envvar:: CFLAGS_ALIASING
807
808   Strict or non-strict aliasing flags used to compile ``Python/dtoa.c``.
809
810   .. versionadded:: 3.7
811
812.. envvar:: CCSHARED
813
814   Compiler flags used to build a shared library.
815
816   For example, ``-fPIC`` is used on Linux and on BSD.
817
818.. envvar:: CFLAGSFORSHARED
819
820   Extra C flags added for building the interpreter object files.
821
822   Default: ``$(CCSHARED)`` when :option:`--enable-shared` is used, or an empty
823   string otherwise.
824
825.. envvar:: PY_CFLAGS
826
827   Default: ``$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)``.
828
829.. envvar:: PY_CFLAGS_NODIST
830
831   Default: ``$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/internal``.
832
833   .. versionadded:: 3.5
834
835.. envvar:: PY_STDMODULE_CFLAGS
836
837   C flags used for building the interpreter object files.
838
839   Default: ``$(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED)``.
840
841   .. versionadded:: 3.7
842
843.. envvar:: PY_CORE_CFLAGS
844
845   Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE``.
846
847   .. versionadded:: 3.2
848
849.. envvar:: PY_BUILTIN_MODULE_CFLAGS
850
851   Compiler flags to build a standard library extension module as a built-in
852   module, like the :mod:`posix` module.
853
854   Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN``.
855
856   .. versionadded:: 3.8
857
858.. envvar:: PURIFY
859
860   Purify command. Purify is a memory debugger program.
861
862   Default: empty string (not used).
863
864
865Linker flags
866------------
867
868.. envvar:: LINKCC
869
870   Linker command used to build programs like ``python`` and ``_testembed``.
871
872   Default: ``$(PURIFY) $(MAINCC)``.
873
874.. envvar:: CONFIGURE_LDFLAGS
875
876   Value of :envvar:`LDFLAGS` variable passed to the ``./configure`` script.
877
878   Avoid assigning :envvar:`CFLAGS`, :envvar:`LDFLAGS`, etc. so users can use
879   them on the command line to append to these values without stomping the
880   pre-set values.
881
882   .. versionadded:: 3.2
883
884.. envvar:: LDFLAGS_NODIST
885
886   :envvar:`LDFLAGS_NODIST` is used in the same manner as
887   :envvar:`CFLAGS_NODIST`.  Use it when a linker flag should *not* be part of
888   the distutils :envvar:`LDFLAGS` once Python is installed (:issue:`35257`).
889
890   In particular, :envvar:`LDFLAGS` should not contain:
891
892   * the compiler flag ``-L`` (for setting the search path for libraries).
893     The ``-L`` flags are processed from left to right, and any flags in
894     :envvar:`LDFLAGS` would take precedence over user- and package-supplied ``-L``
895     flags.
896
897.. envvar:: CONFIGURE_LDFLAGS_NODIST
898
899   Value of :envvar:`LDFLAGS_NODIST` variable passed to the ``./configure``
900   script.
901
902   .. versionadded:: 3.8
903
904.. envvar:: LDFLAGS
905
906   Linker flags, e.g. ``-L<lib dir>`` if you have libraries in a nonstandard
907   directory ``<lib dir>``.
908
909   Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's
910   value for setup.py to be able to build extension modules using the
911   directories specified in the environment variables.
912
913.. envvar:: LIBS
914
915   Linker flags to pass libraries to the linker when linking the Python
916   executable.
917
918   Example: ``-lrt``.
919
920.. envvar:: LDSHARED
921
922   Command to build a shared library.
923
924   Default: ``@LDSHARED@ $(PY_LDFLAGS)``.
925
926.. envvar:: BLDSHARED
927
928   Command to build ``libpython`` shared library.
929
930   Default: ``@BLDSHARED@ $(PY_CORE_LDFLAGS)``.
931
932.. envvar:: PY_LDFLAGS
933
934   Default: ``$(CONFIGURE_LDFLAGS) $(LDFLAGS)``.
935
936.. envvar:: PY_LDFLAGS_NODIST
937
938   Default: ``$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)``.
939
940   .. versionadded:: 3.8
941
942.. envvar:: PY_CORE_LDFLAGS
943
944   Linker flags used for building the interpreter object files.
945
946   .. versionadded:: 3.8
947