All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [Patch v3 0/2] Add support for the Rust programming language
@ 2016-07-14 22:01 Eric Le Bihan
  2016-07-14 22:01 ` [Buildroot] [Patch v3 1/2] rust-bootstrap: new package Eric Le Bihan
  2016-07-14 22:01 ` [Buildroot] [Patch v3 2/2] rust: " Eric Le Bihan
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Le Bihan @ 2016-07-14 22:01 UTC (permalink / raw)
  To: buildroot

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.

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.
 - clarify some comments.

Eric Le Bihan (3):
  jemalloc: new package
  rust-bootstrap: new package
  rust: new package

 package/Config.in.host                             |   1 +
 package/rust-bootstrap/rust-bootstrap.hash         |   3 +
 package/rust-bootstrap/rust-bootstrap.mk           |  24 ++
 ...monize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch |  53 ++++
 .../0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch |  73 +++++
 ...eclaration-in-mipsel-unknown-linux-gnu.mk.patch |  26 ++
 package/rust/Config.in.host                        |  14 +
 package/rust/rust-target-gen                       | 315 +++++++++++++++++++++
 package/rust/rust.hash                             |   2 +
 package/rust/rust.mk                               |  67 +++++
 10 files changed, 578 insertions(+)
 create mode 100644 package/rust-bootstrap/rust-bootstrap.hash
 create mode 100644 package/rust-bootstrap/rust-bootstrap.mk
 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

-- 
2.4.11

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [Patch v3 1/2] rust-bootstrap: new package
  2016-07-14 22:01 [Buildroot] [Patch v3 0/2] Add support for the Rust programming language Eric Le Bihan
@ 2016-07-14 22:01 ` Eric Le Bihan
  2016-10-16 11:27   ` Arnout Vandecappelle
  2016-07-14 22:01 ` [Buildroot] [Patch v3 2/2] rust: " Eric Le Bihan
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Le Bihan @ 2016-07-14 22:01 UTC (permalink / raw)
  To: buildroot

This new package fetches a binary snapshot of the Rust compiler,
suitable for the host, in order to bootstrap the Rust compiler.

Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
 package/rust-bootstrap/rust-bootstrap.hash |  3 +++
 package/rust-bootstrap/rust-bootstrap.mk   | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 package/rust-bootstrap/rust-bootstrap.hash
 create mode 100644 package/rust-bootstrap/rust-bootstrap.mk

diff --git a/package/rust-bootstrap/rust-bootstrap.hash b/package/rust-bootstrap/rust-bootstrap.hash
new file mode 100644
index 0000000..0a21802
--- /dev/null
+++ b/package/rust-bootstrap/rust-bootstrap.hash
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256 d0704d10237c66c3efafa6f7e5570c59a1d3fe5c6d99487540f90ebb37cd84c4 rustc-1.9.0-x86_64-unknown-linux-gnu.tar.gz
+sha256 2951dec835827974d03c7aafbf2c969f39bb530e1c200fd46f90bc01772fae39 rustc-1.9.0-i686-unknown-linux-gnu.tar.gz
diff --git a/package/rust-bootstrap/rust-bootstrap.mk b/package/rust-bootstrap/rust-bootstrap.mk
new file mode 100644
index 0000000..df5fb82
--- /dev/null
+++ b/package/rust-bootstrap/rust-bootstrap.mk
@@ -0,0 +1,24 @@
+################################################################################
+#
+# rust-bootstrap
+#
+################################################################################
+
+RUST_BOOTSTRAP_VERSION = 1.9.0
+RUST_BOOTSTRAP_DATE = 2016-05-24
+
+ifeq ($(HOSTARCH),x86_64)
+RUST_BOOTSTRAP_ARCH = x86_64
+else ifeq ($(HOSTARCH),x86)
+RUST_BOOTSTRAP_ARCH = i686
+else
+$(error Unsupported host architecture)
+endif
+
+RUST_BOOTSTRAP_SITE = https://static.rust-lang.org/dist/$(RUST_BOOTSTRAP_DATE)
+
+RUST_BOOTSTRAP_SOURCE = rustc-$(RUST_BOOTSTRAP_VERSION)-$(RUST_BOOTSTRAP_ARCH)-unknown-linux-gnu.tar.gz
+RUST_BOOTSTRAP_LICENSE = Apache-2.0, MIT
+RUST_BOOTSTRAP_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+
+$(eval $(host-generic-package))
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [Patch v3 2/2] rust: new package
  2016-07-14 22:01 [Buildroot] [Patch v3 0/2] Add support for the Rust programming language Eric Le Bihan
  2016-07-14 22:01 ` [Buildroot] [Patch v3 1/2] rust-bootstrap: new package Eric Le Bihan
@ 2016-07-14 22:01 ` Eric Le Bihan
  2016-10-16 15:28   ` Arnout Vandecappelle
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Le Bihan @ 2016-07-14 22:01 UTC (permalink / raw)
  To: buildroot

This new package provides the compiler for the Rust programming language.

Currently, only the host variant is built.

The internal build process is as follows:

 1. rustc-stage0, provided by rust-bootstrap, is used to build
    rustc-stage1.
 2. rust-stage1 builds 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.

Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
 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 |  73 +++++
 ...eclaration-in-mipsel-unknown-linux-gnu.mk.patch |  26 ++
 package/rust/Config.in.host                        |  14 +
 package/rust/rust-target-gen                       | 315 +++++++++++++++++++++
 package/rust/rust.hash                             |   2 +
 package/rust/rust.mk                               |  67 +++++
 8 files changed, 551 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

