Skip to contentSkip to conversation

Add support for the Rust programming language

PATCH New Eric Le Bihan 4 participants 20 messages Feb 4, 2018 – Feb 9, 2018

lore
Share & tools
lore
#0 lore raw

v10 cover Add support for the Rust programming language

This series adds support for the Rust programming language by adding the following packages:

- rustc: a virtual package for the Rust compiler.
- rust-bin: provides a pre-built version of rustc.
- cargo-bin: provides a pre-built version of Rust package manager.
- rust: builds rustc from source.
- cargo: builds Rust package manager from source.

Only the host variants are provided.

The rustc virtual package is inspired by the mysql one.

v9 -> v10:

- add test cases in support/testing
- add documentation about adding cargo-based packages
- bump cargo to 0.24.0
- bump rust to 1.23.0
- bump cargo-bin to 0.24.0
- bump rust-bin to 1.23.0
- clarify origin of some hashes
- reword some comments
- use $(BR2_CMAKE_HOST_DEPENDENCY) wherever needed
- move some options management from *.mk to Config.in

v8 -> v9:

- replace giant patch by post-extract hook
- drop rust-cargo virtual package
- explicitly enable SSL support in host-libcurl

v7 -> v8:

- replace cargo-bootstrap by cargo-bin
- drop rust-bootstrap and use rust-bin instead
- rust-bin and rust versions are the same
- cargo-bin and cargo versions are the same
- bump cargo to 0.23.0
- bump rust to 1.22.1
- add rust-cargo virtual package

v6 -> v7:

- add cargo 0.20.0
- bump rust to 1.19.0
- bump rust-bootstrap to 1.18.0
- bump cargo-bootstrap to 0.19.0
- bump rust-bin to 1.19.0
- fix mips64 target name in rustc

v5 -> v6:

- bump rust to 1.18.0
- bump rust-bootstrap to 1.17.0
- bump rust-bin to 1.18.0

v4 -> v5:

- add rustc virtual package
- add rust-bin, provider for rustc
- rework rust to be a provider for rustc
- rework some commit messages

v3 -> v4:

- bump rust to 1.16.0
- bump rust-bootstrap to 1.15.1
- add cargo-bootstrap
- use built-in target specifications
- drop external Python script to generate target specifications
- enable support for PowerPC
- expose host variant in menuconfig

v2 -> v3:

- bump rust to 1.10.0
- rework and bump rust-bootstrap to 1.9.0
- host-rust requires at least GCC 4.7 because of LLVM (suggested by R. Naour)
- rust requires a glibc-based cross-compiler
- rust requires GCC 5.x or above for Aarch64

v1 -> v2:

- bump rust to version 1.9.0.
- drop patch for bzip2 support in host-python.
- add package for jemalloc.
- add dependency on host being a x86 machine.
- add dependency on toolchain.
- use dedicated package to provide bootstrapping binary: rust-bootstrap.
- let ./configure find out host/build on its own.
- remove entry from configuration menu.

Eric Le Bihan (10):
rustc: new virtual package
rust-bin: new package
cargo-bin: new package
rust: new package
libssh2: add host variant
libhttpparser: add host variant
libcurl: add host variant
cargo: new package
docs/manual: document cargo-based packages
support/testing: add tests for Rust

 DEVELOPERS                                 |   4 ++
 docs/manual/adding-packages-cargo.txt      | 110 +++++++++++++++++++++++++++++
 docs/manual/adding-packages.txt            |   2 +
 package/Config.in.host                     |   2 +
 package/cargo-bin/cargo-bin.hash           |   8 +++
 package/cargo-bin/cargo-bin.mk             |  13 ++++
 package/cargo/Config.in.host               |   8 +++
 package/cargo/cargo.hash                   |   8 +++
 package/cargo/cargo.mk                     |  91 ++++++++++++++++++++++++
 package/cargo/config.in                    |   2 +
 package/libcurl/libcurl.mk                 |  14 ++++
 package/libhttpparser/libhttpparser.mk     |   9 +++
 package/libssh2/libssh2.mk                 |   6 ++
 package/rust-bin/rust-bin.hash             |  33 +++++++++
 package/rust-bin/rust-bin.mk               |  61 ++++++++++++++++
 package/rust/rust.hash                     |   5 ++
 package/rust/rust.mk                       |  79 +++++++++++++++++++++
 package/rustc/Config.in.host               |  79 +++++++++++++++++++++
 package/rustc/rustc.mk                     |  20 ++++++
 support/testing/tests/package/test_rust.py | 107 ++++++++++++++++++++++++++++
 20 files changed, 661 insertions(+)
 create mode 100644 docs/manual/adding-packages-cargo.txt
 create mode 100644 package/cargo-bin/cargo-bin.hash
 create mode 100644 package/cargo-bin/cargo-bin.mk
 create mode 100644 package/cargo/Config.in.host
 create mode 100644 package/cargo/cargo.hash
 create mode 100644 package/cargo/cargo.mk
 create mode 100644 package/cargo/config.in
 create mode 100644 package/rust-bin/rust-bin.hash
 create mode 100644 package/rust-bin/rust-bin.mk
 create mode 100644 package/rust/rust.hash
 create mode 100644 package/rust/rust.mk
 create mode 100644 package/rustc/Config.in.host
 create mode 100644 package/rustc/rustc.mk
 create mode 100644 support/testing/tests/package/test_rust.py

--
2.14.3

#1 lore raw

PATCH v10 1/10 rustc: new virtual package

The compiler for the Rust programming language is called rustc.

There is only one reference implementation for it, based on LLVM, from the Rust project [1]. It can generate code for various architectures so it can be labeled as a cross-compiler. But, as for GCC, building it from source takes time.

So it would be sensible to have at least one package which provides it as a pre-built version, fetched from the upstream project. Later another package can be added, to build it from source code.

In addition to the compiler, the standard library for the host and/or the target should also be fetched/built.

So, add a virtual package named rustc to enable support for multiple providers.

Currently, only the host variant will be available to allow the user to cross-compile Rust programs for the target.

[1] http://rust-lang.org

---
 package/Config.in.host       |  1 +
 package/rustc/Config.in.host | 31 +++++++++++++++++++++++++++++++
 package/rustc/rustc.mk       | 20 ++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 package/rustc/Config.in.host
 create mode 100644 package/rustc/rustc.mk
package/Config.in.host +1 -0
index dd6415bba5..2f20dd0e48 100644
@@ -46,6 +46,7 @@ menu "Host utilities"
 	source "package/qemu/Config.in.host"
 	source "package/raspberrypi-usbboot/Config.in.host"
 	source "package/rauc/Config.in.host"
+	source "package/rustc/Config.in.host"
 	source "package/s6-rc/Config.in.host"
 	source "package/sam-ba/Config.in.host"
 	source "package/squashfs/Config.in.host"
