All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation
@ 2022-07-07 17:19 Otavio Salvador
  2022-07-07 17:19 ` [PATCH 2/2] cargo-cross-canadian: Use SDK's flags during target linking Otavio Salvador
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Otavio Salvador @ 2022-07-07 17:19 UTC (permalink / raw)
  To: openembedded-core; +Cc: Otavio Salvador

We need full target passed for build so we changed the
rust-cross-canadian to use same code used in regular rust recipes and
added support to use specific llvm-target for the building host.

Fixes: ef566af964 ("rust: fix issue building cross-canadian tools for aarch64 on x86_64")
Fixes: bd36593ba3 ("rust-common: Drop LLVM_TARGET and simplify")
Fixes: 8ed000debb ("rust-common: Fix for target definitions returning 'NoneType' for arm")
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---

 meta/recipes-devtools/rust/rust-common.inc    | 21 ++++++++++++------
 .../rust/rust-cross-canadian-common.inc       | 22 ++++++++++++++++---
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/meta/recipes-devtools/rust/rust-common.inc b/meta/recipes-devtools/rust/rust-common.inc
index ef70c48d0f..f8d365ecf8 100644
--- a/meta/recipes-devtools/rust/rust-common.inc
+++ b/meta/recipes-devtools/rust/rust-common.inc
@@ -119,12 +119,12 @@ def llvm_features(d):
 
 
 ## arm-unknown-linux-gnueabihf
-DATA_LAYOUT[arm] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-TARGET_ENDIAN[arm] = "little"
-TARGET_POINTER_WIDTH[arm] = "32"
-TARGET_C_INT_WIDTH[arm] = "32"
-MAX_ATOMIC_WIDTH[arm] = "64"
-FEATURES[arm] = "+v6,+vfp2"
+DATA_LAYOUT[arm-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+TARGET_ENDIAN[arm-eabi] = "little"
+TARGET_POINTER_WIDTH[arm-eabi] = "32"
+TARGET_C_INT_WIDTH[arm-eabi] = "32"
+MAX_ATOMIC_WIDTH[arm-eabi] = "64"
+FEATURES[arm-eabi] = "+v6,+vfp2"
 
 ## armv7-unknown-linux-gnueabihf
 DATA_LAYOUT[armv7-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
@@ -304,12 +304,19 @@ def rust_gen_target(d, thing, wd, features, cpu, arch, abi=""):
     else:
         arch_abi = rust_arch
 
+    # When building for the building system we need to return the HOST target
+    # or wrong flags are used.
+    if thing is "BUILD":
+        llvm_target = d.getVar('RUST_HOST_SYS', arch_abi)
+    else:
+        llvm_target = d.getVar('RUST_TARGET_SYS', arch_abi)
+
     features = features or d.getVarFlag('FEATURES', arch_abi) or ""
     features = features.strip()
 
     # build tspec
     tspec = {}
-    tspec['llvm-target'] = d.getVar('RUST_TARGET_SYS', arch_abi)
+    tspec['llvm-target'] = llvm_target
     tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', 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)
diff --git a/meta/recipes-devtools/rust/rust-cross-canadian-common.inc b/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
index 1f21c8af26..eff9212648 100644
--- a/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
+++ b/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
@@ -27,9 +27,23 @@ DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDP
 
 python do_rust_gen_targets () {
     wd = d.getVar('WORKDIR') + '/targets/'
-    rust_gen_target(d, 'TARGET', wd, d.getVar('TARGET_LLVM_FEATURES') or "", d.getVar('TARGET_LLVM_CPU'), d.getVar('TARGET_ARCH'))
-    rust_gen_target(d, 'HOST', wd, "", "generic", d.getVar('HOST_ARCH'))
-    rust_gen_target(d, 'BUILD', wd, "", "generic", d.getVar('BUILD_ARCH'))
+    # It is important 'TARGET' is last here so that it overrides our less
+    # informed choices for BUILD & HOST if TARGET happens to be the same as
+    # either of them.
+    for thing in ['BUILD', 'HOST', 'TARGET']:
+        bb.debug(1, "rust_gen_target for " + thing)
+        features = ""
+        cpu = "generic"
+        arch = d.getVar('{}_ARCH'.format(thing))
+        abi = ""
+        if thing is "TARGET":
+            abi = d.getVar('ABIEXTENSION')
+            # arm and armv7 have different targets in llvm
+            if arch == "arm" and target_is_armv7(d):
+                arch = 'armv7'
+            features = d.getVar('TARGET_LLVM_FEATURES') or ""
+            cpu = d.getVar('TARGET_LLVM_CPU')
+        rust_gen_target(d, thing, wd, features, cpu, arch, abi)
 }
 
 INHIBIT_DEFAULT_RUST_DEPS = "1"
@@ -45,6 +59,8 @@ python do_configure:prepend() {
     hosts = ["{}-unknown-linux-gnu".format(d.getVar("HOST_ARCH", True))]
 }
 
+INSANE_SKIP:${PN} = "libdir"
+
 INSANE_SKIP:${RUSTLIB_TARGET_PN} = "file-rdeps arch ldflags"
 SKIP_FILEDEPS:${RUSTLIB_TARGET_PN} = "1"
 
-- 
2.36.1



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

* [PATCH 2/2] cargo-cross-canadian: Use SDK's flags during target linking
  2022-07-07 17:19 [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation Otavio Salvador
@ 2022-07-07 17:19 ` Otavio Salvador
  2022-07-07 17:19 ` [PATCH] Linux 5.4.202 Otavio Salvador
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2022-07-07 17:19 UTC (permalink / raw)
  To: openembedded-core; +Cc: Otavio Salvador

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---

 .../cargo/cargo-cross-canadian.inc            | 20 ++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-devtools/cargo/cargo-cross-canadian.inc b/meta/recipes-devtools/cargo/cargo-cross-canadian.inc
index 7fc22a4128..01ba151d0a 100644
--- a/meta/recipes-devtools/cargo/cargo-cross-canadian.inc
+++ b/meta/recipes-devtools/cargo/cargo-cross-canadian.inc
@@ -39,6 +39,18 @@ 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}"
@@ -47,6 +59,9 @@ do_install () {
 	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"
@@ -58,7 +73,10 @@ do_install () {
 		touch "\$CARGO_HOME/config"
 		echo "[build]" >> "\$CARGO_HOME/config"
 		echo 'target = "'${TARGET_SYS}'"' >> "\$CARGO_HOME/config"
-        fi
+		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
-- 
2.36.1



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

* [PATCH] Linux 5.4.202
  2022-07-07 17:19 [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation Otavio Salvador
  2022-07-07 17:19 ` [PATCH 2/2] cargo-cross-canadian: Use SDK's flags during target linking Otavio Salvador
