feat: impl export-executable-symbols
This commit is contained in:
parent
babff2211e
commit
6674c94d15
7 changed files with 42 additions and 5 deletions
|
@ -2082,7 +2082,12 @@ fn add_order_independent_options(
|
|||
// sections to ensure we have all the data for PGO.
|
||||
let keep_metadata =
|
||||
crate_type == CrateType::Dylib || sess.opts.cg.profile_generate.enabled();
|
||||
cmd.gc_sections(keep_metadata);
|
||||
if crate_type != CrateType::Executable || !sess.opts.unstable_opts.export_executable_symbols
|
||||
{
|
||||
cmd.gc_sections(keep_metadata);
|
||||
} else {
|
||||
cmd.no_gc_sections();
|
||||
}
|
||||
}
|
||||
|
||||
cmd.set_output_kind(link_output_kind, out_filename);
|
||||
|
|
|
@ -640,9 +640,14 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
|
||||
fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[String]) {
|
||||
// Symbol visibility in object files typically takes care of this.
|
||||
if crate_type == CrateType::Executable && self.sess.target.override_export_symbols.is_none()
|
||||
{
|
||||
return;
|
||||
if crate_type == CrateType::Executable {
|
||||
let should_export_executable_symbols =
|
||||
self.sess.opts.unstable_opts.export_executable_symbols;
|
||||
if self.sess.target.override_export_symbols.is_none()
|
||||
&& !should_export_executable_symbols
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// We manually create a list of exported symbols to ensure we don't expose any more.
|
||||
|
@ -969,7 +974,11 @@ impl<'a> Linker for MsvcLinker<'a> {
|
|||
fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[String]) {
|
||||
// Symbol visibility takes care of this typically
|
||||
if crate_type == CrateType::Executable {
|
||||
return;
|
||||
let should_export_executable_symbols =
|
||||
self.sess.opts.unstable_opts.export_executable_symbols;
|
||||
if !should_export_executable_symbols {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let path = tmpdir.join("lib.def");
|
||||
|
|
|
@ -733,6 +733,7 @@ fn test_unstable_options_tracking_hash() {
|
|||
tracked!(debug_macros, true);
|
||||
tracked!(dep_info_omit_d_target, true);
|
||||
tracked!(drop_tracking, true);
|
||||
tracked!(export_executable_symbols, true);
|
||||
tracked!(dual_proc_macros, true);
|
||||
tracked!(dwarf_version, Some(5));
|
||||
tracked!(emit_thin_lto, false);
|
||||
|
|
|
@ -1282,6 +1282,8 @@ options! {
|
|||
"emit a section containing stack size metadata (default: no)"),
|
||||
emit_thin_lto: bool = (true, parse_bool, [TRACKED],
|
||||
"emit the bc module with thin LTO info (default: yes)"),
|
||||
export_executable_symbols: bool = (false, parse_bool, [TRACKED],
|
||||
"export symbols from executables, as if they were dynamic libraries"),
|
||||
fewer_names: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
"reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
|
||||
(default: no)"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue