Commit c5b3de6
committed
[COFF] Emit embedded -exclude-symbols: directives for hidden visibility for MinGW
This works with the automatic export of all symbols; in MinGW mode, when a DLL has no explicit dllexports, it exports all symbols (except for some that are hardcoded to be excluded, including some toolchain libraries). By hooking up the hidden visibility to the -exclude-symbols: directive, the automatic export of all symbols can be controlled in an easier way (with a mechanism that doesn't require strict annotation of every single symbol, but which allows gradually marking more unnecessary symbols as hidden). The primary use case is dylib builds of LLVM/Clang. These can be done in MinGW mode but not in MSVC mode, as MinGW builds can export all symbols (and the calling code can use APIs without corresponding dllimport directives). However, as all symbols are exported, it can easily overflow the max number of exported symbols in a DLL (65536). In the llvm-mingw distribution, only the X86, ARM and AArch64 backends are enabled; for the LLVM 13.0.0 release, libLLVM-13.dll ended up with 58112 exported symbols. For LLVM 14.0.0, it was 62015 symbols. Current builds of the 15.x branch end up at around 64650 symbols - i.e. extremely close to the limit. The msys2 packages of LLVM have had to progressively disable more of their backends in their builds, to be able to keep building with a dylib. This allows improving the current mingw dylib situation significantly, by using the same hidden visibility options and attributes as on Unix. With those in place, a current build of LLVM git main ends up at 35142 symbols instead of 64650. For code using hidden visibility, this now requires linking with either a current git lld or ld.bfd. (Older lld error out on the unknown directives, older ld.bfd will successfully link, but will print huge amounts of warnings.) Differential Revision: https://reviews.llvm.org/D1301211 parent 5d513ef commit c5b3de6
File tree
3 files changed
+129
-20
lines changed- llvm
- docs
- lib/IR
- test/CodeGen/X86
3 files changed
+129
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
111 | 119 | | |
112 | 120 | | |
113 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | | - | |
| 213 | + | |
215 | 214 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
220 | 252 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | 253 | | |
226 | 254 | | |
227 | 255 | | |
| |||
230 | 258 | | |
231 | 259 | | |
232 | 260 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | 261 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
| 262 | + | |
| 263 | + | |
244 | 264 | | |
245 | 265 | | |
246 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments