Don't define SDL_ELF_NOTE_DLOPEN when compiler does not support variadic macro's #14245
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I removed the cmake comment in the documentation since I feel CMake does not belong in the public headers.
Projects can make sure their toolchain supports
SDL_ELF_NOTE_DLOPEN
through this fragment:We document how to disable the macro. CMake/meson developers should know what do do with that.
Here's how to test without using the SDL3 headers:
include(CheckCSourceCompiles) check_c_source_compiles([==[ #ifndef __ELF__ ELF DL notes are only supported on ELF platforms #endif #define ARR1(N1) "[\"" N1 "\"]" #define ARR2(N1, N2) "[\"" N1 "\",\"" N2 "\"]" #define ARR_GET(N1,N2,NAME,...) NAME #define ARR(...) ARR_GET(__VA_ARGS__, ARR2, ARR1)(__VA_ARGS__) #define JOIN2(A,B) A##B #define JOIN(A,B) JOIN2(A,B) #define UNIQ JOIN(s_global, __LINE__) #define DLNOTE_INT2(JSON,VARNAME) \\ __attribute__ ((used,aligned(4),section(".note.dlopen"))) static const struct { \\ struct { int a; int b; } v; __attribute__((aligned(4))) char dlopen_json[sizeof(JSON)]; \\ } VARNAME = { { 4, 0x407c0c0aU }, JSON } #define DLNOTE_INT(JSON,VARNAME) DLNOTE_INT2(JSON,VARNAME) #define DLNOTE(P,...) DLNOTE_INT("[" P "," ARR(__VA_ARGS__) "]", UNIQ) DLNOTE("required", "liba.so.0"); DLNOTE("recommended", "libb.so.0", "libb.so.1"); int main(int argc, char *argv[]) { return argc + argv[0][1]; } ]==] COMPILER_SUPPORTS_ELFNOTES)
Description
Existing Issue(s)
Closes #14214