package/rustc/Config.in.host new file +31 -0
new file mode 100644
index 0000000000..a49f635d65
@@ -0,0 +1,31 @@
+config BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
+	bool
+	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
+	# The pre-built Rust standard library is only available for the
+	# following architectures/ABIs, and is built against glibc.
+	default y if BR2_i386
+	default y if BR2_x86_64
+	default y if BR2_aarch64
+	default y if BR2_arm && !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5
+	default y if BR2_powerpc || BR2_powerpc64
+	default y if (BR2_mips || BR2_mipsel) && !BR2_MIPS_CPU_MIPS32R6
+	default y if (BR2_mips64 || BR2_mips64el) && !BR2_MIPS_CPU_MIPS64R6 \
+		&& BR2_MIPS_NABI64
+	depends on BR2_TOOLCHAIN_USES_GLIBC
+
+config BR2_PACKAGE_HOST_RUSTC_ARCH
+	string
+	default "armv7"  if BR2_ARM_CPU_ARMV7A
+	default BR2_ARCH if !BR2_ARM_CPU_ARMV7A
+
+config BR2_PACKAGE_HOST_RUSTC_ABI
+	string
+	default "eabi"   if BR2_ARM_EABI
+	default "eabihf" if BR2_ARM_EABIHF
+	default "abi64"  if BR2_MIPS_NABI64
+
+config BR2_PACKAGE_HAS_HOST_RUSTC
+	bool
+
+config BR2_PACKAGE_PROVIDES_HOST_RUSTC
+	string
package/rustc/rustc.mk new file +20 -0
new file mode 100644
index 0000000000..7a951c0cfd
@@ -0,0 +1,20 @@
+################################################################################
+#
+# rustc
+#
+################################################################################
+
+RUSTC_ARCH = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ARCH))
+RUSTC_ABI = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ABI))
+
+RUST_TARGET_NAME = $(RUSTC_ARCH)-unknown-linux-gnu$(RUSTC_ABI)
+
+ifeq ($(HOSTARCH),x86)
+RUSTC_HOST_ARCH = i686
+else
+RUSTC_HOST_ARCH = $(HOSTARCH)
+endif
+
+RUST_HOST_NAME = $(RUSTC_HOST_ARCH)-unknown-linux-gnu
+
+$(eval $(host-virtual-package))
Signature · 1 line
2.14.3
#2 lore raw

PATCH v10 1/10 rustc: new virtual package

Hello,

+Peter, Arnout, Ricardo in Cc.

Quoted 14 lines · Eric Le Bihan
package/rustc/rustc.mk new file +8 -0
new file mode 100644
index 0000000000..7a951c0cfd
@@ -0,0 +1,20 @@
+################################################################################
+#
+# rustc
+#
+################################################################################
+
+RUSTC_ARCH = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ARCH))
+RUSTC_ABI = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ABI))

package/rustc/rustc.mk line 18

Quoted 10 lines
package/rustc/rustc.mk new file +10 -0
+
+RUST_TARGET_NAME = $(RUSTC_ARCH)-unknown-linux-gnu$(RUSTC_ABI)
+
+ifeq ($(HOSTARCH),x86)
+RUSTC_HOST_ARCH = i686
+else
+RUSTC_HOST_ARCH = $(HOSTARCH)
+endif
+
+RUST_HOST_NAME = $(RUSTC_HOST_ARCH)-unknown-linux-gnu

check-package is not happy with RUST_TARGET_NAME and RUST_HOST_NAME because they don't have a RUSTC_ prefix, even though they are defined in rustc.mk:

./package/rustc/rustc.mk:10: possible typo: RUST_TARGET_NAME -> *RUSTC* ./package/rustc/rustc.mk:18: possible typo: RUST_HOST_NAME -> *RUSTC*

Would renaming them to RUSTC_TARGET_NAME and RUSTC_HOST_NAME make sense ? Or do we need to keep RUST_TARGET_NAME/RUST_HOST_NAME and add an exception in check-package ?

Thanks for your feedback,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#3 lore raw

PATCH v10 1/10 rustc: new virtual package

Quoted 35 lines · Thomas Petazzoni

Hello,

+Peter, Arnout, Ricardo in Cc.

Quoted 14 lines · Eric Le Bihan
package/rustc/rustc.mk new file +8 -0
new file mode 100644
index 0000000000..7a951c0cfd
@@ -0,0 +1,20 @@
+################################################################################
+#
+# rustc
+#
+################################################################################
+
+RUSTC_ARCH = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ARCH))
+RUSTC_ABI = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ABI))

package/rustc/rustc.mk line 18

Quoted 10 lines
package/rustc/rustc.mk new file +10 -0
+
+RUST_TARGET_NAME = $(RUSTC_ARCH)-unknown-linux-gnu$(RUSTC_ABI)
+
+ifeq ($(HOSTARCH),x86)
+RUSTC_HOST_ARCH = i686
+else
+RUSTC_HOST_ARCH = $(HOSTARCH)
+endif
+
+RUST_HOST_NAME = $(RUSTC_HOST_ARCH)-unknown-linux-gnu

check-package is not happy with RUST_TARGET_NAME and RUST_HOST_NAME because they don't have a RUSTC_ prefix, even though they are defined in rustc.mk:

Quoted 6 lines

./package/rustc/rustc.mk:10: possible typo: RUST_TARGET_NAME -> *RUSTC* ./package/rustc/rustc.mk:18: possible typo: RUST_HOST_NAME -> *RUSTC*

Would renaming them to RUSTC_TARGET_NAME and RUSTC_HOST_NAME make sense ? Or do we need to keep RUST_TARGET_NAME/RUST_HOST_NAME and add an exception in check-package ?

I do not see any problems using RUSTC_{HOST,TARGET}_NAME: it still caries the same information as RUST_{HOST,TARGET}_NAME.

Regards,

--
ELB

#4 lore raw

PATCH v10 1/10 rustc: new virtual package

Hello,

Quoted 7 lines · Eric Le Bihan
Quoted 7 lines

check-package is not happy with RUST_TARGET_NAME and RUST_HOST_NAME because they don't have a RUSTC_ prefix, even though they are defined in rustc.mk:

./package/rustc/rustc.mk:10: possible typo: RUST_TARGET_NAME -> *RUSTC* ./package/rustc/rustc.mk:18: possible typo: RUST_HOST_NAME -> *RUSTC*

Quoted 6 lines
Quoted 3 lines

Would renaming them to RUSTC_TARGET_NAME and RUSTC_HOST_NAME make sense ? Or do we need to keep RUST_TARGET_NAME/RUST_HOST_NAME and add an exception in check-package ?

I do not see any problems using RUSTC_{HOST,TARGET}_NAME: it still caries the same information as RUST_{HOST,TARGET}_NAME.

Question is: are these host and target names "Rust" related, or "Rust compiler" related. If they are Rust related, the current RUST_ prefix makes more sense. If they are specific to the Rust compiler, then RUSTC_ would make more sense. If it isn't clear, then we can use RUSTC_ to avoid the problem :-)

If you are happy with RUSTC_, could you submit a patch against "master" that does the renaming ?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#5 lore raw

PATCH v10 1/10 rustc: new virtual package

