Closed alexlnkp closed 2 months ago
340MB executable does sound suspect. The only thing I can think of is maybe we should consider NK_ASSERT
?
https://github.com/RobLoach/raylib-nuklear/blob/master/include/raylib-nuklear.h#L55
#ifndef NK_ASSERT
#define NK_ASSERT(condition) do { if (!(condition)) { TraceLog(LOG_WARNING, "NUKLEAR: Failed assert \"%s\" (%s:%i)", #condition, "nuklear.h", __LINE__); }} while (0)
#endif // NK_ASSERT
Think that would do anything suspect on execution size? Debug symbols do take up a lot of space.
Perhaps see if doing something like this affects it?
#define NK_ASSERT(condition) ((void)0)
Perhaps see if doing something like this affects it?
#define NK_ASSERT(condition) ((void)0)
-flto=auto
:
With this before the `#include "raylib-nuklear.h": 318072kb
Without: 363128kb-flto=auto
:
With this before the `#include "raylib-nuklear.h": 72288kb
Without: 80480kbAnd this does indeed help, but still the executable's size seems unintentionally too big
Regarding #define NK_ASSERT(condition) ((void)0)
, you could fix this with a simple:
#ifndef NK_ASSERT
#ifdef NDEBUG
#define NK_ASSERT(condition) ((void)0)
#else
#define NK_ASSERT(condition) do { if (!(condition)) { TraceLog(LOG_WARNING, "NUKLEAR: Failed assert \"%s\" (%s:%i)", #condition, "nuklear.h", __LINE__); }} while (0)
#endif
#endif
Though I'm not sure if NDEBUG
flag is as widely used in C as it is in C++?
Love the NDEBUG idea, whether or not it's C++/C... Made a PR https://github.com/RobLoach/raylib-nuklear/pull/71
I've noticed that nuklear.h is included multiple times, this could also be a part of the issue
nuklear.h itself is REALLY heavy, including it twice seems a bit excessive
however i can not help with figuring out how to not do that, the structure of raylib-nuklear.h
is too complex for me (never had to work on a single-header type of projects, sorry)
The applications end up around 1.9MB for me when compiling now. With or without NDEBUG
. I'm not that fluent in raylib's base Makefile. Is there anything else missing that we could add to your set up? Thnaks!
@alexlnkp, add more information about how you're building or installing and also include the final GCC command that your build script is running.
@alexlnkp, add more information about how you're building or installing and also include the final GCC command that your build script is running.
I simply installed the raylib
package from AUR. The final command that is ran to build is gcc -s -Wall -Wextra -Wpedantic -std=c99 -DNDEBUG -O3 -flto=auto -s -lraylib -lm -o 3dren main.c
The output size is 84608
(kb)
Try something like gcc -Wall -Wextra -Wpedantic -std=c99 -DNDEBUG -O3 -c main.c
to compile your program but not link it. Thay will produce main.o
, please check its size. If main.o
is small, then it's unlikely that's caused by raylib-nuklear.
Just a side note, including nuklear.h
several times is fine. It has guards to prevent duplicating itself.
Try something like
gcc -Wall -Wextra -Wpedantic -std=c99 -DNDEBUG -O3 -c main.c
to compile your program but not link it. Thay will producemain.o
, please check its size. Ifmain.o
is small, then it's unlikely that's caused by raylib-nuklear.Just a side note, including
nuklear.h
several times is fine. It has guards to prevent duplicating itself.
Well, it didn't seem to work to be honest.
$ gcc -Wall -Wextra -Wpedantic -std=c99 -DNDEBUG -O3 -c main.c
$ wc -c main.o
406696 main.o
So it seems the program itself, including nuklear and raylib-nuklear, is not that big. It's just ~400 kb.
Are you sure you are getting an increase of 348560 kb? Or is that 348560 bytes (basically around 350 kb)? wc -c
should report bytes, not kb.
If it's 350 kb, I would say that's pretty much expected. Nuklear and raylib-nuklear are basically static libraries and they are fairly complex too.
So it seems the program itself, including nuklear and raylib-nuklear, is not that big. It's just ~400 kb.
Are you sure you are getting an increase of 348560 kb? Or is that 348560 bytes (basically around 350 kb)?
wc -c
should report bytes, not kb.If it's 350 kb, I would say that's pretty much expected. Nuklear and raylib-nuklear are basically static libraries and they are fairly complex too.
Oh my god, You are right... All this time it was bytes, not kilobytes.... I'm so sorry for wasting your time here. I'll close this issue.
Thanks for testing it out! Glad we figured it out :laughing:
not sure if this is expected or even intended, but the executable size grows SIGNIFICANTLY whenever i try to use raylib-nuklear. and the 65912kb size increase? that's with
-flto
! without-flto
, the size increase is 348560kb!i'm not using CMake or Make, i have a small compilation script:
and all of that in a simple 3d render:
the raylib GUI works though, no issues there... just odd how it takes SO much space