reduce the amount of symbols exposed by the library
authorAndreas Beckmann <anbe@debian.org>
Thu, 3 Aug 2023 09:46:40 +0000 (10:46 +0100)
committerAndreas Beckmann <anbe@debian.org>
Thu, 3 Aug 2023 09:46:40 +0000 (10:46 +0100)
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 8c73b644f0f5c48361f804e0e4d3073ab7fb93f6..e009958646f71aeb152a80fa1a44a41eae07c38b 100644 (file)
@@ -48,6 +48,8 @@
 #include <map>
 #include <unordered_map>
 
+#pragma GCC visibility push(default)
+
 namespace llvm {
 class IntrinsicInst;
 } // namespace llvm
@@ -225,4 +227,6 @@ private:
 
 } // namespace SPIRV
 
+#pragma GCC visibility pop
+
 #endif // SPIRV_LLVMSPIRVOPTS_H
index b5c14cbe5baf769b2d1d6c57ac408d70b8ff1d5c..243e11671649f4c04f346ab967e0ee3b76fb7774 100644 (file)
@@ -2137,6 +2137,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;
@@ -2173,6 +2174,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 8a9e0a48548d365ea6a2a0b5236d84c8580686d6..496dc0c78d61636fd9a8001bd82e633c6ef7d0e8 100644 (file)
@@ -81,6 +81,7 @@ static void readQuotedString(std::istream &IS, std::string &Str) {
 }
 
 #ifdef _SPIRV_SUPPORT_TEXT_FMT
+__attribute__ ((visibility ("default")))
 bool SPIRVUseTextFormat = false;
 #endif