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

Allow of way to toggle freestanding platform features #356

Merged
merged 2 commits into from
Mar 11, 2024
Merged

Allow of way to toggle freestanding platform features #356

merged 2 commits into from
Mar 11, 2024

Conversation

MasterAwesome
Copy link
Contributor

@MasterAwesome MasterAwesome commented Mar 7, 2024

RUST_MBED_C_COMPILER_FREESTANDING=1 allows to skip cmake checks where the target must produce valid binaries.

Closes: #355

cc: @Taowyoo

`RUST_MBED_C_COMPILER_FREESTANDING=1` allows to skip cmake checks where
the target must produce valid binaries
@Taowyoo
Copy link
Collaborator

Taowyoo commented Mar 7, 2024

latest nightly compiler provides some new warnings. will fix them in another PR

@@ -32,7 +32,9 @@ impl super::BuildConfig {
// thumbv6m-none-eabi, thumbv7em-none-eabi, thumbv7em-none-eabihf,
// thumbv7m-none-eabi probably use arm-none-eabi-gcc which can cause the
// cmake compiler test to fail.
if target.starts_with("thumbv") && target.contains("none-eabi") {
if target.starts_with("thumbv") && target.contains("none-eabi")
|| crate::features::FEATURES.have_platform_component("c_compiler", "freestanding")
Copy link
Collaborator

@Taowyoo Taowyoo Mar 9, 2024

Choose a reason for hiding this comment

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

This will affect the environment which already has freestanding feature.
I think you could just directly read RUST_MBED_C_COMPILER_FREESTANDING and use it here. And it could have a better name, such as RUST_MBED_C_COMPILER_ARM_BAREMETAL or anything more related to the issue or reason here.

In mbedtls-sys/build/features.rs you do not need to change the logic about adding freestanding feature.

Copy link
Collaborator

@Taowyoo Taowyoo Mar 9, 2024

Choose a reason for hiding this comment

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

Also, I am thinking if your case can be determined by checking some property of cc here.

Note: cc represents c compiler here, see let cc = cc::Build::new().get_compiler();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Querying from CC could work but is not guaranteed for example we can check for -none targets however there might be other operating systems that purely only support static libraries.

I've tested 30b7f13 with

$ CFLAGS="-isysroot /opt/arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-elf" CC=clang RUST_MBED_C_COMPILER_BAREMETAL=1 cargo +stable b --target aarch64-unknown-none --no-default-features --features no_std_deps

@MasterAwesome MasterAwesome marked this pull request as ready for review March 9, 2024 19:39
@Taowyoo Taowyoo merged commit 2f08d21 into fortanix:master Mar 11, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check to set CMAKE_TRY_COMPILE_TARGET_TYPE too restrictive
2 participants