seanmonstar / httparse

A push parser for the HTTP 1.x protocol in Rust.
https://docs.rs/httparse
Apache License 2.0
585 stars 114 forks source link

Build broken on 1.27.0 with target `i686-linux-android` #42

Closed thomcc closed 6 years ago

thomcc commented 6 years ago

The specific error I get is "error[E0425]: cannot find function _tzcnt_u64 in this scope". I assume this is because it's a 32 bit platform but it could be something else.

seanmonstar commented 6 years ago

Welp, yep, that's busted. The AVX2 function is configured to exist on both x86 and x86_64, but _tzcnt_u64 doesn't exist in std::arch::x86!

thomcc commented 6 years ago

Is that a bug in the stdlib? I think both should just be the tzcnt instruction, if you support one you should support the other.

seanmonstar commented 6 years ago

I don't know if it's a bug in libstd or not... There does appear to be std::arc::x86::_tzcnt_u32, which I assume is the same operation, and both just actually use a word?

thomcc commented 6 years ago

The actual instruction is overloaded on what you pass it (sort of, it will be encoded differently). See https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=tzcnt&expand=5536,5535 where the instruction is tzcnt r64, r64 vs tzcnt r32, r32.

I don't think any chips exist that are actually 32 bit and support these instructions though, so IDK how it would work on them.

seanmonstar commented 6 years ago

Instead of hastily swapping to _tzcnt_u32 or something without considering the consequences, I've pushed #43 that just disables AVX2 usage on x86. Is it possible to adjust your Cargo.toml to point at that to see if it fixes it?

thomcc commented 6 years ago

Yep, that fixes it.

seanmonstar commented 6 years ago

Alright, published v1.3.1! Thanks for reporting this.

iximeow commented 3 years ago

judging by the 0xffffffff_00000000 mask used with _tzcnt_u64 i think it could be removed and _tzcnt_u32 used on both architectures. there's a corner case for processors that do not support BMI1 where the same instruction bytes instead mean BSF (with slightly different behavior on a 0 operand)

i'll try this out, see if tests pass, kick the tires etc and put up a PR for that. AVX2 can be used on x86 targets by using a 32-bit OS on modern processors, for example, so this is plausibly (if unlikely) reachable.