diff --git a/recipes-devtools/rust/compiler-rt.inc b/recipes-devtools/rust/compiler-rt.inc new file mode 100644 index 0000000..59677e7 --- /dev/null +++ b/recipes-devtools/rust/compiler-rt.inc @@ -0,0 +1,30 @@ +SUMMARY = "Rust compiler run-time" +HOMEPAGE = "http://www.rust-lang.org" +SECTION = "devel" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://src/compiler-rt/LICENSE.TXT;md5=bf24bca27049b52e9738451aa55771d4" + +require rust.inc +ALLOW_EMPTY_${PN} = "1" + +DEPENDS += "rust-llvm-native (=${PV})" +# dev and staticdev should NOT depend on the binary package +RDEPENDS_${PN}-dev = "" +INSANE_SKIP_${PN}-dev = "staticdev" + +S = "${WORKDIR}/rustc-${PV}" + +DISABLE_STATIC = "" +INHIBIT_DEFAULT_RUST_DEPS = "1" + +do_compile () { + oe_runmake ${TARGET_SYS}/rt/libcompiler-rt.a +} + +do_install () { + mkdir -p ${D}${libdir} + cp ${TARGET_SYS}/rt/libcompiler-rt.a ${D}${libdir}/libcompiler-rt.a +} + +FILES_${PN}-dev = "" +FILES_${PN}-staticdev = "${libdir}/*.a" diff --git a/recipes-devtools/rust/compiler-rt_1.12.1.bb b/recipes-devtools/rust/compiler-rt_1.12.1.bb index c7ef3a0..8e08013 100644 --- a/recipes-devtools/rust/compiler-rt_1.12.1.bb +++ b/recipes-devtools/rust/compiler-rt_1.12.1.bb @@ -1,31 +1,2 @@ -SUMMARY = "Rust compiler run-time" -HOMEPAGE = "http://www.rust-lang.org" -SECTION = "devel" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://src/compiler-rt/LICENSE.TXT;md5=bf24bca27049b52e9738451aa55771d4" - -require rust.inc +require compiler-rt.inc require rust-source-${PV}.inc -ALLOW_EMPTY_${PN} = "1" - -DEPENDS += "rust-llvm-native (=${PV})" -# dev and staticdev should NOT depend on the binary package -RDEPENDS_${PN}-dev = "" -INSANE_SKIP_${PN}-dev = "staticdev" - -S = "${WORKDIR}/rustc-${PV}" - -DISABLE_STATIC = "" -INHIBIT_DEFAULT_RUST_DEPS = "1" - -do_compile () { - oe_runmake ${TARGET_SYS}/rt/libcompiler-rt.a -} - -do_install () { - mkdir -p ${D}${libdir} - cp ${TARGET_SYS}/rt/libcompiler-rt.a ${D}${libdir}/libcompiler-rt.a -} - -FILES_${PN}-dev = "" -FILES_${PN}-staticdev = "${libdir}/*.a" diff --git a/recipes-devtools/rust/libstd-rs.inc b/recipes-devtools/rust/libstd-rs.inc new file mode 100644 index 0000000..185ed63 --- /dev/null +++ b/recipes-devtools/rust/libstd-rs.inc @@ -0,0 +1,32 @@ +SUMMARY = "Rust standard libaries" +HOMEPAGE = "http://www.rust-lang.org" +SECTION = "devel" +LICENSE = "MIT | Apache-2.0" +LIC_FILES_CHKSUM ="file://COPYRIGHT;md5=43e1f1fb9c0ee3af66693d8c4fecafa8" + +S = "${WORKDIR}/rustc-${PV}" + +SRC_URI += "\ + crate://crates.io/gcc/0.3.27 \ +" + +DEPENDS += "compiler-rt (=${PV})" + +RUSTLIB_DEP = "" +inherit cargo + +# Needed so cargo can find libbacktrace +RUSTFLAGS += "-L ${STAGING_LIBDIR}" + +S = "${WORKDIR}/rustc-${PV}" + +do_compile_prepend () { + cd ${S}/src/rustc/std_shim + export CARGO_TARGET_DIR="${B}" + export RUSTC_BOOTSTRAP_KEY="${RS_KEY}" +} + +do_install () { + mkdir -p ${D}${rustlibdir} + cp ${B}/${TARGET_SYS}/release/deps/* ${D}${rustlibdir} +} diff --git a/recipes-devtools/rust/libstd-rs_1.12.1.bb b/recipes-devtools/rust/libstd-rs_1.12.1.bb index 0f2f8dc..3c12c86 100644 --- a/recipes-devtools/rust/libstd-rs_1.12.1.bb +++ b/recipes-devtools/rust/libstd-rs_1.12.1.bb @@ -1,34 +1,2 @@ -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 libstd-rs.inc require rust-source-${PV}.inc - -S = "${WORKDIR}/rustc-${PV}" - -SRC_URI += "\ - crate://crates.io/gcc/0.3.27 \ -" - -DEPENDS += "compiler-rt (=${PV})" - -RUSTLIB_DEP = "" -inherit cargo - -# Needed so cargo can find libbacktrace -RUSTFLAGS += "-L ${STAGING_LIBDIR}" - -S = "${WORKDIR}/rustc-${PV}" - -do_compile_prepend () { - cd ${S}/src/rustc/std_shim - export CARGO_TARGET_DIR="${B}" - export RUSTC_BOOTSTRAP_KEY="${RS_KEY}" -} - -do_install () { - mkdir -p ${D}${rustlibdir} - cp ${B}/${TARGET_SYS}/release/deps/* ${D}${rustlibdir} -} diff --git a/recipes-devtools/rust/rust-cross.inc b/recipes-devtools/rust/rust-cross.inc new file mode 100644 index 0000000..c350014 --- /dev/null +++ b/recipes-devtools/rust/rust-cross.inc @@ -0,0 +1,49 @@ +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" +DEPENDS += "rust-native" + +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}" + +do_configure () { +} + +do_compile () { +} + +do_install () { + mkdir -p ${D}${prefix}/${base_libdir_native}/rustlib + cp ${WORKDIR}/targets/${TARGET_SYS}.json ${D}${prefix}/${base_libdir_native}/rustlib +} + +rust_cross_sysroot_preprocess() { + sysroot_stage_dir ${D}${prefix}/${base_libdir_native}/rustlib ${SYSROOT_DESTDIR}${prefix}/${base_libdir_native}/rustlib +} +SYSROOT_PREPROCESS_FUNCS += "rust_cross_sysroot_preprocess" diff --git a/recipes-devtools/rust/rust-cross_1.12.1.bb b/recipes-devtools/rust/rust-cross_1.12.1.bb index 67b6f3c..ddc25d3 100644 --- a/recipes-devtools/rust/rust-cross_1.12.1.bb +++ b/recipes-devtools/rust/rust-cross_1.12.1.bb @@ -1,50 +1,2 @@ -require rust.inc -inherit cross +require rust-cross.inc require rust-source-${PV}.inc - -# 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" -DEPENDS += "rust-native" - -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}" - -do_configure () { -} - -do_compile () { -} - -do_install () { - mkdir -p ${D}${prefix}/${base_libdir_native}/rustlib - cp ${WORKDIR}/targets/${TARGET_SYS}.json ${D}${prefix}/${base_libdir_native}/rustlib -} - -rust_cross_sysroot_preprocess() { - sysroot_stage_dir ${D}${prefix}/${base_libdir_native}/rustlib ${SYSROOT_DESTDIR}${prefix}/${base_libdir_native}/rustlib -} -SYSROOT_PREPROCESS_FUNCS += "rust_cross_sysroot_preprocess"