Skip to content

Commit 3366232

Browse files
authored
Merge pull request #1685 from timsnyder/add_to_user_compiler_faq
2 parents 46bce6e + fc1e984 commit 3366232

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/maintainer/adding_pkgs.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ for the specification on expressions.
706706
Miscellaneous
707707
=============
708708

709+
.. _activate_scripts:
710+
709711
Activate scripts
710712
----------------
711713

src/user/faq.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,56 @@ FAQ
7373
7474
are a telltale sign that you are lacking compilers.
7575

76+
.. _faq_compiler_required_options:
77+
78+
:ref:`(Q) <faq_compiler_required_options>` **Why don't the C/C++ compilers automatically know how to find libraries installed by conda?**
79+
80+
All of our toolchains are built as cross-compilers (even when they are built to run on the same
81+
architecture that they are targeting). We do this because it makes it possible to then install
82+
them anywhere like any other conda package. As a result, the builtin search path for the
83+
compilers only contains the sysroot they were built with. The compiler binary names are also
84+
'prefixed' with more complete information about the architecture and :std:term:`ABI` they target. So, instead
85+
of ``gcc``, the actual binary will be named something like ``x86_64-conda-linux-gnu-cc``.
86+
87+
The conda-forge infrastructure provides :ref:`activation scripts <activate_scripts>` which are run when
88+
you ``conda activate`` an environment that contains the compiler toolchain. Those scripts set
89+
many environment variables that are typically used by GNU ``autotools`` and ``make`` in the
90+
``standard`` (i.e. builtin) build rules. For example, you would see the variable ``CC`` set to
91+
the long compiler name ``x86_64-conda-linux-gnu-cc``. The activation scripts also set a
92+
``CMAKE_ARGS`` variable with many arguments the conda-forge community finds helpful for
93+
configuring cmake build flows. Of particular note, the activation scripts add the
94+
``CONDA_PREFIX/include`` and ``CONDA_PREFIX/lib`` paths to the appropriate ``FLAGS`` environment
95+
variables (``CLAGS``, ``CPPFLAGS``, ``LDFLAGS``, etc) so that many build systems will pick them up correctly.
96+
97+
What do you do if you have custom ``FLAGS`` that your project requires for it's build or you can't
98+
build with some of the flags supplied by conda-forge? What if you are building something that
99+
is setup for cross-compiling and expects ``CC`` to contain the name of the target toolchain but
100+
wants to be able to build some things for the build-host to use during the build by just calling
101+
``gcc``?
102+
103+
The :ref:`compiler metapackages mentioned above <faq_compiler_metapkg>` also install packages that
104+
create symlinks of the short names (like ``gcc``) to the actual toolchain binary names (like
105+
``x86_64-conda-linux-gnu-cc``) for toolchains that are targeting the system they are running on.
106+
107+
A new optional package called ``conda-gcc-specs`` can also be installed that adds:
108+
* ``-include $CONDA_PREFIX/include`` to compile commands
109+
* ``-rpath $CONDA_PREFIX/lib -rpath-link $CONDA_PREFIX/lib -disable-new-dtags -L $CONDA_PREFIX/lib`` to link
110+
commands
111+
112+
Using the compiler metapackage with ``conda-gcc-specs`` you can incude and link libraries installed
113+
in ``CONDA_PREFIX`` without having to provide any conda-specific cmdline arguments.
114+
115+
.. _faq_compiler_use_system_libs:
116+
117+
:ref:`(Q) <faq_compiler_use_system_libs>` **How can I make conda gcc use my system libraries?**
118+
119+
First, the conda-forge infrastructure tries very hard to avoid using any of the system-provided
120+
libraries, otherwise the dependencies betweeen packages quickly become incomplete and nothing works.
121+
122+
However, as an end user, when not building something that will be packaged and distributed via
123+
conda-forge, you may need to link against libraries on your system instead of libraries in your
124+
conda environment. This can be accomplished (for gcc) by passing ``-sysroot=/`` on the cmdline.
125+
76126
.. _faq_cuda_compiler_header:
77127

78128
:ref:`(Q) <faq_cuda_compiler_header>` **How can I compile CUDA (host or device) codes in my environment?**

0 commit comments

Comments
 (0)