Re: [OE-core] [PATCH v2 1/2] rust-common: Fix use of target definitions for SDK generation

2022-07-14 Thread Otavio Salvador
Hello Alejandro,

Em qua., 13 de jul. de 2022 às 21:08, Alejandro Hernandez Samaniego <
a...@linux.microsoft.com> escreveu:

> These look okay to me, could we backport these to Kirkstone?
>
This is my goal as well; kirkstone is broken for me at this moment.

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

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#168031): 
https://lists.openembedded.org/g/openembedded-core/message/168031
Mute This Topic: https://lists.openembedded.org/mt/92292890/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [OE-core] [PATCH v2 1/2] rust-common: Fix use of target definitions for SDK generation

2022-07-13 Thread Alejandro Hernandez Samaniego


On 7/10/22 10:42, 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
---

Changes in v2:
- Fix syntax for newer Python

  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..a937d58a37 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 == "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"



These look okay to me, could we backport these to Kirkstone?

Alejandro


  





-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#167996): 
https://lists.openembedded.org/g/openembedded-core/message/167996
Mute This Topic: https://lists.openembedded.org/mt/92292890/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [OE-core] [PATCH v2 1/2] rust-common: Fix use of target definitions for SDK generation

2022-07-13 Thread Sundeep KOKKONDA
Hello Otavio,

Are there any build/test issues with previous implementation? Can you let me 
know what are the regression caused by below commits. I want to understand the 
reason for the changes in this patch.
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")

Thanks,
Sundeep K.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#167964): 
https://lists.openembedded.org/g/openembedded-core/message/167964
Mute This Topic: https://lists.openembedded.org/mt/92292890/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[OE-core] [PATCH v2 1/2] rust-common: Fix use of target definitions for SDK generation

2022-07-10 Thread 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 
---

Changes in v2:
- Fix syntax for newer Python

 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..a937d58a37 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 == "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


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#167848): 
https://lists.openembedded.org/g/openembedded-core/message/167848
Mute This Topic: https://lists.openembedded.org/mt/92292890/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-