reduce the amount of symbols exposed by the library
authorAndreas Beckmann <anbe@debian.org>
Thu, 8 Feb 2024 21:48:18 +0000 (22:48 +0100)
committerAndreas Beckmann <anbe@debian.org>
Thu, 8 Feb 2024 21:48:18 +0000 (22:48 +0100)
Forwarded: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/1963

Gbp-Pq: Name visibility-hidden.patch

CMakeLists.txt
include/LLVMSPIRVLib.h
include/LLVMSPIRVOpts.h
lib/SPIRV/libSPIRV/SPIRVModule.cpp
lib/SPIRV/libSPIRV/SPIRVStream.cpp

index 08980f2fcc6b510f1a31be49a78708ee125bbf3c..439e28d2f11a53f65cc7ae5de9b2a37fc38c4e9a 100644 (file)
@@ -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($<$<COMPILE_LANGUAGE:CXX>:-fvisibility-inlines-hidden>)
+
 add_subdirectory(lib/SPIRV)
 add_subdirectory(tools/llvm-spirv)
 if(LLVM_SPIRV_INCLUDE_TESTS)
index 71023853b7e5679f2cd94c94e0d9369a371e3581..051732659c5b538c0ca2bb47b4daf2eba2d78708 100644 (file)
@@ -46,6 +46,8 @@
 #include <iostream>
 #include <string>
 
+#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
index fa1df5fd3645d0a935300fd0870da92466eff0a3..92917ebc9a729cdb6df025cf7cc3ae7191690291 100644 (file)
@@ -48,6 +48,8 @@
 #include <map>
 #include <unordered_map>
 
+#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
index bfe421796adef49dc462cd8af1f782e6c226be2f..da9e355f886c3ca8dbb834ffdc964089f53f208c 100644 (file)
@@ -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);
index 65ca5cbb6123229a1bf87af85cd4d56938ebcb71..8539d7c5a42a4491d3491c17af1677b16f084de3 100644 (file)
@@ -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