blob: 4f3953ea5d75805d9c0c9e2116d3d46461e4e8c3 [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
Victor Stinnerabfd6382021-04-29 13:06:59 +0200211Python Debug Build
212------------------
Victor Stinnera41782c2021-04-08 22:32:21 +0200213
214A debug build is Python built with the :option:`--with-pydebug` configure
215option.
216
217Effects of a debug build:
218
Victor Stinnerabfd6382021-04-29 13:06:59 +0200219* Display all warnings by default: the list of default warning filters is empty
220 in the :mod:`warnings` module.
Victor Stinnera41782c2021-04-08 22:32:21 +0200221* Add ``d`` to :data:`sys.abiflags`.
222* Add :func:`sys.gettotalrefcount` function.
223* Add :option:`-X showrefcount <-X>` command line option.
224* Add :envvar:`PYTHONTHREADDEBUG` environment variable.
Victor Stinner54366952021-04-09 01:58:20 +0200225* Add support for the ``__ltrace__`` variable: enable low-level tracing in the
226 bytecode evaluation loop if the variable is defined.
Victor Stinnerabfd6382021-04-29 13:06:59 +0200227* Install :ref:`debug hooks on memory allocators <default-memory-allocators>`
228 to detect buffer overflow and other memory errors.
229* Define ``Py_DEBUG`` and ``Py_REF_DEBUG`` macros.
230* Add runtime checks: code surroundeded by ``#ifdef Py_DEBUG`` and ``#endif``.
231 Enable ``assert(...)`` and ``_PyObject_ASSERT(...)`` assertions: don't set
232 the ``NDEBUG`` macro (see also the :option:`--with-assertions` configure
233 option). Main runtime checks:
234
235 * Add sanity checks on the function arguments.
236 * Unicode and int objects are created with their memory filled with a pattern
237 to detect usage of uninitialized objects.
238 * Ensure that functions which can clear or replace the current exception are
239 not called with an exception raised.
240 * The garbage collector (:func:`gc.collect` function) runs some basic checks
241 on objects consistency.
242 * The :c:macro:`Py_SAFE_DOWNCAST()` macro checks for integer underflow and
243 overflow when downcasting from wide types to narrow types.
Victor Stinnera41782c2021-04-08 22:32:21 +0200244
245See also the :ref:`Python Development Mode <devmode>` and the
246:option:`--with-trace-refs` configure option.
247
248.. versionchanged:: 3.8
249 Release builds and debug builds are now ABI compatible: defining the
Victor Stinnerabfd6382021-04-29 13:06:59 +0200250 ``Py_DEBUG`` macro no longer implies the ``Py_TRACE_REFS`` macro (see the
251 :option:`--with-trace-refs` option), which introduces the only ABI
252 incompatibility.
Victor Stinnera41782c2021-04-08 22:32:21 +0200253
254
255Debug options
256-------------
257
258.. cmdoption:: --with-pydebug
259
Victor Stinner54366952021-04-09 01:58:20 +0200260 :ref:`Build Python in debug mode <debug-build>`: define the ``Py_DEBUG``
261 macro (disabled by default).
Victor Stinnera41782c2021-04-08 22:32:21 +0200262
263.. cmdoption:: --with-trace-refs
264
265 Enable tracing references for debugging purpose (disabled by default).
266
267 Effects:
268
269 * Define the ``Py_TRACE_REFS`` macro.
270 * Add :func:`sys.getobjects` function.
271 * Add :envvar:`PYTHONDUMPREFS` environment variable.
272
273 This build is not ABI compatible with release build (default build) or debug
Victor Stinner54366952021-04-09 01:58:20 +0200274 build (``Py_DEBUG`` and ``Py_REF_DEBUG`` macros).
Victor Stinnera41782c2021-04-08 22:32:21 +0200275
276 .. versionadded:: 3.8
277
278.. cmdoption:: --with-assertions
279
Victor Stinner54366952021-04-09 01:58:20 +0200280 Build with C assertions enabled (default is no): ``assert(...);`` and
281 ``_PyObject_ASSERT(...);``.
Victor Stinnera41782c2021-04-08 22:32:21 +0200282
283 If set, the ``NDEBUG`` macro is not defined in the :envvar:`OPT` compiler
284 variable.
285
286 See also the :option:`--with-pydebug` option (:ref:`debug build
287 <debug-build>`) which also enables assertions.
288
289 .. versionadded:: 3.6
290
291.. cmdoption:: --with-valgrind
292
293 Enable Valgrind support (default is no).
294
295.. cmdoption:: --with-dtrace
296
297 Enable DTrace support (default is no).
298
Victor Stinner85918e42021-04-12 23:27:35 +0200299 See :ref:`Instrumenting CPython with DTrace and SystemTap
300 <instrumentation>`.
301
Victor Stinnera41782c2021-04-08 22:32:21 +0200302 .. versionadded:: 3.6
303
304.. cmdoption:: --with-address-sanitizer
305
Victor Stinner54366952021-04-09 01:58:20 +0200306 Enable AddressSanitizer memory error detector, ``asan`` (default is no).
Victor Stinnera41782c2021-04-08 22:32:21 +0200307
308 .. versionadded:: 3.6
309
310.. cmdoption:: --with-memory-sanitizer
311
Victor Stinner54366952021-04-09 01:58:20 +0200312 Enable MemorySanitizer allocation error detector, ``msan`` (default is no).
Victor Stinnera41782c2021-04-08 22:32:21 +0200313
314 .. versionadded:: 3.6
315
316.. cmdoption:: --with-undefined-behavior-sanitizer
317
Victor Stinner54366952021-04-09 01:58:20 +0200318 Enable UndefinedBehaviorSanitizer undefined behaviour detector, ``ubsan``
Victor Stinnera41782c2021-04-08 22:32:21 +0200319 (default is no).
320
321 .. versionadded:: 3.6
322
323
324Linker options
325--------------
326
327.. cmdoption:: --enable-shared
328
Victor Stinner54366952021-04-09 01:58:20 +0200329 Enable building a shared Python library: ``libpython`` (default is no).
Victor Stinnera41782c2021-04-08 22:32:21 +0200330
331.. cmdoption:: --without-static-libpython
332
333 Do not build ``libpythonMAJOR.MINOR.a`` and do not install ``python.o``
334 (built and enabled by default).
335
336 .. versionadded:: 3.10
337
338
339Libraries options
340-----------------
341
342.. cmdoption:: --with-libs='lib1 ...'
343
344 Link against additional libraries (default is no).
345
346.. cmdoption:: --with-system-expat
347
348 Build the :mod:`pyexpat` module using an installed ``expat`` library
349 (default is no).
350
351.. cmdoption:: --with-system-ffi
352
353 Build the :mod:`_ctypes` extension module using an installed ``ffi``
354 library, see the :mod:`ctypes` module (default is system-dependent).
355
356.. cmdoption:: --with-system-libmpdec
357
Victor Stinner54366952021-04-09 01:58:20 +0200358 Build the ``_decimal`` extension module using an installed ``mpdec``
Victor Stinnera41782c2021-04-08 22:32:21 +0200359 library, see the :mod:`decimal` module (default is no).
360
361 .. versionadded:: 3.3
362
Victor Stinner54366952021-04-09 01:58:20 +0200363.. cmdoption:: --with-readline=editline
Victor Stinnera41782c2021-04-08 22:32:21 +0200364
Victor Stinner54366952021-04-09 01:58:20 +0200365 Use ``editline`` library for backend of the :mod:`readline` module.
366
367 Define the ``WITH_EDITLINE`` macro.
368
369 .. versionadded:: 3.10
370
371.. cmdoption:: --without-readline
372
373 Don't build the :mod:`readline` module (built by default).
374
375 Don't define the ``HAVE_LIBREADLINE`` macro.
Victor Stinnera41782c2021-04-08 22:32:21 +0200376
377 .. versionadded:: 3.10
378
379.. cmdoption:: --with-tcltk-includes='-I...'
380
381 Override search for Tcl and Tk include files.
382
383.. cmdoption:: --with-tcltk-libs='-L...'
384
385 Override search for Tcl and Tk libraries.
386
387.. cmdoption:: --with-libm=STRING
388
389 Override ``libm`` math library to *STRING* (default is system-dependent).
390
391.. cmdoption:: --with-libc=STRING
392
393 Override ``libc`` C library to *STRING* (default is system-dependent).
394
395.. cmdoption:: --with-openssl=DIR
396
397 Root of the OpenSSL directory.
398
Victor Stinner54366952021-04-09 01:58:20 +0200399 .. versionadded:: 3.7
400
401.. cmdoption:: --with-openssl-rpath=[no|auto|DIR]
Victor Stinnera41782c2021-04-08 22:32:21 +0200402
403 Set runtime library directory (rpath) for OpenSSL libraries:
404
405 * ``no`` (default): don't set rpath;
406 * ``auto``: auto-detect rpath from :option:`--with-openssl` and
407 ``pkg-config``;
408 * *DIR*: set an explicit rpath.
409
410 .. versionadded:: 3.10
411
412
413Security Options
414----------------
415
416.. cmdoption:: --with-hash-algorithm=[fnv|siphash24]
417
418 Select hash algorithm for use in ``Python/pyhash.c``:
419
Victor Stinnera41782c2021-04-08 22:32:21 +0200420 * ``siphash24`` (default).
Victor Stinner54366952021-04-09 01:58:20 +0200421 * ``fnv``;
Victor Stinnera41782c2021-04-08 22:32:21 +0200422
423 .. versionadded:: 3.4
424
425.. cmdoption:: --with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2
426
427 Built-in hash modules:
428
429 * ``md5``;
430 * ``sha1``;
431 * ``sha256``;
432 * ``sha512``;
433 * ``sha3`` (with shake);
434 * ``blake2``.
435
436 .. versionadded:: 3.9
437
438.. cmdoption:: --with-ssl-default-suites=[python|openssl|STRING]
439
440 Override the OpenSSL default cipher suites string:
441
Victor Stinner54366952021-04-09 01:58:20 +0200442 * ``python`` (default): use Python's preferred selection;
Victor Stinnera41782c2021-04-08 22:32:21 +0200443 * ``openssl``: leave OpenSSL's defaults untouched;
444 * *STRING*: use a custom string, PROTOCOL_SSLv2 ignores the setting.
445
446 See the :mod:`ssl` module.
447
448 .. versionadded:: 3.7
449
450
451macOS Options
452-------------
453
454See ``Mac/README.rst``.
455
Victor Stinner54366952021-04-09 01:58:20 +0200456.. cmdoption:: --enable-universalsdk
457.. cmdoption:: --enable-universalsdk=SDKDIR
Victor Stinnera41782c2021-04-08 22:32:21 +0200458
459 Create a universal binary build. *SDKDIR* specifies which macOS SDK should
460 be used to perform the build (default is no).
461
Victor Stinner54366952021-04-09 01:58:20 +0200462.. cmdoption:: --enable-framework
463.. cmdoption:: --enable-framework=INSTALLDIR
Victor Stinnera41782c2021-04-08 22:32:21 +0200464
465 Create a Python.framework rather than a traditional Unix install. Optional
466 *INSTALLDIR* specifies the installation path (default is no).
467
468.. cmdoption:: --with-universal-archs=ARCH
469
Victor Stinner54366952021-04-09 01:58:20 +0200470 Specify the kind of universal binary that should be created. This option is
Victor Stinnera41782c2021-04-08 22:32:21 +0200471 only valid when :option:`--enable-universalsdk` is set.
472
Victor Stinner54366952021-04-09 01:58:20 +0200473 Options:
Victor Stinnera41782c2021-04-08 22:32:21 +0200474
475 * ``universal2``;
476 * ``32-bit``;
477 * ``64-bit``;
478 * ``3-way``;
479 * ``intel``;
480 * ``intel-32``;
481 * ``intel-64``;
482 * ``all``.
483
484.. cmdoption:: --with-framework-name=FRAMEWORK
485
486 Specify the name for the python framework on macOS only valid when
487 :option:`--enable-framework` is set (default: ``Python``).
488
489
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200490Python Build System
491===================
492
493Main files of the build system
494------------------------------
495
496* :file:`configure.ac` => :file:`configure`;
497* :file:`Makefile.pre.in` => :file:`Makefile` (created by :file:`configure`);
498* :file:`pyconfig.h` (created by :file:`configure`);
499* :file:`Modules/Setup`: C extensions built by the Makefile using
500 :file:`Module/makesetup` shell script;
501* :file:`setup.py`: C extensions built using the :mod:`distutils` module.
502
503Main build steps
504----------------
505
506* C files (``.c``) are built as object files (``.o``).
507* A static ``libpython`` library (``.a``) is created from objects files.
508* ``python.o`` and the static ``libpython`` library are linked into the
509 final ``python`` program.
510* C extensions are built by the Makefile (see :file:`Modules/Setup`)
511 and ``python setup.py build``.
512
513Main Makefile targets
514---------------------
515
516* ``make``: Build Python with the standard library.
517* ``make platform:``: build the ``python`` program, but don't build the
518 standard library extension modules.
519* ``make profile-opt``: build Python using Profile Guided Optimization (PGO).
520 You can use the configure :option:`--enable-optimizations` option to make
521 this the default target of the ``make`` command (``make all`` or just
522 ``make``).
523* ``make buildbottest``: Build Python and run the Python test suite, the same
524 way than buildbots test Python. Set ``TESTTIMEOUT`` variable (in seconds)
525 to change the test timeout (1200 by default: 20 minutes).
526* ``make install``: Build and install Python.
527* ``make regen-all``: Regenerate (almost) all generated files;
528 ``make regen-stdlib-module-names`` and ``autoconf`` must be run separately
529 for the remaining generated files.
530* ``make clean``: Remove built files.
531* ``make distclean``: Same than ``make clean``, but remove also files created
532 by the configure script.
533
534C extensions
535------------
536
537Some C extensions are built as built-in modules, like the ``sys`` module.
538They are built with the ``Py_BUILD_CORE_BUILTIN`` macro defined.
539Built-in modules have no ``__file__`` attribute::
540
541 >>> import sys
542 >>> sys
543 <module 'sys' (built-in)>
544 >>> sys.__file__
545 Traceback (most recent call last):
546 File "<stdin>", line 1, in <module>
547 AttributeError: module 'sys' has no attribute '__file__'
548
549Other C extensins are built as dynamic libraires, like the ``_asyncio`` module.
550They are built with the ``Py_BUILD_CORE_MODULE`` macro defined.
551Example on Linux x86-64::
552
553 >>> import _asyncio
554 >>> _asyncio
555 <module '_asyncio' from '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'>
556 >>> _asyncio.__file__
557 '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'
558
559:file:`Modules/Setup` is used to generate Makefile targets to build C extensions.
560At the beginning of the files, C extensions are built as built-in modules.
561Extensions defined after the ``*shared*`` marker are built as dynamic libraries.
562
563The :file:`setup.py` script only builds C extensions as shared libraries using
564the :mod:`distutils` module.
565
566The :c:macro:`PyAPI_FUNC()`, :c:macro:`PyAPI_API()` and
567:c:macro:`PyMODINIT_FUNC()` macros of :file:`Include/pyport.h` are defined
568differently depending if the ``Py_BUILD_CORE_MODULE`` macro is defined:
569
570* Use ``Py_EXPORTED_SYMBOL`` if the ``Py_BUILD_CORE_MODULE`` is defined
571* Use ``Py_IMPORTED_SYMBOL`` otherwise.
572
573If the ``Py_BUILD_CORE_BUILTIN`` macro is used by mistake on a C extension
574built as a shared library, its ``PyInit_xxx()`` function is not exported,
575causing an :exc:`ImportError` on import.
576
577
Victor Stinnera41782c2021-04-08 22:32:21 +0200578Compiler and linker flags
579=========================
580
Victor Stinner54366952021-04-09 01:58:20 +0200581Options set by the ``./configure`` script and environment variables and used by
582``Makefile``.
583
Victor Stinnera41782c2021-04-08 22:32:21 +0200584Preprocessor flags
585------------------
586
Victor Stinnera41782c2021-04-08 22:32:21 +0200587.. envvar:: CONFIGURE_CPPFLAGS
588
Victor Stinner54366952021-04-09 01:58:20 +0200589 Value of :envvar:`CPPFLAGS` variable passed to the ``./configure`` script.
590
Victor Stinnera41782c2021-04-08 22:32:21 +0200591 .. versionadded:: 3.6
592
593.. envvar:: CPPFLAGS
594
595 (Objective) C/C++ preprocessor flags, e.g. ``-I<include dir>`` if you have
596 headers in a nonstandard directory ``<include dir>``.
597
598 Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's
599 value for setup.py to be able to build extension modules using the
600 directories specified in the environment variables.
601
602.. envvar:: BASECPPFLAGS
603
604 .. versionadded:: 3.4
605
Victor Stinnera41782c2021-04-08 22:32:21 +0200606.. envvar:: PY_CPPFLAGS
607
608 Extra preprocessor flags added for building the interpreter object files.
609
610 Default: ``$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)``.
611
612 .. versionadded:: 3.2
613
614Compiler flags
615--------------
616
617.. envvar:: CC
618
619 C compiler command.
620
Victor Stinner54366952021-04-09 01:58:20 +0200621 Example: ``gcc -pthread``.
622
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200623.. envvar:: MAINCC
624
625 C compiler command used to build the ``main()`` function of programs like
626 ``python``.
627
628 Variable set by the :option:`--with-cxx-main` option of the configure
629 script.
630
631 Default: ``$(CC)``.
632
Victor Stinner54366952021-04-09 01:58:20 +0200633.. envvar:: CXX
634
635 C++ compiler command.
636
637 Used if the :option:`--with-cxx-main` option is used.
638
639 Example: ``g++ -pthread``.
640
Victor Stinnera41782c2021-04-08 22:32:21 +0200641.. envvar:: CFLAGS
642
643 C compiler flags.
644
645.. envvar:: CFLAGS_NODIST
646
647 :envvar:`CFLAGS_NODIST` is used for building the interpreter and stdlib C
648 extensions. Use it when a compiler flag should *not* be part of the
649 distutils :envvar:`CFLAGS` once Python is installed (:issue:`21121`).
650
651 .. versionadded:: 3.5
652
653.. envvar:: EXTRA_CFLAGS
654
655 Extra C compiler flags.
656
657.. envvar:: CONFIGURE_CFLAGS
658
Victor Stinner54366952021-04-09 01:58:20 +0200659 Value of :envvar:`CFLAGS` variable passed to the ``./configure``
660 script.
661
Victor Stinnera41782c2021-04-08 22:32:21 +0200662 .. versionadded:: 3.2
663
664.. envvar:: CONFIGURE_CFLAGS_NODIST
665
Victor Stinner54366952021-04-09 01:58:20 +0200666 Value of :envvar:`CFLAGS_NODIST` variable passed to the ``./configure``
667 script.
668
Victor Stinnera41782c2021-04-08 22:32:21 +0200669 .. versionadded:: 3.5
670
671.. envvar:: BASECFLAGS
672
Victor Stinner54366952021-04-09 01:58:20 +0200673 Base compiler flags.
674
Victor Stinnera41782c2021-04-08 22:32:21 +0200675.. envvar:: OPT
676
677 Optimization flags.
678
679.. envvar:: CFLAGS_ALIASING
680
681 Strict or non-strict aliasing flags used to compile ``Python/dtoa.c``.
682
683 .. versionadded:: 3.7
684
Victor Stinner54366952021-04-09 01:58:20 +0200685.. envvar:: CCSHARED
686
687 Compiler flags used to build a shared library.
688
689 For example, ``-fPIC`` is used on Linux and on BSD.
690
Victor Stinnera41782c2021-04-08 22:32:21 +0200691.. envvar:: CFLAGSFORSHARED
692
693 Extra C flags added for building the interpreter object files.
694
Victor Stinner54366952021-04-09 01:58:20 +0200695 Default: ``$(CCSHARED)`` when :option:`--enable-shared` is used, or an empty
696 string otherwise.
697
Victor Stinnera41782c2021-04-08 22:32:21 +0200698.. envvar:: PY_CFLAGS
699
700 Default: ``$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)``.
701
702.. envvar:: PY_CFLAGS_NODIST
703
704 Default: ``$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/internal``.
705
706 .. versionadded:: 3.5
707
708.. envvar:: PY_STDMODULE_CFLAGS
709
710 C flags used for building the interpreter object files.
711
712 Default: ``$(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED)``.
713
714 .. versionadded:: 3.7
715
716.. envvar:: PY_CORE_CFLAGS
717
718 Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE``.
719
720 .. versionadded:: 3.2
721
722.. envvar:: PY_BUILTIN_MODULE_CFLAGS
723
Victor Stinner54366952021-04-09 01:58:20 +0200724 Compiler flags to build a standard library extension module as a built-in
725 module, like the :mod:`posix` module.
726
Victor Stinnera41782c2021-04-08 22:32:21 +0200727 Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN``.
728
729 .. versionadded:: 3.8
730
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200731.. envvar:: PURIFY
732
733 Purify command. Purify is a memory debugger program.
734
735 Default: empty string (not used).
736
Victor Stinnera41782c2021-04-08 22:32:21 +0200737
738Linker flags
739------------
740
Victor Stinnerbd88ccb2021-04-09 14:35:10 +0200741.. envvar:: LINKCC
742
743 Linker command used to build programs like ``python`` and ``_testembed``.
744
745 Default: ``$(PURIFY) $(MAINCC)``.
746
Victor Stinnera41782c2021-04-08 22:32:21 +0200747.. envvar:: CONFIGURE_LDFLAGS
748
Victor Stinner54366952021-04-09 01:58:20 +0200749 Value of :envvar:`LDFLAGS` variable passed to the ``./configure`` script.
750
Victor Stinnera41782c2021-04-08 22:32:21 +0200751 Avoid assigning :envvar:`CFLAGS`, :envvar:`LDFLAGS`, etc. so users can use
752 them on the command line to append to these values without stomping the
753 pre-set values.
754
755 .. versionadded:: 3.2
756
757.. envvar:: LDFLAGS_NODIST
758
759 :envvar:`LDFLAGS_NODIST` is used in the same manner as
760 :envvar:`CFLAGS_NODIST`. Use it when a linker flag should *not* be part of
761 the distutils :envvar:`LDFLAGS` once Python is installed (:issue:`35257`).
762
763.. envvar:: CONFIGURE_LDFLAGS_NODIST
764
Victor Stinner54366952021-04-09 01:58:20 +0200765 Value of :envvar:`LDFLAGS_NODIST` variable passed to the ``./configure``
766 script.
767
Victor Stinnera41782c2021-04-08 22:32:21 +0200768 .. versionadded:: 3.8
769
770.. envvar:: LDFLAGS
771
772 Linker flags, e.g. ``-L<lib dir>`` if you have libraries in a nonstandard
773 directory ``<lib dir>``.
774
775 Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's
776 value for setup.py to be able to build extension modules using the
777 directories specified in the environment variables.
778
779.. envvar:: LIBS
780
Victor Stinner54366952021-04-09 01:58:20 +0200781 Linker flags to pass libraries to the linker when linking the Python
782 executable.
783
784 Example: ``-lrt``.
Victor Stinnera41782c2021-04-08 22:32:21 +0200785
786.. envvar:: LDSHARED
787
788 Command to build a shared library.
789
790 Default: ``@LDSHARED@ $(PY_LDFLAGS)``.
791
792.. envvar:: BLDSHARED
793
Victor Stinner54366952021-04-09 01:58:20 +0200794 Command to build ``libpython`` shared library.
Victor Stinnera41782c2021-04-08 22:32:21 +0200795
796 Default: ``@BLDSHARED@ $(PY_CORE_LDFLAGS)``.
797
798.. envvar:: PY_LDFLAGS
799
800 Default: ``$(CONFIGURE_LDFLAGS) $(LDFLAGS)``.
801
802.. envvar:: PY_LDFLAGS_NODIST
803
804 Default: ``$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)``.
805
806 .. versionadded:: 3.8
807
808.. envvar:: PY_CORE_LDFLAGS
809
810 Linker flags used for building the interpreter object files.
811
812 .. versionadded:: 3.8