Skip to contentSkip to conversation

cargo.bbclass: avoid calling which ${RUSTC} with undefined ${RUSTC}

PATCH Superseded Martin Jansa 2 participants 4 messages Oct 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cargo.bbclass: avoid calling which ${RUSTC} with undefined ${RUSTC}

* causes which help text ending in log.do_compile, e.g.:

| DEBUG: Executing shell function do_compile
| NOTE: Using rust targets from /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/openssl-sys/0.9.77-r0/rust-targets/
| NOTE: cargo = /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/openssl-sys/0.9.77-r0/recipe-sysroot-native/usr/bin/cargo
| Usage: which [options] [--] COMMAND [...]
| Write the full path of COMMAND(s) to standard output.
|
|   --version, -[vV] Print version and exit successfully.
|   --help,          Print this help and exit successfully.
|   --skip-dot       Skip directories in PATH that start with a dot.
|   --skip-tilde     Skip directories in PATH that start with a tilde.
|   --show-dot       Don't expand a dot to current directory in output.
|   --show-tilde     Output a tilde for HOME directory for non-root.
|   --tty-only       Stop processing options on the right if not on tty.
|   --all, -a        Print all matches in PATH, not just the first
|   --read-alias, -i Read list of aliases from stdin.
|   --skip-alias     Ignore option --read-alias; don't read stdin.
|   --read-functions Read shell functions from stdin.
|   --skip-functions Ignore option --read-functions; don't read stdin.
|
| Recommended use is to write the output of (alias; declare -f) to standard
| input, so that which can show aliases and shell functions. See which(1) for
| examples.
|
| If the options --read-alias and/or --read-functions are specified then the
| output can be a full alias or function definition, optionally followed by
| the full path of each command used inside of those.
|
| Report bugs to <[email protected]>.
| NOTE: rustc =
---
 meta/classes-recipe/cargo.bbclass | 4 ++++
 1 file changed, 4 insertions(+)
meta/classes-recipe/cargo.bbclass +4 -0
index d1e83518b5..e884ff8b64 100644
@@ -15,6 +15,10 @@ inherit rust-target-config
 # the binary we will use
 CARGO = "cargo"
 
+# This is normally defined in rust.bbclass, but rust-target-config doesn't inherit rust.bbclass
+# and RUSTC is then undefined when calling which in oe_cargo_build
+RUSTC ?= "rustc"
+
 # We need cargo to compile for the target
 BASEDEPENDS:append = " cargo-native"
 
Signature · 1 line
2.38.1
#1 lore raw
Quoted 29 lines · Martin Jansa

* causes which help text ending in log.do_compile, e.g.:

Quoted 27 lines

DEBUG: Executing shell function do_compile
NOTE: Using rust targets from /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/openssl-sys/0.9.77-r0/rust-targets/
NOTE: cargo = /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/openssl-sys/0.9.77-r0/recipe-sysroot-native/usr/bin/cargo
Usage: which [options] [--] COMMAND [...]
Write the full path of COMMAND(s) to standard output.

--version, -[vV] Print version and exit successfully.

  --help,          Print this help and exit successfully.
  --skip-dot       Skip directories in PATH that start with a dot.
  --skip-tilde     Skip directories in PATH that start with a tilde.
  --show-dot       Don't expand a dot to current directory in output.
  --show-tilde     Output a tilde for HOME directory for non-root.
  --tty-only       Stop processing options on the right if not on tty.
  --all, -a        Print all matches in PATH, not just the first

--read-alias, -i Read list of aliases from stdin.
--skip-alias Ignore option --read-alias; don't read stdin.
--read-functions Read shell functions from stdin. --skip-functions Ignore option --read-functions; don't read stdin.

Recommended use is to write the output of (alias; declare -f) to standard input, so that which can show aliases and shell functions. See which(1) for examples.

If the options --read-alias and/or --read-functions are specified then the output can be a full alias or function definition, optionally followed by the full path of each command used inside of those.

Quoted 7 lines
Quoted 2 lines

Report bugs to <[email protected]>.
NOTE: rustc =

---
 meta/classes-recipe/cargo.bbclass | 4 ++++
 1 file changed, 4 insertions(+)

I've wondered about this. Lets just get rid of that "which RUSTC" call in cargo.bbclass instead?

Cheers,

Richard

#2 lore raw
Quoted 3 lines · Richard Purdie

I've wondered about this. Lets just get rid of that "which RUSTC" call in cargo.bbclass instead?

Fine with me, v2 coming soon.

FWIW: the rustc dependency seems to be there (it was showing the expected path to rustc after this).

#3 lore raw

PATCH v2 1/1 cargo.bbclass: avoid calling which ${RUSTC} with undefined ${RUSTC}

In reply to Richard Purdie

* RUSTC is normally defined in rust.bbclass, but rust-target-config doesn't inherit rust.bbclass and RUSTC is then undefined when calling 'which' in oe_cargo_build

* causes which help text ending in log.do_compile, e.g.:

| DEBUG: Executing shell function do_compile
| NOTE: Using rust targets from /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/openssl-sys/0.9.77-r0/rust-targets/
| NOTE: cargo = /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/openssl-sys/0.9.77-r0/recipe-sysroot-native/usr/bin/cargo
| Usage: which [options] [--] COMMAND [...]
| Write the full path of COMMAND(s) to standard output.
|
|   --version, -[vV] Print version and exit successfully.
|   --help,          Print this help and exit successfully.
|   --skip-dot       Skip directories in PATH that start with a dot.
|   --skip-tilde     Skip directories in PATH that start with a tilde.
|   --show-dot       Don't expand a dot to current directory in output.
|   --show-tilde     Output a tilde for HOME directory for non-root.
|   --tty-only       Stop processing options on the right if not on tty.
|   --all, -a        Print all matches in PATH, not just the first
|   --read-alias, -i Read list of aliases from stdin.
|   --skip-alias     Ignore option --read-alias; don't read stdin.
|   --read-functions Read shell functions from stdin.
|   --skip-functions Ignore option --read-functions; don't read stdin.
|
| Recommended use is to write the output of (alias; declare -f) to standard
| input, so that which can show aliases and shell functions. See which(1) for
| examples.
|
| If the options --read-alias and/or --read-functions are specified then the
| output can be a full alias or function definition, optionally followed by
| the full path of each command used inside of those.
|
| Report bugs to <[email protected]>.
| NOTE: rustc =
---
 meta/classes-recipe/cargo.bbclass | 1 -
 1 file changed, 1 deletion(-)
meta/classes-recipe/cargo.bbclass +0 -1
index d1e83518b5..93e185f2c9 100644
@@ -49,7 +49,6 @@ oe_cargo_build () {
 	export RUSTFLAGS="${RUSTFLAGS}"
 	bbnote "Using rust targets from ${RUST_TARGET_PATH}"
 	bbnote "cargo = $(which ${CARGO})"
-	bbnote "rustc = $(which ${RUSTC})"
 	bbnote "${CARGO} build ${CARGO_BUILD_FLAGS} $@"
 	"${CARGO}" build ${CARGO_BUILD_FLAGS} "$@"
 }
Signature · 1 line
2.38.1