From df7523b23ec6ab5fc4a90163c3669b75d76f5aff Mon Sep 17 00:00:00 2001 From: Kim R2 <65985742+tzarsquared@users.noreply.github.com> Date: Tue, 15 Jun 2021 15:41:39 +0200 Subject: [PATCH] Language edit --- source/tutorials/cross-compilation.rst | 42 +++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/source/tutorials/cross-compilation.rst b/source/tutorials/cross-compilation.rst index d8258cb..f0bbe89 100644 --- a/source/tutorials/cross-compilation.rst +++ b/source/tutorials/cross-compilation.rst @@ -12,24 +12,24 @@ or when it's not easily accessible for development. 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, - we have chosen to follow +.. [#] Terminology for cross-compilation platforms differs between build systems. + We have chosen to follow `autoconf terminology `_. -.. note:: macOS/Darwin is a special case, as not the whole OS is Open Source. +.. note:: macOS/Darwin is a special case, as not the whole OS is open-source. It's only possible to cross-compile between ``aarch64-darwin`` and ``x86_64-darwin``. What's a target platform? ------------------------- -There's actually a third platform named target. +There's actually a third platform named the target platform. 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 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 host. +Since that's rarely needed, we'll treat the target platform the same as the host. Determining the host platform config @@ -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), platform config has to be constructed manually via the following template: +for development), the platform config has to be constructed manually via the following template: .. code:: @@ -67,7 +67,7 @@ Some other common examples of platform configs: Choosing the host platform with Nix ----------------------------------- -Nixpkgs comes with a set of predefined host plaform applied to all packages. +Nixpkgs comes with a set of predefined host platforms applied to all packages. It's possible to list predefined sets via shell completion: @@ -103,9 +103,9 @@ It's possible to list predefined sets via shell completion: pkgsCross.msp430 -From the attribute name it can't always be immediately clear what is the platform. +From the attribute name it isn't always immediately clear what the platform is. -It's possible to query the platform config using:: +It's possible to query the platform config using: $ nix-instantiate '' -A pkgsCross.aarch64-darwin.hostPlatform.config --eval "aarch64-apple-darwin" @@ -118,7 +118,7 @@ Cross-compiling for the first time! ----------------------------------- To cross-compile a package like `hello `_, -pick the platform attribute like ``aarch64-multiplatform`` in our case and run: +pick the platform attribute - ``aarch64-multiplatform`` in our case - and run: .. code:: shell-session @@ -127,10 +127,10 @@ pick the platform attribute like ``aarch64-multiplatform`` in our case and run: /nix/store/pzi2h0d60nb4ydcl3nn7cbxxdnibw3sy-hello-aarch64-unknown-linux-gnu-2.10 `Search for a package `_ attribute name to find the -one that you're interested in to build. +one that you're interested in building. -Real world cross-compiling of a Hello World example +Real-world cross-compiling of a Hello World example --------------------------------------------------- To show off the power of cross-compilation in Nix, let's build our own Hello World program @@ -166,10 +166,10 @@ with `an emulator `_. $CC ${helloWorld} -o hello # Run the compiled program using user mode emulation (Qemu/Wine) - # buildPackages are passed so that emulation is built for the build platform + # buildPackages is passed so that emulation is built for the build platform ${hostPkgs.stdenv.hostPlatform.emulator hostPkgs.buildPackages} hello > $out - # print to stdout program stdout + # print to stdout cat $out ''; in { @@ -190,10 +190,10 @@ If we build this example and print both resulting derivations, we should see "He Developer environment with a cross-compiler ------------------------------------------- -In :ref:`tutorial for declarative reproducible environments `, -we've looked at how Nix helps us provide tooling and system libraries for our project. +In the :ref:`tutorial for declarative reproducible environments `, +we looked at how Nix helps us provide tooling and system libraries for our project. -It's also possible to provide an environment with a compiler configured for cross-compilation! +It's also possible to provide an environment with a compiler configured for cross-compilation. Given we have a ``shell.nix``: @@ -205,7 +205,7 @@ Given we have a ``shell.nix``: # pkgs.callPackage is needed due to https://github.com/NixOS/nixpkgs/pull/126844 pkgs.callPackage ({ mkShell, zlib, pkg-config, file }: mkShell { - # these tools run on the build platform, but are configure to target the target platform + # these tools run on the build platform, but are configured to target the target platform nativeBuildInputs = [ pkg-config file ]; # libraries needed for the target platform buildInputs = [ zlib ]; @@ -240,7 +240,7 @@ And confirm it's aarch64: Next steps ---------- -- `Official binary cache `_ doesn't come with binaries +- The `official binary cache `_ doesn't come with binaries for packages that are cross-compiled, so it's important to set up :ref:`a binary cache and CI (GitHub Actions and Cachix) `. @@ -249,9 +249,9 @@ Next steps On top of that, supporting cross-compilation is not trivial work and due to many possible combinations of what would - need to be tested, packages some might not build. + need to be tested, some packages might not build. - `A detailed explanation how cross-compilation is implemented in Nix can help fixing those issues `_. + `A detailed explanation how of cross-compilation is implemented in Nix `_ can help with fixing those issues. - The Nix community has a `dedicated Matrix room `_ for help around cross-compiling.