diff --git a/package/Config.in.host b/package/Config.in.host
index 6d61f19..e21b02e 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -32,6 +32,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"
diff --git a/package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch b/package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch
new file mode 100644
index 0000000..6c09495
--- /dev/null
+++ b/package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch
@@ -0,0 +1,53 @@
+From 23d9dbfb3ad4a8d5d5997738e8b1436d076898e9 Mon Sep 17 00:00:00 2001
+From: Eric Le Bihan <eric.le.bihan.dev@free.fr>
+Date: Tue, 19 Apr 2016 10:49:20 +0200
+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 <eric.le.bihan.dev@free.fr>
+---
+ mk/cfg/mips-unknown-linux-gnu.mk   | 9 +++++----
+ mk/cfg/mipsel-unknown-linux-gnu.mk | 9 +++++----
+ 2 files changed, 10 insertions(+), 8 deletions(-)
+
+diff --git a/mk/cfg/mips-unknown-linux-gnu.mk b/mk/cfg/mips-unknown-linux-gnu.mk
+index 65b0877..0fe95de 100644
+--- a/mk/cfg/mips-unknown-linux-gnu.mk
++++ b/mk/cfg/mips-unknown-linux-gnu.mk
+@@ -1,8 +1,9 @@
+ # mips-unknown-linux-gnu configuration
+-CC_mips-unknown-linux-gnu=mips-linux-gnu-gcc
+-CXX_mips-unknown-linux-gnu=mips-linux-gnu-g++
+-CPP_mips-unknown-linux-gnu=mips-linux-gnu-gcc -E
+-AR_mips-unknown-linux-gnu=mips-linux-gnu-ar
++CROSS_PREFIX_mips-unknown-linux-gnu=mips-linux-gnu-
++CC_mips-unknown-linux-gnu=gcc
++CXX_mips-unknown-linux-gnu=g++
++CPP_mips-unknown-linux-gnu=gcc -E
++AR_mips-unknown-linux-gnu=ar
+ CFG_LIB_NAME_mips-unknown-linux-gnu=lib$(1).so
+ CFG_STATIC_LIB_NAME_mips-unknown-linux-gnu=lib$(1).a
+ CFG_LIB_GLOB_mips-unknown-linux-gnu=lib$(1)-*.so
+diff --git a/mk/cfg/mipsel-unknown-linux-gnu.mk b/mk/cfg/mipsel-unknown-linux-gnu.mk
+index 4dadfc2..9340c46 100644
+--- a/mk/cfg/mipsel-unknown-linux-gnu.mk
++++ b/mk/cfg/mipsel-unknown-linux-gnu.mk
+@@ -1,8 +1,9 @@
+ # mipsel-unknown-linux-gnu configuration
+-CC_mipsel-unknown-linux-gnu=mipsel-linux-gnu-gcc
+-CXX_mipsel-unknown-linux-gnu=mipsel-linux-gnu-g++
+-CPP_mipsel-unknown-linux-gnu=mipsel-linux-gnu-gcc
+-AR_mipsel-unknown-linux-gnu=mipsel-linux-gnu-ar
++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
++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
+ CFG_LIB_GLOB_mipsel-unknown-linux-gnu=lib$(1)-*.so
+--
+2.1.4
+
diff --git a/package/rust/0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch b/package/rust/0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch
new file mode 100644
index 0000000..c694c39
--- /dev/null
+++ b/package/rust/0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch
@@ -0,0 +1,73 @@
+From a371eb06fef803dcf9894fa0ad6941341887d2d8 Mon Sep 17 00:00:00 2001
+From: Eric Le Bihan <eric.le.bihan.dev@free.fr>
+Date: Tue, 19 Apr 2016 12:51:29 +0200
+Subject: [PATCH 2/3] Expand $(CC) to gcc in x86 mk/cfg/*.cfg
+
+Expand $(CC) and friends to gcc and introduce empty CROSS_PREFIX_ in
+Makefile fragments for cross-compilation of i586, i686 and x86_64 Linux
+platforms to allow use of Sourcery CodeBench toolchains.
+
+Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
+---
+ mk/cfg/i586-unknown-linux-gnu.mk   | 9 +++++----
+ mk/cfg/i686-unknown-linux-gnu.mk   | 9 +++++----
+ mk/cfg/x86_64-unknown-linux-gnu.mk | 9 +++++----
+ 3 files changed, 15 insertions(+), 12 deletions(-)
+
+diff --git a/mk/cfg/i586-unknown-linux-gnu.mk b/mk/cfg/i586-unknown-linux-gnu.mk
+index 0609f36..45af3b8 100644
+--- a/mk/cfg/i586-unknown-linux-gnu.mk
++++ b/mk/cfg/i586-unknown-linux-gnu.mk
+@@ -1,8 +1,9 @@
+ # i586-unknown-linux-gnu configuration
+-CC_i586-unknown-linux-gnu=$(CC)
+-CXX_i586-unknown-linux-gnu=$(CXX)
+-CPP_i586-unknown-linux-gnu=$(CPP)
+-AR_i586-unknown-linux-gnu=$(AR)
++CROSS_PREFIX_i686-unknown-linux-gnu=
++CC_i586-unknown-linux-gnu=gcc
++CXX_i586-unknown-linux-gnu=g++
++CPP_i586-unknown-linux-gnu=gcc -E
++AR_i586-unknown-linux-gnu=ar
+ CFG_LIB_NAME_i586-unknown-linux-gnu=lib$(1).so
+ CFG_STATIC_LIB_NAME_i586-unknown-linux-gnu=lib$(1).a
+ CFG_LIB_GLOB_i586-unknown-linux-gnu=lib$(1)-*.so
+diff --git a/mk/cfg/i686-unknown-linux-gnu.mk b/mk/cfg/i686-unknown-linux-gnu.mk
+index 88c0907..aa4ce42 100644
+--- a/mk/cfg/i686-unknown-linux-gnu.mk
++++ b/mk/cfg/i686-unknown-linux-gnu.mk
+@@ -1,8 +1,9 @@
+ # i686-unknown-linux-gnu configuration
+-CC_i686-unknown-linux-gnu=$(CC)
+-CXX_i686-unknown-linux-gnu=$(CXX)
+-CPP_i686-unknown-linux-gnu=$(CPP)
+-AR_i686-unknown-linux-gnu=$(AR)
++CROSS_PREFIX_i686-unknown-linux-gnu=
++CC_i686-unknown-linux-gnu=gcc
++CXX_i686-unknown-linux-gnu=g++
++CPP_i686-unknown-linux-gnu=gcc -E
++AR_i686-unknown-linux-gnu=ar
+ CFG_LIB_NAME_i686-unknown-linux-gnu=lib$(1).so
+ CFG_STATIC_LIB_NAME_i686-unknown-linux-gnu=lib$(1).a
+ CFG_LIB_GLOB_i686-unknown-linux-gnu=lib$(1)-*.so
+diff --git a/mk/cfg/x86_64-unknown-linux-gnu.mk b/mk/cfg/x86_64-unknown-linux-gnu.mk
+index 044c687..bdd88cd 100644
+--- a/mk/cfg/x86_64-unknown-linux-gnu.mk
++++ b/mk/cfg/x86_64-unknown-linux-gnu.mk
+@@ -1,8 +1,9 @@
+ # x86_64-unknown-linux-gnu configuration
+-CC_x86_64-unknown-linux-gnu=$(CC)
+-CXX_x86_64-unknown-linux-gnu=$(CXX)
+-CPP_x86_64-unknown-linux-gnu=$(CPP)
+-AR_x86_64-unknown-linux-gnu=$(AR)
++CROSS_PREFIX_x86_64-unknown-linux-gnu=
++CC_x86_64-unknown-linux-gnu=gcc
++CXX_x86_64-unknown-linux-gnu=g++
++CPP_x86_64-unknown-linux-gnu=gcc -E
++AR_x86_64-unknown-linux-gnu=ar
+ CFG_LIB_NAME_x86_64-unknown-linux-gnu=lib$(1).so
+ CFG_STATIC_LIB_NAME_x86_64-unknown-linux-gnu=lib$(1).a
+ CFG_LIB_GLOB_x86_64-unknown-linux-gnu=lib$(1)-*.so
+--
+2.1.4
+
diff --git a/package/rust/0003-Fix-CPP-declaration-in-mipsel-unknown-linux-gnu.mk.patch b/package/rust/0003-Fix-CPP-declaration-in-mipsel-unknown-linux-gnu.mk.patch
new file mode 100644
index 0000000..00d338f
--- /dev/null
+++ b/package/rust/0003-Fix-CPP-declaration-in-mipsel-unknown-linux-gnu.mk.patch
@@ -0,0 +1,26 @@
+From f6d8c8f6dcdbabead3a06ed8f592143afaad16ba Mon Sep 17 00:00:00 2001
+From: Eric Le Bihan <eric.le.bihan.dev@free.fr>
+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 <eric.le.bihan.dev@free.fr>
+---
+ 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
+
diff --git a/package/rust/Config.in.host b/package/rust/Config.in.host
new file mode 100644
index 0000000..ca11d38
--- /dev/null
+++ b/package/rust/Config.in.host
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_HOST_RUST_ARCH_SUPPORTS
+	bool
+	default y
+	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
+	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
+	depends on BR2_TOOLCHAIN_USES_GLIBC
+	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
+
+comment "host-rust needs a toolchain w/ gcc >= 5"
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5 && BR2_aarch64
diff --git a/package/rust/rust-target-gen b/package/rust/rust-target-gen
new file mode 100755
index 0000000..b34b72a
--- /dev/null
+++ b/package/rust/rust-target-gen
@@ -0,0 +1,315 @@
+#!/usr/bin/env python2.7
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2016 Eric Le Bihan <eric.le.bihan.dev@free.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""
+`rust-target-gen ` generates the target configuration or the specification
+file for the Rust compiler.
+
+These files will be used when cross-compiling the standard library or any
+program.
+
+The name of the target is to be formatted in one of the following schemes:
+
+- <cpu>-<vendor>-<os>-<system>
+- <cpu>-<os>-<system>
+
+By default, the contents of the configuration file is generated and printed to
+standard output. Add *-m spec* to the command line to generate the contents of
+the specification file. Add *-o FILE* to write contents to file FILE.
+
+It is possible to explicitly set the type of CPU using the *--cpu* option. To
+set one or more additional LLVM attributes (a.k.a. "features"), add as many as
+*--feature* options as needed.
+
+"""
+
+import os
+import re
+import sys
+import csv
+import StringIO
+import argparse
+
+__version__ = "0.1.1"
+
+
+class GenerationError(Exception):
+    """Error raised when generating file contents"""
+
+
+class Target:
+    """Store information about a target"""
+    def __init__(self, name):
+        match = re.match(r'([\w]+)(?:-([\w]+))?-linux-([\w]+)', name)
+        if not match:
+            raise ValueError("Invalid target name")
+        self.cpu = match.group(1)
+        self.vendor = match.group(2) or 'unknown'
+        self.system = match.group(3)
+        self.name = name
+        self.prefix = name + "-"
+
+    def to_pattern(self):
+        """Format the target name as search pattern"""
+        if self.vendor == 'unknown':
+            pattern = "{0.cpu}-[\w]+-linux-{0.system}"
+        else:
+            pattern = "{0.cpu}-(?!{0.vendor})[\w]+-linux-{0.system}"
+        return pattern.format(self)
+
+    @property
+    def canonical_name(self):
+        """Return the canonical name of the target"""
+        return "{0.cpu}-{0.vendor}-linux-{0.system}".format(self)
+
+
+#: Default list of pre-link-args
+DEFAULT_PRE_LINK_ARGS = ["-Wl,--as-needed", "-Wl,-z,noexecstack"]
+
+#: Template for the target specifiation JSON file
+SPEC_TEMPLATE = """{{
+      "llvm-target": "{name}",
+      "target-endian": "{endianness}",
+      "target-pointer-width": "{ptr-width}",
+      "data-layout": "{data-layout}",
+      "target-env": "{environment}",
+      "target-vendor": "{vendor}",
+      "arch": "{arch}",
+      "os": "linux",
+      "cpu": "{cpu}",
+      "features": "{features}",
+      "dynamic-linking": true,
+      "executables": true,
+      "morestack": true,
+      "linker-is-gnu": true,
+      "has-rpath": true,
+      "pre-link-args": [
+          {pre-link-args}
+       ],
+      "position-independent-executables": true,
+      "archive-format": "gnu"
+}}
+"""
+
+#: Contents of the target specifiation database.
+#: The information has been extracted from the Rust source code
+#: (src/libbrust_back/target/*.rs) and formatted as CSV.
+#: The first line is the header of the file, listing the fields of the table.
+SPEC_DATABASE_CONTENTS = """name;arch;endianness;ptr-width;data-layout;cpu;features;pre-link-args
+aarch64-unknown-linux-gnu;aarch64;little;64;e-m:e-i64:64-i128:128-n32:64-S128;;;;
+arm-unknown-linux-gnueabihf;arm;little;32;e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64;;+v6,+vfp2;;
+arm-unknown-linux-gnueabi;arm;little;32;e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64;;+v6;;
+i586-unknown-linux-gnu;x86;little;32;e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128;pentium;;-m32
+i686-unknown-linux-gnu;x86;little;32;e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128;pentium4;;-m32
+mips-unknown-linux-gnu;mips;big;32;E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64;;+mips32r2,+soft-float;;
+mipsel-unknown-linux-gnu;mips;little;32;e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64;;+mips32;;
+x86_64-unknown-linux-gnu;x86_64;little;64;e-m:e-i64:64-f80:128-n8:16:32:64-S128;;;-m64
+"""
+
+
+def join_quoted(strings, delimiter=','):
+    """Quote strings and join them as a single string, using a delimiter.
+
+    :param strings: list of strings
+    :type strings: list
+
+    :param delimiter: optional delimiter
+    :type delimiter: Optional[str]
+
+    :return: a new string
+    :rtype: str
+    """
+    return delimiter.join(["\"{}\"".format(s) for s in strings])
+
+
+def find_similar_spec(target):
+    """Find a target specification similar to a given one.
+
+    :param target: target to be created
+    :type target: Target
+
+    :return: the reference target specification as a dict
+    :rtype: dict of str to str
+    """
+    expr = re.compile(target.to_pattern() + '$')
+    f = StringIO.StringIO(SPEC_DATABASE_CONTENTS)
+    reader = csv.DictReader(f, delimiter=';', quotechar='"')
+    for row in reader:
+        if expr.match(row['name']):
+            spec = dict(row)
+            fields = spec['name'].split('-')
+            spec['vendor'] = fields[1]
+            spec['environment'] = fields[3]
+            pre_links_args = DEFAULT_PRE_LINK_ARGS + spec['pre-link-args'].split()
+            spec['pre-link-args'] = join_quoted(pre_links_args, ', ')
+            spec['cpu'] = spec['cpu'] or 'generic'
+            return spec
+
+    raise GenerationError("Can not find matching specification")
+
+
+def gen_spec(target, cpu=None, features=[]):
+    """Generate target specification file.
+
+    :param target: target to be created
+    :type target: Target
+
+    :param cpu: optional CPU type
+    :type cpu: Optional[str]
+
+    :param features: optional list of additional LLVM features
+    :type features: Optional[list]
+
+    :return: contents of the configuration file
+    :rtype: str
+    """
+    spec = find_similar_spec(target)
+    spec['name'] = target.name
+    spec['vendor'] = target.vendor
+    if features:
+        spec['features'] += ',' + ','.join(features)
+    spec['cpu'] = cpu or spec['cpu']
+    return SPEC_TEMPLATE.format(**spec)
+
+
+def gen_conf_from(target, filename):
+    """Generate target configuration file from an existing one.
+
+    :param target: target to be created
+    :type target: Target
+
+    :param filename: path to an existing configuration file
+    :type str:
+
+    :return: contents of the new configuration file
+    :rtype: str
+    """
+    (name, e) = os.path.splitext(os.path.basename(filename))
+    expr = re.compile(r'CROSS_PREFIX_[-\w]+=(?:[-\w]+)?\n')
+    with open(filename) as input:
+        contents = input.read()
+        contents = contents.replace(name, target.name)
+        line = "CROSS_PREFIX_{}={}\n".format(target.name, target.prefix)
+        if expr.search(contents):
+            contents = expr.sub(line, contents)
+        else:
+            contents += line
+
+    return contents
+
+
+def find_similar_conf(target, srcdir):
+    """Find a configuration file similar to a given target.
+
+    :param target: target to be created
+    :type target: Target
+
+    :param srcdir: path to Rust source code
+    :type srcdir: str
+
+    :return: path to the matching configuration file
+    :rtype: str
+    """
+    cfgdir = os.path.join(srcdir, 'mk', 'cfg')
+    expr = re.compile(target.to_pattern() + '.mk')
+    candidates = filter(lambda f: expr.match(f), os.listdir(cfgdir))
+    if len(candidates) != 1:
+        raise GenerationError("Can not find matching configuration")
+    return os.path.join(cfgdir, candidates[0])
+
+
+def gen_conf(target, srcdir):
+    """Generate target configuration file.
+
+    :param target: target to be created
+    :type target: Target
+
+    :param srcdir: path to Rust source code
+    :type srcdir: str
+
+    :return: contents of the configuration file
+    :rtype: str
+    """
+    reference = find_similar_conf(target, srcdir)
+    return gen_conf_from(target, reference)
+
+
+def save_to_file(filename, text):
+    """Save text to a file.
+
+    :param filename: path to the destination filename
+    :type filename: str
+
+    :param text: contents of the file
+    :type text: str
+    """
+    dstdir = os.path.dirname(filename)
+    if not os.path.exists(dstdir):
+        os.makedirs(dstdir)
+    with open(filename, 'w') as f:
+        f.write(contents)
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser()
+    parser.add_argument('-v', '--version',
+                        action='version',
+                        version=__version__)
+    parser.add_argument('-c', '--cpu',
+                        help='Set CPU type')
+    parser.add_argument('-f', '--feature',
+                        action='append',
+                        metavar='FEATURE',
+                        dest='features',
+                        default=[],
+                        help='Add new LLVM feature')
+    parser.add_argument('-i', '--input',
+                        dest='srcdir',
+                        metavar='DIR',
+                        default=os.getcwd(),
+                        help='set the path to Rust source code')
+    parser.add_argument('-p', '--prefix',
+                        help='set the cross-compiler prefix')
+    parser.add_argument('-m', '--mode',
+                        choices=('conf', 'spec'),
+                        default='conf',
+                        help='set the operating mode')
+    parser.add_argument('-o', '--output',
+                        metavar='FILE',
+                        help='write generated contents to FILE')
+    parser.add_argument('target',
+                        help='target name ("<cpu>-<vendor>-<os>-<system>")')
+
+    args = parser.parse_args()
+
+    target = Target(args.target)
+    if args.prefix:
+        target.prefix = args.prefix
+
+    if args.mode == 'conf':
+        contents = gen_conf(target, args.srcdir)
+    else:
+        contents = gen_spec(target, args.cpu, args.features)
+
+    if not args.output:
+        sys.stdout.write(contents)
+    else:
+        save_to_file(args.output, contents)
+
+# vim: ts=4 sw=4 sts=4 et ai
diff --git a/package/rust/rust.hash b/package/rust/rust.hash
new file mode 100644
index 0000000..4c0369d
--- /dev/null
+++ b/package/rust/rust.hash
@@ -0,0 +1,2 @@
+# Locally calculated
+sha256 a4015aacf4f6d8a8239253c4da46e7abaa8584f8214d1828d2ff0a8f56176869 rustc-1.10.0-src.tar.gz
diff --git a/package/rust/rust.mk b/package/rust/rust.mk
new file mode 100644
index 0000000..7126d23
--- /dev/null
+++ b/package/rust/rust.mk
@@ -0,0 +1,67 @@
+################################################################################
+#
+# rust
+#
+################################################################################
+
+RUST_VERSION = 1.10.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-rust-bootstrap host-python toolchain host-jemalloc
+
+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 = $(if $(VERBOSE),VERBOSE=1)
+
+# Though not using autotools, Rust follows the ./configure convention, in its
+# own way...
+define HOST_RUST_CONFIGURE_CMDS
+	(cd $(@D); $(HOST_CONFIGURE_OPTS) \
+		./configure \
+		--target=$(GNU_TARGET_NAME) \
+		--prefix="$(HOST_DIR)/usr" \
+		--jemalloc-root="$(HOST_DIR)/usr/lib" \
+		--enable-local-rust \
+		--local-rust-root="$(HOST_RUST_BOOTSTRAP_DIR)/rustc" \
+		--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")
+endef
+
+define HOST_RUST_BUILD_CMDS
+	$(HOST_MAKE_ENV) $(HOST_RUST_MAKE_ENV) $(MAKE) \
+		$(HOST_RUST_MAKE_OPTS) -C $(@D)
+endef
+
+define HOST_RUST_INSTALL_CMDS
+	$(HOST_MAKE_ENV) $(HOST_RUST_MAKE_ENV) $(MAKE) \
+		$(HOST_RUST_MAKE_OPTS) -C $(@D) install
+endef
+
+$(eval $(host-generic-package))
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [Patch v3 1/2] rust-bootstrap: new package
  2016-07-14 22:01 ` [Buildroot] [Patch v3 1/2] rust-bootstrap: new package Eric Le Bihan
@ 2016-10-16 11:27   ` Arnout Vandecappelle
  2016-10-18 20:47     ` Eric Le Bihan
  0 siblings, 1 reply; 8+ messages in thread
From: Arnout Vandecappelle @ 2016-10-16 11:27 UTC (permalink / raw)
  To: buildroot



On 15-07-16 00:01, Eric Le Bihan wrote:
> This new package fetches a binary snapshot of the Rust compiler,
> suitable for the host, in order to bootstrap the Rust compiler.

 Annoying that we have to bootstrap from binaries, but that's the way it is.

> 
> Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> ---
>  package/rust-bootstrap/rust-bootstrap.hash |  3 +++
>  package/rust-bootstrap/rust-bootstrap.mk   | 24 ++++++++++++++++++++++++
>  2 files changed, 27 insertions(+)
>  create mode 100644 package/rust-bootstrap/rust-bootstrap.hash
>  create mode 100644 package/rust-bootstrap/rust-bootstrap.mk
> 
> diff --git a/package/rust-bootstrap/rust-bootstrap.hash b/package/rust-bootstrap/rust-bootstrap.hash
> new file mode 100644
> index 0000000..0a21802
> --- /dev/null
> +++ b/package/rust-bootstrap/rust-bootstrap.hash
> @@ -0,0 +1,3 @@
> +# Locally calculated
> +sha256 d0704d10237c66c3efafa6f7e5570c59a1d3fe5c6d99487540f90ebb37cd84c4 rustc-1.9.0-x86_64-unknown-linux-gnu.tar.gz
> +sha256 2951dec835827974d03c7aafbf2c969f39bb530e1c200fd46f90bc01772fae39 rustc-1.9.0-i686-unknown-linux-gnu.tar.gz
> diff --git a/package/rust-bootstrap/rust-bootstrap.mk b/package/rust-bootstrap/rust-bootstrap.mk
> new file mode 100644
> index 0000000..df5fb82
> --- /dev/null
> +++ b/package/rust-bootstrap/rust-bootstrap.mk
> @@ -0,0 +1,24 @@
> +################################################################################
> +#
> +# rust-bootstrap
> +#
> +################################################################################
> +
> +RUST_BOOTSTRAP_VERSION = 1.9.0
> +RUST_BOOTSTRAP_DATE = 2016-05-24
> +
> +ifeq ($(HOSTARCH),x86_64)
> +RUST_BOOTSTRAP_ARCH = x86_64
> +else ifeq ($(HOSTARCH),x86)
> +RUST_BOOTSTRAP_ARCH = i686
> +else
> +$(error Unsupported host architecture)

 This is not good because it is evaluated even if host-rust-bootstrap is not
selected. You need to protect it somehow, which is difficult because there is no
user visible symbol that can ever select this package. So instead you could do a
check in e.g. CONFIGURE_CMDS.

 However, this is not needed, because this package can only be built if rust is
built, and rust can only be built if BR2_PACKAGE_HOST_RUST_ARCH_SUPPORTS=y, and
that one already checks for hostarch.

 IOW, just drop this check.

> +endif
> +
> +RUST_BOOTSTRAP_SITE = https://static.rust-lang.org/dist/$(RUST_BOOTSTRAP_DATE)
> +
> +RUST_BOOTSTRAP_SOURCE = rustc-$(RUST_BOOTSTRAP_VERSION)-$(RUST_BOOTSTRAP_ARCH)-unknown-linux-gnu.tar.gz
> +RUST_BOOTSTRAP_LICENSE = Apache-2.0, MIT

 Can you specify which parts or under which license?

 Regards,
 Arnout

> +RUST_BOOTSTRAP_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
> +
> +$(eval $(host-generic-package))
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [Patch v3 2/2] rust: new package
  2016-07-14 22:01 ` [Buildroot] [Patch v3 2/2] rust: " Eric Le Bihan
@ 2016-10-16 15:28   ` Arnout Vandecappelle
  0 siblings, 0 replies; 8+ messages in thread
From: Arnout Vandecappelle @ 2016-10-16 15:28 UTC (permalink / raw)
  To: buildroot



On 15-07-16 00:01, Eric Le Bihan wrote:
> This new package provides the compiler for the Rust programming language.
> 
> Currently, only the host variant is built.

 Since we don't have any package (yet) that uses rust, it is never going to be
built. This is annoying. However, we were thinking that maybe this (and go)
should get user-visible Config.in options. They are really cross-compilers
(although in a much simpler way than gcc), so it is really part of buildroot's
mission to offer these to users even without packages that use them. Fortran is
another example of this.

 There is a bit of doubt of whether this should go in the "Host tools" menu or
in the "toolchain" menu. We're thinking that the toolchain menu is plenty
confusing as it is, so just add it to host tools.


> The internal build process is as follows:
> 
>  1. rustc-stage0, provided by rust-bootstrap, is used to build
>     rustc-stage1.
>  2. rust-stage1 builds 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.

 I guess it uses a bundled LLVM? Would it be possible to unbundle that at some
point?

> 
> 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`.

 This bit we really don't like. First of all there is the issue that it's a lot
of code. Second, we don't like it when a python script is required for the build.

 I'm trying to understand what it does, and as far as I can see it does two things:

0. Find a "similar target", which is basically the output of
   ls $(@D)/mk/cfg/$(ARCH)-*-linux-$(LIBC)$(ABI)

1. Generate the target .mk file, which is basically updating an existing one
with something very similar to KCONFIG_SET_OPT. I.e. a sed and an echo.

2. Generate the target .spec file, which parses the SPEC_DATABASE_CONTENTS,
finds the line corresponding to the $(ARCH) and $(LIBC)$(ABI) combination, gets
the options to fill in from that, and substitutes them in the template json file.

 IMHO all of the above can easily be done directly in the .mk file. I'd normally
ask to offload things into a shell script, but here it is really trivial. The
SPEC_DATABASE_CONTENTS should be expanded into a set of ifeq's that set some
variables, and then those variables should be used in a sed call to create the
.json file from a template .json.in file


> 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.
> 
> Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> ---
>  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 |  73 +++++
>  ...eclaration-in-mipsel-unknown-linux-gnu.mk.patch |  26 ++

 What's the upstream status?

>  package/rust/Config.in.host                        |  14 +
>  package/rust/rust-target-gen                       | 315 +++++++++++++++++++++
>  package/rust/rust.hash                             |   2 +
>  package/rust/rust.mk                               |  67 +++++
>  8 files changed, 551 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
> 
> diff --git a/package/Config.in.host b/package/Config.in.host
> index 6d61f19..e21b02e 100644
> --- a/package/Config.in.host
> +++ b/package/Config.in.host
> @@ -32,6 +32,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"
> diff --git a/package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch b/package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch
> new file mode 100644
> index 0000000..6c09495
> --- /dev/null
> +++ b/package/rust/0001-Harmonize-use-of-CROSS_PREFIX_-in-mk-cfg-.mk.patch
> @@ -0,0 +1,53 @@
> +From 23d9dbfb3ad4a8d5d5997738e8b1436d076898e9 Mon Sep 17 00:00:00 2001
> +From: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> +Date: Tue, 19 Apr 2016 10:49:20 +0200
> +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 <eric.le.bihan.dev@free.fr>
> +---
> + mk/cfg/mips-unknown-linux-gnu.mk   | 9 +++++----
> + mk/cfg/mipsel-unknown-linux-gnu.mk | 9 +++++----
> + 2 files changed, 10 insertions(+), 8 deletions(-)
> +
> +diff --git a/mk/cfg/mips-unknown-linux-gnu.mk b/mk/cfg/mips-unknown-linux-gnu.mk
> +index 65b0877..0fe95de 100644
> +--- a/mk/cfg/mips-unknown-linux-gnu.mk
> ++++ b/mk/cfg/mips-unknown-linux-gnu.mk
> +@@ -1,8 +1,9 @@
> + # mips-unknown-linux-gnu configuration
> +-CC_mips-unknown-linux-gnu=mips-linux-gnu-gcc
> +-CXX_mips-unknown-linux-gnu=mips-linux-gnu-g++
> +-CPP_mips-unknown-linux-gnu=mips-linux-gnu-gcc -E
> +-AR_mips-unknown-linux-gnu=mips-linux-gnu-ar
> ++CROSS_PREFIX_mips-unknown-linux-gnu=mips-linux-gnu-
> ++CC_mips-unknown-linux-gnu=gcc
> ++CXX_mips-unknown-linux-gnu=g++
> ++CPP_mips-unknown-linux-gnu=gcc -E
> ++AR_mips-unknown-linux-gnu=ar
> + CFG_LIB_NAME_mips-unknown-linux-gnu=lib$(1).so
> + CFG_STATIC_LIB_NAME_mips-unknown-linux-gnu=lib$(1).a
> + CFG_LIB_GLOB_mips-unknown-linux-gnu=lib$(1)-*.so
> +diff --git a/mk/cfg/mipsel-unknown-linux-gnu.mk b/mk/cfg/mipsel-unknown-linux-gnu.mk
> +index 4dadfc2..9340c46 100644
> +--- a/mk/cfg/mipsel-unknown-linux-gnu.mk
> ++++ b/mk/cfg/mipsel-unknown-linux-gnu.mk
> +@@ -1,8 +1,9 @@
> + # mipsel-unknown-linux-gnu configuration
> +-CC_mipsel-unknown-linux-gnu=mipsel-linux-gnu-gcc
> +-CXX_mipsel-unknown-linux-gnu=mipsel-linux-gnu-g++
> +-CPP_mipsel-unknown-linux-gnu=mipsel-linux-gnu-gcc
> +-AR_mipsel-unknown-linux-gnu=mipsel-linux-gnu-ar
> ++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
> ++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
> + CFG_LIB_GLOB_mipsel-unknown-linux-gnu=lib$(1)-*.so
> +--
> +2.1.4
> +
> diff --git a/package/rust/0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch b/package/rust/0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch
> new file mode 100644
> index 0000000..c694c39
> --- /dev/null
> +++ b/package/rust/0002-Expand-CC-to-gcc-in-x86-mk-cfg-.cfg.patch
> @@ -0,0 +1,73 @@
> +From a371eb06fef803dcf9894fa0ad6941341887d2d8 Mon Sep 17 00:00:00 2001
> +From: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> +Date: Tue, 19 Apr 2016 12:51:29 +0200
> +Subject: [PATCH 2/3] Expand $(CC) to gcc in x86 mk/cfg/*.cfg
> +
> +Expand $(CC) and friends to gcc and introduce empty CROSS_PREFIX_ in
> +Makefile fragments for cross-compilation of i586, i686 and x86_64 Linux
> +platforms to allow use of Sourcery CodeBench toolchains.
> +
> +Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> +---
> + mk/cfg/i586-unknown-linux-gnu.mk   | 9 +++++----
> + mk/cfg/i686-unknown-linux-gnu.mk   | 9 +++++----
> + mk/cfg/x86_64-unknown-linux-gnu.mk | 9 +++++----
> + 3 files changed, 15 insertions(+), 12 deletions(-)
> +
> +diff --git a/mk/cfg/i586-unknown-linux-gnu.mk b/mk/cfg/i586-unknown-linux-gnu.mk
> +index 0609f36..45af3b8 100644
> +--- a/mk/cfg/i586-unknown-linux-gnu.mk
> ++++ b/mk/cfg/i586-unknown-linux-gnu.mk
> +@@ -1,8 +1,9 @@
> + # i586-unknown-linux-gnu configuration
> +-CC_i586-unknown-linux-gnu=$(CC)

 I guess this makes it unupstreamable, because this will break support for
clang, no?

> +-CXX_i586-unknown-linux-gnu=$(CXX)
> +-CPP_i586-unknown-linux-gnu=$(CPP)
> +-AR_i586-unknown-linux-gnu=$(AR)
> ++CROSS_PREFIX_i686-unknown-linux-gnu=
                  ^5

> ++CC_i586-unknown-linux-gnu=gcc
> ++CXX_i586-unknown-linux-gnu=g++
> ++CPP_i586-unknown-linux-gnu=gcc -E
> ++AR_i586-unknown-linux-gnu=ar
> + CFG_LIB_NAME_i586-unknown-linux-gnu=lib$(1).so
> + CFG_STATIC_LIB_NAME_i586-unknown-linux-gnu=lib$(1).a
> + CFG_LIB_GLOB_i586-unknown-linux-gnu=lib$(1)-*.so
> +diff --git a/mk/cfg/i686-unknown-linux-gnu.mk b/mk/cfg/i686-unknown-linux-gnu.mk
> +index 88c0907..aa4ce42 100644
> +--- a/mk/cfg/i686-unknown-linux-gnu.mk
> ++++ b/mk/cfg/i686-unknown-linux-gnu.mk
> +@@ -1,8 +1,9 @@
> + # i686-unknown-linux-gnu configuration
> +-CC_i686-unknown-linux-gnu=$(CC)
> +-CXX_i686-unknown-linux-gnu=$(CXX)
> +-CPP_i686-unknown-linux-gnu=$(CPP)
> +-AR_i686-unknown-linux-gnu=$(AR)
> ++CROSS_PREFIX_i686-unknown-linux-gnu=
> ++CC_i686-unknown-linux-gnu=gcc
> ++CXX_i686-unknown-linux-gnu=g++
> ++CPP_i686-unknown-linux-gnu=gcc -E
> ++AR_i686-unknown-linux-gnu=ar
> + CFG_LIB_NAME_i686-unknown-linux-gnu=lib$(1).so
> + CFG_STATIC_LIB_NAME_i686-unknown-linux-gnu=lib$(1).a
> + CFG_LIB_GLOB_i686-unknown-linux-gnu=lib$(1)-*.so
> +diff --git a/mk/cfg/x86_64-unknown-linux-gnu.mk b/mk/cfg/x86_64-unknown-linux-gnu.mk
> +index 044c687..bdd88cd 100644
> +--- a/mk/cfg/x86_64-unknown-linux-gnu.mk
> ++++ b/mk/cfg/x86_64-unknown-linux-gnu.mk
> +@@ -1,8 +1,9 @@
> + # x86_64-unknown-linux-gnu configuration
> +-CC_x86_64-unknown-linux-gnu=$(CC)
> +-CXX_x86_64-unknown-linux-gnu=$(CXX)
> +-CPP_x86_64-unknown-linux-gnu=$(CPP)
> +-AR_x86_64-unknown-linux-gnu=$(AR)
> ++CROSS_PREFIX_x86_64-unknown-linux-gnu=
> ++CC_x86_64-unknown-linux-gnu=gcc
> ++CXX_x86_64-unknown-linux-gnu=g++
> ++CPP_x86_64-unknown-linux-gnu=gcc -E
> ++AR_x86_64-unknown-linux-gnu=ar
> + CFG_LIB_NAME_x86_64-unknown-linux-gnu=lib$(1).so
> + CFG_STATIC_LIB_NAME_x86_64-unknown-linux-gnu=lib$(1).a
> + CFG_LIB_GLOB_x86_64-unknown-linux-gnu=lib$(1)-*.so
> +--
> +2.1.4
> +
> diff --git a/package/rust/0003-Fix-CPP-declaration-in-mipsel-unknown-linux-gnu.mk.patch b/package/rust/0003-Fix-CPP-declaration-in-mipsel-unknown-linux-gnu.mk.patch
> new file mode 100644
> index 0000000..00d338f
> --- /dev/null
> +++ b/package/rust/0003-Fix-CPP-declaration-in-mipsel-unknown-linux-gnu.mk.patch
> @@ -0,0 +1,26 @@
> +From f6d8c8f6dcdbabead3a06ed8f592143afaad16ba Mon Sep 17 00:00:00 2001
> +From: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> +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 <eric.le.bihan.dev@free.fr>
> +---
> + 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
> +
> diff --git a/package/rust/Config.in.host b/package/rust/Config.in.host
> new file mode 100644
> index 0000000..ca11d38
> --- /dev/null
> +++ b/package/rust/Config.in.host
> @@ -0,0 +1,14 @@
> +config BR2_PACKAGE_HOST_RUST_ARCH_SUPPORTS
> +	bool
> +	default y
> +	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
> +	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

 So ARMV7M is OK?

 I also think it depends on !BR2_x86_i486.

> +	depends on BR2_TOOLCHAIN_USES_GLIBC
> +	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
> +
> +comment "host-rust needs a toolchain w/ gcc >= 5"
> +	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5 && BR2_aarch64
> diff --git a/package/rust/rust-target-gen b/package/rust/rust-target-gen
[snip]
> diff --git a/package/rust/rust.mk b/package/rust/rust.mk
> new file mode 100644
> index 0000000..7126d23
> --- /dev/null
> +++ b/package/rust/rust.mk
> @@ -0,0 +1,67 @@
> +################################################################################
> +#
> +# rust
> +#
> +################################################################################
> +
> +RUST_VERSION = 1.10.0
> +RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.gz
> +RUST_SITE = https://static.rust-lang.org/dist
> +RUST_LICENSE = Apache-2.0, MIT

 Can you specify which license applies to what?

> +RUST_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
> +
> +HOST_RUST_DEPENDENCIES = host-rust-bootstrap host-python toolchain host-jemalloc

 We'll probably want to unbundle llvm eventually. But I'm OK with doing that
later, as part as introducing llvm support in buildroot.

> +
> +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 \

 I think it would fit more under staging dir. E.g. we put toolchainfile.cmake
under $(STAGING_DIR)/usr/share/buildroot, this one is a bit similar.

> +		$(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 = $(if $(VERBOSE),VERBOSE=1)
> +
> +# Though not using autotools, Rust follows the ./configure convention, in its
> +# own way...
> +define HOST_RUST_CONFIGURE_CMDS
> +	(cd $(@D); $(HOST_CONFIGURE_OPTS) \
> +		./configure \
> +		--target=$(GNU_TARGET_NAME) \
> +		--prefix="$(HOST_DIR)/usr" \
> +		--jemalloc-root="$(HOST_DIR)/usr/lib" \
> +		--enable-local-rust \
> +		--local-rust-root="$(HOST_RUST_BOOTSTRAP_DIR)/rustc" \
> +		--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")

 Could we conditionally add --enable-ccache (and pass CCACHE=...) ?


 Regards,
 Arnout

> +endef
> +
> +define HOST_RUST_BUILD_CMDS
> +	$(HOST_MAKE_ENV) $(HOST_RUST_MAKE_ENV) $(MAKE) \
> +		$(HOST_RUST_MAKE_OPTS) -C $(@D)
> +endef
> +
> +define HOST_RUST_INSTALL_CMDS
> +	$(HOST_MAKE_ENV) $(HOST_RUST_MAKE_ENV) $(MAKE) \
> +		$(HOST_RUST_MAKE_OPTS) -C $(@D) install
> +endef
> +
> +$(eval $(host-generic-package))
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [Patch v3 1/2] rust-bootstrap: new package
  2016-10-16 11:27   ` Arnout Vandecappelle
@ 2016-10-18 20:47     ` Eric Le Bihan
  2016-10-18 22:09       ` Arnout Vandecappelle
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Le Bihan @ 2016-10-18 20:47 UTC (permalink / raw)
  To: buildroot

Hi!

On 16-10-16 13:27:51, Arnout Vandecappelle wrote:
>
>
> On 15-07-16 00:01, Eric Le Bihan wrote:

[...]

> > +
> > +RUST_BOOTSTRAP_VERSION = 1.9.0
> > +RUST_BOOTSTRAP_DATE = 2016-05-24
> > +
> > +ifeq ($(HOSTARCH),x86_64)
> > +RUST_BOOTSTRAP_ARCH = x86_64
> > +else ifeq ($(HOSTARCH),x86)
> > +RUST_BOOTSTRAP_ARCH = i686
> > +else
> > +$(error Unsupported host architecture)
>
>  This is not good because it is evaluated even if host-rust-bootstrap is not
> selected. You need to protect it somehow, which is difficult because there is no
> user visible symbol that can ever select this package. So instead you could do a
> check in e.g. CONFIGURE_CMDS.
>
>  However, this is not needed, because this package can only be built if rust is
> built, and rust can only be built if BR2_PACKAGE_HOST_RUST_ARCH_SUPPORTS=y, and
> that one already checks for hostarch.
>
>  IOW, just drop this check.

OK.

> > +endif
> > +
> > +RUST_BOOTSTRAP_SITE = https://static.rust-lang.org/dist/$(RUST_BOOTSTRAP_DATE)
> > +
> > +RUST_BOOTSTRAP_SOURCE = rustc-$(RUST_BOOTSTRAP_VERSION)-$(RUST_BOOTSTRAP_ARCH)-unknown-linux-gnu.tar.gz
> > +RUST_BOOTSTRAP_LICENSE = Apache-2.0, MIT
>
>  Can you specify which parts or under which license?

Rust is dual licensed (Apache-2.0 OR MIT). So, I'll change it to:

RUST_BOOTSTRAP_LICENSE = Dual Apache-2.0/MIT

I'll do the same for the rust package.

Thanks for the review.

Best regards,

--
ELB

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [Patch v3 1/2] rust-bootstrap: new package
  2016-10-18 20:47     ` Eric Le Bihan
@ 2016-10-18 22:09       ` Arnout Vandecappelle
  2016-10-19  6:17         ` Eric Le Bihan
  0 siblings, 1 reply; 8+ messages in thread
From: Arnout Vandecappelle @ 2016-10-18 22:09 UTC (permalink / raw)
  To: buildroot



On 18-10-16 22:47, Eric Le Bihan wrote:
> Hi!
> 
> On 16-10-16 13:27:51, Arnout Vandecappelle wrote:
>>
>>
>> On 15-07-16 00:01, Eric Le Bihan wrote:
[snip]
>>> +RUST_BOOTSTRAP_LICENSE = Apache-2.0, MIT
>>
>>  Can you specify which parts or under which license?
> 
> Rust is dual licensed (Apache-2.0 OR MIT). So, I'll change it to:
> 
> RUST_BOOTSTRAP_LICENSE = Dual Apache-2.0/MIT

 No, it should be

RUST_BOOTSTRAP_LICENSE = Apache-2.0 or MIT

See the example in the manual under the generic package infra [1].


 Regards,
 Arnout

[1] https://buildroot.org/downloads/manual/manual.html#generic-package-reference

> 
> I'll do the same for the rust package.
> 
> Thanks for the review.
> 
> Best regards,
> 
> --
> ELB
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [Patch v3 1/2] rust-bootstrap: new package
  2016-10-18 22:09       ` Arnout Vandecappelle
@ 2016-10-19  6:17         ` Eric Le Bihan
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Le Bihan @ 2016-10-19  6:17 UTC (permalink / raw)
  To: buildroot

On 16-10-19 00:09:30, Arnout Vandecappelle wrote:
>
>
> On 18-10-16 22:47, Eric Le Bihan wrote:
> > Hi!
> >
> > On 16-10-16 13:27:51, Arnout Vandecappelle wrote:
> >>
> >>
> >> On 15-07-16 00:01, Eric Le Bihan wrote:
> [snip]
> >>> +RUST_BOOTSTRAP_LICENSE = Apache-2.0, MIT
> >>
> >>  Can you specify which parts or under which license?
> >
> > Rust is dual licensed (Apache-2.0 OR MIT). So, I'll change it to:
> >
> > RUST_BOOTSTRAP_LICENSE = Dual Apache-2.0/MIT
>
>  No, it should be
>
> RUST_BOOTSTRAP_LICENSE = Apache-2.0 or MIT
>
> See the example in the manual under the generic package infra [1].

Right. I should have read the manual instead of sampling packages.
The following ones currently use "FOO_LICENSE = Dual first/second":

- libsamplerate
- nettle
- freetype

I'll send a patch to make them compliant. Looking at the manual [1], I do
not see what should be used for "proprietary" or "commercial". So, for
libsamplerate, should I use "LIBSAMPLERATE_LICENSE = GPLv2+ or COMMERCIAL"?

[1] https://buildroot.org/downloads/manual/manual.html#legal-info-list-licenses

Best regards,

--
ELB

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-10-19  6:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-14 22:01 [Buildroot] [Patch v3 0/2] Add support for the Rust programming language Eric Le Bihan
2016-07-14 22:01 ` [Buildroot] [Patch v3 1/2] rust-bootstrap: new package Eric Le Bihan
2016-10-16 11:27   ` Arnout Vandecappelle
2016-10-18 20:47     ` Eric Le Bihan
2016-10-18 22:09       ` Arnout Vandecappelle
2016-10-19  6:17         ` Eric Le Bihan
2016-07-14 22:01 ` [Buildroot] [Patch v3 2/2] rust: " Eric Le Bihan
2016-10-16 15:28   ` Arnout Vandecappelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.