diff --git a/classes/cargo.bbclass b/classes/cargo.bbclass index 4842766..f7c8193 100644 --- a/classes/cargo.bbclass +++ b/classes/cargo.bbclass @@ -71,10 +71,12 @@ oe_cargo_build () { cargo_do_compile () { cd "${B}" - export TARGET_CC="${RUST_CC}" - export TARGET_CFLAGS="${RUST_CFLAGS}" - export HOST_CC="${RUST_BUILD_CC}" - export HOST_CFLAGS="${RUST_BUILD_CFLAGS}" + export CC="${RUST_CC}" + export CFLAGS="${RUST_CFLAGS}" + export AR="${AR}" + #export HOST_CC="${RUST_BUILD_CC}" + #export HOST_CFLAGS="${RUST_BUILD_CFLAGS}" + #export HOST_AR="${BUILD_AR}" oe_cargo_build } diff --git a/recipes-example/rust-hello-world/rust-hello-world_git.bb b/recipes-example/rust-hello-world/rust-hello-world_git.bb index f31fed0..ba88548 100644 --- a/recipes-example/rust-hello-world/rust-hello-world_git.bb +++ b/recipes-example/rust-hello-world/rust-hello-world_git.bb @@ -9,3 +9,5 @@ HOMEPAGE = "https://github.com/jmesmon/rust-hello-world" LICENSE = "MIT | Apache-2.0" S = "${WORKDIR}/git" + +BBCLASSEXTEND = "native" diff --git a/recipes/cargo/cargo.inc b/recipes/cargo/cargo.inc index bdf39a8..de268d4 100644 --- a/recipes/cargo/cargo.inc +++ b/recipes/cargo/cargo.inc @@ -42,9 +42,15 @@ do_configure () { oe_cargo_config } +# Used by gcc-rs +export CC_${TARGET_SYS}="${RUST_CC}" +export CFLAGS_${TARGET_SYS}="${RUST_CFLAGS}" +export AR_${TARGET_SYS}="${AR}" +export CC_${BUILD_SYS}="${RUST_BUILD_CC}" +export CFLAGS_${BUILD_SYS}="${RUST_BUILD_CFLAGS}" +export AR_${BUILD_SYS}="${BUILD_AR}" + do_compile () { - export CC="${RUST_CC}" - export CFLAGS="${RUST_CFLAGS}" oe_runmake ARGS="--verbose" } diff --git a/recipes/cargo/cargo_2014-12-03.bb b/recipes/cargo/cargo_2014-12-03.bb index d20c49e..d84b6fd 100644 --- a/recipes/cargo/cargo_2014-12-03.bb +++ b/recipes/cargo/cargo_2014-12-03.bb @@ -13,6 +13,7 @@ SRC_URI += " \ \ git://github.com/alexcrichton/gcc-rs.git;protocol=https;name=gcc-rs;destsuffix=gcc-rs \ file://gcc-rs/0001-Support-use-of-namespaced-environment-variables-base.patch;patchdir=../gcc-rs \ + file://gcc-rs/0001-Avoid-death-when-lacking-BUILD_KIND.patch;patchdir=../gcc-rs \ " SRCREV_curl-rust = "5d0f5c8848e3cf1e12480a1923ae888e24d58f63" diff --git a/recipes/cargo/files/gcc-rs/0001-Support-use-of-namespaced-environment-variables-base.patch b/recipes/cargo/files/gcc-rs/0001-Support-use-of-namespaced-environment-variables-base.patch index 3c47ca2..917b6e5 100644 --- a/recipes/cargo/files/gcc-rs/0001-Support-use-of-namespaced-environment-variables-base.patch +++ b/recipes/cargo/files/gcc-rs/0001-Support-use-of-namespaced-environment-variables-base.patch @@ -1,4 +1,4 @@ -From 364ff39932c6281cb90c5ebe8c9fd04e7b05a1f3 Mon Sep 17 00:00:00 2001 +From 5f5cb84a50a505a7876999729d4f53f59fa913ec Mon Sep 17 00:00:00 2001 From: Cody P Schafer Date: Wed, 3 Dec 2014 13:41:11 -0500 Subject: [PATCH] Support use of namespaced environment variables based on @@ -6,8 +6,8 @@ Subject: [PATCH] Support use of namespaced environment variables based on --- README.md | 25 +++++++++++++++++++++++++ - src/lib.rs | 18 +++++++++++++++--- - 2 files changed, 40 insertions(+), 3 deletions(-) + src/lib.rs | 20 +++++++++++++++++--- + 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bb7047d..73b72d7 100644 @@ -46,19 +46,21 @@ index bb7047d..73b72d7 100644 Currently use of this crate means that Windows users will require gcc to be diff --git a/src/lib.rs b/src/lib.rs -index 51157c8..ffd5aef 100644 +index 51157c8..18718b9 100644 --- a/src/lib.rs +++ b/src/lib.rs -@@ -109,8 +109,20 @@ fn run(cmd: &mut Command) { +@@ -109,8 +109,22 @@ fn run(cmd: &mut Command) { } } +fn get_var(var_base: &str) -> Option { -+ let target = os::getenv("TARGET").unwrap(); ++ let target = os::getenv("TARGET") ++ .expect("Environment variable 'TARGET' is unset"); + let target_u = target.split('-') + .collect::>() + .connect("_"); -+ let kind = os::getenv("BUILD_KIND").unwrap(); ++ let kind = os::getenv("BUILD_KIND") ++ .expect("Environment variable 'BUILD_KIND' is unset"); + os::getenv(format!("{}_{}", var_base, target).as_slice()) + .or_else(|| os::getenv(format!("{}_{}", var_base, target_u).as_slice())) + .or_else(|| os::getenv(format!("{}_{}", kind, var_base).as_slice())) @@ -71,7 +73,7 @@ index 51157c8..ffd5aef 100644 "gcc".to_string() } else { "cc".to_string() -@@ -118,11 +130,11 @@ fn gcc() -> String { +@@ -118,11 +132,11 @@ fn gcc() -> String { } fn ar() -> String { diff --git a/recipes/rust/rust.inc b/recipes/rust/rust.inc index b3dc0e4..9144b45 100644 --- a/recipes/rust/rust.inc +++ b/recipes/rust/rust.inc @@ -61,7 +61,7 @@ PRE_LINK_ARGS[i586] = "-Wl,--as-needed -m32" # # XXX: may need to restrict the -rpath flags to only BUILD & HOST RELATIVE_LIB_FROM_BIN = "${@os.path.relpath('${libdir}', '${bindir}')}" -RPATH_LDFLAGS = "-Wl,--enable-new-dtags -Wl,-rpath=$ORIGIN/${RELATIVE_LIB_FROM_BIN} -Wl,-rpath-link=$ORIGIN/${RELATIVE_LIB_FROM_BIN}" +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}"