Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up[On Hold] Add support for builds without assembly. #256
Conversation
This comment has been minimized.
This comment has been minimized.
|
See #199, in particular this comment for more background on this. One thing different from there is I left the digest module in for no_asm builds. It occurs in too many places, and since it will be fixed imminently by #199, didn't seem worth trying to be clever. |
samscott89
force-pushed the
samscott89:no_asm
branch
4 times, most recently
Jul 20, 2016
This comment has been minimized.
This comment has been minimized.
coveralls
commented
Jul 20, 2016
•
|
Coverage decreased (-0.5%) to 88.355% when pulling b7570c6cfc84ea074b0d758cd0108d5d7af471bb on samscott89:no_asm into 2c3a95e on briansmith:master. |
samscott89
force-pushed the
samscott89:no_asm
branch
2 times, most recently
to
ef27d50
Jul 20, 2016
This comment has been minimized.
This comment has been minimized.
coveralls
commented
Jul 20, 2016
•
This comment has been minimized.
This comment has been minimized.
coveralls
commented
Jul 21, 2016
•
This comment has been minimized.
This comment has been minimized.
coveralls
commented
Jul 21, 2016
•
This comment has been minimized.
This comment has been minimized.
|
This looks great. It will be at least a couple of days before I can get to this review. |
samscott89
force-pushed the
samscott89:no_asm
branch
from
ef27d50
Jul 25, 2016
This comment has been minimized.
This comment has been minimized.
coveralls
commented
Jul 25, 2016
•
|
Coverage decreased (-0.001%) to 89.924% when pulling 4ac34e8b85631bb906c937317edfe45346913019 on samscott89:no_asm into 08c729e on briansmith:master. |
briansmith
reviewed
Jul 27, 2016
View changes
| block_data_order: unsafe extern fn(state: &mut [u64; MAX_CHAINING_LEN / 8], data: *const u8, | ||
| num: c::size_t), | ||
| #[cfg(feature="no_asm")] | ||
| block_data_order: unsafe fn(state: &mut [u64; MAX_CHAINING_LEN / 8], data: *const u8, |
This comment has been minimized.
This comment has been minimized.
briansmith
Jul 27, 2016
Owner
In the no_asm case, we could actually make block_data_order a normal, non-unsafe function, right? In the SHA-1 code, we could skip over the unsafe -> safe adapter function, for example.
briansmith
reviewed
Jul 27, 2016
View changes
|
|
||
| #[cfg(feature="no_asm")] | ||
| unsafe fn sha512_block_data_order(_: &mut [u64; MAX_CHAINING_LEN / 8], _: *const u8, _: c::size_t){ | ||
| unimplemented!(); |
This comment has been minimized.
This comment has been minimized.
briansmith
Jul 27, 2016
Owner
Let's drop these definitions that call unimplemented!(). I'll keep this commit separate from the one that adds the Rust implementations of these functions, but I'll land them together. I'd rather have unbuilding code in the intermediate state between those two commits than building-but-broken code.
briansmith
reviewed
Jul 27, 2016
View changes
| num: c::size_t) { | ||
| let data = data as *const [u8; BLOCK_LEN]; | ||
| let blocks = core::slice::from_raw_parts(data, num); | ||
| block_data_order_safe(state, blocks) |
This comment has been minimized.
This comment has been minimized.
briansmith
Jul 27, 2016
Owner
What I mean by my comment above is that we should make it so that in the no_asm mode, block_data_order_safe is used as the block_data_order function. But, I can see now that that requires additional effort, so we can defer that to a later commit.
This comment has been minimized.
This comment has been minimized.
|
This all looks good to me. I'll land it when the Rust SHA-2 code is landed. |
This comment has been minimized.
This comment has been minimized.
|
One question: You chose little-endian just because there's places where we have little-endian logic and no big-endian counterpart, right? Or, was there some other reason? |
This comment has been minimized.
This comment has been minimized.
Correct. Although since the
Wouldn't be a huge amount of additional work. The main reason I opted to keep it marked as unsafe was to be compatible with the |
samscott89
force-pushed the
samscott89:no_asm
branch
3 times, most recently
Jul 27, 2016
This comment has been minimized.
This comment has been minimized.
|
Ok, made the suggested changes. I re-factored |
samscott89
force-pushed the
samscott89:no_asm
branch
2 times, most recently
Jul 27, 2016
This comment has been minimized.
This comment has been minimized.
coveralls
commented
Jul 27, 2016
•
|
Coverage decreased (-0.3%) to 89.634% when pulling 80994ddffac0f189a92e362ec273ffbb23ed11a0 on samscott89:no_asm into f87e2e8 on briansmith:master. |
This comment has been minimized.
This comment has been minimized.
coveralls
commented
Jul 27, 2016
•
|
Coverage decreased (-0.3%) to 89.634% when pulling 80994ddffac0f189a92e362ec273ffbb23ed11a0 on samscott89:no_asm into f87e2e8 on briansmith:master. |
This comment has been minimized.
This comment has been minimized.
coveralls
commented
Jul 27, 2016
•
|
Coverage decreased (-0.3%) to 89.634% when pulling 80994ddffac0f189a92e362ec273ffbb23ed11a0 on samscott89:no_asm into f87e2e8 on briansmith:master. |
This comment has been minimized.
This comment has been minimized.
There's a slight distinction with Unless of course the crate itself allows you to specify not to use As it is, the minority cases which require Target/platform specific builds does sound like a tempting option and would probably help to catch most of the unsatisfactory cases above. Whether it captures everything depends on whether |
This comment has been minimized.
This comment has been minimized.
|
The simple fact of the matter is that Cargo features that reduce API surface when enabled break Cargo. The two solutions are to make it increase API surface instead ( After all, if the crate you depend on that needs the assembly does so because of the API it causes to be exposed, disabling it will cause spooky build failures at a distance. This is, I think, kind of unacceptable. As a user, I would consider that a huge mark against using this crate - it does not cooperate well with the ecosystem. Such build failures would be attributed to other, downstream crates, not to ring, and would cause nontrivial work for those having to deal with them. |
This comment has been minimized.
This comment has been minimized.
Keep in mind that the long-term goal is API parity but we'll need to deal with interim states where we don't have API parity.
No library crate should be using the Here are the requirements, as I see them: I have a feeling that there's not a 100% perfect and we'll have to make compromises. I'm open to considering any solution that has a solution that meets the above requirements. |
This comment has been minimized.
This comment has been minimized.
Yes. Specifically, library
These are covered by making it a default feature.
This is covered by opting out of default features. Note that trying to build a In particular, Either platform-dependent features or scenarios would further improve the situation, allowing Cargo to error out up-front, before building anything. However, those only work with
This either requires that even in the |
briansmith
changed the title
Add support for bulids without assembly.
Add support for builds without assembly.
Sep 8, 2016
This comment has been minimized.
This comment has been minimized.
Thanks. The problem that causes this is that ring doesn't expose its entire API in There is a serious problem with defining an "asm" feature and then having people who don't want asm code to use So, I feel comfortable right now with the following plan:
Obviously this isn't ideal but the problem is that "asm" vs "no-asm" isn't really a feature choice, but the feature mechanism only way we have to control how ring is built. |
This comment has been minimized.
This comment has been minimized.
|
Er, I think you misunderstand what I meant regarding It's not something you build with, it's a dependency constraint you opt out of in Cargo.toml. An example from the Cargo docs: [dependencies.awesome]
version = "1.3.5"
default-features = false # do not include the default features, and optionally
# cherry-pick individual features
features = ["secure-password", "civet"]As a result, your reasoning in that entire second paragraph is erroneous. If any dependent does not opt-out of ring's default features (because it's per-dependency) in its own Cargo.toml, then Similarly, if any dependent enables All it takes is one crate pulled in arbitrarily deep in the dependency graph enabling the "experimental" To build on the example I gave before:
At this point, Even if someone patched them to only use Moreover, the user has to already know ring is at fault in order to even start looking for It's poor citizenship. |
This comment has been minimized.
This comment has been minimized.
|
I see you understand what I meant regarding If some crate enables the no-asm feature then that's an unsupported configuration and so I don't care what happens in that situation. If there's an alternative besides using feature flags for doing this, I'd love to use it. We need to find a solution that doesn't cause
Increase your level of politeness, please. |
This comment has been minimized.
This comment has been minimized.
|
I'm sorry; I didn't intend the "poor citizenship" comment as impoliteness - I see it as meaningfully descriptive. The reason is that the burden and cost of non-root crates enabling It creates a negative externality - ring behaving in a manner counter to Cargo best-practices then makes more work for other people, and not even the ones who chose to do something unsupported. Instead, it places the burden on people who use ring perfectly as intended.
In that context, the above statement then does parse as "I'm unconcerned with causing negative externalities in the greater Cargo ecosystem" - something that, to me, is the literal definition of "poor citizenship." |
This comment has been minimized.
This comment has been minimized.
|
Please suggest a better alternative considering the constraints I gave above. Right now there doesn't seem to be a better alternative. What you've suggested so far is worse insofar as I understand it. People accidentally misusing the no_asm feature isn't worth worrying about. They could easily name a |
This comment has been minimized.
This comment has been minimized.
|
I'm actually curious as to why The fact is, the cases in which one is unsuitable are strongly correlated with the cases where neither is suitable - unsupported platforms and constrained environments. Moreover, opting out of default features doesn't mean the dependent crate can't then re-enable some subset of the defaults. For example, a crate that runs in a no-allocation context on a supported architecture might do this: [dependencies.ring]
default-features = false
features = ["asm"]Similarly, a crate that wants to do RSA on an unsupported platform could do this: [dependencies.ring]
default-features = false
features = ["use_heap"]This is the exact model used by pretty much all crates that support both |
This comment has been minimized.
This comment has been minimized.
|
@eternaleye, running with your previous example since it's a more concrete way to discuss these implications. It would be expected that none of However, suppose none of these crates strictly require On the other hand, in the |
This comment has been minimized.
This comment has been minimized.
This seems to be to be the most pragmatic way forwards. In particular, the second bullet point seems to address @eternaleye's main complaint. I can put together a proof of concept, but presumably the build would fail with an Hopefully cargo will support target-specific features at some point (@eternaleye mentioned them earlier in this thread) so we can enforce |
This comment has been minimized.
This comment has been minimized.
|
One problem with this approach is running tests. Since Then, the only other place Probably best to change the semantics in this case. Perhaps |
samscott89
force-pushed the
samscott89:no_asm
branch
2 times, most recently
Sep 9, 2016
This comment has been minimized.
This comment has been minimized.
|
Ok, so I've made a new commit based on the above. This instead adds a feature Running Enabling |
samscott89
force-pushed the
samscott89:no_asm
branch
to
af39228
Sep 9, 2016
This comment has been minimized.
This comment has been minimized.
This is incorrect. Any crate can opt out of the default features of individual dependencies, separately. That does explain all the other confusion, though. Basically, Essentially, Combined with Cargo features being additive, this results in features only being enabled if things actually need them. @samscott89 Basically, |
This comment has been minimized.
This comment has been minimized.
|
That was my understanding, not necessarily shared by @briansmith.
Sorry, to be clearer I meant the
Let's say |
This comment has been minimized.
This comment has been minimized.
|
@samscott89: Yes, and this is the exact same situation as Platform specific features, which I linked to, or scenarios, which I also linked to, would improve the situation when implemented. In addition, there's a strong sentiment against link time errors in the rust community, because they generally are unreadable. They also mean that a lot of stuff gets built uselessly, wasting the developer's time. |
This comment has been minimized.
This comment has been minimized.
To help me understand: why is |
This comment has been minimized.
This comment has been minimized.
|
I'm speaking specifically of the case where, depending on a feature flag, a crate may or may not use code from This is, in fact, exactly how the RSA code that requires allocation works in ring today. The situation matches because, just like ring's assembly code doesn't support some platforms, there are platforms not supported by all of The The It also is useless for assembly-lacking platforms in the middle period, where not everything has been ported. |
eternaleye
referenced this pull request
Oct 14, 2016
Closed
Use opt-in features instead of opt-out #8
This comment has been minimized.
This comment has been minimized.
|
To follow up on this: The concerns @eternaleye mentioned are valid but unfortunately Rust simply doesn't give us any features we need to do what @eternaleye suggests and still make progress in a useful way. So I'm perfectly happy to take a PR like this and do things the imperfect way until the Rust developers enable us to do things the perfect way. However, I already hate all the |
briansmith
changed the title
Add support for builds without assembly.
[On Hold] Add support for builds without assembly.
Nov 24, 2016
This comment has been minimized.
This comment has been minimized.
|
Thanks for submitting this, long ago. Now is a good time for us to add support for builds without assembly but the code has diverged so much I think it isn't practical to rebase is PR on the current tree, so I'm going to close this. |
samscott89 commentedJul 20, 2016
Set feature "no_asm" to use. This currently disables use of
aead, ec, and rsa/signature modules due to missing code.
Also adds the mipsel-unknown-linux-gnu target to the travis
builds. These builds currently fail in anticipation of PR#199.