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

[WEB] building with Makefile triggers warning: linker setting ignored during compilation: 'ASSERTIONS' [-Wunused-command-line-argument] #4716

Closed
sleeptightAnsiC opened this issue Jan 21, 2025 · 1 comment

Comments

@sleeptightAnsiC
Copy link
Contributor

sleeptightAnsiC commented Jan 21, 2025

If you build raylib with src/Makefile, with PLATFORM_WEB and DEBUG, you will notice following warning:

emcc: warning: linker setting ignored during compilation: 'ASSERTIONS' [-Wunused-command-line-argument]

This is because Makefile adds -sASSERTIONS=1 to CFLAGS despite that this is not a compiler option but a linker option. This is not severe at all, but I wonder if said flag hasn't been misused. Currently it has no effect at all.

It probably would be better to use -sASSERTIONS=1 as part of LDFLAGS. Makefile never links when building for WEB, since it can't create shared library for WEB, but someone may still query it for LDFLAGS (this is how I'm building and linking my project actually).

Anyway, I could quickly fix it and propose PR but there are more Makefiles than the one in src/ that also have this issue [SEE DOWN BELOW]. Let me know what do you think before taking care of this. The are actually some Makefiles that properly set it to LDFLAGS, but most do not [SEE DOWN BELOW].

Environment

~ $ uname -a
Linux MAL200424 6.12.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 10 Jan 2025 00:39:41 +0000 x86_64 GNU/Linux
~ $ emcc --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.72-git (437140d149d9c977ffc8b09dbaf9b0f5a02db190)

Code Example

repro and outcome:

~ $ git clone https://github.com/raysan5/raylib
~ $ cd raylib/src
~/raylib/src $ make TARGET_PLATFORM=PLATFORM_WEB RAYLIB_BUILD_MODE=DEBUG
emcc -c rcore.c -Wall -D_GNU_SOURCE -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing -std=gnu99 -fPIC -g -D_DEBUG -sASSERTIONS=1 --profiling  -I.  -Iexternal/glfw/include
emcc: warning: linker setting ignored during compilation: 'ASSERTIONS' [-Wunused-command-line-argument]
In file included from rcore.c:121:
./rlgl.h:3233:9: warning: variable 'mipOffset' set but not used [-Wunused-but-set-variable]
 3233 |     int mipOffset = 0;          // Mipmap data offset, only used for tracelog
      |         ^
1 warning generated.
emcc -c rshapes.c -Wall -D_GNU_SOURCE -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing -std=gnu99 -fPIC -g -D_DEBUG -sASSERTIONS=1 --profiling  -I.  -Iexternal/glfw/include
emcc: warning: linker setting ignored during compilation: 'ASSERTIONS' [-Wunused-command-line-argument]
emcc -c rtextures.c -Wall -D_GNU_SOURCE -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing -std=gnu99 -fPIC -g -D_DEBUG -sASSERTIONS=1 --profiling  -I.  -Iexternal/glfw/include
emcc: warning: linker setting ignored during compilation: 'ASSERTIONS' [-Wunused-command-line-argument]
emcc -c rtext.c -Wall -D_GNU_SOURCE -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing -std=gnu99 -fPIC -g -D_DEBUG -sASSERTIONS=1 --profiling  -I.  -Iexternal/glfw/include
emcc: warning: linker setting ignored during compilation: 'ASSERTIONS' [-Wunused-command-line-argument]
emcc -c utils.c -Wall -D_GNU_SOURCE -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing -std=gnu99 -fPIC -g -D_DEBUG -sASSERTIONS=1 --profiling  -I.  -Iexternal/glfw/include
emcc: warning: linker setting ignored during compilation: 'ASSERTIONS' [-Wunused-command-line-argument]
emcc -c rmodels.c -Wall -D_GNU_SOURCE -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing -std=gnu99 -fPIC -g -D_DEBUG -sASSERTIONS=1 --profiling  -I.  -Iexternal/glfw/include
emcc: warning: linker setting ignored during compilation: 'ASSERTIONS' [-Wunused-command-line-argument]
emcc -c raudio.c -Wall -D_GNU_SOURCE -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing -std=gnu99 -fPIC -g -D_DEBUG -sASSERTIONS=1 --profiling  -I.  -Iexternal/glfw/include
emcc: warning: linker setting ignored during compilation: 'ASSERTIONS' [-Wunused-command-line-argument]
emar rcs ../src/libraylib.web.a rcore.o rshapes.o rtextures.o rtext.o utils.o  rmodels.o raudio.o
raylib library generated (libraylib.web.a)!

all files affected by this issue:

~/raylib $ grep -rn ASSERTIONS | grep CFLAGS
src/Makefile:387:        CFLAGS += -sASSERTIONS=1 --profiling
projects/VSCode/Makefile:244:        CFLAGS += -sASSERTIONS=1 --profiling
projects/4coder/Makefile:238:        CFLAGS += -sASSERTIONS=1 --profiling
examples/Makefile.Web:193:        CFLAGS += -sASSERTIONS=1 --profiling
examples/Makefile:237:        CFLAGS += -sASSERTIONS=1 --profiling

files NOT affected:

~/raylib $ grep -rn ASSERTIONS | grep LDFLAGS
examples/Makefile.Web:303:        LDFLAGS += -sASSERTIONS=1 --profiling
examples/Makefile:366:        LDFLAGS += -sASSERTIONS=1 --profiling
@raysan5
Copy link
Owner

raysan5 commented Jan 21, 2025

@sleeptightAnsiC thanks for reporting, reviewed.

@raysan5 raysan5 closed this as completed Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants