mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Add unstable feature flags
This commit is contained in:
parent
39ba9dadee
commit
83f96e8142
@ -91,9 +91,22 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
|||||||
//
|
//
|
||||||
// Treat cdylibs and staticlibs similarly. If `-C prefer-dynamic` is set,
|
// Treat cdylibs and staticlibs similarly. If `-C prefer-dynamic` is set,
|
||||||
// the caller may be code-size conscious, but without it, it makes sense
|
// the caller may be code-size conscious, but without it, it makes sense
|
||||||
// to statically link a cdylib or staticlib.
|
// to statically link a cdylib or staticlib. For staticlibs we use
|
||||||
CrateType::Dylib | CrateType::Cdylib | CrateType::Staticlib => {
|
// `-Z staticlib-prefer-dynamic` for now. This may be merged into
|
||||||
if sess.opts.cg.prefer_dynamic { Linkage::Dynamic } else { Linkage::Static }
|
// `-C prefer-dynamic` in the future.
|
||||||
|
CrateType::Dylib | CrateType::Cdylib => {
|
||||||
|
if sess.opts.cg.prefer_dynamic {
|
||||||
|
Linkage::Dynamic
|
||||||
|
} else {
|
||||||
|
Linkage::Static
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CrateType::Staticlib => {
|
||||||
|
if sess.opts.unstable_opts.staticlib_prefer_dynamic {
|
||||||
|
Linkage::Dynamic
|
||||||
|
} else {
|
||||||
|
Linkage::Static
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the global prefer_dynamic switch is turned off, or the final
|
// If the global prefer_dynamic switch is turned off, or the final
|
||||||
@ -123,9 +136,10 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
|||||||
|
|
||||||
// Static executables must have all static dependencies.
|
// Static executables must have all static dependencies.
|
||||||
// If any are not found, generate some nice pretty errors.
|
// If any are not found, generate some nice pretty errors.
|
||||||
if ty == CrateType::Executable
|
if (ty == CrateType::Staticlib && !sess.opts.unstable_opts.staticlib_allow_rdylib_deps)
|
||||||
|
|| (ty == CrateType::Executable
|
||||||
&& sess.crt_static(Some(ty))
|
&& sess.crt_static(Some(ty))
|
||||||
&& !sess.target.crt_static_allows_dylibs
|
&& !sess.target.crt_static_allows_dylibs)
|
||||||
{
|
{
|
||||||
for &cnum in tcx.crates(()).iter() {
|
for &cnum in tcx.crates(()).iter() {
|
||||||
if tcx.dep_kind(cnum).macros_only() {
|
if tcx.dep_kind(cnum).macros_only() {
|
||||||
|
@ -1709,6 +1709,10 @@ options! {
|
|||||||
#[rustc_lint_opt_deny_field_access("use `Session::stack_protector` instead of this field")]
|
#[rustc_lint_opt_deny_field_access("use `Session::stack_protector` instead of this field")]
|
||||||
stack_protector: StackProtector = (StackProtector::None, parse_stack_protector, [TRACKED],
|
stack_protector: StackProtector = (StackProtector::None, parse_stack_protector, [TRACKED],
|
||||||
"control stack smash protection strategy (`rustc --print stack-protector-strategies` for details)"),
|
"control stack smash protection strategy (`rustc --print stack-protector-strategies` for details)"),
|
||||||
|
staticlib_allow_rdylib_deps: bool = (false, parse_bool, [TRACKED],
|
||||||
|
"allow staticlibs to have rust dylib dependencies"),
|
||||||
|
staticlib_prefer_dynamic: bool = (false, parse_bool, [TRACKED],
|
||||||
|
"prefer dynamic linking to static linking for staticlibs (default: no)"),
|
||||||
strict_init_checks: bool = (false, parse_bool, [TRACKED],
|
strict_init_checks: bool = (false, parse_bool, [TRACKED],
|
||||||
"control if mem::uninitialized and mem::zeroed panic on more UB"),
|
"control if mem::uninitialized and mem::zeroed panic on more UB"),
|
||||||
strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
|
strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
|
||||||
|
@ -2,7 +2,9 @@ include ../tools.mk
|
|||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) -C prefer-dynamic bar.rs
|
$(RUSTC) -C prefer-dynamic bar.rs
|
||||||
$(RUSTC) foo.rs --crate-type staticlib --print native-static-libs 2>&1 | grep 'note: native-static-libs: ' | sed 's/note: native-static-libs: \(.*\)/\1/' > $(TMPDIR)/libs.txt
|
$(RUSTC) foo.rs --crate-type staticlib --print native-static-libs \
|
||||||
|
-Z staticlib-allow-rdylib-deps 2>&1 | grep 'note: native-static-libs: ' \
|
||||||
|
| sed 's/note: native-static-libs: \(.*\)/\1/' > $(TMPDIR)/libs.txt
|
||||||
cat $(TMPDIR)/libs.txt
|
cat $(TMPDIR)/libs.txt
|
||||||
|
|
||||||
ifdef IS_MSVC
|
ifdef IS_MSVC
|
||||||
|
Loading…
Reference in New Issue
Block a user