From 39688d28eaecc33cfd0736c74ca2edf6161f58e3 Mon Sep 17 00:00:00 2001 From: sleeptightAnsiC <91839286+sleeptightAnsiC@users.noreply.github.com> Date: Tue, 21 Apr 2026 21:18:42 +0200 Subject: [PATCH 1/2] disable optimizations and other costly CFLAGS from demos Demos must compile as fast as possible, in order to be quick to reiterate and retest. Given that each needs to link and recompile amalgamation every time, the difference between -O2 and -O0 is noticeable. This also slightly affects CI times. This topic was discussed under several occasions, for example: https://github.com/Immediate-Mode-UI/Nuklear/pull/894#issuecomment-3880985649 https://github.com/Immediate-Mode-UI/Nuklear/issues/895#issuecomment-3884228468 --- demo/rawfb/wayland/Makefile | 3 ++- demo/sdl3_renderer/Makefile | 6 +++--- demo/sdl_opengles2/Makefile | 3 ++- demo/sdl_renderer/Makefile | 3 ++- demo/sdl_vulkan/Makefile | 3 ++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/demo/rawfb/wayland/Makefile b/demo/rawfb/wayland/Makefile index 809bd6df..d633f9ea 100644 --- a/demo/rawfb/wayland/Makefile +++ b/demo/rawfb/wayland/Makefile @@ -2,7 +2,8 @@ WAYLAND=`pkg-config wayland-client --cflags --libs` WAYLAND_SCANNER=wayland-scanner WAYLAND_PROTOCOLS_DIR=/usr/share/wayland-protocols -CFLAGS+=-std=c99 -Wall -Wextra -pedantic -Wno-unused-function -O3 -fvisibility=hidden +CFLAGS += -std=c99 -Wall -Wextra -pedantic -Wno-unused-function -fvisibility=hidden +#CFLAGS += -O3 .PHONY: clean diff --git a/demo/sdl3_renderer/Makefile b/demo/sdl3_renderer/Makefile index 48ee50e1..6022302a 100644 --- a/demo/sdl3_renderer/Makefile +++ b/demo/sdl3_renderer/Makefile @@ -23,9 +23,9 @@ BINEXT := ${binext_${OSNAME}} TEMPDIR := ./bin BIN := ${TEMPDIR}/demo${BINEXT} -cflags += -std=c89 -Wall -Wextra -Wpedantic -cflags += -O2 -#cflags += -O0 -g +cflags += -std=c89 -Wall -Wextra -pedantic +#cflags += -O2 +cflags += -O0 -g #cflags += -fsanitize=address #cflags += -fsanitize=undefined cflags += ${CFLAGS} diff --git a/demo/sdl_opengles2/Makefile b/demo/sdl_opengles2/Makefile index b97ada72..b445c779 100644 --- a/demo/sdl_opengles2/Makefile +++ b/demo/sdl_opengles2/Makefile @@ -3,6 +3,7 @@ BIN = demo # Flags CFLAGS += -std=c89 -Wall -Wextra -pedantic -DSDL_DISABLE_IMMINTRIN_H +#CFLAGS += -Os SRC = main.c OBJ = $(SRC:.c=.o) @@ -18,7 +19,7 @@ $(BIN): prepare $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) $(LIBS) web: prepare - emcc $(SRC) -Os -s USE_SDL=2 -o bin/index.html + emcc $(SRC) $(CFLAGS) -s USE_SDL=2 -o bin/index.html rpi: prepare $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) `PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig/ pkg-config --cflags --libs bcm_host brcmglesv2` `/usr/local/bin/sdl2-config --libs --cflags` diff --git a/demo/sdl_renderer/Makefile b/demo/sdl_renderer/Makefile index b3efdb8c..b02f71b7 100644 --- a/demo/sdl_renderer/Makefile +++ b/demo/sdl_renderer/Makefile @@ -2,7 +2,8 @@ BIN = demo # Flags -CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 -DSDL_DISABLE_IMMINTRIN_H +CFLAGS += -std=c89 -Wall -Wextra -pedantic -DSDL_DISABLE_IMMINTRIN_H +#CFLAGS += -O2 CFLAGS += `sdl2-config --cflags` SRC = main.c diff --git a/demo/sdl_vulkan/Makefile b/demo/sdl_vulkan/Makefile index 2d8444b6..33e2a701 100644 --- a/demo/sdl_vulkan/Makefile +++ b/demo/sdl_vulkan/Makefile @@ -2,7 +2,8 @@ BIN = demo # Flags -CFLAGS += -std=c89 -Wall -Wextra -pedantic -fsanitize=address -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic +#CFLAGS += -fsanitize=address -O2 CFLAGS += -DSDL_DISABLE_IMMINTRIN_H SRC = main.c From eda8438bbd2a74918bf6164852bca03c08f1b5cf Mon Sep 17 00:00:00 2001 From: sleeptightAnsiC <91839286+sleeptightAnsiC@users.noreply.github.com> Date: Mon, 4 May 2026 21:49:10 +0200 Subject: [PATCH 2/2] disable optimizations for MSVC demos too removes /O flags from CL and FXC, for all demos using build.bat intentionally split into different commit because we rarely test those Fixes: https://github.com/Immediate-Mode-UI/Nuklear/pull/946#issuecomment-4306256773 --- demo/d3d11/build.bat | 6 +++--- demo/d3d12/build.bat | 6 +++--- demo/d3d9/build.bat | 2 +- demo/gdi/build.bat | 2 +- demo/gdi_native_nuklear/build.bat | 2 +- demo/gdip/build.bat | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/demo/d3d11/build.bat b/demo/d3d11/build.bat index 31bd0e05..8f6fafda 100644 --- a/demo/d3d11/build.bat +++ b/demo/d3d11/build.bat @@ -3,7 +3,7 @@ rem This will use VS2015 for compiler call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 -fxc.exe /nologo /T vs_4_0_level_9_0 /E vs /O3 /Zpc /Ges /Fh nuklear_d3d11_vertex_shader.h /Vn nk_d3d11_vertex_shader /Qstrip_reflect /Qstrip_debug /Qstrip_priv nuklear_d3d11.hlsl -fxc.exe /nologo /T ps_4_0_level_9_0 /E ps /O3 /Zpc /Ges /Fh nuklear_d3d11_pixel_shader.h /Vn nk_d3d11_pixel_shader /Qstrip_reflect /Qstrip_debug /Qstrip_priv nuklear_d3d11.hlsl +fxc.exe /nologo /T vs_4_0_level_9_0 /E vs /Zpc /Ges /Fh nuklear_d3d11_vertex_shader.h /Vn nk_d3d11_vertex_shader /Qstrip_reflect /Qstrip_debug /Qstrip_priv nuklear_d3d11.hlsl +fxc.exe /nologo /T ps_4_0_level_9_0 /E ps /Zpc /Ges /Fh nuklear_d3d11_pixel_shader.h /Vn nk_d3d11_pixel_shader /Qstrip_reflect /Qstrip_debug /Qstrip_priv nuklear_d3d11.hlsl -cl /D_CRT_SECURE_NO_DEPRECATE /nologo /W3 /O2 /fp:fast /Gm- /Fedemo.exe main.c user32.lib dxguid.lib d3d11.lib /link /incremental:no +cl /D_CRT_SECURE_NO_DEPRECATE /nologo /W3 /fp:fast /Gm- /Fedemo.exe main.c user32.lib dxguid.lib d3d11.lib /link /incremental:no diff --git a/demo/d3d12/build.bat b/demo/d3d12/build.bat index 42302077..2593d81f 100644 --- a/demo/d3d12/build.bat +++ b/demo/d3d12/build.bat @@ -3,7 +3,7 @@ rem This will use VS2015 for compiler... if you have vs 2015 and it is installed at this / the default path call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 -fxc.exe /nologo /T vs_5_1 /E vs /O3 /Zpc /Ges /Fh nuklear_d3d12_vertex_shader.h /Vn nk_d3d12_vertex_shader /Qstrip_reflect /Qstrip_debug /Qstrip_priv nuklear_d3d12.hlsl -fxc.exe /nologo /T ps_5_1 /E ps /O3 /Zpc /Ges /Fh nuklear_d3d12_pixel_shader.h /Vn nk_d3d12_pixel_shader /Qstrip_reflect /Qstrip_debug /Qstrip_priv /enable_unbounded_descriptor_tables nuklear_d3d12.hlsl +fxc.exe /nologo /T vs_5_1 /E vs /Zpc /Ges /Fh nuklear_d3d12_vertex_shader.h /Vn nk_d3d12_vertex_shader /Qstrip_reflect /Qstrip_debug /Qstrip_priv nuklear_d3d12.hlsl +fxc.exe /nologo /T ps_5_1 /E ps /Zpc /Ges /Fh nuklear_d3d12_pixel_shader.h /Vn nk_d3d12_pixel_shader /Qstrip_reflect /Qstrip_debug /Qstrip_priv /enable_unbounded_descriptor_tables nuklear_d3d12.hlsl -cl /D_CRT_SECURE_NO_DEPRECATE /nologo /W3 /O2 /fp:fast /Gm- /Fedemo.exe main.c user32.lib dxguid.lib dxgi.lib d3d12.lib /link /incremental:no +cl /D_CRT_SECURE_NO_DEPRECATE /nologo /W3 /fp:fast /Gm- /Fedemo.exe main.c user32.lib dxguid.lib dxgi.lib d3d12.lib /link /incremental:no diff --git a/demo/d3d9/build.bat b/demo/d3d9/build.bat index 726b6f6f..cb248aeb 100644 --- a/demo/d3d9/build.bat +++ b/demo/d3d9/build.bat @@ -3,4 +3,4 @@ rem This will use VS2015 for compiler call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 -cl /D_CRT_SECURE_NO_DEPRECATE /nologo /W3 /O2 /fp:fast /Gm- /Fedemo.exe main.c user32.lib d3d9.lib /link /incremental:no +cl /D_CRT_SECURE_NO_DEPRECATE /nologo /W3 /fp:fast /Gm- /Fedemo.exe main.c user32.lib d3d9.lib /link /incremental:no diff --git a/demo/gdi/build.bat b/demo/gdi/build.bat index ddd3edf1..d51c9441 100644 --- a/demo/gdi/build.bat +++ b/demo/gdi/build.bat @@ -3,4 +3,4 @@ rem This will use VS2015 for compiler call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 -cl /nologo /W3 /O2 /fp:fast /Gm- /Fedemo.exe main.c user32.lib gdi32.lib Msimg32.lib /link /incremental:no +cl /nologo /W3 /fp:fast /Gm- /Fedemo.exe main.c user32.lib gdi32.lib Msimg32.lib /link /incremental:no diff --git a/demo/gdi_native_nuklear/build.bat b/demo/gdi_native_nuklear/build.bat index 2f87f8e1..9c773ce2 100644 --- a/demo/gdi_native_nuklear/build.bat +++ b/demo/gdi_native_nuklear/build.bat @@ -3,4 +3,4 @@ rem This will use VS2015 for compiler call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 -cl /nologo /W3 /O2 /fp:fast /Gm- /D_CRT_SECURE_NO_DEPRECATE /Fedemo.exe main.c user32.lib gdi32.lib Msimg32.lib /link /incremental:no +cl /nologo /W3 /fp:fast /Gm- /D_CRT_SECURE_NO_DEPRECATE /Fedemo.exe main.c user32.lib gdi32.lib Msimg32.lib /link /incremental:no diff --git a/demo/gdip/build.bat b/demo/gdip/build.bat index 0f246555..1173d2af 100644 --- a/demo/gdip/build.bat +++ b/demo/gdip/build.bat @@ -2,4 +2,4 @@ call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 -cl /nologo /W3 /O2 /fp:fast /Gm- /Fedemo.exe /D_CRT_SECURE_NO_DEPRECATE main.c user32.lib gdiplus.lib shlwapi.lib /link /incremental:no +cl /nologo /W3 /fp:fast /Gm- /Fedemo.exe /D_CRT_SECURE_NO_DEPRECATE main.c user32.lib gdiplus.lib shlwapi.lib /link /incremental:no