openembedded-core.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/29] nativesdk: Clear TUNE_FEATURES
@ 2022-08-05 13:12 Richard Purdie
  2022-08-05 13:12 ` [PATCH 02/29] populate_sdk_base: Disable rust SDK for MIPS n32 Richard Purdie
                   ` (27 more replies)
  0 siblings, 28 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Similarly to what native.bbclass does, clear TUNE_FEATURES since these
aren't appropriate to the nativesdk build. This saves us having to change
down signature issues due to data in this variable.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/nativesdk.bbclass | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meta/classes/nativesdk.bbclass b/meta/classes/nativesdk.bbclass
index f8e96075134..e46739e325b 100644
--- a/meta/classes/nativesdk.bbclass
+++ b/meta/classes/nativesdk.bbclass
@@ -55,6 +55,7 @@ TARGET_CXXFLAGS = "${BUILDSDK_CXXFLAGS}"
 TARGET_LDFLAGS = "${BUILDSDK_LDFLAGS}"
 TARGET_FPU = ""
 EXTRA_OECONF_GCC_FLOAT = ""
+TUNE_FEATURES = ""
 
 CPPFLAGS = "${BUILDSDK_CPPFLAGS}"
 CFLAGS = "${BUILDSDK_CFLAGS}"
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 02/29] populate_sdk_base: Disable rust SDK for MIPS n32
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-07  0:39   ` [OE-core] " Khem Raj
  2022-08-05 13:12 ` [PATCH 03/29] selftest/reproducible: Exclude rust/rust-dbg for now until we can fix Richard Purdie
                   ` (26 subsequent siblings)
  27 siblings, 1 reply; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

The n32 MIPS rust SDK doesn't quite build (libstd-rs fails with an llvm
register issue). Disable it for now, someone with interest in having it working
can fix if/as/when.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/populate_sdk_base.bbclass | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass
index f260217b508..0d1c6e18c4e 100644
--- a/meta/classes/populate_sdk_base.bbclass
+++ b/meta/classes/populate_sdk_base.bbclass
@@ -45,6 +45,7 @@ SDKTARGETSYSROOT = "${SDKPATH}/sysroots/${REAL_MULTIMACH_TARGET_SYS}"
 
 SDK_TOOLCHAIN_LANGS ??= ""
 SDK_TOOLCHAIN_LANGS:remove:sdkmingw32 = "rust"
+SDK_TOOLCHAIN_LANGS:remove:mipsarchn32 = "rust"
 
 TOOLCHAIN_HOST_TASK ?= " \
     nativesdk-packagegroup-sdk-host \
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 03/29] selftest/reproducible: Exclude rust/rust-dbg for now until we can fix
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
  2022-08-05 13:12 ` [PATCH 02/29] populate_sdk_base: Disable rust SDK for MIPS n32 Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 04/29] conf/distro/no-static-libs: Allow static musl for rust Richard Purdie
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

There looks to be a reproducibility issue left in one of the rust
libraries. It doesn't appear to be a string issue but some binary
problem. Disable rust from the reproducibility testing until we can
get to the bottom of the issue (allowing wider testing of all the
other improvements).

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/lib/oeqa/selftest/cases/reproducible.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/reproducible.py b/meta/lib/oeqa/selftest/cases/reproducible.py
index 5042c11d8eb..f4dd779842a 100644
--- a/meta/lib/oeqa/selftest/cases/reproducible.py
+++ b/meta/lib/oeqa/selftest/cases/reproducible.py
@@ -16,6 +16,8 @@ import os
 import datetime
 
 exclude_packages = [
+	'rust',
+	'rust-dbg'
 	]
 
 def is_excluded(package):
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 04/29] conf/distro/no-static-libs: Allow static musl for rust
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
  2022-08-05 13:12 ` [PATCH 02/29] populate_sdk_base: Disable rust SDK for MIPS n32 Richard Purdie
  2022-08-05 13:12 ` [PATCH 03/29] selftest/reproducible: Exclude rust/rust-dbg for now until we can fix Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-07  0:41   ` [OE-core] " Khem Raj
  2022-08-05 13:12 ` [PATCH 05/29] rust-target-config: Add mips n32 best guess at target information Richard Purdie
                   ` (24 subsequent siblings)
  27 siblings, 1 reply; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

When building rust for musl targets we need the static library from musl,
so enable it.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/conf/distro/include/no-static-libs.inc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/conf/distro/include/no-static-libs.inc b/meta/conf/distro/include/no-static-libs.inc
index ee673834601..75359928a14 100644
--- a/meta/conf/distro/include/no-static-libs.inc
+++ b/meta/conf/distro/include/no-static-libs.inc
@@ -18,6 +18,8 @@ DISABLE_STATIC:pn-nativesdk-openssl = ""
 DISABLE_STATIC:pn-gcc-runtime = ""
 # libusb1-native is used to build static dfu-util-native
 DISABLE_STATIC:pn-libusb1-native = ""
+# needed by rust
+DISABLE_STATIC:pn-musl = ""
 
 EXTRA_OECONF:append = "${DISABLE_STATIC}"
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 05/29] rust-target-config: Add mips n32 best guess at target information
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (2 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 04/29] conf/distro/no-static-libs: Allow static musl for rust Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-07  0:47   ` [OE-core] " Khem Raj
  2022-08-05 13:12 ` [PATCH 06/29] rust-common: Add CXXFLAGS Richard Purdie
                   ` (23 subsequent siblings)
  27 siblings, 1 reply; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Add a best guess at MIPS n32 target information. This might not be
100% correct but is something to start from at least.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-target-config.bbclass | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/meta/classes/rust-target-config.bbclass b/meta/classes/rust-target-config.bbclass
index 87b7dee3edc..1721839922e 100644
--- a/meta/classes/rust-target-config.bbclass
+++ b/meta/classes/rust-target-config.bbclass
@@ -190,6 +190,13 @@ TARGET_POINTER_WIDTH[mips64] = "64"
 TARGET_C_INT_WIDTH[mips64] = "64"
 MAX_ATOMIC_WIDTH[mips64] = "64"
 
+## mips64-n32-unknown-linux-{gnu, musl}
+DATA_LAYOUT[mips64-n32] = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+TARGET_ENDIAN[mips64-n32] = "big"
+TARGET_POINTER_WIDTH[mips64-n32] = "32"
+TARGET_C_INT_WIDTH[mips64-n32] = "32"
+MAX_ATOMIC_WIDTH[mips64-n32] = "64"
+
 ## mips64el-unknown-linux-{gnu, musl}
 DATA_LAYOUT[mips64el] = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 TARGET_ENDIAN[mips64el] = "little"
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 06/29] rust-common: Add CXXFLAGS
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (3 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 05/29] rust-target-config: Add mips n32 best guess at target information Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 07/29] rust-common: Drop export directive from wrappers Richard Purdie
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Similarly to CC and CCLD, handle CXX flags too.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-common.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass
index cb811ac5da7..0c9363b31a1 100644
--- a/meta/classes/rust-common.bbclass
+++ b/meta/classes/rust-common.bbclass
@@ -177,7 +177,7 @@ do_rust_create_wrappers () {
 	# Yocto Target / Rust Target C compiler
 	create_wrapper "${RUST_TARGET_CC}" "${WRAPPER_TARGET_CC}" "${WRAPPER_TARGET_LDFLAGS}"
 	# Yocto Target / Rust Target C++ compiler
-	create_wrapper "${RUST_TARGET_CXX}" "${WRAPPER_TARGET_CXX}"
+	create_wrapper "${RUST_TARGET_CXX}" "${WRAPPER_TARGET_CXX}" "${CXXFLAGS}"
 	# Yocto Target / Rust Target linker
 	create_wrapper "${RUST_TARGET_CCLD}" "${WRAPPER_TARGET_CCLD}" "${WRAPPER_TARGET_LDFLAGS}"
 	# Yocto Target / Rust Target archiver
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 07/29] rust-common: Drop export directive from wrappers
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (4 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 06/29] rust-common: Add CXXFLAGS Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 08/29] rust-common: Rework wrappers top handle musl Richard Purdie
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

These variables don't need to be exported into the environment, which reduces
the scope of rebuilds when variable values change.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-common.bbclass | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass
index 0c9363b31a1..b79a829462c 100644
--- a/meta/classes/rust-common.bbclass
+++ b/meta/classes/rust-common.bbclass
@@ -153,11 +153,11 @@ create_wrapper () {
 	chmod +x "${file}"
 }
 
-export WRAPPER_TARGET_CC = "${CC}"
-export WRAPPER_TARGET_CXX = "${CXX}"
-export WRAPPER_TARGET_CCLD = "${CCLD}"
-export WRAPPER_TARGET_LDFLAGS = "${LDFLAGS}"
-export WRAPPER_TARGET_AR = "${AR}"
+WRAPPER_TARGET_CC = "${CC}"
+WRAPPER_TARGET_CXX = "${CXX}"
+WRAPPER_TARGET_CCLD = "${CCLD}"
+WRAPPER_TARGET_LDFLAGS = "${LDFLAGS}"
+WRAPPER_TARGET_AR = "${AR}"
 
 # compiler is used by gcc-rs
 # linker is used by rustc/cargo
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 08/29] rust-common: Rework wrappers top handle musl
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (5 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 07/29] rust-common: Drop export directive from wrappers Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 09/29] rust: Work around reproducibility issues Richard Purdie
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

For musl we need to be able to add a library to the end of the linker commandline.
Rework the wrapper code to be able to do this through a new variable.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-common.bbclass | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass
index b79a829462c..1bce7761ab0 100644
--- a/meta/classes/rust-common.bbclass
+++ b/meta/classes/rust-common.bbclass
@@ -141,13 +141,18 @@ RUST_TARGET_AR = "${WRAPPER_DIR}/target-rust-ar"
 create_wrapper () {
 	file="$1"
 	shift
+	extras="$1"
+	shift
 
 	cat <<- EOF > "${file}"
 	#!/usr/bin/env python3
 	import os, sys
 	orig_binary = "$@"
+	extras = "${extras}"
 	binary = orig_binary.split()[0]
 	args = orig_binary.split() + sys.argv[1:]
+	if extras:
+	    args.append(extras)
 	os.execvp(binary, args)
 	EOF
 	chmod +x "${file}"
@@ -157,6 +162,7 @@ WRAPPER_TARGET_CC = "${CC}"
 WRAPPER_TARGET_CXX = "${CXX}"
 WRAPPER_TARGET_CCLD = "${CCLD}"
 WRAPPER_TARGET_LDFLAGS = "${LDFLAGS}"
+WRAPPER_TARGET_EXTRALD = ""
 WRAPPER_TARGET_AR = "${AR}"
 
 # compiler is used by gcc-rs
@@ -166,22 +172,22 @@ do_rust_create_wrappers () {
 	mkdir -p "${WRAPPER_DIR}"
 
 	# Yocto Build / Rust Host C compiler
-	create_wrapper "${RUST_BUILD_CC}" "${BUILD_CC}"
+	create_wrapper "${RUST_BUILD_CC}" "" "${BUILD_CC}"
 	# Yocto Build / Rust Host C++ compiler
-	create_wrapper "${RUST_BUILD_CXX}" "${BUILD_CXX}"
+	create_wrapper "${RUST_BUILD_CXX}" "" "${BUILD_CXX}"
 	# Yocto Build / Rust Host linker
-	create_wrapper "${RUST_BUILD_CCLD}" "${BUILD_CCLD}" "${BUILD_LDFLAGS}"
+	create_wrapper "${RUST_BUILD_CCLD}" "" "${BUILD_CCLD}" "${BUILD_LDFLAGS}"
 	# Yocto Build / Rust Host archiver
-	create_wrapper "${RUST_BUILD_AR}" "${BUILD_AR}"
+	create_wrapper "${RUST_BUILD_AR}" "" "${BUILD_AR}"
 
 	# Yocto Target / Rust Target C compiler
-	create_wrapper "${RUST_TARGET_CC}" "${WRAPPER_TARGET_CC}" "${WRAPPER_TARGET_LDFLAGS}"
+	create_wrapper "${RUST_TARGET_CC}" "${WRAPPER_TARGET_EXTRALD}" "${WRAPPER_TARGET_CC}" "${WRAPPER_TARGET_LDFLAGS}"
 	# Yocto Target / Rust Target C++ compiler
-	create_wrapper "${RUST_TARGET_CXX}" "${WRAPPER_TARGET_CXX}" "${CXXFLAGS}"
+	create_wrapper "${RUST_TARGET_CXX}" "${WRAPPER_TARGET_EXTRALD}" "${WRAPPER_TARGET_CXX}" "${CXXFLAGS}"
 	# Yocto Target / Rust Target linker
-	create_wrapper "${RUST_TARGET_CCLD}" "${WRAPPER_TARGET_CCLD}" "${WRAPPER_TARGET_LDFLAGS}"
+	create_wrapper "${RUST_TARGET_CCLD}" "${WRAPPER_TARGET_EXTRALD}" "${WRAPPER_TARGET_CCLD}" "${WRAPPER_TARGET_LDFLAGS}"
 	# Yocto Target / Rust Target archiver
-	create_wrapper "${RUST_TARGET_AR}" "${WRAPPER_TARGET_AR}"
+	create_wrapper "${RUST_TARGET_AR}" "" "${WRAPPER_TARGET_AR}"
 
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 09/29] rust: Work around reproducibility issues
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (6 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 08/29] rust-common: Rework wrappers top handle musl Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 10/29] rust: Switch to use RUST_XXX_SYS consistently Richard Purdie
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Add a patch which removes the sections of code which encode buildpaths. Whilst
not ideal, the patches at least show where the problematic data is coming from
and should allow more focused work to resovle it by someone who has a better
understanding of rust and what this code is doing. It does look unlikely we
actually need this code in our usecases anyway.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/rust/rust-source.inc    |  3 +
 .../rust/rust/hardcodepaths.patch             | 70 +++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust/hardcodepaths.patch

diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
index fda26534e88..b814574e55f 100644
--- a/meta/recipes-devtools/rust/rust-source.inc
+++ b/meta/recipes-devtools/rust/rust-source.inc
@@ -1,6 +1,9 @@
 SRC_URI += "https://static.rust-lang.org/dist/rustc-${PV}-src.tar.xz;name=rust"
 SRC_URI[rust.sha256sum] = "6c00ef115c894c2645e60b5049a4f5dacf1dc0c993f3074f7ae4fdf4c755dd5e"
 
+SRC_URI:append:class-target:pn-rust = " file://hardcodepaths.patch"
+SRC_URI:append:class-nativesdk:pn-nativesdk-rust = " file://hardcodepaths.patch"
+
 RUSTSRC = "${WORKDIR}/rustc-${PV}-src"
 
 UPSTREAM_CHECK_URI = "https://forge.rust-lang.org/infra/other-installation-methods.html"