Quoted 15 lines · Thomas Petazzoni

Hello,

Quoted 11 lines · Eric Le Bihan
Quoted 10 lines

check-package is not happy with RUST_TARGET_NAME and RUST_HOST_NAME because they don't have a RUSTC_ prefix, even though they are defined in rustc.mk:

./package/rustc/rustc.mk:10: possible typo: RUST_TARGET_NAME -> *RUSTC* ./package/rustc/rustc.mk:18: possible typo: RUST_HOST_NAME -> *RUSTC*

Would renaming them to RUSTC_TARGET_NAME and RUSTC_HOST_NAME make sense ? Or do we need to keep RUST_TARGET_NAME/RUST_HOST_NAME and add an exception in check-package ?

Quoted 8 lines
Quoted 2 lines

I do not see any problems using RUSTC_{HOST,TARGET}_NAME: it still caries the same information as RUST_{HOST,TARGET}_NAME.

Question is: are these host and target names "Rust" related, or "Rust compiler" related. If they are Rust related, the current RUST_ prefix makes more sense. If they are specific to the Rust compiler, then RUSTC_ would make more sense. If it isn't clear, then we can use RUSTC_ to avoid the problem :-)

As RUSTC_{HOST,TARGET}_NAME is passed to the Rust compiler by the --target option, it is "Rust compiler" related. So the renaming makes sense.

Quoted 2 lines

If you are happy with RUSTC_, could you submit a patch against "master" that does the renaming ?

Should I provide a global patch or a series of patches, one for each affected package?

Regards,

--
ELB

#6 lore raw

PATCH v10 2/10 rust-bin: new package

In reply to Eric Le Bihan

This package provides a pre-built version of rustc, the compiler for the Rust programming language, fetched from the upstream project.

A pre-built version of the standard library for the host as well as one for the chosen target are also fetched and installed.

Only the host variant is provided to allow the user to cross-compile Rust programs and run them on the target.

This package could also be used to provide a bootstrap compiler when building Rust from source. So, in order to add it as a build dependency, the compiler and standard libraries are only installed in $(HOST_DIR) if the package is explicitly selected.

The menuconfig entry for rustc is also updated to expose this provider.

---
 DEVELOPERS                     |  1 +
 package/rust-bin/rust-bin.hash | 33 +++++++++++++++++++++++
 package/rust-bin/rust-bin.mk   | 61 ++++++++++++++++++++++++++++++++++++++++++
 package/rustc/Config.in.host   | 29 ++++++++++++++++++++
 4 files changed, 124 insertions(+)
 create mode 100644 package/rust-bin/rust-bin.hash
 create mode 100644 package/rust-bin/rust-bin.mk
DEVELOPERS +1 -0
index 4f2c84758e..7e04f872ac 100644
@@ -548,6 +548,7 @@ F:	package/hicolor-icon-theme/
 F:	package/jemalloc/
 F:	package/meson/
 F:	package/ninja/
+F:	package/rust-bin/
 F:	package/s6/
 F:	package/s6-dns/
 F:	package/s6-linux-init/
package/rust-bin/rust-bin.hash new file +33 -0
new file mode 100644
index 0000000000..5b34a6aa0c
@@ -0,0 +1,33 @@
+# From https://static.rust-lang.org/dist/rustc-1.23.0-i686-unknown-linux-gnu.tar.xz.sha256
+sha256 243de2826b2d545b8428414a3f7e86ce5e86163ec927a374958052a047b55e69  rustc-1.23.0-i686-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rustc-1.23.0-x86_64-unknown-linux-gnu.tar.xz.sha256
+sha256 d72674a683dcc8a07ad72d6ae08b96a7dfc72cf08433e2ae69c0f8a2b9c79c17  rustc-1.23.0-x86_64-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-aarch64-unknown-linux-gnu.tar.xz.sha256
+sha256 0d9c976c46a277ef860ce5766387ea8e40f84657e5f9962cba91be62a00ca345  rust-std-1.23.0-aarch64-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-arm-unknown-linux-gnueabi.tar.xz.sha256
+sha256 3d7ce58f6d2bbf6faf91049893e96611a172b0af02d98190e36a49e8b0f974ee  rust-std-1.23.0-arm-unknown-linux-gnueabi.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-arm-unknown-linux-gnueabihf.tar.xz.sha256
+sha256 0a2a43668c2ddc2516e85e1c097d2672acaf61541d2b70f40daba548b3ccbee1  rust-std-1.23.0-arm-unknown-linux-gnueabihf.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-armv7-unknown-linux-gnueabihf.tar.xz.sha256
+sha256 b2f7f4e2e31d86302e929d0435b6f40778c22fc9306f0850b0edc4738ff2634e  rust-std-1.23.0-armv7-unknown-linux-gnueabihf.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-i686-unknown-linux-gnu.tar.xz.sha256
+sha256 f9659f844ccd2e25e9f01a49fb7adf0ce26cbbec7a4df7081dd2d0929a86b2d3  rust-std-1.23.0-i686-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-mips-unknown-linux-gnu.tar.xz.sha256
+sha256 8324d9c1eacba0de31fff29841d0f0567261489ee46a270e30be929095bfe19a  rust-std-1.23.0-mips-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-mips64-unknown-linux-gnuabi64.tar.xz.sha256
+sha256 521f70f3346ff8e28e33350fd5ad9bbba7dfc9038389f3965bcfa2f1d1a498a5  rust-std-1.23.0-mips64-unknown-linux-gnuabi64.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-mips64el-unknown-linux-gnuabi64.tar.xz.sha256
+sha256 d08f5792bd0d4f5d3d81a4ec1b3a2b36e7c389de2ecf2e777e390461ff015d08  rust-std-1.23.0-mips64el-unknown-linux-gnuabi64.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-mipsel-unknown-linux-gnu.tar.xz.sha256
+sha256 77291fff357b9e1764a4d7975bdbecdb37aeb0d37d85ccb68f7d785f4da1a056  rust-std-1.23.0-mipsel-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-powerpc-unknown-linux-gnu.tar.xz.sha256
+sha256 d1b862d32c4921058ff4ea5b7fead3b2954b5f0f036603b1c58a600e602d1f25  rust-std-1.23.0-powerpc-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-powerpc64-unknown-linux-gnu.tar.xz.sha256
+sha256 e03bf7907914c88d2f19e719f07641b1b1ffbb65cf9daae8b028f4ab4619b4ff  rust-std-1.23.0-powerpc64-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-powerpc64le-unknown-linux-gnu.tar.xz.sha256
+sha256 674f74245341119409e203109c22d432d0ed3312a6ff4d3b03cab251e61cc53a  rust-std-1.23.0-powerpc64le-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-x86_64-unknown-linux-gnu.tar.xz.sha256
+sha256 0d87225dd081c7ea5002fdeb21983d23bc52fa37d23c88d5c97b2c44660f8af9  rust-std-1.23.0-x86_64-unknown-linux-gnu.tar.xz
+# Locally generated
+sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2  LICENSE-APACHE
+sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3  LICENSE-MIT
package/rust-bin/rust-bin.mk new file +61 -0

