blob: e7fad7f2e622b9e1f7cd7934c9fed0a6772bd689 [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
Victor Stinner85918e42021-04-12 23:27:35 +020022 is no).
23
24 See the :meth:`sqlite3.Connection.enable_load_extension` method of the
25 :mod:`sqlite3` module.
Victor Stinnera41782c2021-04-08 22:32:21 +020026
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
Victor Stinner54366952021-04-09 01:58:20 +020034.. cmdoption:: --enable-big-digits=[15|30]
Victor Stinnera41782c2021-04-08 22:32:21 +020035
Victor Stinner54366952021-04-09 01:58:20 +020036 Define the size in bits of Python :class:`int` digits: 15 or 30 bits.
37
38 By default, the number of bits is selected depending on ``sizeof(void*)``:
39 30 bits if ``void*`` size is 64-bit or larger, 15 bits otherwise.
40
41 Define the ``PYLONG_BITS_IN_DIGIT`` to ``15`` or ``30``.
Victor Stinnera41782c2021-04-08 22:32:21 +020042
43 See :data:`sys.int_info.bits_per_digit <sys.int_info>`.
44
Victor Stinner54366952021-04-09 01:58:20 +020045.. cmdoption:: --with-cxx-main
46.. cmdoption:: --with-cxx-main=COMPILER
Victor Stinnera41782c2021-04-08 22:32:21 +020047
48 Compile the Python ``main()`` function and link Python executable with C++
Victor Stinner54366952021-04-09 01:58:20 +020049 compiler: ``$CXX``, or *COMPILER* if specified.
Victor Stinnera41782c2021-04-08 22:32:21 +020050
51.. cmdoption:: --with-suffix=SUFFIX
52
Victor Stinner54366952021-04-09 01:58:20 +020053 Set the Python executable suffix to *SUFFIX*.
54
55 The default suffix is ``.exe`` on Windows and macOS (``python.exe``
56 executable), and an empty string on other platforms (``python`` executable).
Victor Stinnera41782c2021-04-08 22:32:21 +020057
58.. cmdoption:: --with-tzpath=<list of absolute paths separated by pathsep>
59
Victor Stinner85918e42021-04-12 23:27:35 +020060 Select the default time zone search path for :data:`zoneinfo.TZPATH`.
61 See the :ref:`Compile-time configuration
62 <zoneinfo_data_compile_time_config>` of the :mod:`zoneinfo` module.
Victor Stinnera41782c2021-04-08 22:32:21 +020063
Victor Stinner54366952021-04-09 01:58:20 +020064 Default: ``/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo``.
65
66 See :data:`os.pathsep` path separator.
67
Victor Stinnera41782c2021-04-08 22:32:21 +020068 .. versionadded:: 3.9
69
70.. cmdoption:: --without-decimal-contextvar
71
72 Build the ``_decimal`` extension module using a thread-local context rather
73 than a coroutine-local context (default), see the :mod:`decimal` module.
74
Victor Stinner54366952021-04-09 01:58:20 +020075 See :data:`decimal.HAVE_CONTEXTVAR` and the :mod:`contextvars` module.
Victor Stinnera41782c2021-04-08 22:32:21 +020076
77 .. versionadded:: 3.9
78
79.. cmdoption:: --with-dbmliborder=db1:db2:...
80
81 Override order to check db backends for the :mod:`dbm` module
82
Victor Stinner54366952021-04-09 01:58:20 +020083 A valid value is a colon (``:``) separated string with the backend names:
Victor Stinnera41782c2021-04-08 22:32:21 +020084
85 * ``ndbm``;
86 * ``gdbm``;
87 * ``bdb``.
88
Victor Stinner54366952021-04-09 01:58:20 +020089.. cmdoption:: --without-c-locale-coercion
Victor Stinnera41782c2021-04-08 22:32:21 +020090
Victor Stinner54366952021-04-09 01:58:20 +020091 Disable C locale coercion to a UTF-8 based locale (enabled by default).
92
93 Don't define the ``PY_COERCE_C_LOCALE`` macro.
Victor Stinnera41782c2021-04-08 22:32:21 +020094
95 See :envvar:`PYTHONCOERCECLOCALE` and the :pep:`538`.
96
97.. cmdoption:: --with-platlibdir=DIRNAME
98
99 Python library directory name (default is ``lib``).
100
101 Fedora and SuSE use ``lib64`` on 64-bit platforms.
102
103 See :data:`sys.platlibdir`.
104
105 .. versionadded:: 3.9
106
107.. cmdoption:: --with-wheel-pkg-dir=PATH
108
109 Directory of wheel packages used by the :mod:`ensurepip` module
110 (none by default).
111
112 Some Linux distribution packaging policies recommend against bundling
113 dependencies. For example, Fedora installs wheel packages in the
114 ``/usr/share/python-wheels/`` directory and don't install the
115 :mod:`ensurepip._bundled` package.
116
117 .. versionadded:: 3.10
118
119
120Install Options
121---------------
122
123.. cmdoption:: --disable-test-modules
124
125 Don't build nor install test modules, like the :mod:`test` package or the
126 :mod:`_testcapi` extension module (built and installed by default).
127
128 .. versionadded:: 3.10
129
Victor Stinner54366952021-04-09 01:58:20 +0200130.. cmdoption:: --with-ensurepip=[upgrade|install|no]
Victor Stinnera41782c2021-04-08 22:32:21 +0200131
Victor Stinner54366952021-04-09 01:58:20 +0200132 Select the :mod:`ensurepip` command run on Python installation:
133
134 * ``upgrade`` (default): run ``python -m ensurepip --altinstall --upgrade``
135 command.
136 * ``install``: run ``python -m ensurepip --altinstall`` command;
137 * ``no``: don't run ensurepip;
Victor Stinnera41782c2021-04-08 22:32:21 +0200138
139 .. versionadded:: 3.6
140
141
142Performance options
143-------------------
144
145Configuring Python using ``--enable-optimizations --with-lto`` (PGO + LTO) is
146recommended for best performance.
147
148.. cmdoption:: --enable-optimizations
149
150 Enable Profile Guided Optimization (PGO) using :envvar:`PROFILE_TASK`
151 (disabled by default).
152
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200153 The C compiler Clang requires ``llvm-profdata`` program for PGO. On
154 macOS, GCC also requires it: GCC is just an alias to Clang on macOS.
155
Victor Stinnera41782c2021-04-08 22:32:21 +0200156 Disable also semantic interposition in libpython if ``--enable-shared`` and
157 GCC is used: add ``-fno-semantic-interposition`` to the compiler and linker
158 flags.
159
160 .. versionadded:: 3.6
161
162 .. versionchanged:: 3.10
163 Use ``-fno-semantic-interposition`` on GCC.
164
165.. envvar:: PROFILE_TASK
166
167 Environment variable used in the Makefile: Python command line arguments for
168 the PGO generation task.
169
170 Default: ``-m test --pgo --timeout=$(TESTTIMEOUT)``.
171
172 .. versionadded:: 3.8
173
174.. cmdoption:: --with-lto
175
176 Enable Link Time Optimization (LTO) in any build (disabled by default).
177
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200178 The C compiler Clang requires ``llvm-ar`` for LTO, as well as an LTO-aware
179 linker (``ld.gold`` or ``lld``).
180
Victor Stinnera41782c2021-04-08 22:32:21 +0200181 .. versionadded:: 3.6
182
183.. cmdoption:: --with-computed-gotos
184
185 Enable computed gotos in evaluation loop (enabled by default on supported
186 compilers).
187
188.. cmdoption:: --without-pymalloc
189
190 Disable the specialized Python memory allocator :ref:`pymalloc <pymalloc>`
191 (enabled by default).
192
193 See also :envvar:`PYTHONMALLOC` environment variable.
194
195.. cmdoption:: --without-doc-strings
196
197 Disable static documentation strings to reduce the memory footprint (enabled
198 by default). Documentation strings defined in Python are not affected.
199
Victor Stinner54366952021-04-09 01:58:20 +0200200 Don't define the ``WITH_DOC_STRINGS`` macro.
201
202 See the ``PyDoc_STRVAR()`` macro.
Victor Stinnera41782c2021-04-08 22:32:21 +0200203
204.. cmdoption:: --enable-profiling
205
206 Enable C-level code profiling with ``gprof`` (disabled by default).
207
208
209.. _debug-build:
210
211Debug build
212-----------
213
214A debug build is Python built with the :option:`--with-pydebug` configure
215option.
216
217Effects of a debug build:
218
219* Define ``Py_DEBUG`` and ``Py_REF_DEBUG`` macros.
220* Add ``d`` to :data:`sys.abiflags`.
221* Add :func:`sys.gettotalrefcount` function.
222* Add :option:`-X showrefcount <-X>` command line option.
223* Add :envvar:`PYTHONTHREADDEBUG` environment variable.
Victor Stinner54366952021-04-09 01:58:20 +0200224* Add support for the ``__ltrace__`` variable: enable low-level tracing in the
225 bytecode evaluation loop if the variable is defined.
Victor Stinnera41782c2021-04-08 22:32:21 +0200226* The list of default warning filters is empty in the :mod:`warnings` module.
227* Install debug hooks on memory allocators to detect buffer overflow and other
228 memory errors: see :c:func:`PyMem_SetupDebugHooks`.
229* Build Python with assertions (don't set ``NDEBUG`` macro):
Victor Stinner54366952021-04-09 01:58:20 +0200230 ``assert(...);`` and ``_PyObject_ASSERT(...);``.
Victor Stinnera41782c2021-04-08 22:32:21 +0200231 See also the :option:`--with-assertions` configure option.
Victor Stinnera41782c2021-04-08 22:32:21 +0200232* Unicode and int objects are created with their memory filled with a pattern
233 to help detecting uninitialized bytes.
234* Many functions ensure that are not called with an exception raised, since
235 they can clear or replace the current exception.
Victor Stinner54366952021-04-09 01:58:20 +0200236* The garbage collector (:func:`gc.collect` function) runs some basic checks on
237 objects consistency.
238* More generally, add runtime checks, code surroundeded by ``#ifdef Py_DEBUG``
239 and ``#endif``.
Victor Stinnera41782c2021-04-08 22:32:21 +0200240
241See also the :ref:`Python Development Mode <devmode>` and the
242:option:`--with-trace-refs` configure option.
243
244.. versionchanged:: 3.8
245 Release builds and debug builds are now ABI compatible: defining the
246 ``Py_DEBUG`` macro no longer implies the ``Py_TRACE_REFS`` macro, which
247 introduces the only ABI incompatibility.
248
249
250Debug options
251-------------
252
253.. cmdoption:: --with-pydebug
254
Victor Stinner54366952021-04-09 01:58:20 +0200255 :ref:`Build Python in debug mode <debug-build>`: define the ``Py_DEBUG``
256 macro (disabled by default).
Victor Stinnera41782c2021-04-08 22:32:21 +0200257
258.. cmdoption:: --with-trace-refs
259
260 Enable tracing references for debugging purpose (disabled by default).
261
262 Effects:
263
264 * Define the ``Py_TRACE_REFS`` macro.
265 * Add :func:`sys.getobjects` function.
266 * Add :envvar:`PYTHONDUMPREFS` environment variable.
267
268 This build is not ABI compatible with release build (default build) or debug
Victor Stinner54366952021-04-09 01:58:20 +0200269 build (``Py_DEBUG`` and ``Py_REF_DEBUG`` macros).
Victor Stinnera41782c2021-04-08 22:32:21 +0200270
271 .. versionadded:: 3.8
272
273.. cmdoption:: --with-assertions
274
Victor Stinner54366952021-04-09 01:58:20 +0200275 Build with C assertions enabled (default is no): ``assert(...);`` and
276 ``_PyObject_ASSERT(...);``.
Victor Stinnera41782c2021-04-08 22:32:21 +0200277
278 If set, the ``NDEBUG`` macro is not defined in the :envvar:`OPT` compiler
279 variable.
280
281 See also the :option:`--with-pydebug` option (:ref:`debug build
282 <debug-build>`) which also enables assertions.
283
284 .. versionadded:: 3.6
285
286.. cmdoption:: --with-valgrind
287
288 Enable Valgrind support (default is no).
289
290.. cmdoption:: --with-dtrace
291
292 Enable DTrace support (default is no).
293
Victor Stinner85918e42021-04-12 23:27:35 +0200294 See :ref:`Instrumenting CPython with DTrace and SystemTap
295 <instrumentation>`.
296
Victor Stinnera41782c2021-04-08 22:32:21 +0200297 .. versionadded:: 3.6
298
299.. cmdoption:: --with-address-sanitizer
300
Victor Stinner54366952021-04-09 01:58:20 +0200301 Enable AddressSanitizer memory error detector, ``asan`` (default is no).
Victor Stinnera41782c2021-04-08 22:32:21 +0200302
303 .. versionadded:: 3.6
304
305.. cmdoption:: --with-memory-sanitizer
306
Victor Stinner54366952021-04-09 01:58:20 +0200307 Enable MemorySanitizer allocation error detector, ``msan`` (default is no).
Victor Stinnera41782c2021-04-08 22:32:21 +0200308
309 .. versionadded:: 3.6
310
311.. cmdoption:: --with-undefined-behavior-sanitizer
312
Victor Stinner54366952021-04-09 01:58:20 +0200313 Enable UndefinedBehaviorSanitizer undefined behaviour detector, ``ubsan``
Victor Stinnera41782c2021-04-08 22:32:21 +0200314 (default is no).
315
316 .. versionadded:: 3.6
317
318
319Linker options
320--------------
321
322.. cmdoption:: --enable-shared
323
Victor Stinner54366952021-04-09 01:58:20 +0200324 Enable building a shared Python library: ``libpython`` (default is no).
Victor Stinnera41782c2021-04-08 22:32:21 +0200325
326.. cmdoption:: --without-static-libpython
327
328 Do not build ``libpythonMAJOR.MINOR.a`` and do not install ``python.o``
329 (built and enabled by default).
330
331 .. versionadded:: 3.10
332
333
334Libraries options
335-----------------
336
337.. cmdoption:: --with-libs='lib1 ...'
338
339 Link against additional libraries (default is no).
340
341.. cmdoption:: --with-system-expat
342
343 Build the :mod:`pyexpat` module using an installed ``expat`` library
344 (default is no).
345
346.. cmdoption:: --with-system-ffi
347
348 Build the :mod:`_ctypes` extension module using an installed ``ffi``
349 library, see the :mod:`ctypes` module (default is system-dependent).
350
351.. cmdoption:: --with-system-libmpdec
352
Victor Stinner54366952021-04-09 01:58:20 +0200353 Build the ``_decimal`` extension module using an installed ``mpdec``
Victor Stinnera41782c2021-04-08 22:32:21 +0200354 library, see the :mod:`decimal` module (default is no).
355
356 .. versionadded:: 3.3
357
Victor Stinner54366952021-04-09 01:58:20 +0200358.. cmdoption:: --with-readline=editline
Victor Stinnera41782c2021-04-08 22:32:21 +0200359
Victor Stinner54366952021-04-09 01:58:20 +0200360 Use ``editline`` library for backend of the :mod:`readline` module.
361
362 Define the ``WITH_EDITLINE`` macro.
363
364 .. versionadded:: 3.10
365
366.. cmdoption:: --without-readline
367
368 Don't build the :mod:`readline` module (built by default).
369
370 Don't define the ``HAVE_LIBREADLINE`` macro.
Victor Stinnera41782c2021-04-08 22:32:21 +0200371
372 .. versionadded:: 3.10
373
374.. cmdoption:: --with-tcltk-includes='-I...'
375
376 Override search for Tcl and Tk include files.
377
378.. cmdoption:: --with-tcltk-libs='-L...'
379
380 Override search for Tcl and Tk libraries.
381
382.. cmdoption:: --with-libm=STRING
383
384 Override ``libm`` math library to *STRING* (default is system-dependent).
385
386.. cmdoption:: --with-libc=STRING
387
388 Override ``libc`` C library to *STRING* (default is system-dependent).
389
390.. cmdoption:: --with-openssl=DIR
391
392 Root of the OpenSSL directory.
393
Victor Stinner54366952021-04-09 01:58:20 +0200394 .. versionadded:: 3.7
395
396.. cmdoption:: --with-openssl-rpath=[no|auto|DIR]
Victor Stinnera41782c2021-04-08 22:32:21 +0200397
398 Set runtime library directory (rpath) for OpenSSL libraries:
399
400 * ``no`` (default): don't set rpath;
401 * ``auto``: auto-detect rpath from :option:`--with-openssl` and
402 ``pkg-config``;
403 * *DIR*: set an explicit rpath.
404
405 .. versionadded:: 3.10
406
407
408Security Options
409----------------
410
411.. cmdoption:: --with-hash-algorithm=[fnv|siphash24]
412
413 Select hash algorithm for use in ``Python/pyhash.c``:
414
Victor Stinnera41782c2021-04-08 22:32:21 +0200415 * ``siphash24`` (default).
Victor Stinner54366952021-04-09 01:58:20 +0200416 * ``fnv``;
Victor Stinnera41782c2021-04-08 22:32:21 +0200417
418 .. versionadded:: 3.4
419
420.. cmdoption:: --with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2
421
422 Built-in hash modules:
423
424 * ``md5``;
425 * ``sha1``;
426 * ``sha256``;
427 * ``sha512``;
428 * ``sha3`` (with shake);
429 * ``blake2``.
430
431 .. versionadded:: 3.9
432
433.. cmdoption:: --with-ssl-default-suites=[python|openssl|STRING]
434
435 Override the OpenSSL default cipher suites string:
436
Victor Stinner54366952021-04-09 01:58:20 +0200437 * ``python`` (default): use Python's preferred selection;
Victor Stinnera41782c2021-04-08 22:32:21 +0200438 * ``openssl``: leave OpenSSL's defaults untouched;
439 * *STRING*: use a custom string, PROTOCOL_SSLv2 ignores the setting.
440
441 See the :mod:`ssl` module.
442
443 .. versionadded:: 3.7
444
445
446macOS Options
447-------------
448
449See ``Mac/README.rst``.
450
Victor Stinner54366952021-04-09 01:58:20 +0200451.. cmdoption:: --enable-universalsdk
452.. cmdoption:: --enable-universalsdk=SDKDIR
Victor Stinnera41782c2021-04-08 22:32:21 +0200453
454 Create a universal binary build. *SDKDIR* specifies which macOS SDK should
455 be used to perform the build (default is no).
456
Victor Stinner54366952021-04-09 01:58:20 +0200457.. cmdoption:: --enable-framework
458.. cmdoption:: --enable-framework=INSTALLDIR
Victor Stinnera41782c2021-04-08 22:32:21 +0200459
460 Create a Python.framework rather than a traditional Unix install. Optional
461 *INSTALLDIR* specifies the installation path (default is no).
462
463.. cmdoption:: --with-universal-archs=ARCH
464
Victor Stinner54366952021-04-09 01:58:20 +0200465 Specify the kind of universal binary that should be created. This option is
Victor Stinnera41782c2021-04-08 22:32:21 +0200466 only valid when :option:`--enable-universalsdk` is set.
467
Victor Stinner54366952021-04-09 01:58:20 +0200468 Options:
Victor Stinnera41782c2021-04-08 22:32:21 +0200469
470 * ``universal2``;
471 * ``32-bit``;
472 * ``64-bit``;
473 * ``3-way``;
474 * ``intel``;
475 * ``intel-32``;
476 * ``intel-64``;
477 * ``all``.
478
479.. cmdoption:: --with-framework-name=FRAMEWORK
480
481 Specify the name for the python framework on macOS only valid when
482 :option:`--enable-framework` is set (default: ``Python``).
483
484
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200485Python Build System
486===================
487
488Main files of the build system
489------------------------------
490
491* :file:`configure.ac` => :file:`configure`;
492* :file:`Makefile.pre.in` => :file:`Makefile` (created by :file:`configure`);
493* :file:`pyconfig.h` (created by :file:`configure`);
494* :file:`Modules/Setup`: C extensions built by the Makefile using
495 :file:`Module/makesetup` shell script;
496* :file:`setup.py`: C extensions built using the :mod:`distutils` module.
497
498Main build steps
499----------------
500
501* C files (``.c``) are built as object files (``.o``).
502* A static ``libpython`` library (``.a``) is created from objects files.
503* ``python.o`` and the static ``libpython`` library are linked into the
504 final ``python`` program.
505* C extensions are built by the Makefile (see :file:`Modules/Setup`)
506 and ``python setup.py build``.
507
508Main Makefile targets
509---------------------
510
511* ``make``: Build Python with the standard library.
512* ``make platform:``: build the ``python`` program, but don't build the
513 standard library extension modules.
514* ``make profile-opt``: build Python using Profile Guided Optimization (PGO).
515 You can use the configure :option:`--enable-optimizations` option to make
516 this the default target of the ``make`` command (``make all`` or just
517 ``make``).
518* ``make buildbottest``: Build Python and run the Python test suite, the same
519 way than buildbots test Python. Set ``TESTTIMEOUT`` variable (in seconds)
520 to change the test timeout (1200 by default: 20 minutes).
521* ``make install``: Build and install Python.
522* ``make regen-all``: Regenerate (almost) all generated files;
523 ``make regen-stdlib-module-names`` and ``autoconf`` must be run separately
524 for the remaining generated files.
525* ``make clean``: Remove built files.
526* ``make distclean``: Same than ``make clean``, but remove also files created
527 by the configure script.
528
529C extensions
530------------
531
532Some C extensions are built as built-in modules, like the ``sys`` module.
533They are built with the ``Py_BUILD_CORE_BUILTIN`` macro defined.
534Built-in modules have no ``__file__`` attribute::
535
536 >>> import sys
537 >>> sys
538 <module 'sys' (built-in)>
539 >>> sys.__file__
540 Traceback (most recent call last):
541 File "<stdin>", line 1, in <module>
542 AttributeError: module 'sys' has no attribute '__file__'
543
544Other C extensins are built as dynamic libraires, like the ``_asyncio`` module.
545They are built with the ``Py_BUILD_CORE_MODULE`` macro defined.
546Example on Linux x86-64::
547
548 >>> import _asyncio
549 >>> _asyncio
550 <module '_asyncio' from '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'>
551 >>> _asyncio.__file__
552 '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'
553
554:file:`Modules/Setup` is used to generate Makefile targets to build C extensions.
555At the beginning of the files, C extensions are built as built-in modules.
556Extensions defined after the ``*shared*`` marker are built as dynamic libraries.
557
558The :file:`setup.py` script only builds C extensions as shared libraries using
559the :mod:`distutils` module.
560
561The :c:macro:`PyAPI_FUNC()`, :c:macro:`PyAPI_API()` and
562:c:macro:`PyMODINIT_FUNC()` macros of :file:`Include/pyport.h` are defined
563differently depending if the ``Py_BUILD_CORE_MODULE`` macro is defined:
564
565* Use ``Py_EXPORTED_SYMBOL`` if the ``Py_BUILD_CORE_MODULE`` is defined
566* Use ``Py_IMPORTED_SYMBOL`` otherwise.
567
568If the ``Py_BUILD_CORE_BUILTIN`` macro is used by mistake on a C extension
569built as a shared library, its ``PyInit_xxx()`` function is not exported,
570causing an :exc:`ImportError` on import.
571
572
Victor Stinnera41782c2021-04-08 22:32:21 +0200573Compiler and linker flags
574=========================
575
Victor Stinner54366952021-04-09 01:58:20 +0200576Options set by the ``./configure`` script and environment variables and used by
577``Makefile``.
578
Victor Stinnera41782c2021-04-08 22:32:21 +0200579Preprocessor flags
580------------------
581
Victor Stinnera41782c2021-04-08 22:32:21 +0200582.. envvar:: CONFIGURE_CPPFLAGS
583
Victor Stinner54366952021-04-09 01:58:20 +0200584 Value of :envvar:`CPPFLAGS` variable passed to the ``./configure`` script.
585
Victor Stinnera41782c2021-04-08 22:32:21 +0200586 .. versionadded:: 3.6
587
588.. envvar:: CPPFLAGS
589
590 (Objective) C/C++ preprocessor flags, e.g. ``-I<include dir>`` if you have
591 headers in a nonstandard directory ``<include dir>``.
592
593 Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's
594 value for setup.py to be able to build extension modules using the
595 directories specified in the environment variables.
596
597.. envvar:: BASECPPFLAGS
598
599 .. versionadded:: 3.4
600
Victor Stinnera41782c2021-04-08 22:32:21 +0200601.. envvar:: PY_CPPFLAGS
602
603 Extra preprocessor flags added for building the interpreter object files.
604
605 Default: ``$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)``.
606
607 .. versionadded:: 3.2
608
609Compiler flags
610--------------
611
612.. envvar:: CC
613
614 C compiler command.
615
Victor Stinner54366952021-04-09 01:58:20 +0200616 Example: ``gcc -pthread``.
617
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200618.. envvar:: MAINCC
619
620 C compiler command used to build the ``main()`` function of programs like
621 ``python``.
622
623 Variable set by the :option:`--with-cxx-main` option of the configure
624 script.
625
626 Default: ``$(CC)``.
627
Victor Stinner54366952021-04-09 01:58:20 +0200628.. envvar:: CXX
629
630 C++ compiler command.
631
632 Used if the :option:`--with-cxx-main` option is used.
633
634 Example: ``g++ -pthread``.
635
Victor Stinnera41782c2021-04-08 22:32:21 +0200636.. envvar:: CFLAGS
637
638 C compiler flags.
639
640.. envvar:: CFLAGS_NODIST
641
642 :envvar:`CFLAGS_NODIST` is used for building the interpreter and stdlib C
643 extensions. Use it when a compiler flag should *not* be part of the
644 distutils :envvar:`CFLAGS` once Python is installed (:issue:`21121`).
645
646 .. versionadded:: 3.5
647
648.. envvar:: EXTRA_CFLAGS
649
650 Extra C compiler flags.
651
652.. envvar:: CONFIGURE_CFLAGS
653
Victor Stinner54366952021-04-09 01:58:20 +0200654 Value of :envvar:`CFLAGS` variable passed to the ``./configure``
655 script.
656
Victor Stinnera41782c2021-04-08 22:32:21 +0200657 .. versionadded:: 3.2
658
659.. envvar:: CONFIGURE_CFLAGS_NODIST
660
Victor Stinner54366952021-04-09 01:58:20 +0200661 Value of :envvar:`CFLAGS_NODIST` variable passed to the ``./configure``
662 script.
663
Victor Stinnera41782c2021-04-08 22:32:21 +0200664 .. versionadded:: 3.5
665
666.. envvar:: BASECFLAGS
667
Victor Stinner54366952021-04-09 01:58:20 +0200668 Base compiler flags.
669
Victor Stinnera41782c2021-04-08 22:32:21 +0200670.. envvar:: OPT
671
672 Optimization flags.
673
674.. envvar:: CFLAGS_ALIASING
675
676 Strict or non-strict aliasing flags used to compile ``Python/dtoa.c``.
677
678 .. versionadded:: 3.7
679
Victor Stinner54366952021-04-09 01:58:20 +0200680.. envvar:: CCSHARED
681
682 Compiler flags used to build a shared library.
683
684 For example, ``-fPIC`` is used on Linux and on BSD.
685
Victor Stinnera41782c2021-04-08 22:32:21 +0200686.. envvar:: CFLAGSFORSHARED
687
688 Extra C flags added for building the interpreter object files.
689
Victor Stinner54366952021-04-09 01:58:20 +0200690 Default: ``$(CCSHARED)`` when :option:`--enable-shared` is used, or an empty
691 string otherwise.
692
Victor Stinnera41782c2021-04-08 22:32:21 +0200693.. envvar:: PY_CFLAGS
694
695 Default: ``$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)``.
696
697.. envvar:: PY_CFLAGS_NODIST
698
699 Default: ``$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/internal``.
700
701 .. versionadded:: 3.5
702
703.. envvar:: PY_STDMODULE_CFLAGS
704
705 C flags used for building the interpreter object files.
706
707 Default: ``$(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED)``.
708
709 .. versionadded:: 3.7
710
711.. envvar:: PY_CORE_CFLAGS
712
713 Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE``.
714
715 .. versionadded:: 3.2
716
717.. envvar:: PY_BUILTIN_MODULE_CFLAGS
718
Victor Stinner54366952021-04-09 01:58:20 +0200719 Compiler flags to build a standard library extension module as a built-in
720 module, like the :mod:`posix` module.
721
Victor Stinnera41782c2021-04-08 22:32:21 +0200722 Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN``.
723
724 .. versionadded:: 3.8
725
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200726.. envvar:: PURIFY
727
728 Purify command. Purify is a memory debugger program.
729
730 Default: empty string (not used).
731
Victor Stinnera41782c2021-04-08 22:32:21 +0200732
733Linker flags
734------------
735
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200736.. envvar:: LINKCC
737
738 Linker command used to build programs like ``python`` and ``_testembed``.
739
740 Default: ``$(PURIFY) $(MAINCC)``.
741
Victor Stinnera41782c2021-04-08 22:32:21 +0200742.. envvar:: CONFIGURE_LDFLAGS
743
Victor Stinner54366952021-04-09 01:58:20 +0200744 Value of :envvar:`LDFLAGS` variable passed to the ``./configure`` script.
745
Victor Stinnera41782c2021-04-08 22:32:21 +0200746 Avoid assigning :envvar:`CFLAGS`, :envvar:`LDFLAGS`, etc. so users can use
747 them on the command line to append to these values without stomping the
748 pre-set values.
749
750 .. versionadded:: 3.2
751
752.. envvar:: LDFLAGS_NODIST
753
754 :envvar:`LDFLAGS_NODIST` is used in the same manner as
755 :envvar:`CFLAGS_NODIST`. Use it when a linker flag should *not* be part of
756 the distutils :envvar:`LDFLAGS` once Python is installed (:issue:`35257`).
757
758.. envvar:: CONFIGURE_LDFLAGS_NODIST
759
Victor Stinner54366952021-04-09 01:58:20 +0200760 Value of :envvar:`LDFLAGS_NODIST` variable passed to the ``./configure``
761 script.
762
Victor Stinnera41782c2021-04-08 22:32:21 +0200763 .. versionadded:: 3.8
764
765.. envvar:: LDFLAGS
766
767 Linker flags, e.g. ``-L<lib dir>`` if you have libraries in a nonstandard
768 directory ``<lib dir>``.
769
770 Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's
771 value for setup.py to be able to build extension modules using the
772 directories specified in the environment variables.
773
774.. envvar:: LIBS
775
Victor Stinner54366952021-04-09 01:58:20 +0200776 Linker flags to pass libraries to the linker when linking the Python
777 executable.
778
779 Example: ``-lrt``.
Victor Stinnera41782c2021-04-08 22:32:21 +0200780
781.. envvar:: LDSHARED
782
783 Command to build a shared library.
784
785 Default: ``@LDSHARED@ $(PY_LDFLAGS)``.
786
787.. envvar:: BLDSHARED
788
Victor Stinner54366952021-04-09 01:58:20 +0200789 Command to build ``libpython`` shared library.
Victor Stinnera41782c2021-04-08 22:32:21 +0200790
791 Default: ``@BLDSHARED@ $(PY_CORE_LDFLAGS)``.
792
793.. envvar:: PY_LDFLAGS
794
795 Default: ``$(CONFIGURE_LDFLAGS) $(LDFLAGS)``.
796
797.. envvar:: PY_LDFLAGS_NODIST
798
799 Default: ``$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)``.
800
801 .. versionadded:: 3.8
802
803.. envvar:: PY_CORE_LDFLAGS
804
805 Linker flags used for building the interpreter object files.
806
807 .. versionadded:: 3.8