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

compile of tvintris.v failed #22122

Closed
wpeckham opened this issue Aug 27, 2024 · 11 comments
Closed

compile of tvintris.v failed #22122

wpeckham opened this issue Aug 27, 2024 · 11 comments
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor.

Comments

@wpeckham
Copy link

wpeckham commented Aug 27, 2024

V doctor:

V full version: V 0.4.7 bbbb864.05c7aa2
OS: linux, "Manjaro Linux"
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz

getwd: /home/wpeckham/.vmodules
vexe: /home/wpeckham/v/v
vexe mtime: 2024-08-27 20:23:42

vroot: OK, value: /home/wpeckham/v
VMODULES: OK, value: /home/wpeckham/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.46.0
Git vroot status: weekly.2022.24-4876-g05c7aa2c
.git/config present: true

CC version: cc (GCC) 14.2.1 20240805
thirdparty/tcc status: thirdparty-linux-amd64 a0799a5b

What did you do?
./v -g -o vdbg cmd/v && ./vdbg sdl/examples/tvintris/tvintris.v
See attached file sdl/examples/tvintris/tvintris.v

What did you expect to see?

successful compile

What did you see instead?

INFO: compile with `v -live sdl/examples/tvintris/tvintris.v `, if you want to use the @[live] function draw_begin .
================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/tvintris.01J6ASNYWK7ANJFGF8V7KP01E7.tmp.c:2696: error: ';' expected (got "sdl__OSEvent")
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@wpeckham
Copy link
Author

Note that this was the tvintris.v I found after "v install sdl".
The only outdated module is c2v.
Am I missing something?

@JalonSolov JalonSolov added Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. labels Aug 27, 2024
@JalonSolov
Copy link
Contributor

sdl and c2v don't have anything to do with each other. I have confirmed this failure.

@JalonSolov
Copy link
Contributor

$ sdl2-config --version
2.30.6
$

@medvednikov
Copy link
Member

should also be caught by ci

@larpon
Copy link
Contributor

larpon commented Aug 29, 2024

v install sdl will install a V wrapper compatible with SDL2 v2.0.8. To use vlang/sdl you need to checkout the corresponding branch that matches the SDL2 version installed on your system.

This is all documented in the README.md. We currently can not automate this process due to how v install/vpm currently works - we cannot run code/scripts after install to e.g. determine the user's setup.

If you are on a Unix based system you can run v ~/.vmodules/sdl/setup.vsh that will try to determine your system install of SDL2 and checkout the corresponding branch in vlang/sdl

@wpeckham please also note that you will highly likely need to pass -d sdl_memory_no_gc when building/running SDL2 based applications due to problems with V's garbage collector and SDL's memory allocations. (Also documented in the README.md)

Maybe vpm could support showing a user facing message from the module upon install or update that hints what to do since we cannot automate such things with vpm currently.

@JalonSolov
Copy link
Contributor

If I run the setup.vsh script to get the correct branch, it fails in a different way...

[jalon@7950x sdl]$ v run setup.vsh
Your version is 2.30.6
The SDL module officially supports these versions of SDL:
   ['2.0.8', '2.0.10', '2.0.12', '2.0.14', '2.0.16', '2.0.18', '2.0.20', '2.0.22', '2.0.9', '2.24.0', '2.26.0', '2.28.0', '2.30.0']
Setting up the repository to branch 2.30.0, that best matches the system SDL version: 2.30.6 ...
branch '2.30.0' set up to track 'origin/2.30.0'.
Switched to a new branch '2.30.0'
[jalon@7950x sdl]$ v -g run examples/tvintris/
INFO: compile with `v -live examples/tvintris/ `, if you want to use the @[live] function draw_begin .
tVintris -- tribute to venerable Twintris
76c551aec987 : at ???: RUNTIME ERROR: invalid memory access
76c551bb0daf : by ???
76c551bf3c60 : by ???
76c551bf901e : by ???
76c551b1a2d9 : by ???
76c551c11883 : by ???
76c551af0dd8 : by ???
/tmp/v_1000/../../../../../../home/jalon/git/sdl/sdl.c.v:82: by sdl__init
/tmp/v_1000/../../../../../../home/jalon/git/sdl/examples/tvintris/tvintris.v:231: by main__SdlContext_set_sdl_context
/tmp/v_1000/../../../../../../home/jalon/git/sdl/examples/tvintris/tvintris.v:294: by main__main
/tmp/v_1000/../../../../../../tmp/v_1000/tvintris.01J6F3JB7YZKMGN5XTPX0STVJ1.tmp.c:65417: by main
[jalon@7950x sdl]$

@larpon
Copy link
Contributor

larpon commented Aug 29, 2024

@JalonSolov try with -d sdl_memory_no_gc it is a know bug as I describe above.

@larpon
Copy link
Contributor

larpon commented Aug 29, 2024

We have an issue tracking it here vlang/sdl#744 (comment)

@JalonSolov
Copy link
Contributor

Yes, with that option, it works.

@wpeckham
Copy link
Author

I could find none of that in my README files here, but using those two commands does allow it to compile and run.

Thank you!

@wpeckham
Copy link
Author

This should be documented in the distributed files, but that might be considered a different issue. We can close this.
To resolve ran "v ~/.vmodules/sdl/setup.vsh"
Then compiled with the option "-d sdl_memory_no_gc"

@larpon larpon closed this as completed Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor.
Projects
None yet
Development

No branches or pull requests

4 participants