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,
|
NativeStaticNobundle,
|
||||||
/// macOS-specific
|
/// macOS-specific
|
||||||
NativeFramework,
|
NativeFramework,
|
||||||
|
/// windows dynamic library without import library
|
||||||
|
NativeRawDylib,
|
||||||
/// default way to specify a dynamic library
|
/// default way to specify a dynamic library
|
||||||
NativeUnknown,
|
NativeUnknown,
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,6 +323,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
|
||||||
NativeLibraryKind::NativeStatic => {}
|
NativeLibraryKind::NativeStatic => {}
|
||||||
NativeLibraryKind::NativeStaticNobundle |
|
NativeLibraryKind::NativeStaticNobundle |
|
||||||
NativeLibraryKind::NativeFramework |
|
NativeLibraryKind::NativeFramework |
|
||||||
|
NativeLibraryKind::NativeRawDylib |
|
||||||
NativeLibraryKind::NativeUnknown => continue,
|
NativeLibraryKind::NativeUnknown => continue,
|
||||||
}
|
}
|
||||||
if let Some(name) = lib.name {
|
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))
|
Some(format!("-framework {}", name))
|
||||||
},
|
},
|
||||||
// These are included, no need to print them
|
// These are included, no need to print them
|
||||||
NativeLibraryKind::NativeStatic => None,
|
NativeLibraryKind::NativeStatic |
|
||||||
|
NativeLibraryKind::NativeRawDylib => None,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -1293,7 +1295,11 @@ pub fn add_local_native_libraries(cmd: &mut dyn Linker,
|
||||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(name),
|
NativeLibraryKind::NativeUnknown => cmd.link_dylib(name),
|
||||||
NativeLibraryKind::NativeFramework => cmd.link_framework(name),
|
NativeLibraryKind::NativeFramework => cmd.link_framework(name),
|
||||||
NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(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
|
// ignore statically included native libraries here as we've
|
||||||
// already included them when we included the rust library
|
// already included them when we included the rust library
|
||||||
// previously
|
// 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
|
// resolve! Does this work? Unsure! That's what the issue is about
|
||||||
*providers = Providers {
|
*providers = Providers {
|
||||||
is_dllimport_foreign_item: |tcx, id| {
|
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| {
|
is_statically_included_foreign_item: |tcx, id| {
|
||||||
match tcx.native_library_kind(id) {
|
match tcx.native_library_kind(id) {
|
||||||
|
|
|
@ -73,6 +73,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
|
||||||
"static-nobundle" => cstore::NativeStaticNobundle,
|
"static-nobundle" => cstore::NativeStaticNobundle,
|
||||||
"dylib" => cstore::NativeUnknown,
|
"dylib" => cstore::NativeUnknown,
|
||||||
"framework" => cstore::NativeFramework,
|
"framework" => cstore::NativeFramework,
|
||||||
|
"raw-dylib" => cstore::NativeRawDylib,
|
||||||
k => {
|
k => {
|
||||||
struct_span_err!(self.tcx.sess, item.span(), E0458,
|
struct_span_err!(self.tcx.sess, item.span(), E0458,
|
||||||
"unknown kind: `{}`", k)
|
"unknown kind: `{}`", k)
|
||||||
|
@ -169,6 +170,14 @@ impl Collector<'tcx> {
|
||||||
GateIssue::Language,
|
GateIssue::Language,
|
||||||
"kind=\"static-nobundle\" is unstable");
|
"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);
|
self.libs.push(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -522,6 +522,9 @@ declare_features! (
|
||||||
/// Allows the definition of `const extern fn` and `const unsafe extern fn`.
|
/// Allows the definition of `const extern fn` and `const unsafe extern fn`.
|
||||||
(active, const_extern_fn, "1.40.0", Some(64926), None),
|
(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
|
// 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, \
|
"the `link_args` attribute is experimental and not portable across platforms, \
|
||||||
it is recommended to use `#[link(name = \"foo\")] instead",
|
it is recommended to use `#[link(name = \"foo\")] instead",
|
||||||
),
|
),
|
||||||
|
gated!(
|
||||||
|
link_ordinal,
|
||||||
|
Whitelisted,
|
||||||
|
template!(List: "ordinal"),
|
||||||
|
raw_dylib,
|
||||||
|
experimental!(link_ordinal)
|
||||||
|
),
|
||||||
// Plugins:
|
// Plugins:
|
||||||
(
|
(
|
||||||
sym::plugin_registrar, Normal, template!(Word),
|
sym::plugin_registrar, Normal, template!(Word),
|
||||||
|
|
|
@ -389,6 +389,7 @@ symbols! {
|
||||||
link_cfg,
|
link_cfg,
|
||||||
link_llvm_intrinsics,
|
link_llvm_intrinsics,
|
||||||
link_name,
|
link_name,
|
||||||
|
link_ordinal,
|
||||||
link_section,
|
link_section,
|
||||||
LintPass,
|
LintPass,
|
||||||
lint_reasons,
|
lint_reasons,
|
||||||
|
@ -531,6 +532,7 @@ symbols! {
|
||||||
RangeInclusive,
|
RangeInclusive,
|
||||||
RangeTo,
|
RangeTo,
|
||||||
RangeToInclusive,
|
RangeToInclusive,
|
||||||
|
raw_dylib,
|
||||||
raw_identifiers,
|
raw_identifiers,
|
||||||
Ready,
|
Ready,
|
||||||
reason,
|
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