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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue