Rollup merge of #109677 - dpaoliello:rawdylib, r=michaelwoerister,wesleywiser

Stabilize raw-dylib, link_ordinal, import_name_type and -Cdlltool

This stabilizes the `raw-dylib` feature (#58713) for all architectures (i.e., `x86` as it is already stable for all other architectures).

Changes:
* Permit the use of the `raw-dylib` link kind for x86, the `link_ordinal` attribute and the `import_name_type` key for the `link` attribute.
* Mark the `raw_dylib` feature as stable.
* Stabilized the `-Zdlltool` argument as `-Cdlltool`.
* Note the path to `dlltool` if invoking it failed (we don't need to do this if `dlltool` returns an error since it prints its path in the error message).
* Adds tests for `-Cdlltool`.
* Adds tests for being unable to find the dlltool executable, and dlltool failing.
* Fixes a bug where we were checking the exit code of dlltool to see if it failed, but dlltool always returns 0 (indicating success), so instead we need to check if anything was written to `stderr`.

NOTE: As previously noted (https://github.com/rust-lang/rust/pull/104218#issuecomment-1315895618) using dlltool within rustc is temporary, but this is not the first time that Rust has added a temporary tool use and argument: https://github.com/rust-lang/rust/pull/104218#issuecomment-1318720482

Big thanks to ``````@tbu-`````` for the first version of this PR (#104218)
This commit is contained in:
Yuki Okushi 2023-05-06 09:09:30 +09:00 committed by GitHub
commit 923a5a2ca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 146 additions and 223 deletions

View File

@ -24,7 +24,7 @@ codegen_llvm_error_writing_def_file =
Error writing .DEF file: {$error}
codegen_llvm_error_calling_dlltool =
Error calling dlltool: {$error}
Error calling dlltool '{$dlltool_path}': {$error}
codegen_llvm_dlltool_fail_import_library =
Dlltool could not create import library: {$stdout}

View File

@ -198,7 +198,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
"arm" => ("arm", "--32"),
_ => panic!("unsupported arch {}", sess.target.arch),
};
let result = std::process::Command::new(dlltool)
let result = std::process::Command::new(&dlltool)
.args([
"-d",
def_file_path.to_str().unwrap(),
@ -218,9 +218,13 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
match result {
Err(e) => {
sess.emit_fatal(ErrorCallingDllTool { error: e });
sess.emit_fatal(ErrorCallingDllTool {
dlltool_path: dlltool.to_string_lossy(),
error: e,
});
}
Ok(output) if !output.status.success() => {
// dlltool returns '0' on failure, so check for error output instead.
Ok(output) if !output.stderr.is_empty() => {
sess.emit_fatal(DlltoolFailImportLibrary {
stdout: String::from_utf8_lossy(&output.stdout),
stderr: String::from_utf8_lossy(&output.stderr),
@ -431,7 +435,7 @@ fn string_to_io_error(s: String) -> io::Error {
fn find_binutils_dlltool(sess: &Session) -> OsString {
assert!(sess.target.options.is_like_windows && !sess.target.options.is_like_msvc);
if let Some(dlltool_path) = &sess.opts.unstable_opts.dlltool {
if let Some(dlltool_path) = &sess.opts.cg.dlltool {
return dlltool_path.clone().into_os_string();
}

View File

@ -67,7 +67,8 @@ pub(crate) struct ErrorWritingDEFFile {
#[derive(Diagnostic)]
#[diag(codegen_llvm_error_calling_dlltool)]
pub(crate) struct ErrorCallingDllTool {
pub(crate) struct ErrorCallingDllTool<'a> {
pub dlltool_path: Cow<'a, str>,
pub error: std::io::Error,
}

View File

@ -592,15 +592,6 @@ fn should_inherit_track_caller(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
use rustc_ast::{LitIntType, LitKind, MetaItemLit};
if !tcx.features().raw_dylib && tcx.sess.target.arch == "x86" {
feature_err(
&tcx.sess.parse_sess,
sym::raw_dylib,
attr.span,
"`#[link_ordinal]` is unstable on x86",
)
.emit();
}
let meta_item_list = attr.meta_item_list();
let meta_item_list = meta_item_list.as_deref();
let sole_meta_list = match meta_item_list {

View File

@ -280,6 +280,8 @@ declare_features! (
(accepted, pub_restricted, "1.18.0", Some(32409), None),
/// Allows use of the postfix `?` operator in expressions.
(accepted, question_mark, "1.13.0", Some(31436), None),
/// Allows the use of raw-dylibs (RFC 2627).
(accepted, raw_dylib, "CURRENT_RUSTC_VERSION", Some(58713), None),
/// Allows keywords to be escaped for use as identifiers.
(accepted, raw_identifiers, "1.30.0", Some(48589), None),
/// Allows relaxing the coherence rules such that

View File

@ -489,8 +489,6 @@ declare_features! (
(active, precise_pointer_size_matching, "1.32.0", Some(56354), None),
/// Allows macro attributes on expressions, statements and non-inline modules.
(active, proc_macro_hygiene, "1.30.0", Some(54727), None),
/// Allows the use of raw-dylibs (RFC 2627).
(active, raw_dylib, "1.65.0", Some(58713), None),
/// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions.
(active, raw_ref_op, "1.41.0", Some(64490), None),
/// Allows using the `#[register_tool]` attribute.

View File

@ -547,6 +547,7 @@ fn test_codegen_options_tracking_hash() {
untracked!(ar, String::from("abc"));
untracked!(codegen_units, Some(42));
untracked!(default_linker_libraries, true);
untracked!(dlltool, Some(PathBuf::from("custom_dlltool.exe")));
untracked!(extra_filename, String::from("extra-filename"));
untracked!(incremental, Some(String::from("abc")));
// `link_arg` is omitted because it just forwards to `link_args`.
@ -651,7 +652,6 @@ fn test_unstable_options_tracking_hash() {
untracked!(assert_incr_state, Some(String::from("loaded")));
untracked!(deduplicate_diagnostics, false);
untracked!(dep_tasks, true);
untracked!(dlltool, Some(PathBuf::from("custom_dlltool.exe")));
untracked!(dont_buffer_diagnostics, true);
untracked!(dump_dep_graph, true);
untracked!(dump_drop_tracking_cfg, Some("cfg.dot".to_string()));

View File

@ -161,14 +161,6 @@ impl<'tcx> Collector<'tcx> {
"raw-dylib" => {
if !sess.target.is_like_windows {
sess.emit_err(errors::FrameworkOnlyWindows { span });
} else if !features.raw_dylib && sess.target.arch == "x86" {
feature_err(
&sess.parse_sess,
sym::raw_dylib,
span,
"link kind `raw-dylib` is unstable on x86",
)
.emit();
}
NativeLibKind::RawDylib
}
@ -251,16 +243,6 @@ impl<'tcx> Collector<'tcx> {
continue;
}
};
if !features.raw_dylib {
let span = item.name_value_literal_span().unwrap();
feature_err(
&sess.parse_sess,
sym::raw_dylib,
span,
"import name type is unstable",
)
.emit();
}
import_name_type = Some((link_import_name_type, item.span()));
}
_ => {

View File

@ -1235,6 +1235,8 @@ options! {
line-tables-only, limited, or full; default: 0)"),
default_linker_libraries: bool = (false, parse_bool, [UNTRACKED],
"allow the linker to link its default libraries (default: no)"),
dlltool: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
"import library generation tool (ignored except when targeting windows-gnu)"),
embed_bitcode: bool = (true, parse_bool, [TRACKED],
"emit bitcode in rlibs (default: yes)"),
extra_filename: String = (String::new(), parse_string, [UNTRACKED],
@ -1391,8 +1393,6 @@ options! {
(default: no)"),
diagnostic_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
"set the current output width for diagnostic truncation"),
dlltool: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
"import library generation tool (windows-gnu only)"),
dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
"emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \
(default: no)"),

View File

@ -90,6 +90,14 @@ It takes one of the following values:
For example, for gcc flavor linkers, this issues the `-nodefaultlibs` flag to
the linker.
## dlltool
On `windows-gnu` targets, this flag controls which dlltool `rustc` invokes to
generate import libraries when using the [`raw-dylib` link kind](../../reference/items/external-blocks.md#the-link-attribute).
It takes a path to [the dlltool executable](https://sourceware.org/binutils/docs/binutils/dlltool.html).
If this flag is not specified, a dlltool executable will be inferred based on
the host environment and target.
## embed-bitcode
This flag controls whether or not the compiler embeds LLVM bitcode into object

View File

@ -1,34 +0,0 @@
# `raw_dylib`
The tracking issue for this feature is: [#58713]
[#58713]: https://github.com/rust-lang/rust/issues/58713
------------------------
The `raw_dylib` feature allows you to link against the implementations of functions in an `extern`
block without, on Windows, linking against an import library.
```rust,ignore (partial-example)
#![feature(raw_dylib)]
#[link(name="library", kind="raw-dylib")]
extern {
fn extern_function(x: i32);
}
fn main() {
unsafe {
extern_function(14);
}
}
```
## Limitations
This feature is unstable for the `x86` architecture, and stable for all other architectures.
This feature is only supported on Windows.
On the `x86` architecture, this feature supports only the `cdecl`, `stdcall`, `system`, `fastcall`, and
`vectorcall` calling conventions.

View File

@ -115,6 +115,11 @@ pub(super) fn handle_needs(
condition: cache.x86_64_dlltool,
ignore_reason: "ignored when dlltool for x86_64 is not present",
},
Need {
name: "needs-dlltool",
condition: cache.dlltool,
ignore_reason: "ignored when dlltool for the current architecture is not present",
},
Need {
name: "needs-git-hash",
condition: config.git_hash,
@ -183,6 +188,7 @@ pub(super) struct CachedNeedsConditions {
rust_lld: bool,
i686_dlltool: bool,
x86_64_dlltool: bool,
dlltool: bool,
}
impl CachedNeedsConditions {
@ -190,6 +196,17 @@ impl CachedNeedsConditions {
let path = std::env::var_os("PATH").expect("missing PATH environment variable");
let path = std::env::split_paths(&path).collect::<Vec<_>>();
// On Windows, dlltool.exe is used for all architectures.
#[cfg(windows)]
let dlltool = path.iter().any(|dir| dir.join("dlltool.exe").is_file());
// For non-Windows, there are architecture specific dlltool binaries.
#[cfg(not(windows))]
let i686_dlltool = path.iter().any(|dir| dir.join("i686-w64-mingw32-dlltool").is_file());
#[cfg(not(windows))]
let x86_64_dlltool =
path.iter().any(|dir| dir.join("x86_64-w64-mingw32-dlltool").is_file());
let target = &&*config.target;
Self {
sanitizer_support: std::env::var_os("RUSTC_SANITIZER_SUPPORT").is_some(),
@ -225,17 +242,26 @@ impl CachedNeedsConditions {
.join(if config.host.contains("windows") { "rust-lld.exe" } else { "rust-lld" })
.exists(),
// On Windows, dlltool.exe is used for all architectures.
#[cfg(windows)]
i686_dlltool: path.iter().any(|dir| dir.join("dlltool.exe").is_file()),
i686_dlltool: dlltool,
#[cfg(windows)]
x86_64_dlltool: path.iter().any(|dir| dir.join("dlltool.exe").is_file()),
x86_64_dlltool: dlltool,
#[cfg(windows)]
dlltool,
// For non-Windows, there are architecture specific dlltool binaries.
#[cfg(not(windows))]
i686_dlltool: path.iter().any(|dir| dir.join("i686-w64-mingw32-dlltool").is_file()),
i686_dlltool,
#[cfg(not(windows))]
x86_64_dlltool: path.iter().any(|dir| dir.join("x86_64-w64-mingw32-dlltool").is_file()),
x86_64_dlltool,
#[cfg(not(windows))]
dlltool: if config.matches_arch("x86") {
i686_dlltool
} else if config.matches_arch("x86_64") {
x86_64_dlltool
} else {
false
},
}
}
}

View File

@ -1,5 +1,4 @@
#![feature(abi_vectorcall)]
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[repr(C)]
#[derive(Clone)]

View File

@ -1,5 +1,3 @@
#![feature(raw_dylib)]
#[link(name = "extern_1.dll", kind = "raw-dylib", modifiers = "+verbatim")]
extern {
fn extern_fn_1();

View File

@ -1,4 +1,3 @@
#![feature(raw_dylib)]
#![feature(no_core, lang_items)]
#![no_std]
#![no_core]

View File

@ -0,0 +1,11 @@
# Test using -Cdlltool to change where raw-dylib looks for the dlltool binary.
# only-windows
# only-gnu
# needs-dlltool
include ../tools.mk
all:
$(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs -Cdlltool=$(CURDIR)/script.cmd
$(DIFF) output.txt "$(TMPDIR)"/output.txt

View File

@ -0,0 +1,10 @@
#[link(name = "extern_1", kind = "raw-dylib")]
extern {
fn extern_fn_1();
}
pub fn library_function() {
unsafe {
extern_fn_1();
}
}

View File

@ -0,0 +1 @@
Called dlltool via script.cmd

View File

@ -0,0 +1,2 @@
echo Called dlltool via script.cmd> %TMPDIR%\output.txt
dlltool.exe %*

View File

@ -1,4 +1,3 @@
#![feature(raw_dylib)]
#![feature(abi_vectorcall)]
#[link(name = "extern", kind = "raw-dylib", import_name_type = "undecorated")]

View File

@ -1,5 +1,3 @@
#![feature(raw_dylib)]
extern crate raw_dylib_test;
extern crate raw_dylib_test_wrapper;

View File

@ -1,5 +1,3 @@
#![feature(raw_dylib)]
#[link(name = "extern_1", kind = "raw-dylib")]
extern {
fn extern_fn_1();

View File

@ -1,5 +1,3 @@
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link(name = "exporter", kind = "raw-dylib")]
extern {
#[link_ordinal(13)]

View File

@ -1,5 +1,3 @@
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link(name = "exporter", kind = "raw-dylib")]
extern "stdcall" {
#[link_ordinal(15)]

View File

@ -1,12 +0,0 @@
// only-x86
#[link(name = "foo")]
extern "C" {
#[link_ordinal(42)]
//~^ ERROR: `#[link_ordinal]` is unstable on x86
fn foo();
#[link_ordinal(5)]
//~^ ERROR: `#[link_ordinal]` is unstable on x86
static mut imported_variable: i32;
}
fn main() {}

View File

@ -1,21 +0,0 @@
error[E0658]: `#[link_ordinal]` is unstable on x86
--> $DIR/feature-gate-raw-dylib-2.rs:4:5
|
LL | #[link_ordinal(42)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
= help: add `#![feature(raw_dylib)]` to the crate attributes to enable
error[E0658]: `#[link_ordinal]` is unstable on x86
--> $DIR/feature-gate-raw-dylib-2.rs:7:5
|
LL | #[link_ordinal(5)]
| ^^^^^^^^^^^^^^^^^^
|
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
= help: add `#![feature(raw_dylib)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,8 +0,0 @@
// only-windows
// only-x86
#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
//~^ ERROR link kind `raw-dylib` is unstable on x86
//~| ERROR import name type is unstable
extern "C" {}
fn main() {}

View File

@ -1,21 +0,0 @@
error[E0658]: link kind `raw-dylib` is unstable on x86
--> $DIR/feature-gate-raw-dylib-import-name-type.rs:3:29
|
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
| ^^^^^^^^^^^
|
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
= help: add `#![feature(raw_dylib)]` to the crate attributes to enable
error[E0658]: import name type is unstable
--> $DIR/feature-gate-raw-dylib-import-name-type.rs:3:61
|
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
| ^^^^^^^^^^^
|
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
= help: add `#![feature(raw_dylib)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,7 +0,0 @@
// only-windows
// only-x86
#[link(name = "foo", kind = "raw-dylib")]
//~^ ERROR: link kind `raw-dylib` is unstable on x86
extern "C" {}
fn main() {}

View File

@ -1,12 +0,0 @@
error[E0658]: link kind `raw-dylib` is unstable on x86
--> $DIR/feature-gate-raw-dylib.rs:3:29
|
LL | #[link(name = "foo", kind = "raw-dylib")]
| ^^^^^^^^^^^
|
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
= 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`.

View File

@ -0,0 +1,19 @@
// Tests that dlltool failing to generate an import library will raise an error.
// only-gnu
// only-windows
// needs-dlltool
// compile-flags: --crate-type lib --emit link
// normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL"
// normalize-stderr-test: "[^ ]*/foo.def" -> "$$DEF_FILE"
#[link(name = "foo", kind = "raw-dylib")]
extern "C" {
// `@1` is an invalid name to export, as it usually indicates that something
// is being exported via ordinal.
#[link_name = "@1"]
fn f(x: i32);
}
pub fn lib_main() {
unsafe { f(42); }
}

View File

@ -0,0 +1,5 @@
error: Dlltool could not create import library:
$DLLTOOL: Syntax error in def file $DEF_FILE:1
error: aborting due to previous error

View File

@ -1,7 +1,5 @@
// only-windows
// only-x86
#![feature(raw_dylib)]
#[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
//~^ ERROR import name type must be of the form `import_name_type = "string"`
extern "C" { }

View File

@ -1,5 +1,5 @@
error: import name type must be of the form `import_name_type = "string"`
--> $DIR/import-name-type-invalid-format.rs:5:42
--> $DIR/import-name-type-invalid-format.rs:3:42
|
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
| ^^^^^^^^^^^^^^^^^^^^

View File

@ -1,8 +1,6 @@
// ignore-tidy-linelength
// only-windows
// only-x86
#![feature(raw_dylib)]
#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
//~^ ERROR multiple `import_name_type` arguments in a single `#[link]` attribute
extern "C" { }

View File

@ -1,5 +1,5 @@
error: multiple `import_name_type` arguments in a single `#[link]` attribute
--> $DIR/import-name-type-multiple.rs:6:74
--> $DIR/import-name-type-multiple.rs:4:74
|
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,7 +1,5 @@
// only-windows
// only-x86
#![feature(raw_dylib)]
#[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
//~^ ERROR unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated
extern "C" { }

View File

@ -1,5 +1,5 @@
error: unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated
--> $DIR/import-name-type-unknown-value.rs:5:42
--> $DIR/import-name-type-unknown-value.rs:3:42
|
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,7 +1,5 @@
// only-windows
// only-x86
#![feature(raw_dylib)]
#[link(name = "foo", import_name_type = "decorated")]
//~^ ERROR import name type can only be used with link kind `raw-dylib`
extern "C" { }

View File

@ -1,11 +1,11 @@
error: import name type can only be used with link kind `raw-dylib`
--> $DIR/import-name-type-unsupported-link-kind.rs:5:22
--> $DIR/import-name-type-unsupported-link-kind.rs:3:22
|
LL | #[link(name = "foo", import_name_type = "decorated")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: import name type can only be used with link kind `raw-dylib`
--> $DIR/import-name-type-unsupported-link-kind.rs:9:39
--> $DIR/import-name-type-unsupported-link-kind.rs:7:39
|
LL | #[link(name = "bar", kind = "static", import_name_type = "decorated")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -0,0 +1,13 @@
// Tests that failing to run dlltool will raise an error.
// only-gnu
// only-windows
// compile-flags: --crate-type lib --emit link -Cdlltool=does_not_exit.exe
#[link(name = "foo", kind = "raw-dylib")]
extern "C" {
fn f(x: i32);
}
pub fn lib_main() {
unsafe { f(42); }
}

View File

@ -0,0 +1,4 @@
error: Error calling dlltool 'does_not_exit.exe': program not found
error: aborting due to previous error

View File

@ -1,5 +1,3 @@
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link(name="foo")]
extern "C" {
#[link_name="foo"]

View File

@ -1,11 +1,11 @@
error: cannot use `#[link_name]` with `#[link_ordinal]`
--> $DIR/link-ordinal-and-name.rs:6:5
--> $DIR/link-ordinal-and-name.rs:4:5
|
LL | #[link_ordinal(42)]
| ^^^^^^^^^^^^^^^^^^^
error: cannot use `#[link_name]` with `#[link_ordinal]`
--> $DIR/link-ordinal-and-name.rs:10:5
--> $DIR/link-ordinal-and-name.rs:8:5
|
LL | #[link_ordinal(5)]
| ^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,3 @@
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link(name = "foo")]
extern "C" {
#[link_ordinal("JustMonika")]

View File

@ -1,5 +1,5 @@
error: illegal ordinal format in `link_ordinal`
--> $DIR/link-ordinal-invalid-format.rs:5:5
--> $DIR/link-ordinal-invalid-format.rs:3:5
|
LL | #[link_ordinal("JustMonika")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[link_ordinal("JustMonika")]
= note: an unsuffixed integer value, e.g., `1`, is expected
error: illegal ordinal format in `link_ordinal`
--> $DIR/link-ordinal-invalid-format.rs:8:5
--> $DIR/link-ordinal-invalid-format.rs:6:5
|
LL | #[link_ordinal("JustMonika")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,3 @@
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link(name = "foo")]
extern "C" {
#[link_ordinal()]

View File

@ -1,5 +1,5 @@
error: incorrect number of arguments to `#[link_ordinal]`
--> $DIR/link-ordinal-missing-argument.rs:5:5
--> $DIR/link-ordinal-missing-argument.rs:3:5
|
LL | #[link_ordinal()]
| ^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[link_ordinal()]
= note: the attribute requires exactly one argument
error: incorrect number of arguments to `#[link_ordinal]`
--> $DIR/link-ordinal-missing-argument.rs:8:5
--> $DIR/link-ordinal-missing-argument.rs:6:5
|
LL | #[link_ordinal()]
| ^^^^^^^^^^^^^^^^^

View File

@ -1,6 +1,4 @@
// only-windows
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link(name = "foo", kind = "raw-dylib")]
extern "C" {
#[link_ordinal(1)] //~ ERROR multiple `link_ordinal` attributes

View File

@ -1,23 +1,23 @@
error: multiple `link_ordinal` attributes
--> $DIR/link-ordinal-multiple.rs:6:5
--> $DIR/link-ordinal-multiple.rs:4:5
|
LL | #[link_ordinal(1)]
| ^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/link-ordinal-multiple.rs:7:5
--> $DIR/link-ordinal-multiple.rs:5:5
|
LL | #[link_ordinal(2)]
| ^^^^^^^^^^^^^^^^^^
error: multiple `link_ordinal` attributes
--> $DIR/link-ordinal-multiple.rs:9:5
--> $DIR/link-ordinal-multiple.rs:7:5
|
LL | #[link_ordinal(1)]
| ^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/link-ordinal-multiple.rs:10:5
--> $DIR/link-ordinal-multiple.rs:8:5
|
LL | #[link_ordinal(2)]
| ^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,3 @@
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link_ordinal(123)]
//~^ ERROR attribute should be applied to a foreign function or static
struct Foo {}

View File

@ -1,17 +1,17 @@
error: attribute should be applied to a foreign function or static
--> $DIR/link-ordinal-not-foreign-fn.rs:3:1
--> $DIR/link-ordinal-not-foreign-fn.rs:1:1
|
LL | #[link_ordinal(123)]
| ^^^^^^^^^^^^^^^^^^^^
error: attribute should be applied to a foreign function or static
--> $DIR/link-ordinal-not-foreign-fn.rs:7:1
--> $DIR/link-ordinal-not-foreign-fn.rs:5:1
|
LL | #[link_ordinal(123)]
| ^^^^^^^^^^^^^^^^^^^^
error: attribute should be applied to a foreign function or static
--> $DIR/link-ordinal-not-foreign-fn.rs:11:1
--> $DIR/link-ordinal-not-foreign-fn.rs:9:1
|
LL | #[link_ordinal(42)]
| ^^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,3 @@
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link(name = "foo")]
extern "C" {
#[link_ordinal(72436)]

View File

@ -1,5 +1,5 @@
error: ordinal value in `link_ordinal` is too large: `72436`
--> $DIR/link-ordinal-too-large.rs:5:5
--> $DIR/link-ordinal-too-large.rs:3:5
|
LL | #[link_ordinal(72436)]
| ^^^^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[link_ordinal(72436)]
= note: the value may not exceed `u16::MAX`
error: ordinal value in `link_ordinal` is too large: `72436`
--> $DIR/link-ordinal-too-large.rs:8:5
--> $DIR/link-ordinal-too-large.rs:6:5
|
LL | #[link_ordinal(72436)]
| ^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,3 @@
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link(name = "foo")]
extern "C" {
#[link_ordinal(3, 4)]

View File

@ -1,5 +1,5 @@
error: incorrect number of arguments to `#[link_ordinal]`
--> $DIR/link-ordinal-too-many-arguments.rs:5:5
--> $DIR/link-ordinal-too-many-arguments.rs:3:5
|
LL | #[link_ordinal(3, 4)]
| ^^^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[link_ordinal(3, 4)]
= note: the attribute requires exactly one argument
error: incorrect number of arguments to `#[link_ordinal]`
--> $DIR/link-ordinal-too-many-arguments.rs:8:5
--> $DIR/link-ordinal-too-many-arguments.rs:6:5
|
LL | #[link_ordinal(3, 4)]
| ^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,3 @@
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link(name = "foo")]
extern "C" {
#[link_ordinal(3)]

View File

@ -1,11 +1,11 @@
error: `#[link_ordinal]` is only supported if link kind is `raw-dylib`
--> $DIR/link-ordinal-unsupported-link-kind.rs:5:5
--> $DIR/link-ordinal-unsupported-link-kind.rs:3:5
|
LL | #[link_ordinal(3)]
| ^^^^^^^^^^^^^^^^^^
error: `#[link_ordinal]` is only supported if link kind is `raw-dylib`
--> $DIR/link-ordinal-unsupported-link-kind.rs:12:5
--> $DIR/link-ordinal-unsupported-link-kind.rs:10:5
|
LL | #[link_ordinal(3)]
| ^^^^^^^^^^^^^^^^^^

View File

@ -2,7 +2,6 @@
// only-windows
// compile-flags: --crate-type lib --emit link
#![allow(clashing_extern_declarations)]
#![feature(raw_dylib)]
#[link(name = "foo", kind = "raw-dylib")]
extern "C" {
fn f(x: i32);

View File

@ -1,5 +1,5 @@
error: multiple declarations of external function `f` from library `foo.dll` have different calling conventions
--> $DIR/multiple-declarations.rs:14:9
--> $DIR/multiple-declarations.rs:13:9
|
LL | fn f(x: i32);
| ^^^^^^^^^^^^^

View File

@ -1,6 +1,5 @@
// ignore-windows
// compile-flags: --crate-type lib
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
#[link(name = "foo", kind = "raw-dylib")]
//~^ ERROR: link kind `raw-dylib` is only supported on Windows targets
extern "C" {}

View File

@ -1,5 +1,5 @@
error[E0455]: link kind `raw-dylib` is only supported on Windows targets
--> $DIR/raw-dylib-windows-only.rs:4:29
--> $DIR/raw-dylib-windows-only.rs:3:29
|
LL | #[link(name = "foo", kind = "raw-dylib")]
| ^^^^^^^^^^^