Closed raysan5 closed 6 years ago
I was curious and ran CC=tcc cmake
on my Ubuntu VM. The compiler crashed compiling src/rlgl.c
:
$ tail -n1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"
$ tcc -v
tcc version 0.9.26 (x86-64 Linux)
$ tcc -DGRAPHICS_API_OPENGL_33 -c src/rlgl.c
tcc: x86_64-gen.c:421: load: Assertion `((ft & 0x000f) == 0) || ((ft & 0x000f) == 12) || ((ft & 0x000f) == 4) || ((ft & 0x000f) == 5) || ((ft & 0x000f) == 6)' failed.
Aborted (core dumped)
creduce(1)
reduced it to this snippet that reliably crashes my tcc
:
typedef struct {
y;
float z;
} Vector3;
fn1() {
(Vector3) {
0.0f, (Vector3) {}
If someone's interested in tackling this, please check whether this bug still persists with current tcc
and report it to their mailing list if it does. Thanks!
Also tried compiling raylib on Windows (Win10, 64bit) with latest version (0.9.27
) and using include/libs from main repo: http://repo.or.cz/w/tinycc.git
And I get several compilation errors:
> Compile raylib modules
------------------------------
tcc -c core.c -DPLATFORM_DESKTOP -Iexternal/glfw/include
Process started >>>
c:/raylib/tcc/include/math.h:217: error: unknown constraint 't'
<<< Process finished. (Exit code 1)
tcc -c rglfw.c -std=c99 -Wall -Iexternal/glfw/deps/mingw
Process started >>>
In file included from rglfw.c:52:
In file included from external/glfw/src/context.c:28:
In file included from external/glfw/src/internal.h:186:
In file included from external/glfw/src/win32_platform.h:66:
external/glfw/deps/mingw/dinput.h:23: error: include file 'objbase.h' not found
<<< Process finished. (Exit code 1)
tcc -c rlgl.c -std=c99 -Wall -DGRAPHICS_API_OPENGL_33
Process started >>>
c:/raylib/tcc/include/math.h:217: error: unknown constraint 't'
<<< Process finished. (Exit code 1)
tcc -c shapes.c -std=c99 -Wall -DPLATFORM_DESKTOP
Process started >>>
c:/raylib/tcc/include/math.h:217: error: unknown constraint 't'
<<< Process finished. (Exit code 1)
tcc -c textures.c -std=c99 -Wall -DPLATFORM_DESKTOP -Wno-missing-braces
Process started >>>
In file included from textures.c:112:
external/stb_image.h:616: error: include file 'emmintrin.h' not found
<<< Process finished. (Exit code 1)
tcc -c text.c -std=c99 -Wall -DPLATFORM_DESKTOP -Wno-missing-braces
Process started >>>
<<< Process finished. (Exit code 0)
tcc -c models.c -std=c99 -Wall -DPLATFORM_DESKTOP -Wno-missing-braces
Process started >>>
c:/raylib/tcc/include/math.h:217: error: unknown constraint 't'
<<< Process finished. (Exit code 1)
tcc -c audio.c -std=c99 -Wall -DPLATFORM_DESKTOP -Wno-missing-braces
Process started >>>
c:/raylib/tcc/include/math.h:217: error: unknown constraint 't'
<<< Process finished. (Exit code 1)
tcc -c external/mini_al.c -std=c99 -Wall -I.
Process started >>>
In file included from external/mini_al.c:4:
external/mini_al.h:1685: error: invalid type
<<< Process finished. (Exit code 1)
tcc -c external/stb_vorbis.c -Wall -I.
Process started >>>
<<< Process finished. (Exit code 0)
tcc -c utils.c -std=c99 -Wall -DPLATFORM_DESKTOP
Process started >>>
<<< Process finished. (Exit code 0)
The main error I get is: c:/raylib/tcc/include/math.h:217: error: unknown constraint 't'
Tried googling it and test proposed solutions but keeps failing with same error. :(
Hi, just spend a couple of hours working on this...
Updated tcc libraries from MinGW32 and added required ones, also had to do some tweaks. Finally managed to compile raylib (with some warnings and some small tweak). Tried to compile core_basic_window
, it seems tcc uses .def files for linkage.
Compile line:
tcc -o core_basic_window.exe core_basic_window -s -I..\..\src -Iexternal -L..\..\src -lmsvcrt -lraylib -lopengl32 -lgdi32 -luser32 -lkernel32 -std=c99
Get some missing symbols errors:
tcc: error: undefined symbol 'sqrtf'
tcc: error: undefined symbol 'atan2f'
tcc: error: undefined symbol 'sinf'
tcc: error: undefined symbol 'cosf'
tcc: error: undefined symbol 'asinf'
tcc: error: undefined symbol 'VerSetConditionMask'
tcc: error: undefined symbol 'VerifyVersionInfoW'
tcc: error: undefined symbol 'UIntToPtr'
tcc: error: undefined symbol 'GetRawInputDeviceList'
tcc: error: undefined symbol 'GetRawInputDeviceInfoA'
tcc: error: undefined symbol 'SetLayeredWindowAttributes'
tcc: error: undefined symbol 'GetRawInputData'
tcc: error: undefined symbol 'DragQueryFileW'
tcc: error: undefined symbol 'DragQueryPoint'
tcc: error: undefined symbol 'DragFinish'
tcc: error: undefined symbol 'DragAcceptFiles'
tcc: error: undefined symbol 'GetClassLongPtrW'
tcc: error: undefined symbol 'GetLayeredWindowAttributes'
tcc: error: undefined symbol 'RegisterRawInputDevices'
tcc: error: undefined symbol 'powf'
tcc: error: undefined symbol 'logf'
tcc: error: undefined symbol 'ceilf'
Missing symbols belong to libm (math)
, libuser32
, libkernel32
and libshell32
... Don't know how .def linkage works exactly but I imagine that provided .def symbols do not match with corresponding system .dll symbols... libm
doesn't exist, I think those math symbols shold be provided on msvcrt
.
I just tried it in Gentoo Linux, and didn't have problems, except I had to define -DSTBI_NO_SIMD
for stb_image. I just changed CC in makefile, here is the output:
thinkpad src # make
tcc -DSTBI_NO_SIMD -c core.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33
tcc -DSTBI_NO_SIMD -c rlgl.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33
tcc -DSTBI_NO_SIMD -c shapes.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33
tcc -DSTBI_NO_SIMD -c textures.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33
tcc -DSTBI_NO_SIMD -c text.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33
tcc -DSTBI_NO_SIMD -c models.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33
tcc -DSTBI_NO_SIMD -c utils.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP
tcc -DSTBI_NO_SIMD -c rglfw.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33
tcc -DSTBI_NO_SIMD -c audio.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP
tcc -DSTBI_NO_SIMD -c external/stb_vorbis.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP
tcc -DSTBI_NO_SIMD -c external/mini_al.c -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -I. -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP
In file included from external/mini_al.c:4:
external/mini_al.h:9919: warning: implicit declaration of function '__sync_lock_test_and_set'
In file included from external/mini_al.c:4:
external/mini_al.h:9919: warning: implicit declaration of function '__sync_synchronize'
raylib library release path is ../release/libs/linux
ar rcs ../release/libs/linux/libraylib.a core.o rlgl.o shapes.o textures.o text.o models.o utils.o rglfw.o audio.o stb_vorbis.o mini_al.o
raylib static library generated (libraylib.a)!
And version:
thinkpad src # tcc -vv
tcc version 0.9.27 (x86_64 Linux)
install: /usr/lib64/tcc
include:
/usr/lib64/tcc/include
/usr/local/include
/usr/include
libraries:
/usr/lib64
/lib64
/usr/local/lib64
libtcc1:
/usr/lib64/tcc/libtcc1.a
crt:
/usr/lib64
elfinterp:
/lib64/ld-linux-x86-64.so.2
Edit: Tried also examples, after I removed -no-pie fro Makefile all core examples are compiled and linked, it failes on textures:
examples # make
tcc -o core/core_basic_window core/core_basic_window.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_input_keys core/core_input_keys.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_input_mouse core/core_input_mouse.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_mouse_wheel core/core_mouse_wheel.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_input_gamepad core/core_input_gamepad.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_random_values core/core_random_values.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_color_select core/core_color_select.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_drop_files core/core_drop_files.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_storage_values core/core_storage_values.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_gestures_detection core/core_gestures_detection.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_3d_mode core/core_3d_mode.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_3d_picking core/core_3d_picking.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_3d_camera_free core/core_3d_camera_free.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_3d_camera_first_person core/core_3d_camera_first_person.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_2d_camera core/core_2d_camera.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_world_screen core/core_world_screen.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o core/core_vr_simulator core/core_vr_simulator.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o shapes/shapes_logo_raylib shapes/shapes_logo_raylib.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o shapes/shapes_basic_shapes shapes/shapes_basic_shapes.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o shapes/shapes_colors_palette shapes/shapes_colors_palette.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o shapes/shapes_logo_raylib_anim shapes/shapes_logo_raylib_anim.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o shapes/shapes_lines_bezier shapes/shapes_lines_bezier.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o textures/textures_logo_raylib textures/textures_logo_raylib.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o textures/textures_image_loading textures/textures_image_loading.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o textures/textures_rectangle textures/textures_rectangle.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o textures/textures_srcrec_dstrec textures/textures_srcrec_dstrec.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o textures/textures_to_image textures/textures_to_image.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o textures/textures_raw_data textures/textures_raw_data.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o textures/textures_particles_blending textures/textures_particles_blending.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o textures/textures_image_processing textures/textures_image_processing.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o textures/textures_image_drawing textures/textures_image_drawing.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc -o textures/textures_image_generation textures/textures_image_generation.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
textures/textures_image_generation.c:30: error: too many arguments to function
make: *** [Makefile:349: textures/textures_image_generation] Error 1
When I skip textures_image_generation (didn't try but probably fails also with gcc, related to some new changes) next it fails here:
shaders/shaders_postprocessing.c:87: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:88: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:89: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:90: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:91: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:92: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:93: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:94: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:95: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:96: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:97: warning: assignment discards qualifiers from pointer target type
shaders/shaders_postprocessing.c:98: warning: assignment discards qualifiers from pointer target type
tcc -o audio/audio_sound_loading audio/audio_sound_loading.c -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -D_DEFAULT_SOURCE -I. -I../release/include -I../src -I../src/external -L. -L../release/libs/linux -L../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -DPLATFORM_DESKTOP
tcc: error: undefined symbol '__sync_lock_test_and_set'
tcc: error: undefined symbol '__sync_synchronize'
make: *** [Makefile:348: audio/audio_sound_loading] Error 1
Hi @gen2brain! Thank you very much for the feedback!
It's great to see it working on Linux! Textures issue is probably related to this change: https://github.com/raysan5/raylib/commit/c8e97df233f50b0bc1cba07e014aca93c5c0f15c
I'll keep trying to get it on Windows... latest MinGW64 is 420MB and latest Clang (LLVM) is 835MB, keep asking myself if those sizes for a C/C++ compiler could not be reduced... I'm not an expert on compilers...
No problem, it is interesting to play with this.
Tiny C is very fast! If you can get it to work on Windows it can be a great addition for your installer. I don't know much about Windows, but perhaps for now you can try to mix it and link with mingw libraries, not default Windows libs.
Here it is described how you can create additional .def files for dlls http://repo.or.cz/tinycc.git/blob/refs/heads/mob:/win32/tcc-win32.txt#l64 .
but perhaps for now you can try to mix it and link with mingw libraries, not default Windows libs.
Yes, that's the route I'm following, including the required libraries from MinGW package... managed to get libraylib.a
compiled (with some code tweaks) but it fails on program compilation due to system DLLs not matching TCC provided DEF files... I'll try next to generated my own .DEF...
I also managed to build raylib with TCC on Windows 7. I added some headers from winapi-full-for-0.9.27.zip , some are from TDM-GCC I had installed on Windows, and some are from mingw git repo. I made some changes in couple of header files and added some missing defines. The zip file with everything included is available here https://gist.github.com/gen2brain/ea182882eaa1de337cc6aebfbc9a84fb , you can just unzip it to c:\TCC and add that dir to PATH.
All system .def files are regenerated, and opengl32.def is added, it seems that needs to be done so missing math functions and functions from shell32, user32 etc. is corrected with this.
In src Makefile I changed CC to tcc -DSTBI_NO_SIMD
and AR to tcc -ar
.
In examples Makefile also CC, and I had to add -lkernel32 -lshell32 -luser32
. I also regenerated raylib.rc with windres -O coff raylib.rc -o resources.o
(note the .o for object, also changed accordingly in Makefile). And I removed LDLIBS += -static -lpthread
(needed for physac, you must remove at least -static from there).
Note that TCC will compile and link examples with raylib.dll that is compiled with gcc, but that is not supported and will crash. To be sure, remove all libraries from release directory and then compile one with TCC.
Now, the only problem left is this error, it is reported for all functions from raymath, e.g.
../release/libs/win32/mingw32/libraylib.a: error: 'Clamp' defined twice
../release/libs/win32/mingw32/libraylib.a: error: 'Vector2Zero' defined twice
../release/libs/win32/mingw32/libraylib.a: error: 'Vector2One' defined twice
../release/libs/win32/mingw32/libraylib.a: error: 'Vector2Add' defined twice
Edit: I added in mini_al.c #define MAL_NO_WASAPI
, because audioclient.h
etc. headers are not included, there were some issues with those.
Apparently, support for inline
functions is lacking:
A flag won't help, I'm pretty sure this is an inherent limit of TCC. The lack of stored parse information about functions means that the information that TCC would need to perform "proper" inlining just isn't available to the compiler when the inlining must be done, because it isn't kept anywhere.
Ideally, there would be a tcc --ignore-duplicate-symbols
flag. Lacking that, we will have to either change the inline
s to static inline
or remove inline
s altogether. I will draft a fix.
WOW! UNBELIEVABLE! It sounds SUPER-AMAZING to me!
As soon as we get it working I could prepare a slim-installer-package for students!
I tested with https://github.com/raysan5/raylib/commit/8b0fef6c34bc6732e297edd85627d62fe1d6e6be and examples are compiled (I skipped physac and a few of model_ examples). Binaries don't have .exe appended, and I can't start them.
Though, my Windows 7 is in VM, it is maybe related (when compiled without subsystem windows it shows WARNING: [GLFW3 Error] Code: 65543 Decription: WGL: Failed to create OpenGL context
).
Audio examples errors with undefined symbol:
tcc: error: undefined symbol '__sync_lock_test_and_set'
tcc: error: undefined symbol '__sync_synchronize'
Same symbols shows warning during library compile:
external/mini_al.h:9953: warning: implicit declaration of function '__sync_lock_test_and_set'
In file included from external/mini_al.c:5:
external/mini_al.h:9953: warning: implicit declaration of function '__sync_synchronize'
What is also super cool is that when tcc is built with --enable-cross
you get this:
/usr/bin/arm-tcc
/usr/bin/arm-wince-tcc
/usr/bin/arm64-tcc
/usr/bin/c67-tcc
/usr/bin/i386-tcc
/usr/bin/i386-win32-tcc
/usr/bin/tcc
/usr/bin/x86_64-osx-tcc
/usr/bin/x86_64-tcc
/usr/bin/x86_64-win32-tcc
I built tcc on Windows with build-tcc.bat
but should be possible also on Windows. So you can for example have profile for cross compile for RPi, or something like that :)
Could you take a look at the resulting binary with Dependency Walker? It might show some missing libraries/symbols.
Audio examples errors with undefined symbol:
Pushed an (untested) fix for this.
@gen2brain GLFW issue is related to VM, seen it before, OpenGL 3.3 is not supported on VM environment. It should work ok on Windows. Didn't know about cross-compiler build option, AMAZING!
About mini_al
issue when compiling with TCC, probably @mackron should be aware of that.
Fix for audio examples works, now they compile. I tried dependency walker but whole vmware crashes if I try snipping tool or just printscr button to take a screenshot. Here are some of the errors/warnings:
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL
DCOMP.DLL
GPSVC.DLL
IESHIMS.DLL
For all these it reports Error opening file. The system cannot find the file specified (2)
Edit: @raysan5 ok, I will try with opengl 1 in VM, I should have some kind of support for opengl there.
And it works OK in VM if I compile with GRAPHICS_API_OPENGL_11 ;)
Oh, apparently Dependency Walker hasn't kept up with newer Windows versions and these are just false positives...
And it works OK in VM if I compile with GRAPHICS_API_OPENGL_11 ;)
Great!
And it works OK in VM if I compile with GRAPHICS_API_OPENGL_11 ;)
That's great, so, it should work ok on non-VM Windows.
What about audio? Does it work?
Tried to run it on Windows 10 64bit, it seems TCC needs to be recompiled for my OS:
This version of C:\raylib\tcc\tcc.exe is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
@raysan5 audio_music_stream and audio_sound_loading both works, raw_stream I think I disabled because of some issues, and that is with #define MAL_NO_WASAPI
, I will see if I can also include audioclient.h
and deps.
Compile tcc for your system, but copy includes from my zip file. And you should probably just cd to tcc\lib and do the tcc -impdef opengl32.dll
and also overwrite all .def files like this.
Edit: audio_module_playing fails:
WARNING: [resources/mini1111.xm] OGG audio file could not be opened
ERROR: PlayMusicStream() : No audio buffer
Edit: There are no issues with audio_raw_stream.
My results:
tcc -o core_basic_window.exe core_basic_window.c -Iexternal -I../../src -L../../src -lraylib -lopengl32 -lgdi32 -lkernel32 -lshell32 -luser32 -std=c99
tcc: error: undefined symbol 'sqrtf'
tcc: error: undefined symbol 'asinf'
tcc: error: undefined symbol 'cosf'
tcc: error: undefined symbol 'sinf'
tcc: error: undefined symbol 'atan2f'
tcc: error: undefined symbol 'powf'
tcc: error: undefined symbol 'logf'
tcc: error: undefined symbol 'ceilf'
Tried also with -static
to link default libc:
tcc -o core_basic_window.exe core_basic_window.c -Iexternal -I../../src -L../../src -static -lraylib -lopengl32 -lgdi32 -lkernel32 -lshell32 -luser32 -std=c99
tcc: error: library 'opengl32' not found
Those math functions are included in msvcrt.def in Windows 7, but I had the same error, it was gone after I did tcc -impdef msvcrt.dll
in lib dir.
You cannot compile with -static
, and all system libs must be used via def files. But you can use raylib.a static lib, just the binary cannot be fully static. At least that is how I understood.
Edit: try also with -lmsvcrt
, but it was not needed in my case.
Tried the same process in my Surface with Windows 10 64bit and I get similar errors, also tried proposed solution but I keep getting errors:
tcc -o core_basic_window.exe core_basic_window.c -I../../src -Iexternal -L../../src -lmsvcrt -lraylib -lopengl32 -lgdi32 -luser32 -lkernel32 -lshell32 -std=c99
tcc: error: undefined symbol 'sqrtf'
tcc: error: undefined symbol 'asinf'
tcc: error: undefined symbol 'cosf'
tcc: error: undefined symbol 'sinf'
tcc: error: undefined symbol 'atan2f'
tcc: error: undefined symbol 'powf'
tcc: error: undefined symbol 'GetClassLongPtrW'
tcc: error: undefined symbol 'logf'
tcc: error: undefined symbol 'ceilf'
On this computer I also got an additional undefined symbol! That's weird...
As per my understanding, generated .def do not include those symbols, so I opened them in Notepad++ (they are plain text files) and added the symbols manually; compiled again and everything worked!
So, it seems generated .def do not use right version of those .dll (or use the first version they get access to), then the generated executable uses the right .dll of the system...
@a3f I've integrated your fix upstream (https://github.com/dr-soft/mini_al/commit/02b7ef1c2c3fbc68d06c4c6e84cf202d9e01d903).
@gen2brain
I added in mini_al.c #define MAL_NO_WASAPI , because audioclient.h etc. headers are not included, there were some issues with those.
The next version of mini_al does not depend on audioclient.h, etc. so #define MAL_NO_WASAPI
should become unnecessary.
Any other mini_al specific issues here that I've missed?
Any other mini_al specific issues here that I've missed?
@mackron, nothing else for the moment! :)
Tried on Windows 10 32bit and, again, I got the missing symbols issue:
tcc: error: undefined symbol 'sqrtf'
tcc: error: undefined symbol 'asinf'
tcc: error: undefined symbol 'cosf'
tcc: error: undefined symbol 'sinf'
tcc: error: undefined symbol 'atan2f'
tcc: error: undefined symbol 'powf'
tcc: error: undefined symbol 'logf'
tcc: error: undefined symbol 'ceilf'
But this time, adding them to msvcrt.def
is not enough, program compiles but when trying to run it, it complains at runtime about not finding sqrtf
. That's very weird... any idea?
My guess: MSVCRT defines the float math functions as inline functions that expand to the double version, e.g. inline float sqrtf(float f) { return (float)sqrt((double)f); }
, but MinGW headers define them as external symbols and that mismatch causes the missing symbols.
Great guess @a3f! It sounds reasonable to me... but then, why on Windows 10 64bit it works? Maybe MSVCRT.dll 64bit exposes those symbols but not MSVCRT.dll 32bit? Do you know how could I check that? Any proposed solution for that issue? Maybe I can just define my own float functions the same way?
To check symbols I tried:
nm C:\Windows\System32\msvcrt.dll
nm C:\Windows\SysWOW64\msvcrt.dll
But it reports no symbols, probably they have been stripped from header...
Checked TCC math.h
header, that comes from MinGW32 and it defines sqrtf
as:
float __cdecl sqrtf(float _X);
but some lines below...
#ifndef __x86_64
...
__CRT_INLINE float powf(float _X,float _Y) { return ((float)pow((double)_X,(double)_Y)); }
__CRT_INLINE float sinf(float _X) { return ((float)sin((double)_X)); }
__CRT_INLINE float sinhf(float _X) { return ((float)sinh((double)_X)); }
__CRT_INLINE float sqrtf(float _X) { return ((float)sqrt((double)_X)); }
__CRT_INLINE float tanf(float _X) { return ((float)tan((double)_X)); }
__CRT_INLINE float tanhf(float _X) { return ((float)tanh((double)_X)); }
#endif
why on Windows 10 64bit it works
No idea. That's why it's a guess!
you know how could I check that?
DLL walker noted further up is what I used so far for checking exported symbols on Windows.
Any proposed solution for that issue?
Check out what MSVC's <math.h>
actually defines/declares.
Maybe I can just define my own float functions the same way?
I'd edit <math.h>
and try adding
static inline float sqrtf (float f) { return (float)sqrt(f); }
static inline float asinf (float f) { return (float)asin(f); }
static inline float cosf (float f) { return (float)cos(f); }
static inline float sinf (float f) { return (float)sin(f); }
static inline float atan2f (float f1, float f2) { return (float)atan2(f1, f2); }
static inline float powf (float f1, float f2) { return (float)pow(f1, f2); }
static inline float logf (float f) { return (float)log(f); }
static inline float ceilf (float f) { return (float)ceil(f); }
MSVC's math.h
defines:
#if defined _M_X64 || defined _M_ARM || defined _M_ARM64
...
_Check_return_ _ACRTIMP float __cdecl sqrtf(_In_ float _X);
...
#else
...
_Check_return_ __inline float __CRTDECL sqrtf(_In_ float _X)
{
return (float)sqrt(_X);
}
...
#endif
So, as _M_X64
is defined for x64 processors, in Windows 10 64bit, those functions are compiled with symbols but on Windows 10 32bit, those functions are inlined, so no symbols on MSVCRT.dll 32bit.
But TCC math.h
that comes from MinGW defines it correctly for #ifndef __x86_64
to inline functions... or that's apparently what should happen with:
__CRT_INLINE float sqrtf(float _X) { return ((float)sqrt((double)_X)); }
Let's take a closer look... _mingw.h
defines:
#define __CRT_INLINE extern __inline__
But __inline__
is a non-standard extension; we can't say with certainty if its supported by the compiler.
Moreover, digging a bit further, I found this statement:
TCC doesn't support function inlining, because the 'inline' keyword is ignored, so if a function needs to be inlined, you must use defines instead.
I love to discover and understand how things work! :D
Now, let's implement a solution.
EDIT 1: TCC C99 Manual for reference.
EDIT 2: Re-reading issue, I saw @a3f already pointed lack of inline support on TCC... >_<
The inline
in static inline
is just a hint anyway, so it's ok that tinycc ignores it. It shouldn't cause an error or miscompilation (<raymath.h>
uses static inline
definitions as well for tinycc).
Use of #define
s here would be wrong, because that would prevent taking pointers to these functions.
Just tried using static
function declarations on math.h
, it works.
TCC compiler support is complete, tested on win32 and win64. Closing this issue.
Is there an installer for Windows for TCC, since this all seems complicated to me, or maybe a list of instructions to try it myself? I am grateful for everyone's efforts on this!
Just unzip the right binary release from http://download.savannah.gnu.org/releases/tinycc/ and you're done...
This improvement has a double pourpose, first just offer an alternative to the already supported C compilers (GCC, clang, MSVC), second, offer a really tiny lightweight environment to play with raylib.
raylib is provided to students as an installer including the library, a preconfigured version of Notepad++ and MinGW package. This installer is pretty big and I'd like to reduce its size. Current MinGW package is around 200 MB; in comparison, TCC with basic libraries is just around 3 MB.