61 lines not on this page · raw message

package/rustc/Config.in.host +29 -0
index a49f635d65..66c50c4579 100644
@@ -24,8 +24,37 @@ config BR2_PACKAGE_HOST_RUSTC_ABI
 	default "eabihf" if BR2_ARM_EABIHF
 	default "abi64"  if BR2_MIPS_NABI64
 
+config BR2_PACKAGE_HOST_RUSTC
+	bool "host rustc"
+	depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
+	help
+	  Compiler for the Rust language
+
+	  http://www.rust-lang.org
+
+if BR2_PACKAGE_HOST_RUSTC
+
+choice
+	prompt "Rust compiler variant"
+	default BR2_PACKAGE_HOST_RUST_BIN
+	help
+	  Select a Rust compiler
+
+config BR2_PACKAGE_HOST_RUST_BIN
+	bool "host rust (pre-built)"
+	select BR2_PACKAGE_HAS_HOST_RUSTC
+	help
+	  This package will install pre-built versions of the compiler
+	  for the host and the Rust standard library for the target.
+
+endchoice
+
 config BR2_PACKAGE_HAS_HOST_RUSTC
 	bool
 
 config BR2_PACKAGE_PROVIDES_HOST_RUSTC
 	string
+	default "host-rust-bin" if BR2_PACKAGE_HOST_RUST_BIN
+
+endif
+
Signature · 1 line
2.14.3
#7 lore raw

PATCH v10 3/10 cargo-bin: new package

In reply to Eric Le Bihan

This new package fetches a binary version of Cargo, suitable to bootstrap the host variants of the Rust compiler and Cargo, the package manager.

---
 DEVELOPERS                       |  1 +
 package/cargo-bin/cargo-bin.hash |  8 ++++++++
 package/cargo-bin/cargo-bin.mk   | 13 +++++++++++++
 3 files changed, 22 insertions(+)
 create mode 100644 package/cargo-bin/cargo-bin.hash
 create mode 100644 package/cargo-bin/cargo-bin.mk
DEVELOPERS +1 -0
index 7e04f872ac..70ca569feb 100644
@@ -541,6 +541,7 @@ F:	package/xxhash/
 N:	Eric Le Bihan <[email protected]>
 F:	docs/manual/adding-packages-meson.txt
 F:	package/adwaita-icon-theme/
+F:	package/cargo-bin/
 F:	package/darkhttpd/
 F:	package/eudev/
 F:	package/execline/
package/cargo-bin/cargo-bin.hash new file +8 -0
new file mode 100644
index 0000000000..ea121547b4
@@ -0,0 +1,8 @@
+# From https://static.rust-lang.org/dist/cargo-0.24.0-i686-unknown-linux-gnu.tar.xz.sha256
+sha256 6ffc847e0ee2a1273223ce500f7b212d051e99a6d234e34585d0c55e21a963ea  cargo-0.24.0-i686-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/cargo-0.24.0-x86_64-unknown-linux-gnu.tar.xz.sha256
+sha256 93b953c8c7a2088aef952de8dccd7f6ccf9b21bf94b735d3909961ffe831da8c  cargo-0.24.0-x86_64-unknown-linux-gnu.tar.xz
+# Locally generated
+sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2  LICENSE-APACHE
+sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3  LICENSE-MIT
+sha256 8bd89f9222dc80292f4107347103b693ac66f3a083371f0629ccf42338abe880  LICENSE-THIRD-PARTY
package/cargo-bin/cargo-bin.mk new file +13 -0
new file mode 100644
index 0000000000..0f235748ff
@@ -0,0 +1,13 @@
+################################################################################
+#
+# cargo-bin
+#
+################################################################################
+
+CARGO_BIN_VERSION = 0.24.0
+CARGO_BIN_SITE = https://static.rust-lang.org/dist
+CARGO_BIN_SOURCE = cargo-$(CARGO_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz
+CARGO_BIN_LICENSE = Apache-2.0 or MIT
+CARGO_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+
+$(eval $(host-generic-package))
Signature · 1 line
2.14.3
#8 lore raw

PATCH v10 4/10 rust: new package

In reply to Eric Le Bihan

This new package provides rustc, the compiler for the Rust programming language, built from source.

Currently, only the host variant is built.

The Rust compiler uses LLVM as its backend: a copy of LLVM source code is provided and CMake is used to build it. It is possible to use a pre-built external copy. When LLVM/clang will be available in Buildroot, it would be possible to benefit from this feature and thus decrease build time.

LLVM is configured to generate code for x86, ARM, PowerPC and MIPS architectures.

The Rust compiler uses Cargo as its build system and is written in Rust. Therefore this package depends on cargo-bin and rust-bin.

The internal build process is as follows:

1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler.
2. stage1 compiler builds the final Rust compiler (stage2 compiler) and the standard library for the host architecture.
3. the standard library for the target architecture is built.

The target architecture to support is given by the GNU/LLVM target triple. Rust supports some predefined targets [1]. As the build system expects the triple to be in the form of <arch>-unknown-<system> and Buildroot toolchain wrapper uses <arch>-buildroot-<system>, the package Makefile uses $(RUST_TARGET_NAME) defined in the rustc package and uses it instead of $(GNU_TARGET_NAME).

When compiling Rust code with this compiler, the generated program only depends on the target C library, as it is statically linked to the Rust standard library and any other code from Rust packages (a.k.a. "crates").

If the jemalloc package is selected, support for this memory allocator will be enabled in the target standard library.

The menuconfig entry for rustc is also updated to expose this provider.

[1] https://forge.rust-lang.org/platform-support.html

---
 DEVELOPERS                   |  1 +
 package/rust/rust.hash       |  5 +++
 package/rust/rust.mk         | 79 ++++++++++++++++++++++++++++++++++++++++++++
 package/rustc/Config.in.host | 19 +++++++++++
 4 files changed, 104 insertions(+)
 create mode 100644 package/rust/rust.hash
 create mode 100644 package/rust/rust.mk
DEVELOPERS +1 -0
index 70ca569feb..0e041d6f40 100644
@@ -550,6 +550,7 @@ F:	package/jemalloc/
 F:	package/meson/
 F:	package/ninja/
 F:	package/rust-bin/
+F:	package/rust/
 F:	package/s6/
 F:	package/s6-dns/
 F:	package/s6-linux-init/
package/rust/rust.hash new file +5 -0
new file mode 100644
index 0000000000..d6731b6dc2
@@ -0,0 +1,5 @@
+# From https://static.rust-lang.org/dist/rustc-1.23.0-src.tar.xz.sha256
+sha256 7196032371b50dd5582465b3bfa79ffd783b74f0711420d99b61b26c96fb3d80  rustc-1.23.0-src.tar.xz
+# Locally generated
+sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2  LICENSE-APACHE
+sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3  LICENSE-MIT
package/rust/rust.mk new file +79 -0

79 lines not on this page · raw message

package/rustc/Config.in.host +19 -0
index 66c50c4579..d93ff05209 100644
@@ -40,6 +40,24 @@ choice
 	help
 	  Select a Rust compiler
 
+config BR2_PACKAGE_HOST_RUST
+	bool "host rust"
+	depends on BR2_HOST_GCC_AT_LEAST_4_7 # required by LLVM
+	# triggers ICE on trunc_int_for_mode, at explow.c:56
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5 || !BR2_aarch64
+	select BR2_PACKAGE_HAS_HOST_RUSTC
+	help
+	  This package will build the compiler for the host as well as
+	  two flavors of the standard library: one for the host, another
+	  for the target. Both are installed in the host directory.
+
+comment "host-rust needs a toolchain w/ gcc >= 5"
+	depends on BR2_aarch64
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5
+
+comment "host-rust needs host gcc >= 4.7"
+	depends on !BR2_HOST_GCC_AT_LEAST_4_7
+
 config BR2_PACKAGE_HOST_RUST_BIN
 	bool "host rust (pre-built)"
 	select BR2_PACKAGE_HAS_HOST_RUSTC
@@ -54,6 +72,7 @@ config BR2_PACKAGE_HAS_HOST_RUSTC
 
 config BR2_PACKAGE_PROVIDES_HOST_RUSTC
 	string
+	default "host-rust" if BR2_PACKAGE_HOST_RUST
 	default "host-rust-bin" if BR2_PACKAGE_HOST_RUST_BIN
 
 endif
Signature · 1 line
2.14.3
#9 lore raw

PATCH v10 5/10 libssh2: add host variant

In reply to Eric Le Bihan

Allow build of host variant of libssh2, which depends on host-openssl.

---
 package/libssh2/libssh2.mk | 6 ++++++
 1 file changed, 6 insertions(+)
package/libssh2/libssh2.mk +6 -0
index 18e772c722..c5b0bd855e 100644
@@ -40,4 +40,10 @@ else
 LIBSSH2_CONF_OPTS += --without-libz
 endif
 
+HOST_LIBSSH2_DEPENDENCIES += host-openssl
+HOST_LIBSSH2_CONF_OPTS += --with-openssl \
+	--with-libssl-prefix=$(HOST_DIR)/usr \
+	--without-libgcrypt
+
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))
Signature · 1 line
2.14.3
#10 lore raw

