Skip to content

Commit

Permalink
Add a version script for non-Windows/macOS systems
Browse files Browse the repository at this point in the history
To more aggressively control library exports. Despite the -fvisibility=hidden
flag that should hide everything by default, GNU's libstdc++ forces default
visibility for generated std namespace symbols (from template functions that
don't inline, for example), adding some standard C++ symbols to the exported
symbol list. This can cause ABI problems if an app links to OpenAL and uses one
of those symbols, as a future internal change can cause the function to not be
generated and make the symbol no longer available. There seems to be no way to
prevent this, aside from this version script.

This has the added advantage of ensuring future extension functions don't
accidentally get exported due to the ALC_API or AL_API macros making them
visible.
  • Loading branch information
kcat committed Apr 10, 2023
1 parent 3853e31 commit 31f3336
Show file tree
Hide file tree
Showing 2 changed files with 204 additions and 4 deletions.
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ set(OPENAL_OBJS
al/effects/dedicated.cpp
al/effects/distortion.cpp
al/effects/echo.cpp
al/effects/effects.cpp
al/effects/effects.cpp
al/effects/effects.h
al/effects/equalizer.cpp
al/effects/fshifter.cpp
Expand Down Expand Up @@ -801,7 +801,7 @@ set(ALC_OBJS
alc/inprogext.h
alc/panning.cpp)

if (ALSOFT_EAX)
if(ALSOFT_EAX)
set(OPENAL_OBJS
${OPENAL_OBJS}
al/eax/api.cpp
Expand All @@ -820,8 +820,8 @@ if (ALSOFT_EAX)
al/eax/utils.cpp
al/eax/utils.h
al/eax/x_ram.h
)
endif ()
)
endif()

# Include SIMD mixers
set(CPU_EXTS "Default")
Expand Down Expand Up @@ -1373,13 +1373,21 @@ else()
# the project
set(TARGET_PUBLIC_HEADERS include/AL/al.h include/AL/alc.h include/AL/alext.h include/AL/efx.h
include/AL/efx-presets.h)

add_library(${IMPL_TARGET} SHARED ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS} ${RC_CONFIG}
${TARGET_PUBLIC_HEADERS})
if(WIN32)
set_target_properties(${IMPL_TARGET} PROPERTIES PREFIX "")
endif()
target_link_libraries(${IMPL_TARGET} PRIVATE common ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})

