Add support for Rust programming language
cover Add support for Rust programming language
This series adds support for the Rust programming language by providing a package for the host variant of the Rust compiler, able to cross-compile code for ARM, MIPS and x86_64 architectures.
Best regards,
ELB
Eric Le Bihan (2):
python: enable bzip2 in host variant
rust: new package
package/Config.in.host | 1 + package/python/python.mk | 3 +- ...monize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch | 53 ++++ .../0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch | 71 +++++ ...eclaration-in-mipsel-unknown-linux-gnu.mk.patch | 26 ++ package/rust/Config.in.host | 24 ++ package/rust/rust-target-gen | 314 +++++++++++++++++++++ package/rust/rust.hash | 5 + package/rust/rust.mk | 90 ++++++ 9 files changed, 585 insertions(+), 2 deletions(-) create mode 100644 package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch create mode 100644 package/rust/0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch create mode 100644 package/rust/0003-Fix-CPP-declaration-in-mipsel-unknown-linux-gnu.mk.patch create mode 100644 package/rust/Config.in.host create mode 100755 package/rust/rust-target-gen create mode 100644 package/rust/rust.hash create mode 100644 package/rust/rust.mk
Signature · 1 line
2.4.11
PATCH 1/2 python: enable bzip2 in host variant
Enable support for bzip2 in Python host variant, so the tarfile module works properly.
--- package/python/python.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
package/python/python.mk +1 -2
@@ -31,7 +31,6 @@ HOST_PYTHON_CONF_OPTS += \ --disable-gdbm \ --disable-bsddb \ --disable-test-modules \ - --disable-bz2 \ --disable-ssl \ --disable-ossaudiodev \ --disable-pyo-build
@@ -52,7 +51,7 @@ HOST_PYTHON_MAKE = $(MAKE1) PYTHON_DEPENDENCIES = host-python libffi -HOST_PYTHON_DEPENDENCIES = host-expat host-zlib +HOST_PYTHON_DEPENDENCIES = host-expat host-zlib host-bzip2 PYTHON_INSTALL_STAGING = YES
Signature · 1 line
2.4.11
PATCH 1/2 python: enable bzip2 in host variant
Hello,
Quoted 4 lines · Eric Le Bihan
Enable support for bzip2 in Python host variant, so the tarfile module works properly.
Signed-off-by Eric Le Bihan <[email protected]>
Could you give some more details about this? The tarfile module seems to only import the bz2 module when a bzip2-compressed file is handled. Is this actually the case with rust?
I am hesitant between applying your patch (and therefore removing package/nodejs/0.10.45/0001-remove-python-bz2-dependency.patch), or adding an hidden BR2_HOST_PACKAGE_PYTHON_BZIP2 that the rust package could select to make sure bzip2 support is built into host-python.
Indeed, host-python is used by numerous packages, and we're trying to not add too many dependencies to host-python. On the other hand, building bzip2 is pretty fast, so maybe it's reasonable to add it as a mandatory dependency of host-python.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/2 python: enable bzip2 in host variant
Le Thu, 16 Jun 2016 00:01:31 +0200,
Thomas Petazzoni <[email protected]> a ?crit :
Quoted 9 lines · Eric Le Bihan
Quoted 4 lines
Enable support for bzip2 in Python host variant, so the tarfile module works properly.
Signed-off-by Eric Le Bihan <[email protected]>Could you give some more details about this? The tarfile module seems to only import the bz2 module when a bzip2-compressed file is handled. Is this actually the case with rust?
This was required because my initial take on Rust let the build process download the rust-stage0 bzip2 tarball and uncompress it on its own. As the bootstrap binary will now be provided by the rust-bootstrap package, this is not needed anymore.
Quoted 4 lines
Indeed, host-python is used by numerous packages, and we're trying to not add too many dependencies to host-python. On the other hand, building bzip2 is pretty fast, so maybe it's reasonable to add it as a mandatory dependency of host-python.
bz2 tarballs are widespread. So having support for this format in host-python, regardless of Rust, will benefit the user.
Regards,
Signature · 1 line
ELB
PATCH 1/2 python: enable bzip2 in host variant
Hello,
Quoted 8 lines · Eric Le Bihan
Quoted 3 lines
Could you give some more details about this? The tarfile module seems to only import the bz2 module when a bzip2-compressed file is handled. Is this actually the case with rust?
This was required because my initial take on Rust let the build process download the rust-stage0 bzip2 tarball and uncompress it on its own. As the bootstrap binary will now be provided by the rust-bootstrap package, this is not needed anymore.
OK, great!
Quoted 7 lines
Quoted 4 lines
Indeed, host-python is used by numerous packages, and we're trying to not add too many dependencies to host-python. On the other hand, building bzip2 is pretty fast, so maybe it's reasonable to add it as a mandatory dependency of host-python.
bz2 tarballs are widespread. So having support for this format in host-python, regardless of Rust, will benefit the user.
host-python is only meant to be used as a dependency to build other things in Buildroot. As long as these "other things" don't need bz2 support in Python, there's no reason to enable it.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 2/2 rust: new package
In reply to Eric Le BihanThis new package provides the compiler for the Rust programming language.
Currently, only the host variant is built.
The build process is as follows:
1. a snapshot of the Rust compiler matching the host architecture is downloaded. This is rustc-stage0.
2. rustc-stage0 is used to build rustc-stage1, which will build the final Rust compiler (rust-stage2) and the standard library for the host architecture.
3. the standard library for the target architecture is build.
The Rust compiler uses LLVM as its backend, compiled with support for x86, ARM, PowerPC and MIPS architectures.
To properly build the standard library for the target, two files are needed:
- the target configuration: a Makefile fragment telling the build system about the cross-compiler and such.
- the target specification: a JSON file describing the target architecture to the LLVM backend.
These files are generated with a Python script which takes info from the Buildroot configuration: rust-target-gen.
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.
--- package/Config.in.host | 1 + ...monize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch | 53 ++++ .../0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch | 71 +++++ ...eclaration-in-mipsel-unknown-linux-gnu.mk.patch | 26 ++ package/rust/Config.in.host | 24 ++ package/rust/rust-target-gen | 314 +++++++++++++++++++++ package/rust/rust.hash | 5 + package/rust/rust.mk | 90 ++++++ 8 files changed, 584 insertions(+) create mode 100644 package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch create mode 100644 package/rust/0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch create mode 100644 package/rust/0003-Fix-CPP-declaration-in-mipsel-unknown-linux-gnu.mk.patch create mode 100644 package/rust/Config.in.host create mode 100755 package/rust/rust-target-gen create mode 100644 package/rust/rust.hash create mode 100644 package/rust/rust.mk
package/Config.in.host +1 -0
@@ -28,6 +28,7 @@ menu "Host utilities" source "package/patchelf/Config.in.host" source "package/pwgen/Config.in.host" source "package/qemu/Config.in.host" + source "package/rust/Config.in.host" source "package/sam-ba/Config.in.host" source "package/squashfs/Config.in.host" source "package/sunxi-tools/Config.in.host"
package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch new file +53 -0
53 lines not on this page · raw message
package/rust/0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch new file +71 -0
71 lines not on this page · raw message
package/rust/0003-Fix-CPP-declaration-in-mipsel-unknown-linux-gnu.mk.patch new file +26 -0
@@ -0,0 +1,26 @@ +From f6d8c8f6dcdbabead3a06ed8f592143afaad16ba Mon Sep 17 00:00:00 2001 +From: Eric Le Bihan <[email protected]> +Date: Tue, 19 Apr 2016 12:57:24 +0200 +Subject: [PATCH 3/3] Fix CPP declaration in mipsel-unknown-linux-gnu.mk + +Signed-off-by: Eric Le Bihan <[email protected]> +--- + mk/cfg/mipsel-unknown-linux-gnu.mk | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mk/cfg/mipsel-unknown-linux-gnu.mk b/mk/cfg/mipsel-unknown-linux-gnu.mk +index 9340c46..aaa18c2 100644 +--- a/mk/cfg/mipsel-unknown-linux-gnu.mk ++++ b/mk/cfg/mipsel-unknown-linux-gnu.mk +@@ -2,7 +2,7 @@ + CROSS_PREFIX_mipsel-unknown-linux-gnu=mipsel-linux-gnu- + CC_mipsel-unknown-linux-gnu=gcc + CXX_mipsel-unknown-linux-gnu=g++ +-CPP_mipsel-unknown-linux-gnu=gcc ++CPP_mipsel-unknown-linux-gnu=gcc -E + AR_mipsel-unknown-linux-gnu=ar + CFG_LIB_NAME_mipsel-unknown-linux-gnu=lib$(1).so + CFG_STATIC_LIB_NAME_mipsel-unknown-linux-gnu=lib$(1).a +-- +2.1.4 +
package/rust/Config.in.host new file +24 -0
@@ -0,0 +1,24 @@ +config BR2_PACKAGE_RUST_ARCH_SUPPORTS + bool + default y + depends on BR2_arm || BR2_aarch64 || BR2_i386 \ + || BR2_mips || BR2_mipsel || BR2_x86_64 + depends on !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5 + +config BR2_PACKAGE_HOST_RUST + bool "host rust" + depends on BR2_PACKAGE_RUST_ARCH_SUPPORTS + depends on BR2_TOOLCHAIN_USES_GLIBC + depends on BR2_TOOLCHAIN_HAS_THREADS + help + Rust is a systems programming language that runs blazingly fast, + prevents segfaults, and guarantees thread safety. + + This option builds a Rust cross-compiler for your selected + architecture. + + http://www.rust-lang.org/ + +comment "host-rust needs a (e)glibc toolchain w/ threads" + depends on BR2_PACKAGE_RUST_ARCH_SUPPORTS + depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_TOOLCHAIN_HAS_THREADS
package/rust/rust-target-gen new file +314 -0
314 lines not on this page · raw message
package/rust/rust.hash new file +5 -0
@@ -0,0 +1,5 @@ +# Locally calculated +sha256 af4466147e8d4db4de2a46e07494d2dc2d96313c5b37da34237f511c905f7449 rustc-1.8.0-src.tar.gz +sha1 d29b7607d13d64078b6324aec82926fb493f59ba rust-stage0-2016-02-17-4d3eebf-linux-x86_64-d29b7607d13d64078b6324aec82926fb493f59ba.tar.bz2 +sha1 5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7 rust-stage0-2016-02-17-4d3eebf-linux-i386-5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7.tar.bz2 +
package/rust/rust.mk new file +90 -0
90 lines not on this page · raw message
Signature · 1 line
2.4.11
PATCH 2/2 rust: new package
Hello,
Thanks Eric for working on Rust. Below a preliminary review with lots of questions/comments.
Quoted 8 lines · Eric Le Bihan
This new package provides the compiler for the Rust programming language.
Currently, only the host variant is built.
The build process is as follows:
1. a snapshot of the Rust compiler matching the host architecture is downloaded. This is rustc-stage0.
OK, this one is downloaded pre-compiled. So your package should have a dependency on the host architecture, since the pre-compiled rust compilers are only available on x86 and x86_64 it seems. So you probably want something like:
depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
Quoted 3 lines
2. rustc-stage0 is used to build rustc-stage1, which will build the final Rust compiler (rust-stage2) and the standard library for the host architecture.
Is this all happening inside the rust build process? Because from what I can see in your package, you're downloading and extracting rustc-stage0, and then directly building rust.
Quoted 8 lines
3. the standard library for the target architecture is build.
The Rust compiler uses LLVM as its backend, compiled with support for x86, ARM, PowerPC and MIPS architectures.
To properly build the standard library for the target, two files are needed:
Quoted 7 lines
- the target configuration: a
Makefilefragment telling the build system about the cross-compiler and such.
- the target specification: a JSON file describing the target architecture to the LLVM backend.These files are generated with a Python script which takes info from the Buildroot configuration:
rust-target-gen.
It is not entirely clear to me if a separate Python script is needed, or if they could be generated from rust.mk directly.
Quoted 3 lines
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.
So where does the glibc dependency comes from?
Quoted 9 lines
package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch new file +3
-0@@ -0,0 +1,53 @@ +From 23d9dbfb3ad4a8d5d5997738e8b1436d076898e9 Mon Sep 17 00:00:00 2001 +From: Eric Le Bihan <[email protected]> +Date: Tue, 19 Apr 2016 10:49:20 +0200
package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch line 13
Quoted 10 lines
package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch new file +10
-0+Subject: [PATCH 1/3] Harmonize use of CROSS_PREFIX_* in mk/cfg/*.mk + +Use CROSS_PREFIX_ in Makefile fragments for cross-compiling on Linux +wherever possible. + +Signed-off-by: Eric Le Bihan <[email protected]> +--- + mk/cfg/mips-unknown-linux-gnu.mk | 9 +++++---- + mk/cfg/mipsel-unknown-linux-gnu.mk | 9 +++++---- + 2 files changed, 10 insertions(+), 8 deletions(-)
Aren't those files generated by your Python script? If so, why are you patching the existing ones?
Quoted 6 lines
package/rust/Config.in.host new file +0
-0
package/rust/Config.in.host line 9
Quoted 9 lines
package/rust/Config.in.host new file +9
-0@@ -0,0 +1,24 @@ +config BR2_PACKAGE_RUST_ARCH_SUPPORTS + bool + default y + depends on BR2_arm || BR2_aarch64 || BR2_i386 \ + || BR2_mips || BR2_mipsel || BR2_x86_64 + depends on !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5 + +config BR2_PACKAGE_HOST_RUST + bool "host rust"
Normally, we wouldn't add visible Config.in options for such host packages, they should just be used as dependencies of target packages. Like we did for the host-go package recently.
package/rust/rust.hash line 5
Quoted 11 lines
package/rust/rust.hash new file +5
-0@@ -0,0 +1,5 @@ +# Locally calculated +sha256 af4466147e8d4db4de2a46e07494d2dc2d96313c5b37da34237f511c905f7449 rustc-1.8.0-src.tar.gz +sha1 d29b7607d13d64078b6324aec82926fb493f59ba rust-stage0-2016-02-17-4d3eebf-linux-x86_64-d29b7607d13d64078b6324aec82926fb493f59ba.tar.bz2 +sha1 5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7 rust-stage0-2016-02-17-4d3eebf-linux-i386-5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7.tar.bz2 +
Unneeded empty line. If you're locally calculating the hashes, why not use sha256 for all of them?
Quoted 33 lines
package/rust/rust.mk new file +27
-0@@ -0,0 +1,90 @@ +################################################################################ +# +# rust +# +################################################################################ + +RUST_VERSION = 1.8.0 +RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.gz +RUST_SITE = https://static.rust-lang.org/dist +RUST_LICENSE = Apache-2.0, MIT +RUST_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT + +HOST_RUST_DEPENDENCIES = host-python + +# Taken from src/snapshots.txt +HOST_RUST_SNAP_SITE = https://static.rust-lang.org/stage0-snapshots +HOST_RUST_SNAP_DATE = 2016-02-17 +HOST_RUST_SNAP_REV = 4d3eebf + +ifeq ($(HOSTARCH),x86_64) +HOST_RUST_SNAP_HASH = d29b7607d13d64078b6324aec82926fb493f59ba +else +HOST_RUST_SNAP_HASH = 5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7 +endif + +HOST_RUST_SNAP_SOURCE = \ + rust-stage0-$(HOST_RUST_SNAP_DATE)-$(HOST_RUST_SNAP_REV)-linux-$(HOSTARCH)-$(HOST_RUST_SNAP_HASH).tar.bz2
package/rust/rust.mk line 37
Quoted 10 lines
package/rust/rust.mk new file +10
-0+ +HOST_RUST_EXTRA_DOWNLOADS = \ + $(HOST_RUST_SNAP_SITE)/$(HOST_RUST_SNAP_SOURCE) + +define HOST_RUST_SNAP_EXTRACT + $(call suitable-extractor,$(HOST_RUST_SNAP_SOURCE)) $(DL_DIR)/$(HOST_RUST_SNAP_SOURCE) | \ + $(TAR) -C $(@D) $(TAR_OPTIONS) - +endef + +HOST_RUST_POST_EXTRACT_HOOKS += HOST_RUST_SNAP_EXTRACT
Alternatively, downloading and installing the rustc-stage0 compiler could be done in a separate package, perhaps?
Quoted 30 lines
package/rust/rust.mk new file +30
-0+ +define HOST_RUST_GEN_CONF + package/rust/rust-target-gen \ + --mode conf \ + --prefix=$(notdir $(TARGET_CROSS)) \ + --input $(@D) \ + --output $(@D)/mk/cfg/$(GNU_TARGET_NAME).mk \ + $(GNU_TARGET_NAME) +endef + +define HOST_RUST_GEN_SPEC + package/rust/rust-target-gen \ + --mode spec \ + --input $(@D) \ + --output $(HOST_DIR)/etc/rustc/$(GNU_TARGET_NAME).json \ + $(GNU_TARGET_NAME) +endef + +HOST_RUST_PRE_CONFIGURE_HOOKS += \ + HOST_RUST_GEN_CONF \ + HOST_RUST_GEN_SPEC + +HOST_RUST_MAKE_ENV = RUST_TARGET_PATH=$(HOST_DIR)/etc/rustc +HOST_RUST_MAKE_OPTS = VERBOSE=1 + +define HOST_RUST_CONFIGURE_CMDS + (cd $(@D); $(HOST_CONFIGURE_OPTS) \ + ./configure \ + --host=$(GNU_HOST_NAME) \ + --build=$(GNU_HOST_NAME) \
package/rust/rust.mk line 77
Quoted 10 lines
package/rust/rust.mk new file +10
-0+ --target=$(GNU_TARGET_NAME) \ + --prefix="$(HOST_DIR)/usr" \ + --enable-local-rust \ + --local-rust-root="$(@D)/rust-stage0" \ + --disable-docs \ + --disable-manage-submodules \ + --sysconfdir="$(HOST_DIR)/etc" \ + --localstatedir="$(HOST_DIR)/var/lib" \ + --datadir="$(HOST_DIR)/usr/share" \ + --infodir="$(HOST_DIR)/usr/share/info")
It's probably good to explain somewhere that the configure script is not an autoconf-generated configure script.
In any case, I applied your patches, and tried to build the following defconfig:
BR2_arm=y
BR2_cortex_a8=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_RUST=y
and it fails to build with:
Quoted 1 line
Quoted 1 line
Quoted 1 line
host-rust 1.8.0 Configuring
package/rust/rust-target-gen --mode conf --prefix=arm-linux-gnueabihf- --input /home/thomas/projets/buildroot/output/build/host-rust-1.8.0 --output /home/thomas/projets/buildroot/output/build/host-rust-1.8.0/mk/cfg/arm-buildroot-linux-gnueabihf.mk arm-buildroot-linux-gnueabihf
package/rust/rust-target-gen --mode spec --input /home/thomas/projets/buildroot/output/build/host-rust-1.8.0 --output /home/thomas/projets/buildroot/output/host/etc/rustc/arm-buildroot-linux-gnueabihf.json arm-buildroot-linux-gnueabihf
(cd /home/thomas/projets/buildroot/output/build/host-rust-1.8.0; PATH="/home/thomas/projets/buildroot/output/host/bin:/home/thomas/projets/buildroot/output/host/sbin:/home/thomas/projets/buildroot/output/host/usr/bin:/home/thomas/projets/buildroot/output/host/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/thomas/sys/bin:/home/thomas/.gem/ruby/2.1.0/bin" AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm" CC="/usr/bin/gcc" GCC="/usr/bin/gcc" CXX="/usr/bin/g++" CPP="/usr/bin/cpp" OBJCOPY="/usr/bin/objcopy" RANLIB="/usr/bin/ranlib" CPPFLAGS="-I/home/thomas/projets/buildroot/output/host/usr/include" CFLAGS="-O2 -I/home/thomas/projets/buildroot/output/host/usr/include" CXXFLAGS="-O2 -I/home/thomas/projets/buildroot/output/host/usr/include" LDFLAGS="-L/home/thomas/projets/buildroot/output/host/lib -L/home/thomas/projets/buildroot/output/host/usr/lib -Wl,-rpath,/home/thomas/projets/buildroot/output/ho
st/usr/l
ib" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG="/home/thomas/projets/buildroot/output/host/usr/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_LIBDIR="/home/thomas/projets/buildroot/output/host/usr/lib/pkgconfig:/home/thomas/projets/buildroot/output/host/usr/share/pkgconfig" INTLTOOL_PERL=/usr/bin/perl ./configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --target=arm-buildroot-linux-gnueabihf --prefix="/home/thomas/projets/buildroot/output/host/usr" --enable-local-rust --local-rust-root="/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/rust-stage0" --disable-docs --disable-manage-submodules --sysconfdir="/home/thomas/projets/buildroot/output/host/etc" --localstatedir="/home/thomas/projets/buildroot/output/host/var/lib" --datadir="/home/thomas/projets/buildroot/output/host/usr/share" --infodir="/home/thomas/projets/buildroot/output/host/usr/share/info")
configure: looking for configure programs
configure: found program 'cmp'
configure: found program 'mkdir'
configure: found program 'printf'
configure: found program 'cut'
configure: found program 'head'
configure: found program 'grep'
configure: found program 'xargs'
configure: found program 'cp'
configure: found program 'find'
configure: found program 'uname'
configure: found program 'date'
configure: found program 'tr'
configure: found program 'sed'
configure: found program 'file'
configure: found program 'make'
configure: inspecting environment
configure: recreating config.tmp
configure:
configure: processing ./configure args
configure:
configure: CFG_DISABLE_DOCS := 1
configure: CFG_ENABLE_LOCAL_RUST := 1
configure: CFG_LOCALSTATEDIR := /home/thomas/projets/buildroot/outp ...
configure: CFG_SYSCONFDIR := /home/thomas/projets/buildroot/outp ...
configure: CFG_DATADIR := /home/thomas/projets/buildroot/outp ...
configure: CFG_INFODIR := /home/thomas/projets/buildroot/outp ...
configure: CFG_LLVM_ROOT :=
configure: CFG_PYTHON :=
configure: CFG_JEMALLOC_ROOT :=
configure: CFG_BUILD := x86_64-pc-linux-gnu
configure: CFG_ANDROID_CROSS_PATH :=
configure: CFG_I686_LINUX_ANDROID_NDK :=
configure: CFG_ARM_LINUX_ANDROIDEABI_NDK :=
configure: CFG_AARCH64_LINUX_ANDROID_NDK :=
configure: CFG_NACL_CROSS_PATH :=
configure: CFG_RELEASE_CHANNEL := dev
configure: CFG_MUSL_ROOT := /usr/local
configure: CFG_EXTRA_FILENAME :=
configure: CFG_DEFAULT_LINKER := cc
configure: CFG_DEFAULT_AR := ar
configure: CFG_LIBDIR := /home/thomas/projets/buildroot/outp ...
configure:
configure: validating ./configure args
configure:
configure: CFG_BOOTSTRAP_KEY := 23:44:24
configure:
configure: looking for build programs
configure:
configure: CFG_CURLORWGET := /usr/bin/curl (7.47.0)
configure: CFG_PYTHON := /home/thomas/projets/buildroot/outp ...
configure: CFG_GIT := /usr/bin/git (2.7.4)
configure: git: no git directory. disabling submodules
configure: CFG_MD5 :=
configure: CFG_MD5SUM := /usr/bin/md5sum (8.25)
configure: CFG_HASH_COMMAND := /usr/bin/md5sum | cut -c 1-8
configure: CFG_CLANG :=
configure: CFG_CCACHE :=
configure: CFG_GCC := /usr/bin/gcc (5.3.1-14ubuntu2.1)
configure: CFG_LD := /usr/bin/ld (2.26)
configure: CFG_VALGRIND :=
configure: CFG_PERF :=
configure: CFG_ISCC :=
configure: CFG_ANTLR4 :=
configure: CFG_GRUN :=
configure: CFG_FLEX := /usr/bin/flex (2.6.0)
configure: CFG_BISON := /usr/bin/bison (3.0.4)
configure: CFG_GDB := /usr/bin/gdb (7.11-0ubuntu1)
configure: CFG_LLDB :=
configure: CFG_DISABLE_VALGRIND_RPASS := 1
configure: CFG_GDB_VERSION := GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11
configure:
configure: looking for target specific programs
configure:
configure: CFG_ADB := /usr/bin/adb
configure:
configure: using rustc at: /home/thomas/projets/buildroot/output/build/host-rust-1.8.0/rust-stage0 with version: rustc 1.8.0-dev (4d3eebff9 2016-02-17)
configure:
configure: CFG_LOCAL_RUST_ROOT := /home/thomas/projets/buildroot/outp ...
configure: skipping compiler inference steps; using provided CC=/usr/bin/gcc
configure: CFG_CC := /usr/bin/gcc
configure: CFG_CXX := /usr/bin/g++
configure: CFG_CPP := /usr/bin/cpp
configure: CFG_CFLAGS := -O2 -I/home/thomas/projets/buildroo ...
configure: CFG_CXXFLAGS := -O2 -I/home/thomas/projets/buildroo ...
configure: CFG_LDFLAGS := -L/home/thomas/projets/buildroot/ou ...
configure: CFG_STDCPP_NAME := stdc++
configure: error: unsupported target triples "x86_64-pc-linux-gnu" foundpackage/pkg-generic.mk:185: recipe for target '/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/.stamp_configured' failed
make[1]: *** [/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/.stamp_configured] Error 1
Makefile:36: recipe for target '_all' failed
make: *** [_all] Error 2
Is this expected?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 2/2 rust: new package
Thomas,
We are already building rust 1.9.0 derived from Eric?s patches - he updated them a bit ago and we modified them slightly.
I haven?t tried to post any other patches since I don?t want to confuse the issue with our changes on his changes on buildroot changes.
However, if you or Eric would like/need anything from us - please let us know because it is alot easier on us if rust goes into buildroot proper.
BTW - I would also really want to know what the proper method is for making an EXTERNAL rust toolchain option because that llvm compiles is at least 5 expressos long and by the time it is down - well the hands just jitter.
Regards,
Charles
Quoted 332 lines · Thomas Petazzoni
Hello,
Thanks Eric for working on Rust. Below a preliminary review with lots of questions/comments.
Quoted 8 lines · Eric Le Bihan
This new package provides the compiler for the Rust programming language.
Currently, only the host variant is built.
The build process is as follows:
1. a snapshot of the Rust compiler matching the host architecture is downloaded. This is rustc-stage0.
OK, this one is downloaded pre-compiled. So your package should have a dependency on the host architecture, since the pre-compiled rust compilers are only available on x86 and
x86_64it seems. So you probably want something like:depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"Quoted 3 lines
2. rustc-stage0 is used to build rustc-stage1, which will build the final Rust compiler (rust-stage2) and the standard library for the host architecture.
Is this all happening inside the rust build process? Because from what I can see in your package, you're downloading and extracting rustc-stage0, and then directly building rust.
Quoted 8 lines
3. the standard library for the target architecture is build.
The Rust compiler uses LLVM as its backend, compiled with support for x86, ARM, PowerPC and MIPS architectures.
To properly build the standard library for the target, two files are needed:
Quoted 7 lines
- the target configuration: a
Makefilefragment telling the build system about the cross-compiler and such.
- the target specification: a JSON file describing the target architecture to the LLVM backend.These files are generated with a Python script which takes info from the Buildroot configuration:
rust-target-gen.It is not entirely clear to me if a separate Python script is needed, or if they could be generated from rust.mk directly.
Quoted 3 lines
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.
So where does the glibc dependency comes from?
Quoted 9 lines
package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch new file +3
-0@@ -0,0 +1,53 @@ +From 23d9dbfb3ad4a8d5d5997738e8b1436d076898e9 Mon Sep 17 00:00:00 2001 +From: Eric Le Bihan <[email protected]> +Date: Tue, 19 Apr 2016 10:49:20 +0200package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch line 13
Quoted 10 lines
package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch new file +10
-0+Subject: [PATCH 1/3] Harmonize use of CROSS_PREFIX_* in mk/cfg/*.mk + +Use CROSS_PREFIX_ in Makefile fragments for cross-compiling on Linux +wherever possible. + +Signed-off-by: Eric Le Bihan <[email protected]> +--- + mk/cfg/mips-unknown-linux-gnu.mk | 9 +++++---- + mk/cfg/mipsel-unknown-linux-gnu.mk | 9 +++++---- + 2 files changed, 10 insertions(+), 8 deletions(-)Aren't those files generated by your Python script? If so, why are you patching the existing ones?
Quoted 6 lines
package/rust/Config.in.host new file +0
-0package/rust/Config.in.host line 9
Quoted 9 lines
package/rust/Config.in.host new file +9
-0@@ -0,0 +1,24 @@ +config BR2_PACKAGE_RUST_ARCH_SUPPORTS + bool + default y + depends on BR2_arm || BR2_aarch64 || BR2_i386 \ + || BR2_mips || BR2_mipsel || BR2_x86_64 + depends on !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5 + +config BR2_PACKAGE_HOST_RUST + bool "host rust"Normally, we wouldn't add visible Config.in options for such host packages, they should just be used as dependencies of target packages. Like we did for the host-go package recently.
package/rust/rust.hash line 5
Quoted 11 lines
package/rust/rust.hash new file +5
-0@@ -0,0 +1,5 @@ +# Locally calculated +sha256 af4466147e8d4db4de2a46e07494d2dc2d96313c5b37da34237f511c905f7449 rustc-1.8.0-src.tar.gz +sha1 d29b7607d13d64078b6324aec82926fb493f59ba rust-stage0-2016-02-17-4d3eebf-linux-x86_64-d29b7607d13d64078b6324aec82926fb493f59ba.tar.bz2 +sha1 5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7 rust-stage0-2016-02-17-4d3eebf-linux-i386-5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7.tar.bz2 +Unneeded empty line. If you're locally calculating the hashes, why not use sha256 for all of them?
Quoted 33 lines
package/rust/rust.mk new file +27
-0@@ -0,0 +1,90 @@ +################################################################################ +# +# rust +# +################################################################################ + +RUST_VERSION = 1.8.0 +RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.gz +RUST_SITE = https://static.rust-lang.org/dist +RUST_LICENSE = Apache-2.0, MIT +RUST_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT + +HOST_RUST_DEPENDENCIES = host-python + +# Taken from src/snapshots.txt +HOST_RUST_SNAP_SITE = https://static.rust-lang.org/stage0-snapshots +HOST_RUST_SNAP_DATE = 2016-02-17 +HOST_RUST_SNAP_REV = 4d3eebf + +ifeq ($(HOSTARCH),x86_64) +HOST_RUST_SNAP_HASH = d29b7607d13d64078b6324aec82926fb493f59ba +else +HOST_RUST_SNAP_HASH = 5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7 +endif + +HOST_RUST_SNAP_SOURCE = \ + rust-stage0-$(HOST_RUST_SNAP_DATE)-$(HOST_RUST_SNAP_REV)-linux-$(HOSTARCH)-$(HOST_RUST_SNAP_HASH).tar.bz2package/rust/rust.mk line 37
Quoted 10 lines
package/rust/rust.mk new file +10
-0+ +HOST_RUST_EXTRA_DOWNLOADS = \ + $(HOST_RUST_SNAP_SITE)/$(HOST_RUST_SNAP_SOURCE) + +define HOST_RUST_SNAP_EXTRACT + $(call suitable-extractor,$(HOST_RUST_SNAP_SOURCE)) $(DL_DIR)/$(HOST_RUST_SNAP_SOURCE) | \ + $(TAR) -C $(@D) $(TAR_OPTIONS) - +endef + +HOST_RUST_POST_EXTRACT_HOOKS += HOST_RUST_SNAP_EXTRACTAlternatively, downloading and installing the rustc-stage0 compiler could be done in a separate package, perhaps?
Quoted 30 lines
package/rust/rust.mk new file +30
-0+ +define HOST_RUST_GEN_CONF + package/rust/rust-target-gen \ + --mode conf \ + --prefix=$(notdir $(TARGET_CROSS)) \ + --input $(@D) \ + --output $(@D)/mk/cfg/$(GNU_TARGET_NAME).mk \ + $(GNU_TARGET_NAME) +endef + +define HOST_RUST_GEN_SPEC + package/rust/rust-target-gen \ + --mode spec \ + --input $(@D) \ + --output $(HOST_DIR)/etc/rustc/$(GNU_TARGET_NAME).json \ + $(GNU_TARGET_NAME) +endef + +HOST_RUST_PRE_CONFIGURE_HOOKS += \ + HOST_RUST_GEN_CONF \ + HOST_RUST_GEN_SPEC + +HOST_RUST_MAKE_ENV = RUST_TARGET_PATH=$(HOST_DIR)/etc/rustc +HOST_RUST_MAKE_OPTS = VERBOSE=1 + +define HOST_RUST_CONFIGURE_CMDS + (cd $(@D); $(HOST_CONFIGURE_OPTS) \ + ./configure \ + --host=$(GNU_HOST_NAME) \ + --build=$(GNU_HOST_NAME) \package/rust/rust.mk line 77
Quoted 10 lines
package/rust/rust.mk new file +10
-0+ --target=$(GNU_TARGET_NAME) \ + --prefix="$(HOST_DIR)/usr" \ + --enable-local-rust \ + --local-rust-root="$(@D)/rust-stage0" \ + --disable-docs \ + --disable-manage-submodules \ + --sysconfdir="$(HOST_DIR)/etc" \ + --localstatedir="$(HOST_DIR)/var/lib" \ + --datadir="$(HOST_DIR)/usr/share" \ + --infodir="$(HOST_DIR)/usr/share/info")It's probably good to explain somewhere that the configure script is not an autoconf-generated configure script.
In any case, I applied your patches, and tried to build the following defconfig:
BR2_arm=y
BR2_cortex_a8=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
#BR2_PACKAGE_BUSYBOXis not set
#BR2_TARGET_ROOTFS_TARis not set
BR2_PACKAGE_HOST_RUST=yand it fails to build with:
Quoted 1 line
Quoted 1 line
Quoted 1 line
host-rust 1.8.0 Configuring
package/rust/rust-target-gen --mode conf --prefix=arm-linux-gnueabihf- --input
/home/thomas/projets/buildroot/output/build/host-rust-1.8.0--output/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/mk/cfg/arm-buildroot-linux-gnueabihf.mkarm-buildroot-linux-gnueabihf
package/rust/rust-target-gen --mode spec --input/home/thomas/projets/buildroot/output/build/host-rust-1.8.0--output/home/thomas/projets/buildroot/output/host/etc/rustc/arm-buildroot-linux-gnueabihf.jsonarm-buildroot-linux-gnueabihf
(cd/home/thomas/projets/buildroot/output/build/host-rust-1.8.0; PATH="/home/thomas/projets/buildroot/output/host/bin:/home/thomas/projets/buildroot/output/host/sbin:/home/thomas/projets/buildroot/output/host/usr/bin:/home/thomas/projets/buildroot/output/host/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/thomas/sys/bin:/home/thomas/.gem/ruby/2.1.0/bin" AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm" CC="/usr/bin/gcc" GCC="/usr/bin/gcc" CXX="/usr/bin/g++" CPP="/usr/bin/cpp" OBJCOPY="/usr/bin/objcopy" RANLIB="/usr/bin/ranlib" CPPFLAGS="-I/home/thomas/projets/buildroot/output/host/usr/include" CFLAGS="-O2 -I/home/thomas/projets/buildroot/output/host/usr/include" CXXFLAGS="-O2 -I/home/thomas/projets/buildroot/output/host/usr/include" LDFLAGS="-L/home/thomas/projets/buildroot/output/host/lib -L/home/thomas/projets/buildroot/output/host/usr/lib -Wl,-rpath,/home/thomas/projets/buildroot/output/ho st/usr/l
ib" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG="/home/thomas/projets/buildroot/output/host/usr/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_LIBDIR="/home/thomas/projets/buildroot/output/host/usr/lib/pkgconfig:/home/thomas/projets/buildroot/output/host/usr/share/pkgconfig" INTLTOOL_PERL=/usr/bin/perl ./configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --target=arm-buildroot-linux-gnueabihf --prefix="/home/thomas/projets/buildroot/output/host/usr" --enable-local-rust --local-rust-root="/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/rust-stage0" --disable-docs --disable-manage-submodules --sysconfdir="/home/thomas/projets/buildroot/output/host/etc" --localstatedir="/home/thomas/projets/buildroot/output/host/var/lib" --datadir="/home/thomas/projets/buildroot/output/host/usr/share" --infodir="/home/thomas/projets/buildroot/output/host/usr/share/info")
configure: looking for configure programs
configure: found program 'cmp'
configure: found program 'mkdir'
configure: found program 'printf'
configure: found program 'cut'
configure: found program 'head'
configure: found program 'grep'
configure: found program 'xargs'
configure: found program 'cp'
configure: found program 'find'
configure: found program 'uname'
configure: found program 'date'
configure: found program 'tr'
configure: found program 'sed'
configure: found program 'file'
configure: found program 'make'
configure: inspecting environment
configure: recreating config.tmp
configure:
configure: processing ./configure args
configure:
configure:CFG_DISABLE_DOCS:= 1
configure:CFG_ENABLE_LOCAL_RUST:= 1
configure:CFG_LOCALSTATEDIR:=/home/thomas/projets/buildroot/outp...
configure:CFG_SYSCONFDIR:=/home/thomas/projets/buildroot/outp...
configure:CFG_DATADIR:=/home/thomas/projets/buildroot/outp...
configure:CFG_INFODIR:=/home/thomas/projets/buildroot/outp...
configure:CFG_LLVM_ROOT:=
configure:CFG_PYTHON:=
configure:CFG_JEMALLOC_ROOT:=
configure:CFG_BUILD:= x86_64-pc-linux-gnu
configure:CFG_ANDROID_CROSS_PATH:=
configure:CFG_I686_LINUX_ANDROID_NDK:=
configure:CFG_ARM_LINUX_ANDROIDEABI_NDK:=
configure:CFG_AARCH64_LINUX_ANDROID_NDK:=
configure:CFG_NACL_CROSS_PATH:=
configure:CFG_RELEASE_CHANNEL:= dev
configure:CFG_MUSL_ROOT:=/usr/local
configure:CFG_EXTRA_FILENAME:=
configure:CFG_DEFAULT_LINKER:= cc
configure:CFG_DEFAULT_AR:= ar
configure:CFG_LIBDIR:=/home/thomas/projets/buildroot/outp...
configure:
configure: validating ./configure args
configure:
configure:CFG_BOOTSTRAP_KEY:= 23:44:24
configure:
configure: looking for build programs
configure:
configure:CFG_CURLORWGET:=/usr/bin/curl(7.47.0)
configure:CFG_PYTHON:=/home/thomas/projets/buildroot/outp...
configure:CFG_GIT:=/usr/bin/git(2.7.4)
configure: git: no git directory. disabling submodules
configure:CFG_MD5:=
configure:CFG_MD5SUM:=/usr/bin/md5sum(8.25)
configure:CFG_HASH_COMMAND:=/usr/bin/md5sum| cut -c 1-8
configure:CFG_CLANG:=
configure:CFG_CCACHE:=
configure:CFG_GCC:=/usr/bin/gcc(5.3.1-14ubuntu2.1)
configure:CFG_LD:=/usr/bin/ld(2.26)
configure:CFG_VALGRIND:=
configure:CFG_PERF:=
configure:CFG_ISCC:=
configure:CFG_ANTLR4:=
configure:CFG_GRUN:=
configure:CFG_FLEX:=/usr/bin/flex(2.6.0)
configure:CFG_BISON:=/usr/bin/bison(3.0.4)
configure:CFG_GDB:=/usr/bin/gdb(7.11-0ubuntu1)
configure:CFG_LLDB:=
configure:CFG_DISABLE_VALGRIND_RPASS:= 1
configure:CFG_GDB_VERSION:= GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11
configure:
configure: looking for target specific programs
configure:
configure:CFG_ADB:=/usr/bin/adb
configure:
configure: using rustc at:/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/rust-stage0with version: rustc 1.8.0-dev (4d3eebff92016-02-17)
configure:
configure:CFG_LOCAL_RUST_ROOT:=/home/thomas/projets/buildroot/outp...
configure: skipping compiler inference steps; using provided CC=/usr/bin/gcc
configure:CFG_CC:=/usr/bin/gcc
configure:CFG_CXX:=/usr/bin/g++
configure:CFG_CPP:=/usr/bin/cpp
configure:CFG_CFLAGS:= -O2 -I/home/thomas/projets/buildroo ...
configure:CFG_CXXFLAGS:= -O2 -I/home/thomas/projets/buildroo ...
configure:CFG_LDFLAGS:= -L/home/thomas/projets/buildroot/ou ...
configure:CFG_STDCPP_NAME:= stdc++
configure: error: unsupported target triples "x86_64-pc-linux-gnu" foundpackage/pkg-generic.mk:185: recipe for target '/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/.stamp_configured' failed
make[1]: *** [/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/.stamp_configured] Error 1
Makefile:36: recipe for target '_all' failed
make: *** [_all] Error 2Is this expected?
Thanks!
Thomas
Signature · 7 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
PATCH 2/2 rust: new package
Hi!
Le Wed, 15 Jun 2016 15:42:13 -0700,
Charles Hardin <[email protected]> a ?crit :
Quoted 6 lines
We are already building rust 1.9.0 derived from Eric?s patches - he updated them a bit ago and we modified them slightly.
I haven?t tried to post any other patches since I don?t want to confuse the issue with our changes on his changes on buildroot changes.
A new version of the patch series, with support for Rust 1.9.0, will be posted shortly. Feel free to comment/review it when available.
Quoted 4 lines
BTW - I would also really want to know what the proper method is for making an EXTERNAL rust toolchain option because that llvm compiles is at least 5 expressos long and by the time it is down - well the hands just jitter.
Maybe we could introduce a virtual package named "rust-toolchain". Then there will be two packages which provides it:
- rust: build Rust from source
- rust-external: download the official pre-built release or use one provided by the user.
Regards,
Signature · 1 line
ELB
PATCH 2/2 rust: new package
In reply to Thomas PetazzoniLe Thu, 16 Jun 2016 00:09:33 +0200,
Thomas Petazzoni <[email protected]> a ?crit :
Quoted 11 lines · Eric Le Bihan
Quoted 9 lines
This new package provides the compiler for the Rust programming language.
Currently, only the host variant is built.
The build process is as follows:
1. a snapshot of the Rust compiler matching the host architecture is downloaded. This is rustc-stage0.
Quoted 6 lines
OK, this one is downloaded pre-compiled. So your package should have a dependency on the host architecture, since the pre-compiled rust compilers are only available on x86 and
x86_64it seems. So you probably want something like:depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
OK. I will add it to rust/Config.in.host.
Quoted 7 lines
Quoted 3 lines
2. rustc-stage0 is used to build rustc-stage1, which will build the final Rust compiler (rust-stage2) and the standard library for
the host architecture.Is this all happening inside the rust build process? Because from what I can see in your package, you're downloading and extracting rustc-stage0, and then directly building rust.
Yes it is. I will reword the commit message to clarify.
Quoted 13 lines
Quoted 13 lines
3. the standard library for the target architecture is build.
The Rust compiler uses LLVM as its backend, compiled with support for x86, ARM, PowerPC and MIPS architectures.
To properly build the standard library for the target, two files are needed:
- the target configuration: a
Makefilefragment telling the build system about the cross-compiler and such.
- the target specification: a JSON file describing the target architecture to the LLVM backend.
Quoted 5 lines
Quoted 2 lines
These files are generated with a Python script which takes info from the Buildroot configuration:
rust-target-gen.It is not entirely clear to me if a separate Python script is needed, or if they could be generated from rust.mk directly.
Though it may be possible, it will make the Makefile more difficult to read. Besides, Python provides more flexibility.
Quoted 5 lines
Quoted 3 lines
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.
So where does the glibc dependency comes from?
I will remove it. It is useless.
Quoted 14 lines
Quoted 14 lines
diff --git
a/package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patchb/package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patchnew file mode 100644 index 0000000..a8dc151 ---/dev/null
+++b/package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch(quoted diff) +0
-0@@ -0,0 +1,53 @@ +From 23d9dbfb3ad4a8d5d5997738e8b1436d076898e9 MonSep 17 00:00:00 2001 +From: Eric Le Bihan<[email protected]> +Date: Tue, 19 Apr 2016 10:49:20 +0200
package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch new file +3
-0+Subject: [PATCH 1/3] Harmonize use of CROSS_PREFIX_* in mk/cfg/*.mk + +Use CROSS_PREFIX_ in Makefile fragments for cross-compiling onLinux +wherever possible.
+
Quoted 8 lines
Quoted 5 lines
+Signed-off-by: Eric Le Bihan <[email protected]>
+--- + mk/cfg/mips-unknown-linux-gnu.mk | 9 +++++---- + mk/cfg/mipsel-unknown-linux-gnu.mk | 9 +++++---- + 2 files changed, 10 insertions(+), 8 deletions(-)Aren't those files generated by your Python script? If so, why are you patching the existing ones?
When invoked in target configuration generation mode, the Python script looks for a configuration file in mk/cfg which matches the input target (e.g. "mips-unknown-linux-gnu" for "mips-buildroot-linux-gnu"). Then it will copy this file and update its contents. Unfortunately, all mk/cfg/*.mk files do not follow the same template. My patches solves this by harmonizing them, thus making the code of the Python script simpler. I will try to upstream them.
Quoted 11 lines
Quoted 11 lines
(quoted diff) +0
-0b/package/rust/Config.in.host new file mode 100644 index 0000000..b9bbe0b
package/rust/Config.in.host new file +5
-0@@ -0,0 +1,24 @@ +config BR2_PACKAGE_RUST_ARCH_SUPPORTS + bool + default y + depends on BR2_arm || BR2_aarch64 || BR2_i386 \ + || BR2_mips || BR2_mipsel || BR2_x86_64
Quoted 8 lines
package/rust/Config.in.host line 9
Quoted 4 lines
package/rust/Config.in.host new file +4
-0+ depends on !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5 + +config BR2_PACKAGE_HOST_RUST + bool "host rust"Normally, we wouldn't add visible Config.in options for such host packages, they should just be used as dependencies of target packages. Like we did for the host-go package recently.
OK.
Quoted 10 lines
Quoted 10 lines
package/rust/rust.hash new file +2
-0@@ -0,0 +1,5 @@ +# Locally calculated +sha256
af4466147e8d4db4de2a46e07494d2dc2d96313c5b37da34237f511c905f7449rustc-1.8.0-src.tar.gz +sha1
Quoted 8 lines
Quoted 5 lines
d29b7607d13d64078b6324aec82926fb493f59barust-stage0-2016-02-17-4d3eebf-linux-x86_64-d29b7607d13d64078b6324aec82926fb493f59ba.tar.bz2 +sha15f194aa7628c0703f0fd48adc4ec7f3cc64b98c7rust-stage0-2016-02-17-4d3eebf-linux-i386-5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7.tar.bz2 +Unneeded empty line. If you're locally calculating the hashes, why not use sha256 for all of them?
Out of laziness, I copied the sha1, which are included in the file names. I will use sha256 sums.
Quoted 39 lines
Quoted 39 lines
package/rust/rust.mk new file +27
-0@@ -0,0 +1,90 @@ +################################################################################ +# +# rust +# +################################################################################ + +RUST_VERSION = 1.8.0 +RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.gz +RUST_SITE = https://static.rust-lang.org/dist +RUST_LICENSE = Apache-2.0, MIT +RUST_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT + +HOST_RUST_DEPENDENCIES = host-python + +# Taken from src/snapshots.txt +HOST_RUST_SNAP_SITE = https://static.rust-lang.org/stage0-snapshots +HOST_RUST_SNAP_DATE = 2016-02-17 +HOST_RUST_SNAP_REV = 4d3eebf + +ifeq ($(HOSTARCH),x86_64) +HOST_RUST_SNAP_HASH = d29b7607d13d64078b6324aec82926fb493f59ba +else +HOST_RUST_SNAP_HASH = 5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7 +endif + +HOST_RUST_SNAP_SOURCE = \ +rust-stage0-$(HOST_RUST_SNAP_DATE)-$(HOST_RUST_SNAP_REV)-linux-$(HOSTARCH)-$(HOST_RUST_SNAP_HASH).tar.bz2
+ +HOST_RUST_EXTRA_DOWNLOADS = \package/rust/rust.mk new file +4
-0+ $(HOST_RUST_SNAP_SITE)/$(HOST_RUST_SNAP_SOURCE) + +define HOST_RUST_SNAP_EXTRACT + $(call suitable-extractor,$(HOST_RUST_SNAP_SOURCE))
Quoted 8 lines
package/rust/rust.mk line 37
Quoted 5 lines
$(DL_DIR)/$(HOST_RUST_SNAP_SOURCE) | \
package/rust/rust.mk new file +4
-0+ $(TAR) -C $(@D) $(TAR_OPTIONS) - +endef + +HOST_RUST_POST_EXTRACT_HOOKS += HOST_RUST_SNAP_EXTRACTAlternatively, downloading and installing the rustc-stage0 compiler could be done in a separate package, perhaps?
For Cargo, the Rust package manager, I introduced cargo-bootstrap. I will do the same for rust, with rust-bootstrap.
Quoted 36 lines
Quoted 36 lines
package/rust/rust.mk new file +15
-0+ +define HOST_RUST_GEN_CONF + package/rust/rust-target-gen \ + --mode conf \ + --prefix=$(notdir $(TARGET_CROSS)) \ + --input $(@D) \ + --output $(@D)/mk/cfg/$(GNU_TARGET_NAME).mk \ + $(GNU_TARGET_NAME) +endef + +define HOST_RUST_GEN_SPEC + package/rust/rust-target-gen \ + --mode spec \ + --input $(@D) \ + --output$(HOST_DIR)/etc/rustc/$(GNU_TARGET_NAME).json \
package/rust/rust.mk new file +20
-0+ $(GNU_TARGET_NAME) +endef + +HOST_RUST_PRE_CONFIGURE_HOOKS += \ + HOST_RUST_GEN_CONF \ + HOST_RUST_GEN_SPEC + +HOST_RUST_MAKE_ENV = RUST_TARGET_PATH=$(HOST_DIR)/etc/rustc +HOST_RUST_MAKE_OPTS = VERBOSE=1 + +define HOST_RUST_CONFIGURE_CMDS + (cd $(@D); $(HOST_CONFIGURE_OPTS) \ + ./configure \ + --host=$(GNU_HOST_NAME) \ + --build=$(GNU_HOST_NAME) \ + --target=$(GNU_TARGET_NAME) \ + --prefix="$(HOST_DIR)/usr" \ + --enable-local-rust \ + --local-rust-root="$(@D)/rust-stage0" \ + --disable-docs \
Quoted 8 lines
package/rust/rust.mk line 77
Quoted 5 lines
package/rust/rust.mk new file +5
-0+ --disable-manage-submodules \ + --sysconfdir="$(HOST_DIR)/etc" \ + --localstatedir="$(HOST_DIR)/var/lib" \ + --datadir="$(HOST_DIR)/usr/share" \ + --infodir="$(HOST_DIR)/usr/share/info")It's probably good to explain somewhere that the configure script is not an autoconf-generated configure script.
OK.
Quoted 126 lines
In any case, I applied your patches, and tried to build the following defconfig:
BR2_arm=y
BR2_cortex_a8=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
#BR2_PACKAGE_BUSYBOXis not set
#BR2_TARGET_ROOTFS_TARis not set
BR2_PACKAGE_HOST_RUST=yand it fails to build with:
Quoted 1 line
Quoted 1 line
Quoted 1 line
host-rust 1.8.0 Configuring
package/rust/rust-target-gen --mode conf
--prefix=arm-linux-gnueabihf-
--input/home/thomas/projets/buildroot/output/build/host-rust-1.8.0
--output/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/mk/cfg/arm-buildroot-linux-gnueabihf.mk
arm-buildroot-linux-gnueabihf package/rust/rust-target-gen --mode
spec
--input/home/thomas/projets/buildroot/output/build/host-rust-1.8.0
--output/home/thomas/projets/buildroot/output/host/etc/rustc/arm-buildroot-linux-gnueabihf.json
arm-buildroot-linux-gnueabihf
(cd/home/thomas/projets/buildroot/output/build/host-rust-1.8.0; PATH="/home/thomas/projets/buildroot/output/host/bin:/home/thomas/projets/buildroot/output/host/sbin:/home/thomas/projets/buildroot/output/host/usr/bin:/home/thomas/projets/buildroot/output/host/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/thomas/sys/bin:/home/thomas/.gem/ruby/2.1.0/bin" AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm"
CC="/usr/bin/gcc" GCC="/usr/bin/gcc" CXX="/usr/bin/g++"
CPP="/usr/bin/cpp" OBJCOPY="/usr/bin/objcopy"
RANLIB="/usr/bin/ranlib"
CPPFLAGS="-I/home/thomas/projets/buildroot/output/host/usr/include"
CFLAGS="-O2 -I/home/thomas/projets/buildroot/output/host/usr/include"
CXXFLAGS="-O2
-I/home/thomas/projets/buildroot/output/host/usr/include"
LDFLAGS="-L/home/thomas/projets/buildroot/output/host/lib(quoted diff) +0
-2-L/home/thomas/projets/buildroot/output/host/usr/lib -Wl,-rpath,/home/thomas/projets/buildroot/output/ho st/usr/l ib"PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG="/home/thomas/projets/buildroot/output/host/usr/bin/pkg-config"
PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_LIBDIR="/home/thomas/projets/buildroot/output/host/usr/lib/pkgconfig:/home/thomas/projets/buildroot/output/host/usr/share/pkgconfig" INTLTOOL_PERL=/usr/bin/perl ./configure --host=x86_64-pc-linux-gnu
--build=x86_64-pc-linux-gnu --target=arm-buildroot-linux-gnueabihf --prefix="/home/thomas/projets/buildroot/output/host/usr"
--enable-local-rust
--local-rust-root="/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/rust-stage0"
--disable-docs --disable-manage-submodules
--sysconfdir="/home/thomas/projets/buildroot/output/host/etc" --localstatedir="/home/thomas/projets/buildroot/output/host/var/lib" --datadir="/home/thomas/projets/buildroot/output/host/usr/share" --infodir="/home/thomas/projets/buildroot/output/host/usr/share/info")
configure: looking for configure programs configure: found program
'cmp' configure: found program 'mkdir' configure: found program
'printf' configure: found program 'cut' configure: found program
'head' configure: found program 'grep' configure: found program
'xargs' configure: found program 'cp' configure: found program 'find'
configure: found program 'uname' configure: found program 'date'
configure: found program 'tr' configure: found program 'sed'
configure: found program 'file' configure: found program 'make'
configure: inspecting environment configure: recreating config.tmp
configure: configure: processing ./configure args configure:
configure:CFG_DISABLE_DOCS:= 1 configure:CFG_ENABLE_LOCAL_RUST:= 1 configure:CFG_LOCALSTATEDIR:=/home/thomas/projets/buildroot/outp...
configure:CFG_SYSCONFDIR:=/home/thomas/projets/buildroot/outp...
configure:CFG_DATADIR:=/home/thomas/projets/buildroot/outp...
configure:CFG_INFODIR:=/home/thomas/projets/buildroot/outp...
configure:CFG_LLVM_ROOT:= configure:CFG_PYTHON:=
configure:CFG_JEMALLOC_ROOT:= configure:CFG_BUILD:=
x86_64-pc-linux-gnu configure:CFG_ANDROID_CROSS_PATH:= configure:CFG_I686_LINUX_ANDROID_NDK:= configure:CFG_ARM_LINUX_ANDROIDEABI_NDK:= configure:CFG_AARCH64_LINUX_ANDROID_NDK:= configure:CFG_NACL_CROSS_PATH:=
configure:CFG_RELEASE_CHANNEL:= dev configure:CFG_MUSL_ROOT:=/usr/localconfigure:CFG_EXTRA_FILENAME:=
configure:CFG_DEFAULT_LINKER:= cc configure:CFG_DEFAULT_AR:= ar configure:CFG_LIBDIR:=/home/thomas/projets/buildroot/outp...
configure: configure: validating ./configure args configure:
configure:CFG_BOOTSTRAP_KEY:= 23:44:24 configure: configure:
looking for build programs configure: configure:CFG_CURLORWGET:=/usr/bin/curl(7.47.0) configure:CFG_PYTHON:=/home/thomas/projets/buildroot/outp...
configure:CFG_GIT:=/usr/bin/git(2.7.4) configure:
git: no git directory. disabling submodules configure:CFG_MD5 := configure: CFG_MD5SUM := /usr/bin/md5sum (8.25) configure: CFG_HASH_COMMAND := /usr/bin/md5sum | cut -c 1-8 configure: CFG_CLANG := configure: CFG_CCACHE := configure: CFG_GCC := /usr/bin/gcc (5.3.1-14ubuntu2.1) configure: CFG_LD := /usr/bin/ld (2.26) configure: CFG_VALGRIND := configure: CFG_PERF := configure: CFG_ISCC := configure: CFG_ANTLR4 := configure: CFG_GRUN := configure: CFG_FLEX := /usr/bin/flex (2.6.0) configure: CFG_BISON := /usr/bin/bison (3.0.4) configure: CFG_GDB := /usr/bin/gdb (7.11-0ubuntu1) configure: CFG_LLDB := configure: CFG_DISABLE_VALGRIND_RPASS := 1configure:
CFG_GDB_VERSION:= GNU gdb (Ubuntu 7.11-0ubuntu1)
7.11 configure: configure: looking for target specific programs
configure: configure:CFG_ADB:=/usr/bin/adbconfigure:
configure: using rustc
at:/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/rust-stage0with version: rustc 1.8.0-dev (4d3eebff92016-02-17) configure:
configure:CFG_LOCAL_RUST_ROOT:=/home/thomas/projets/buildroot/outp...
configure: skipping compiler inference steps; using provided
CC=/usr/bin/gcc configure:CFG_CC:=/usr/bin/gcc
configure:CFG_CXX:=/usr/bin/g++configure:CFG_CPP:=/usr/bin/cppconfigure:CFG_CFLAGS:= -O2 -I/home/thomas/projets/buildroo ...
configure:CFG_CXXFLAGS:= -O2
-I/home/thomas/projets/buildroo ... configure:CFG_LDFLAGS:= -L/home/thomas/projets/buildroot/ou ...
configure:CFG_STDCPP_NAME:= stdc++ configure: error:
unsupported target triples "x86_64-pc-linux-gnu" foundpackage/pkg-generic.mk:185: recipe for target '/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/.stamp_configured' failed make[1]: *** [/home/thomas/projets/buildroot/output/build/host-rust-1.8.0/.stamp_configured] Error 1 Makefile:36: recipe for target '_all' failed make: *** [_all] Error 2
Quoted 1 line
Is this expected?
Of course, not! The commit b571dbf introduced a new version of support/gnuconfig/config.guess which outputs "x86_64-pc-linux-gnu" as $(GNU_HOST_NAME). The ./configure script only supports "*-unknown-linux-*". Removing the --host=$(GNU_HOST_NAME) and --build=$(GNU_HOST_NAME) options in the Makefile solves the issue, as the ./configure will compute the values on its own.
Regards,
Signature · 1 line
ELB