diff --git a/meta/recipes-devtools/rust/rust/hardcodepaths.patch b/meta/recipes-devtools/rust/rust/hardcodepaths.patch
new file mode 100644
index 00000000000..2fdfe6d4637
--- /dev/null
+++ b/meta/recipes-devtools/rust/rust/hardcodepaths.patch
@@ -0,0 +1,70 @@
+When building for the target, some build paths end up embedded in the binaries. 
+These changes remove that. Further investigation is needed to work out the way
+to resolve these issues properly upstream.
+
+Upstream-Status: Inappropriate [patches need rework]
+Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+
+Index: rustc-1.62.0-src/src/tools/clippy/src/driver.rs
+===================================================================
+--- rustc-1.62.0-src.orig/src/tools/clippy/src/driver.rs
++++ rustc-1.62.0-src/src/tools/clippy/src/driver.rs
+@@ -255,7 +255,6 @@ pub fn main() {
+                     .and_then(|out| String::from_utf8(out.stdout).ok())
+                     .map(|s| PathBuf::from(s.trim()))
+             })
+-            .or_else(|| option_env!("SYSROOT").map(PathBuf::from))
+             .or_else(|| {
+                 let home = option_env!("RUSTUP_HOME")
+                     .or(option_env!("MULTIRUST_HOME"))
+Index: rustc-1.62.0-src/compiler/rustc_codegen_llvm/src/context.rs
+===================================================================
+--- rustc-1.62.0-src.orig/compiler/rustc_codegen_llvm/src/context.rs
++++ rustc-1.62.0-src/compiler/rustc_codegen_llvm/src/context.rs
+@@ -167,46 +167,6 @@ pub unsafe fn create_module<'ll>(
+         }
+     }
+ 
+-    // Ensure the data-layout values hardcoded remain the defaults.
+-    if sess.target.is_builtin {
+-        let tm = crate::back::write::create_informational_target_machine(tcx.sess);
+-        llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
+-        llvm::LLVMRustDisposeTargetMachine(tm);
+-
+-        let llvm_data_layout = llvm::LLVMGetDataLayoutStr(llmod);
+-        let llvm_data_layout = str::from_utf8(CStr::from_ptr(llvm_data_layout).to_bytes())
+-            .expect("got a non-UTF8 data-layout from LLVM");
+-
+-        // Unfortunately LLVM target specs change over time, and right now we
+-        // don't have proper support to work with any more than one
+-        // `data_layout` than the one that is in the rust-lang/rust repo. If
+-        // this compiler is configured against a custom LLVM, we may have a
+-        // differing data layout, even though we should update our own to use
+-        // that one.
+-        //
+-        // As an interim hack, if CFG_LLVM_ROOT is not an empty string then we
+-        // disable this check entirely as we may be configured with something
+-        // that has a different target layout.
+-        //
+-        // Unsure if this will actually cause breakage when rustc is configured
+-        // as such.
+-        //
+-        // FIXME(#34960)
+-        let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
+-        let custom_llvm_used = cfg_llvm_root.trim() != "";
+-
+-        if !custom_llvm_used && target_data_layout != llvm_data_layout {
+-            bug!(
+-                "data-layout for target `{rustc_target}`, `{rustc_layout}`, \
+-                  differs from LLVM target's `{llvm_target}` default layout, `{llvm_layout}`",
+-                rustc_target = sess.opts.target_triple,
+-                rustc_layout = target_data_layout,
+-                llvm_target = sess.target.llvm_target,
+-                llvm_layout = llvm_data_layout
+-            );
+-        }
+-    }
+-
+     let data_layout = SmallCStr::new(&target_data_layout);
+     llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
+ 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 10/29] rust: Switch to use RUST_XXX_SYS consistently
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (7 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 09/29] rust: Work around reproducibility issues Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 11/29] rust.inc: Rename variables to make code clearer Richard Purdie
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/cargo.bbclass                   |  4 ++--
 meta/classes/cargo_common.bbclass            |  6 +++---
 meta/classes/python_pyo3.bbclass             |  2 +-
 meta/classes/rust-target-config.bbclass      |  2 +-
 meta/classes/rust.bbclass                    |  4 ++--
 meta/conf/bitbake.conf                       |  2 +-
 meta/recipes-devtools/rust/libstd-rs.inc     |  4 ++--
 meta/recipes-devtools/rust/rust.inc          | 10 +++++-----
 meta/recipes-gnome/librsvg/librsvg_2.54.4.bb |  4 ++--
 9 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/meta/classes/cargo.bbclass b/meta/classes/cargo.bbclass
index 4a780a501ff..539ff03ec7d 100644
--- a/meta/classes/cargo.bbclass
+++ b/meta/classes/cargo.bbclass
@@ -32,12 +32,12 @@ MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml"
 
 RUSTFLAGS ??= ""
 BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}"
-CARGO_BUILD_FLAGS = "-v --target ${HOST_SYS} ${BUILD_MODE} --manifest-path=${MANIFEST_PATH}"
+CARGO_BUILD_FLAGS = "-v --target ${RUST_HOST_SYS} ${BUILD_MODE} --manifest-path=${MANIFEST_PATH}"
 
 # This is based on the content of CARGO_BUILD_FLAGS and generally will need to
 # change if CARGO_BUILD_FLAGS changes.
 BUILD_DIR = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}"
-CARGO_TARGET_SUBDIR="${HOST_SYS}/${BUILD_DIR}"
+CARGO_TARGET_SUBDIR="${RUST_HOST_SYS}/${BUILD_DIR}"
 oe_cargo_build () {
 	export RUSTFLAGS="${RUSTFLAGS}"
 	export RUST_TARGET_PATH="${RUST_TARGET_PATH}"
diff --git a/meta/classes/cargo_common.bbclass b/meta/classes/cargo_common.bbclass
index 39f32829fd4..dcd0afd9801 100644
--- a/meta/classes/cargo_common.bbclass
+++ b/meta/classes/cargo_common.bbclass
@@ -69,15 +69,15 @@ cargo_common_do_configure () {
 	cat <<- EOF >> ${CARGO_HOME}/config
 
 	# HOST_SYS
-	[target.${HOST_SYS}]
+	[target.${RUST_HOST_SYS}]
 	linker = "${CARGO_RUST_TARGET_CCLD}"
 	EOF
 
-	if [ "${HOST_SYS}" != "${BUILD_SYS}" ]; then
+	if [ "${RUST_HOST_SYS}" != "${RUST_BUILD_SYS}" ]; then
 		cat <<- EOF >> ${CARGO_HOME}/config
 
 		# BUILD_SYS
-		[target.${BUILD_SYS}]
+		[target.${RUST_BUILD_SYS}]
 		linker = "${RUST_BUILD_CCLD}"
 		EOF
 	fi
diff --git a/meta/classes/python_pyo3.bbclass b/meta/classes/python_pyo3.bbclass
index 10cc3a06457..b41e3ba0752 100644
--- a/meta/classes/python_pyo3.bbclass
+++ b/meta/classes/python_pyo3.bbclass
@@ -8,7 +8,7 @@ inherit cargo python3-dir siteinfo
 export PYO3_CROSS="1"
 export PYO3_CROSS_PYTHON_VERSION="${PYTHON_BASEVERSION}"
 export PYO3_CROSS_LIB_DIR="${STAGING_LIBDIR}"
-export CARGO_BUILD_TARGET="${HOST_SYS}"
+export CARGO_BUILD_TARGET="${RUST_HOST_SYS}"
 export RUSTFLAGS
 export PYO3_PYTHON="${PYTHON}"
 export PYO3_CONFIG_FILE="${WORKDIR}/pyo3.config"
diff --git a/meta/classes/rust-target-config.bbclass b/meta/classes/rust-target-config.bbclass
index 1721839922e..7fe039601af 100644
--- a/meta/classes/rust-target-config.bbclass
+++ b/meta/classes/rust-target-config.bbclass
@@ -360,7 +360,7 @@ def rust_gen_target(d, thing, wd, arch):
         json.dump(tspec, f, indent=4)
 
 # These are accounted for in tmpdir path names so don't need to be in the task sig
-rust_gen_target[vardepsexclude] += "RUST_HOST_SYS RUST_TARGET_SYS ABIEXTENSION llvm_cpu"
+rust_gen_target[vardepsexclude] += "ABIEXTENSION llvm_cpu"
 
 do_rust_gen_targets[vardeps] += "DATA_LAYOUT TARGET_ENDIAN TARGET_POINTER_WIDTH TARGET_C_INT_WIDTH MAX_ATOMIC_WIDTH FEATURES"
 
diff --git a/meta/classes/rust.bbclass b/meta/classes/rust.bbclass
index 5c8938d09fe..f20e063c5be 100644
--- a/meta/classes/rust.bbclass
+++ b/meta/classes/rust.bbclass
@@ -2,7 +2,7 @@ inherit rust-common
 
 RUSTC = "rustc"
 
-RUSTC_ARCHFLAGS += "--target=${HOST_SYS} ${RUSTFLAGS}"
+RUSTC_ARCHFLAGS += "--target=${RUST_HOST_SYS} ${RUSTFLAGS}"
 
 def rust_base_dep(d):
     # Taken from meta/classes/base.bbclass `base_dep_prepend` and modified to
@@ -37,7 +37,7 @@ HOST_CFLAGS   ?= "${CFLAGS}"
 HOST_CXXFLAGS ?= "${CXXFLAGS}"
 HOST_CPPFLAGS ?= "${CPPFLAGS}"
 
-rustlib_suffix="${TUNE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${HOST_SYS}/lib"
+rustlib_suffix="${TUNE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/rustlib/${RUST_HOST_SYS}/lib"
 # Native sysroot standard library path
 rustlib_src="${prefix}/lib/${rustlib_suffix}"
 # Host sysroot standard library path
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 1d36aae8b35..bdfb6784371 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -943,7 +943,7 @@ BB_HASHEXCLUDE_COMMON ?= "TMPDIR FILE PATH PWD BB_TASKHASH BBPATH BBSERVER DL_DI
     SSTATE_HASHEQUIV_OWNER CCACHE_TOP_DIR BB_HASHSERVE GIT_CEILING_DIRECTORIES \
     OMP_NUM_THREADS BB_CURRENTTASK"
 BB_BASEHASH_IGNORE_VARS ?= "${BB_HASHEXCLUDE_COMMON} PSEUDO_IGNORE_PATHS BUILDHISTORY_DIR \
-    SSTATE_DIR SOURCE_DATE_EPOCH"
+    SSTATE_DIR SOURCE_DATE_EPOCH RUST_BUILD_SYS RUST_HOST_SYS RUST_TARGET_SYS"
 BB_HASHCONFIG_IGNORE_VARS ?= "${BB_HASHEXCLUDE_COMMON} DATE TIME SSH_AGENT_PID \
     SSH_AUTH_SOCK PSEUDO_BUILD BB_ENV_PASSTHROUGH_ADDITIONS DISABLE_SANITY_CHECKS \
     PARALLEL_MAKE BB_NUMBER_THREADS BB_ORIGENV BB_INVALIDCONF BBINCLUDED \
diff --git a/meta/recipes-devtools/rust/libstd-rs.inc b/meta/recipes-devtools/rust/libstd-rs.inc
index 987956344a2..d49383ced58 100644
--- a/meta/recipes-devtools/rust/libstd-rs.inc
+++ b/meta/recipes-devtools/rust/libstd-rs.inc
@@ -35,6 +35,6 @@ do_install () {
     # With the incremental build support added in 1.24, the libstd deps directory also includes dependency
     # files that get installed. Those are really only needed to incrementally rebuild the libstd library
     # itself and don't need to be installed.
-    rm -f ${B}/${TARGET_SYS}/${BUILD_DIR}/deps/*.d
-    cp ${B}/${TARGET_SYS}/${BUILD_DIR}/deps/* ${D}${rustlibdir}
+    rm -f ${B}/${RUST_TARGET_SYS}/${BUILD_DIR}/deps/*.d
+    cp ${B}/${RUST_TARGET_SYS}/${BUILD_DIR}/deps/* ${D}${rustlibdir}
 }
diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index ecb057ad3b5..aa067932fdd 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -79,7 +79,7 @@ python do_configure() {
     config = configparser.RawConfigParser()
 
     # [target.ARCH-poky-linux]
-    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    target_section = "target.{}".format(d.getVar('RUST_TARGET_SYS', True))
     config.add_section(target_section)
 
     llvm_config = d.expand("${YOCTO_ALTERNATE_EXE_PATH}")
@@ -128,11 +128,11 @@ python do_configure() {
     config.set("build", "vendor", e(True))
 
     if not "targets" in locals():
-        targets = [d.getVar("TARGET_SYS", True)]
+        targets = [d.getVar("RUST_TARGET_SYS", True)]
     config.set("build", "target", e(targets))
 
     if not "hosts" in locals():
-        hosts = [d.getVar("HOST_SYS", True)]
+        hosts = [d.getVar("RUST_HOST_SYS", True)]
     config.set("build", "host", e(hosts))
 
     # We can't use BUILD_SYS since that is something the rust snapshot knows
@@ -181,10 +181,10 @@ do_compile () {
 
 rust_do_install () {
     mkdir -p ${D}${bindir}
-    cp build/${HOST_SYS}/stage2/bin/* ${D}${bindir}
+    cp build/${RUST_HOST_SYS}/stage2/bin/* ${D}${bindir}
 
     mkdir -p ${D}${libdir}/rustlib
-    cp -pRd build/${HOST_SYS}/stage2/lib/* ${D}${libdir}
+    cp -pRd build/${RUST_HOST_SYS}/stage2/lib/* ${D}${libdir}
     # Remove absolute symlink so bitbake doesn't complain
     rm -f ${D}${libdir}/rustlib/src/rust
 }
diff --git a/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb b/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb
index cc7fb9bbdfe..f3bbeb74ebe 100644
--- a/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb
+++ b/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb
@@ -31,7 +31,7 @@ export RUST_BACKTRACE = "full"
 export RUSTFLAGS
 export RUST_TARGET_PATH
 
-export RUST_TARGET = "${HOST_SYS}"
+export RUST_TARGET = "${RUST_HOST_SYS}"
 
 RUSTFLAGS:append:mips = " --cfg crossbeam_no_atomic_64"
 RUSTFLAGS:append:mipsel = " --cfg crossbeam_no_atomic_64"
@@ -45,7 +45,7 @@ RUSTFLAGS:append:riscv32 = " --cfg crossbeam_no_atomic_64"
 do_compile:prepend() {
     cp ${STAGING_LIBDIR_NATIVE}/rustlib/${HOST_SYS}.json ${WORKDIR}
     cp ${STAGING_LIBDIR_NATIVE}/rustlib/${BUILD_SYS}.json ${WORKDIR}
-    sed -ie 's,"linker": ".*","linker": "${RUST_TARGET_CC}",g' ${WORKDIR}/${HOST_SYS}.json
+    sed -ie 's,"linker": ".*","linker": "${RUST_TARGET_CC}",g' ${WORKDIR}/${RUST_HOST_SYS}.json
     RUST_TARGET_PATH="${WORKDIR}"
     export RUST_TARGET_PATH
 }
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 11/29] rust.inc: Rename variables to make code clearer
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (8 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 10/29] rust: Switch to use RUST_XXX_SYS consistently Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 12/29] rust.inc: Fix cross build llvm-config handling Richard Purdie
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Instead of reusing a "target_section" variable, name them host and build
section instead. This patch sets things up for other improvementsm,
separating out the renaming.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/rust/rust.inc | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index aa067932fdd..30f2b71fe8c 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -79,24 +79,24 @@ python do_configure() {
     config = configparser.RawConfigParser()
 
     # [target.ARCH-poky-linux]
-    target_section = "target.{}".format(d.getVar('RUST_TARGET_SYS', True))
-    config.add_section(target_section)
+    host_section = "target.{}".format(d.getVar('RUST_TARGET_SYS', True))
+    config.add_section(host_section)
 
     llvm_config = d.expand("${YOCTO_ALTERNATE_EXE_PATH}")
-    config.set(target_section, "llvm-config", e(llvm_config))
+    config.set(host_section, "llvm-config", e(llvm_config))
 
-    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
-    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(host_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(host_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
 
     # If we don't do this rust-native will compile it's own llvm for BUILD.
     # [target.${BUILD_ARCH}-unknown-linux-gnu]
-    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
-    config.add_section(target_section)
+    build_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(build_section)
 
-    config.set(target_section, "llvm-config", e(llvm_config))
+    config.set(build_section, "llvm-config", e(llvm_config))
 
-    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
-    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+    config.set(build_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(build_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
 
     # [llvm]
     config.add_section("llvm")
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 12/29] rust.inc: Fix cross build llvm-config handling
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (9 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 11/29] rust.inc: Rename variables to make code clearer Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-07  0:56   ` [OE-core] " Khem Raj
  2022-08-05 13:12 ` [PATCH 13/29] rust/mesa: Drop obsolete YOCTO_ALTERNATE_MULTILIB_NAME Richard Purdie
                   ` (16 subsequent siblings)
  27 siblings, 1 reply; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

We need llvm-config for the target but the cross compiled target binary is
no good. We can copy the native one into the target location where it will
then return the target values though.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/rust/rust.inc | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index 30f2b71fe8c..47b76e725de 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -18,7 +18,8 @@ export RUST_TARGET_PATH="${WORKDIR}/targets/"
 export FORCE_CRATE_HASH="${BB_TASKHASH}"
 
 RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config"
-export YOCTO_ALTERNATE_EXE_PATH = "${RUST_ALTERNATE_EXE_PATH}"
+RUST_ALTERNATE_EXE_PATH_NATIVE = "${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config"
+
 export YOCTO_ALTERNATE_MULTILIB_NAME = "/${BASELIB}"
 
 # We don't want to use bitbakes vendoring because the rust sources do their
@@ -82,8 +83,9 @@ python do_configure() {
     host_section = "target.{}".format(d.getVar('RUST_TARGET_SYS', True))
     config.add_section(host_section)
 
-    llvm_config = d.expand("${YOCTO_ALTERNATE_EXE_PATH}")
-    config.set(host_section, "llvm-config", e(llvm_config))
+    llvm_config_target = d.expand("${RUST_ALTERNATE_EXE_PATH}")
+    llvm_config_build = d.expand("${RUST_ALTERNATE_EXE_PATH_NATIVE}")
+    config.set(host_section, "llvm-config", e(llvm_config_target))
 
     config.set(host_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
     config.set(host_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
@@ -93,7 +95,7 @@ python do_configure() {
     build_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
     config.add_section(build_section)
 
-    config.set(build_section, "llvm-config", e(llvm_config))
+    config.set(build_section, "llvm-config", e(llvm_config_build))
 
     config.set(build_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
     config.set(build_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
@@ -169,6 +171,14 @@ rust_runx () {
     unset CXXFLAGS
     unset CPPFLAGS
 
+    # Copy the natively built llvm-config into the target so we can run it. Horrible,
+    # but works!
+    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} ]; then
+        mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}`
+        cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
+        chrpath -d ${RUST_ALTERNATE_EXE_PATH}
+    fi
+
     oe_cargo_fix_env
 
     python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 13/29] rust/mesa: Drop obsolete YOCTO_ALTERNATE_MULTILIB_NAME
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (10 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 12/29] rust.inc: Fix cross build llvm-config handling Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 14/29] rust-target-config: Show clear error when target isn't defined Richard Purdie
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

This variable is no longer used by the llvm patches.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/rust/rust.inc | 2 --
 meta/recipes-graphics/mesa/mesa.inc | 1 -
 2 files changed, 3 deletions(-)

diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index 47b76e725de..7d1f5347ea7 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -20,8 +20,6 @@ export FORCE_CRATE_HASH="${BB_TASKHASH}"
 RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config"
 RUST_ALTERNATE_EXE_PATH_NATIVE = "${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config"
 
-export YOCTO_ALTERNATE_MULTILIB_NAME = "/${BASELIB}"
-
 # We don't want to use bitbakes vendoring because the rust sources do their
 # own vendoring.
 CARGO_DISABLE_BITBAKE_VENDORING = "1"
diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index f02ef2dc2bf..7e46fd9c15f 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -56,7 +56,6 @@ ANY_OF_DISTRO_FEATURES:class-target = "opengl vulkan"
 PLATFORMS ??= "${@bb.utils.filter('PACKAGECONFIG', 'x11 wayland', d)}"
 
 export YOCTO_ALTERNATE_EXE_PATH = "${STAGING_LIBDIR}/llvm-config"
-export YOCTO_ALTERNATE_MULTILIB_NAME = "${base_libdir}"
 export LLVM_CONFIG = "${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE}"
 export WANT_LLVM_RELEASE = "${MESA_LLVM_RELEASE}"
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 14/29] rust-target-config: Show clear error when target isn't defined
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (11 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 13/29] rust/mesa: Drop obsolete YOCTO_ALTERNATE_MULTILIB_NAME Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 15/29] rust: Generate per recipe target configuration files Richard Purdie
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-target-config.bbclass | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/classes/rust-target-config.bbclass b/meta/classes/rust-target-config.bbclass
index 7fe039601af..ab177cf59f4 100644
--- a/meta/classes/rust-target-config.bbclass
+++ b/meta/classes/rust-target-config.bbclass
@@ -326,6 +326,8 @@ def rust_gen_target(d, thing, wd, arch):
     tspec = {}
     tspec['llvm-target'] = llvm_target
     tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi)
+    if tspec['data-layout'] is None:
+        bb.fatal("No rust target defined for %s" % arch_abi)
     tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch_abi))
     tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch_abi)
     tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch_abi)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 15/29] rust: Generate per recipe target configuration files
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (12 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 14/29] rust-target-config: Show clear error when target isn't defined Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 16/29] rust-common/rust: Improve bootstrap BUILD_SYS handling Richard Purdie
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Instead of generating target configuration files centrally and often getting
it wrong, or having trouble finding the right set, generate them dynamically
from the bbclass into WORKDIR per recipe.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/cargo.bbclass                   |  3 ++-
 meta/classes/rust-bin.bbclass                |  1 -
 meta/classes/rust-common.bbclass             |  2 +-
 meta/classes/rust-target-config.bbclass      | 18 +++++++++---------
 meta/recipes-devtools/cargo/cargo.inc        |  2 ++
 meta/recipes-devtools/rust/libstd-rs.inc     |  3 +++
 meta/recipes-devtools/rust/rust.inc          |  5 ++---
 meta/recipes-gnome/librsvg/librsvg_2.54.4.bb | 14 +++++++-------
 8 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/meta/classes/cargo.bbclass b/meta/classes/cargo.bbclass
index 539ff03ec7d..2475d05b3d2 100644
--- a/meta/classes/cargo.bbclass
+++ b/meta/classes/cargo.bbclass
@@ -4,6 +4,7 @@
 ## Cargo.
 
 inherit cargo_common
+inherit rust-target-config
 
 # the binary we will use
 CARGO = "cargo"
@@ -40,7 +41,7 @@ BUILD_DIR = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}"
 CARGO_TARGET_SUBDIR="${RUST_HOST_SYS}/${BUILD_DIR}"
 oe_cargo_build () {
 	export RUSTFLAGS="${RUSTFLAGS}"
-	export RUST_TARGET_PATH="${RUST_TARGET_PATH}"
+	bbnote "Using rust targets from ${RUST_TARGET_PATH}"
 	bbnote "cargo = $(which ${CARGO})"
 	bbnote "rustc = $(which ${RUSTC})"
 	bbnote "${CARGO} build ${CARGO_BUILD_FLAGS} $@"
diff --git a/meta/classes/rust-bin.bbclass b/meta/classes/rust-bin.bbclass
index c87343b3cff..7a70a7b6ba3 100644
--- a/meta/classes/rust-bin.bbclass
+++ b/meta/classes/rust-bin.bbclass
@@ -93,7 +93,6 @@ do_configure () {
 }
 
 oe_runrustc () {
-	export RUST_TARGET_PATH="${RUST_TARGET_PATH}"
 	bbnote ${RUSTC} ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@"
 	"${RUSTC}" ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@"
 }
diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass
index 1bce7761ab0..adcf96f0cd9 100644
--- a/meta/classes/rust-common.bbclass
+++ b/meta/classes/rust-common.bbclass
@@ -1,4 +1,5 @@
 inherit python3native
+inherit rust-target-config
 
 # Common variables used by all Rust builds
 export rustlibdir = "${libdir}/rust"
@@ -10,7 +11,6 @@ RUSTLIB = "-L ${STAGING_LIBDIR}/rust"
 RUST_DEBUG_REMAP = "--remap-path-prefix=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}"
 RUSTFLAGS += "${RUSTLIB} ${RUST_DEBUG_REMAP}"
 RUSTLIB_DEP ?= "libstd-rs"
-export RUST_TARGET_PATH = "${STAGING_LIBDIR_NATIVE}/rustlib"
 RUST_PANIC_STRATEGY ?= "unwind"
 
 # Native builds are not effected by TCLIBC. Without this, rust-native
diff --git a/meta/classes/rust-target-config.bbclass b/meta/classes/rust-target-config.bbclass
index ab177cf59f4..bc6bd77abbf 100644
--- a/meta/classes/rust-target-config.bbclass
+++ b/meta/classes/rust-target-config.bbclass
@@ -292,6 +292,7 @@ def rust_gen_target(d, thing, wd, arch):
     import json
     sys = d.getVar('{}_SYS'.format(thing))
     prefix = d.getVar('{}_PREFIX'.format(thing))
+    rustsys = d.getVar('RUST_{}_SYS'.format(thing))
 
     abi = None
     cpu = "generic"
@@ -318,13 +319,9 @@ def rust_gen_target(d, thing, wd, arch):
     features = features or d.getVarFlag('FEATURES', arch_abi) or ""
     features = features.strip()
 
-    llvm_target = d.getVar('RUST_TARGET_SYS')
-    if thing == "BUILD":
-        llvm_target = d.getVar('RUST_HOST_SYS')
-
     # build tspec
     tspec = {}
-    tspec['llvm-target'] = llvm_target
+    tspec['llvm-target'] = rustsys
     tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi)
     if tspec['data-layout'] is None:
         bb.fatal("No rust target defined for %s" % arch_abi)
@@ -358,7 +355,7 @@ def rust_gen_target(d, thing, wd, arch):
     tspec['panic-strategy'] = d.getVar("RUST_PANIC_STRATEGY")
 
     # write out the target spec json file
-    with open(wd + sys + '.json', 'w') as f:
+    with open(wd + rustsys + '.json', 'w') as f:
         json.dump(tspec, f, indent=4)
 
 # These are accounted for in tmpdir path names so don't need to be in the task sig
@@ -366,10 +363,13 @@ rust_gen_target[vardepsexclude] += "ABIEXTENSION llvm_cpu"
 
 do_rust_gen_targets[vardeps] += "DATA_LAYOUT TARGET_ENDIAN TARGET_POINTER_WIDTH TARGET_C_INT_WIDTH MAX_ATOMIC_WIDTH FEATURES"
 
-RUST_TARGETGENS = "BUILD"
+RUST_TARGETS_DIR = "${WORKDIR}/rust-targets/"
+export RUST_TARGET_PATH = "${RUST_TARGETS_DIR}"
+
+RUST_TARGETGENS = "BUILD HOST TARGET"
 
 python do_rust_gen_targets () {
-    wd = d.getVar('WORKDIR') + '/targets/'
+    wd = d.getVar('RUST_TARGETS_DIR')
     # Order of BUILD, HOST, TARGET is important in case the files overwrite, most specific last
     rust_gen_target(d, 'BUILD', wd, d.getVar('BUILD_ARCH'))
     if "HOST" in d.getVar("RUST_TARGETGENS"):
@@ -379,5 +379,5 @@ python do_rust_gen_targets () {
 }
 
 addtask rust_gen_targets after do_patch before do_compile
-do_rust_gen_targets[dirs] += "${WORKDIR}/targets"
+do_rust_gen_targets[dirs] += "${RUST_TARGETS_DIR}"
 
diff --git a/meta/recipes-devtools/cargo/cargo.inc b/meta/recipes-devtools/cargo/cargo.inc
index 607c51fc3d1..978504052b9 100644
--- a/meta/recipes-devtools/cargo/cargo.inc
+++ b/meta/recipes-devtools/cargo/cargo.inc
@@ -18,6 +18,8 @@ EXCLUDE_FROM_WORLD = "1"
 
 inherit cargo pkgconfig
 
+RUST_TARGETGENS = "BUILD HOST TARGET"
+
 do_cargo_setup_snapshot () {
 	${WORKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh --prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfig
 	# Need to use uninative's loader if enabled/present since the library paths
diff --git a/meta/recipes-devtools/rust/libstd-rs.inc b/meta/recipes-devtools/rust/libstd-rs.inc
index d49383ced58..1498b88f0e2 100644
--- a/meta/recipes-devtools/rust/libstd-rs.inc
+++ b/meta/recipes-devtools/rust/libstd-rs.inc
@@ -12,6 +12,9 @@ DEPENDS:append:libc-musl = " libunwind"
 DEPENDS:remove:riscv32 = "libunwind"
 DEPENDS:remove:riscv64 = "libunwind"
 
+
+RUST_TARGETGENS = "BUILD HOST TARGET"
+
 # Embed bitcode in order to allow compiling both with and without LTO
 RUSTFLAGS += "-Cembed-bitcode=yes"
 # Needed so cargo can find libbacktrace
diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index 7d1f5347ea7..172cd22657d 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -12,9 +12,6 @@ DEPENDS:append:class-native = " rust-llvm-native"
 
 S = "${RUSTSRC}"
 
-# We generate local targets, and need to be able to locate them
-export RUST_TARGET_PATH="${WORKDIR}/targets/"
-
 export FORCE_CRATE_HASH="${BB_TASKHASH}"
 
 RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config"
@@ -40,6 +37,8 @@ setup_cargo_environment () {
 
 inherit rust-target-config
 
+RUST_TARGETGENS = "BUILD HOST TARGET"
+
 do_rust_setup_snapshot () {
     for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
         "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
diff --git a/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb b/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb
index f3bbeb74ebe..82b1bf9bcef 100644
--- a/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb
+++ b/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb
@@ -14,7 +14,7 @@ SECTION = "x11/utils"
 DEPENDS = "cairo gdk-pixbuf glib-2.0 libxml2 pango python3-docutils-native"
 BBCLASSEXTEND = "native nativesdk"
 
-inherit gnomebase pixbufcache upstream-version-is-even gobject-introspection rust vala gi-docgen
+inherit cargo_common gnomebase pixbufcache upstream-version-is-even gobject-introspection rust vala gi-docgen
 
 SRC_URI += "file://0001-Makefile.am-pass-rust-target-to-cargo-also-when-not-.patch \
            file://0001-system-deps-src-lib.rs-do-not-probe-into-harcoded-li.patch \
@@ -29,7 +29,6 @@ BASEDEPENDS:append = " cargo-native"
 
 export RUST_BACKTRACE = "full"
 export RUSTFLAGS
-export RUST_TARGET_PATH
 
 export RUST_TARGET = "${RUST_HOST_SYS}"
 
@@ -38,16 +37,17 @@ RUSTFLAGS:append:mipsel = " --cfg crossbeam_no_atomic_64"
 RUSTFLAGS:append:powerpc = " --cfg crossbeam_no_atomic_64"
 RUSTFLAGS:append:riscv32 = " --cfg crossbeam_no_atomic_64"
 
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+do_configure[postfuncs] += "cargo_common_do_configure"
+
+inherit rust-target-config
+
 # rust-cross writes the target linker binary into target json definition without any flags.
 # This breaks here because the linker isn't going to work without at least knowing where
 # the sysroot is. So copy the json to workdir, and patch in the path to wrapper from rust class
 # which supplies the needed flags.
 do_compile:prepend() {
-    cp ${STAGING_LIBDIR_NATIVE}/rustlib/${HOST_SYS}.json ${WORKDIR}
-    cp ${STAGING_LIBDIR_NATIVE}/rustlib/${BUILD_SYS}.json ${WORKDIR}
-    sed -ie 's,"linker": ".*","linker": "${RUST_TARGET_CC}",g' ${WORKDIR}/${RUST_HOST_SYS}.json
-    RUST_TARGET_PATH="${WORKDIR}"
-    export RUST_TARGET_PATH
+    sed -ie 's,"linker": ".*","linker": "${RUST_TARGET_CC}",g' ${RUST_TARGETS_DIR}/${RUST_HOST_SYS}.json
 }
 
 # Issue only on windows
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 16/29] rust-common/rust: Improve bootstrap BUILD_SYS handling
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (13 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 15/29] rust: Generate per recipe target configuration files Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 17/29] cargo_common: Handle build SYS as well as HOST/TARGET Richard Purdie
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Move the "unknown" vendor workaround used during bootstrap to a
central location so it is applied consistently to all RUST_BUILD_SYS
values rather than some subset.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-common.bbclass    | 5 +++++
 meta/recipes-devtools/rust/rust.inc | 7 +++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass
index adcf96f0cd9..f2e99493fef 100644
--- a/meta/classes/rust-common.bbclass
+++ b/meta/classes/rust-common.bbclass
@@ -68,6 +68,11 @@ def rust_base_triple(d, thing):
     else:
         arch = oe.rust.arch_to_rust_arch(d.getVar('{}_ARCH'.format(thing)))
 
+    # When bootstrapping rust-native, BUILD must be the same as upstream snapshot tarballs
+    bpn = d.getVar('BPN')
+    if thing == "BUILD" and bpn in ["rust"]:
+        return arch + "-unknown-linux-gnu"
+
     # All the Yocto targets are Linux and are 'unknown'
     vendor = "-unknown"
     os = d.getVar('{}_OS'.format(thing))
diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index 172cd22657d..5730887411a 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -23,7 +23,6 @@ CARGO_DISABLE_BITBAKE_VENDORING = "1"
 
 # We can't use RUST_BUILD_SYS here because that may be "musl" if
 # TCLIBC="musl". Snapshots are always -unknown-linux-gnu
-SNAPSHOT_BUILD_SYS = "${RUST_BUILD_ARCH}-unknown-linux-gnu"
 setup_cargo_environment () {
     # The first step is to build bootstrap and some early stage tools,
     # these are build for the same target as the snapshot, e.g.
@@ -31,7 +30,7 @@ setup_cargo_environment () {
     # Later stages are build for the native target (i.e. target.x86_64-linux)
     cargo_common_do_configure
 
-    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf '[target.%s]\n' "${RUST_BUILD_SYS}" >> ${CARGO_HOME}/config
     printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
 }
 
@@ -89,7 +88,7 @@ python do_configure() {
 
     # If we don't do this rust-native will compile it's own llvm for BUILD.
     # [target.${BUILD_ARCH}-unknown-linux-gnu]
-    build_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    build_section = "target.{}".format(d.getVar('RUST_BUILD_SYS', True))
     config.add_section(build_section)
 
     config.set(build_section, "llvm-config", e(llvm_config_build))
@@ -136,7 +135,7 @@ python do_configure() {
 
     # We can't use BUILD_SYS since that is something the rust snapshot knows
     # nothing about when trying to build some stage0 tools (like fabricate)
-    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+    config.set("build", "build", e(d.getVar("RUST_BUILD_SYS", True)))
 
     # [install]
     config.add_section("install")
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 17/29] cargo_common: Handle build SYS as well as HOST/TARGET
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (14 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 16/29] rust-common/rust: Improve bootstrap BUILD_SYS handling Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 18/29] rust-llvm: Enable nativesdk variant Richard Purdie
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Improve the common class to handle BUILD_SYS as well as host and target,
removing the need to a workaround in the rust recipe.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/cargo_common.bbclass   | 9 +++++++++
 meta/recipes-devtools/rust/rust.inc | 3 ---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/meta/classes/cargo_common.bbclass b/meta/classes/cargo_common.bbclass
index dcd0afd9801..4a419cdd0a3 100644
--- a/meta/classes/cargo_common.bbclass
+++ b/meta/classes/cargo_common.bbclass
@@ -82,6 +82,15 @@ cargo_common_do_configure () {
 		EOF
 	fi
 
+	if [ "${RUST_TARGET_SYS}" != "${RUST_BUILD_SYS}" -a "${RUST_TARGET_SYS}" != "${RUST_HOST_SYS}"]; then
+		cat <<- EOF >> ${CARGO_HOME}/config
+
+		# TARGET_SYS
+		[target.${RUST_TARGET_SYS}]
+		linker = "${RUST_TARGET_CCLD}"
+		EOF
+	fi
+
 	# Put build output in build directory preferred by bitbake instead of
 	# inside source directory unless they are the same
 	if [ "${B}" != "${S}" ]; then
diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index 5730887411a..12c86e02c4a 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -29,9 +29,6 @@ setup_cargo_environment () {
     # x86_64-unknown-linux-gnu.
     # Later stages are build for the native target (i.e. target.x86_64-linux)
     cargo_common_do_configure
-
-    printf '[target.%s]\n' "${RUST_BUILD_SYS}" >> ${CARGO_HOME}/config
-    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
 }
 
 inherit rust-target-config
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 18/29] rust-llvm: Enable nativesdk variant
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (15 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 17/29] cargo_common: Handle build SYS as well as HOST/TARGET Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 14:51   ` [OE-core] " Peter Kjellerstedt
  2022-08-05 13:12 ` [PATCH 19/29] rust.inc: Fix for cross compilation configuration Richard Purdie
                   ` (10 subsequent siblings)
  27 siblings, 1 reply; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

The allow nativesdk variants of the tools to build, enable a nativesdk
variant of rust-llvm.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/rust/rust-llvm.inc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-devtools/rust/rust-llvm.inc b/meta/recipes-devtools/rust/rust-llvm.inc
index 9baad12dc8e..625eb570416 100644
--- a/meta/recipes-devtools/rust/rust-llvm.inc
+++ b/meta/recipes-devtools/rust/rust-llvm.inc
@@ -47,6 +47,13 @@ EXTRA_OECMAKE:append:class-target = "\
     -DLLVM_CONFIG_PATH=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config \
 "
 
+EXTRA_OECMAKE:append:class-nativesdk = "\
+    -DCMAKE_CROSSCOMPILING:BOOL=ON \
+    -DLLVM_BUILD_TOOLS=OFF \
+    -DLLVM_TABLEGEN=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-tblgen \
+    -DLLVM_CONFIG_PATH=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config \
+"
+
 # The debug symbols are huge here (>2GB) so suppress them since they
 # provide almost no value. If you really need them then override this
 INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
@@ -68,4 +75,4 @@ FILES:${PN}-staticdev =+ "${libdir}/llvm-rust/*/*.a"
 FILES:${PN} += "${libdir}/libLLVM*.so.* ${libdir}/llvm-rust/lib/*.so.* ${libdir}/llvm-rust/bin"
 FILES:${PN}-dev += "${datadir}/llvm ${libdir}/llvm-rust/lib/*.so ${libdir}/llvm-rust/include ${libdir}/llvm-rust/share ${libdir}/llvm-rust/lib/cmake"
 
-BBCLASSEXTEND = "native"
+BBCLASSEXTEND = "native nativesdk"
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 19/29] rust.inc: Fix for cross compilation configuration
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (16 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 18/29] rust-llvm: Enable nativesdk variant Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 20/29] rust-common: Update to match cross targets Richard Purdie
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

For cross compilation, build, host and target may be different. Ensure
the main rust config has the appropriate sections added to match the
configurations.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/rust/rust.inc | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index 12c86e02c4a..7c16b8165bb 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -73,7 +73,7 @@ python do_configure() {
     config = configparser.RawConfigParser()
 
     # [target.ARCH-poky-linux]
-    host_section = "target.{}".format(d.getVar('RUST_TARGET_SYS', True))
+    host_section = "target.{}".format(d.getVar('RUST_HOST_SYS', True))
     config.add_section(host_section)
 
     llvm_config_target = d.expand("${RUST_ALTERNATE_EXE_PATH}")
@@ -86,12 +86,22 @@ python do_configure() {
     # If we don't do this rust-native will compile it's own llvm for BUILD.
     # [target.${BUILD_ARCH}-unknown-linux-gnu]
     build_section = "target.{}".format(d.getVar('RUST_BUILD_SYS', True))
-    config.add_section(build_section)
+    if build_section != host_section:
+        config.add_section(build_section)
 
-    config.set(build_section, "llvm-config", e(llvm_config_build))
+        config.set(build_section, "llvm-config", e(llvm_config_build))
 
-    config.set(build_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
-    config.set(build_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+        config.set(build_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+        config.set(build_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    target_section = "target.{}".format(d.getVar('RUST_TARGET_SYS', True))
+    if target_section != host_section and target_section != build_section:
+        config.add_section(target_section)
+
+        config.set(target_section, "llvm-config", e(llvm_config_target))
+
+        config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+        config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
 
     # [llvm]
     config.add_section("llvm")
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 20/29] rust-common: Update to match cross targets
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (17 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 19/29] rust.inc: Fix for cross compilation configuration Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 21/29] rust-target-config: Make target workaround generic Richard Purdie
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Tweak the armv7 workaround to work for cross environments and as a host
triplet and not just as a target.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-common.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass
index f2e99493fef..7c432ed131b 100644
--- a/meta/classes/rust-common.bbclass
+++ b/meta/classes/rust-common.bbclass
@@ -63,7 +63,7 @@ def rust_base_triple(d, thing):
     '''
 
     # The llvm-target for armv7 is armv7-unknown-linux-gnueabihf
-    if thing == "TARGET" and target_is_armv7(d):
+    if d.getVar('{}_ARCH'.format(thing)) == d.getVar('TARGET_ARCH') and target_is_armv7(d):
         arch = "armv7"
     else:
         arch = oe.rust.arch_to_rust_arch(d.getVar('{}_ARCH'.format(thing)))
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 21/29] rust-target-config: Make target workaround generic
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (18 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 20/29] rust-common: Update to match cross targets Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 14:47   ` [OE-core] " Peter Kjellerstedt
  2022-08-05 13:12 ` [PATCH 22/29] rust-common: Simplify libc handling Richard Purdie
                   ` (7 subsequent siblings)
  27 siblings, 1 reply; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Ensure the 'target' data is set for both HOST and TARGET queries
as appropriate to work correctly in cross configurations.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-target-config.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/meta/classes/rust-target-config.bbclass b/meta/classes/rust-target-config.bbclass
index bc6bd77abbf..b3c738f02a4 100644
--- a/meta/classes/rust-target-config.bbclass
+++ b/meta/classes/rust-target-config.bbclass
@@ -290,6 +290,10 @@ llvm_cpu[vardepvalue] = "${@llvm_cpu(d)}"
 
 def rust_gen_target(d, thing, wd, arch):
     import json
+
+    build_sys = d.getVar('BUILD_SYS')
+    target_sys = d.getVar('TARGET_SYS')
+
     sys = d.getVar('{}_SYS'.format(thing))
     prefix = d.getVar('{}_PREFIX'.format(thing))
     rustsys = d.getVar('RUST_{}_SYS'.format(thing))
@@ -298,7 +302,9 @@ def rust_gen_target(d, thing, wd, arch):
     cpu = "generic"
     features = ""
 
-    if thing == "TARGET":
+    # Need to apply the target tuning conssitently, only if the triplet applies to the target
+    # and not in the native case
+    if sys == target_sys and sys != build_sys:
         abi = d.getVar('ABIEXTENSION')
         cpu = llvm_cpu(d)
         if bb.data.inherits_class('native', d):
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 22/29] rust-common: Simplify libc handling
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (19 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 21/29] rust-target-config: Make target workaround generic Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 23/29] cargo: Drop cross-canadian variant and fix/use nativesdk Richard Purdie
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

The current libc handling code is simply wrong in many cases. Simplify it
to a check of the triplet for musl handling which is much simpler and less
error prone when handling things like nativesdk targets.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-common.bbclass | 45 ++++++--------------------------
 1 file changed, 8 insertions(+), 37 deletions(-)

diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass
index 7c432ed131b..516b258c15e 100644
--- a/meta/classes/rust-common.bbclass
+++ b/meta/classes/rust-common.bbclass
@@ -13,27 +13,6 @@ RUSTFLAGS += "${RUSTLIB} ${RUST_DEBUG_REMAP}"
 RUSTLIB_DEP ?= "libstd-rs"
 RUST_PANIC_STRATEGY ?= "unwind"
 
-# Native builds are not effected by TCLIBC. Without this, rust-native
-# thinks it's "target" (i.e. x86_64-linux) is a musl target.
-RUST_LIBC = "${TCLIBC}"
-RUST_LIBC:class-crosssdk = "glibc"
-RUST_LIBC:class-native = "glibc"
-
-def determine_libc(d, thing):
-    '''Determine which libc something should target'''
-
-    # BUILD is never musl, TARGET may be musl or glibc,
-    # HOST could be musl, but only if a compiler is built to be run on
-    # target in which case HOST_SYS != BUILD_SYS.
-    if thing == 'TARGET':
-        libc = d.getVar('RUST_LIBC')
-    elif thing == 'BUILD' and (d.getVar('HOST_SYS') != d.getVar('BUILD_SYS')):
-        libc = d.getVar('RUST_LIBC')
-    else:
-        libc = d.getVar('RUST_LIBC:class-native')
-
-    return libc
-
 def target_is_armv7(d):
     '''Determine if target is armv7'''
     # TUNE_FEATURES may include arm* even if the target is not arm
@@ -73,26 +52,18 @@ def rust_base_triple(d, thing):
     if thing == "BUILD" and bpn in ["rust"]:
         return arch + "-unknown-linux-gnu"
 
-    # All the Yocto targets are Linux and are 'unknown'
-    vendor = "-unknown"
-    os = d.getVar('{}_OS'.format(thing))
-    libc = determine_libc(d, thing)
-
-    # Prefix with a dash and convert glibc -> gnu
-    if libc == "glibc":
-        libc = "-gnu"
-    elif libc == "musl":
-        libc = "-musl"
-
-    # Don't double up musl (only appears to be the case on aarch64)
-    if os == "linux-musl":
-        if libc != "-musl":
-            bb.fatal("{}_OS was '{}' but TCLIBC was not 'musl'".format(thing, os))
-        os = "linux"
+    vendor = d.getVar('{}_VENDOR'.format(thing))
 
+    # Default to glibc
+    libc = "-gnu"
+    os = d.getVar('{}_OS'.format(thing))
     # This catches ARM targets and appends the necessary hard float bits
     if os == "linux-gnueabi" or os == "linux-musleabi":
         libc = bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hf', '', d)
+    elif "musl" in os:
+        libc = "-musl"
+        os = "linux"
+
     return arch + vendor + '-' + os + libc
 
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 23/29] cargo: Drop cross-canadian variant and fix/use nativesdk
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (20 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 22/29] rust-common: Simplify libc handling Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 24/29] rust-common: Set rustlibdir to match target expectation Richard Purdie
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

The cargo-cross-candian variant made no sense as one version of cargo in
the SDK can work for all targets. Replace it with nativesdk-cargo instead.

Move the SDK env to rust-cross-canadian.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/conf/distro/include/maintainers.inc      |  1 -
 .../packagegroup-rust-cross-canadian.bb       |  3 +-
 .../cargo/cargo-cross-canadian.inc            | 85 -------------------
 .../cargo/cargo-cross-canadian_1.62.0.bb      |  6 --
 meta/recipes-devtools/cargo/cargo.inc         |  5 ++
 meta/recipes-devtools/cargo/cargo_1.62.0.bb   |  1 +
 .../rust/rust-cross-canadian.inc              | 37 ++++++++
 7 files changed, 44 insertions(+), 94 deletions(-)
 delete mode 100644 meta/recipes-devtools/cargo/cargo-cross-canadian.inc
 delete mode 100644 meta/recipes-devtools/cargo/cargo-cross-canadian_1.62.0.bb

diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc
index e20275c6746..b563c517962 100644
--- a/meta/conf/distro/include/maintainers.inc
+++ b/meta/conf/distro/include/maintainers.inc
@@ -90,7 +90,6 @@ RECIPE_MAINTAINER:pn-bzip2 = "Denys Dmytriyenko <denis@denix.org>"
 RECIPE_MAINTAINER:pn-ca-certificates = "Alexander Kanavin <alex.kanavin@gmail.com>"
 RECIPE_MAINTAINER:pn-cairo = "Anuj Mittal <anuj.mittal@intel.com>"
 RECIPE_MAINTAINER:pn-cargo = "Randy MacLeod <Randy.MacLeod@windriver.com>"
-RECIPE_MAINTAINER:pn-cargo-cross-canadian-${TRANSLATED_TARGET_ARCH} = "Randy MacLeod <Randy.MacLeod@windriver.com>"
 RECIPE_MAINTAINER:pn-cantarell-fonts = "Alexander Kanavin <alex.kanavin@gmail.com>"
 RECIPE_MAINTAINER:pn-ccache = "Robert Yang <liezhi.yang@windriver.com>"
 RECIPE_MAINTAINER:pn-cdrtools-native = "Yi Zhao <yi.zhao@windriver.com>"
diff --git a/meta/recipes-core/packagegroups/packagegroup-rust-cross-canadian.bb b/meta/recipes-core/packagegroups/packagegroup-rust-cross-canadian.bb
index 0d4f5ec9ef2..6d324002a1a 100644
--- a/meta/recipes-core/packagegroups/packagegroup-rust-cross-canadian.bb
+++ b/meta/recipes-core/packagegroups/packagegroup-rust-cross-canadian.bb
@@ -6,12 +6,11 @@ inherit cross-canadian packagegroup
 PACKAGEGROUP_DISABLE_COMPLEMENTARY = "1"
 
 RUST="rust-cross-canadian-${TRANSLATED_TARGET_ARCH}"
-CARGO="cargo-cross-canadian-${TRANSLATED_TARGET_ARCH}"
 RUST_TOOLS="rust-tools-cross-canadian-${TRANSLATED_TARGET_ARCH}"
 
 RDEPENDS:${PN} = " \
     ${@all_multilib_tune_values(d, 'RUST')} \
-    ${@all_multilib_tune_values(d, 'CARGO')} \
+    nativesdk-cargo \
     rust-cross-canadian-src \
     ${@all_multilib_tune_values(d, 'RUST_TOOLS')} \
 "
diff --git a/meta/recipes-devtools/cargo/cargo-cross-canadian.inc b/meta/recipes-devtools/cargo/cargo-cross-canadian.inc
deleted file mode 100644
index a2fac929d45..00000000000
--- a/meta/recipes-devtools/cargo/cargo-cross-canadian.inc
+++ /dev/null
@@ -1,85 +0,0 @@
-SUMMARY = "Cargo, a package manager for Rust cross canadian flavor."
-
-RUST_ALTERNATE_EXE_PATH = "${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config"
-
-HOST_SYS = "${HOST_ARCH}-unknown-linux-gnu"
-CARGO_RUST_TARGET_CCLD = "${RUST_BUILD_CCLD}"
-
-inherit rust-target-config
-require cargo.inc
-
-CARGO = "${WORKDIR}/${CARGO_SNAPSHOT}/bin/cargo"
-BASEDEPENDS:remove = "cargo-native"
-
-export RUST_TARGET_PATH="${WORKDIR}/targets/"
-
-RUSTLIB = " \
-	-L ${STAGING_DIR_NATIVE}/${SDKPATHNATIVE}/usr/lib/${TARGET_SYS}/rustlib/${HOST_SYS}/lib \
-"
-
-DEPENDS += "rust-native \
-            rust-cross-canadian-${TRANSLATED_TARGET_ARCH} \
-            virtual/nativesdk-${HOST_PREFIX}compilerlibs \
-            nativesdk-openssl nativesdk-zlib \
-            virtual/nativesdk-libc \
-"
-
-inherit cross-canadian
-
-PN = "cargo-cross-canadian-${TRANSLATED_TARGET_ARCH}"
-
-RUST_TARGETGENS = "BUILD HOST"
-
-do_compile:prepend () {
-	PKG_CONFIG_PATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/pkgconfig:${PKG_CONFIG_PATH}"
-}
-
-create_sdk_wrapper () {
-        file="$1"
-        shift
-
-        cat <<- EOF > "${file}"
-		#!/bin/sh
-		\$$1 \$@
-		EOF
-
-        chmod +x "$file"
-}
-
-do_install () {
-    SYS_BINDIR=$(dirname ${D}${bindir})
-    install -d "${SYS_BINDIR}"
-    install -m 755 "${B}/target/${CARGO_TARGET_SUBDIR}/cargo" "${SYS_BINDIR}"
-    for i in ${SYS_BINDIR}/*; do
-	chrpath -r "\$ORIGIN/../lib" ${i}
-    done
-
-    # Uses SDK's CC as linker so linked binaries works out of box.
-    create_sdk_wrapper "${SYS_BINDIR}/target-rust-ccld" "CC"
-
-    ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d
-    mkdir "${ENV_SETUP_DIR}"
-    ENV_SETUP_SH="${ENV_SETUP_DIR}/cargo.sh"
-    cat <<- EOF > "${ENV_SETUP_SH}"
-	export CARGO_HOME="\$OECORE_TARGET_SYSROOT/home/cargo"
-	mkdir -p "\$CARGO_HOME"
-        # Init the default target once, it might be otherwise user modified.
-	if [ ! -f "\$CARGO_HOME/config" ]; then
-		touch "\$CARGO_HOME/config"
-		echo "[build]" >> "\$CARGO_HOME/config"
-		echo 'target = "'${TARGET_SYS}'"' >> "\$CARGO_HOME/config"
-		echo '# TARGET_SYS' >> "\$CARGO_HOME/config"
-		echo '[target.'${TARGET_SYS}']' >> "\$CARGO_HOME/config"
-		echo 'linker = "target-rust-ccld"' >> "\$CARGO_HOME/config"
-    fi
-
-	# Keep the below off as long as HTTP/2 is disabled.
-	export CARGO_HTTP_MULTIPLEXING=false
-
-	export CARGO_HTTP_CAINFO="\$OECORE_NATIVE_SYSROOT/etc/ssl/certs/ca-certificates.crt"
-	EOF
-}
-
-PKG_SYS_BINDIR = "${SDKPATHNATIVE}/usr/bin"
-FILES:${PN} += "${base_prefix}/environment-setup.d ${PKG_SYS_BINDIR}"
-
diff --git a/meta/recipes-devtools/cargo/cargo-cross-canadian_1.62.0.bb b/meta/recipes-devtools/cargo/cargo-cross-canadian_1.62.0.bb
deleted file mode 100644
index 63fd69107be..00000000000
--- a/meta/recipes-devtools/cargo/cargo-cross-canadian_1.62.0.bb
+++ /dev/null
@@ -1,6 +0,0 @@
-require recipes-devtools/rust/rust-source.inc
-require recipes-devtools/rust/rust-snapshot.inc
-
-FILESEXTRAPATHS:prepend := "${THISDIR}/cargo-${PV}:"
-
-require cargo-cross-canadian.inc
diff --git a/meta/recipes-devtools/cargo/cargo.inc b/meta/recipes-devtools/cargo/cargo.inc
index 978504052b9..e34554a9d78 100644
--- a/meta/recipes-devtools/cargo/cargo.inc
+++ b/meta/recipes-devtools/cargo/cargo.inc
@@ -56,3 +56,8 @@ export LIBSSH2_SYS_USE_PKG_CONFIG = "1"
 # so we must use the locally set up snapshot to bootstrap the build.
 BASEDEPENDS:remove:class-native = "cargo-native"
 CARGO:class-native = "${WORKDIR}/${CARGO_SNAPSHOT}/bin/cargo"
+
+DEPENDS:append:class-nativesdk = " nativesdk-rust"
+RUSTLIB:append:class-nativesdk = " -L ${STAGING_DIR_HOST}/${SDKPATHNATIVE}/usr/lib/rustlib/${RUST_HOST_SYS}/lib"
+
+
diff --git a/meta/recipes-devtools/cargo/cargo_1.62.0.bb b/meta/recipes-devtools/cargo/cargo_1.62.0.bb
index eee58fc2452..5c8527708cb 100644
--- a/meta/recipes-devtools/cargo/cargo_1.62.0.bb
+++ b/meta/recipes-devtools/cargo/cargo_1.62.0.bb
@@ -2,3 +2,4 @@ require recipes-devtools/rust/rust-source.inc
 require recipes-devtools/rust/rust-snapshot.inc
 require cargo.inc
 BBCLASSEXTEND = "native nativesdk"
+RUSTLIB_DEP:class-nativesdk = ""
\ No newline at end of file
diff --git a/meta/recipes-devtools/rust/rust-cross-canadian.inc b/meta/recipes-devtools/rust/rust-cross-canadian.inc
index 8bbbd61bdc3..677bd8842c6 100644
--- a/meta/recipes-devtools/rust/rust-cross-canadian.inc
+++ b/meta/recipes-devtools/rust/rust-cross-canadian.inc
@@ -16,6 +16,18 @@ do_compile () {
     rust_runx build --stage 2
 }
 
+create_sdk_wrapper () {
+        file="$1"
+        shift
+
+        cat <<- EOF > "${file}"
+		#!/bin/sh
+		\$$1 \$@
+		EOF
+
+        chmod +x "$file"
+}
+
 do_install () {
     # Rust requires /usr/lib to contain the libs.
     # Similar story is with /usr/bin ruquiring  `lib` to be at the same level.
@@ -51,6 +63,11 @@ do_install () {
     # Remove executable bit from any files so then SDK doesn't try to relocate.
     chmod -R -x+X ${SRC_DIR}
 
+
+    # Uses SDK's CC as linker so linked binaries works out of box.
+    install -d ${SYS_BINDIR}
+    create_sdk_wrapper "${SYS_BINDIR}/target-rust-ccld" "CC"
+
     ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d
     mkdir "${ENV_SETUP_DIR}"
     ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh"
@@ -61,6 +78,26 @@ do_install () {
 	EOF
 
     chown -R root.root ${D}
+
+    ENV_SETUP_SH="${ENV_SETUP_DIR}/cargo.sh"
+    cat <<- EOF > "${ENV_SETUP_SH}"
+	export CARGO_HOME="\$OECORE_TARGET_SYSROOT/home/cargo"
+	mkdir -p "\$CARGO_HOME"
+        # Init the default target once, it might be otherwise user modified.
+	if [ ! -f "\$CARGO_HOME/config" ]; then
+		touch "\$CARGO_HOME/config"
+		echo "[build]" >> "\$CARGO_HOME/config"
+		echo 'target = "'${RUST_TARGET_SYS}'"' >> "\$CARGO_HOME/config"
+		echo '# TARGET_SYS' >> "\$CARGO_HOME/config"
+		echo '[target.'${RUST_TARGET_SYS}']' >> "\$CARGO_HOME/config"
+		echo 'linker = "target-rust-ccld"' >> "\$CARGO_HOME/config"
+    fi
+
+	# Keep the below off as long as HTTP/2 is disabled.
+	export CARGO_HTTP_MULTIPLEXING=false
+
+	export CARGO_HTTP_CAINFO="\$OECORE_NATIVE_SYSROOT/etc/ssl/certs/ca-certificates.crt"
+	EOF
 }
 
 PKG_SYS_LIBDIR = "${SDKPATHNATIVE}/usr/lib"
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 24/29] rust-common: Set rustlibdir to match target expectation
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (21 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 23/29] cargo: Drop cross-canadian variant and fix/use nativesdk Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 25/29] rust-cross-canadian: Simplify and fix Richard Purdie
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-common.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass
index 516b258c15e..8ee05f57f86 100644
--- a/meta/classes/rust-common.bbclass
+++ b/meta/classes/rust-common.bbclass
@@ -2,12 +2,12 @@ inherit python3native
 inherit rust-target-config
 
 # Common variables used by all Rust builds
-export rustlibdir = "${libdir}/rust"
+export rustlibdir = "${libdir}/rustlib/${RUST_HOST_SYS}/lib"
 FILES:${PN} += "${rustlibdir}/*.so"
 FILES:${PN}-dev += "${rustlibdir}/*.rlib ${rustlibdir}/*.rmeta"
 FILES:${PN}-dbg += "${rustlibdir}/.debug"
 
-RUSTLIB = "-L ${STAGING_LIBDIR}/rust"
+RUSTLIB = "-L ${STAGING_DIR_HOST}${rustlibdir}"
 RUST_DEBUG_REMAP = "--remap-path-prefix=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}"
 RUSTFLAGS += "${RUSTLIB} ${RUST_DEBUG_REMAP}"
 RUSTLIB_DEP ?= "libstd-rs"
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 25/29] rust-cross-canadian: Simplify and fix
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (22 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 24/29] rust-common: Set rustlibdir to match target expectation Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 26/29] rust: Drop cross/crosssdk Richard Purdie
                   ` (3 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Since a copy of rust can target any target and doesn't need to be target
specific, we can simplify rust-cross-canadian to simply contain the json
configuration and envirionment setup scripts.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 .../rust/rust-cross-canadian-common.inc       | 49 --------------
 .../rust/rust-cross-canadian.inc              | 65 +++----------------
 .../rust/rust-cross-canadian_1.62.0.bb        |  8 +--
 3 files changed, 12 insertions(+), 110 deletions(-)
 delete mode 100644 meta/recipes-devtools/rust/rust-cross-canadian-common.inc

diff --git a/meta/recipes-devtools/rust/rust-cross-canadian-common.inc b/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
deleted file mode 100644
index 34020ff6ff4..00000000000
--- a/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
+++ /dev/null
@@ -1,49 +0,0 @@
-
-RUST_ALTERNATE_EXE_PATH = "${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config"
-
-require rust.inc
-
-DEPENDS += "rust-llvm (=${PV})"
-
-inherit cross-canadian
-
-DEPENDS += "  \
-            virtual/${HOST_PREFIX}gcc-crosssdk \
-            virtual/nativesdk-libc rust-llvm-native \
-            virtual/${TARGET_PREFIX}compilerlibs \
-            virtual/nativesdk-${HOST_PREFIX}compilerlibs \
-            gcc-cross-${TARGET_ARCH} \
-           "
-
-# The host tools are likely not to be able to do the necessary operation on
-# the target architecturea. Alternatively one could check compatibility
-# between host/target.
-EXCLUDE_FROM_SHLIBS_${RUSTLIB_TARGET_PN} = "1"
-
-DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
-                    -fdebug-prefix-map=${STAGING_DIR_HOST}= \
-                    -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
-                    "
-
-RUST_TARGETGENS = "BUILD HOST TARGET"
-
-INHIBIT_DEFAULT_RUST_DEPS = "1"
-
-export WRAPPER_TARGET_CC = "${CCACHE}${TARGET_PREFIX}gcc --sysroot=${STAGING_DIR_TARGET} ${TARGET_CC_ARCH} ${SECURITY_NOPIE_CFLAGS}"
-export WRAPPER_TARGET_CXX = "${CCACHE}${TARGET_PREFIX}g++ --sysroot=${STAGING_DIR_TARGET} ${TARGET_CC_ARCH} ${SECURITY_NOPIE_CFLAGS}"
-export WRAPPER_TARGET_CCLD = "${TARGET_PREFIX}gcc --sysroot=${STAGING_DIR_TARGET} ${TARGET_CC_ARCH} ${SECURITY_NOPIE_CFLAGS}"
-export WRAPPER_TARGET_LDFLAGS = "${TARGET_LDFLAGS}"
-export WRAPPER_TARGET_AR = "${TARGET_PREFIX}ar"
-
-python do_configure:prepend() {
-    targets = [d.getVar("TARGET_SYS", True), "{}-unknown-linux-gnu".format(d.getVar("HOST_ARCH", True))]
-    hosts = ["{}-unknown-linux-gnu".format(d.getVar("HOST_ARCH", True))]
-}
-
-INSANE_SKIP:${RUSTLIB_TARGET_PN} = "file-rdeps arch ldflags"
-SKIP_FILEDEPS:${RUSTLIB_TARGET_PN} = "1"
-
-INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
-INHIBIT_PACKAGE_STRIP = "1"
-INHIBIT_SYSROOT_STRIP = "1"
-
diff --git a/meta/recipes-devtools/rust/rust-cross-canadian.inc b/meta/recipes-devtools/rust/rust-cross-canadian.inc
index 677bd8842c6..2b09661542d 100644
--- a/meta/recipes-devtools/rust/rust-cross-canadian.inc
+++ b/meta/recipes-devtools/rust/rust-cross-canadian.inc
@@ -1,20 +1,11 @@
-
-require rust-cross-canadian-common.inc
-
-RUSTLIB_TARGET_PN = "rust-cross-canadian-rustlib-target-${TRANSLATED_TARGET_ARCH}"
-RUSTLIB_HOST_PN = "rust-cross-canadian-rustlib-host-${TRANSLATED_TARGET_ARCH}"
-RUSTLIB_SRC_PN = "rust-cross-canadian-src"
-RUSTLIB_PKGS = "${RUSTLIB_SRC_PN} ${RUSTLIB_TARGET_PN} ${RUSTLIB_HOST_PN}"
 PN = "rust-cross-canadian-${TRANSLATED_TARGET_ARCH}"
 
-PACKAGES = "${RUSTLIB_PKGS} ${PN}"
-RDEPENDS:${PN} += "${RUSTLIB_PKGS}"
+inherit rust-target-config
+inherit rust-common
 
-# The default behaviour of x.py changed in 1.47+ so now we need to
-# explicitly ask for the stage 2 compiler to be assembled.
-do_compile () {
-    rust_runx build --stage 2
-}
+LICENSE = "MIT"
+
+MODIFYTOS = "0"
 
 create_sdk_wrapper () {
         file="$1"
@@ -30,39 +21,14 @@ create_sdk_wrapper () {
 
 do_install () {
     # Rust requires /usr/lib to contain the libs.
-    # Similar story is with /usr/bin ruquiring  `lib` to be at the same level.
     # The required structure is retained for simplicity.
     SYS_LIBDIR=$(dirname ${D}${libdir})
     SYS_BINDIR=$(dirname ${D}${bindir})
     RUSTLIB_DIR=${SYS_LIBDIR}/${TARGET_SYS}/rustlib
 
-    install -d "${SYS_BINDIR}"
-    cp build/${SNAPSHOT_BUILD_SYS}/stage2/bin/* ${SYS_BINDIR}
-    for i in ${SYS_BINDIR}/*; do
-	chrpath -r "\$ORIGIN/../lib" ${i}
-    done
-
-    install -d "${D}${libdir}"
-    cp -pRd build/${SNAPSHOT_BUILD_SYS}/stage2/lib/${TARGET_SYS}/*.so ${SYS_LIBDIR}
-    cp -pRd build/${SNAPSHOT_BUILD_SYS}/stage2/lib/${TARGET_SYS}/rustlib ${RUSTLIB_DIR}
-
-    for i in ${SYS_LIBDIR}/*.so; do
-	chrpath -r "\$ORIGIN/../lib" ${i}
-    done
-    for i in ${RUSTLIB_DIR}/*/lib/*.so; do
-	chrpath -d ${i}
-    done
-
-    install -m 0644 "${WORKDIR}/targets/${TARGET_SYS}.json" "${RUSTLIB_DIR}"
-
-    SRC_DIR=${RUSTLIB_DIR}/src/rust
-    install -d ${SRC_DIR}/src/llvm-project
-    cp -R --no-dereference build/${SNAPSHOT_BUILD_SYS}/stage2/lib/rustlib/src/rust/src/llvm-project/libunwind ${SRC_DIR}/src/llvm-project
-    cp -R --no-dereference build/${SNAPSHOT_BUILD_SYS}/stage2/lib/rustlib/src/rust/library ${SRC_DIR}
-    cp --no-dereference build/${SNAPSHOT_BUILD_SYS}/stage2/lib/rustlib/src/rust/Cargo.lock ${SRC_DIR}
-    # Remove executable bit from any files so then SDK doesn't try to relocate.
-    chmod -R -x+X ${SRC_DIR}
-
+    install -d ${RUSTLIB_DIR}
+    install -m 0644 "${RUST_TARGETS_DIR}/${RUST_HOST_SYS}.json" "${RUSTLIB_DIR}"
+    install -m 0644 "${RUST_TARGETS_DIR}/${RUST_TARGET_SYS}.json" "${RUSTLIB_DIR}"
 
     # Uses SDK's CC as linker so linked binaries works out of box.
     install -d ${SYS_BINDIR}
@@ -73,7 +39,7 @@ do_install () {
     ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh"
 
     cat <<- EOF > "${ENV_SETUP_SH}"
-	export RUSTFLAGS="--sysroot=\$OECORE_NATIVE_SYSROOT/usr -C link-arg=--sysroot=\$OECORE_TARGET_SYSROOT -L\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib/${TARGET_SYS}/lib"
+	export RUSTFLAGS="--sysroot=\$OECORE_TARGET_SYSROOT/usr -C link-arg=--sysroot=\$OECORE_TARGET_SYSROOT"
 	export RUST_TARGET_PATH="\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib"
 	EOF
 
@@ -100,16 +66,5 @@ do_install () {
 	EOF
 }
 
-PKG_SYS_LIBDIR = "${SDKPATHNATIVE}/usr/lib"
-PKG_SYS_BINDIR = "${SDKPATHNATIVE}/usr/bin"
-PKG_RUSTLIB_DIR = "${PKG_SYS_LIBDIR}/${TARGET_SYS}/rustlib"
-FILES:${PN} = "${PKG_SYS_LIBDIR}/*.so ${PKG_SYS_BINDIR} ${base_prefix}/environment-setup.d"
-FILES:${RUSTLIB_TARGET_PN} = "${PKG_RUSTLIB_DIR}/${TARGET_SYS} ${PKG_RUSTLIB_DIR}/${TARGET_SYS}.json"
-FILES:${RUSTLIB_HOST_PN} = "${PKG_RUSTLIB_DIR}/${BUILD_ARCH}-unknown-linux-gnu"
-FILES:${RUSTLIB_SRC_PN} = "${PKG_RUSTLIB_DIR}/src"
-
-SUMMARY:${RUSTLIB_TARGET_PN} = "Rust cross canadian libaries for ${TARGET_SYS}"
-SUMMARY:${RUSTLIB_HOST_PN} = "Rust cross canadian libaries for ${HOST_SYS}"
-SUMMARY:${RUSTLIB_SRC_PN} = "Rust standard library sources for cross canadian toolchain"
-SUMMARY:${PN} = "Rust crost canadian compiler"
+FILES:${PN} += "${base_prefix}/environment-setup.d"
 
diff --git a/meta/recipes-devtools/rust/rust-cross-canadian_1.62.0.bb b/meta/recipes-devtools/rust/rust-cross-canadian_1.62.0.bb
index 766912c019b..55865238ab4 100644
--- a/meta/recipes-devtools/rust/rust-cross-canadian_1.62.0.bb
+++ b/meta/recipes-devtools/rust/rust-cross-canadian_1.62.0.bb
@@ -1,6 +1,2 @@
-require rust-cross-canadian.inc
-require rust-source.inc
-require rust-snapshot.inc
-
-FILESEXTRAPATHS:prepend := "${THISDIR}/rust:"
-
+inherit cross-canadian
+require rust-cross-canadian.inc
\ No newline at end of file
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 26/29] rust: Drop cross/crosssdk
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (23 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 25/29] rust-cross-canadian: Simplify and fix Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 27/29] rust: Enable nativesdk and target builds + replace rust-tools-cross-canadian Richard Purdie
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Now that target config json is provided by rust-target-config.bbclass,
the need for the cross and crosssdk recipes is removed. Drop them and
simplify dependencies accordingly.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/cargo.bbclass                    |  4 +-
 meta/classes/rust.bbclass                     |  2 +-
 meta/conf/distro/include/maintainers.inc      |  2 -
 meta/recipes-devtools/rust/rust-cross.inc     | 47 -------------------
 .../rust/rust-cross_1.62.0.bb                 |  8 ----
 .../rust/rust-crosssdk_1.62.0.bb              |  8 ----
 6 files changed, 3 insertions(+), 68 deletions(-)
 delete mode 100644 meta/recipes-devtools/rust/rust-cross.inc
 delete mode 100644 meta/recipes-devtools/rust/rust-cross_1.62.0.bb
 delete mode 100644 meta/recipes-devtools/rust/rust-crosssdk_1.62.0.bb

diff --git a/meta/classes/cargo.bbclass b/meta/classes/cargo.bbclass
index 2475d05b3d2..4bfcfe5fc65 100644
--- a/meta/classes/cargo.bbclass
+++ b/meta/classes/cargo.bbclass
@@ -13,8 +13,8 @@ CARGO = "cargo"
 BASEDEPENDS:append = " cargo-native"
 
 # Ensure we get the right rust variant
-DEPENDS:append:class-target = " virtual/${TARGET_PREFIX}rust ${RUSTLIB_DEP}"
-DEPENDS:append:class-nativesdk = " virtual/${TARGET_PREFIX}rust ${RUSTLIB_DEP}"
+DEPENDS:append:class-target = " rust-native ${RUSTLIB_DEP}"
+DEPENDS:append:class-nativesdk = " rust-native ${RUSTLIB_DEP}"
 DEPENDS:append:class-native = " rust-native"
 
 # Enable build separation
diff --git a/meta/classes/rust.bbclass b/meta/classes/rust.bbclass
index f20e063c5be..2639cecfd43 100644
--- a/meta/classes/rust.bbclass
+++ b/meta/classes/rust.bbclass
@@ -10,7 +10,7 @@ def rust_base_dep(d):
     deps = ""
     if not d.getVar('INHIBIT_DEFAULT_RUST_DEPS'):
         if (d.getVar('HOST_SYS') != d.getVar('BUILD_SYS')):
-            deps += " virtual/${TARGET_PREFIX}rust ${RUSTLIB_DEP}"
+            deps += " rust-native ${RUSTLIB_DEP}"
         else:
             deps += " rust-native"
     return deps
diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc
index b563c517962..80dfd6eb473 100644
--- a/meta/conf/distro/include/maintainers.inc
+++ b/meta/conf/distro/include/maintainers.inc
@@ -717,8 +717,6 @@ RECIPE_MAINTAINER:pn-rt-tests = "Alexander Kanavin <alex.kanavin@gmail.com>"
 RECIPE_MAINTAINER:pn-ruby = "Ross Burton <ross.burton@arm.com>"
 RECIPE_MAINTAINER:pn-run-postinsts = "Ross Burton <ross.burton@arm.com>"
 RECIPE_MAINTAINER:pn-rust = "Randy MacLeod <Randy.MacLeod@windriver.com>"
-RECIPE_MAINTAINER:pn-rust-cross-${TUNE_PKGARCH}-${TCLIBC} = "Randy MacLeod <Randy.MacLeod@windriver.com>"
-RECIPE_MAINTAINER:pn-rust-crosssdk-${SDK_ARCH}-glibc = "Randy MacLeod <Randy.MacLeod@windriver.com>"
 RECIPE_MAINTAINER:pn-rust-cross-canadian-${TRANSLATED_TARGET_ARCH} = "Randy MacLeod <Randy.MacLeod@windriver.com>"
 RECIPE_MAINTAINER:pn-rust-hello-world = "Randy MacLeod <Randy.MacLeod@windriver.com>"
 RECIPE_MAINTAINER:pn-rust-llvm = "Randy MacLeod <Randy.MacLeod@windriver.com>"
diff --git a/meta/recipes-devtools/rust/rust-cross.inc b/meta/recipes-devtools/rust/rust-cross.inc
deleted file mode 100644
index ab538e6659b..00000000000
--- a/meta/recipes-devtools/rust/rust-cross.inc
+++ /dev/null
@@ -1,47 +0,0 @@
-RUST_TARGETGENS = "BUILD HOST TARGET"
-
-# 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 += "rust-native"
-
-# 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_rust_setup_snapshot () {
-}
-
-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/meta/recipes-devtools/rust/rust-cross_1.62.0.bb b/meta/recipes-devtools/rust/rust-cross_1.62.0.bb
deleted file mode 100644
index 5358d98da85..00000000000
--- a/meta/recipes-devtools/rust/rust-cross_1.62.0.bb
+++ /dev/null
@@ -1,8 +0,0 @@
-require rust.inc
-inherit cross
-require rust-cross.inc
-require rust-source.inc
-
-DEPENDS += "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}compilerlibs virtual/libc"
-PROVIDES = "virtual/${TARGET_PREFIX}rust"
-PN = "rust-cross-${TUNE_PKGARCH}-${TCLIBC}"
diff --git a/meta/recipes-devtools/rust/rust-crosssdk_1.62.0.bb b/meta/recipes-devtools/rust/rust-crosssdk_1.62.0.bb
deleted file mode 100644
index 6ea8cb09b21..00000000000
--- a/meta/recipes-devtools/rust/rust-crosssdk_1.62.0.bb
+++ /dev/null
@@ -1,8 +0,0 @@
-require rust.inc
-inherit crosssdk
-require rust-cross.inc
-require rust-source.inc
-
-DEPENDS += "virtual/${TARGET_PREFIX}gcc-crosssdk virtual/nativesdk-${TARGET_PREFIX}compilerlibs virtual/nativesdk-libc"
-PROVIDES = "virtual/nativesdk-${TARGET_PREFIX}rust"
-PN = "rust-crosssdk-${TUNE_PKGARCH}-${RUST_LIBC}"
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 27/29] rust: Enable nativesdk and target builds + replace rust-tools-cross-canadian
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (24 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 26/29] rust: Drop cross/crosssdk Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 28/29] rust: Fix musl builds Richard Purdie
  2022-08-05 13:12 ` [PATCH 29/29] rust: Ensure buildpaths are handled in debug symbols correctly Richard Purdie
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Enable rust target builds as well as nativesdk-rust for the sdk. Merge
the builds of rust-tools components into the rust build, packaged separately
since this is a lot more efficient and saves rebuilding core rust multiple
times. The tools are not target specific so nativesdk-rust-tools suffices
and we can drop the cross canadian piece.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/conf/distro/include/maintainers.inc      |  1 -
 .../packagegroup-rust-cross-canadian.bb       |  6 +-
 meta/recipes-devtools/rust/rust-target.inc    |  2 +-
 .../rust/rust-tools-cross-canadian.inc        | 38 ----------
 .../rust/rust-tools-cross-canadian_1.62.0.bb  |  6 --
 meta/recipes-devtools/rust/rust.inc           | 13 +---
 meta/recipes-devtools/rust/rust_1.62.0.bb     | 69 +++++++++++++++++--
 7 files changed, 70 insertions(+), 65 deletions(-)
 delete mode 100644 meta/recipes-devtools/rust/rust-tools-cross-canadian.inc
 delete mode 100644 meta/recipes-devtools/rust/rust-tools-cross-canadian_1.62.0.bb

diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc
index 80dfd6eb473..c0c38dfc165 100644
--- a/meta/conf/distro/include/maintainers.inc
+++ b/meta/conf/distro/include/maintainers.inc
@@ -720,7 +720,6 @@ RECIPE_MAINTAINER:pn-rust = "Randy MacLeod <Randy.MacLeod@windriver.com>"
 RECIPE_MAINTAINER:pn-rust-cross-canadian-${TRANSLATED_TARGET_ARCH} = "Randy MacLeod <Randy.MacLeod@windriver.com>"
 RECIPE_MAINTAINER:pn-rust-hello-world = "Randy MacLeod <Randy.MacLeod@windriver.com>"
 RECIPE_MAINTAINER:pn-rust-llvm = "Randy MacLeod <Randy.MacLeod@windriver.com>"
-RECIPE_MAINTAINER:pn-rust-tools-cross-canadian-${TRANSLATED_TARGET_ARCH} = "Randy MacLeod <Randy.MacLeod@windriver.com>"
 RECIPE_MAINTAINER:pn-rxvt-unicode = "Unassigned <unassigned@yoctoproject.org>"
 RECIPE_MAINTAINER:pn-sato-screenshot = "Ross Burton <ross.burton@arm.com>"
 RECIPE_MAINTAINER:pn-sato-icon-theme = "Richard Purdie <richard.purdie@linuxfoundation.org>"
diff --git a/meta/recipes-core/packagegroups/packagegroup-rust-cross-canadian.bb b/meta/recipes-core/packagegroups/packagegroup-rust-cross-canadian.bb
index 6d324002a1a..42f85f0eb38 100644
--- a/meta/recipes-core/packagegroups/packagegroup-rust-cross-canadian.bb
+++ b/meta/recipes-core/packagegroups/packagegroup-rust-cross-canadian.bb
@@ -6,12 +6,12 @@ inherit cross-canadian packagegroup
 PACKAGEGROUP_DISABLE_COMPLEMENTARY = "1"
 
 RUST="rust-cross-canadian-${TRANSLATED_TARGET_ARCH}"
-RUST_TOOLS="rust-tools-cross-canadian-${TRANSLATED_TARGET_ARCH}"
 
 RDEPENDS:${PN} = " \
     ${@all_multilib_tune_values(d, 'RUST')} \
+    nativesdk-rust \
     nativesdk-cargo \
-    rust-cross-canadian-src \
-    ${@all_multilib_tune_values(d, 'RUST_TOOLS')} \
+    nativesdk-rust-tools-clippy \
+    nativesdk-rust-tools-rustfmt \
 "
 
diff --git a/meta/recipes-devtools/rust/rust-target.inc b/meta/recipes-devtools/rust/rust-target.inc
index 3f637b3ba54..dce2b47517b 100644
--- a/meta/recipes-devtools/rust/rust-target.inc
+++ b/meta/recipes-devtools/rust/rust-target.inc
@@ -7,4 +7,4 @@ 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"
+BBCLASSEXTEND = "native nativesdk"
diff --git a/meta/recipes-devtools/rust/rust-tools-cross-canadian.inc b/meta/recipes-devtools/rust/rust-tools-cross-canadian.inc
deleted file mode 100644
index f0358551ae2..00000000000
--- a/meta/recipes-devtools/rust/rust-tools-cross-canadian.inc
+++ /dev/null
@@ -1,38 +0,0 @@
-
-require rust-cross-canadian-common.inc
-
-RUST_TOOLS_CLIPPY_PN = "rust-tools-clippy-cross-canadian-${TRANSLATED_TARGET_ARCH}"
-RUST_TOOLS_RUSTFMT_PN = "rust-tools-rustfmt-cross-canadian-${TRANSLATED_TARGET_ARCH}"
-RUST_TOOLS_PKGS = "${RUST_TOOLS_CLIPPY_PN} ${RUST_TOOLS_RUSTFMT_PN}"
-PN = "rust-tools-cross-canadian-${TRANSLATED_TARGET_ARCH}"
-
-PACKAGES = "${RUST_TOOLS_CLIPPY_PN} ${RUST_TOOLS_RUSTFMT_PN} ${PN}"
-RDEPENDS:${PN} += "${RUST_TOOLS_PKGS}"
-
-do_compile () {
-    rust_runx build --stage 2 src/tools/clippy
-    rust_runx build --stage 2 src/tools/rustfmt
-}
-
-do_install () {
-    SYS_BINDIR=$(dirname ${D}${bindir})
-
-    install -d "${SYS_BINDIR}"
-    cp build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/* ${SYS_BINDIR}
-    for i in ${SYS_BINDIR}/*; do
-	chrpath -r "\$ORIGIN/../lib" ${i}
-    done
-
-    chown -R root.root ${D}
-}
-
-ALLOW_EMPTY:${PN} = "1"
-
-PKG_SYS_BINDIR = "${SDKPATHNATIVE}/usr/bin"
-FILES:${RUST_TOOLS_CLIPPY_PN} = "${PKG_SYS_BINDIR}/cargo-clippy ${PKG_SYS_BINDIR}/clippy-driver"
-FILES:${RUST_TOOLS_RUSTFMT_PN} = "${PKG_SYS_BINDIR}/rustfmt"
-
-SUMMARY:${PN} = "Rust helper tools"
-SUMMARY:${RUST_TOOLS_CLIPPY_PN} = "A collection of lints to catch common mistakes and improve your Rust code"
-SUMMARY:${RUST_TOOLS_RUSTFMT_PN} = "A tool for formatting Rust code according to style guidelines"
-
diff --git a/meta/recipes-devtools/rust/rust-tools-cross-canadian_1.62.0.bb b/meta/recipes-devtools/rust/rust-tools-cross-canadian_1.62.0.bb
deleted file mode 100644
index 2d809d68f52..00000000000
--- a/meta/recipes-devtools/rust/rust-tools-cross-canadian_1.62.0.bb
+++ /dev/null
@@ -1,6 +0,0 @@
-require rust-tools-cross-canadian.inc
-require rust-source.inc
-require rust-snapshot.inc
-
-FILESEXTRAPATHS:prepend := "${THISDIR}/rust:"
-
diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index 7c16b8165bb..1c8fe225fd4 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -9,6 +9,7 @@ inherit cargo_common
 
 DEPENDS += "file-native python3-native"
 DEPENDS:append:class-native = " rust-llvm-native"
+DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm"
 
 S = "${RUSTSRC}"
 
@@ -202,18 +203,6 @@ rust_do_install () {
     rm -f ${D}${libdir}/rustlib/src/rust
 }
 
-rust_install_targets() {
-    # 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
-}
-
-
 do_install () {
     rust_do_install
-    rust_install_targets
 }
-# ex: sts=4 et sw=4 ts=8
diff --git a/meta/recipes-devtools/rust/rust_1.62.0.bb b/meta/recipes-devtools/rust/rust_1.62.0.bb
index b505ad46caf..81923c33313 100644
--- a/meta/recipes-devtools/rust/rust_1.62.0.bb
+++ b/meta/recipes-devtools/rust/rust_1.62.0.bb
@@ -3,19 +3,80 @@ require rust-source.inc
 require rust-snapshot.inc
 
 INSANE_SKIP:${PN}:class-native = "already-stripped"
+FILES:${PN} += "${libdir}/rustlib"
+FILES:${PN} += "${libdir}/*.so"
+FILES:${PN}-dev = ""
 
 do_compile () {
     rust_runx build --stage 2
 }
 
+do_compile:append:class-target () {
+    rust_runx build --stage 2 src/tools/clippy
+    rust_runx build --stage 2 src/tools/rustfmt
+}
+
+do_compile:append:class-nativesdk () {
+    rust_runx build --stage 2 src/tools/clippy
+    rust_runx build --stage 2 src/tools/rustfmt
+}
+
+ALLOW_EMPTY:${PN} = "1"
+
+PACKAGES =+ "${PN}-tools-clippy ${PN}-tools-rustfmt"
+FILES:${PN}-tools-clippy = "${bindir}/cargo-clippy ${bindir}/clippy-driver"
+FILES:${PN}-tools-rustfmt = "${bindir}/rustfmt"
+RDEPENDS:${PN}-tools-clippy = "${PN}"
+RDEPENDS:${PN}-tools-rustfmt = "${PN}"
+
+SUMMARY:${PN}-tools-clippy = "A collection of lints to catch common mistakes and improve your Rust code"
+SUMMARY:${PN}-tools-rustfmt = "A tool for formatting Rust code according to style guidelines"
+
 rust_do_install() {
     rust_runx install
 }
 
-python () {
-    pn = d.getVar('PN')
+rust_do_install:class-nativesdk() {
+    export PSEUDO_UNLOAD=1
+    rust_runx install
+    unset PSEUDO_UNLOAD
+
+    install -d ${D}${bindir}
+    for i in cargo-clippy clippy-driver rustfmt; do
+        cp build/${RUST_BUILD_SYS}/stage2-tools-bin/$i ${D}${bindir}
+        chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
+    done
 
-    if not pn.endswith("-native"):
-        raise bb.parse.SkipRecipe("Rust recipe doesn't work for target builds at this time. Fixes welcome.")
+    chown root:root ${D}/ -R
+    rm ${D}${libdir}/rustlib/uninstall.sh
+    rm ${D}${libdir}/rustlib/install.log
+    rm ${D}${libdir}/rustlib/manifest*
 }
 
+rust_do_install:class-target() {
+    export PSEUDO_UNLOAD=1
+    rust_runx install
+    unset PSEUDO_UNLOAD
+
+    install -d ${D}${bindir}
+    for i in cargo-clippy clippy-driver rustfmt; do
+        cp build/${RUST_BUILD_SYS}/stage2-tools-bin/$i ${D}${bindir}
+        chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
+    done
+
+    chown root:root ${D}/ -R
+    rm ${D}${libdir}/rustlib/uninstall.sh
+    rm ${D}${libdir}/rustlib/install.log
+    rm ${D}${libdir}/rustlib/manifest*
+}
+
+# see recipes-devtools/gcc/gcc/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
+# we need to link with ssp_nonshared on musl to avoid "undefined reference to `__stack_chk_fail_local'"
+# when building MACHINE=qemux86 for musl
+WRAPPER_TARGET_EXTRALD:libc-musl = "-lssp_nonshared"
+
+RUSTLIB_DEP:class-nativesdk = ""
+
+# musl builds include libunwind.a
+INSANE_SKIP:${PN} = "staticdev"
+
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 28/29] rust: Fix musl builds
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (25 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 27/29] rust: Enable nativesdk and target builds + replace rust-tools-cross-canadian Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  2022-08-05 13:12 ` [PATCH 29/29] rust: Ensure buildpaths are handled in debug symbols correctly Richard Purdie
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

Musl targets need a sysroot set to find the musl static libraries. Set this
appropriately in musl builds.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/rust/rust.inc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index 1c8fe225fd4..d0f7467a887 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -83,6 +83,8 @@ python do_configure() {
 
     config.set(host_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
     config.set(host_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    if "musl" in host_section:
+        config.set(host_section, "musl-root", e(d.expand("${STAGING_DIR_HOST}${exec_prefix}")))
 
     # If we don't do this rust-native will compile it's own llvm for BUILD.
     # [target.${BUILD_ARCH}-unknown-linux-gnu]
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 29/29] rust: Ensure buildpaths are handled in debug symbols correctly
  2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
                   ` (26 preceding siblings ...)
  2022-08-05 13:12 ` [PATCH 28/29] rust: Fix musl builds Richard Purdie
@ 2022-08-05 13:12 ` Richard Purdie
  27 siblings, 0 replies; 35+ messages in thread
From: Richard Purdie @ 2022-08-05 13:12 UTC (permalink / raw)
  To: openembedded-core

To ensure buildpaths aren't encoded in the debug symbol output, ensure
we pass our prefix remapping compiler options in.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/rust/rust.inc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index d0f7467a887..7e302b59929 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -177,6 +177,8 @@ rust_runx () {
     unset CXXFLAGS
     unset CPPFLAGS
 
+    export RUSTFLAGS="${RUST_DEBUG_REMAP}"
+
     # Copy the natively built llvm-config into the target so we can run it. Horrible,
     # but works!
     if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} ]; then
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* RE: [OE-core] [PATCH 21/29] rust-target-config: Make target workaround generic
  2022-08-05 13:12 ` [PATCH 21/29] rust-target-config: Make target workaround generic Richard Purdie
@ 2022-08-05 14:47   ` Peter Kjellerstedt
  0 siblings, 0 replies; 35+ messages in thread
From: Peter Kjellerstedt @ 2022-08-05 14:47 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Richard Purdie
> Sent: den 5 augusti 2022 15:13
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH 21/29] rust-target-config: Make target workaround generic
> 
> Ensure the 'target' data is set for both HOST and TARGET queries
> as appropriate to work correctly in cross configurations.
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/classes/rust-target-config.bbclass | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/rust-target-config.bbclass b/meta/classes/rust-target-config.bbclass
> index bc6bd77abbf..b3c738f02a4 100644
> --- a/meta/classes/rust-target-config.bbclass
> +++ b/meta/classes/rust-target-config.bbclass
> @@ -290,6 +290,10 @@ llvm_cpu[vardepvalue] = "${@llvm_cpu(d)}"
> 
>  def rust_gen_target(d, thing, wd, arch):
>      import json
> +
> +    build_sys = d.getVar('BUILD_SYS')
> +    target_sys = d.getVar('TARGET_SYS')
> +
>      sys = d.getVar('{}_SYS'.format(thing))
>      prefix = d.getVar('{}_PREFIX'.format(thing))
>      rustsys = d.getVar('RUST_{}_SYS'.format(thing))
> @@ -298,7 +302,9 @@ def rust_gen_target(d, thing, wd, arch):
>      cpu = "generic"
>      features = ""
> 
> -    if thing == "TARGET":
> +    # Need to apply the target tuning conssitently, only if the triplet applies to the target

Typo: conssitently -> consistently

> +    # and not in the native case
> +    if sys == target_sys and sys != build_sys:
>          abi = d.getVar('ABIEXTENSION')
>          cpu = llvm_cpu(d)
>          if bb.data.inherits_class('native', d):
> --
> 2.34.1

//Peter



^ permalink raw reply	[flat|nested] 35+ messages in thread

* RE: [OE-core] [PATCH 18/29] rust-llvm: Enable nativesdk variant
  2022-08-05 13:12 ` [PATCH 18/29] rust-llvm: Enable nativesdk variant Richard Purdie
@ 2022-08-05 14:51   ` Peter Kjellerstedt
  0 siblings, 0 replies; 35+ messages in thread
From: Peter Kjellerstedt @ 2022-08-05 14:51 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Richard Purdie
> Sent: den 5 augusti 2022 15:13
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH 18/29] rust-llvm: Enable nativesdk variant
> 
> The allow nativesdk variants of the tools to build, enable a nativesdk

Typo: "The allow" -> "To allow"

> variant of rust-llvm.
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/recipes-devtools/rust/rust-llvm.inc | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-devtools/rust/rust-llvm.inc b/meta/recipes-devtools/rust/rust-llvm.inc
> index 9baad12dc8e..625eb570416 100644
> --- a/meta/recipes-devtools/rust/rust-llvm.inc
> +++ b/meta/recipes-devtools/rust/rust-llvm.inc
> @@ -47,6 +47,13 @@ EXTRA_OECMAKE:append:class-target = "\
>      -DLLVM_CONFIG_PATH=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config \
>  "
> 
> +EXTRA_OECMAKE:append:class-nativesdk = "\
> +    -DCMAKE_CROSSCOMPILING:BOOL=ON \
> +    -DLLVM_BUILD_TOOLS=OFF \
> +    -DLLVM_TABLEGEN=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-tblgen \
> +    -DLLVM_CONFIG_PATH=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config \
> +"
> +
>  # The debug symbols are huge here (>2GB) so suppress them since they
>  # provide almost no value. If you really need them then override this
>  INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
> @@ -68,4 +75,4 @@ FILES:${PN}-staticdev =+ "${libdir}/llvm-rust/*/*.a"
>  FILES:${PN} += "${libdir}/libLLVM*.so.* ${libdir}/llvm-rust/lib/*.so.* ${libdir}/llvm-rust/bin"
>  FILES:${PN}-dev += "${datadir}/llvm ${libdir}/llvm-rust/lib/*.so ${libdir}/llvm-rust/include ${libdir}/llvm-rust/share ${libdir}/llvm-rust/lib/cmake"
> 
> -BBCLASSEXTEND = "native"
> +BBCLASSEXTEND = "native nativesdk"
> --
> 2.34.1

//Peter



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [OE-core] [PATCH 02/29] populate_sdk_base: Disable rust SDK for MIPS n32
  2022-08-05 13:12 ` [PATCH 02/29] populate_sdk_base: Disable rust SDK for MIPS n32 Richard Purdie
@ 2022-08-07  0:39   ` Khem Raj
  0 siblings, 0 replies; 35+ messages in thread
From: Khem Raj @ 2022-08-07  0:39 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core

On Fri, Aug 5, 2022 at 6:12 AM Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> The n32 MIPS rust SDK doesn't quite build (libstd-rs fails with an llvm
> register issue). Disable it for now, someone with interest in having it working
> can fix if/as/when.
>

Thats ok. Can you add a comment in code too so we know roughly the
reason just by looking at code disabling it.

> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/classes/populate_sdk_base.bbclass | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass
> index f260217b508..0d1c6e18c4e 100644
> --- a/meta/classes/populate_sdk_base.bbclass
> +++ b/meta/classes/populate_sdk_base.bbclass
> @@ -45,6 +45,7 @@ SDKTARGETSYSROOT = "${SDKPATH}/sysroots/${REAL_MULTIMACH_TARGET_SYS}"
>
>  SDK_TOOLCHAIN_LANGS ??= ""
>  SDK_TOOLCHAIN_LANGS:remove:sdkmingw32 = "rust"
> +SDK_TOOLCHAIN_LANGS:remove:mipsarchn32 = "rust"
>
>  TOOLCHAIN_HOST_TASK ?= " \
>      nativesdk-packagegroup-sdk-host \
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#168936): https://lists.openembedded.org/g/openembedded-core/message/168936
> Mute This Topic: https://lists.openembedded.org/mt/92834377/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [OE-core] [PATCH 04/29] conf/distro/no-static-libs: Allow static musl for rust
  2022-08-05 13:12 ` [PATCH 04/29] conf/distro/no-static-libs: Allow static musl for rust Richard Purdie
@ 2022-08-07  0:41   ` Khem Raj
  0 siblings, 0 replies; 35+ messages in thread
From: Khem Raj @ 2022-08-07  0:41 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core

On Fri, Aug 5, 2022 at 6:13 AM Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> When building rust for musl targets we need the static library from musl,
> so enable it.

it should be ok in general to link with static libs from musl so this
change is fine.

>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/conf/distro/include/no-static-libs.inc | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/meta/conf/distro/include/no-static-libs.inc b/meta/conf/distro/include/no-static-libs.inc
> index ee673834601..75359928a14 100644
> --- a/meta/conf/distro/include/no-static-libs.inc
> +++ b/meta/conf/distro/include/no-static-libs.inc
> @@ -18,6 +18,8 @@ DISABLE_STATIC:pn-nativesdk-openssl = ""
>  DISABLE_STATIC:pn-gcc-runtime = ""
>  # libusb1-native is used to build static dfu-util-native
>  DISABLE_STATIC:pn-libusb1-native = ""
> +# needed by rust
> +DISABLE_STATIC:pn-musl = ""
>
>  EXTRA_OECONF:append = "${DISABLE_STATIC}"
>
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#168938): https://lists.openembedded.org/g/openembedded-core/message/168938
> Mute This Topic: https://lists.openembedded.org/mt/92834379/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [OE-core] [PATCH 05/29] rust-target-config: Add mips n32 best guess at target information
  2022-08-05 13:12 ` [PATCH 05/29] rust-target-config: Add mips n32 best guess at target information Richard Purdie
@ 2022-08-07  0:47   ` Khem Raj
  0 siblings, 0 replies; 35+ messages in thread
From: Khem Raj @ 2022-08-07  0:47 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core

On Fri, Aug 5, 2022 at 6:13 AM Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> Add a best guess at MIPS n32 target information. This might not be
> 100% correct but is something to start from at least.
>

Looking at llvm data layout this is correct, so you might update the
commit comment

> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/classes/rust-target-config.bbclass | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/meta/classes/rust-target-config.bbclass b/meta/classes/rust-target-config.bbclass
> index 87b7dee3edc..1721839922e 100644
> --- a/meta/classes/rust-target-config.bbclass
> +++ b/meta/classes/rust-target-config.bbclass
> @@ -190,6 +190,13 @@ TARGET_POINTER_WIDTH[mips64] = "64"
>  TARGET_C_INT_WIDTH[mips64] = "64"
>  MAX_ATOMIC_WIDTH[mips64] = "64"
>
> +## mips64-n32-unknown-linux-{gnu, musl}
> +DATA_LAYOUT[mips64-n32] = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
> +TARGET_ENDIAN[mips64-n32] = "big"
> +TARGET_POINTER_WIDTH[mips64-n32] = "32"
> +TARGET_C_INT_WIDTH[mips64-n32] = "32"
> +MAX_ATOMIC_WIDTH[mips64-n32] = "64"
> +
>  ## mips64el-unknown-linux-{gnu, musl}
>  DATA_LAYOUT[mips64el] = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
>  TARGET_ENDIAN[mips64el] = "little"
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#168939): https://lists.openembedded.org/g/openembedded-core/message/168939
> Mute This Topic: https://lists.openembedded.org/mt/92834380/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [OE-core] [PATCH 12/29] rust.inc: Fix cross build llvm-config handling
  2022-08-05 13:12 ` [PATCH 12/29] rust.inc: Fix cross build llvm-config handling Richard Purdie
@ 2022-08-07  0:56   ` Khem Raj
  0 siblings, 0 replies; 35+ messages in thread
From: Khem Raj @ 2022-08-07  0:56 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core

On Fri, Aug 5, 2022 at 6:13 AM Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> We need llvm-config for the target but the cross compiled target binary is
> no good. We can copy the native one into the target location where it will
> then return the target values though.
>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/recipes-devtools/rust/rust.inc | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
> index 30f2b71fe8c..47b76e725de 100644
> --- a/meta/recipes-devtools/rust/rust.inc
> +++ b/meta/recipes-devtools/rust/rust.inc
> @@ -18,7 +18,8 @@ export RUST_TARGET_PATH="${WORKDIR}/targets/"
>  export FORCE_CRATE_HASH="${BB_TASKHASH}"
>
>  RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config"
> -export YOCTO_ALTERNATE_EXE_PATH = "${RUST_ALTERNATE_EXE_PATH}"
> +RUST_ALTERNATE_EXE_PATH_NATIVE = "${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config"
> +
>  export YOCTO_ALTERNATE_MULTILIB_NAME = "/${BASELIB}"
>
>  # We don't want to use bitbakes vendoring because the rust sources do their
> @@ -82,8 +83,9 @@ python do_configure() {
>      host_section = "target.{}".format(d.getVar('RUST_TARGET_SYS', True))
>      config.add_section(host_section)
>
> -    llvm_config = d.expand("${YOCTO_ALTERNATE_EXE_PATH}")
> -    config.set(host_section, "llvm-config", e(llvm_config))
> +    llvm_config_target = d.expand("${RUST_ALTERNATE_EXE_PATH}")
> +    llvm_config_build = d.expand("${RUST_ALTERNATE_EXE_PATH_NATIVE}")
> +    config.set(host_section, "llvm-config", e(llvm_config_target))
>
>      config.set(host_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
>      config.set(host_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
> @@ -93,7 +95,7 @@ python do_configure() {
>      build_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
>      config.add_section(build_section)
>
> -    config.set(build_section, "llvm-config", e(llvm_config))
> +    config.set(build_section, "llvm-config", e(llvm_config_build))
>
>      config.set(build_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
>      config.set(build_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
> @@ -169,6 +171,14 @@ rust_runx () {
>      unset CXXFLAGS
>      unset CPPFLAGS
>
> +    # Copy the natively built llvm-config into the target so we can run it. Horrible,
> +    # but works!
> +    if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} ]; then
> +        mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}`
> +        cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH}
> +        chrpath -d ${RUST_ALTERNATE_EXE_PATH}
> +    fi
> +


this is interesting. In meta-clang we have a different solution which
uses wrapper for llvm-config but this seems
interesting at the same time hacky but if it works. I will take a
deeper look from clang's pov too.

>      oe_cargo_fix_env
>
>      python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#168946): https://lists.openembedded.org/g/openembedded-core/message/168946
> Mute This Topic: https://lists.openembedded.org/mt/92834390/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2022-08-07  0:56 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05 13:12 [PATCH 01/29] nativesdk: Clear TUNE_FEATURES Richard Purdie
2022-08-05 13:12 ` [PATCH 02/29] populate_sdk_base: Disable rust SDK for MIPS n32 Richard Purdie
2022-08-07  0:39   ` [OE-core] " Khem Raj
2022-08-05 13:12 ` [PATCH 03/29] selftest/reproducible: Exclude rust/rust-dbg for now until we can fix Richard Purdie
2022-08-05 13:12 ` [PATCH 04/29] conf/distro/no-static-libs: Allow static musl for rust Richard Purdie
2022-08-07  0:41   ` [OE-core] " Khem Raj
2022-08-05 13:12 ` [PATCH 05/29] rust-target-config: Add mips n32 best guess at target information Richard Purdie
2022-08-07  0:47   ` [OE-core] " Khem Raj
2022-08-05 13:12 ` [PATCH 06/29] rust-common: Add CXXFLAGS Richard Purdie
2022-08-05 13:12 ` [PATCH 07/29] rust-common: Drop export directive from wrappers Richard Purdie
2022-08-05 13:12 ` [PATCH 08/29] rust-common: Rework wrappers top handle musl Richard Purdie
2022-08-05 13:12 ` [PATCH 09/29] rust: Work around reproducibility issues Richard Purdie
2022-08-05 13:12 ` [PATCH 10/29] rust: Switch to use RUST_XXX_SYS consistently Richard Purdie
2022-08-05 13:12 ` [PATCH 11/29] rust.inc: Rename variables to make code clearer Richard Purdie
2022-08-05 13:12 ` [PATCH 12/29] rust.inc: Fix cross build llvm-config handling Richard Purdie
2022-08-07  0:56   ` [OE-core] " Khem Raj
2022-08-05 13:12 ` [PATCH 13/29] rust/mesa: Drop obsolete YOCTO_ALTERNATE_MULTILIB_NAME Richard Purdie
2022-08-05 13:12 ` [PATCH 14/29] rust-target-config: Show clear error when target isn't defined Richard Purdie
2022-08-05 13:12 ` [PATCH 15/29] rust: Generate per recipe target configuration files Richard Purdie
2022-08-05 13:12 ` [PATCH 16/29] rust-common/rust: Improve bootstrap BUILD_SYS handling Richard Purdie
2022-08-05 13:12 ` [PATCH 17/29] cargo_common: Handle build SYS as well as HOST/TARGET Richard Purdie
2022-08-05 13:12 ` [PATCH 18/29] rust-llvm: Enable nativesdk variant Richard Purdie
2022-08-05 14:51   ` [OE-core] " Peter Kjellerstedt
2022-08-05 13:12 ` [PATCH 19/29] rust.inc: Fix for cross compilation configuration Richard Purdie
2022-08-05 13:12 ` [PATCH 20/29] rust-common: Update to match cross targets Richard Purdie
2022-08-05 13:12 ` [PATCH 21/29] rust-target-config: Make target workaround generic Richard Purdie
2022-08-05 14:47   ` [OE-core] " Peter Kjellerstedt
2022-08-05 13:12 ` [PATCH 22/29] rust-common: Simplify libc handling Richard Purdie
2022-08-05 13:12 ` [PATCH 23/29] cargo: Drop cross-canadian variant and fix/use nativesdk Richard Purdie
2022-08-05 13:12 ` [PATCH 24/29] rust-common: Set rustlibdir to match target expectation Richard Purdie
2022-08-05 13:12 ` [PATCH 25/29] rust-cross-canadian: Simplify and fix Richard Purdie
2022-08-05 13:12 ` [PATCH 26/29] rust: Drop cross/crosssdk Richard Purdie
2022-08-05 13:12 ` [PATCH 27/29] rust: Enable nativesdk and target builds + replace rust-tools-cross-canadian Richard Purdie
2022-08-05 13:12 ` [PATCH 28/29] rust: Fix musl builds Richard Purdie
2022-08-05 13:12 ` [PATCH 29/29] rust: Ensure buildpaths are handled in debug symbols correctly Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).