* [OE-core][PATCH v2 1/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUSTFLAGS
@ 2023-10-03 7:06 Sean Nyekjaer
2023-10-03 7:06 ` [OE-core][PATCH v2 2/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUNNER for nativesdk Sean Nyekjaer
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sean Nyekjaer @ 2023-10-03 7:06 UTC (permalink / raw)
To: openembedded-core; +Cc: Sean Nyekjaer, kasper
Avoid setting sdk-wide RUSTFLAGS as these flags only are valid when
building for target.
This will enable building for different targets with different
RUSTFLAGS.
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
meta/recipes-devtools/rust/rust-cross-canadian.inc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-devtools/rust/rust-cross-canadian.inc b/meta/recipes-devtools/rust/rust-cross-canadian.inc
index d569ac59f5..d25646237c 100644
--- a/meta/recipes-devtools/rust/rust-cross-canadian.inc
+++ b/meta/recipes-devtools/rust/rust-cross-canadian.inc
@@ -54,8 +54,10 @@ do_install () {
mkdir "${ENV_SETUP_DIR}"
RUST_ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh"
+ RUST_TARGET_TRIPLE=`echo ${RUST_TARGET_SYS} | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'`
+
cat <<- EOF > "${RUST_ENV_SETUP_SH}"
- export RUSTFLAGS="--sysroot=\$OECORE_TARGET_SYSROOT/usr -C link-arg=--sysroot=\$OECORE_TARGET_SYSROOT"
+ export CARGO_TARGET_${RUST_TARGET_TRIPLE}_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
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [OE-core][PATCH v2 2/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUNNER for nativesdk
2023-10-03 7:06 [OE-core][PATCH v2 1/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUSTFLAGS Sean Nyekjaer
@ 2023-10-03 7:06 ` Sean Nyekjaer
2023-10-03 7:06 ` [OE-core][PATCH v2 3/3] oeqa/sdk/rust: Add build and run test of rust binary with SDK host Sean Nyekjaer
2023-10-06 22:01 ` [OE-core][PATCH v2 1/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUSTFLAGS Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Sean Nyekjaer @ 2023-10-03 7:06 UTC (permalink / raw)
To: openembedded-core; +Cc: Sean Nyekjaer, kasper
This will enable us to build and run rust programs on the sdk host.
% cargo run --target x86_64-oesdk-linux-gnu -vv
Fresh hello v0.1.0 (~/development/hello)
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running `/usr/local/sdk/sysroots/x86_64-oesdk-linux/lib/ld-linux-x86-64.so.2 target/x86_64-oesdk-linux-gnu/debug/hello`
Hello, world
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
meta/recipes-devtools/rust/rust-cross-canadian.inc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/meta/recipes-devtools/rust/rust-cross-canadian.inc b/meta/recipes-devtools/rust/rust-cross-canadian.inc
index d25646237c..5b89216658 100644
--- a/meta/recipes-devtools/rust/rust-cross-canadian.inc
+++ b/meta/recipes-devtools/rust/rust-cross-canadian.inc
@@ -55,9 +55,12 @@ do_install () {
RUST_ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh"
RUST_TARGET_TRIPLE=`echo ${RUST_TARGET_SYS} | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'`
+ RUST_HOST_TRIPLE=`echo ${RUST_HOST_SYS} | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'`
+ SDKARCH=`echo ${SDK_ARCH} | sed 's/_/-/g'`
cat <<- EOF > "${RUST_ENV_SETUP_SH}"
export CARGO_TARGET_${RUST_TARGET_TRIPLE}_RUSTFLAGS="--sysroot=\$OECORE_TARGET_SYSROOT/usr -C link-arg=--sysroot=\$OECORE_TARGET_SYSROOT"
+ export CARGO_TARGET_${RUST_HOST_TRIPLE}_RUNNER="\$OECORE_NATIVE_SYSROOT/lib/ld-linux-${SDKARCH}.so.2"
export RUST_TARGET_PATH="\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib"
EOF
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [OE-core][PATCH v2 3/3] oeqa/sdk/rust: Add build and run test of rust binary with SDK host
2023-10-03 7:06 [OE-core][PATCH v2 1/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUSTFLAGS Sean Nyekjaer
2023-10-03 7:06 ` [OE-core][PATCH v2 2/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUNNER for nativesdk Sean Nyekjaer
@ 2023-10-03 7:06 ` Sean Nyekjaer
2023-10-06 22:01 ` [OE-core][PATCH v2 1/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUSTFLAGS Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Sean Nyekjaer @ 2023-10-03 7:06 UTC (permalink / raw)
To: openembedded-core; +Cc: Sean Nyekjaer, kasper
Add a QA test to the SDK to test that a basic cargo build works for the
SDK host.
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
Changes since v1:
- use SDK_SYS for compiling for SDK Host
meta/lib/oeqa/sdk/cases/rust.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/meta/lib/oeqa/sdk/cases/rust.py b/meta/lib/oeqa/sdk/cases/rust.py
index 31036f0f14..f5d437bb19 100644
--- a/meta/lib/oeqa/sdk/cases/rust.py
+++ b/meta/lib/oeqa/sdk/cases/rust.py
@@ -33,3 +33,25 @@ class RustCompileTest(OESDKTestCase):
def test_cargo_build(self):
self._run('cd %s/hello; cargo build' % self.tc.sdk_dir)
+
+class RustHostCompileTest(OESDKTestCase):
+ td_vars = ['MACHINE', 'SDK_SYS']
+
+ @classmethod
+ def setUpClass(self):
+ targetdir = os.path.join(self.tc.sdk_dir, "hello")
+ try:
+ shutil.rmtree(targetdir)
+ except FileNotFoundError:
+ pass
+ shutil.copytree(os.path.join(self.tc.sdk_files_dir, "rust/hello"), targetdir)
+
+ def setUp(self):
+ machine = self.td.get("MACHINE")
+ if not self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine):
+ raise unittest.SkipTest("RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain")
+
+ def test_cargo_build(self):
+ sdksys = self.td.get("SDK_SYS")
+ self._run('cd %s/hello; cargo build --target %s-gnu' % (self.tc.sdk_dir, sdksys))
+ self._run('cd %s/hello; cargo run --target %s-gnu' % (self.tc.sdk_dir, sdksys))
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [OE-core][PATCH v2 1/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUSTFLAGS
2023-10-03 7:06 [OE-core][PATCH v2 1/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUSTFLAGS Sean Nyekjaer
2023-10-03 7:06 ` [OE-core][PATCH v2 2/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUNNER for nativesdk Sean Nyekjaer
2023-10-03 7:06 ` [OE-core][PATCH v2 3/3] oeqa/sdk/rust: Add build and run test of rust binary with SDK host Sean Nyekjaer
@ 2023-10-06 22:01 ` Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2023-10-06 22:01 UTC (permalink / raw)
To: Sean Nyekjaer; +Cc: openembedded-core, kasper
Hello,
I believe this series causes this kind of failures:
https://autobuilder.yoctoproject.org/typhoon/#/builders/73/builds/7857/steps/17/logs/stdio
File "/home/pokybuild/yocto-worker/qemux86-64/build/meta/lib/oeqa/sdk/cases/rust.py", line 57, in test_cargo_build
self._run('cd %s/hello; cargo run --target %s-gnu' % (self.tc.sdk_dir, sdksys))
File "/home/pokybuild/yocto-worker/qemux86-64/build/meta/lib/oeqa/sdk/case.py", line 14, in _run
return subprocess.check_output(". %s > /dev/null; %s;" % \
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pokybuild/yocto-worker/qemux86-64/build/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/python3.11/subprocess.py", line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pokybuild/yocto-worker/qemux86-64/build/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/python3.11/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
oeqa.utils.subprocesstweak.OETestCalledProcessError: Command '. /home/pokybuild/yocto-worker/qemux86-64/build/build/tmp/work/qemux86_64-poky-linux/core-image-sato/1.0/testimage-sdk/environment-setup-core2-64-poky-linux > /dev/null; cd /home/pokybuild/yocto-worker/qemux86-64/build/build/tmp/work/qemux86_64-poky-linux/core-image-sato/1.0/testimage-sdk//hello; cargo run --target i686-pokysdk-linux-gnu;' returned non-zero exit status 101
Standard Output: Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running `/home/pokybuild/yocto-worker/qemux86-64/build/build/tmp/work/qemux86_64-poky-linux/core-image-sato/1.0/testimage-sdk/sysroots/i686-pokysdk-linux/lib/ld-linux-i686.so.2 target/i686-pokysdk-linux-gnu/debug/hello`
error: could not execute process `/home/pokybuild/yocto-worker/qemux86-64/build/build/tmp/work/qemux86_64-poky-linux/core-image-sato/1.0/testimage-sdk/sysroots/i686-pokysdk-linux/lib/ld-linux-i686.so.2 target/i686-pokysdk-linux-gnu/debug/hello` (never executed)
Caused by:
No such file or directory (os error 2)
On 03/10/2023 09:06:28+0200, Sean Nyekjaer wrote:
> Avoid setting sdk-wide RUSTFLAGS as these flags only are valid when
> building for target.
> This will enable building for different targets with different
> RUSTFLAGS.
>
> Signed-off-by: Sean Nyekjaer <sean@geanix.com>
> ---
> meta/recipes-devtools/rust/rust-cross-canadian.inc | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-devtools/rust/rust-cross-canadian.inc b/meta/recipes-devtools/rust/rust-cross-canadian.inc
> index d569ac59f5..d25646237c 100644
> --- a/meta/recipes-devtools/rust/rust-cross-canadian.inc
> +++ b/meta/recipes-devtools/rust/rust-cross-canadian.inc
> @@ -54,8 +54,10 @@ do_install () {
> mkdir "${ENV_SETUP_DIR}"
> RUST_ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh"
>
> + RUST_TARGET_TRIPLE=`echo ${RUST_TARGET_SYS} | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'`
> +
> cat <<- EOF > "${RUST_ENV_SETUP_SH}"
> - export RUSTFLAGS="--sysroot=\$OECORE_TARGET_SYSROOT/usr -C link-arg=--sysroot=\$OECORE_TARGET_SYSROOT"
> + export CARGO_TARGET_${RUST_TARGET_TRIPLE}_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
>
> --
> 2.42.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#188625): https://lists.openembedded.org/g/openembedded-core/message/188625
> Mute This Topic: https://lists.openembedded.org/mt/101729592/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-06 22:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-03 7:06 [OE-core][PATCH v2 1/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUSTFLAGS Sean Nyekjaer
2023-10-03 7:06 ` [OE-core][PATCH v2 2/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUNNER for nativesdk Sean Nyekjaer
2023-10-03 7:06 ` [OE-core][PATCH v2 3/3] oeqa/sdk/rust: Add build and run test of rust binary with SDK host Sean Nyekjaer
2023-10-06 22:01 ` [OE-core][PATCH v2 1/3] rust-cross-canadian: set CARGO_TARGET_<triple>_RUSTFLAGS Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox