Skip to content

Commit 3e69da7

Browse files
committed
backlink to env vars in cross-compilation
1 parent 8d03df8 commit 3e69da7

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

sphinx/src/maintainer/knowledge_base.rst

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,12 @@ Cross-compilation terminology usually distinguishes between two types of machine
325325
.. note::
326326

327327
Some cross-compilation documentation might also distinguish between a third type of machine, the
328-
target machine. You can read more about it in `this Stack Overflow question
328+
target machine. You can read more about it in `this Stack Overflow question
329329
<https://stackoverflow.com/questions/47010422/cross-compilation-terminologies-build-host-and-target>`__.
330330
For the purposes of conda-forge, we'll consider the target machine to be the same as the host.
331331

332+
.. _cross_compilation_howto:
333+
332334
How to enable cross-compilation
333335
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
334336

@@ -369,8 +371,8 @@ can aid in cross-compilation setups:
369371
automatically created for you too.
370372
- ``CC_FOR_BUILD``: C compilers targeting the build platform.
371373
- ``CXX_FOR_BUILD``: C++ compilers targeting the build platform.
372-
- ``CROSSCOMPILING_EMULATOR``: the emulator to use when emulating the target platform. This is
373-
usually set to the ``qemu`` binary for the host platform.
374+
- ``CROSSCOMPILING_EMULATOR``: Path to the ``qemu`` binary for the host platform (see
375+
:ref:`emulation`).
374376

375377
This is all supported by two main conda-build features introduced in version 3:
376378

@@ -438,7 +440,7 @@ In the build script, it would need to update ``cmake`` call and guard any tests
438440
439441
# Pass ``CMAKE_ARGS`` to ``cmake``
440442
cmake ${CMAKE_ARGS} ..
441-
443+
442444
# Skip ``ctest`` when cross-compiling
443445
if [[ "${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR:-}" != "" ]]; then
444446
ctest
@@ -507,11 +509,11 @@ In practical terms, for conda-forge, this results into two extra metadata bits t
507509
wrapper for the ``crossenv`` Python interpreters with `some activation logic that adjust some of
508510
the crossenv workarounds
509511
<https://github.com/conda-forge/cross-python-feedstock/blob/main/recipe/activate-cross-python.sh>`__
510-
so they work better with the conda-build setup.
512+
so they work better with the conda-build setup.
511513
- Copying some Python-related packages from ``host`` to ``build`` with a ``[build_platform !=
512514
target_platform]`` selector:
513515

514-
- ``python`` itself, to support ``crossenv``.
516+
- ``python`` itself, to support ``crossenv``.
515517
- Non-pure Python packages (i.e. they ship compiled libraries) that need to be present while the
516518
package is being built, like ``cython`` and ``numpy``.
517519

@@ -526,7 +528,7 @@ following changes before the builds scripts run:
526528
is also included in ``$PYTHONPATH``.
527529
- A copy of all ``$PREFIX`` site-packages to ``$BUILD_PREFIX`` (except the compiled libraries).
528530

529-
All in all, this results in a setup where ``conda-build`` can run a ``$BUILD_PREFIX``-architecture
531+
All in all, this results in a setup where ``conda-build`` can run a ``$BUILD_PREFIX``-architecture
530532
``python`` interpreter that can see the packages in ``$PREFIX`` (with the compiled bits provided by
531533
their corresponding counterparts in ``$BUILD_PREFIX``) and sufficiently mimic that target
532534
architecture.
@@ -556,7 +558,7 @@ Ensure changes are applied by :ref:`rerendering <dev_update_rerender>` the feeds
556558
Emulation examples
557559
^^^^^^^^^^^^^^^^^^
558560

559-
Configure ``conda-forge.yml`` to emulate ``linux-ppc64le``, but use native runners for ``linux-64``
561+
Configure ``conda-forge.yml`` to emulate ``linux-ppc64le``, but use native runners for ``linux-64``
560562
and ``linux-aarch64``. This works because ``linux-ppc64le`` is not natively supported by Azure, so
561563
``conda-smithy`` will add QEMU steps to emulate it. However, ``linux-64`` and ``linux-aarch64`` are
562564
natively supported by Azure and Travis CI, respectively, so no emulation is needed.
@@ -568,6 +570,15 @@ natively supported by Azure and Travis CI, respectively, so no emulation is need
568570
linux_ppc64le: azure
569571
linux_64: azure
570572
573+
Use this variables in your builds scripts if needed:
574+
575+
- ``CONDA_BUILD_CROSS_COMPILATION``: Set to ``1`` when build and host platforms differ. This can
576+
mean your are cross-compiling or emulating.
577+
- ``CROSSCOMPILING_EMULATOR``: Path to the ``qemu`` binary for the host platform.
578+
579+
See also :ref:`cross_compilation_howto` for other variables you might find useful in your build
580+
scripts.
581+
571582
Rust Nightly
572583
------------
573584

@@ -638,13 +649,13 @@ When should CDTs be used?
638649
2. When a conda packaged library will not work properly.
639650
For example: a new ``glibc`` package means we would have to edit the elf interpreter of
640651
all the conda package binaries.
641-
652+
642653
What's are some good examples?
643654
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
644655

645656
1. The OpenCL loader (``ocl-icd`` together with ``ocl-icd-system``) provides an OpenCL
646657
loading library. The loader will look at OpenCL implementations given in
647-
``$CONDA_PREFIX/etc/OpenCL/vendors``.
658+
``$CONDA_PREFIX/etc/OpenCL/vendors``.
648659
For example: Pocl is a conda packaged implementation that runs OpenCL on the CPU. Vendor
649660
specific implementations like the NVIDIA OpenCL or ROCm OpenCL are not conda packaged, so we
650661
have to rely on the system. By installing ``ocl-icd-system`` we enable the loader to look at

0 commit comments

Comments
 (0)