if(NOT WIN32 AND NOT APPLE)
# FIXME: This doesn't put a dependency on the version script. Changing
# the version script will not cause a relink as it should.
set_property(TARGET ${IMPL_TARGET} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--version-script=${OpenAL_SOURCE_DIR}/libopenal.version")
endif()

if(APPLE AND ALSOFT_OSX_FRAMEWORK)
# Sets framework name to soft_oal to avoid ambiguity with the system OpenAL.framework
set(LIBNAME "soft_oal")
Expand Down
192 changes: 192 additions & 0 deletions libopenal.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
{
global:
alBuffer3f;
alBuffer3i;
alBufferData;
alBufferf;
alBufferfv;
alBufferi;
alBufferiv;
alcCaptureCloseDevice;
alcCaptureOpenDevice;
alcCaptureSamples;
alcCaptureStart;
alcCaptureStop;
alcCloseDevice;
alcCreateContext;
alcDestroyContext;
alcGetContextsDevice;
alcGetCurrentContext;
alcGetEnumValue;
alcGetError;
alcGetIntegerv;
alcGetProcAddress;
alcGetString;
alcIsExtensionPresent;
alcMakeContextCurrent;
alcOpenDevice;
alcProcessContext;
alcSuspendContext;
alDeleteBuffers;
alDeleteSources;
alDisable;
alDistanceModel;
alDopplerFactor;
alEnable;
alGenBuffers;
alGenSources;
alGetBoolean;
alGetBooleanv;
alGetBuffer3f;
alGetBuffer3i;
alGetBufferf;
alGetBufferfv;
alGetBufferi;
alGetBufferiv;
alGetDouble;
alGetDoublev;
alGetEnumValue;
alGetError;
alGetFloat;
alGetFloatv;
alGetInteger;
alGetIntegerv;
alGetListener3f;
alGetListener3i;
alGetListenerf;
alGetListenerfv;
alGetListeneri;
alGetListeneriv;
alGetProcAddress;
alGetSource3f;
alGetSource3i;
alGetSourcef;
alGetSourcefv;
alGetSourcei;
alGetSourceiv;
alGetString;
alIsBuffer;
alIsEnabled;
alIsExtensionPresent;
alIsSource;
alListener3f;
alListener3i;
alListenerf;
alListenerfv;
alListeneri;
alListeneriv;
alSource3f;
alSource3i;
alSourcef;
alSourcefv;
alSourcei;
alSourceiv;
alSourcePause;
alSourcePausev;
alSourcePlay;
alSourcePlayv;
alSourceQueueBuffers;
alSourceRewind;
alSourceRewindv;
alSourceStop;
alSourceStopv;
alSourceUnqueueBuffers;
alSpeedOfSound;

# Deprecated in AL 1.1, kept for compatibility.
alDopplerVelocity;

# EFX, effectively standard at this point.
alAuxiliaryEffectSlotf;
alAuxiliaryEffectSlotfv;
alAuxiliaryEffectSloti;
alAuxiliaryEffectSlotiv;
alDeleteAuxiliaryEffectSlots;
alDeleteEffects;
alDeleteFilters;
alEffectf;
alEffectfv;
alEffecti;
alEffectiv;
alFilterf;
alFilterfv;
alFilteri;
alFilteriv;
alGenAuxiliaryEffectSlots;
alGenEffects;
alGenFilters;
alGetAuxiliaryEffectSlotf;
alGetAuxiliaryEffectSlotfv;
alGetAuxiliaryEffectSloti;
alGetAuxiliaryEffectSlotiv;
alGetEffectf;
alGetEffectfv;
alGetEffecti;
alGetEffectiv;
alGetFilterf;
alGetFilterfv;
alGetFilteri;
alGetFilteriv;
alIsAuxiliaryEffectSlot;
alIsEffect;
alIsFilter;

# Non-standard
alsoft_get_version;

# These extension functions shouldn't be exported here, but they were exported
# by mistake in previous releases, so need to stay for compatibility with apps
# that may have directly linked to them. Remove them if it can be done without
# breaking anything.
alAuxiliaryEffectSlotPlaySOFT;
alAuxiliaryEffectSlotPlayvSOFT;
alAuxiliaryEffectSlotStopSOFT;
alAuxiliaryEffectSlotStopvSOFT;
alBufferCallbackSOFT;
alBufferSamplesSOFT;
alBufferStorageSOFT;
alBufferSubDataSOFT;
alBufferSubSamplesSOFT;
alcDevicePauseSOFT;
alcDeviceResumeSOFT;
alcGetInteger64vSOFT;
alcGetStringiSOFT;
alcGetThreadContext;
alcIsRenderFormatSupportedSOFT;
alcLoopbackOpenDeviceSOFT;
alcRenderSamplesSOFT;
alcResetDeviceSOFT;
alcSetThreadContext;
alDeferUpdatesSOFT;
alEventCallbackSOFT;
alEventControlSOFT;
alFlushMappedBufferSOFT;
alGetBuffer3PtrSOFT;
alGetBufferPtrSOFT;
alGetBufferPtrvSOFT;
alGetBufferSamplesSOFT;
alGetInteger64SOFT;
alGetInteger64vSOFT;
alGetPointerSOFT;
alGetPointervSOFT;
alGetSource3dSOFT;
alGetSource3i64SOFT;
alGetSourcedSOFT;
alGetSourcedvSOFT;
alGetSourcei64SOFT;
alGetSourcei64vSOFT;
alGetStringiSOFT;
alIsBufferFormatSupportedSOFT;
alMapBufferSOFT;
alProcessUpdatesSOFT;
alSource3dSOFT;
alSource3i64SOFT;
alSourcedSOFT;
alSourcedvSOFT;
alSourcei64SOFT;
alSourcei64vSOFT;
alSourceQueueBufferLayersSOFT;
alUnmapBufferSOFT;

local: *;
};

0 comments on commit 31f3336

Please sign in to comment.