Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Jun 15, 2021
1 parent 365c398 commit f9922e9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions source/tutorials/cross-compilation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ to the **host platform**, where the compiled **executable runs**. [#]_
It's needed when the host platform has limited resources (such as CPU)
or when it's not easily accessible for development.

Nix community has world-class support for cross-compilation,
The Nix community has world-class support for cross-compilation,
after years of hard work from our community.

.. [#] Terminology for cross-compilation platforms differs between build systems,
Nix community has chosen to follow
we have chosen to follow
`autoconf terminology <https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Hosts-and-Cross_002dCompilation.html>`_.
.. note:: macOS/Darwin is a special case, as not the whole OS is Open Source.
Expand All @@ -27,13 +27,13 @@ There's actually a third platform named target.

It matters in cases where you'd like to distribute a compiler binary,
as you'd then like to build a compiler on the build platform, compile code on the
target plaform and run the final executable on the host platform.
host plaform and run the final executable on the target platform.

Since that's rarely needed, we'll treat target platform the same as the build.
Since that's rarely needed, we'll treat target platform the same as the host.


Determining the host platform
-----------------------------
Determining the host platform config
------------------------------------

The build platform is determined automatically by Nix
as it can just guess it during the configure phase.
Expand All @@ -46,7 +46,7 @@ The host platform is best determined by running on the host platform:
aarch64-unknown-linux-gnu
In case that's not possible (when the host platform is not easily accessible
for development), it has to be constructed manually via the following template:
for development), platform config has to be constructed manually via the following template:

.. code::
Expand All @@ -56,7 +56,7 @@ Note that ``<vendor>`` is often ``unknown`` and ``<abi>`` is optional.
There's also no unique identifier for a platform, for example ``unknown`` and
``pc`` are interchangeable (hence it's called config.guess).

Some other common examples of platforms:
Some other common examples of platform configs:

- aarch64-apple-darwin14
- aarch64-pc-linux-gnu
Expand Down Expand Up @@ -105,7 +105,7 @@ It's possible to list predefined sets via shell completion:
From the attribute name it can't always be immediately clear what is the platform.

It's possible to query the platform name using::
It's possible to query the platform config using::

$ nix-instantiate '<nixpkgs>' -A pkgsCross.aarch64-darwin.hostPlatform.config --eval
"aarch64-apple-darwin"
Expand All @@ -118,7 +118,7 @@ Cross-compiling for the first time!
-----------------------------------

To cross-compile a package like `hello <https://www.gnu.org/software/hello/>`_,
pick the platform target name like ``aarch64-multiplatform`` in our case and run:
pick the platform attribute like ``aarch64-multiplatform`` in our case and run:

.. code:: shell-session
Expand Down Expand Up @@ -165,8 +165,8 @@ with `an emulator <https://en.wikipedia.org/wiki/Emulator>`_.
# Compile our example using the compiler specific to our host platform
$CC ${helloWorld} -o hello
# Run the compiled program using an emulator
# Usually Qemu, but on windows it is Wine
# Run the compiled program using user mode emulation (Qemu/Wine)
# buildPackages are passed so that emulation is built for the build platform
${hostPkgs.stdenv.hostPlatform.emulator hostPkgs.buildPackages} hello > $out
# print to stdout program stdout
Expand Down Expand Up @@ -253,5 +253,5 @@ Next steps

`A detailed explanation how cross-compilation is implemented in Nix can help fixing those issues <https://nixos.org/manual/nixpkgs/stable/#chap-cross>`_.

- Nix community has a `dedicated Matrix room <https://matrix.to/#/#cross-compiling:nixos.org>`_
- The Nix community has a `dedicated Matrix room <https://matrix.to/#/#cross-compiling:nixos.org>`_
for help around cross-compiling.

0 comments on commit f9922e9

Please sign in to comment.