Merge pull request #51 from srwalter/cross-compile-libstd
Replace rust-cross with a cross-compiled libstd
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
inherit rust-vars
|
||||
# add crate fetch support
|
||||
inherit crate-fetch
|
||||
|
||||
@@ -11,7 +12,7 @@ export CARGO_HOME = "${WORKDIR}/cargo_home"
|
||||
BASEDEPENDS_append = " cargo-native"
|
||||
|
||||
# Ensure we get the right rust variant
|
||||
DEPENDS_append_class-target = "virtual/${TARGET_PREFIX}rust"
|
||||
DEPENDS_append_class-target = " virtual/${TARGET_PREFIX}rust ${RUSTLIB_DEP}"
|
||||
|
||||
# Cargo only supports in-tree builds at the moment
|
||||
B = "${S}"
|
||||
@@ -35,12 +36,14 @@ export RUST_CFLAGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${CFLAGS}"
|
||||
export RUST_BUILD_CC = "${CCACHE}${BUILD_PREFIX}gcc"
|
||||
export RUST_BUILD_CFLAGS = "${BUILD_CC_ARCH} ${BUILD_CFLAGS}"
|
||||
|
||||
RUSTFLAGS ??= ""
|
||||
export CARGO_BUILD_FLAGS = "-v --target ${HOST_SYS} --release"
|
||||
|
||||
# This is based on the content of CARGO_BUILD_FLAGS and generally will need to
|
||||
# change if CARGO_BUILD_FLAGS changes.
|
||||
export CARGO_TARGET_SUBDIR="${HOST_SYS}/release"
|
||||
oe_cargo_build () {
|
||||
export RUSTFLAGS="${RUSTFLAGS}"
|
||||
bbnote "cargo = $(which cargo)"
|
||||
bbnote "rustc = $(which rustc)"
|
||||
bbnote "${CARGO} build ${CARGO_BUILD_FLAGS} $@"
|
||||
@@ -70,12 +73,15 @@ cargo_util_do_compile () {
|
||||
oe_cargo_build
|
||||
}
|
||||
|
||||
# All but the most simple projects will need to override this.
|
||||
cargo_util_do_install () {
|
||||
local have_installed=false
|
||||
install -d "${D}${bindir}"
|
||||
for tgt in "${B}/target/${CARGO_TARGET_SUBDIR}/"*; do
|
||||
if [ -f "$tgt" ] && [ -x "$tgt" ]; then
|
||||
if [[ $tgt == *.so || $tgt == *.rlib ]]; then
|
||||
install -d "${D}${rustlibdir}"
|
||||
install -m755 "$tgt" "${D}${rustlibdir}"
|
||||
have_installed=true
|
||||
elif [ -f "$tgt" ] && [ -x "$tgt" ]; then
|
||||
install -d "${D}${bindir}"
|
||||
install -m755 "$tgt" "${D}${bindir}"
|
||||
have_installed=true
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
export rustlibdir = "${libdir}/rust"
|
||||
FILES_${PN} += "${rustlibdir}/*.so"
|
||||
FILES_${PN}-dev += "${rustlibdir}/*.rlib"
|
||||
FILES_${PN}-dbg += "${rustlibdir}/.debug"
|
||||
|
||||
RUSTLIB = "-L ${STAGING_LIBDIR}/rust"
|
||||
RUSTFLAGS += "-C rpath -C crate_hash=${BB_TASKHASH} ${RUSTLIB}"
|
||||
RUSTLIB_DEP ?= "libstd-rs"
|
||||
@@ -1,10 +1,9 @@
|
||||
inherit rust-vars
|
||||
|
||||
RUSTC = "rustc"
|
||||
|
||||
# FIXME: --sysroot might be needed
|
||||
RUSTFLAGS += "-C rpath -C crate_hash=${BB_TASKHASH}"
|
||||
RUSTC_ARCHFLAGS += "--target=${TARGET_SYS} ${RUSTFLAGS}"
|
||||
|
||||
RUSTLIB_DEP ?= "rustlib"
|
||||
def rust_base_dep(d):
|
||||
# Taken from meta/classes/base.bbclass `base_dep_prepend` and modified to
|
||||
# use rust instead of gcc
|
||||
@@ -107,7 +106,3 @@ rustlib_suffix="${TUNE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${HOST_SYS}/li
|
||||
rustlib_src="${prefix}/lib/${rustlib_suffix}"
|
||||
# Host sysroot standard library path
|
||||
rustlib="${libdir}/${rustlib_suffix}"
|
||||
export rustlibdir = "${libdir}/rust"
|
||||
FILES_${PN} += "${rustlibdir}/*.so"
|
||||
FILES_${PN}-dev += "${rustlibdir}/*.rlib"
|
||||
FILES_${PN}-dbg += "${rustlibdir}/.debug"
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
SUMMARY = "Rust compiler run-time"
|
||||
HOMEPAGE = "http://www.rust-lang.org"
|
||||
SECTION = "devel"
|
||||
LICENSE = "MIT"
|
||||
|
||||
require rust-shared-source.inc
|
||||
LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=27b14ab4ce08d04c3a9a5f0ed7997362"
|
||||
|
||||
S .= "/src/compiler-rt"
|
||||
B = "${WORKDIR}/build"
|
||||
|
||||
do_compile () {
|
||||
oe_runmake -C ${S} \
|
||||
ProjSrcRoot="${S}" \
|
||||
ProjObjRoot="${B}" \
|
||||
TargetTriple=${HOST_SYS} \
|
||||
triple-builtins
|
||||
}
|
||||
|
||||
do_install () {
|
||||
mkdir -p ${D}${libdir}
|
||||
cp triple/builtins/libcompiler_rt.a ${D}${libdir}/libcompiler-rt.a
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
SUMMARY = "Rust standard libaries"
|
||||
HOMEPAGE = "http://www.rust-lang.org"
|
||||
SECTION = "devel"
|
||||
LICENSE = "MIT | Apache-2.0"
|
||||
|
||||
LIC_FILES_CHKSUM ="file://COPYRIGHT;md5=43e1f1fb9c0ee3af66693d8c4fecafa8"
|
||||
require rust-shared-source.inc
|
||||
|
||||
DEPENDS += "compiler-rt"
|
||||
|
||||
RUSTLIB_DEP = ""
|
||||
inherit cargo_util
|
||||
|
||||
# Needed so cargo can find libbacktrace
|
||||
RUSTFLAGS += "-L ${STAGING_LIBDIR}"
|
||||
|
||||
B = "${WORKDIR}/build"
|
||||
|
||||
do_compile () {
|
||||
cd ${S}/src/rustc/std_shim
|
||||
export CARGO_TARGET_DIR="${B}"
|
||||
export RUSTC_BOOTSTRAP_KEY="e8edd0fd"
|
||||
oe_cargo_fix_env
|
||||
oe_cargo_build
|
||||
}
|
||||
|
||||
do_install () {
|
||||
mkdir -p ${D}${rustlibdir}
|
||||
cp ${B}/${TARGET_SYS}/release/deps/* ${D}${rustlibdir}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ INHIBIT_DEFAULT_RUST_DEPS = "1"
|
||||
# the bits we need explicitly.
|
||||
DEPENDS += "rust-llvm-native"
|
||||
DEPENDS += "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}compilerlibs virtual/libc"
|
||||
DEPENDS += "rust-native"
|
||||
|
||||
PROVIDES = "virtual/${TARGET_PREFIX}rust"
|
||||
PN = "rust-cross-${TARGET_ARCH}"
|
||||
@@ -31,14 +32,18 @@ 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
|
||||
do_configure () {
|
||||
}
|
||||
|
||||
# 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"
|
||||
do_compile () {
|
||||
}
|
||||
|
||||
do_install () {
|
||||
mkdir -p ${D}${prefix}/${baselib}/rustlib
|
||||
cp ${WORKDIR}/targets/${TARGET_ARCH}* ${D}${prefix}/${baselib}/rustlib
|
||||
}
|
||||
|
||||
rust_cross_sysroot_preprocess() {
|
||||
sysroot_stage_dir ${D}${prefix}/${baselib}/rustlib ${SYSROOT_DESTDIR}${prefix}/${baselib}/rustlib
|
||||
}
|
||||
SYSROOT_PREPROCESS_FUNCS += "rust_cross_sysroot_preprocess"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
inherit rust-installer
|
||||
require rust.inc
|
||||
|
||||
DEPENDS += "rust-llvm"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# ex: sts=4 et sw=4 ts=8
|
||||
inherit rust
|
||||
inherit rust-installer
|
||||
require rust-shared-source.inc
|
||||
require rust-snapshot-2016-05-24.inc
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
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}/*; 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}-dev += "${rustlib}/*.rlib"
|
||||
FILES_${PN}-staticdev += "${rustlib}/*.a"
|
||||
FILES_${PN}-dbg += "${rustlib}/.debug"
|
||||
Reference in New Issue
Block a user