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

[build] Makefile: throw an error when trying to build SHARED library #4718

Merged

Conversation

sleeptightAnsiC
Copy link
Contributor

[see linked issue for more context]

When asking Makefile to create SHARED library for WEB

~/raylib/src $ make TARGET_PLATFORM=PLATFORM_WEB RAYLIB_LIBTYPE=SHARED

it would instead silently create STATIC library thus not fulfilling the request as expected

This commit adds an error in this case and stops further execution which fixes this issue.

This is not consistent with Cmake, because Cmake throws the warning and does not stop, but Cmake can easily recover from this case and people probably does not even notice it. However, Makefile is something that you have to handle yourself and you have to recover from any issues so having an error and aborting with exit code 1 is more expected. Otherwise people may spend a lot of time debugging Makefile in order to understand what's even going on.

Fixes: #4717

When asking Makefile to create SHARED library for WEB
	$ make TARGET_PLATFORM=PLATFORM_WEB RAYLIB_LIBTYPE=SHARED
it would instead silently create STATIC library
thus not fulfilling the request as expected

This commit adds an error in this case and stops further execution.

This is not consistent with Cmake, because Cmake throws the warning and
does not stop, but Cmake can easily recover from this case and people
probably does not even notice it. However, Makefile is something that
you have to handle yourself and you have to recover from any issues so
having an error and aborting with exit code 1 is more expected.
Otherwise people may spend a lot of time debugging Makefile in order to
understand what's even going on.

Fixes: raysan5#4717
@Peter0x44
Copy link
Contributor

I don't think this should be a fatal error, since that just causes inconsistency. A warning alone is fine.

@sleeptightAnsiC
Copy link
Contributor Author

sleeptightAnsiC commented Jan 21, 2025

I've mentioned why this is inconsistent @Peter0x44

Cmake can easily recover from this case and people probably does not even notice it. However, Makefile is something that you have to handle yourself and you have to recover from any issues

The fact that Cmake is not erroring here is also bad BUT since people usually depend on raylib with add_library(raylib) it won't be a fatal issue in 99% cases since Cmake is doing any heavy lifting.

Makefile cannot automatically do this, it can't recover on its own. If you have a build recipe that expects .so and raylib produces .a, you may get a very nasty issue somewhere down the line that won't be obvious to fix. For example, it may grab old .so that wasn't build for WEB and emcc may freak out throwing linking errors OR WORSE: it could link just fine but break at runtime.

@raysan5
Copy link
Owner

raysan5 commented Jan 21, 2025

@sleeptightAnsiC I agree with @Peter0x44 that a warning is enough.

@raysan5 raysan5 changed the title Fix(WEB): Makefile: throw an error when trying to build SHARED library [build] Makefile: throw an error when trying to build SHARED library Jan 21, 2025
@raysan5 raysan5 added the platform: Web Web platform label Jan 21, 2025
@raysan5 raysan5 merged commit 322ba54 into raysan5:master Jan 21, 2025
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented Jan 21, 2025

@sleeptightAnsiC Merging and reviewing it myself as a warning. Thanks for the improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Web Web platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[WEB] Makefile: building with RAYLIB_LIBTYPE=SHARED silently creates STATIC library
3 participants