Skip to content
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

Merged
merged 1 commit into from
Oct 30, 2019

Conversation

hug-dev
Copy link
Member

@hug-dev hug-dev commented Oct 29, 2019

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.

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>
@hug-dev hug-dev added the enhancement New feature or request label Oct 29, 2019
@hug-dev hug-dev requested a review from ionut-arm October 29, 2019 16:49
@hug-dev hug-dev self-assigned this Oct 29, 2019
@@ -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);
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for this

Copy link
Member

@ionut-arm ionut-arm left a 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()
Copy link
Member

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

Copy link
Member Author

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 😃

@hug-dev hug-dev merged commit 5a02bc4 into parallaxsecond:master Oct 30, 2019
@hug-dev hug-dev deleted the cross-compile branch October 30, 2019 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants