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

fixes to 32-bit handling, to support 32-bit arm #4870

Merged
merged 1 commit into from
Mar 31, 2020
Merged

fixes to 32-bit handling, to support 32-bit arm #4870

merged 1 commit into from
Mar 31, 2020

Conversation

andrewrk
Copy link
Member

With these changes, I was able to use ziglang/bootstrap to cross-compile an arm-linux-musleabihf tarball.

@@ -811,7 +815,7 @@ pub const NativeTargetInfo = struct {
}

fn preadMin(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usize {
var i: u64 = 0;
var i: usize = 0;

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

This fn is allowed to return short reads. i is just an offset, which is relative to min_read_len. usize was the correct type all along.

const rpoff_usize = std.math.cast(usize, rpoff) catch |err| switch (err) {
error.Overflow => return error.InvalidElfFile,
};
const rpath_list = mem.spanZ(@ptrCast([*:0]u8, strtab[rpoff_usize..].ptr));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this was strtab[rpoff_usize..:0]. could we remove the @ptrCast? (and TODO above)

@@ -645,7 +646,7 @@ pub const NativeTargetInfo = struct {
{
var dyn_off = elfInt(is_64, need_bswap, ph32.p_offset, ph64.p_offset);
const p_filesz = elfInt(is_64, need_bswap, ph32.p_filesz, ph64.p_filesz);
const dyn_size: u64 = if (is_64) @sizeOf(elf.Elf64_Dyn) else @sizeOf(elf.Elf32_Dyn);
const dyn_size: usize = if (is_64) @sizeOf(elf.Elf64_Dyn) else @sizeOf(elf.Elf32_Dyn);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does peer-type resolution not work here? (i.e. omit the type?)

Copy link
Member Author

Choose a reason for hiding this comment

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

is_64 is runtime known, so it hits #137

Copy link
Contributor

Choose a reason for hiding this comment

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

oh interesting. I thought @sizeOf would return a comptime-known usize rather than a comptime_int

@andrewrk andrewrk merged commit 839d85e into master Mar 31, 2020
@andrewrk andrewrk deleted the arm32 branch April 15, 2020 21:13
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.

2 participants