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

Support clients defining weak symbols of opengx functions #70

Merged
merged 1 commit into from
Sep 28, 2024

Conversation

mardy
Copy link
Collaborator

@mardy mardy commented Sep 26, 2024

With this change, the translation unit (TU) of functions.c gets brought
into the list of units used in the linking when a gc_gl.c's TU is used,
as confirmed by nm:

functions.o:
...
00000000 B _ogx_functions_c
00000000 T ogx_get_proc_address
...

gc_gl.o:
...
00000000 D _ogx_force_proctable
         U _ogx_functions_c
00000000 T ogx_initialize
...

As the comment in the code explains it, this allows us to support the
scenario where we use opengx in a client library (such as SDL) without
forcing a dependency on it in the client application. More precisely,
this change is made to support the case where an application does use
opengx via libSDL, to make so that the weak symbol for
ogx_get_proc_address() defined in libSDL gets overridden by the real one
(since the application is unlikely to use this function directly, but
it's indirectly used when SDL_GL_GetProcAddress() is called).

With this change, the translation unit (TU) of functions.c gets brought
into the list of units used in the linking when gc_gl.c's TU is used, as
confirmed by nm:

    functions.o:
    ...
    00000000 B _ogx_functions_c
    00000000 T ogx_get_proc_address
    ...

    gc_gl.o:
    ...
    00000000 D _ogx_force_proctable
             U _ogx_functions_c
    00000000 T ogx_initialize
    ...

As the comment in the code explains it, this allows us to support the
scenario where we use opengx in a client library (such as SDL) without
forcing a dependency on it in the client application. More precisely,
this change is made to support the case where an application *does use*
opengx via libSDL, to make so that the weak symbol for
ogx_get_proc_address() defined in libSDL gets overridden by the real one
(since the application is unlikely to use this function directly, but
it's indirectly used when SDL_GL_GetProcAddress() is called).
@WinterMute WinterMute merged commit b5406c8 into devkitPro:master Sep 28, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants