[rcore][android] Add WARNING comment for --wrap=fopen build system requirements (#5624)

Co-authored-by: Federico Gherardi <ghera@libero.it>
This commit is contained in:
ghera
2026-03-05 11:50:47 +01:00
committed by GitHub
parent ea00b97c59
commit f9ee714c76

View File

@@ -275,6 +275,22 @@ static int android_write(void *cookie, const char *buf, int size);
static fpos_t android_seek(void *cookie, fpos_t offset, int whence);
static int android_close(void *cookie);
// WARNING: fopen() calls are intercepted via linker flag -Wl,--wrap=fopen: the linker renames
// the original fopen -> __real_fopen and redirects all call sites to __wrap_fopen
// The flag MUST be applied at every final link step that needs wrapping,
// it has no effect when only building a static archive (.a)
//
// CMake: no action required, raylib's CMakeLists.txt already sets
// target_link_options(raylib INTERFACE -Wl,--wrap=fopen) which propagates to
// the final app link, wrapping app code and all static (.a) dependencies too
// Make (SHARED): no action required for raylib itself, src/Makefile already sets
// LDFLAGS += -Wl,--wrap=fopen wrapping fopen inside libraylib.so only;
// app code and static (.a) dependencies are NOT wrapped unless -Wl,--wrap=fopen
// is also added to the final app link step
// Make (STATIC): pass -Wl,--wrap=fopen to the linker command producing the final artifact
// build.zig: no dedicated wrap helper; pass -Wl,--wrap=fopen to the linker command producing
// the final artifact
// custom: pass -Wl,--wrap=fopen to the linker command producing the final artifact
FILE *__real_fopen(const char *fileName, const char *mode); // Real fopen, provided by the linker (--wrap=fopen)
FILE *__wrap_fopen(const char *fileName, const char *mode); // Replacement for fopen()