Skip to content

Commit e1d08fb

Browse files
committed
UIC-8953: rust: Allow target triple overide in CMakeCargo too
This change is helpful to trace/debug rust related job. This was useful to build zpc natively on arm64 (aarch64-unknown-linux-gnu). The earlier change is not enough. What has been observed on native arm64 build: .../1.71.0-aarch64-unknown-linux-gnu/bin/cargo build \ --manifest-path /.../applications/zpc/components/zpc_rust/Cargo.toml \ --locked \ --target x86_64-unknown-linux-gnu While it was passed a cmake define Note to self, for maintenance sake, it would make sense to contribute those macros outside, the project ideally in rust or cmake community. It was made for core v7 but also applies to zpc v6 Relate-to: https://doc.rust-lang.org/nightly/rustc/platform-support.html Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
1 parent 35eb6e4 commit e1d08fb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmake/modules/CMakeCargo.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ endfunction()
100100
# --locked only build specific versions
101101
# defined in Cargo.lock file. the goal is to get more deterministic builds
102102
# --target specify the target triple to build for.
103-
get_target_triple(CARGO_TARGET_TRIPLE)
103+
104+
# Allow overide from env (the above detection may not be reliable or scale)
105+
if(NOT DEFINED CARGO_TARGET_TRIPLE)
106+
get_target_triple(CARGO_TARGET_TRIPLE)
107+
endif()
108+
104109
rust_build_profile(CARGO_PROFILE)
105110
set(CARGO_ARGS
106111
" --locked --target ${CARGO_TARGET_TRIPLE} --profile ${CARGO_PROFILE}")

0 commit comments

Comments
 (0)