@ 2022-07-07 17:19 ` Otavio Salvador
       [not found] ` <16FF9BAD54CACFDA.9983@lists.openembedded.org>
  2022-07-09 13:14 ` [OE-core] [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation Richard Purdie
  3 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2022-07-07 17:19 UTC (permalink / raw)
  To: openembedded-core
  Cc: Greg Kroah-Hartman, Jon Hunter, Florian Fainelli, Shuah Khan,
	Guenter Roeck, Sudip Mukherjee, Hulk Robot

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Link: https://lore.kernel.org/r/20220627111927.641837068@linuxfoundation.org
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Shuah Khan <skhan@linuxfoundation.org>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Tested-by: Hulk Robot <hulkrobot@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index ae9156f804e5..021878dc23f9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 VERSION = 5
 PATCHLEVEL = 4
-SUBLEVEL = 201
+SUBLEVEL = 202
 EXTRAVERSION =
 NAME = Kleptomaniac Octopus
 
-- 
2.36.1



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

* Re: [OE-core] [PATCH] Linux 5.4.202
       [not found] ` <16FF9BAD54CACFDA.9983@lists.openembedded.org>
@ 2022-07-07 17:21   ` Otavio Salvador
  0 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2022-07-07 17:21 UTC (permalink / raw)
  To: Otavio Salvador
  Cc: Patches and discussions about the oe-core layer,
	Greg Kroah-Hartman, Jon Hunter, Florian Fainelli, Shuah Khan,
	Guenter Roeck, Sudip Mukherjee, Hulk Robot

[-- Attachment #1: Type: text/plain, Size: 1746 bytes --]

My mistake, sorry.

Em qui., 7 de jul. de 2022 às 14:19, Otavio Salvador via
lists.openembedded.org <otavio.salvador=gmail.com@lists.openembedded.org>
escreveu:

> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> Link:
> https://lore.kernel.org/r/20220627111927.641837068@linuxfoundation.org
> Tested-by: Jon Hunter <jonathanh@nvidia.com>
> Tested-by: Florian Fainelli <f.fainelli@gmail.com>
> Tested-by: Shuah Khan <skhan@linuxfoundation.org>
> Tested-by: Guenter Roeck <linux@roeck-us.net>
> Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
> Tested-by: Hulk Robot <hulkrobot@huawei.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index ae9156f804e5..021878dc23f9 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1,7 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0
>  VERSION = 5
>  PATCHLEVEL = 4
> -SUBLEVEL = 201
> +SUBLEVEL = 202
>  EXTRAVERSION =
>  NAME = Kleptomaniac Octopus
>
> --
> 2.36.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#167796):
> https://lists.openembedded.org/g/openembedded-core/message/167796
> Mute This Topic: https://lists.openembedded.org/mt/92233382/3617537
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> otavio.salvador@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>

-- 
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750

[-- Attachment #2: Type: text/html, Size: 3495 bytes --]

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

* Re: [OE-core] [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation
  2022-07-07 17:19 [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation Otavio Salvador
                   ` (2 preceding siblings ...)
       [not found] ` <16FF9BAD54CACFDA.9983@lists.openembedded.org>
@ 2022-07-09 13:14 ` Richard Purdie
  2022-07-09 16:00   ` Otavio Salvador
  3 siblings, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2022-07-09 13:14 UTC (permalink / raw)
  To: Otavio Salvador, openembedded-core; +Cc: Otavio Salvador

On Thu, 2022-07-07 at 14:19 -0300, Otavio Salvador wrote:
> We need full target passed for build so we changed the
> rust-cross-canadian to use same code used in regular rust recipes and
> added support to use specific llvm-target for the building host.
> 
> Fixes: ef566af964 ("rust: fix issue building cross-canadian tools for aarch64 on x86_64")
> Fixes: bd36593ba3 ("rust-common: Drop LLVM_TARGET and simplify")
> Fixes: 8ed000debb ("rust-common: Fix for target definitions returning 'NoneType' for arm")
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> ---
> 
>  meta/recipes-devtools/rust/rust-common.inc    | 21 ++++++++++++------
>  .../rust/rust-cross-canadian-common.inc       | 22 ++++++++++++++++---
>  2 files changed, 33 insertions(+), 10 deletions(-)

I ran these through the autobuilder:

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/3809/steps/14/logs/stdio

seems there is some syntax that recent python doesn't like. I do need
to look at the patches in more detail but wanted to share the
autobuilder results.

Cheers,

Richard



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

* Re: [OE-core] [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation
  2022-07-09 13:14 ` [OE-core] [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation Richard Purdie
@ 2022-07-09 16:00   ` Otavio Salvador
  0 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2022-07-09 16:00 UTC (permalink / raw)
  To: Richard Purdie
  Cc: Patches and discussions about the oe-core layer, Otavio Salvador

[-- Attachment #1: Type: text/plain, Size: 1465 bytes --]

Em sáb., 9 de jul. de 2022 às 10:14, Richard Purdie <
richard.purdie@linuxfoundation.org> escreveu:

> On Thu, 2022-07-07 at 14:19 -0300, Otavio Salvador wrote:
> > We need full target passed for build so we changed the
> > rust-cross-canadian to use same code used in regular rust recipes and
> > added support to use specific llvm-target for the building host.
> >
> > Fixes: ef566af964 ("rust: fix issue building cross-canadian tools for
> aarch64 on x86_64")
> > Fixes: bd36593ba3 ("rust-common: Drop LLVM_TARGET and simplify")
> > Fixes: 8ed000debb ("rust-common: Fix for target definitions returning
> 'NoneType' for arm")
> > Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> > ---
> >
> >  meta/recipes-devtools/rust/rust-common.inc    | 21 ++++++++++++------
> >  .../rust/rust-cross-canadian-common.inc       | 22 ++++++++++++++++---
> >  2 files changed, 33 insertions(+), 10 deletions(-)
>
> I ran these through the autobuilder:
>
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/3809/steps/14/logs/stdio
>
> seems there is some syntax that recent python doesn't like. I do need
> to look at the patches in more detail but wanted to share the
> autobuilder results.
>

I will fix and send a v2.

-- 
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750

[-- Attachment #2: Type: text/html, Size: 2338 bytes --]

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

end of thread, other threads:[~2022-07-09 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 17:19 [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation Otavio Salvador
2022-07-07 17:19 ` [PATCH 2/2] cargo-cross-canadian: Use SDK's flags during target linking Otavio Salvador
2022-07-07 17:19 ` [PATCH] Linux 5.4.202 Otavio Salvador
     [not found] ` <16FF9BAD54CACFDA.9983@lists.openembedded.org>
2022-07-07 17:21   ` [OE-core] " Otavio Salvador
2022-07-09 13:14 ` [OE-core] [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation Richard Purdie
2022-07-09 16:00   ` Otavio Salvador

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.