@@ -84,6 +84,28 @@ compiler and linker options from various sources:
84
84
85
85
.. Ignoring AR, ARFLAGS, RANLIB here because they are used by the (obsolete?) build_clib, not build_ext.
86
86
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
+
87
109
The resulting command line is then processed by the compiler and linker.
88
110
According to the GCC manual sections on `directory options `_ and
89
111
`environment variables `_, the C/C++ compiler searches for files named in
0 commit comments