reduce the amount of symbols exposed by the library
authorAndreas Beckmann <anbe@debian.org>
Tue, 18 Jun 2024 12:51:41 +0000 (14:51 +0200)
committerAndreas Beckmann <anbe@debian.org>
Tue, 18 Jun 2024 12:51:41 +0000 (14:51 +0200)
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 14ac386cb802a9cb92f634f5cf1c3aa0b0bc1491..be52f8df1775063b53ad1786484ccb1e2e852a53 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 4957fff13d3a236efdbe5700ec0b7d0c0ff97f70..7728175a5b679ac07007f9f41ca9189cc6e120be 100644 (file)
@@ -2274,6 +2274,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;
@@ -2310,6 +2311,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 d6f1d698312c9c98c7f22d7ed7732cbe7d6e41df..7c777ffc221548432ba9139ffb6c1a21736097bf 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