Skip to content

mmap() wrapper in std.os.linux has bitness-related portability issues that should be fairly straightforward to fix #22464

Open
@Validark

Description

Zig Version

0.14.0-dev.2628+5b5c60f43

Steps to Reproduce and Observed Behavior

git clone https://github.com/coolaj86/uuidv7.git
cd uuidv7
chmod +x ./build.sh
./build.sh

(build.sh can be found here)

On AJ's M2 macbook, it gives these errors for these targets:

mips64-linux-gnuabin32
/Users/aj/.local/opt/zig-v0.14.0-dev.2628+5b5c60f43/lib/std/os/linux.zig:928:13: error: expected type 'usize', found 'u64'
/Users/aj/.local/opt/zig-v0.14.0-dev.2628+5b5c60f43/lib/std/os/linux.zig:928:13: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values
/Users/aj/.local/opt/zig-v0.14.0-dev.2628+5b5c60f43/lib/std/os/linux/mips64.zig:135:11: note: parameter type declared here

mips64el-linux-gnuabin32
/Users/aj/.local/opt/zig-v0.14.0-dev.2628+5b5c60f43/lib/std/os/linux.zig:928:13: error: expected type 'usize', found 'u64'
/Users/aj/.local/opt/zig-v0.14.0-dev.2628+5b5c60f43/lib/std/os/linux.zig:928:13: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values
/Users/aj/.local/opt/zig-v0.14.0-dev.2628+5b5c60f43/lib/std/os/linux/mips64.zig:135:11: note: parameter type declared

x86_64-linux-gnux32
/Users/aj/.local/opt/zig-v0.14.0-dev.2628+5b5c60f43/lib/std/os/linux.zig:928:13: error: expected type 'usize', found 'u64'
/Users/aj/.local/opt/zig-v0.14.0-dev.2628+5b5c60f43/lib/std/os/linux.zig:928:13: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values
/Users/aj/.local/opt/zig-v0.14.0-dev.2628+5b5c60f43/lib/std/os/linux/x86_64.zig:88:11: note: parameter type declared here

However, on my Zen 5 x86_64 machine, running the same bash script does not give these errors.

(there are also some RISC-V errors on both machines that I talked to Sinon about getting fixed)

AJ's machine has these characteristics:

uname -srm
Darwin 23.6.0 arm64

AJ thought maybe the clang or LLVM version might have something to do with it, but I'd be surprised if the usize comes from one of those. But here is the clang info:

clang --version
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Expected Behavior

no errors, usize should be u64 so the syscall definitions should match just fine

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions