summaryrefslogtreecommitdiff
path: root/docs/userguide/ext_modules.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/userguide/ext_modules.rst')
-rw-r--r--docs/userguide/ext_modules.rst20
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/userguide/ext_modules.rst b/docs/userguide/ext_modules.rst
index 0467f4ec..9f19e8c7 100644
--- a/docs/userguide/ext_modules.rst
+++ b/docs/userguide/ext_modules.rst
@@ -84,6 +84,26 @@ compiler and linker options from various sources:
.. Ignoring AR, ARFLAGS, RANLIB here because they are used by the (obsolete?) build_clib, not build_ext.
+Specifically, if the environment variables ``CC``, ``CPP``, ``CXX``, and ``LDSHARED``
+are set, they will be used instead of the ``sysconfig`` variables of the same names.
+
+The compiler options appear in the command line in the following order:
+
+.. Reference: "compiler_so" and distutils.ccompiler.gen_preprocess_options, CCompiler.compile, UnixCCompiler._compile
+
+* first, the options provided by the ``sysconfig`` variable ``CFLAGS``,
+* then, the options provided by the environment variables ``CFLAGS`` and ``CPPFLAGS``,
+* then, the options provided by the ``sysconfig`` variable ``CCSHARED``,
+* finally, a ``-I`` option for each element of ``Extension.include_dirs``.
+
+The linker options appear in the command line in the following order:
+
+.. Reference: "linker_so" and CCompiler.link
+
+* first, the options provided by environment variables and ``sysconfig`` variables,
+* then, a ``-L`` option for each element of ``Extension.library_dirs``,
+* finally, a linker-specific option like ``-Wl,-rpath`` for each element of ``Extension.runtime_library_dirs``.
+
The resulting command line is then processed by the compiler and linker.
According to the GCC manual sections on `directory options`_ and
`environment variables`_, the C/C++ compiler searches for files named in