From: Andreas Beckmann Date: Thu, 14 Mar 2024 19:01:08 +0000 (+0100) Subject: reduce the amount of symbols exposed by the library X-Git-Tag: archive/raspbian/15.0.1-1+rpi1^2^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=47dd2302ea4b98dd2b807ee06bf6fbdd4a24e98c;p=spirv-llvm-translator-15.git reduce the amount of symbols exposed by the library Forwarded: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/1963 Gbp-Pq: Name visibility-hidden.patch --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 08980f2..439e28d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,6 +117,9 @@ if(NOT SPIRV_TOOLS_FOUND) "--spirv-tools-dis support.") endif(NOT SPIRV_TOOLS_FOUND) +add_compile_options(-fvisibility=hidden) +add_compile_options($<$:-fvisibility-inlines-hidden>) + add_subdirectory(lib/SPIRV) add_subdirectory(tools/llvm-spirv) if(LLVM_SPIRV_INCLUDE_TESTS) diff --git a/include/LLVMSPIRVLib.h b/include/LLVMSPIRVLib.h index 7102385..0517326 100644 --- a/include/LLVMSPIRVLib.h +++ b/include/LLVMSPIRVLib.h @@ -46,6 +46,8 @@ #include #include +#pragma GCC visibility push(default) + namespace llvm { // Pass initialization functions need to be declared before inclusion of // PassSupport.h. @@ -68,8 +70,12 @@ class ModulePass; class FunctionPass; } // namespace llvm +#pragma GCC visibility pop + #include "llvm/IR/Module.h" +#pragma GCC visibility push(default) + namespace SPIRV { class SPIRVModule; @@ -229,4 +235,6 @@ FunctionPass *createSPIRVLowerBitCastToNonStandardTypeLegacy( } // namespace llvm +#pragma GCC visibility pop + #endif // SPIRV_H diff --git a/include/LLVMSPIRVOpts.h b/include/LLVMSPIRVOpts.h index fa1df5f..92917eb 100644 --- a/include/LLVMSPIRVOpts.h +++ b/include/LLVMSPIRVOpts.h @@ -48,6 +48,8 @@ #include #include +#pragma GCC visibility push(default) + namespace llvm { class IntrinsicInst; } // namespace llvm @@ -245,4 +247,6 @@ private: } // namespace SPIRV +#pragma GCC visibility pop + #endif // SPIRV_LLVMSPIRVOPTS_H diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/lib/SPIRV/libSPIRV/SPIRVModule.cpp index bfe4217..da9e355 100644 --- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp @@ -2251,6 +2251,7 @@ bool isSpirvBinary(const std::string &Img) { #ifdef _SPIRV_SUPPORT_TEXT_FMT +__attribute__ ((visibility ("default"))) bool convertSpirv(std::istream &IS, std::ostream &OS, std::string &ErrMsg, bool FromText, bool ToText) { auto SaveOpt = SPIRVUseTextFormat; @@ -2287,6 +2288,7 @@ bool isSpirvText(const std::string &Img) { return Magic == MagicNumber; } +__attribute__ ((visibility ("default"))) bool convertSpirv(std::string &Input, std::string &Out, std::string &ErrMsg, bool ToText) { auto FromText = isSpirvText(Input); diff --git a/lib/SPIRV/libSPIRV/SPIRVStream.cpp b/lib/SPIRV/libSPIRV/SPIRVStream.cpp index 65ca5cb..8539d7c 100644 --- a/lib/SPIRV/libSPIRV/SPIRVStream.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVStream.cpp @@ -82,6 +82,7 @@ static void readQuotedString(std::istream &IS, std::string &Str) { } #ifdef _SPIRV_SUPPORT_TEXT_FMT +__attribute__ ((visibility ("default"))) bool SPIRVUseTextFormat = false; #endif