-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cross-compilation logic for Mbed Crypto #61
Conversation
When compiling the service with `cargo build --target aarch64-unknown-linux-gnu` Mbed Crypto should also be compiled for the same target and all object files should be linked together for that target. This commit adds the necessary logic to achieve that. Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
@@ -70,45 +81,66 @@ fn setup_mbed_crypto(mbed_config: &MbedConfig) { | |||
let metadata = package | |||
.metadata | |||
.expect("Cargo.toml does not contain package metadata."); | |||
let plasma_config = get_value_from_table(&metadata, CONFIG_TABLE_NAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, 'plasma' was still a thing. 😮
project_dir | ||
); | ||
println!("cargo:rustc-link-lib=static=mbedcrypto"); | ||
println!("cargo:rerun-if-changed={}", header); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thanks for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
toolchain = mbed_config.aarch64_unknown_linux_gnu.as_ref().unwrap(); | ||
mbed_compiler = toolchain | ||
.mbed_compiler | ||
.clone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to clone here? Since you only use the value in an if-else, you should be able to just extract it out of toolchain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove the clone
I have the following error:
error[E0507]: cannot move out of `toolchain.mbed_compiler` which is behind a shared reference
--> build.rs:95:25
|
95 | mbed_compiler = toolchain
| _________________________^
96 | | .mbed_compiler
| |__________________________^ move occurs because `toolchain.mbed_compiler` has type `std::option::Option<std::string::String>`, which does not implement the `Copy` trait
help: consider borrowing the `Option`'s content
|
95 | mbed_compiler = toolchain
96 | .mbed_compiler.as_ref()
|
If I use as_ref
however then in the unwrap_or
I have on one side a &String
and one the other a &str
. I did not find a good way to convert both to the same type so I just assumed using clone
was acceptable here because of that 😃
When compiling the service with
cargo build --target aarch64-unknown-linux-gnu
Mbed Crypto should also be compiled for the same target and all object
files should be linked together for that target. This commit adds the
necessary logic to achieve that.