PATCH v10 6/10 libhttpparser: add host variant

In reply to Eric Le Bihan

Allow build of host variant of libhttpparser.

---
 package/libhttpparser/libhttpparser.mk | 9 +++++++++
 1 file changed, 9 insertions(+)
package/libhttpparser/libhttpparser.mk +9 -0
index 8ff0413322..1df26017e7 100644
@@ -23,4 +23,13 @@ define LIBHTTPPARSER_INSTALL_TARGET_CMDS
 	$(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) PREFIX=$(TARGET_DIR)/usr install
 endef
 
+define HOST_LIBHTTPPARSER_BUILD_CMDS
+	$(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D) library package
+endef
+
+define HOST_LIBHTTPPARSER_INSTALL_CMDS
+	$(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D) PREFIX=$(HOST_DIR)/usr install
+endef
+
 $(eval $(generic-package))
+$(eval $(host-generic-package))
Signature · 1 line
2.14.3
#11 lore raw

PATCH v10 7/10 libcurl: add host variant

In reply to Eric Le Bihan
---
 package/libcurl/libcurl.mk | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
package/libcurl/libcurl.mk +14 -0
index a1d2aa7a60..39ed3e4da5 100644
@@ -88,4 +88,18 @@ endef
 LIBCURL_POST_INSTALL_TARGET_HOOKS += LIBCURL_TARGET_CLEANUP
 endif
 
+HOST_LIBCURL_DEPENDENCIES = host-openssl
+HOST_LIBCURL_CONF_OPTS = \
+	--disable-manual \
+	--disable-ntlm-wb \
+	--disable-curldebug \
+	--with-ssl \
+	--without-gnutls \
+	--without-mbedtls \
+	--without-polarssl \
+	--without-nss
+
+HOST_LIBCURL_POST_PATCH_HOOKS += LIBCURL_FIX_DOT_PC
+
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))
Signature · 1 line
2.14.3
#12 lore raw

PATCH v10 8/10 cargo: new package

In reply to Eric Le Bihan

This new package provides Cargo, the Rust official package manager. Cargo is written in Rust and uses Cargo as its build system. It also depends on other Rust packages.

Normally, a previously installed version of Cargo would be used to:

1. Fetch the dependencies.
2. Build the new version of Cargo, using the available Rust compiler.

But the fetching step prevents offline builds. So instead two features of Cargo are leveraged: vendoring [1] and local registry.

First, a tarball of the build dependencies generated using cargo vendor is fetched along with Cargo source code.

Then, the build process is as follows:

1. The tarball of the build dependencies is uncompressed in a local registry.
2. A snapshot of Cargo, provided by cargo-bin, builds the final version of Cargo.
3. A configuration file telling Cargo how to cross-compile programs for the target is generated and installed.

Currently, only the host variant is provided.

[1] https://github.com/alexcrichton/cargo-vendor

---
 DEVELOPERS                   |  1 +
 package/Config.in.host       |  1 +
 package/cargo/Config.in.host |  8 ++++
 package/cargo/cargo.hash     |  8 ++++
 package/cargo/cargo.mk       | 91 ++++++++++++++++++++++++++++++++++++++++++++
 package/cargo/config.in      |  2 +
 6 files changed, 111 insertions(+)
 create mode 100644 package/cargo/Config.in.host
 create mode 100644 package/cargo/cargo.hash
 create mode 100644 package/cargo/cargo.mk
 create mode 100644 package/cargo/config.in
DEVELOPERS +1 -0
index 0e041d6f40..c524cb6ac5 100644
@@ -542,6 +542,7 @@ N:	Eric Le Bihan <[email protected]>
 F:	docs/manual/adding-packages-meson.txt
 F:	package/adwaita-icon-theme/
 F:	package/cargo-bin/
+F:	package/cargo/
 F:	package/darkhttpd/
 F:	package/eudev/
 F:	package/execline/
package/Config.in.host +1 -0
index 2f20dd0e48..199a8e9856 100644
@@ -2,6 +2,7 @@ menu "Host utilities"
 
 	source "package/aespipe/Config.in.host"
 	source "package/android-tools/Config.in.host"
+	source "package/cargo/Config.in.host"
 	source "package/cbootimage/Config.in.host"
 	source "package/checkpolicy/Config.in.host"
 	source "package/cmake/Config.in.host"
