Add feature gate for raw_dylib.
This commit is contained in:
parent
4ac4809ccf
commit
e70ffed9cd
11 changed files with 78 additions and 5 deletions
|
@ -96,6 +96,8 @@ pub enum NativeLibraryKind {
|
|||
NativeStaticNobundle,
|
||||
/// macOS-specific
|
||||
NativeFramework,
|
||||
/// windows dynamic library without import library
|
||||
NativeRawDylib,
|
||||
/// default way to specify a dynamic library
|
||||
NativeUnknown,
|
||||
}
|
||||
|
|
|
@ -323,6 +323,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
|
|||
NativeLibraryKind::NativeStatic => {}
|
||||
NativeLibraryKind::NativeStaticNobundle |
|
||||
NativeLibraryKind::NativeFramework |
|
||||
NativeLibraryKind::NativeRawDylib |
|
||||
NativeLibraryKind::NativeUnknown => continue,
|
||||
}
|
||||
if let Some(name) = lib.name {
|
||||
|
@ -883,7 +884,8 @@ pub fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLibrary
|
|||
Some(format!("-framework {}", name))
|
||||
},
|
||||
// These are included, no need to print them
|
||||
NativeLibraryKind::NativeStatic => None,
|
||||
NativeLibraryKind::NativeStatic |
|
||||
NativeLibraryKind::NativeRawDylib => None,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
@ -1293,7 +1295,11 @@ pub fn add_local_native_libraries(cmd: &mut dyn Linker,
|
|||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(name),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(name),
|
||||
NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(name),
|
||||
NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(name, &search_path)
|
||||
NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(name, &search_path),
|
||||
NativeLibraryKind::NativeRawDylib => {
|
||||
// FIXME(#58713): Proper handling for raw dylibs.
|
||||
bug!("raw_dylib feature not yet implemented");
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1678,7 +1684,11 @@ pub fn add_upstream_native_libraries(
|
|||
// ignore statically included native libraries here as we've
|
||||
// already included them when we included the rust library
|
||||
// previously
|
||||
NativeLibraryKind::NativeStatic => {}
|
||||
NativeLibraryKind::NativeStatic => {},
|
||||
NativeLibraryKind::NativeRawDylib => {
|
||||
// FIXME(#58713): Proper handling for raw dylibs.
|
||||
bug!("raw_dylib feature not yet implemented");
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,7 +270,11 @@ pub fn provide(providers: &mut Providers<'_>) {
|
|||
// resolve! Does this work? Unsure! That's what the issue is about
|
||||
*providers = Providers {
|
||||
is_dllimport_foreign_item: |tcx, id| {
|
||||
tcx.native_library_kind(id) == Some(NativeLibraryKind::NativeUnknown)
|
||||
match tcx.native_library_kind(id) {
|
||||
Some(NativeLibraryKind::NativeUnknown) |
|
||||
Some(NativeLibraryKind::NativeRawDylib) => true,
|
||||
_ => false,
|
||||
}
|
||||
},
|
||||
is_statically_included_foreign_item: |tcx, id| {
|
||||
match tcx.native_library_kind(id) {
|
||||
|
|
|
@ -73,6 +73,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
|
|||
"static-nobundle" => cstore::NativeStaticNobundle,
|
||||
"dylib" => cstore::NativeUnknown,
|
||||
"framework" => cstore::NativeFramework,
|
||||
"raw-dylib" => cstore::NativeRawDylib,
|
||||
k => {
|
||||
struct_span_err!(self.tcx.sess, item.span(), E0458,
|
||||
"unknown kind: `{}`", k)
|
||||
|
@ -169,6 +170,14 @@ impl Collector<'tcx> {
|
|||
GateIssue::Language,
|
||||
"kind=\"static-nobundle\" is unstable");
|
||||
}
|
||||
if lib.kind == cstore::NativeRawDylib &&
|
||||
!self.tcx.features().raw_dylib {
|
||||
feature_gate::emit_feature_err(&self.tcx.sess.parse_sess,
|
||||
sym::raw_dylib,
|
||||
span.unwrap_or_else(|| syntax_pos::DUMMY_SP),
|
||||
GateIssue::Language,
|
||||
"kind=\"raw-dylib\" is feature gated");
|
||||
}
|
||||
self.libs.push(lib);
|
||||
}
|
||||
|
||||
|
|
|
@ -522,6 +522,9 @@ declare_features! (
|
|||
/// Allows the definition of `const extern fn` and `const unsafe extern fn`.
|
||||
(active, const_extern_fn, "1.40.0", Some(64926), None),
|
||||
|
||||
// Allows the use of raw-dylibs (RFC 2627).
|
||||
(active, raw_dylib, "1.39.0", Some(58713), None),
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// feature-group-end: actual feature gates
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
|
@ -276,7 +276,13 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
"the `link_args` attribute is experimental and not portable across platforms, \
|
||||
it is recommended to use `#[link(name = \"foo\")] instead",
|
||||
),
|
||||
|
||||
gated!(
|
||||
link_ordinal,
|
||||
Whitelisted,
|
||||
template!(List: "ordinal"),
|
||||
raw_dylib,
|
||||
experimental!(link_ordinal)
|
||||
),
|
||||
// Plugins:
|
||||
(
|
||||
sym::plugin_registrar, Normal, template!(Word),
|
||||
|
|
|
@ -389,6 +389,7 @@ symbols! {
|
|||
link_cfg,
|
||||
link_llvm_intrinsics,
|
||||
link_name,
|
||||
link_ordinal,
|
||||
link_section,
|
||||
LintPass,
|
||||
lint_reasons,
|
||||
|
@ -531,6 +532,7 @@ symbols! {
|
|||
RangeInclusive,
|
||||
RangeTo,
|
||||
RangeToInclusive,
|
||||
raw_dylib,
|
||||
raw_identifiers,
|
||||
Ready,
|
||||
reason,
|
||||
|
|
8
src/test/ui/feature-gates/feature-gate-raw-dylib-2.rs
Normal file
8
src/test/ui/feature-gates/feature-gate-raw-dylib-2.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
#[link(name="foo")]
|
||||
extern {
|
||||
#[link_ordinal(42)]
|
||||
//~^ ERROR: the `#[link_ordinal]` attribute is an experimental feature
|
||||
fn foo();
|
||||
}
|
||||
|
||||
fn main() {}
|
12
src/test/ui/feature-gates/feature-gate-raw-dylib-2.stderr
Normal file
12
src/test/ui/feature-gates/feature-gate-raw-dylib-2.stderr
Normal file
|
@ -0,0 +1,12 @@
|
|||
error[E0658]: the `#[link_ordinal]` attribute is an experimental feature
|
||||
--> $DIR/feature-gate-raw-dylib-2.rs:3:1
|
||||
|
|
||||
LL | #[link_ordinal(42)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/58713
|
||||
= help: add `#![feature(raw_dylib)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
5
src/test/ui/feature-gates/feature-gate-raw-dylib.rs
Normal file
5
src/test/ui/feature-gates/feature-gate-raw-dylib.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
#[link(name="foo", kind="raw-dylib")]
|
||||
//~^ ERROR: kind="raw-dylib" is feature gated
|
||||
extern {}
|
||||
|
||||
fn main() {}
|
12
src/test/ui/feature-gates/feature-gate-raw-dylib.stderr
Normal file
12
src/test/ui/feature-gates/feature-gate-raw-dylib.stderr
Normal file
|
@ -0,0 +1,12 @@
|
|||
error[E0658]: kind="raw-dylib" is feature gated
|
||||
--> $DIR/feature-gate-raw-dylib.rs:1:1
|
||||
|
|
||||
LL | #[link(name="foo", kind="raw-dylib")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/58713
|
||||
= help: add `#![feature(raw_dylib)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
Loading…
Reference in a new issue