Commit 5e9e95c
committed
kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion
When CONFIG_TRIM_UNUSED_KSYMS is enabled, Kbuild recursively traverses
the directory tree to determine which EXPORT_SYMBOL to trim. If an
EXPORT_SYMBOL turns out to be unused by anyone, Kbuild begins the
second traverse, where some source files are recompiled with their
EXPORT_SYMBOL() tuned into a no-op.
Linus stated negative opinions about this slowness in commits:
- 5cf0fd5 ("Kbuild: disable TRIM_UNUSED_KSYMS option")
- a555bdd ("Kbuild: enable TRIM_UNUSED_KSYMS again, with some guarding")
We can do this better now. The final data structures of EXPORT_SYMBOL
are generated by the modpost stage, so modpost can selectively emit
KSYMTAB entries that are really used by modules.
Commit f73edc8 ("kbuild: unify two modpost invocations") is another
ground-work to do this in a one-pass algorithm. With the list of modules,
modpost sets sym->used if it is used by a module. modpost emits KSYMTAB
only for symbols with sym->used==true.
BTW, Nicolas explained why the trimming was implemented with recursion:
https://lore.kernel.org/all/[email protected]/
Actually, we never achieved that level of optimization where the chain
reaction of trimming comes into play because:
- CONFIG_LTO_CLANG cannot remove any unused symbols
- CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is enabled only for vmlinux,
but not modules
If deeper trimming is required, we need to revisit this, but I guess
that is unlikely to happen.
Signed-off-by: Masahiro Yamada <[email protected]>1 parent 700c48b commit 5e9e95c
11 files changed
Lines changed: 78 additions & 264 deletions
File tree
- include/linux
- scripts
- basic
- mod
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
| |||
112 | 111 | | |
113 | 112 | | |
114 | 113 | | |
115 | | - | |
116 | 114 | | |
117 | 115 | | |
118 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1193 | 1193 | | |
1194 | 1194 | | |
1195 | 1195 | | |
1196 | | - | |
1197 | | - | |
1198 | 1196 | | |
1199 | 1197 | | |
1200 | 1198 | | |
1201 | | - | |
1202 | 1199 | | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
1206 | | - | |
1207 | 1200 | | |
1208 | 1201 | | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
1216 | | - | |
1217 | | - | |
1218 | 1202 | | |
1219 | 1203 | | |
1220 | 1204 | | |
| |||
1223 | 1207 | | |
1224 | 1208 | | |
1225 | 1209 | | |
1226 | | - | |
| 1210 | + | |
1227 | 1211 | | |
1228 | 1212 | | |
1229 | 1213 | | |
| |||
1279 | 1263 | | |
1280 | 1264 | | |
1281 | 1265 | | |
1282 | | - | |
| 1266 | + | |
1283 | 1267 | | |
1284 | 1268 | | |
1285 | 1269 | | |
| |||
2039 | 2023 | | |
2040 | 2024 | | |
2041 | 2025 | | |
2042 | | - | |
| 2026 | + | |
2043 | 2027 | | |
2044 | 2028 | | |
2045 | 2029 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | 53 | | |
72 | 54 | | |
73 | 55 | | |
| |||
77 | 59 | | |
78 | 60 | | |
79 | 61 | | |
80 | | - | |
| 62 | + | |
81 | 63 | | |
82 | | - | |
| 64 | + | |
83 | 65 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
| 66 | + | |
105 | 67 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 68 | + | |
| 69 | + | |
120 | 70 | | |
121 | 71 | | |
122 | 72 | | |
123 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
124 | 77 | | |
125 | 78 | | |
126 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | 220 | | |
226 | 221 | | |
227 | 222 | | |
228 | 223 | | |
229 | 224 | | |
230 | 225 | | |
231 | | - | |
232 | 226 | | |
233 | 227 | | |
234 | 228 | | |
| |||
239 | 233 | | |
240 | 234 | | |
241 | 235 | | |
242 | | - | |
243 | 236 | | |
244 | 237 | | |
245 | 238 | | |
| |||
258 | 251 | | |
259 | 252 | | |
260 | 253 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | 254 | | |
268 | 255 | | |
269 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
94 | 101 | | |
95 | 102 | | |
96 | 103 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
250 | | - | |
| 249 | + | |
251 | 250 | | |
252 | 251 | | |
253 | 252 | | |
| |||
This file was deleted.
0 commit comments