File: visibility-hidden.patch

package info (click to toggle)
spirv-llvm-translator-17 17.0.18-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 16,044 kB
  • sloc: cpp: 50,192; lisp: 3,609; sh: 153; python: 44; makefile: 40
file content (93 lines) | stat: -rw-r--r-- 2,420 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Author: Andreas Beckmann <anbe@debian.org>
Description: reduce the amount of symbols exposed by the library
Forwarded: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/1963

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -142,6 +142,9 @@ if (NOT SPIRV_TOOLS_FOUND)
 endif()
 
 
+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)
--- a/include/LLVMSPIRVLib.h
+++ b/include/LLVMSPIRVLib.h
@@ -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;
@@ -256,4 +262,6 @@ FunctionPass *createSPIRVLowerBitCastToN
 
 } // namespace llvm
 
+#pragma GCC visibility pop
+
 #endif // SPIRV_H
--- a/include/LLVMSPIRVOpts.h
+++ b/include/LLVMSPIRVOpts.h
@@ -48,6 +48,8 @@
 #include <optional>
 #include <unordered_map>
 
+#pragma GCC visibility push(default)
+
 namespace llvm {
 class IntrinsicInst;
 } // namespace llvm
@@ -341,4 +343,6 @@ private:
 
 } // namespace SPIRV
 
+#pragma GCC visibility pop
+
 #endif // SPIRV_LLVMSPIRVOPTS_H
--- a/lib/SPIRV/libSPIRV/SPIRVStream.cpp
+++ b/lib/SPIRV/libSPIRV/SPIRVStream.cpp
@@ -82,6 +82,7 @@ static void readQuotedString(std::istrea
 }
 
 #ifdef _SPIRV_SUPPORT_TEXT_FMT
+__attribute__ ((visibility ("default")))
 bool SPIRVUseTextFormat = false;
 #endif
 
--- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp
+++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
@@ -2478,6 +2478,7 @@ bool isSpirvBinary(const std::string &Im
 
 #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;
@@ -2514,6 +2515,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);