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

cannot use l (variable of type int) as uintptr value in assignment #18

Open
gggrafff opened this issue Dec 8, 2023 · 3 comments
Open

Comments

@gggrafff
Copy link
Contributor

gggrafff commented Dec 8, 2023

Hello!
I'm trying to compile encoding+deconidng code to wasi targert with tinygo 0.30.0 and have the following errors:

$ make
tinygo build -o main.wasm -target ./target.json -opt=2 -gc=precise .
# github.com/kelindar/binary
../../../../go/pkg/mod/github.com/kelindar/binary@v1.0.18/convert.go:24:19: cannot use l (variable of type int) as uintptr value in assignment
../../../../go/pkg/mod/github.com/kelindar/binary@v1.0.18/convert.go:25:19: cannot use l (variable of type int) as uintptr value in assignment
make: *** [Makefile:17: main.wasm] Error 1

My target.json:

{
    "inherits": [ "wasi" ],
    "ldflags": [
        "--initial-memory=2097152",
        "--max-memory=67108864",
        "-zstack-size=65536"
    ]
}

It looks like an easy problem, let's fix it :-)

@gggrafff
Copy link
Contributor Author

gggrafff commented Dec 8, 2023

Oh, I took a closer look, probably this is a tinygo problem, because their SliceHeader implementation differs from the standard one
But if you have an idea how to make a portable code, please let me know

tinygo-org/tinygo#3372
tinygo-org/tinygo#1284
tinygo-org/tinygo-site#346

UPD:
It looks like unsafe.Slice is more portable option of unsafe.SliceHeader. Maybe we can use it?

@kelindar
Copy link
Owner

kelindar commented Dec 8, 2023

Sounds great, feel free to submit a PR 🙏🏻

@gggrafff
Copy link
Contributor Author

gggrafff commented Dec 8, 2023

Which version of golang you are using?
unsafe.Slice is a new feature, if your go is old, we need something like this: https://stackoverflow.com/a/59210739/12903113

UPD: I see: https://github.com/kelindar/binary/blob/3a4b1f08e35cb98743e5ce84572f3a92aca97e1c/go.mod#L3C1-L3C8

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

No branches or pull requests

2 participants