-
Notifications
You must be signed in to change notification settings - Fork 237
Open
Description
As the $subject says, we should provide an exported symbols list to
linker for Apple Mach-O targets, in order to prevent prevent third-
party symbols from leaking into our library: such may be the case if
we statically link a vendored library to us, e.g. libjxl which leaks
libjxl and brotli symbols into SDL_image.
Reference issue: libsdl-org/libjxl#2
We can generate an exports file at cmake configuration time from the
existing version script file, like below:
set(sdlimage_exports)
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/src/SDL_image.sym" sdlimage_exports_strings)
foreach(sdlimage_export_string ${sdlimage_exports_strings})
string(STRIP "${sdlimage_export_string}" sdlimage_export_string)
string(REGEX REPLACE "\;" "" sdlimage_export_string "${sdlimage_export_string}")
if(sdlimage_export_string MATCHES "IMG_.*")
# Prepend '_' to symbol name for Mach-O
set(sdlimage_exports "${sdlimage_exports}_${sdlimage_export_string}\n")
endif()
endforeach()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/SDL_image.exports" "${sdlimage_exports}")
# then add:
#
# -Wl,-exported_symbols_list,'${CMAKE_CURRENT_BINARY_DIR}/SDL_image.exports'
#
# to linker flagsIf we do this, we should do it similary in SDL_mixer and SDL_ttf, too.
Leaving implementation to @madebr
/cc @slouken
/cc @elevenfive
Metadata
Metadata
Assignees
Labels
No labels