blob: 85c9018067e0473654a5a5a79776cad8d13b461d [file] [log] [blame]
Victor Stinnera41782c2021-04-08 22:32:21 +02001****************
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), see the :mod:`sqlite3` module.
23
24 .. versionadded:: 3.6
25
26.. cmdoption:: --disable-ipv6
27
28 Disable IPv6 support (enabled by default if supported), see the
29 :mod:`socket` module.
30
Victor Stinner54366952021-04-09 01:58:20 +020031.. cmdoption:: --enable-big-digits=[15|30]
Victor Stinnera41782c2021-04-08 22:32:21 +020032
Victor Stinner54366952021-04-09 01:58:20 +020033 Define the size in bits of Python :class:`int` digits: 15 or 30 bits.
34
35 By default, the number of bits is selected depending on ``sizeof(void*)``:
36 30 bits if ``void*`` size is 64-bit or larger, 15 bits otherwise.
37
38 Define the ``PYLONG_BITS_IN_DIGIT`` to ``15`` or ``30``.
Victor Stinnera41782c2021-04-08 22:32:21 +020039
40 See :data:`sys.int_info.bits_per_digit <sys.int_info>`.
41
Victor Stinner54366952021-04-09 01:58:20 +020042.. cmdoption:: --with-cxx-main
43.. cmdoption:: --with-cxx-main=COMPILER
Victor Stinnera41782c2021-04-08 22:32:21 +020044
45 Compile the Python ``main()`` function and link Python executable with C++
Victor Stinner54366952021-04-09 01:58:20 +020046 compiler: ``$CXX``, or *COMPILER* if specified.
Victor Stinnera41782c2021-04-08 22:32:21 +020047
48.. cmdoption:: --with-suffix=SUFFIX
49
Victor Stinner54366952021-04-09 01:58:20 +020050 Set the Python executable suffix to *SUFFIX*.
51
52 The default suffix is ``.exe`` on Windows and macOS (``python.exe``
53 executable), and an empty string on other platforms (``python`` executable).
Victor Stinnera41782c2021-04-08 22:32:21 +020054
55.. cmdoption:: --with-tzpath=<list of absolute paths separated by pathsep>
56
57 Select the default time zone search path for :data:`zoneinfo.TZPATH`,
58 see the :mod:`zoneinfo` module.
59
Victor Stinner54366952021-04-09 01:58:20 +020060 Default: ``/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo``.
61
62 See :data:`os.pathsep` path separator.
63
Victor Stinnera41782c2021-04-08 22:32:21 +020064 .. versionadded:: 3.9
65
66.. cmdoption:: --without-decimal-contextvar
67
68 Build the ``_decimal`` extension module using a thread-local context rather
69 than a coroutine-local context (default), see the :mod:`decimal` module.
70
Victor Stinner54366952021-04-09 01:58:20 +020071 See :data:`decimal.HAVE_CONTEXTVAR` and the :mod:`contextvars` module.
Victor Stinnera41782c2021-04-08 22:32:21 +020072
73 .. versionadded:: 3.9
74
75.. cmdoption:: --with-dbmliborder=db1:db2:...
76
77 Override order to check db backends for the :mod:`dbm` module
78
Victor Stinner54366952021-04-09 01:58:20 +020079 A valid value is a colon (``:``) separated string with the backend names:
Victor Stinnera41782c2021-04-08 22:32:21 +020080
81 * ``ndbm``;
82 * ``gdbm``;
83 * ``bdb``.
84
Victor Stinner54366952021-04-09 01:58:20 +020085.. cmdoption:: --without-c-locale-coercion
Victor Stinnera41782c2021-04-08 22:32:21 +020086
Victor Stinner54366952021-04-09 01:58:20 +020087 Disable C locale coercion to a UTF-8 based locale (enabled by default).
88
89 Don't define the ``PY_COERCE_C_LOCALE`` macro.
Victor Stinnera41782c2021-04-08 22:32:21 +020090
91 See :envvar:`PYTHONCOERCECLOCALE` and the :pep:`538`.
92
93.. cmdoption:: --with-platlibdir=DIRNAME
94
95 Python library directory name (default is ``lib``).
96
97 Fedora and SuSE use ``lib64`` on 64-bit platforms.
98
99 See :data:`sys.platlibdir`.
100
101 .. versionadded:: 3.9
102
103.. cmdoption:: --with-wheel-pkg-dir=PATH
104
105 Directory of wheel packages used by the :mod:`ensurepip` module
106 (none by default).
107
108 Some Linux distribution packaging policies recommend against bundling
109 dependencies. For example, Fedora installs wheel packages in the
110 ``/usr/share/python-wheels/`` directory and don't install the
111 :mod:`ensurepip._bundled` package.
112
113 .. versionadded:: 3.10
114
115
116Install Options
117---------------
118
119.. cmdoption:: --disable-test-modules
120
121 Don't build nor install test modules, like the :mod:`test` package or the
122 :mod:`_testcapi` extension module (built and installed by default).
123
124 .. versionadded:: 3.10
125
Victor Stinner54366952021-04-09 01:58:20 +0200126.. cmdoption:: --with-ensurepip=[upgrade|install|no]
Victor Stinnera41782c2021-04-08 22:32:21 +0200127
Victor Stinner54366952021-04-09 01:58:20 +0200128 Select the :mod:`ensurepip` command run on Python installation:
129
130 * ``upgrade`` (default): run ``python -m ensurepip --altinstall --upgrade``
131 command.
132 * ``install``: run ``python -m ensurepip --altinstall`` command;
133 * ``no``: don't run ensurepip;
Victor Stinnera41782c2021-04-08 22:32:21 +0200134
135 .. versionadded:: 3.6
136
137
138Performance options
139-------------------
140
141Configuring Python using ``--enable-optimizations --with-lto`` (PGO + LTO) is
142recommended for best performance.
143
144.. cmdoption:: --enable-optimizations
145
146 Enable Profile Guided Optimization (PGO) using :envvar:`PROFILE_TASK`
147 (disabled by default).
148
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200149 The C compiler Clang requires ``llvm-profdata`` program for PGO. On
150 macOS, GCC also requires it: GCC is just an alias to Clang on macOS.
151
Victor Stinnera41782c2021-04-08 22:32:21 +0200152 Disable also semantic interposition in libpython if ``--enable-shared`` and
153 GCC is used: add ``-fno-semantic-interposition`` to the compiler and linker
154 flags.
155
156 .. versionadded:: 3.6
157
158 .. versionchanged:: 3.10
159 Use ``-fno-semantic-interposition`` on GCC.
160
161.. envvar:: PROFILE_TASK
162
163 Environment variable used in the Makefile: Python command line arguments for
164 the PGO generation task.
165
166 Default: ``-m test --pgo --timeout=$(TESTTIMEOUT)``.
167
168 .. versionadded:: 3.8
169
170.. cmdoption:: --with-lto
171
172 Enable Link Time Optimization (LTO) in any build (disabled by default).
173
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200174 The C compiler Clang requires ``llvm-ar`` for LTO, as well as an LTO-aware
175 linker (``ld.gold`` or ``lld``).
176
Victor Stinnera41782c2021-04-08 22:32:21 +0200177 .. versionadded:: 3.6
178
179.. cmdoption:: --with-computed-gotos
180
181 Enable computed gotos in evaluation loop (enabled by default on supported
182 compilers).
183
184.. cmdoption:: --without-pymalloc
185
186 Disable the specialized Python memory allocator :ref:`pymalloc <pymalloc>`
187 (enabled by default).
188
189 See also :envvar:`PYTHONMALLOC` environment variable.
190
191.. cmdoption:: --without-doc-strings
192
193 Disable static documentation strings to reduce the memory footprint (enabled
194 by default). Documentation strings defined in Python are not affected.
195
Victor Stinner54366952021-04-09 01:58:20 +0200196 Don't define the ``WITH_DOC_STRINGS`` macro.
197
198 See the ``PyDoc_STRVAR()`` macro.
Victor Stinnera41782c2021-04-08 22:32:21 +0200199
200.. cmdoption:: --enable-profiling
201
202 Enable C-level code profiling with ``gprof`` (disabled by default).
203
204
205.. _debug-build:
206
207Debug build
208-----------
209
210A debug build is Python built with the :option:`--with-pydebug` configure
211option.
212
213Effects of a debug build:
214
215* Define ``Py_DEBUG`` and ``Py_REF_DEBUG`` macros.
216* Add ``d`` to :data:`sys.abiflags`.
217* Add :func:`sys.gettotalrefcount` function.
218* Add :option:`-X showrefcount <-X>` command line option.
219* Add :envvar:`PYTHONTHREADDEBUG` environment variable.
Victor Stinner54366952021-04-09 01:58:20 +0200220* Add support for the ``__ltrace__`` variable: enable low-level tracing in the
221 bytecode evaluation loop if the variable is defined.
Victor Stinnera41782c2021-04-08 22:32:21 +0200222* The list of default warning filters is empty in the :mod:`warnings` module.
223* Install debug hooks on memory allocators to detect buffer overflow and other
224 memory errors: see :c:func:`PyMem_SetupDebugHooks`.
225* Build Python with assertions (don't set ``NDEBUG`` macro):
Victor Stinner54366952021-04-09 01:58:20 +0200226 ``assert(...);`` and ``_PyObject_ASSERT(...);``.
Victor Stinnera41782c2021-04-08 22:32:21 +0200227 See also the :option:`--with-assertions` configure option.
Victor Stinnera41782c2021-04-08 22:32:21 +0200228* Unicode and int objects are created with their memory filled with a pattern
229 to help detecting uninitialized bytes.
230* Many functions ensure that are not called with an exception raised, since
231 they can clear or replace the current exception.
Victor Stinner54366952021-04-09 01:58:20 +0200232* The garbage collector (:func:`gc.collect` function) runs some basic checks on
233 objects consistency.
234* More generally, add runtime checks, code surroundeded by ``#ifdef Py_DEBUG``
235 and ``#endif``.
Victor Stinnera41782c2021-04-08 22:32:21 +0200236
237See also the :ref:`Python Development Mode <devmode>` and the
238:option:`--with-trace-refs` configure option.
239
240.. versionchanged:: 3.8
241 Release builds and debug builds are now ABI compatible: defining the
242 ``Py_DEBUG`` macro no longer implies the ``Py_TRACE_REFS`` macro, which
243 introduces the only ABI incompatibility.
244
245
246Debug options
247-------------
248
249.. cmdoption:: --with-pydebug
250
Victor Stinner54366952021-04-09 01:58:20 +0200251 :ref:`Build Python in debug mode <debug-build>`: define the ``Py_DEBUG``
252 macro (disabled by default).
Victor Stinnera41782c2021-04-08 22:32:21 +0200253
254.. cmdoption:: --with-trace-refs
255
256 Enable tracing references for debugging purpose (disabled by default).
257
258 Effects:
259
260 * Define the ``Py_TRACE_REFS`` macro.
261 * Add :func:`sys.getobjects` function.
262 * Add :envvar:`PYTHONDUMPREFS` environment variable.
263
264 This build is not ABI compatible with release build (default build) or debug
Victor Stinner54366952021-04-09 01:58:20 +0200265 build (``Py_DEBUG`` and ``Py_REF_DEBUG`` macros).
Victor Stinnera41782c2021-04-08 22:32:21 +0200266
267 .. versionadded:: 3.8
268
269.. cmdoption:: --with-assertions
270
Victor Stinner54366952021-04-09 01:58:20 +0200271 Build with C assertions enabled (default is no): ``assert(...);`` and
272 ``_PyObject_ASSERT(...);``.
Victor Stinnera41782c2021-04-08 22:32:21 +0200273
274 If set, the ``NDEBUG`` macro is not defined in the :envvar:`OPT` compiler
275 variable.
276
277 See also the :option:`--with-pydebug` option (:ref:`debug build
278 <debug-build>`) which also enables assertions.
279
280 .. versionadded:: 3.6
281
282.. cmdoption:: --with-valgrind
283
284 Enable Valgrind support (default is no).
285
286.. cmdoption:: --with-dtrace
287
288 Enable DTrace support (default is no).
289
290 .. versionadded:: 3.6
291
292.. cmdoption:: --with-address-sanitizer
293
Victor Stinner54366952021-04-09 01:58:20 +0200294 Enable AddressSanitizer memory error detector, ``asan`` (default is no).
Victor Stinnera41782c2021-04-08 22:32:21 +0200295
296 .. versionadded:: 3.6
297
298.. cmdoption:: --with-memory-sanitizer
299
Victor Stinner54366952021-04-09 01:58:20 +0200300 Enable MemorySanitizer allocation error detector, ``msan`` (default is no).
Victor Stinnera41782c2021-04-08 22:32:21 +0200301
302 .. versionadded:: 3.6
303
304.. cmdoption:: --with-undefined-behavior-sanitizer
305
Victor Stinner54366952021-04-09 01:58:20 +0200306 Enable UndefinedBehaviorSanitizer undefined behaviour detector, ``ubsan``
Victor Stinnera41782c2021-04-08 22:32:21 +0200307 (default is no).
308
309 .. versionadded:: 3.6
310
311
312Linker options
313--------------
314
315.. cmdoption:: --enable-shared
316
Victor Stinner54366952021-04-09 01:58:20 +0200317 Enable building a shared Python library: ``libpython`` (default is no).
Victor Stinnera41782c2021-04-08 22:32:21 +0200318
319.. cmdoption:: --without-static-libpython
320
321 Do not build ``libpythonMAJOR.MINOR.a`` and do not install ``python.o``
322 (built and enabled by default).
323
324 .. versionadded:: 3.10
325
326
327Libraries options
328-----------------
329
330.. cmdoption:: --with-libs='lib1 ...'
331
332 Link against additional libraries (default is no).
333
334.. cmdoption:: --with-system-expat
335
336 Build the :mod:`pyexpat` module using an installed ``expat`` library
337 (default is no).
338
339.. cmdoption:: --with-system-ffi
340
341 Build the :mod:`_ctypes` extension module using an installed ``ffi``
342 library, see the :mod:`ctypes` module (default is system-dependent).
343
344.. cmdoption:: --with-system-libmpdec
345
Victor Stinner54366952021-04-09 01:58:20 +0200346 Build the ``_decimal`` extension module using an installed ``mpdec``
Victor Stinnera41782c2021-04-08 22:32:21 +0200347 library, see the :mod:`decimal` module (default is no).
348
349 .. versionadded:: 3.3
350
Victor Stinner54366952021-04-09 01:58:20 +0200351.. cmdoption:: --with-readline=editline
Victor Stinnera41782c2021-04-08 22:32:21 +0200352
Victor Stinner54366952021-04-09 01:58:20 +0200353 Use ``editline`` library for backend of the :mod:`readline` module.
354
355 Define the ``WITH_EDITLINE`` macro.
356
357 .. versionadded:: 3.10
358
359.. cmdoption:: --without-readline
360
361 Don't build the :mod:`readline` module (built by default).
362
363 Don't define the ``HAVE_LIBREADLINE`` macro.
Victor Stinnera41782c2021-04-08 22:32:21 +0200364
365 .. versionadded:: 3.10
366
367.. cmdoption:: --with-tcltk-includes='-I...'
368
369 Override search for Tcl and Tk include files.
370
371.. cmdoption:: --with-tcltk-libs='-L...'
372
373 Override search for Tcl and Tk libraries.
374
375.. cmdoption:: --with-libm=STRING
376
377 Override ``libm`` math library to *STRING* (default is system-dependent).
378
379.. cmdoption:: --with-libc=STRING
380
381 Override ``libc`` C library to *STRING* (default is system-dependent).
382
383.. cmdoption:: --with-openssl=DIR
384
385 Root of the OpenSSL directory.
386
Victor Stinner54366952021-04-09 01:58:20 +0200387 .. versionadded:: 3.7
388
389.. cmdoption:: --with-openssl-rpath=[no|auto|DIR]
Victor Stinnera41782c2021-04-08 22:32:21 +0200390
391 Set runtime library directory (rpath) for OpenSSL libraries:
392
393 * ``no`` (default): don't set rpath;
394 * ``auto``: auto-detect rpath from :option:`--with-openssl` and
395 ``pkg-config``;
396 * *DIR*: set an explicit rpath.
397
398 .. versionadded:: 3.10
399
400
401Security Options
402----------------
403
404.. cmdoption:: --with-hash-algorithm=[fnv|siphash24]
405
406 Select hash algorithm for use in ``Python/pyhash.c``:
407
Victor Stinnera41782c2021-04-08 22:32:21 +0200408 * ``siphash24`` (default).
Victor Stinner54366952021-04-09 01:58:20 +0200409 * ``fnv``;
Victor Stinnera41782c2021-04-08 22:32:21 +0200410
411 .. versionadded:: 3.4
412
413.. cmdoption:: --with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2
414
415 Built-in hash modules:
416
417 * ``md5``;
418 * ``sha1``;
419 * ``sha256``;
420 * ``sha512``;
421 * ``sha3`` (with shake);
422 * ``blake2``.
423
424 .. versionadded:: 3.9
425
426.. cmdoption:: --with-ssl-default-suites=[python|openssl|STRING]
427
428 Override the OpenSSL default cipher suites string:
429
Victor Stinner54366952021-04-09 01:58:20 +0200430 * ``python`` (default): use Python's preferred selection;
Victor Stinnera41782c2021-04-08 22:32:21 +0200431 * ``openssl``: leave OpenSSL's defaults untouched;
432 * *STRING*: use a custom string, PROTOCOL_SSLv2 ignores the setting.
433
434 See the :mod:`ssl` module.
435
436 .. versionadded:: 3.7
437
438
439macOS Options
440-------------
441
442See ``Mac/README.rst``.
443
Victor Stinner54366952021-04-09 01:58:20 +0200444.. cmdoption:: --enable-universalsdk
445.. cmdoption:: --enable-universalsdk=SDKDIR
Victor Stinnera41782c2021-04-08 22:32:21 +0200446
447 Create a universal binary build. *SDKDIR* specifies which macOS SDK should
448 be used to perform the build (default is no).
449
Victor Stinner54366952021-04-09 01:58:20 +0200450.. cmdoption:: --enable-framework
451.. cmdoption:: --enable-framework=INSTALLDIR
Victor Stinnera41782c2021-04-08 22:32:21 +0200452
453 Create a Python.framework rather than a traditional Unix install. Optional
454 *INSTALLDIR* specifies the installation path (default is no).
455
456.. cmdoption:: --with-universal-archs=ARCH
457
Victor Stinner54366952021-04-09 01:58:20 +0200458 Specify the kind of universal binary that should be created. This option is
Victor Stinnera41782c2021-04-08 22:32:21 +0200459 only valid when :option:`--enable-universalsdk` is set.
460
Victor Stinner54366952021-04-09 01:58:20 +0200461 Options:
Victor Stinnera41782c2021-04-08 22:32:21 +0200462
463 * ``universal2``;
464 * ``32-bit``;
465 * ``64-bit``;
466 * ``3-way``;
467 * ``intel``;
468 * ``intel-32``;
469 * ``intel-64``;
470 * ``all``.
471
472.. cmdoption:: --with-framework-name=FRAMEWORK
473
474 Specify the name for the python framework on macOS only valid when
475 :option:`--enable-framework` is set (default: ``Python``).
476
477
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200478Python Build System
479===================
480
481Main files of the build system
482------------------------------
483
484* :file:`configure.ac` => :file:`configure`;
485* :file:`Makefile.pre.in` => :file:`Makefile` (created by :file:`configure`);
486* :file:`pyconfig.h` (created by :file:`configure`);
487* :file:`Modules/Setup`: C extensions built by the Makefile using
488 :file:`Module/makesetup` shell script;
489* :file:`setup.py`: C extensions built using the :mod:`distutils` module.
490
491Main build steps
492----------------
493
494* C files (``.c``) are built as object files (``.o``).
495* A static ``libpython`` library (``.a``) is created from objects files.
496* ``python.o`` and the static ``libpython`` library are linked into the
497 final ``python`` program.
498* C extensions are built by the Makefile (see :file:`Modules/Setup`)
499 and ``python setup.py build``.
500
501Main Makefile targets
502---------------------
503
504* ``make``: Build Python with the standard library.
505* ``make platform:``: build the ``python`` program, but don't build the
506 standard library extension modules.
507* ``make profile-opt``: build Python using Profile Guided Optimization (PGO).
508 You can use the configure :option:`--enable-optimizations` option to make
509 this the default target of the ``make`` command (``make all`` or just
510 ``make``).
511* ``make buildbottest``: Build Python and run the Python test suite, the same
512 way than buildbots test Python. Set ``TESTTIMEOUT`` variable (in seconds)
513 to change the test timeout (1200 by default: 20 minutes).
514* ``make install``: Build and install Python.
515* ``make regen-all``: Regenerate (almost) all generated files;
516 ``make regen-stdlib-module-names`` and ``autoconf`` must be run separately
517 for the remaining generated files.
518* ``make clean``: Remove built files.
519* ``make distclean``: Same than ``make clean``, but remove also files created
520 by the configure script.
521
522C extensions
523------------
524
525Some C extensions are built as built-in modules, like the ``sys`` module.
526They are built with the ``Py_BUILD_CORE_BUILTIN`` macro defined.
527Built-in modules have no ``__file__`` attribute::
528
529 >>> import sys
530 >>> sys
531 <module 'sys' (built-in)>
532 >>> sys.__file__
533 Traceback (most recent call last):
534 File "<stdin>", line 1, in <module>
535 AttributeError: module 'sys' has no attribute '__file__'
536
537Other C extensins are built as dynamic libraires, like the ``_asyncio`` module.
538They are built with the ``Py_BUILD_CORE_MODULE`` macro defined.
539Example on Linux x86-64::
540
541 >>> import _asyncio
542 >>> _asyncio
543 <module '_asyncio' from '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'>
544 >>> _asyncio.__file__
545 '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'
546
547:file:`Modules/Setup` is used to generate Makefile targets to build C extensions.
548At the beginning of the files, C extensions are built as built-in modules.
549Extensions defined after the ``*shared*`` marker are built as dynamic libraries.
550
551The :file:`setup.py` script only builds C extensions as shared libraries using
552the :mod:`distutils` module.
553
554The :c:macro:`PyAPI_FUNC()`, :c:macro:`PyAPI_API()` and
555:c:macro:`PyMODINIT_FUNC()` macros of :file:`Include/pyport.h` are defined
556differently depending if the ``Py_BUILD_CORE_MODULE`` macro is defined:
557
558* Use ``Py_EXPORTED_SYMBOL`` if the ``Py_BUILD_CORE_MODULE`` is defined
559* Use ``Py_IMPORTED_SYMBOL`` otherwise.
560
561If the ``Py_BUILD_CORE_BUILTIN`` macro is used by mistake on a C extension
562built as a shared library, its ``PyInit_xxx()`` function is not exported,
563causing an :exc:`ImportError` on import.
564
565
Victor Stinnera41782c2021-04-08 22:32:21 +0200566Compiler and linker flags
567=========================
568
Victor Stinner54366952021-04-09 01:58:20 +0200569Options set by the ``./configure`` script and environment variables and used by
570``Makefile``.
571
Victor Stinnera41782c2021-04-08 22:32:21 +0200572Preprocessor flags
573------------------
574
Victor Stinnera41782c2021-04-08 22:32:21 +0200575.. envvar:: CONFIGURE_CPPFLAGS
576
Victor Stinner54366952021-04-09 01:58:20 +0200577 Value of :envvar:`CPPFLAGS` variable passed to the ``./configure`` script.
578
Victor Stinnera41782c2021-04-08 22:32:21 +0200579 .. versionadded:: 3.6
580
581.. envvar:: CPPFLAGS
582
583 (Objective) C/C++ preprocessor flags, e.g. ``-I<include dir>`` if you have
584 headers in a nonstandard directory ``<include dir>``.
585
586 Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's
587 value for setup.py to be able to build extension modules using the
588 directories specified in the environment variables.
589
590.. envvar:: BASECPPFLAGS
591
592 .. versionadded:: 3.4
593
Victor Stinnera41782c2021-04-08 22:32:21 +0200594.. envvar:: PY_CPPFLAGS
595
596 Extra preprocessor flags added for building the interpreter object files.
597
598 Default: ``$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)``.
599
600 .. versionadded:: 3.2
601
602Compiler flags
603--------------
604
605.. envvar:: CC
606
607 C compiler command.
608
Victor Stinner54366952021-04-09 01:58:20 +0200609 Example: ``gcc -pthread``.
610
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200611.. envvar:: MAINCC
612
613 C compiler command used to build the ``main()`` function of programs like
614 ``python``.
615
616 Variable set by the :option:`--with-cxx-main` option of the configure
617 script.
618
619 Default: ``$(CC)``.
620
Victor Stinner54366952021-04-09 01:58:20 +0200621.. envvar:: CXX
622
623 C++ compiler command.
624
625 Used if the :option:`--with-cxx-main` option is used.
626
627 Example: ``g++ -pthread``.
628
Victor Stinnera41782c2021-04-08 22:32:21 +0200629.. envvar:: CFLAGS
630
631 C compiler flags.
632
633.. envvar:: CFLAGS_NODIST
634
635 :envvar:`CFLAGS_NODIST` is used for building the interpreter and stdlib C
636 extensions. Use it when a compiler flag should *not* be part of the
637 distutils :envvar:`CFLAGS` once Python is installed (:issue:`21121`).
638
639 .. versionadded:: 3.5
640
641.. envvar:: EXTRA_CFLAGS
642
643 Extra C compiler flags.
644
645.. envvar:: CONFIGURE_CFLAGS
646
Victor Stinner54366952021-04-09 01:58:20 +0200647 Value of :envvar:`CFLAGS` variable passed to the ``./configure``
648 script.
649
Victor Stinnera41782c2021-04-08 22:32:21 +0200650 .. versionadded:: 3.2
651
652.. envvar:: CONFIGURE_CFLAGS_NODIST
653
Victor Stinner54366952021-04-09 01:58:20 +0200654 Value of :envvar:`CFLAGS_NODIST` variable passed to the ``./configure``
655 script.
656
Victor Stinnera41782c2021-04-08 22:32:21 +0200657 .. versionadded:: 3.5
658
659.. envvar:: BASECFLAGS
660
Victor Stinner54366952021-04-09 01:58:20 +0200661 Base compiler flags.
662
Victor Stinnera41782c2021-04-08 22:32:21 +0200663.. envvar:: OPT
664
665 Optimization flags.
666
667.. envvar:: CFLAGS_ALIASING
668
669 Strict or non-strict aliasing flags used to compile ``Python/dtoa.c``.
670
671 .. versionadded:: 3.7
672
Victor Stinner54366952021-04-09 01:58:20 +0200673.. envvar:: CCSHARED
674
675 Compiler flags used to build a shared library.
676
677 For example, ``-fPIC`` is used on Linux and on BSD.
678
Victor Stinnera41782c2021-04-08 22:32:21 +0200679.. envvar:: CFLAGSFORSHARED
680
681 Extra C flags added for building the interpreter object files.
682
Victor Stinner54366952021-04-09 01:58:20 +0200683 Default: ``$(CCSHARED)`` when :option:`--enable-shared` is used, or an empty
684 string otherwise.
685
Victor Stinnera41782c2021-04-08 22:32:21 +0200686.. envvar:: PY_CFLAGS
687
688 Default: ``$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)``.
689
690.. envvar:: PY_CFLAGS_NODIST
691
692 Default: ``$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/internal``.
693
694 .. versionadded:: 3.5
695
696.. envvar:: PY_STDMODULE_CFLAGS
697
698 C flags used for building the interpreter object files.
699
700 Default: ``$(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED)``.
701
702 .. versionadded:: 3.7
703
704.. envvar:: PY_CORE_CFLAGS
705
706 Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE``.
707
708 .. versionadded:: 3.2
709
710.. envvar:: PY_BUILTIN_MODULE_CFLAGS
711
Victor Stinner54366952021-04-09 01:58:20 +0200712 Compiler flags to build a standard library extension module as a built-in
713 module, like the :mod:`posix` module.
714
Victor Stinnera41782c2021-04-08 22:32:21 +0200715 Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN``.
716
717 .. versionadded:: 3.8
718
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200719.. envvar:: PURIFY
720
721 Purify command. Purify is a memory debugger program.
722
723 Default: empty string (not used).
724
Victor Stinnera41782c2021-04-08 22:32:21 +0200725
726Linker flags
727------------
728
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200729.. envvar:: LINKCC
730
731 Linker command used to build programs like ``python`` and ``_testembed``.
732
733 Default: ``$(PURIFY) $(MAINCC)``.
734
Victor Stinnera41782c2021-04-08 22:32:21 +0200735.. envvar:: CONFIGURE_LDFLAGS
736
Victor Stinner54366952021-04-09 01:58:20 +0200737 Value of :envvar:`LDFLAGS` variable passed to the ``./configure`` script.
738
Victor Stinnera41782c2021-04-08 22:32:21 +0200739 Avoid assigning :envvar:`CFLAGS`, :envvar:`LDFLAGS`, etc. so users can use
740 them on the command line to append to these values without stomping the
741 pre-set values.
742
743 .. versionadded:: 3.2
744
745.. envvar:: LDFLAGS_NODIST
746
747 :envvar:`LDFLAGS_NODIST` is used in the same manner as
748 :envvar:`CFLAGS_NODIST`. Use it when a linker flag should *not* be part of
749 the distutils :envvar:`LDFLAGS` once Python is installed (:issue:`35257`).
750
751.. envvar:: CONFIGURE_LDFLAGS_NODIST
752
Victor Stinner54366952021-04-09 01:58:20 +0200753 Value of :envvar:`LDFLAGS_NODIST` variable passed to the ``./configure``
754 script.
755
Victor Stinnera41782c2021-04-08 22:32:21 +0200756 .. versionadded:: 3.8
757
758.. envvar:: LDFLAGS
759
760 Linker flags, e.g. ``-L<lib dir>`` if you have libraries in a nonstandard
761 directory ``<lib dir>``.
762
763 Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's
764 value for setup.py to be able to build extension modules using the
765 directories specified in the environment variables.
766
767.. envvar:: LIBS
768
Victor Stinner54366952021-04-09 01:58:20 +0200769 Linker flags to pass libraries to the linker when linking the Python
770 executable.
771
772 Example: ``-lrt``.
Victor Stinnera41782c2021-04-08 22:32:21 +0200773
774.. envvar:: LDSHARED
775
776 Command to build a shared library.
777
778 Default: ``@LDSHARED@ $(PY_LDFLAGS)``.
779
780.. envvar:: BLDSHARED
781
Victor Stinner54366952021-04-09 01:58:20 +0200782 Command to build ``libpython`` shared library.
Victor Stinnera41782c2021-04-08 22:32:21 +0200783
784 Default: ``@BLDSHARED@ $(PY_CORE_LDFLAGS)``.
785
786.. envvar:: PY_LDFLAGS
787
788 Default: ``$(CONFIGURE_LDFLAGS) $(LDFLAGS)``.
789
790.. envvar:: PY_LDFLAGS_NODIST
791
792 Default: ``$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)``.
793
794 .. versionadded:: 3.8
795
796.. envvar:: PY_CORE_LDFLAGS
797
798 Linker flags used for building the interpreter object files.
799
800 .. versionadded:: 3.8