vlang / tccbin

39 stars 18 forks source link

sokol/sounds examples in V repo cannot be compiled with tcc-amd64 #18

Closed SleepyRoy closed 3 years ago

SleepyRoy commented 3 years ago

I have a vague impression that compilation used to be successful X months ago.

spaceface777 commented 3 years ago

vlang/v#8639 :)

SleepyRoy commented 3 years ago

I applied changes there, but some sokol/sounds examples still couldn't be compiled. Also I think v -cc tcc build-examples should be added to CI tcc-win. Have you ever tried it on your windows?

spaceface777 commented 3 years ago

Have you updated your local tcc installation? I pushed a commit yesterday; run .\make.bat -tcc to update it.

SleepyRoy commented 3 years ago

Yep I was using latest tcc branch. For example v -cc tcc melody.v gave very long errors and here're some parts.

C:\Users\Roy\AppData\Local\Temp\v\melody.5295414309335613677.tmp.c:15845:170: note: (near initialization for '(anonymous).stream_userdata_cb')
C:\Users\Roy\AppData\Local\Temp\v\melody.5295414309335613677.tmp.c:15860:15: warning: initialization of 'void (*)(void *)' from incompatible pointer type 'void (*)(main__AppState *)' {aka 'void (*)(struct main__AppState *)'} [-Wincompatible-pointer-types]
   .frame_fn = main__graphics_frame,
               ^~~~~~~~~~~~~~~~~~~~
C:\Users\Roy\AppData\Local\Temp\v\melody.5295414309335613677.tmp.c:15860:15: note: (near initialization for '(anonymous).frame_fn')
C:\Users\Roy\AppData\Local\Temp\v\melody.5295414309335613677.tmp.c: In function '_vinit':
C:\Users\Roy\AppData\Local\Temp\v\melody.5295414309335613677.tmp.c:16027:62: warning: passing argument 2 of 'new_map_init_2' from incompatible pointer type [-Wincompatible-pointer-types]
  _const_gx__string_colors = new_map_init_2(&map_hash_string, &map_eq_string, &map_clone_string, &map_free_string, 3, sizeof(string), sizeof(gx__Color), _MOV((string[3]){_SLIT("black"), _SLIT("blue"), _SLIT("red"), }), _MOV((gx__Color[3]){_const_gx__black, _const_gx__blue, _const_gx__red, }));
                                                              ^~~~~~~~~~~~~~
C:\Users\Roy\AppData\Local\Temp\v\melody.5295414309335613677.tmp.c:8109:47: note: expected 'MapEqFn' {aka 'int (*)(void *, void *)'} but argument is of type '_Bool (*)(void *, void *)'
 map new_map_init_2(MapHashFn hash_fn, MapEqFn key_eq_fn, MapCloneFn clone_fn, MapFreeFn free_fn, int n, int key_bytes, int value_bytes, voidptr keys, voidptr values) {
                                       ~~~~~~~~^~~~~~~~~
C:\Users\Roy\.vmodules\cache\23\2323aceb5c4f26f6f81be6689fb790d7.o: In function `stbi_zlib_decode_malloc_guesssize':
<command line>:(.text+0xccde): undefined reference to `__chkstk'
C:\Users\Roy\.vmodules\cache\23\2323aceb5c4f26f6f81be6689fb790d7.o: In function `stbi_zlib_decode_malloc_guesssize_headerflag':
<command line>:(.text+0xce2c): undefined reference to `__chkstk'
C:\Users\Roy\.vmodules\cache\23\2323aceb5c4f26f6f81be6689fb790d7.o: In function `stbi_zlib_decode_buffer':
<command line>:(.text+0xcf38): undefined reference to `__chkstk'
C:\Users\Roy\.vmodules\cache\23\2323aceb5c4f26f6f81be6689fb790d7.o: In function `stbi_zlib_decode_noheader_malloc':
<command line>:(.text+0xcfd4): undefined reference to `__chkstk'
C:\Users\Roy\.vmodules\cache\23\2323aceb5c4f26f6f81be6689fb790d7.o: In function `stbi_zlib_decode_noheader_buffer':
<command line>:(.text+0xd0e4): undefined reference to `__chkstk'
C:\Users\Roy\.vmodules\cache\23\2323aceb5c4f26f6f81be6689fb790d7.o:<command line>:(.text+0x17b45): more undefined references to `__chkstk' follow
C:/OtherProgram/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OtherProgram\vlang\examples\sokol\sounds\melody.exe(.pdata): relocation ".uw_base+0x0 (type R_X86_64_RELATIVE)" goes out of range
C:/OtherProgram/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: Symbol needs debug section which does not exist
collect2.exe: error: ld returned 1 exit status
builder error:
==================
C error. This should never happen.

I found it quite strange because it was somehow using mingw64. So I wanted to "hide" my mingw64 and renamed it. Then I simply got

C compilation failed.
builder error: exec failed (CreateProcess) with code 2: 系统找不到指定的文件。(Translation: couldn't find intended files)
 cmd: gcc "@C:\Users\Roy\AppData\Local\Temp\v\melody.14326360450439642725.tmp.c.rsp"

still had strange relation with gcc.

This issue only applies to sokol/sounds examples, not all sokol examples.

SleepyRoy commented 3 years ago

BTW v -cc gcc sokol/sounds examples just worked nicely.

spaceface777 commented 3 years ago

could you try again? I've pushed another fix.

SleepyRoy commented 3 years ago

Good work! It's fixed.