From 302cca7529be776a07f3ad0ed00e2e0e5603a082 Mon Sep 17 00:00:00 2001 From: Tyler Hall Date: Tue, 28 Jul 2015 09:20:10 -0400 Subject: [PATCH 1/4] rust-bin.bbclass: suffix rust libraries with -rs Rust library names may have sonames that overlap with C/C++ libraries. This causes bitbake to not be able to create the correct automatic RDEPENDS between packages. The result is that dependencies may not get automatically installed. Add -rs to the file name and soname. The crate name remains the same, and rust is not dependent on the file name to look up the crate inside the library. --- classes/rust-bin.bbclass | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/classes/rust-bin.bbclass b/classes/rust-bin.bbclass index c663100..e062fc5 100644 --- a/classes/rust-bin.bbclass +++ b/classes/rust-bin.bbclass @@ -38,7 +38,7 @@ RUSTC_FLAGS += "-C prefer-dynamic" rustlib="${libdir}/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${HOST_SYS}/lib" CRATE_NAME ?= "${@d.getVar('BPN', True).replace('-rs', '').replace('-', '_')}" BINNAME ?= "${BPN}" -LIBNAME ?= "lib${CRATE_NAME}" +LIBNAME ?= "lib${CRATE_NAME}-rs" CRATE_TYPE ?= "dylib" BIN_SRC ?= "${S}/src/main.rs" LIB_SRC ?= "${S}/src/lib.rs" @@ -46,7 +46,7 @@ LIB_SRC ?= "${S}/src/lib.rs" get_overlap_externs () { externs= for dep in ${OVERLAP_DEPS}; do - extern=$(ls ${STAGING_DIR_HOST}/${rustlibdir}/lib$dep.{so,rlib} 2>/dev/null \ + extern=$(ls ${STAGING_DIR_HOST}/${rustlibdir}/lib$dep-rs.{so,rlib} 2>/dev/null \ | awk '{print $1}'); if [ -n "$extern" ]; then externs="$externs --extern $dep=$extern" @@ -59,15 +59,17 @@ get_overlap_externs () { } oe_compile_rust_lib () { + [ "${CRATE_TYPE}" == "dylib" ] && suffix=so || suffix=rlib rm -rf ${LIBNAME}.{rlib,so} local -a link_args if [ "${CRATE_TYPE}" == "dylib" ]; then link_args[0]="-C" - link_args[1]="link-args=-Wl,-soname -Wl,${LIBNAME}.so" + link_args[1]="link-args=-Wl,-soname -Wl,${LIBNAME}.$suffix" fi oe_runrustc $(get_overlap_externs) \ "${link_args[@]}" \ ${LIB_SRC} \ + -o ${LIBNAME}.$suffix \ --crate-name=${CRATE_NAME} --crate-type=${CRATE_TYPE} \ "$@" } From 63cf611e65c2db61be692d57ec1c8b1501b574c1 Mon Sep 17 00:00:00 2001 From: Dan Dedrick Date: Tue, 28 Jul 2015 15:32:33 -0400 Subject: [PATCH 2/4] rust-bin.bbclass: update path to cross output poky 1.7 changes where it publishes cross output to so this recipe needs to follow that. Unfortunately this path is defined in cross.bbclass and we can't inherit that since we aren't cross. --- classes/rust-bin.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/rust-bin.bbclass b/classes/rust-bin.bbclass index e062fc5..88071d5 100644 --- a/classes/rust-bin.bbclass +++ b/classes/rust-bin.bbclass @@ -35,7 +35,7 @@ OVERLAP_DEPS = "${@get_overlap_deps(d)}" # See https://github.com/rust-lang/rust/issues/19680 RUSTC_FLAGS += "-C prefer-dynamic" -rustlib="${libdir}/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${HOST_SYS}/lib" +rustlib="${libdir}/${TUNE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${HOST_SYS}/lib" CRATE_NAME ?= "${@d.getVar('BPN', True).replace('-rs', '').replace('-', '_')}" BINNAME ?= "${BPN}" LIBNAME ?= "lib${CRATE_NAME}-rs" From ebe7fb0d8fd532726b59510a9996a69ffb76b93e Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Thu, 27 Aug 2015 13:33:37 -0400 Subject: [PATCH 3/4] rust-bin.bbclass: look for RUNPATH instead of RPATH Poky 1.7 uses RPATH is now RUNPATH, so update our grep string appropriately. Additionally, bitbake is having trouble with the automatic RDEPENDS on rustlib. Make it explicit for now. --- classes/rust-bin.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/rust-bin.bbclass b/classes/rust-bin.bbclass index 88071d5..de8fbad 100644 --- a/classes/rust-bin.bbclass +++ b/classes/rust-bin.bbclass @@ -2,6 +2,7 @@ inherit rust RUSTLIB_DEP ?= " rustlib" DEPENDS .= "${RUSTLIB_DEP}" +RDEPENDS_${PN} .= "${RUSTLIB_DEP}" DEPENDS += "patchelf-native" export rustlibdir = "${libdir}/rust" @@ -101,7 +102,7 @@ do_rust_bin_fixups() { for f in `find ${PKGD}`; do file "$f" | grep -q ELF || continue - readelf -d "$f" | grep RPATH | grep -q rustlib || continue + readelf -d "$f" | grep RUNPATH | grep -q rustlib || continue echo "Set rpath:" "$f" patchelf --set-rpath '$ORIGIN:'${rustlibdir}:${rustlib} "$f" done From 45d77b849f8c51dbebf43f87aff217a7b5219666 Mon Sep 17 00:00:00 2001 From: Wes Lindauer Date: Mon, 2 Nov 2015 10:25:52 -0500 Subject: [PATCH 4/4] rust-bin.bbclass: Add empty do_configure This prevents rust recipes that are missing clean rules from failing when they are rebuilt. --- classes/rust-bin.bbclass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes/rust-bin.bbclass b/classes/rust-bin.bbclass index de8fbad..8a0f7af 100644 --- a/classes/rust-bin.bbclass +++ b/classes/rust-bin.bbclass @@ -59,6 +59,9 @@ get_overlap_externs () { echo "$externs" } +do_configure () { +} + oe_compile_rust_lib () { [ "${CRATE_TYPE}" == "dylib" ] && suffix=so || suffix=rlib rm -rf ${LIBNAME}.{rlib,so}