Commit d64e8599 by Ben Clayton

glslang: Only export public interface for SOs

Default to `-fvisibility=hidden`, and annotate the public glslang interface with `GLSLANG_EXPORT` to change the visibility of these cherry-picked symbols to default. This is also used by Windows builds for `__declspec(dllexport)`-ing the public DLL interface. This allows us to classify API changes into those that are publicly backwards compatible, and those that are not. Note that `libSPIRV` will likely need similar treatment. Issues: #2283, #1484
parent c858d7bd
...@@ -205,6 +205,21 @@ if(BUILD_EXTERNAL AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/External) ...@@ -205,6 +205,21 @@ if(BUILD_EXTERNAL AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/External)
add_subdirectory(External) add_subdirectory(External)
endif() endif()
# glslang_only_export_explicit_symbols() makes the symbol visibility hidden by
# default for <target> when building shared libraries, and sets the
# GLSLANG_IS_SHARED_LIBRARY define, and GLSLANG_EXPORTING to 1 when specifically
# building <target>.
function(glslang_only_export_explicit_symbols target)
target_compile_definitions(${target} PUBLIC "GLSLANG_IS_SHARED_LIBRARY=1")
if(BUILD_SHARED_LIBS)
if(WIN32)
target_compile_definitions(${target} PRIVATE "GLSLANG_EXPORTING=1")
else()
target_compile_options(${target} PRIVATE "-fvisibility=hidden")
endif()
endif()
endfunction()
if(NOT TARGET SPIRV-Tools-opt) if(NOT TARGET SPIRV-Tools-opt)
set(ENABLE_OPT OFF) set(ENABLE_OPT OFF)
endif() endif()
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
#include "../glslang/OSDependent/osinclude.h" #include "../glslang/OSDependent/osinclude.h"
extern "C" { extern "C" {
SH_IMPORT_EXPORT void ShOutputHtml(); GLSLANG_EXPORT void ShOutputHtml();
} }
// Command-line options // Command-line options
......
...@@ -132,6 +132,8 @@ target_include_directories(glslang PUBLIC ...@@ -132,6 +132,8 @@ target_include_directories(glslang PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
glslang_only_export_explicit_symbols(glslang)
if(WIN32 AND BUILD_SHARED_LIBS) if(WIN32 AND BUILD_SHARED_LIBS)
set_target_properties(glslang PROPERTIES PREFIX "") set_target_properties(glslang PROPERTIES PREFIX "")
endif() endif()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment