Move the cargo and rust recipes from 'recipes' to 'recipes-devtools'

This commit is contained in:
Derek Straka
2016-02-19 19:10:12 -05:00
parent c4a3f15a8c
commit e76332d732
36 changed files with 1 additions and 1 deletions
@@ -0,0 +1,58 @@
From c7daec775a917d9e3017bc35ea7d88cc9418f181 Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Mon, 2 Mar 2015 13:27:49 -0500
Subject: [PATCH] add option to disable rewriting of install paths
This is intended for use by rust & cargo's `make install`, as in that
case:
- these paths are typically built into the pre-install layout already
- attempting to do the replacement will be incorrect subdirectory
cases (ie: libdir=lib/foo)
---
install-template.sh | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/install-template.sh b/install-template.sh
index 042b955..4ecf430 100644
--- a/install-template.sh
+++ b/install-template.sh
@@ -618,16 +618,18 @@ install_components() {
# Decide the destination of the file
local _file_install_path="$_dest_prefix/$_file"
- if echo "$_file" | grep "^lib/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^lib\///')"
- _file_install_path="$CFG_LIBDIR/$_f"
- fi
+ if [ -n "${CFG_REWRITE_PATHS-}" ]; then
+ if echo "$_file" | grep "^lib/" > /dev/null
+ then
+ local _f="$(echo "$_file" | sed 's/^lib\///')"
+ _file_install_path="$CFG_LIBDIR/$_f"
+ fi
- if echo "$_file" | grep "^share/man/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^share\/man\///')"
- _file_install_path="$CFG_MANDIR/$_f"
+ if echo "$_file" | grep "^share/man/" > /dev/null
+ then
+ local _f="$(echo "$_file" | sed 's/^share\/man\///')"
+ _file_install_path="$CFG_MANDIR/$_f"
+ fi
fi
# Make sure there's a directory for it
@@ -810,6 +812,7 @@ valopt mandir "$CFG_DESTDIR_PREFIX/share/man" "install man pages in PATH"
opt ldconfig 1 "run ldconfig after installation (Linux only)"
opt verify 1 "obsolete"
flag verbose "run with verbose output"
+opt rewrite-paths 1 "rewrite install paths for libdir & mandir"
if [ $HELP -eq 1 ]
then
--
2.4.1
@@ -0,0 +1,11 @@
+++ llvm/src/llvm/include/llvm/CodeGen/CommandFlags.h.orig 2016-01-18 19:18:03.847470845 +0000
+++ llvm/src/llvm/include/llvm/CodeGen/CommandFlags.h 2016-01-18 19:18:11.211408270 +0000
@@ -21,7 +21,7 @@
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/MC/MCTargetOptionsCommandFlags.h"
-#include "llvm//MC/SubtargetFeature.h"
+#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Host.h"
@@ -0,0 +1,27 @@
From af2eaed835d3b717552ea83e75f4c5e86e614979 Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Sat, 15 Nov 2014 20:12:48 -0500
Subject: [PATCH 1/9] platform.mk: avoid choking on i586
---
mk/platform.mk | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mk/platform.mk b/mk/platform.mk
index 856a22d..0c90632 100644
--- a/mk/platform.mk
+++ b/mk/platform.mk
@@ -14,7 +14,9 @@
# would create a variable HOST_i686-darwin-macos with the value
# i386.
define DEF_HOST_VAR
- HOST_$(1) = $(subst i686,i386,$(word 1,$(subst -, ,$(1))))
+ HOST_$(1) = $(subst i686,i386,\
+ $(subst i586,i386,\
+ $(word 1,$(subst -, ,$(1)))))
endef
$(foreach t,$(CFG_TARGET),$(eval $(call DEF_HOST_VAR,$(t))))
$(foreach t,$(CFG_TARGET),$(info cfg: host for $(t) is $(HOST_$(t))))
--
2.4.10
@@ -0,0 +1,109 @@
From 632d71477fdecb18852812d86b8e2ee1e33c521b Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Tue, 18 Nov 2014 01:40:21 -0500
Subject: [PATCH 2/9] Target: add default target.json path:
$libdir/rust/targets
---
src/librustc/session/config.rs | 6 +++---
src/librustc/session/mod.rs | 8 ++++++--
src/librustc_back/target/mod.rs | 14 +++++++++++---
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index 7e8104d..ecb38d4 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -36,7 +36,7 @@ use getopts;
use std::collections::HashMap;
use std::env;
use std::fmt;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use llvm;
@@ -653,8 +653,8 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig {
v
}
-pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
- let target = match Target::search(&opts.target_triple) {
+pub fn build_target_config(sysroot: &Path, opts: &Options, sp: &SpanHandler) -> Config {
+ let target = match Target::search(sysroot, &opts.target_triple[..]) {
Ok(t) => t,
Err(e) => {
sp.handler().fatal(&format!("Error loading target specification: {}", e));
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index 0a1df25..ad223d5 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -412,14 +412,18 @@ pub fn build_session_(sopts: config::Options,
local_crate_source_file: Option<PathBuf>,
span_diagnostic: diagnostic::SpanHandler)
-> Session {
- let host = match Target::search(config::host_triple()) {
+ let sysroot = match sopts.maybe_sysroot {
+ Some(ref x) => PathBuf::from(x),
+ None => filesearch::get_or_default_sysroot()
+ };
+ let host = match Target::search(&sysroot, config::host_triple()) {
Ok(t) => t,
Err(e) => {
span_diagnostic.handler()
.fatal(&format!("Error loading host specification: {}", e));
}
};
- let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
+ let target_cfg = config::build_target_config(&sysroot, &sopts, &span_diagnostic);
let p_s = parse::ParseSess::with_span_handler(span_diagnostic);
let default_sysroot = match sopts.maybe_sysroot {
Some(_) => None,
diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs
index 6ae7435..3ffa484 100644
--- a/src/librustc_back/target/mod.rs
+++ b/src/librustc_back/target/mod.rs
@@ -49,6 +49,8 @@ use serialize::json::Json;
use std::default::Default;
use std::io::prelude::*;
use syntax::{diagnostic, abi};
+use std::borrow::ToOwned;
+use std::path::Path;
mod android_base;
mod apple_base;
@@ -346,12 +348,13 @@ impl Target {
///
/// The error string could come from any of the APIs called, including
/// filesystem access and JSON decoding.
- pub fn search(target: &str) -> Result<Target, String> {
+ pub fn search(sysroot: &Path, target: &str) -> Result<Target, String> {
use std::env;
use std::ffi::OsString;
use std::fs::File;
use std::path::{Path, PathBuf};
use serialize::json;
+ use std::iter::IntoIterator;
fn load_file(path: &Path) -> Result<Target, String> {
let mut f = try!(File::open(path).map_err(|e| e.to_string()));
@@ -447,9 +450,14 @@ impl Target {
let target_path = env::var_os("RUST_TARGET_PATH")
.unwrap_or(OsString::new());
- // FIXME 16351: add a sane default search path?
+ let mut default_path = sysroot.to_owned();
+ default_path.push(env!("CFG_LIBDIR_RELATIVE"));
+ default_path.push("rustlib");
- for dir in env::split_paths(&target_path) {
+ let paths = env::split_paths(&target_path)
+ .chain(Some(default_path).into_iter());
+
+ for dir in paths {
let p = dir.join(&path);
if p.is_file() {
return load_file(&p);
--
2.4.10
@@ -0,0 +1,67 @@
From b544f5bfa38d5932db23214e168988d05cbc5620 Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Tue, 18 Nov 2014 14:52:56 -0500
Subject: [PATCH 3/9] mk: for stage0, use RUSTFLAGS to override target libs dir
Setting HLIB specially for stage0 (and even more specially for windows)
also affects the location we place TLIB. To keep the TLIBs we build in
the place requested by configure, use '-L' and '--sysroot' to point
stage0-rustc at the appropriate location.
---
mk/main.mk | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/mk/main.mk b/mk/main.mk
index 34f8247..896c1df 100644
--- a/mk/main.mk
+++ b/mk/main.mk
@@ -376,21 +376,22 @@ define SREQ
# Destinations of artifacts for the host compiler
HROOT$(1)_H_$(3) = $(3)/stage$(1)
HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
-ifeq ($$(CFG_WINDOWSY_$(3)),1)
-HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
-else
-ifeq ($(1),0)
-HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/lib
-else
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
-endif
-endif
# Destinations of artifacts for target architectures
TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustlib/$(2)
TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib
+# Don't trust stage0, be explicit about libraries
+# TODO: rather than specifying sysroot, we really want to tell which libdir to
+# use (ie: the dir containing 'rustlib'). This would allow us to avoid
+# passing the '-L' options.
+ifeq ($(1),0)
+RUSTFLAGS_S_$(1)_T_$(2)_H_$(3) += --sysroot "$$(HROOT$(1)_H_$(3))" \
+ -L "$$(TLIB$(1)_T_$(2)_H_$(3))"
+endif
+
# Preqrequisites for using the stageN compiler
ifeq ($(1),0)
HSREQ$(1)_H_$(3) = $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))
@@ -502,6 +503,7 @@ STAGE$(1)_T_$(2)_H_$(3) := \
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
--cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
$$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
+ $$(RUSTFLAGS_S_$(1)_T_$(2)_H_$(3)) \
$$(RUSTC_FLAGS_$(2))
PERF_STAGE$(1)_T_$(2)_H_$(3) := \
@@ -510,6 +512,7 @@ PERF_STAGE$(1)_T_$(2)_H_$(3) := \
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
--cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
$$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
+ $$(RUSTFLAGS_S_$(1)_T_$(2)_H_$(3)) \
$$(RUSTC_FLAGS_$(2))
endef
--
2.4.10
@@ -0,0 +1,27 @@
From 004ddead436887fe99bfa9d0d25f6cdaf9f6148b Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Tue, 18 Nov 2014 13:48:14 -0500
Subject: [PATCH 4/9] mk: add missing CFG_LIBDIR_RELATIVE
---
mk/grammar.mk | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mk/grammar.mk b/mk/grammar.mk
index 0d527bd..926f247 100644
--- a/mk/grammar.mk
+++ b/mk/grammar.mk
@@ -11,8 +11,8 @@
BG = $(CFG_BUILD_DIR)/grammar/
SG = $(S)src/grammar/
B = $(CFG_BUILD_DIR)/$(CFG_BUILD)/stage2/
-L = $(B)lib/rustlib/$(CFG_BUILD)/lib
-LD = $(CFG_BUILD)/stage2/lib/rustlib/$(CFG_BUILD)/lib/
+L = $(B)$(CFG_LIBDIR_RELATIVE)/rustlib/$(CFG_BUILD)/lib
+LD = $(CFG_BUILD)/stage2/$(CFG_LIBDIR_RELATIVE)/rustlib/$(CFG_BUILD)/lib/
RUSTC = $(STAGE2_T_$(CFG_BUILD)_H_$(CFG_BUILD))
ifeq ($(CFG_OSTYPE),apple-darwin)
FLEX_LDFLAGS=-ll
--
2.4.10
@@ -0,0 +1,362 @@
From 1197d6ec82df147e8bbe0d42017fe1ee75804369 Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Mon, 24 Nov 2014 13:10:15 -0500
Subject: [PATCH 5/9] configure: support --bindir, and extend libdir to
non-blessed dirs
Adds --bindir, and:
Allows --bindir and --libdir to have multiple elements in their paths
relative to sysroot, and allows libdir to end in an arbitrary directory
(previously it was limited to lib, lib32, and lib64).
Note that this assumes absolute paths start with '/', which may break
windows platforms
---
configure | 49 ++++++++++++++++------
mk/host.mk | 6 ++-
mk/main.mk | 11 +++++
mk/perf.mk | 4 +-
mk/prepare.mk | 4 +-
src/librustc/metadata/filesearch.rs | 84 ++++++++++++++-----------------------
src/librustc_trans/back/link.rs | 3 +-
7 files changed, 90 insertions(+), 71 deletions(-)
diff --git a/configure b/configure
index 60d3661..01c447b 100755
--- a/configure
+++ b/configure
@@ -334,6 +334,31 @@ enable_if_not_disabled() {
fi
}
+abspath () {
+ case "$1" in
+ /*) echo "$1" ;;
+ *) echo "$PWD/$1" ;;
+ esac
+}
+
+relpath () {
+ local src=$(abspath "$1")
+ local dst=$(abspath "$2")
+ local common=$src
+ local result=
+
+ # Start by checking if the whole src is common, then strip off pack
+ # components until we find the common element.
+ while [ "${dst#"$common"}" = "$dst" ]; do
+ common=$(dirname "$common")
+ result="../$result"
+ done
+
+ local down="${dst#"$common"}"
+ result="${result}${down#/}"
+ echo "$result"
+}
+
to_llvm_triple() {
case $1 in
i686-w64-mingw32) echo i686-pc-windows-gnu ;;
@@ -632,6 +657,8 @@ putvar CFG_BUILD # Yes, this creates a duplicate entry, but the last one wins.
CFG_HOST=$(to_llvm_triple $CFG_HOST)
CFG_TARGET=$(to_llvm_triple $CFG_TARGET)
+CFG_LIBDIR_RELATIVE=lib
+
# On windows we just store the libraries in the bin directory because
# there's no rpath. This is where the build system itself puts libraries;
# --libdir is used to configure the installation directory.
@@ -639,24 +666,21 @@ CFG_TARGET=$(to_llvm_triple $CFG_TARGET)
if [ "$CFG_OSTYPE" = "pc-windows-gnu" ] || [ "$CFG_OSTYPE" = "pc-windows-msvc" ]
then
CFG_LIBDIR_RELATIVE=bin
-else
- CFG_LIBDIR_RELATIVE=lib
fi
-valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries (do not set it on windows platform)"
+valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries"
-case "$CFG_LIBDIR" in
- "$CFG_PREFIX"/*) CAT_INC=2;;
- "$CFG_PREFIX"*) CAT_INC=1;;
- *)
- err "libdir must begin with the prefix. Use --prefix to set it accordingly.";;
-esac
+CFG_BINDIR_RELATIVE=bin
+valopt bindir "${CFG_PREFIX}/${CFG_BINDIR_RELATIVE}" "install binaries"
-CFG_LIBDIR_RELATIVE=`echo ${CFG_LIBDIR} | cut -c$((${#CFG_PREFIX}+${CAT_INC}))-`
+# Determine libdir and bindir relative to prefix
+step_msg "calculating relative paths to prefix = ${CFG_PREFIX}"
+CFG_BINDIR_RELATIVE=$(relpath "${CFG_PREFIX}" "${CFG_BINDIR}")
+CFG_LIBDIR_RELATIVE=$(relpath "${CFG_PREFIX}" "${CFG_LIBDIR}")
if ( [ "$CFG_OSTYPE" = "pc-windows-gnu" ] || [ "$CFG_OSTYPE" = "pc-windows-msvc" ] ) \
- && [ "$CFG_LIBDIR_RELATIVE" != "bin" ]; then
- err "libdir on windows should be set to 'bin'"
+ && [ "$CFG_LIBDIR_RELATIVE" != "$CFG_BINDIR_RELATIVE" ]; then
+ err "Windows builds currently require that LIBDIR == BINDIR (we have libdir{$CFG_LIBDIR_RELATIVE} != bindir{$CFG_BINDIR_RELATIVE} )"
fi
if [ $HELP -eq 1 ]
@@ -1733,6 +1757,7 @@ putvar CFG_PREFIX
putvar CFG_HOST
putvar CFG_TARGET
putvar CFG_LIBDIR_RELATIVE
+putvar CFG_BINDIR_RELATIVE
putvar CFG_DISABLE_MANAGE_SUBMODULES
putvar CFG_AARCH64_LINUX_ANDROID_NDK
putvar CFG_ARM_LINUX_ANDROIDEABI_NDK
diff --git a/mk/host.mk b/mk/host.mk
index 59a0095..b8e8345 100644
--- a/mk/host.mk
+++ b/mk/host.mk
@@ -59,9 +59,13 @@ endef
# $(4) - the host triple (same as $(3))
define CP_HOST_STAGE_N
-ifneq ($(CFG_LIBDIR_RELATIVE),bin)
$$(HLIB$(2)_H_$(4))/:
@mkdir -p $$@
+
+# Avoid redefinition warnings if libdir==bindir
+ifneq ($(HBIN$(2)_H_$(4)),$(HLIB$(2)_H_$(4)))
+$$(HBIN$(2)_H_$(4))/:
+ @mkdir -p $$@
endif
endef
diff --git a/mk/main.mk b/mk/main.mk
index 896c1df..ab12166 100644
--- a/mk/main.mk
+++ b/mk/main.mk
@@ -345,7 +345,9 @@ export CFG_RELEASE_CHANNEL
export CFG_LLVM_ROOT
export CFG_PREFIX
export CFG_LIBDIR
+export CFG_BINDIR
export CFG_LIBDIR_RELATIVE
+export CFG_BINDIR_RELATIVE
export CFG_DISABLE_INJECT_STD_VERSION
ifdef CFG_DISABLE_UNSTABLE_FEATURES
CFG_INFO := $(info cfg: disabling unstable features (CFG_DISABLE_UNSTABLE_FEATURES))
@@ -375,7 +377,16 @@ define SREQ
# Destinations of artifacts for the host compiler
HROOT$(1)_H_$(3) = $(3)/stage$(1)
+
+ifeq ($(1)-$(3),0-$$(CFG_BUILD))
+# stage0 relative paths are fixed so we can bootstrap from snapshots
+# (downloaded snapshots drop their rustc in HROOT/bin)
+# libdir discrepancy is worked around with RUSTFLAGS below.
HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
+else
+HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_BINDIR_RELATIVE)
+endif
+
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
# Destinations of artifacts for target architectures
diff --git a/mk/perf.mk b/mk/perf.mk
index 16cbaab..f8a354c 100644
--- a/mk/perf.mk
+++ b/mk/perf.mk
@@ -10,13 +10,13 @@
ifdef CFG_PERF_TOOL
-rustc-perf$(X): $(CFG_BUILD)/stage2/bin/rustc$(X_$(CFG_BUILD))
+rustc-perf$(X): $(CFG_BUILD)/stage2/$(CFG_BINDIR_RELATIVE)/rustc$(X_$(CFG_BUILD))
@$(call E, perf compile: $@)
$(PERF_STAGE2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
-o $@ $(COMPILER_CRATE) >rustc-perf.err 2>&1
$(Q)rm -f $(LIBRUSTC_GLOB)
else
-rustc-perf$(X): $(CFG_BUILD)/stage2/bin/rustc$(X_$(CFG_BUILD))
+rustc-perf$(X): $(CFG_BUILD)/stage2/$(CFG_BINDIR_RELATIVE)/rustc$(X_$(CFG_BUILD))
$(Q)touch $@
endif
diff --git a/mk/prepare.mk b/mk/prepare.mk
index e263a6d..45590ab 100644
--- a/mk/prepare.mk
+++ b/mk/prepare.mk
@@ -186,10 +186,10 @@ INSTALL_DEBUGGER_SCRIPT_COMMANDS=$(if $(findstring windows,$(1)),\
define DEF_PREPARE
prepare-base-$(1)-%: PREPARE_SOURCE_DIR=$$(PREPARE_HOST)/stage$$(PREPARE_STAGE)
-prepare-base-$(1)-%: PREPARE_SOURCE_BIN_DIR=$$(PREPARE_SOURCE_DIR)/bin
+prepare-base-$(1)-%: PREPARE_SOURCE_BIN_DIR=$$(PREPARE_SOURCE_DIR)/$$(CFG_BINDIR_RELATIVE)
prepare-base-$(1)-%: PREPARE_SOURCE_LIB_DIR=$$(PREPARE_SOURCE_DIR)/$$(CFG_LIBDIR_RELATIVE)
prepare-base-$(1)-%: PREPARE_SOURCE_MAN_DIR=$$(S)/man
-prepare-base-$(1)-%: PREPARE_DEST_BIN_DIR=$$(PREPARE_DEST_DIR)/bin
+prepare-base-$(1)-%: PREPARE_DEST_BIN_DIR=$$(PREPARE_DEST_DIR)/$$(CFG_BINDIR_RELATIVE)
prepare-base-$(1)-%: PREPARE_DEST_LIB_DIR=$$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)
prepare-base-$(1)-%: PREPARE_DEST_MAN_DIR=$$(PREPARE_DEST_DIR)/share/man/man1
diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs
index 311ab1c..1b03b1a 100644
--- a/src/librustc/metadata/filesearch.rs
+++ b/src/librustc/metadata/filesearch.rs
@@ -68,8 +68,7 @@ impl<'a> FileSearch<'a> {
if !found {
let rustpath = rust_path();
for path in &rustpath {
- let tlib_path = make_rustpkg_lib_path(
- self.sysroot, path, self.triple);
+ let tlib_path = make_rustpkg_lib_path(path, self.triple);
debug!("is {} in visited_dirs? {}", tlib_path.display(),
visited_dirs.contains(&tlib_path));
@@ -96,7 +95,7 @@ impl<'a> FileSearch<'a> {
where F: FnMut(&Path, PathKind) -> FileMatch
{
self.for_each_lib_search_path(|lib_search_path, kind| {
- debug!("searching {}", lib_search_path.display());
+ info!("searching {}", lib_search_path.display());
match fs::read_dir(lib_search_path) {
Ok(files) => {
let files = files.filter_map(|p| p.ok().map(|s| s.path()))
@@ -157,7 +156,7 @@ impl<'a> FileSearch<'a> {
// Returns a list of directories where target-specific tool binaries are located.
pub fn get_tools_search_paths(&self) -> Vec<PathBuf> {
let mut p = PathBuf::from(self.sysroot);
- p.push(&find_libdir(self.sysroot));
+ p.push(libdir_str());
p.push(&rustlibdir());
p.push(&self.triple);
p.push("bin");
@@ -165,8 +164,8 @@ impl<'a> FileSearch<'a> {
}
}
-pub fn relative_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
- let mut p = PathBuf::from(&find_libdir(sysroot));
+pub fn relative_target_lib_path(target_triple: &str) -> PathBuf {
+ let mut p = PathBuf::from(&libdir_str());
assert!(p.is_relative());
p.push(&rustlibdir());
p.push(target_triple);
@@ -176,17 +175,28 @@ pub fn relative_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf
fn make_target_lib_path(sysroot: &Path,
target_triple: &str) -> PathBuf {
- sysroot.join(&relative_target_lib_path(sysroot, target_triple))
+ sysroot.join(&relative_target_lib_path(target_triple))
}
-fn make_rustpkg_lib_path(sysroot: &Path,
- dir: &Path,
+fn make_rustpkg_lib_path(dir: &Path,
triple: &str) -> PathBuf {
- let mut p = dir.join(&find_libdir(sysroot));
+ let mut p = dir.join(libdir_str());
p.push(triple);
p
}
+pub fn bindir_relative_str() -> &'static str {
+ env!("CFG_BINDIR_RELATIVE")
+}
+
+pub fn bindir_relative_path() -> PathBuf {
+ PathBuf::from(bindir_relative_str())
+}
+
+pub fn libdir_str() -> &'static str {
+ env!("CFG_LIBDIR_RELATIVE")
+}
+
pub fn get_or_default_sysroot() -> PathBuf {
// Follow symlinks. If the resolved path is relative, make it absolute.
fn canonicalize(path: Option<PathBuf>) -> Option<PathBuf> {
@@ -202,7 +212,18 @@ pub fn get_or_default_sysroot() -> PathBuf {
}
match canonicalize(env::current_exe().ok()) {
- Some(mut p) => { p.pop(); p.pop(); p }
+ Some(mut p) => {
+ // Remove the exe name
+ p.pop();
+ let mut rel = bindir_relative_path();
+
+ // Remove a number of elements equal to the number of elements in the bindir relative
+ // path
+ while rel.pop() {
+ p.pop();
+ }
+ p
+ }
None => panic!("can't determine value for sysroot")
}
}
@@ -257,47 +278,6 @@ pub fn rust_path() -> Vec<PathBuf> {
env_rust_path
}
-// The name of the directory rustc expects libraries to be located.
-// On Unix should be "lib", on windows "bin"
-#[cfg(unix)]
-fn find_libdir(sysroot: &Path) -> String {
- // FIXME: This is a quick hack to make the rustc binary able to locate
- // Rust libraries in Linux environments where libraries might be installed
- // to lib64/lib32. This would be more foolproof by basing the sysroot off
- // of the directory where librustc is located, rather than where the rustc
- // binary is.
- //If --libdir is set during configuration to the value other than
- // "lib" (i.e. non-default), this value is used (see issue #16552).
-
- match option_env!("CFG_LIBDIR_RELATIVE") {
- Some(libdir) if libdir != "lib" => return libdir.to_string(),
- _ => if sysroot.join(&primary_libdir_name()).join(&rustlibdir()).exists() {
- return primary_libdir_name();
- } else {
- return secondary_libdir_name();
- }
- }
-
- #[cfg(target_pointer_width = "64")]
- fn primary_libdir_name() -> String {
- "lib64".to_string()
- }
-
- #[cfg(target_pointer_width = "32")]
- fn primary_libdir_name() -> String {
- "lib32".to_string()
- }
-
- fn secondary_libdir_name() -> String {
- "lib".to_string()
- }
-}
-
-#[cfg(windows)]
-fn find_libdir(_sysroot: &Path) -> String {
- "bin".to_string()
-}
-
// The name of rustc's own place to organize libraries.
// Used to be "rustc", now the default is "rustlib"
pub fn rustlibdir() -> String {
diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs
index 6171ff1..32f41ff 100644
--- a/src/librustc_trans/back/link.rs
+++ b/src/librustc_trans/back/link.rs
@@ -1033,11 +1033,10 @@ fn link_args(cmd: &mut Linker,
// where extern libraries might live, based on the
// addl_lib_search_paths
if sess.opts.cg.rpath {
- let sysroot = sess.sysroot();
let target_triple = &sess.opts.target_triple;
let mut get_install_prefix_lib_path = || {
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
- let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
+ let tlib = filesearch::relative_target_lib_path(target_triple);
let mut path = PathBuf::from(install_prefix);
path.push(&tlib);
--
2.4.10
@@ -0,0 +1,25 @@
From 68662f758244a476b64b0772d93c7a1731e9d1ad Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Wed, 3 Dec 2014 19:15:19 -0500
Subject: [PATCH 6/9] std/thread_local: workaround for NULL __dso_handle
---
src/libstd/thread/local.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs
index c204f79..b2f6f1d 100644
--- a/src/libstd/thread/local.rs
+++ b/src/libstd/thread/local.rs
@@ -338,7 +338,7 @@ mod imp {
#[linkage = "extern_weak"]
static __cxa_thread_atexit_impl: *const libc::c_void;
}
- if !__cxa_thread_atexit_impl.is_null() {
+ if !__cxa_thread_atexit_impl.is_null() && !__dso_handle.is_null() {
type F = unsafe extern fn(dtor: unsafe extern fn(*mut u8),
arg: *mut u8,
dso_handle: *mut u8) -> libc::c_int;
--
2.4.10
@@ -0,0 +1,30 @@
From be3663fcd9ae11a207b3c1649917bfff3c69b1c4 Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Mon, 2 Mar 2015 13:34:59 -0500
Subject: [PATCH 7/9] mk/install: use disable-rewrite-paths
This stops the install scripts from doing work we've already handled.
Path rewriting is only useful for prepackaged binary installers.
---
mk/install.mk | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mk/install.mk b/mk/install.mk
index 8b81702..4fed072 100644
--- a/mk/install.mk
+++ b/mk/install.mk
@@ -12,7 +12,9 @@ RUN_INSALLER = cd tmp/empty_dir && \
sh ../../tmp/dist/$(1)/install.sh \
--prefix="$(DESTDIR)$(CFG_PREFIX)" \
--libdir="$(DESTDIR)$(CFG_LIBDIR)" \
- --mandir="$(DESTDIR)$(CFG_MANDIR)"
+ --mandir="$(DESTDIR)$(CFG_MANDIR)" \
+ "$(MAYBE_DISABLE_VERIFY)"
+ --disable-rewrite-paths
install:
ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
--
2.4.10
@@ -0,0 +1,28 @@
From d7aa5e6824e8658c01f702259eebac02553fb7b8 Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Tue, 26 May 2015 12:09:36 -0400
Subject: [PATCH 8/9] install: disable ldconfig
---
mk/install.mk | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mk/install.mk b/mk/install.mk
index 4fed072..92e66cd 100644
--- a/mk/install.mk
+++ b/mk/install.mk
@@ -13,8 +13,9 @@ RUN_INSALLER = cd tmp/empty_dir && \
--prefix="$(DESTDIR)$(CFG_PREFIX)" \
--libdir="$(DESTDIR)$(CFG_LIBDIR)" \
--mandir="$(DESTDIR)$(CFG_MANDIR)" \
- "$(MAYBE_DISABLE_VERIFY)"
- --disable-rewrite-paths
+ "$(MAYBE_DISABLE_VERIFY)" \
+ --disable-rewrite-paths \
+ --disable-ldconfig
install:
ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
--
2.4.10
@@ -0,0 +1,28 @@
From e6888f9b888911bdbd52e2ee7c37914ee4cee0e2 Mon Sep 17 00:00:00 2001
From: Steven Walter <swalter@lexmark.com>
Date: Tue, 7 Jul 2015 14:57:42 -0400
Subject: [PATCH 9/9] Remove crate metadata from symbol hashing
---
src/librustc_trans/back/link.rs | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs
index 32f41ff..2a87cd7 100644
--- a/src/librustc_trans/back/link.rs
+++ b/src/librustc_trans/back/link.rs
@@ -212,11 +212,6 @@ fn symbol_hash<'tcx>(tcx: &ty::ctxt<'tcx>,
symbol_hasher.reset();
symbol_hasher.input_str(&link_meta.crate_name);
symbol_hasher.input_str("-");
- symbol_hasher.input_str(link_meta.crate_hash.as_str());
- for meta in tcx.sess.crate_metadata.borrow().iter() {
- symbol_hasher.input_str(&meta[..]);
- }
- symbol_hasher.input_str("-");
symbol_hasher.input(&encoder::encoded_ty(tcx, t));
// Prefix with 'h' so that it never blends into adjacent digits
let mut hash = String::from("h");
--
2.4.10
@@ -0,0 +1,158 @@
From 1bd3ab55ce24b2a54e021ba471a5f934b3b9ad6b Mon Sep 17 00:00:00 2001
From: Steven Walter <swalter@lexmark.com>
Date: Tue, 7 Jul 2015 16:49:44 -0400
Subject: [PATCH 10/12] rustc_trans: make .note.rustc look more like debug info
Mark the global variable as const and private so the resulting section
is not flagged as writable and to avoid putting an unnecessary symbol in
the dynamic table of shared objects.
Unfortunately there doesn't seem to be a way to avoid the section being
marked SHF_ALLOC when declared as a variable in LLVM. Hack around that
by using objcopy to clear the flags on the section before the final
link.
This places the section at the end of the executable so it can be
stripped later without rearranging important code/data sections.
---
mk/platform.mk | 1 +
src/librustc/session/config.rs | 2 ++
src/librustc_back/target/mod.rs | 4 ++++
src/librustc_trans/back/link.rs | 38 ++++++++++++++++++++++++++++++++++++++
src/librustc_trans/trans/base.rs | 3 +++
5 files changed, 48 insertions(+)
diff --git a/mk/platform.mk b/mk/platform.mk
index 0c90632..4681783 100644
--- a/mk/platform.mk
+++ b/mk/platform.mk
@@ -181,6 +181,7 @@ define CFG_MAKE_TOOLCHAIN
AR_$(1)=$(CROSS_PREFIX_$(1))$(AR_$(1))
LINK_$(1)=$(CROSS_PREFIX_$(1))$(LINK_$(1))
RUSTC_CROSS_FLAGS_$(1)=-C linker=$$(call FIND_COMPILER,$$(LINK_$(1))) \
+ -C objcopy=$$(call FIND_COMPILER,$$(OBJCOPY_$(1))) \
-C ar=$$(call FIND_COMPILER,$$(AR_$(1))) $(RUSTC_CROSS_FLAGS_$(1))
RUSTC_FLAGS_$(1)=$$(RUSTC_CROSS_FLAGS_$(1)) $(RUSTC_FLAGS_$(1))
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index ecb38d4..b74b3c4 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -460,6 +460,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
CG_OPTIONS, cg_type_desc, cgsetters,
ar: Option<String> = (None, parse_opt_string,
"tool to assemble archives with"),
+ objcopy: Option<String> = (None, parse_opt_string,
+ "system objcopy for manipulating objects"),
linker: Option<String> = (None, parse_opt_string,
"system linker to link outputs with"),
link_args: Option<Vec<String>> = (None, parse_opt_list,
diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs
index 3ffa484..d52e67c 100644
--- a/src/librustc_back/target/mod.rs
+++ b/src/librustc_back/target/mod.rs
@@ -110,6 +110,8 @@ pub struct TargetOptions {
/// sysroot folder.
pub pre_link_objects: Vec<String>,
pub post_link_objects: Vec<String>,
+ /// Path to objcopy. Defaults to "objcopy".
+ pub objcopy: String,
/// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults
/// to "default".
pub cpu: String,
@@ -198,6 +200,7 @@ impl Default for TargetOptions {
ar: option_env!("CFG_DEFAULT_AR").unwrap_or("ar").to_string(),
pre_link_args: Vec::new(),
post_link_args: Vec::new(),
+ objcopy: "objcopy".to_string(),
cpu: "generic".to_string(),
features: "".to_string(),
dynamic_linking: false,
@@ -314,6 +317,7 @@ impl Target {
key!(cpu);
key!(ar);
key!(linker);
+ key!(objcopy);
key!(relocation_model);
key!(code_model);
key!(dll_prefix);
diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs
index 2a87cd7..53fa913 100644
--- a/src/librustc_trans/back/link.rs
+++ b/src/librustc_trans/back/link.rs
@@ -393,6 +393,13 @@ fn command_path(sess: &Session) -> OsString {
env::join_paths(new_path).unwrap()
}
+pub fn get_objcopy_prog(sess: &Session) -> String {
+ match sess.opts.cg.objcopy {
+ Some(ref objcopy) => return objcopy.to_string(),
+ None => sess.target.target.options.objcopy.clone(),
+ }
+}
+
pub fn remove(sess: &Session, path: &Path) {
match fs::remove_file(path) {
Ok(..) => {}
@@ -919,6 +926,34 @@ fn link_natively(sess: &Session, dylib: bool,
}
}
+fn fix_meta_section_attributes(sess: &Session, meta_name: &PathBuf) {
+ // First, fix up the note section attributes. We want the SHF_ALLOC and
+ // SHF_WRITE flags to be unset so the section will get placed near the
+ // end along with the debug info. This allows the section to be
+ // stripped later without renumbering important sections that
+ // contain code and data.
+ let objcopy = get_objcopy_prog(sess);
+ let mut o_cmd = Command::new(&objcopy);
+ o_cmd.arg("--rename-section")
+ .arg(".note.rustc=.note.rustc,contents,noload,readonly")
+ .arg(&meta_name);
+ // Invoke objcopy
+ info!("{:?}", o_cmd);
+ match o_cmd.status() {
+ Ok(exitstatus) => {
+ if !exitstatus.success() {
+ sess.err(&format!("objcopy failed with exit code {:?}", exitstatus.code()));
+ sess.note(&format!("{:?}", &o_cmd));
+ }
+ },
+ Err(exitstatus) => {
+ sess.err(&format!("objcopy failed: {}", exitstatus));
+ sess.note(&format!("{:?}", &o_cmd));
+ }
+ }
+ sess.abort_if_errors();
+}
+
fn link_args(cmd: &mut Linker,
sess: &Session,
dylib: bool,
@@ -951,6 +986,9 @@ fn link_args(cmd: &mut Linker,
// executable. This metadata is in a separate object file from the main
// object file, so we link that in here.
if dylib {
+ let meta_name = outputs.with_extension("metadata.o");
+
+ fix_meta_section_attributes(sess, &meta_name);
cmd.add_object(&outputs.with_extension("metadata.o"));
}
diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs
index 14fea61..df019f7 100644
--- a/src/librustc_trans/trans/base.rs
+++ b/src/librustc_trans/trans/base.rs
@@ -2560,6 +2560,9 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &hir::Crate,
};
unsafe {
llvm::LLVMSetInitializer(llglobal, llconst);
+ llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
+ llvm::LLVMSetUnnamedAddr(llglobal, llvm::True);
+ llvm::SetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
let name = loader::meta_section_name(&cx.sess().target.target);
let name = CString::new(name).unwrap();
llvm::LLVMSetSection(llglobal, name.as_ptr())
--
1.9.1
@@ -0,0 +1,78 @@
From 128a81ede6b188637743a37a582b2267a49d0a32 Mon Sep 17 00:00:00 2001
From: Steven Walter <swalter@lexmark.com>
Date: Wed, 18 Nov 2015 08:33:26 -0500
Subject: [PATCH 11/12] Allow overriding crate_hash with -C crate_hash
The current crate hash is not stable from run-to-run. This causes
problems with bitbake; it needs a guarantee that every build with the
same input will generate compatible output, otherwise sstate won't work.
Using -C crate_hash, we can do that by using the bitbake input hash to
determine the crate hash; the bitbake input hash will be stable, but
still different for different rust recipes.
---
src/librustc/session/config.rs | 2 ++
src/librustc_trans/back/link.rs | 26 ++++++++++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index b74b3c4..a11cb90 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -500,6 +500,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
"choose the code model to use (llc -code-model for details)"),
metadata: Vec<String> = (Vec::new(), parse_list,
"metadata to mangle symbol names with"),
+ crate_hash: String = ("".to_string(), parse_string,
+ "override crate hash with given value"),
extra_filename: String = ("".to_string(), parse_string,
"extra data to put in each output filename"),
codegen_units: usize = (1, parse_uint,
diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs
index 53fa913..83619ae 100644
--- a/src/librustc_trans/back/link.rs
+++ b/src/librustc_trans/back/link.rs
@@ -46,7 +46,7 @@ use std::str;
use flate;
use serialize::hex::ToHex;
use syntax::ast;
-use syntax::codemap::Span;
+use syntax::codemap::{Span,BytePos,NO_EXPANSION};
use syntax::parse::token::{self, InternedString};
use syntax::attr::AttrMetaMethods;
@@ -185,9 +185,31 @@ pub fn find_crate_name(sess: Option<&Session>,
pub fn build_link_meta(sess: &Session, krate: &hir::Crate,
name: &str) -> LinkMeta {
+ let crate_hash = if sess.opts.cg.crate_hash != "" {
+ let dummy_span = Span {
+ lo: BytePos(0),
+ hi: BytePos(0),
+ expn_id: NO_EXPANSION
+ };
+ let dummy_module = hir::Mod {
+ inner: dummy_span,
+ items: vec!()
+ };
+ let dummy_krate = hir::Crate {
+ module: dummy_module,
+ attrs: vec!(),
+ config: vec!(),
+ span: dummy_span,
+ exported_macros: vec!()
+ };
+
+ Svh::calculate(&vec!(sess.opts.cg.crate_hash.clone()), &dummy_krate)
+ } else {
+ Svh::calculate(&sess.opts.cg.metadata, krate)
+ };
let r = LinkMeta {
crate_name: name.to_owned(),
- crate_hash: Svh::calculate(&sess.opts.cg.metadata, krate),
+ crate_hash: crate_hash,
};
info!("{:?}", r);
return r;
--
1.9.1
@@ -0,0 +1,25 @@
From d0fa41075317425b01262dd539c01e87e2eaf5f4 Mon Sep 17 00:00:00 2001
From: Steven Walter <swalter@lexmark.com>
Date: Wed, 18 Nov 2015 08:41:17 -0500
Subject: [PATCH 12/12] mk/platform.mk: pass -C crate_hash to builds
bitbake recipe will export FORCE_CRATE_HASH
---
mk/platform.mk | 1 +
1 file changed, 1 insertion(+)
diff --git a/mk/platform.mk b/mk/platform.mk
index 4681783..59aa560 100644
--- a/mk/platform.mk
+++ b/mk/platform.mk
@@ -182,6 +182,7 @@ define CFG_MAKE_TOOLCHAIN
LINK_$(1)=$(CROSS_PREFIX_$(1))$(LINK_$(1))
RUSTC_CROSS_FLAGS_$(1)=-C linker=$$(call FIND_COMPILER,$$(LINK_$(1))) \
-C objcopy=$$(call FIND_COMPILER,$$(OBJCOPY_$(1))) \
+ -C crate_hash=$(FORCE_CRATE_HASH) \
-C ar=$$(call FIND_COMPILER,$$(AR_$(1))) $(RUSTC_CROSS_FLAGS_$(1))
RUSTC_FLAGS_$(1)=$$(RUSTC_CROSS_FLAGS_$(1)) $(RUSTC_FLAGS_$(1))
--
1.9.1
@@ -0,0 +1,56 @@
From 1fbfa088007054c655741e547bb3e72f1d5f1746 Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Thu, 4 Feb 2016 10:44:23 -0500
Subject: [PATCH] mk: allow changing the platform configuration source
directory
---
configure | 4 +++-
mk/platform.mk | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 01c447b..0f004cf 100755
--- a/configure
+++ b/configure
@@ -650,6 +650,7 @@ valopt_nosave local-rust-root "/usr/local" "set prefix for local rust binary"
valopt_nosave host "${CFG_BUILD}" "GNUs ./configure syntax LLVM host triples"
valopt_nosave target "${CFG_HOST}" "GNUs ./configure syntax LLVM target triples"
valopt_nosave mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
+valopt_nosave platform-cfg "${CFG_SRC_DIR}/mk/cfg" "Location platform configuration for non-rust code"
# Temporarily support old triples until buildbots get updated
CFG_BUILD=$(to_llvm_triple $CFG_BUILD)
@@ -1110,7 +1111,7 @@ CFG_MANDIR=${CFG_MANDIR%/}
CFG_HOST="$(echo $CFG_HOST | tr ',' ' ')"
CFG_TARGET="$(echo $CFG_TARGET | tr ',' ' ')"
CFG_SUPPORTED_TARGET=""
-for target_file in ${CFG_SRC_DIR}mk/cfg/*.mk; do
+for target_file in ${CFG_PLATFORM_CFG}/*.mk; do
CFG_SUPPORTED_TARGET="${CFG_SUPPORTED_TARGET} $(basename "$target_file" .mk)"
done
@@ -1763,6 +1764,7 @@ putvar CFG_AARCH64_LINUX_ANDROID_NDK
putvar CFG_ARM_LINUX_ANDROIDEABI_NDK
putvar CFG_I686_LINUX_ANDROID_NDK
putvar CFG_MANDIR
+putvar CFG_PLATFORM_CFG
# Avoid spurious warnings from clang by feeding it original source on
# ccache-miss rather than preprocessed input.
diff --git a/mk/platform.mk b/mk/platform.mk
index 59aa560..a964d6f 100644
--- a/mk/platform.mk
+++ b/mk/platform.mk
@@ -112,7 +112,7 @@ $(foreach cvar,CC CXX CPP CFLAGS CXXFLAGS CPPFLAGS, \
CFG_RLIB_GLOB=lib$(1)-*.rlib
-include $(wildcard $(CFG_SRC_DIR)mk/cfg/*.mk)
+include $(wildcard $(CFG_PLATFORM_CFG)/*.mk)
define ADD_INSTALLED_OBJECTS
INSTALLED_OBJECTS_$(1) += $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
--
2.7.0
+44
View File
@@ -0,0 +1,44 @@
require rust.inc
inherit cross
# Otherwise we'll depend on what we provide
INHIBIT_DEFAULT_RUST_DEPS = "1"
# Unlike native (which nicely maps it's DEPENDS) cross wipes them out completely.
# Generally, we (and cross in general) need the same things that native needs,
# so it might make sense to take it's mapping. For now, though, we just mention
# the bits we need explicitly.
DEPENDS += "rust-llvm-native"
DEPENDS += "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}compilerlibs virtual/libc"
PROVIDES = "virtual/${TARGET_PREFIX}rust"
PN = "rust-cross-${TARGET_ARCH}"
# In the cross compilation case, rustc doesn't seem to get the rpath quite
# right. It manages to include '../../lib/${TARGET_PREFIX}', but doesn't
# include the '../../lib' (ie: relative path from cross_bindir to normal
# libdir. As a result, we end up not being able to properly reference files in normal ${libdir}.
# Most of the time this happens to work fine as the systems libraries are
# subsituted, but sometimes a host system will lack a library, or the right
# version of a library (libtinfo was how I noticed this).
#
# FIXME: this should really be fixed in rust itself.
# FIXME: using hard-coded relative paths is wrong, we should ask bitbake for
# the relative path between 2 of it's vars.
HOST_POST_LINK_ARGS_append = " -Wl,-rpath=../../lib"
BUILD_POST_LINK_ARGS_append = " -Wl,-rpath=../../lib"
# We need the same thing for the calls to the compiler when building the runtime crap
TARGET_CC_ARCH_append = " --sysroot=${STAGING_DIR_TARGET}"
# cross.bbclass is "helpful" and overrides our do_install. Tell it not to.
do_install () {
rust_do_install
}
# using host-strip on target .so files generated by this recipie causes build errors.
# for now, disable stripping.
# A better (but more complex) approach would be to mimic gcc-runtime and build
# the target.so files in a seperate .bb file.
INHIBIT_PACKAGE_STRIP = "1"
INHIBIT_SYSROOT_STRIP = "1"
+9
View File
@@ -0,0 +1,9 @@
require rust-llvm.inc
LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=4c0bc17c954e99fd547528d938832bfa"
do_install_append () {
cd "${B}"
install -d "${D}${bindir}"
install -m755 "Release/bin/FileCheck" "${D}${bindir}"
}
+39
View File
@@ -0,0 +1,39 @@
require rust-shared-source.inc
SUMMARY = "LLVM compiler framework (packaged with rust)"
LICENSE = "NCSA"
S .= "/src/llvm"
inherit autotools
EXTRA_OECONF += "--enable-targets=x86,x86_64,arm,aarch64,mips,powerpc"
EXTRA_OECONF += "--enable-optimized"
EXTRA_OECONF += "--disable-assertions"
EXTRA_OECONF += "--disable-docs"
EXTRA_OECONF += "--enable-bindings=none"
EXTRA_OECONF += "--disable-terminfo"
EXTRA_OECONF += "--disable-zlib"
EXTRA_OECONF += "--disable-libffi"
EXTRA_OECONF += "--enable-keep-symbols"
PACKAGES += "${PN}-data"
# Add the extra locations to avoid the complaints about unpackaged files
FILES_${PN}-data = "${datadir}"
FILES_${PN}-dev += "${libdir}"
do_install_append () {
# Remove the debug info (>2 GB) as part of normal operation
rm -rf ${D}${bindir}/.debug
cd ${D}${bindir}
ln -s *-llc llc
for i in *-llvm-*; do
link=$(echo $i | sed -e 's/.*-llvm-\(.*\)/\1/')
ln -sf $i llvm-$link
done
}
BBCLASSEXTEND = "native"
+6
View File
@@ -0,0 +1,6 @@
SRC_URI = "\
https://static.rust-lang.org/dist/rustc-${PV}-src.tar.gz;name=rust \
"
S = "${WORKDIR}/rustc-${PV}"
@@ -0,0 +1,3 @@
inherit shared-source-use
require rust-version.inc
S .= "/rustc-${PV}"
@@ -0,0 +1,14 @@
## snapshot info taken from rust/src/snapshots.txt
## TODO: find a way to add additional SRC_URIs based on the contents of an
## earlier SRC_URI.
RS_DATE = "2015-08-11"
RS_SRCHASH = "1af31d4"
# linux-x86_64
RS_ARCH = "linux-x86_64"
RS_HASH = "7df8ba9dec63ec77b857066109d4b6250f3d222f"
RUST_SNAPSHOT = "rust-stage0-${RS_DATE}-${RS_SRCHASH}-${RS_ARCH}-${RS_HASH}.tar.bz2"
SRC_URI[rust-snapshot.md5sum] = "53b2e1f553eaeb88e8d60d5380670283"
SRC_URI[rust-snapshot.sha256sum] = "5936f5ec4327d41f3aa9f98cbedebb6fd3d72715f8df578e0c9a669154c80bc3"
+31
View File
@@ -0,0 +1,31 @@
# In order to share the same source between multiple packages (.bb files), we
# unpack and patch the rustc source here into a shared dir.
#
# Take a look at gcc-source.inc for the general structure of this
inherit shared-source-provide
require rust-version.inc
require rust-release.inc
SRC_URI[rust.md5sum] = "234bd912481a04e93b7f2eff0d5b3485"
SRC_URI[rust.sha256sum] = "641037af7b7b6cad0b231cc20671f8a314fbf2f40fc0901d0b877c39fc8da5a0"
LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=eb87dba71cb424233bcce88db3ae2f1a"
SRC_URI_append = "\
file://rust/0001-platform.mk-avoid-choking-on-i586.patch \
file://rust/0002-Target-add-default-target.json-path-libdir-rust-targ.patch \
file://rust/0003-mk-for-stage0-use-RUSTFLAGS-to-override-target-libs-.patch \
file://rust/0004-mk-add-missing-CFG_LIBDIR_RELATIVE.patch \
file://rust/0005-configure-support-bindir-and-extend-libdir-to-non-bl.patch \
file://rust/0006-std-thread_local-workaround-for-NULL-__dso_handle.patch \
file://rust/0007-mk-install-use-disable-rewrite-paths.patch \
file://rust/0008-install-disable-ldconfig.patch \
file://rust/0009-Remove-crate-metadata-from-symbol-hashing.patch \
file://rust/0010-rustc_trans-make-.note.rustc-look-more-like-debug-in.patch \
file://rust/0011-Allow-overriding-crate_hash-with-C-crate_hash.patch \
file://rust/0012-mk-platform.mk-pass-C-crate_hash-to-builds.patch \
file://rust/0013-mk-allow-changing-the-platform-configuration-source-.patch \
file://rust-llvm/0000-rust-llvm-remove-extra-slash.patch \
file://rust-installer/0001-add-option-to-disable-rewriting-of-install-paths.patch;patchdir=src/rust-installer \
"
+6
View File
@@ -0,0 +1,6 @@
# Note: if you adjust this, you'll also need to change the hashes in
# rust-source.bb
SOURCE_NAME = "rust"
PV = "1.5.0"
LICENSE = "MIT | Apache-2.0"
+10
View File
@@ -0,0 +1,10 @@
require rust.inc
DEPENDS += "rust-llvm"
# Otherwise we'll depend on what we provide
INHIBIT_DEFAULT_RUST_DEPS_class-native = "1"
# We don't need to depend on gcc-native because yocto assumes it exists
PROVIDES_class-native = "virtual/${TARGET_PREFIX}rust"
BBCLASSEXTEND = "native"
+461
View File
@@ -0,0 +1,461 @@
# ex: sts=4 et sw=4 ts=8
inherit rust
inherit rust-installer
require rust-shared-source.inc
require rust-snapshot-2015-08-11.inc
LIC_FILES_CHKSUM ="file://COPYRIGHT;md5=eb87dba71cb424233bcce88db3ae2f1a"
SUMMARY = "Rust compiler and runtime libaries"
HOMEPAGE = "http://www.rust-lang.org"
SECTION = "devel"
B = "${WORKDIR}/build"
DEPENDS += "file-native"
# Avoid having the default bitbake.conf disable sub-make parallelization
EXTRA_OEMAKE = ""
PACKAGECONFIG ??= ""
# Controls whether we use the local rust to build.
# By default, we use the rust-snapshot. In some cases (non-supported host
# systems) this may not be possible. In other cases, it might be desirable
# to have rust-cross built using rust-native.
PACKAGECONFIG[local-rust] = ""
SRC_URI += "${@bb.utils.contains('PACKAGECONFIG', 'local-rust', '', 'https://static.rust-lang.org/stage0-snapshots/${RUST_SNAPSHOT};unpack=0;name=rust-snapshot', d)}"
# We generate local targets, and need to be able to locate them
export RUST_TARGET_PATH="${WORKDIR}/targets/"
export FORCE_CRATE_HASH="${BB_TASKHASH}"
# Right now this is focused on arm-specific tune features.
# We get away with this for now as one can only use x86-64 as the build host
# (not arm).
# Note that TUNE_FEATURES is _always_ refering to the target, so we really
# don't want to use this for the host/build.
def llvm_features_from_tune(d):
f = []
feat = d.getVar('TUNE_FEATURES', True)
if not feat:
return ""
feat = frozenset(feat.split())
if 'vfpv4' in feat:
f.append("+vfp4")
if 'vfpv3' in feat:
f.append("+vfp3")
if 'vfpv3d16' in feat:
f.append("+d16")
if 'vfpv2' in feat or 'vfp' in feat:
f.append("+vfp2")
if 'neon' in feat:
f.append("+neon")
if 'aarch64' in feat:
f.append("+v8")
v7=frozenset(['armv7a', 'armv7r', 'armv7m', 'armv7ve'])
if not feat.isdisjoint(v7):
f.append("+v7")
if 'armv6' in feat:
f.append("+v6")
if 'dsp' in feat:
f.append("+dsp")
if d.getVar('ARM_THUMB_OPT', True) is "thumb":
if not feat.isdisjoint(v7):
f.append("+thumb2")
f.append("+thumb-mode")
if 'cortexa5' in feat:
f.append("+a5")
if 'cortexa7' in feat:
f.append("+a7")
if 'cortexa9' in feat:
f.append("+a9")
if 'cortexa15' in feat:
f.append("+a15")
if 'cortexa17' in feat:
f.append("+a17")
# Seems like it could be infered by the lack of vfp options, but we'll
# include it anyhow
if 'soft' in feat:
f.append("+soft-float")
return ','.join(f)
## arm-unknown-linux-gnueabihf
DATA_LAYOUT[arm] = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32"
LLVM_TARGET[arm] = "${RUST_TARGET_SYS}"
TARGET_ENDIAN[arm] = "little"
TARGET_POINTER_WIDTH[arm] = "32"
FEATURES[arm] = "+v6,+vfp2"
PRE_LINK_ARGS[arm] = "-Wl,--as-needed"
DATA_LAYOUT[aarch64] = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-n32:64-S128"
LLVM_TARGET[aarch64] = "aarch64-unknown-linux-gnu"
TARGET_ENDIAN[aarch64] = "little"
TARGET_POINTER_WIDTH[aarch64] = "64"
PRE_LINK_ARGS[aarch64] = "-Wl,--as-needed"
## x86_64-unknown-linux-gnu
DATA_LAYOUT[x86_64] = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
LLVM_TARGET[x86_64] = "x86_64-unknown-linux-gnu"
TARGET_ENDIAN[x86_64] = "little"
TARGET_POINTER_WIDTH[x86_64] = "64"
PRE_LINK_ARGS[x86_64] = "-Wl,--as-needed -m64"
## i686-unknown-linux-gnu
DATA_LAYOUT[i686] = "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
LLVM_TARGET[i686] = "i686-unknown-linux-gnu"
TARGET_ENDIAN[i686] = "little"
TARGET_POINTER_WIDTH[i686] = "32"
PRE_LINK_ARGS[i686] = "-Wl,--as-needed -m32"
## XXX: a bit of a hack so qemux86 builds, clone of i686-unknown-linux-gnu above
DATA_LAYOUT[i586] = "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
LLVM_TARGET[i586] = "i586-unknown-linux-gnu"
TARGET_ENDIAN[i586] = "little"
TARGET_POINTER_WIDTH[i586] = "32"
PRE_LINK_ARGS[i586] = "-Wl,--as-needed -m32"
# enable-new-dtags causes rpaths to be inserted as DT_RUNPATH (as well as
# DT_RPATH), which lets LD_LIBRARY_PATH override them
RPATH_LDFLAGS = "-Wl,--enable-new-dtags"
TARGET_PRE_LINK_ARGS = "${RPATH_LDFLAGS} ${TARGET_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
BUILD_PRE_LINK_ARGS = "${RPATH_LDFLAGS} ${BUILD_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
HOST_PRE_LINK_ARGS = "${RPATH_LDFLAGS} ${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
# These LDFLAGS have '-L' options in them. We need these to come last so they
# don't screw up the link order and pull in the wrong rust build/version.
# TODO: may want to strip out all the '-L' flags entirely here
TARGET_POST_LINK_ARGS = "${TARGET_LDFLAGS}"
BUILD_POST_LINK_ARGS = "${BUILD_LDFLAGS}"
HOST_POST_LINK_ARGS = "${HOST_LDFLAGS}"
def arch_for(d, thing):
return d.getVar('{}_ARCH'.format(thing), True)
def sys_for(d, thing):
return d.getVar('{}_SYS'.format(thing), True)
def prefix_for(d, thing):
return d.getVar('{}_PREFIX'.format(thing), True)
## Note: TOOLCHAIN_OPTIONS is set to "" by native.bbclass and cross.bbclass,
## which prevents us from grabbing them when building a cross compiler (native doesn't matter).
## We workaround this in internal-rust-cross.bbclass.
def cflags_for(d, thing):
cc_arch = d.getVar('{}_CC_ARCH'.format(thing), True) or ""
flags = d.getVar('{}_CFLAGS'.format(thing), True) or ""
tc = d.getVar('TOOLCHAIN_OPTIONS', True) or ""
return ' '.join([cc_arch, flags, tc])
def cxxflags_for(d, thing):
cc_arch = d.getVar('{}_CC_ARCH'.format(thing), True) or ""
flags = d.getVar('{}_CXXFLAGS'.format(thing), True) or ""
tc = d.getVar('TOOLCHAIN_OPTIONS', True) or ""
return ' '.join([cc_arch, flags, tc])
# Convert a normal arch (HOST_ARCH, TARGET_ARCH, BUILD_ARCH, etc) to something
# rust's internals won't choke on.
def arch_to_rust_target_arch(arch):
if arch == "i586" or arch == "i686":
return "x86"
else:
return arch
def as_json(list_):
a = '['
for e in list_:
if type(e) == str:
a += '"{}",'.format(e)
else:
raise Exception
if len(list_):
a = a[:-1]
a += ']'
return a
def post_link_args_for(d, thing, arch):
post_link_args = (d.getVar('{}_POST_LINK_ARGS'.format(thing), True) or "").split()
post_link_args.extend((d.getVarFlag('POST_LINK_ARGS', arch, True) or "").split())
return post_link_args
def pre_link_args_for(d, thing, arch):
ldflags = (d.getVar('{}_PRE_LINK_ARGS'.format(thing), True) or "").split()
ldflags.extend((d.getVarFlag('PRE_LINK_ARGS', arch, True) or "").split())
return ldflags
def ldflags_for(d, thing, arch):
a = pre_link_args_for(d, thing, arch)
a.extend(post_link_args_for(d, thing, arch))
return a
TARGET_LLVM_FEATURES = "${@llvm_features_from_tune(d)}"
TARGET_LLVM_FEATURES_class-cross = "${@llvm_features_from_tune(d)}"
# class-native implies TARGET=HOST, and TUNE_FEATURES only describes the real
# (original) target.
TARGET_LLVM_FEATURES_class-native = ""
def rust_gen_target(d, thing, wd):
arch = arch_for(d, thing)
sys = sys_for(d, thing)
prefix = prefix_for(d, thing)
o = open(wd + sys + '.json', 'w')
data_layout = d.getVarFlag('DATA_LAYOUT', arch, True)
if not data_layout:
bb.utils.fatal("DATA_LAYOUT[{}] required but not set for {}".format(arch, thing))
llvm_target = d.getVarFlag('LLVM_TARGET', arch, True)
target_pointer_width = d.getVarFlag('TARGET_POINTER_WIDTH', arch, True)
endian = d.getVarFlag('TARGET_ENDIAN', arch, True)
prefix = d.getVar('{}_PREFIX'.format(thing), True)
ccache = d.getVar('CCACHE', True)
linker = "{}{}gcc".format(ccache, prefix)
objcopy = "{}objcopy".format(prefix)
features = ""
if thing is "TARGET":
features = d.getVar('TARGET_LLVM_FEATURES', True) or ""
features = features or d.getVarFlag('FEATURES', arch, True) or ""
pre_link_args = pre_link_args_for(d, thing, arch)
post_link_args = post_link_args_for(d, thing, arch)
o.write('''{{
"data-layout": "{}",
"llvm-target": "{}",
"target-endian": "{}",
"target-word-size": "{}",
"target-pointer-width": "{}",
"arch": "{}",
"os": "linux",
"linker": "{}",
"objcopy": "{}",
"features": "{}",
"dynamic-linking": true,
"executables": true,
"morestack": true,
"linker-is-gnu": true,
"has-rpath": true,
"position-independent-executables": true,
"pre-link-args": {},
"post-link-args": {}
}}'''.format(
data_layout,
llvm_target,
endian,
target_pointer_width,
target_pointer_width,
arch_to_rust_target_arch(arch),
linker,
objcopy,
features,
as_json(pre_link_args),
as_json(post_link_args),
))
o.close()
python do_rust_gen_targets () {
wd = d.getVar('WORKDIR', True) + '/targets/'
# It is important 'TARGET' is last here so that it overrides our less
# informed choices for BUILD & HOST if TARGET happens to be the same as
# either of them.
for thing in ['BUILD', 'HOST', 'TARGET']:
bb.debug(1, "rust_gen_target for " + thing)
rust_gen_target(d, thing, wd)
}
addtask rust_gen_targets after do_patch before do_compile
do_rust_gen_targets[dirs] += "${WORKDIR}/targets"
def rust_gen_mk_cfg(d, thing):
''''
Rust's build system adds support for new archs via 2 things:
1. a file in mk/cfg which defines how the runtime libraries are built
2. and rustc arch definition either built into the compiler or supplied as a .json file
This generates a new #1 for the given 'thing' (one of HOST, TARGET, BUILD)
using a "similar" config that rust already supplies as a template.
Note that the configure process also depends on the existence of #1, so we
have to run this before do_configure
'''
import subprocess
rust_base_sys = rust_base_triple(d, thing)
arch = arch_for(d, thing)
sys = sys_for(d, thing)
prefix = prefix_for(d, thing)
llvm_target = d.getVarFlag('LLVM_TARGET', arch, True)
ldflags = ' '.join(ldflags_for(d, thing, arch))
b = d.getVar('WORKDIR', True) + '/mk-cfg/'
o = open(b + sys_for(d, thing) + '.mk', 'w')
i = open(d.getVar('S', True) + '/mk/cfg/' + rust_base_sys + '.mk', 'r')
r = subprocess.call(['sed',
# update all triplets to the new one
'-e', 's/{}/{}/g'.format(rust_base_sys, sys),
# Replace tools with our own (CROSS_PREFIX is appended to all tools
# by rust's build system). We delete and then insert this because not
# all targets define it.
'-e', 's/^CROSS_PREFIX_{}.*$//'.format(sys),
'-e', '2 a CROSS_PREFIX_{} := {}'.format(sys, prefix),
'-e', 's/^CFG_LLVM_TARGET_.*$//',
'-e', '2 a CFG_LLVM_TARGET_{} := {}'.format(sys, llvm_target),
'-e', 's/^CC_{}=.*$/CC_{} := gcc/'.format(sys, sys),
'-e', 's/^CXX_{}.*$/CXX_{} := g++/'.format(sys, sys),
'-e', 's/^CPP_{}.*$/CPP_{} := gcc -E/'.format(sys, sys),
'-e', 's/^AR_{}.*$/AR_{} := ar/'.format(sys, sys),
# Some targets don't have LINK even though it is required to build.
'-e', 's/^LINK_{}.*$//'.format(sys),
'-e', '2 a LINK_{} := gcc'.format(sys),
# Append our flags to the existing ones
'-e', '/^CFG_JEMALLOC_CFLAGS/ s;$; {};'.format(cflags_for(d, thing)),
'-e', '/^CFG_GCCISH_CFLAGS/ s;$; {};'.format(cflags_for(d, thing)),
'-e', '/^CFG_GCCISH_CXXFLAGS/ s;$; {};'.format(cxxflags_for(d, thing)),
'-e', '/^CFG_GCCISH_LINK_FLAGS/ s;$; {};'.format(ldflags),
# May need to add: CFG_LLC_FLAGS_{}
], stdout=o, stdin=i)
if r:
raise Exception
o.write("OBJCOPY_{} := {}objcopy\n".format(sys, prefix))
o.close()
i.close()
python do_rust_arch_fixup () {
for thing in ['BUILD', 'HOST', 'TARGET']:
bb.debug(1, "rust_gen_mk_cfg for " + thing)
rust_gen_mk_cfg(d, thing)
}
addtask rust_arch_fixup before do_configure after do_patch
do_rust_arch_fixup[dirs] += "${WORKDIR}/mk-cfg"
llvmdir = "${STAGING_DIR_NATIVE}/${prefix_native}"
do_configure () {
# Note: when we adjust the generated targets, rust doesn't rebuild (even
# when it should), so for now we need to remove the build dir to keep
# things in sync.
cd "${WORKDIR}"
rm -rf "${B}/"
mkdir -p "${B}/"
cd "${B}"
# FIXME: target_prefix vs prefix, see cross.bbclass
# CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
# wide range of targets (not just HOST). Yocto's settings for them will
# be inappropriate, avoid using.
unset CFLAGS
unset LDFLAGS
unset CXXFLAGS
unset CPPFLAGS
# FIXME: this path to rustc (via `which rustc`) may not be quite right in the case
# where we're reinstalling the compiler. May want to try for a real
# path based on bitbake vars
# Also will be wrong when relative libdir and/or bindir aren't 'bin' and 'lib'.
local_maybe_enable=disable
local_rust_root=/not/set/do/not/use
if which rustc >/dev/null 2>&1; then
local_rustc=$(which rustc)
if [ -n "$local_rustc" ]; then
local_rust_root=$(dirname $(dirname $local_rustc))
if [ -e "$local_rust_root/bin/rustc" ]; then
local_maybe_enable=enable
fi
fi
fi
# - rpath is required otherwise rustc fails to resolve symbols
# - submodule management is done by bitbake's fetching
${S}/configure \
"--enable-rpath" \
"--disable-docs" \
"--disable-manage-submodules" \
"--disable-debug" \
"--enable-debuginfo" \
"--enable-optimize" \
"--enable-optimize-cxx" \
"--disable-llvm-version-check" \
"--llvm-root=${llvmdir}" \
"--enable-optimize-tests" \
"--prefix=${prefix}" \
"--target=${TARGET_SYS}" \
"--host=${HOST_SYS}" \
"--build=${BUILD_SYS}" \
"--localstatedir=${localstatedir}" \
"--sysconfdir=${sysconfdir}" \
"--datadir=${datadir}" \
"--infodir=${infodir}" \
"--mandir=${mandir}" \
"--libdir=${libdir}" \
"--bindir=${bindir}" \
"--platform-cfg=${WORKDIR}/mk-cfg/" \
${@bb.utils.contains('PACKAGECONFIG', 'local-rust', '--$local_maybe_enable-local-rust --local-rust-root=$local_rust_root', '--local-rust-root=/not/a/dir', d)} \
${EXTRA_OECONF}
}
rust_runmake () {
echo "COMPILE ${PN}" "$@"
env
# CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
# wide range of targets (not just TARGET). Yocto's settings for them will
# be inappropriate, avoid using.
unset CFLAGS
unset LDFLAGS
unset CXXFLAGS
unset CPPFLAGS
oe_runmake "VERBOSE=1" "$@"
}
do_compile () {
if ${@bb.utils.contains('PACKAGECONFIG', 'local-rust', 'false', 'true', d)}; then
mkdir -p dl
cp -f ${WORKDIR}/${RUST_SNAPSHOT} dl
fi
rust_runmake
}
rust_do_install () {
rust_runmake DESTDIR="${D}" install
# Rust's install.sh doesn't mark executables as executable because
# we're using a custom bindir, do it ourselves.
chmod +x "${D}/${bindir}/rustc"
chmod +x "${D}/${bindir}/rustdoc"
chmod +x "${D}/${bindir}/rust-gdb"
# Install our custom target.json files
local td="${D}${libdir}/rustlib/"
install -d "$td"
for tgt in "${WORKDIR}/targets/"* ; do
install -m 0644 "$tgt" "$td"
done
## rust will complain about multiple providers of the runtime libs
## (libstd, libsync, etc.) without this.
(cd "${D}${libdir}" && ln -sf "rustlib/${HOST_SYS}/lib/lib"*.so .)
}
do_install () {
rust_do_install
}
+24
View File
@@ -0,0 +1,24 @@
SUMMARY = "Rust runtime libaries"
HOMEPAGE = "http://www.rust-lang.org"
SECTION = "devel"
LICENSE = "MIT | Apache-2.0"
inherit rust-bin
DEPENDS += "virtual/${TARGET_PREFIX}rust"
RUSTLIB_DEP = ""
do_install () {
for f in ${STAGING_DIR_NATIVE}/${rustlib_src}/*.so; do
echo Installing $f
install -D -m 755 $f ${D}/${rustlib}/$(basename $f)
done
}
# This has no license file
python do_qa_configure() {
return True
}
FILES_${PN} += "${rustlib}/*.so"
FILES_${PN}-dbg += "${rustlib}/.debug"