package/cargo/Config.in.host new file +8 -0
new file mode 100644
index 0000000000..0f1ca305c6
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_HOST_CARGO
+	bool "host cargo"
+	depends on BR2_PACKAGE_HAS_HOST_RUSTC
+	help
+	  Cargo is the package manager for the Rust programming
+	  language.
+
+	  https://crates.io/
package/cargo/cargo.hash new file +8 -0
new file mode 100644
index 0000000000..f0990484d9
@@ -0,0 +1,8 @@
+# Locally generated
+sha256 a9d4291254a1d622d3c3cb942aaa56ab4059b8d04915c3af234f0362f14722e8  cargo-0.24.0.tar.gz
+sha256 dc7240d60a869fa24a68c8734fb7c810c27cca0a6dad52df6279865e4e8e7fae  rust-installer-4f994850808a572e2cc8d43f968893c8e942e9bf.tar.gz
+sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2  LICENSE-APACHE
+sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3  LICENSE-MIT
+sha256 8bd89f9222dc80292f4107347103b693ac66f3a083371f0629ccf42338abe880  LICENSE-THIRD-PARTY
+# From http://pkgs.fedoraproject.org/repo/pkgs/cargo/cargo-0.23.0-vendor.tar.xz/sha512
+sha512 60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21  cargo-0.24.0-vendor.tar.xz
package/cargo/cargo.mk new file +91 -0

91 lines not on this page · raw message

package/cargo/config.in new file +2 -0
new file mode 100644
index 0000000000..cc048c71c4
@@ -0,0 +1,2 @@
+[target. at RUST_TARGET_NAME@]
+linker = "@CROSS_PREFIX at gcc"
Signature · 1 line
2.14.3
#13 lore raw

PATCH v10 8/10 cargo: new package

Quoted 32 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Eric" == Eric Le Bihan <[email protected]> writes:

This new package provides Cargo, the Rust official package manager. Cargo is written in Rust and uses Cargo as its build system. It also depends on other Rust packages.

Normally, a previously installed version of Cargo would be used to:

1. Fetch the dependencies.
2. Build the new version of Cargo, using the available Rust compiler.

But the fetching step prevents offline builds. So instead two features of Cargo are leveraged: vendoring [1] and local registry.

First, a tarball of the build dependencies generated using cargo vendor is fetched along with Cargo source code.

Then, the build process is as follows:

1. The tarball of the build dependencies is uncompressed in a local registry.
2. A snapshot of Cargo, provided by cargo-bin, builds the final version of Cargo.
3. A configuration file telling Cargo how to cross-compile programs for the target is generated and installed.

Currently, only the host variant is provided.

[1] https://github.com/alexcrichton/cargo-vendor

+++ b/package/cargo/cargo.hash

package/cargo/cargo.hash line 7

Quoted 7 lines
package/cargo/cargo.hash new file +7 -0
@@ -0,0 +1,8 @@
+# Locally generated
+sha256 a9d4291254a1d622d3c3cb942aaa56ab4059b8d04915c3af234f0362f14722e8  cargo-0.24.0.tar.gz
+sha256 dc7240d60a869fa24a68c8734fb7c810c27cca0a6dad52df6279865e4e8e7fae  rust-installer-4f994850808a572e2cc8d43f968893c8e942e9bf.tar.gz
+sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2  LICENSE-APACHE
+sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3  LICENSE-MIT
+sha256 8bd89f9222dc80292f4107347103b693ac66f3a083371f0629ccf42338abe880  LICENSE-THIRD-PARTY
+# From http://pkgs.fedoraproject.org/repo/pkgs/cargo/cargo-0.23.0-vendor.tar.xz/sha512

That should probably be 0.24.0?

package/cargo/cargo.mk line 13

Quoted 7 lines
package/cargo/cargo.mk new file +7 -0
+CARGO_VERSION = 0.24.0
+CARGO_SITE = $(call github,rust-lang,cargo,$(CARGO_VERSION))
+CARGO_LICENSE = Apache-2.0 or MIT
+CARGO_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+
+CARGO_DEPS_SHA512 = 60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21
+CARGO_DEPS_SITE = http://pkgs.fedoraproject.org/repo/pkgs/cargo/$(CARGO_DEPS_SOURCE)/sha512/$(CARGO_DEPS_SHA512)

Is that the official location for this?

pkgs.fedoraproject.org is failing for me at the moment :/

--2018-02-05 11:25:50-- http://pkgs.fedoraproject.org/repo/pkgs/cargo/cargo-0.24.0-vendor.tar.xz/sha512/60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21/cargo-0.24.0-vendor.tar.xz
Resolving pkgs.fedoraproject.org (pkgs.fedoraproject.org)... 209.132.181.4
Connecting to pkgs.fedoraproject.org (pkgs.fedoraproject.org)|209.132.181.4|:80... failed: No route to host.

Otherwise the series looks good to me and I would like to add it for 2018.02.

Signature · 1 line
Bye, Peter Korsgaard
#14 lore raw

PATCH v10 8/10 cargo: new package

Eric, Peter,

Quoted 2 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Eric" == Eric Le Bihan <[email protected]> writes:

[snip]

Quoted 6 lines

package/cargo/cargo.mk line 13

Quoted 2 lines
package/cargo/cargo.mk new file +2 -0
+CARGO_DEPS_SHA512 = 60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21
+CARGO_DEPS_SITE = http://pkgs.fedoraproject.org/repo/pkgs/cargo/$(CARGO_DEPS_SOURCE)/sha512/$(CARGO_DEPS_SHA512)

Is that the official location for this?

pkgs.fedoraproject.org is failing for me at the moment :/

I hopped into #fedora-admin and was told that pkgs was deprecated last year, and due to some DoS mitigation was taken offline last week (I didn't press if it was permanent).

In either case, it seems like this should using src.fedoraproject.org as that is the permanent solution given to me.

Thanks,

Sam Voss

#15 lore raw

PATCH v10 8/10 cargo: new package

In reply to Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Peter" == Peter Korsgaard <[email protected]> writes:

Hi,

Quoted 8 lines
Quoted 4 lines

+CARGO_DEPS_SHA512 = 60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21 +CARGO_DEPS_SITE =
http://pkgs.fedoraproject.org/repo/pkgs/cargo/$(CARGO_DEPS_SOURCE)/sha512/$(CARGO_DEPS_SHA512)

Is that the official location for this?

pkgs.fedoraproject.org is failing for me at the moment :/

Committed after changing to src.fedoraproject.org, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#16 lore raw

PATCH v10 9/10 docs/manual: document cargo-based packages

In reply to Eric Le Bihan

Add instructions for adding a package which uses Cargo as build system.

---
 docs/manual/adding-packages-cargo.txt | 110 ++++++++++++++++++++++++++++++++++
 docs/manual/adding-packages.txt       |   2 +
 2 files changed, 112 insertions(+)
 create mode 100644 docs/manual/adding-packages-cargo.txt
