mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
Avoid adding compiler-used functions to symbols.o
This commit is contained in:
parent
7ceaf19868
commit
9ed0d11efb
@ -60,7 +60,7 @@ fn prepare_lto(
|
||||
};
|
||||
|
||||
let symbol_filter = &|&(ref name, info): &(String, SymbolExportInfo)| {
|
||||
if info.level.is_below_threshold(export_threshold) || info.used {
|
||||
if info.level.is_below_threshold(export_threshold) || info.used || info.used_compiler {
|
||||
Some(CString::new(name.as_str()).unwrap())
|
||||
} else {
|
||||
None
|
||||
|
@ -111,7 +111,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
|
||||
let is_builtin_fn = is_compiler_builtins
|
||||
&& symbol_export_level(tcx, def_id.to_def_id())
|
||||
.is_below_threshold(SymbolExportLevel::C);
|
||||
let used = is_builtin_fn || name == "rust_eh_personality";
|
||||
let used = name == "rust_eh_personality";
|
||||
|
||||
let export_level = if special_runtime_crate {
|
||||
SymbolExportLevel::Rust
|
||||
@ -138,6 +138,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
|
||||
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED)
|
||||
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
|
||||
|| used,
|
||||
used_compiler: is_builtin_fn,
|
||||
};
|
||||
(def_id.to_def_id(), info)
|
||||
})
|
||||
@ -150,6 +151,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
|
||||
level: SymbolExportLevel::C,
|
||||
kind: SymbolExportKind::Data,
|
||||
used: false,
|
||||
used_compiler: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -198,6 +200,7 @@ fn exported_symbols_provider_local(
|
||||
level: info.level,
|
||||
kind: SymbolExportKind::Text,
|
||||
used: info.used,
|
||||
used_compiler: false,
|
||||
},
|
||||
)
|
||||
})
|
||||
@ -214,6 +217,7 @@ fn exported_symbols_provider_local(
|
||||
level: SymbolExportLevel::C,
|
||||
kind: SymbolExportKind::Text,
|
||||
used: false,
|
||||
used_compiler: false,
|
||||
},
|
||||
));
|
||||
}
|
||||
@ -233,6 +237,7 @@ fn exported_symbols_provider_local(
|
||||
level: SymbolExportLevel::Rust,
|
||||
kind: SymbolExportKind::Text,
|
||||
used: false,
|
||||
used_compiler: false,
|
||||
},
|
||||
));
|
||||
}
|
||||
@ -245,6 +250,7 @@ fn exported_symbols_provider_local(
|
||||
level: SymbolExportLevel::Rust,
|
||||
kind: SymbolExportKind::Data,
|
||||
used: false,
|
||||
used_compiler: false,
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -264,6 +270,7 @@ fn exported_symbols_provider_local(
|
||||
level: SymbolExportLevel::C,
|
||||
kind: SymbolExportKind::Data,
|
||||
used: false,
|
||||
used_compiler: false,
|
||||
},
|
||||
)
|
||||
}));
|
||||
@ -289,6 +296,7 @@ fn exported_symbols_provider_local(
|
||||
level: SymbolExportLevel::C,
|
||||
kind: SymbolExportKind::Data,
|
||||
used: false,
|
||||
used_compiler: false,
|
||||
},
|
||||
)
|
||||
}));
|
||||
@ -306,6 +314,7 @@ fn exported_symbols_provider_local(
|
||||
level: SymbolExportLevel::C,
|
||||
kind: SymbolExportKind::Data,
|
||||
used: true,
|
||||
used_compiler: false,
|
||||
},
|
||||
));
|
||||
}
|
||||
@ -346,6 +355,7 @@ fn exported_symbols_provider_local(
|
||||
level: SymbolExportLevel::Rust,
|
||||
kind: SymbolExportKind::Text,
|
||||
used: false,
|
||||
used_compiler: false,
|
||||
},
|
||||
));
|
||||
}
|
||||
@ -362,6 +372,7 @@ fn exported_symbols_provider_local(
|
||||
level: SymbolExportLevel::Rust,
|
||||
kind: SymbolExportKind::Text,
|
||||
used: false,
|
||||
used_compiler: false,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
@ -35,7 +35,12 @@ pub enum SymbolExportKind {
|
||||
pub struct SymbolExportInfo {
|
||||
pub level: SymbolExportLevel,
|
||||
pub kind: SymbolExportKind,
|
||||
/// Used to mark these symbols not to be internalized by LTO. These symbols
|
||||
/// are also added to `symbols.o` to avoid circular dependencies when linking.
|
||||
pub used: bool,
|
||||
/// Also used to mark these symbols not to be internalized by LTO. But will
|
||||
/// not be added to `symbols.o`. Currently there are only builtin functions.
|
||||
pub used_compiler: bool,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Debug, Copy, Clone, TyEncodable, TyDecodable, HashStable)]
|
||||
|
@ -165,6 +165,7 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
|
||||
level: SymbolExportLevel::C,
|
||||
kind: SymbolExportKind::Text,
|
||||
used: false,
|
||||
used_compiler: false,
|
||||
},
|
||||
))
|
||||
}),
|
||||
|
7
tests/run-make/no-builtins-symbols/Makefile
Normal file
7
tests/run-make/no-builtins-symbols/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-x86_64-unknown-linux-gnu
|
||||
|
||||
all:
|
||||
$(RUSTC) main.rs -o $(TMPDIR)/main
|
||||
[ "$$("$(LLVM_BIN_DIR)"/llvm-nm -U $(TMPDIR)/main | grep -c __fixunssfti)" -eq "0" ]
|
1
tests/run-make/no-builtins-symbols/main.rs
Normal file
1
tests/run-make/no-builtins-symbols/main.rs
Normal file
@ -0,0 +1 @@
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user