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 NO_STD switch #154

Merged
merged 8 commits into from
Mar 27, 2022
Merged

Add NO_STD switch #154

merged 8 commits into from
Mar 27, 2022

Conversation

arkkors
Copy link
Contributor

@arkkors arkkors commented Mar 25, 2022

Adds the NO_STD switch to Corrosion, allowing building
no_std crates in CMake without linking additional libraries.

Closes #153

Adds the NO_DEFAULT_LIBRARIES switch to Corrosion, allowing building
no_std crates in CMake without linking additional libraries.
@arkkors arkkors marked this pull request as ready for review March 25, 2022 17:07
@arkkors arkkors marked this pull request as draft March 25, 2022 17:12
Copy link
Collaborator

@ogoffart ogoffart 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!

I just wonder if the option should not be called just NO_STD to match the rust attribute.
Or is that a different thing?
Does it work for a no_std crate that uses the alloc crate?

@arkkors
Copy link
Contributor Author

arkkors commented Mar 25, 2022

  1. Yeah, NO_STD is shorter :) Also, I don't really see the distinction (at least in practice).

  2. I don't see why it shouldn't work with alloc, but I'm not entirely sure. Will try that out later.

@arkkors arkkors changed the title Add NO_DEFAULT_LIBRARIES switch Add NO_STD switch Mar 25, 2022
@arkkors
Copy link
Contributor Author

arkkors commented Mar 25, 2022

  1. The nostd test should now work under 1.44.1, so the test suite should (hopefully) pass now.
  2. Regarding the alloc crate question: The alloc crate itself works in this setup. You need to define a global allocator though and probably setup an alloc error handler (e.g via #![feature(default_alloc_error_handler)]). This needs a nightly toolchain AFAIK. But it works :)

@arkkors arkkors marked this pull request as ready for review March 25, 2022 18:53
@jschwe
Copy link
Collaborator

jschwe commented Mar 25, 2022

Thanks for the PR. I see you also touched gen_cmake/target.rs. If possible, could you also add the same changes (basically add the include_platform_libs switch) to the experimental generator in at cmake/CorrosionGenerator.cmake? Should be this function: https://github.com/corrosion-rs/corrosion/blob/master/cmake/CorrosionGenerator.cmake#L25

@arkkors
Copy link
Contributor Author

arkkors commented Mar 25, 2022

Here you go. Not very pretty, but it works.

@jschwe jschwe merged commit 3b2f040 into corrosion-rs:master Mar 27, 2022
@arkkors arkkors deleted the nostd-support branch March 27, 2022 20:29
jschwe added a commit to jschwe/corrosion that referenced this pull request Mar 10, 2023
This variable was introduced in corrosion-rs#154.
Since then we have unified how default
libraries are added to the linker line,
and the legacy generator does not have
this option anymore.
So this unused variable can be safely removed.
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.

Support #[no_std] crates
3 participants