docs/manual/adding-packages-cargo.txt new file +110 -0
new file mode 100644
index 0000000000..8de7c97cb9
@@ -0,0 +1,110 @@
+// -*- mode:doc; -*-
+// vim: set syntax=asciidoc:
+
+=== Integration of Cargo-based packages
+
+Cargo is the package manager for the Rust programming language. It allows the
+user to build programs or libraries written in Rust, but it also downloads and
+manages their dependencies, to ensure repeatable builds. Cargo packages are
+called "crates".
+
+[[cargo-package-tutorial]]
+
+==== Cargo-based package's +Config.in+ file
+
+The +Config.in+ file of Cargo-based package 'foo' should contain:
+
+---------------------------
+01: config BR2_PACKAGE_FOO
+02: 	bool "foo"
+03: 	depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
+04: 	select BR2_PACKAGE_HOST_CARGO
+05:   help
+06:     This is a comment that explains what foo is.
+07:
+08:  	  http://foosoftware.org/foo/
+---------------------------
+
+==== Cargo-based package's +.mk+ file
+
+Buildroot does not (yet) provide a dedicated package infrastructure for
+Cargo-based packages. So, we will explain how to write a +.mk+ file for such a
+package. Let's start with an example:
+
+------------------------------
+01: ################################################################################
+02: #
+03: # foo
+04: #
+05: ################################################################################
+06:
+07: FOO_VERSION = 1.0
+08: FOO_SOURCE = foo-$(FOO_VERSION).tar.gz
+09: FOO_SITE = http://www.foosoftware.org/download
+10: FOO_LICENSE = GPLv3+
+11: FOO_LICENSE_FILES = COPYING
+12:
+13: FOO_DEPENDENCIES = host-cargo
+14:
+15: FOO_CARGO_ENV = CARGO_HOME=$(HOST_DIR)/share/cargo
+16: FOO_CARGO_MODE = $(if $(BR2_ENABLE_DEBUG),debug,release)
+17:
+18: FOO_BIN_DIR = target/$(RUST_TARGET_NAME)/$(FOO_CARGO_MODE)
+19:
+20: FOO_CARGO_OPTS = \
+21:   --$(FOO_CARGO_MODE) \
+22: 	--target=$(RUST_TARGET_NAME) \
+23: 	--manifest-path=$(@D)/Cargo.toml
+24:
+25: define FOO_BUILD_CMDS
+26: 	$(TARGET_MAKE_ENV) $(FOO_CARGO_ENV) \
+27: 		cargo build $(FOO_CARGO_OPTS)
+28: endef
+29:
+30: define FOO_INSTALL_TARGET_CMDS
+31: 	$(INSTALL) -D -m 0755 $(@D)/$(FOO_BIN_DIR)/foo \
+32: 		$(TARGET_DIR)/usr/bin/foo
+33: endef
+34:
+35: $(eval $(generic-package))
+--------------------------------
+
+The Makefile starts with the definition of the standard variables for package
+declaration (lines 7 to 11).
+
+As seen in line 35, it is based on the
+xref:generic-package-tutorial[+generic-package+ infrastructure]. So, it defines
+the variables required by this particular infrastructure, where Cargo is
+invoked:
+
+* +FOO_BUILD_CMDS+: Cargo is invoked to perform the build. The options required
+  to configure the cross-compilation of the package are passed via
+  +FOO_CONF_OPTS+.
+
+* +FOO_INSTALL_TARGET_CMDS+: The binary executable generated is installed on
+  the target.
+
+In order to have Cargo available for the build, +FOO_DEPENDENCIES+ needs to
+contain +host-cargo+.
+
+To sum it up, to add a new Cargo-based package, the Makefile example can be
+copied verbatim then edited to replace all occurences of +FOO+ with the
+uppercase name of the new package and update the values of the standard
+variables.
+
+==== About Dependencies Management
+
+A crate can depend on other libraries from crates.io or git repositories, listed
+in its Cargo.toml file. Before starting a build, Cargo usually downloads
+automatically them. This step can also be performed independently, via the
++cargo fetch+ command.
+
+Cargo maintains a local cache of the registry index and of git checkouts of the
+crates, whose location is given by +$CARGO_HOME+. As seen in the package
+Makefile example at line 15, this environment variable is set to
++$(HOST_DIR)/share/cargo+.
+
+This dependency download mechanism is not convenient when performing an offline
+build, as Cargo will fail to fetch the dependencies. In that case, it is advised
+to generate a tarball of the dependencies using the +cargo vendor+ and add it to
++FOO_EXTRA_DOWNLOADS+.
docs/manual/adding-packages.txt +2 -0
index e542124cf9..e8d40daee4 100644
@@ -36,6 +36,8 @@ include::adding-packages-waf.txt[]
 
 include::adding-packages-meson.txt[]
 
+include::adding-packages-cargo.txt[]
+
 include::adding-packages-kernel-module.txt[]
 
 include::adding-packages-asciidoc.txt[]
Signature · 1 line
2.14.3
#17 lore raw

PATCH v10 9/10 docs/manual: document cargo-based packages

Quoted 29 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Eric" == Eric Le Bihan <[email protected]> writes:

Add instructions for adding a package which uses Cargo as build system.

---
 docs/manual/adding-packages-cargo.txt | 110 ++++++++++++++++++++++++++++++++++
 docs/manual/adding-packages.txt       |   2 +
 2 files changed, 112 insertions(+)
 create mode 100644 docs/manual/adding-packages-cargo.txt
docs/manual/adding-packages-cargo.txt new file +13 -0
new file mode 100644
index 0000000000..8de7c97cb9
@@ -0,0 +1,110 @@
+// -*- mode:doc; -*-
+// vim: set syntax=asciidoc:
+
+=== Integration of Cargo-based packages
+
+Cargo is the package manager for the Rust programming language. It allows the
+user to build programs or libraries written in Rust, but it also downloads and
+manages their dependencies, to ensure repeatable builds. Cargo packages are
+called "crates".
+
+[[cargo-package-tutorial]]
+
+==== Cargo-based package's +Config.in+ file

docs/manual/adding-packages-cargo.txt line 23

Quoted 10 lines
docs/manual/adding-packages-cargo.txt new file +10 -0
+
+The +Config.in+ file of Cargo-based package 'foo' should contain:
+
+---------------------------
+01: config BR2_PACKAGE_FOO
+02: 	bool "foo"
+03: 	depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
+04: 	select BR2_PACKAGE_HOST_CARGO
+05:   help
+06:     This is a comment that explains what foo is.

The indentation here is wrong. It should be <tab>help and <tab><space><space>This is a comment..

Signature · 1 line
Bye, Peter Korsgaard
#18 lore raw

PATCH v10 10/10 support/testing: add tests for Rust

In reply to Eric Le Bihan

To test the support for the Rust language, the following tests are added:

- building Rust compiler and Cargo from source.
- installing a pre-built Rust compiler and building Cargo from source.

For each test, a Rust test program is built and installed in the root file system of a ARM vexpress QEMU system. The test is declared OK if the program can be run properly from the test system.

---
 support/testing/tests/package/test_rust.py | 107 +++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)
 create mode 100644 support/testing/tests/package/test_rust.py
support/testing/tests/package/test_rust.py new file +107 -0
new file mode 100644
index 0000000000..8035f8b83a
@@ -0,0 +1,107 @@
+import os
+import tempfile
+import subprocess
+import shutil
+
+import infra.basetest
+
+
+class TestRustBase(infra.basetest.BRTest):
+
+    target = 'armv7-unknown-linux-gnueabihf'
+    crate = 'hello-world'
+
+    def login(self):
+        img = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv7",
+                           kernel="builtin",
+                           options=["-initrd", img])
+        self.emulator.login()
+
+    def build_test_prog(self):
+        hostdir = os.path.join(self.builddir, 'host')
+        env = os.environ.copy()
+        env["PATH"] = "{}:".format(os.path.join(hostdir, 'bin')) + env["PATH"]
+        env["CARGO_HOME"] = os.path.join(hostdir, 'usr', 'share', 'cargo')
+        env["RUST_TARGET_PATH"] = os.path.join(hostdir, 'etc', 'rustc')
+        cargo = os.path.join(hostdir, 'bin', 'cargo')
+        workdir = os.path.join(tempfile.mkdtemp(suffix='-br2-testing-rust'),
+                               self.crate)
+        manifest = os.path.join(workdir, 'Cargo.toml')
+        prog = os.path.join(workdir, 'target', self.target, 'debug', self.crate)
+
+        cmd = [cargo, 'init', '--bin', '--vcs', 'none', '-vv', workdir]
+        ret = subprocess.call(cmd,
+                              stdout=self.b.logfile,
+                              stderr=self.b.logfile,
+                              env=env)
+        if ret != 0:
+            raise SystemError("Cargo init failed")
+
+        cmd = [
+            cargo, 'build', '-vv', '--target', self.target,
+            '--manifest-path', manifest
+        ]
+        ret = subprocess.call(cmd,
+                              stdout=self.b.logfile,
+                              stderr=self.b.logfile,
+                              env=env)
+        if ret != 0:
+            raise SystemError("Cargo build failed")
+
+        shutil.copy(prog, os.path.join(self.builddir, 'target', 'usr', 'bin'))
+        self.b.build()
+        shutil.rmtree(workdir)
+
+    def test_run(self):
+        self.build_test_prog()
+        self.login()
+        _, exit_code = self.emulator.run(self.crate)
+        self.assertEqual(exit_code, 0)
+
+
+class TestRustBin(TestRustBase):
+    config = \
+             """
+             BR2_arm=y
+             BR2_cortex_a9=y
+             BR2_ARM_ENABLE_NEON=y
+             BR2_ARM_ENABLE_VFP=y
+             BR2_TOOLCHAIN_EXTERNAL=y
+             BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+             BR2_SYSTEM_DHCP="eth0"
+             BR2_LINUX_KERNEL=y
+             BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+             BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11.3"
+             BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
+             BR2_LINUX_KERNEL_DTS_SUPPORT=y
+             BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
+             BR2_TARGET_ROOTFS_CPIO=y
+             # BR2_TARGET_ROOTFS_TAR is not set
+             BR2_PACKAGE_HOST_CARGO=y
+             BR2_PACKAGE_HOST_RUSTC=y
+             """
+
+
+class TestRust(TestRustBase):
+    config = \
+             """
+             BR2_arm=y
+             BR2_cortex_a9=y
+             BR2_ARM_ENABLE_NEON=y
+             BR2_ARM_ENABLE_VFP=y
+             BR2_TOOLCHAIN_EXTERNAL=y
+             BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+             BR2_SYSTEM_DHCP="eth0"
+             BR2_LINUX_KERNEL=y
+             BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+             BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11.3"
+             BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
+             BR2_LINUX_KERNEL_DTS_SUPPORT=y
+             BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
+             BR2_TARGET_ROOTFS_CPIO=y
+             # BR2_TARGET_ROOTFS_TAR is not set
+             BR2_PACKAGE_HOST_CARGO=y
+             BR2_PACKAGE_HOST_RUSTC=y
+             BR2_PACKAGE_HOST_RUST=y
+             """
Signature · 1 line
2.14.3
#19 lore raw

v10 cover Add support for the Rust programming language

In reply to Eric Le Bihan
Quoted 95 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Eric" == Eric Le Bihan <[email protected]> writes:

This series adds support for the Rust programming language by adding the following packages:

- rustc: a virtual package for the Rust compiler.
- rust-bin: provides a pre-built version of rustc.
- cargo-bin: provides a pre-built version of Rust package manager.
- rust: builds rustc from source.
- cargo: builds Rust package manager from source.

Only the host variants are provided.

The rustc virtual package is inspired by the mysql one.

v9 -> v10:

- add test cases in support/testing
- add documentation about adding cargo-based packages
- bump cargo to 0.24.0
- bump rust to 1.23.0
- bump cargo-bin to 0.24.0
- bump rust-bin to 1.23.0
- clarify origin of some hashes
- reword some comments
- use $(BR2_CMAKE_HOST_DEPENDENCY) wherever needed
- move some options management from *.mk to Config.in

v8 -> v9:

- replace giant patch by post-extract hook
- drop rust-cargo virtual package
- explicitly enable SSL support in host-libcurl

v7 -> v8:

- replace cargo-bootstrap by cargo-bin
- drop rust-bootstrap and use rust-bin instead
- rust-bin and rust versions are the same
- cargo-bin and cargo versions are the same
- bump cargo to 0.23.0
- bump rust to 1.22.1
- add rust-cargo virtual package

v6 -> v7:

- add cargo 0.20.0
- bump rust to 1.19.0
- bump rust-bootstrap to 1.18.0
- bump cargo-bootstrap to 0.19.0
- bump rust-bin to 1.19.0
- fix mips64 target name in rustc

v5 -> v6:

- bump rust to 1.18.0
- bump rust-bootstrap to 1.17.0
- bump rust-bin to 1.18.0

v4 -> v5:

- add rustc virtual package
- add rust-bin, provider for rustc
- rework rust to be a provider for rustc
- rework some commit messages

v3 -> v4:

- bump rust to 1.16.0
- bump rust-bootstrap to 1.15.1
- add cargo-bootstrap
- use built-in target specifications
- drop external Python script to generate target specifications
- enable support for PowerPC
- expose host variant in menuconfig

v2 -> v3:

- bump rust to 1.10.0
- rework and bump rust-bootstrap to 1.9.0
- host-rust requires at least GCC 4.7 because of LLVM (suggested by R. Naour)
- rust requires a glibc-based cross-compiler
- rust requires GCC 5.x or above for Aarch64

v1 -> v2:

- bump rust to version 1.9.0.
- drop patch for bzip2 support in host-python.
- add package for jemalloc.
- add dependency on host being a x86 machine.
- add dependency on toolchain.
- use dedicated package to provide bootstrapping binary: rust-bootstrap.
- let ./configure find out host/build on its own.
- remove entry from configuration menu.

Quoted 11 lines

Eric Le Bihan (10):
rustc: new virtual package
rust-bin: new package
cargo-bin: new package
rust: new package
libssh2: add host variant
libhttpparser: add host variant
libcurl: add host variant
cargo: new package
docs/manual: document cargo-based packages
support/testing: add tests for Rust

Committed series, thanks!

Signature · 1 line
Bye, Peter Korsgaard