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

fix no_std #127

Merged
merged 4 commits into from Apr 4, 2019
Merged

fix no_std #127

merged 4 commits into from Apr 4, 2019

Conversation

evq
Copy link
Contributor

@evq evq commented Mar 20, 2019

fixes #125

@Ogeon
Copy link
Owner

Ogeon commented Mar 20, 2019

Cool, thank you for this! Is libm in a state where it can be used for the things we need now? That would be excellent! If this is all that's needed, it's definitely approved once the tests pass.

As for the test results, that overflow seems strange. I hope it's not something too nasty... Otherwise, I guess they had to tweak some inference rules since last time it ran.

@evq
Copy link
Contributor Author

evq commented Mar 25, 2019

hey @Ogeon - looks like the overflow is due to the longstanding issue rust-lang/libm#4 which was previously discussed in #110. so to your question - I suppose libm is not yet fixed.

that libm issue is very interesting - it appears the overflow is intentional however it does not use Wrapping or wrapped_add and as such panics only in debug mode. meaning release mode is perfectly functional.

IMO having working no_std support with the caveat that there may be occasional spurious failures in debug mode far outweighs not having no_std support at all (current state). What are your thoughts on updating the documentation to highlight this caveat and move forward without waiting on libm?

@Ogeon
Copy link
Owner

Ogeon commented Mar 25, 2019

Ah, that one. I more or less agree with you, but it requires a workaround that will also work for the tests. I'm not a fan of the thought of disabling overflow checks for the whole library, for example, but maybe that's what we have to do... We can't wait for libm to move if we want this within a foreseeable future, so unless a better alternative has appeared since last time i checked, we have to do what we can with what we have.

@@ -391,7 +391,7 @@ where
/// 0.7353569830524495,
/// 0.5370987304831942,
/// ];
/// let hsv = Bgr::from_raw_slice(&buffer)[1].into();
/// let hsv: Hsv<palette::encoding::Srgb, _> = Bgr::from_raw_slice(&buffer)[1].into();
Copy link
Owner

@Ogeon Ogeon Mar 25, 2019

Choose a reason for hiding this comment

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

Wasn't just Hsv enough? Srgb should be the default. Or was Srgb what it couldn't infer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah strangely enough, just Hsv didn't seem to be enough :(

Copy link
Owner

Choose a reason for hiding this comment

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

That's odd. Oh well. In that case can you add Srgb to the import at the top of the example? That would make this part a bit less noisy... I don't know if you tried it, but you may be able to skip the _ at least, unless I'm forgetting something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would conflict with palette::Srgb imported above - do you have a preferred alias for the Srgb encoding? (e.g. eSrgb or similar?)

I have tried without the _ and that doesn't seem to be enough.

Copy link
Owner

Choose a reason for hiding this comment

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

Ugh, good job on me for not reading it all. It's also f64, not the default f32, so that's probably why _ has to be there.

Uhm... I usually prefer to spell it out if I can... You could put a self in the encoding import and at least shorten it down to encoding::Srgb, I guess. :) If that makes a difference. I'm just trying to put the focus on the right hand expression, but it's not that important.

Copy link
Owner

Choose a reason for hiding this comment

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

Oh, you can create an alias like type Hsv64 = Hsv<encoding::Srgb, f64>;!

@evq
Copy link
Contributor Author

evq commented Mar 25, 2019

What do you think about creating multiple travis jobs? One runs tests with std as a required feature and the other runs tests with --release and would not have std as a required feature.

@Ogeon
Copy link
Owner

Ogeon commented Mar 25, 2019

There's one script (test_features.sh) that runs all the features one by one. I suppose that one can run with --release instead. Then it will test with both in the same job. It's just too bad it's going to increase the build time, but let's try and see how big the impact is.

@evq
Copy link
Contributor Author

evq commented Mar 25, 2019

If we only run with --release we might miss other overflow checks though. If we create two travis jobs they can run in parallel so we can both get overflow checks except for no_std and test no_std.

@Ogeon
Copy link
Owner

Ogeon commented Mar 25, 2019

I don't think it's going to be a problem, really. If you look at https://github.com/Ogeon/palette/blob/master/.travis.yml, it starts out by compiling and running with the default features. Then it runs the script and most of that script runs with std disabled. That's why we would not lose much on changing the script to run with --release. The alternative could be to change the script to run everything with std enabled, and then run a final test pass with everything disabled and --release enabled.

@Ogeon Ogeon closed this Mar 25, 2019
@Ogeon
Copy link
Owner

Ogeon commented Mar 25, 2019

Also, I'm afraid we may be maxing out on parallel runners already, so I don't think we will save any time on that unless they increased the limit.

@Ogeon Ogeon reopened this Mar 25, 2019
@Ogeon
Copy link
Owner

Ogeon commented Mar 25, 2019

Sorry, I accidentally clicked the close and comment button.

@evq
Copy link
Contributor Author

evq commented Mar 25, 2019

Ah gotcha! So we'd hit the default features in debug mode and individual features in release mode. That sounds good to me - will adjust

@Ogeon
Copy link
Owner

Ogeon commented Mar 25, 2019

I think that will cover enough of the cases to give a good enough result. The optional features are mostly just utilities.

@evq
Copy link
Contributor Author

evq commented Apr 4, 2019

@Ogeon I think this should be good to go now

@Ogeon
Copy link
Owner

Ogeon commented Apr 4, 2019

Nice! I didn't have the time to check it until now, but it looks good! I'll try to get a release out this weekend. I would just like to check if the rest of the code is in a good state first.

@Ogeon
Copy link
Owner

Ogeon commented Apr 4, 2019

bors: r+

bors bot added a commit that referenced this pull request Apr 4, 2019
127: fix no_std r=Ogeon a=evq

fixes #125

Co-authored-by: eV <ev@7pr.xyz>
@Ogeon
Copy link
Owner

Ogeon commented Apr 4, 2019

Oh, and once again, thanks for the help!

@bors
Copy link
Contributor

bors bot commented Apr 4, 2019

Build succeeded

@bors bors bot merged commit eacbf37 into Ogeon:master Apr 4, 2019
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.

no_std support is broken
2 participants