-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Compiling hyper 0.12 on armv7-linux-androideabi with target-features=+neon fails with LLVM ERROR: ran out of registers during register allocation #55105
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Can reproduce this locally.
Rustc version:
|
(This is blocking the Hyper upgrade in Servo.) |
I've traced down the bug to originate from the |
This gives us this self-contained example: pub struct Header<'a> {
pub name: &'a [u8],
pub value: &'a [u8],
}
pub struct HeaderIndices {
name: (usize, usize),
value: (usize, usize),
}
pub fn record_header_indices(bytes: &[u8], headers: &[Header], indices: &mut [HeaderIndices]) {
let bytes_ptr = bytes.as_ptr() as usize;
for (header, indices) in headers.iter().zip(indices.iter_mut()) {
let name_start = header.name.as_ptr() as usize - bytes_ptr;
let name_end = name_start + header.name.len();
indices.name = (name_start, name_end);
let value_start = header.value.as_ptr() as usize - bytes_ptr;
let value_end = value_start + header.value.len();
indices.value = (value_start, value_end);
}
} Compiled with the same invocation as above. For a workaround, splitting up the loop seems to have fixed the bug: pub fn record_header_indices(bytes: &[u8], headers: &[Header], indices: &mut [HeaderIndices]) {
let bytes_ptr = bytes.as_ptr() as usize;
for (header, indices) in headers.iter().zip(indices.iter_mut()) {
let name_start = header.name.as_ptr() as usize - bytes_ptr;
let name_end = name_start + header.name.len();
indices.name = (name_start, name_end);
}
for (header, indices) in headers.iter().zip(indices.iter_mut()) {
let value_start = header.value.as_ptr() as usize - bytes_ptr;
let value_end = value_start + header.value.len();
indices.value = (value_start, value_end);
}
} |
I've tried to make a C version that reproduces this, but failed. This is a Rust version very close to C that reproduces the bug: pub struct Header {
pub name: * const u8,
pub name_len: usize,
pub value: * const u8,
pub value_len: usize,
}
pub struct HeaderIndices {
name_a :usize,
name_b: usize,
value_a: usize,
value_b: usize,
}
pub fn record_header_indices(bytes_ptr: usize, headers: * const Header, indices: *mut HeaderIndices, len: isize) {
for i in 0 .. len {
let mut indices = unsafe { &mut *indices.offset(i) };
let header = unsafe { &*headers.offset(i) };
let name_start = header.name as usize - bytes_ptr;
let name_end = name_start + header.name_len;
indices.name_a = name_start;
indices.name_b = name_end;
let value_start = header.value as usize - bytes_ptr;
let value_end = value_start + header.value_len;
indices.value_a = value_start;
indices.value_b = value_end;
}
} But this C version doesn't (clang invocation was typedef unsigned __INT32_TYPE__ size_t;
typedef struct header {
char *name;
size_t name_len;
char *val;
size_t val_len;
} header;
typedef struct header_indices {
size_t name_a;
size_t name_b;
size_t val_a;
size_t val_b;
} header_indices;
void record_header_indices(size_t bytes_ptr, const header *headers, header_indices *indices, size_t len) {
for (size_t i = 0; i < len; i++) {
header_indices *idxs = &indices[i];
const header *hdr = &headers[i];
size_t name_start = ((size_t)hdr->name) - bytes_ptr;
size_t name_end = name_start + hdr->name_len;
idxs->name_a = name_start;
idxs->name_b = name_end;
size_t val_start = ((size_t)hdr->val) - bytes_ptr;
size_t val_end = name_start + hdr->val_len;
idxs->val_a = name_start;
idxs->val_b = name_end;
}
} |
Here's the output of emit=llvm-ir
|
rustc issue: rust-lang/rust#55105 Steps to reproduce: ``` rustup target add armv7-linux-androideabi RUSTFLAGS="-Ctarget-feature=+neon" cargo build --target armv7-linux-androideabi --release ``` Output without this change: ``` Compiling hyper v0.12.11 (/home/simon/projects/servo-deps/hyper) LLVM ERROR: ran out of registers during register allocation error: Could not compile `hyper`. ```
Thanks @est31 for reducing and finding a work-around! I’ve filed it at hyperium/hyper#1671 |
…levant targets rustc issue: rust-lang/rust#55105 Steps to reproduce: ``` rustup target add armv7-linux-androideabi RUSTFLAGS="-Ctarget-feature=+neon" cargo build --target armv7-linux-androideabi --release ``` Output without this change: ``` Compiling hyper v0.12.11 (/home/simon/projects/servo-deps/hyper) LLVM ERROR: ran out of registers during register allocation error: Could not compile `hyper`. ```
WIP: Update hyper to 0.12 Left to do: - servo/webrender#3034 - servo/hyper_serde#20 - rust-lang/rust#55105 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21644) <!-- Reviewable:end -->
…M bug rustc issue: rust-lang/rust#55105 Steps to reproduce: ``` rustup target add armv7-linux-androideabi RUSTFLAGS="-Ctarget-feature=+neon" cargo build --target armv7-linux-androideabi --release ``` Output without this change: ``` Compiling hyper v0.12.11 (/home/simon/projects/servo-deps/hyper) LLVM ERROR: ran out of registers during register allocation error: Could not compile `hyper`. ```
WIP: Update hyper to 0.12 Left to do: - servo/webrender#3034 - servo/hyper_serde#20 - rust-lang/rust#55105 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21644) <!-- Reviewable:end -->
WIP: Update hyper to 0.12 Left to do: - servo/webrender#3034 - servo/hyper_serde#20 - rust-lang/rust#55105 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21644) <!-- Reviewable:end -->
WIP: Update hyper to 0.12 Left to do: - servo/webrender#3034 - servo/hyper_serde#20 - rust-lang/rust#55105 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21644) <!-- Reviewable:end -->
Just a nudge that this should probably be triaged or labeled, as it's a bug in the LLVM output of the compiler. Once fixed, hyper can remove its workaround that split the loop into two loops. |
Have you tried with target-feature=-d16, neon isn't supported with only 16 registers. |
|
So should that be automatically assumed this target? I'd prefer to remove the hack from hyper. |
IIUC hyper didn't build because of user error (using |
This error went away for me this week, but I'm not sure why. I did apply some system updates (kubuntu 19.10) so perhaps clang fixed this upstream? I am able to use
Edit: We do depend on reqwest/hyper |
The text was updated successfully, but these errors were encountered: