Skip to content

Commit 61d72a5

Browse files
authored
Add more detail on sysconfig/environ vars for build_ext (#3387)
docs/userguide/ext_modules.rst: Add more detail on sysconfig/environ vars
2 parents 173e1fa + 89bb914 commit 61d72a5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/userguide/ext_modules.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,28 @@ compiler and linker options from various sources:
8484

8585
.. Ignoring AR, ARFLAGS, RANLIB here because they are used by the (obsolete?) build_clib, not build_ext.
8686
87+
Specifically, if the environment variables ``CC``, ``CPP``, ``CXX``, and ``LDSHARED``
88+
are set, they will be used instead of the ``sysconfig`` variables of the same names.
89+
90+
The compiler options appear in the command line in the following order:
91+
92+
.. Reference: "compiler_so" and distutils.ccompiler.gen_preprocess_options, CCompiler.compile, UnixCCompiler._compile
93+
94+
* first, the options provided by the ``sysconfig`` variable ``CFLAGS``,
95+
* then, the options provided by the environment variables ``CFLAGS`` and ``CPPFLAGS``,
96+
* then, the options provided by the ``sysconfig`` variable ``CCSHARED``,
97+
* then, a ``-I`` option for each element of ``Extension.include_dirs``,
98+
* finally, the options provided by ``Extension.extra_compile_args``.
99+
100+
The linker options appear in the command line in the following order:
101+
102+
.. Reference: "linker_so" and CCompiler.link
103+
104+
* first, the options provided by environment variables and ``sysconfig`` variables,
105+
* then, a ``-L`` option for each element of ``Extension.library_dirs``,
106+
* then, a linker-specific option like ``-Wl,-rpath`` for each element of ``Extension.runtime_library_dirs``,
107+
* finally, the options provided by ``Extension.extra_link_args``.
108+
87109
The resulting command line is then processed by the compiler and linker.
88110
According to the GCC manual sections on `directory options`_ and
89111
`environment variables`_, the C/C++ compiler searches for files named in

0 commit comments

Comments
 (0)