Skip to content

Commit 6d29eac

Browse files
committed
Revert "Auto merge of #118568 - DianQK:no-builtins-symbols, r=pnkfelix"
This reverts commit 503e129, reversing changes made to 0e7f91b.
1 parent 2b1365b commit 6d29eac

File tree

6 files changed

+4
-30
lines changed

6 files changed

+4
-30
lines changed

compiler/rustc_codegen_llvm/src/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn prepare_lto(
6060
};
6161

6262
let symbol_filter = &|&(ref name, info): &(String, SymbolExportInfo)| {
63-
if info.level.is_below_threshold(export_threshold) || info.used || info.used_compiler {
63+
if info.level.is_below_threshold(export_threshold) || info.used {
6464
Some(CString::new(name.as_str()).unwrap())
6565
} else {
6666
None

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,20 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
105105
}
106106
})
107107
.map(|def_id| {
108-
let codegen_attrs = tcx.codegen_fn_attrs(def_id.to_def_id());
109108
// We won't link right if this symbol is stripped during LTO.
110109
let name = tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())).name;
111110
// We have to preserve the symbols of the built-in functions during LTO.
112111
let is_builtin_fn = is_compiler_builtins
113112
&& symbol_export_level(tcx, def_id.to_def_id())
114-
.is_below_threshold(SymbolExportLevel::C)
115-
&& codegen_attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE);
116-
let used = name == "rust_eh_personality";
113+
.is_below_threshold(SymbolExportLevel::C);
114+
let used = is_builtin_fn || name == "rust_eh_personality";
117115

118116
let export_level = if special_runtime_crate {
119117
SymbolExportLevel::Rust
120118
} else {
121119
symbol_export_level(tcx, def_id.to_def_id())
122120
};
121+
let codegen_attrs = tcx.codegen_fn_attrs(def_id.to_def_id());
123122
debug!(
124123
"EXPORTED SYMBOL (local): {} ({:?})",
125124
tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())),
@@ -139,7 +138,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
139138
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED)
140139
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
141140
|| used,
142-
used_compiler: is_builtin_fn,
143141
};
144142
(def_id.to_def_id(), info)
145143
})
@@ -152,7 +150,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
152150
level: SymbolExportLevel::C,
153151
kind: SymbolExportKind::Data,
154152
used: false,
155-
used_compiler: false,
156153
},
157154
);
158155
}
@@ -201,7 +198,6 @@ fn exported_symbols_provider_local(
201198
level: info.level,
202199
kind: SymbolExportKind::Text,
203200
used: info.used,
204-
used_compiler: false,
205201
},
206202
)
207203
})
@@ -218,7 +214,6 @@ fn exported_symbols_provider_local(
218214
level: SymbolExportLevel::C,
219215
kind: SymbolExportKind::Text,
220216
used: false,
221-
used_compiler: false,
222217
},
223218
));
224219
}
@@ -238,7 +233,6 @@ fn exported_symbols_provider_local(
238233
level: SymbolExportLevel::Rust,
239234
kind: SymbolExportKind::Text,
240235
used: false,
241-
used_compiler: false,
242236
},
243237
));
244238
}
@@ -251,7 +245,6 @@ fn exported_symbols_provider_local(
251245
level: SymbolExportLevel::Rust,
252246
kind: SymbolExportKind::Data,
253247
used: false,
254-
used_compiler: false,
255248
},
256249
))
257250
}
@@ -271,7 +264,6 @@ fn exported_symbols_provider_local(
271264
level: SymbolExportLevel::C,
272265
kind: SymbolExportKind::Data,
273266
used: false,
274-
used_compiler: false,
275267
},
276268
)
277269
}));
@@ -297,7 +289,6 @@ fn exported_symbols_provider_local(
297289
level: SymbolExportLevel::C,
298290
kind: SymbolExportKind::Data,
299291
used: false,
300-
used_compiler: false,
301292
},
302293
)
303294
}));
@@ -315,7 +306,6 @@ fn exported_symbols_provider_local(
315306
level: SymbolExportLevel::C,
316307
kind: SymbolExportKind::Data,
317308
used: true,
318-
used_compiler: false,
319309
},
320310
));
321311
}
@@ -356,7 +346,6 @@ fn exported_symbols_provider_local(
356346
level: SymbolExportLevel::Rust,
357347
kind: SymbolExportKind::Text,
358348
used: false,
359-
used_compiler: false,
360349
},
361350
));
362351
}
@@ -373,7 +362,6 @@ fn exported_symbols_provider_local(
373362
level: SymbolExportLevel::Rust,
374363
kind: SymbolExportKind::Text,
375364
used: false,
376-
used_compiler: false,
377365
},
378366
));
379367
}

compiler/rustc_middle/src/middle/exported_symbols.rs

-5
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@ pub enum SymbolExportKind {
3535
pub struct SymbolExportInfo {
3636
pub level: SymbolExportLevel,
3737
pub kind: SymbolExportKind,
38-
/// Used to mark these symbols not to be internalized by LTO. These symbols
39-
/// are also added to `symbols.o` to avoid circular dependencies when linking.
4038
pub used: bool,
41-
/// Also used to mark these symbols not to be internalized by LTO. But will
42-
/// not be added to `symbols.o`. Currently there are only builtin functions.
43-
pub used_compiler: bool,
4439
}
4540

4641
#[derive(Eq, PartialEq, Debug, Copy, Clone, TyEncodable, TyDecodable, HashStable)]

src/tools/miri/src/bin/miri.rs

-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
165165
level: SymbolExportLevel::C,
166166
kind: SymbolExportKind::Text,
167167
used: false,
168-
used_compiler: false,
169168
},
170169
))
171170
}),

tests/run-make/no-builtins-symbols/Makefile

-7
This file was deleted.

tests/run-make/no-builtins-symbols/main.rs

-1
This file was deleted.

0 commit comments

Comments
 (0)