From 0cf7fd1208f79a0f1cbf6341871bf6eaa0319abb Mon Sep 17 00:00:00 2001 From: Richard Cobbe Date: Mon, 1 Nov 2021 15:49:58 -0700 Subject: [PATCH] Call out to binutils' dlltool for raw-dylib on windows-gnu platforms. --- .../rustc_codegen_llvm/src/back/archive.rs | 205 ++++++++++++++---- compiler/rustc_interface/src/tests.rs | 1 + compiler/rustc_metadata/src/native_libs.rs | 5 - compiler/rustc_session/src/options.rs | 2 + src/test/run-make/raw-dylib-c/Makefile | 7 +- .../run-make/raw-dylib-link-ordinal/Makefile | 6 +- .../raw-dylib-stdcall-ordinal/Makefile | 23 ++ .../raw-dylib-stdcall-ordinal/driver.rs | 5 + .../expected_output.txt | 2 + .../exporter-gnu.def | 4 + .../exporter-msvc.def | 4 + .../raw-dylib-stdcall-ordinal/exporter.c | 11 + .../run-make/raw-dylib-stdcall-ordinal/lib.rs | 20 ++ .../feature-gate-raw-dylib-windows-gnu.rs | 8 - .../feature-gate-raw-dylib-windows-gnu.stderr | 18 -- ...dows-msvc.rs => feature-gate-raw-dylib.rs} | 3 +- ...c.stderr => feature-gate-raw-dylib.stderr} | 2 +- .../link-ordinal-multiple.rs | 2 +- .../multiple-declarations.rs | 3 +- .../multiple-declarations.stderr | 4 +- .../rfc-2627-raw-dylib/raw-dylib-msvc-only.rs | 8 - .../raw-dylib-msvc-only.stderr | 17 -- .../ui/rfc-2627-raw-dylib/unsupported-abi.rs | 3 +- .../rfc-2627-raw-dylib/unsupported-abi.stderr | 2 +- 24 files changed, 252 insertions(+), 113 deletions(-) create mode 100644 src/test/run-make/raw-dylib-stdcall-ordinal/Makefile create mode 100644 src/test/run-make/raw-dylib-stdcall-ordinal/driver.rs create mode 100644 src/test/run-make/raw-dylib-stdcall-ordinal/expected_output.txt create mode 100644 src/test/run-make/raw-dylib-stdcall-ordinal/exporter-gnu.def create mode 100644 src/test/run-make/raw-dylib-stdcall-ordinal/exporter-msvc.def create mode 100644 src/test/run-make/raw-dylib-stdcall-ordinal/exporter.c create mode 100644 src/test/run-make/raw-dylib-stdcall-ordinal/lib.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.stderr rename src/test/ui/feature-gates/{feature-gate-raw-dylib-windows-msvc.rs => feature-gate-raw-dylib.rs} (71%) rename src/test/ui/feature-gates/{feature-gate-raw-dylib-windows-msvc.stderr => feature-gate-raw-dylib.stderr} (88%) delete mode 100644 src/test/ui/rfc-2627-raw-dylib/raw-dylib-msvc-only.rs delete mode 100644 src/test/ui/rfc-2627-raw-dylib/raw-dylib-msvc-only.stderr diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index 2fb5a0f9faf82..5703a72c686e5 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -1,6 +1,7 @@ //! A helper class for dealing with static archives -use std::ffi::{CStr, CString}; +use std::env; +use std::ffi::{CStr, CString, OsString}; use std::io; use std::mem; use std::path::{Path, PathBuf}; @@ -158,54 +159,127 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> { output_path.with_extension("lib") }; - // we've checked for \0 characters in the library name already - let dll_name_z = CString::new(lib_name).unwrap(); - // All import names are Rust identifiers and therefore cannot contain \0 characters. - // FIXME: when support for #[link_name] implemented, ensure that import.name values don't - // have any \0 characters - let import_name_and_ordinal_vector: Vec<(CString, Option)> = dll_imports + let mingw_gnu_toolchain = self.config.sess.target.llvm_target.ends_with("pc-windows-gnu"); + + let import_name_and_ordinal_vector: Vec<(String, Option)> = dll_imports .iter() .map(|import: &DllImport| { if self.config.sess.target.arch == "x86" { - (LlvmArchiveBuilder::i686_decorated_name(import), import.ordinal) + ( + LlvmArchiveBuilder::i686_decorated_name(import, mingw_gnu_toolchain), + import.ordinal, + ) } else { - (CString::new(import.name.to_string()).unwrap(), import.ordinal) + (import.name.to_string(), import.ordinal) } }) .collect(); - let output_path_z = rustc_fs_util::path_to_c_string(&output_path); + if mingw_gnu_toolchain { + // The binutils linker used on -windows-gnu targets cannot read the import + // libraries generated by LLVM: in our attempts, the linker produced an .EXE + // that loaded but crashed with an AV upon calling one of the imported + // functions. Therefore, use binutils to create the import library instead, + // by writing a .DEF file to the temp dir and calling binutils's dlltool. + let def_file_path = + tmpdir.as_ref().join(format!("{}_imports", lib_name)).with_extension("def"); + + let def_file_content = format!( + "EXPORTS\n{}", + import_name_and_ordinal_vector + .into_iter() + .map(|(name, ordinal)| { + match ordinal { + Some(n) => format!("{} @{} NONAME", name, n), + None => name, + } + }) + .collect::>() + .join("\n") + ); - tracing::trace!("invoking LLVMRustWriteImportLibrary"); - tracing::trace!(" dll_name {:#?}", dll_name_z); - tracing::trace!(" output_path {}", output_path.display()); - tracing::trace!( - " import names: {}", - dll_imports.iter().map(|import| import.name.to_string()).collect::>().join(", "), - ); + match std::fs::write(&def_file_path, def_file_content) { + Ok(_) => {} + Err(e) => { + self.config.sess.fatal(&format!("Error writing .DEF file: {}", e)); + } + }; - let ffi_exports: Vec = import_name_and_ordinal_vector - .iter() - .map(|(name_z, ordinal)| LLVMRustCOFFShortExport::new(name_z.as_ptr(), *ordinal)) - .collect(); - let result = unsafe { - crate::llvm::LLVMRustWriteImportLibrary( - dll_name_z.as_ptr(), - output_path_z.as_ptr(), - ffi_exports.as_ptr(), - ffi_exports.len(), - llvm_machine_type(&self.config.sess.target.arch) as u16, - !self.config.sess.target.is_like_msvc, - ) - }; + let dlltool = find_binutils_dlltool(self.config.sess); + let result = std::process::Command::new(dlltool) + .args([ + "-d", + def_file_path.to_str().unwrap(), + "-D", + lib_name, + "-l", + output_path.to_str().unwrap(), + ]) + .output(); + + match result { + Err(e) => { + self.config.sess.fatal(&format!("Error calling dlltool: {}", e.to_string())); + } + Ok(output) if !output.status.success() => self.config.sess.fatal(&format!( + "Dlltool could not create import library: {}\n{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + )), + _ => {} + } + } else { + // we've checked for \0 characters in the library name already + let dll_name_z = CString::new(lib_name).unwrap(); + + let output_path_z = rustc_fs_util::path_to_c_string(&output_path); + + tracing::trace!("invoking LLVMRustWriteImportLibrary"); + tracing::trace!(" dll_name {:#?}", dll_name_z); + tracing::trace!(" output_path {}", output_path.display()); + tracing::trace!( + " import names: {}", + dll_imports + .iter() + .map(|import| import.name.to_string()) + .collect::>() + .join(", "), + ); - if result == crate::llvm::LLVMRustResult::Failure { - self.config.sess.fatal(&format!( - "Error creating import library for {}: {}", - lib_name, - llvm::last_error().unwrap_or("unknown LLVM error".to_string()) - )); - } + // All import names are Rust identifiers and therefore cannot contain \0 characters. + // FIXME: when support for #[link_name] is implemented, ensure that the import names + // still don't contain any \0 characters. Also need to check that the names don't + // contain substrings like " @" or "NONAME" that are keywords or otherwise reserved + // in definition files. + let cstring_import_name_and_ordinal_vector: Vec<(CString, Option)> = + import_name_and_ordinal_vector + .into_iter() + .map(|(name, ordinal)| (CString::new(name).unwrap(), ordinal)) + .collect(); + + let ffi_exports: Vec = cstring_import_name_and_ordinal_vector + .iter() + .map(|(name_z, ordinal)| LLVMRustCOFFShortExport::new(name_z.as_ptr(), *ordinal)) + .collect(); + let result = unsafe { + crate::llvm::LLVMRustWriteImportLibrary( + dll_name_z.as_ptr(), + output_path_z.as_ptr(), + ffi_exports.as_ptr(), + ffi_exports.len(), + llvm_machine_type(&self.config.sess.target.arch) as u16, + !self.config.sess.target.is_like_msvc, + ) + }; + + if result == crate::llvm::LLVMRustResult::Failure { + self.config.sess.fatal(&format!( + "Error creating import library for {}: {}", + lib_name, + llvm::last_error().unwrap_or("unknown LLVM error".to_string()) + )); + } + }; self.add_archive(&output_path, |_| false).unwrap_or_else(|e| { self.config.sess.fatal(&format!( @@ -332,22 +406,61 @@ impl<'a> LlvmArchiveBuilder<'a> { } } - fn i686_decorated_name(import: &DllImport) -> CString { + fn i686_decorated_name(import: &DllImport, mingw: bool) -> String { let name = import.name; - // We verified during construction that `name` does not contain any NULL characters, so the - // conversion to CString is guaranteed to succeed. - CString::new(match import.calling_convention { - DllCallingConvention::C => format!("_{}", name), - DllCallingConvention::Stdcall(arg_list_size) => format!("_{}@{}", name, arg_list_size), + let prefix = if mingw { "" } else { "_" }; + + match import.calling_convention { + DllCallingConvention::C => format!("{}{}", prefix, name), + DllCallingConvention::Stdcall(arg_list_size) => { + format!("{}{}@{}", prefix, name, arg_list_size) + } DllCallingConvention::Fastcall(arg_list_size) => format!("@{}@{}", name, arg_list_size), DllCallingConvention::Vectorcall(arg_list_size) => { format!("{}@@{}", name, arg_list_size) } - }) - .unwrap() + } } } fn string_to_io_error(s: String) -> io::Error { io::Error::new(io::ErrorKind::Other, format!("bad archive: {}", s)) } + +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.debugging_opts.dlltool { + return dlltool_path.clone().into_os_string(); + } + + let mut tool_name: OsString = if sess.host.arch != sess.target.arch { + // We are cross-compiling, so we need the tool with the prefix matching our target + if sess.target.arch == "x86" { + "i686-w64-mingw32-dlltool" + } else { + "x86_64-w64-mingw32-dlltool" + } + } else { + // We are not cross-compiling, so we just want `dlltool` + "dlltool" + } + .into(); + + if sess.host.options.is_like_windows { + // If we're compiling on Windows, add the .exe suffix + tool_name.push(".exe"); + } + + // NOTE: it's not clear how useful it is to explicitly search PATH. + for dir in env::split_paths(&env::var_os("PATH").unwrap_or_default()) { + let full_path = dir.join(&tool_name); + if full_path.is_file() { + return full_path.into_os_string(); + } + } + + // The user didn't specify the location of the dlltool binary, and we weren't able + // to find the appropriate one on the PATH. Just return the name of the tool + // and let the invocation fail with a hopefully useful error message. + tool_name +} diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 2d3cb52f5fd47..23946ce3c5c19 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -640,6 +640,7 @@ fn test_debugging_options_tracking_hash() { untracked!(borrowck, String::from("other")); 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_mir, Some(String::from("abc"))); diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 2431b819a3f30..e75478375bb33 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -274,11 +274,6 @@ impl Collector<'tcx> { span, "`#[link(...)]` with `kind = \"raw-dylib\"` only supported on Windows", ); - } else if !self.tcx.sess.target.options.is_like_msvc { - self.tcx.sess.span_warn( - span, - "`#[link(...)]` with `kind = \"raw-dylib\"` not supported on windows-gnu", - ); } if lib_name.as_str().contains('\0') { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index e894e46a30142..e487598f05703 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1073,6 +1073,8 @@ options! { dep_tasks: bool = (false, parse_bool, [UNTRACKED], "print tasks that execute and the color their dep node gets (requires debug build) \ (default: no)"), + dlltool: Option = (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)"), diff --git a/src/test/run-make/raw-dylib-c/Makefile b/src/test/run-make/raw-dylib-c/Makefile index 26ab4d34764d1..166305672e6f2 100644 --- a/src/test/run-make/raw-dylib-c/Makefile +++ b/src/test/run-make/raw-dylib-c/Makefile @@ -1,14 +1,19 @@ # Test the behavior of #[link(.., kind = "raw-dylib")] on windows-msvc -# only-windows-msvc +# only-windows -include ../../run-make-fulldeps/tools.mk all: $(call COMPILE_OBJ,"$(TMPDIR)"/extern_1.obj,extern_1.c) $(call COMPILE_OBJ,"$(TMPDIR)"/extern_2.obj,extern_2.c) +ifdef IS_MSVC $(CC) "$(TMPDIR)"/extern_1.obj -link -dll -out:"$(TMPDIR)"/extern_1.dll $(CC) "$(TMPDIR)"/extern_2.obj -link -dll -out:"$(TMPDIR)"/extern_2.dll +else + $(CC) "$(TMPDIR)"/extern_1.obj -shared -o "$(TMPDIR)"/extern_1.dll + $(CC) "$(TMPDIR)"/extern_2.obj -shared -o "$(TMPDIR)"/extern_2.dll +endif $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs $(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)" "$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt diff --git a/src/test/run-make/raw-dylib-link-ordinal/Makefile b/src/test/run-make/raw-dylib-link-ordinal/Makefile index 04b257d063204..0e84a749b0578 100644 --- a/src/test/run-make/raw-dylib-link-ordinal/Makefile +++ b/src/test/run-make/raw-dylib-link-ordinal/Makefile @@ -1,12 +1,16 @@ # Test the behavior of #[link(.., kind = "raw-dylib")] and #[link_ordinal] on windows-msvc -# only-windows-msvc +# only-windows -include ../../run-make-fulldeps/tools.mk all: $(call COMPILE_OBJ,"$(TMPDIR)"/exporter.obj,exporter.c) +ifdef IS_MSVC $(CC) "$(TMPDIR)"/exporter.obj exporter.def -link -dll -out:"$(TMPDIR)"/exporter.dll +else + $(CC) "$(TMPDIR)"/exporter.obj exporter.def -shared -o "$(TMPDIR)"/exporter.dll +endif $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs $(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)" "$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt diff --git a/src/test/run-make/raw-dylib-stdcall-ordinal/Makefile b/src/test/run-make/raw-dylib-stdcall-ordinal/Makefile new file mode 100644 index 0000000000000..69f62669d6291 --- /dev/null +++ b/src/test/run-make/raw-dylib-stdcall-ordinal/Makefile @@ -0,0 +1,23 @@ +# Test the behavior of #[link(.., kind = "raw-dylib")], #[link_ordinal], and alternative calling conventions on i686 windows. + +# only-x86 +# only-windows + +-include ../../run-make-fulldeps/tools.mk + +all: + $(call COMPILE_OBJ,"$(TMPDIR)"/exporter.obj,exporter.c) +ifdef IS_MSVC + $(CC) "$(TMPDIR)"/exporter.obj exporter-msvc.def -link -dll -out:"$(TMPDIR)"/exporter.dll +else + $(CC) "$(TMPDIR)"/exporter.obj exporter-gnu.def -shared -o "$(TMPDIR)"/exporter.dll +endif + $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs + $(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)" + "$(TMPDIR)"/driver > "$(TMPDIR)"/actual_output.txt + +ifdef RUSTC_BLESS_TEST + cp "$(TMPDIR)"/actual_output.txt expected_output.txt +else + $(DIFF) expected_output.txt "$(TMPDIR)"/actual_output.txt +endif diff --git a/src/test/run-make/raw-dylib-stdcall-ordinal/driver.rs b/src/test/run-make/raw-dylib-stdcall-ordinal/driver.rs new file mode 100644 index 0000000000000..4059ede11fc96 --- /dev/null +++ b/src/test/run-make/raw-dylib-stdcall-ordinal/driver.rs @@ -0,0 +1,5 @@ +extern crate raw_dylib_test; + +fn main() { + raw_dylib_test::library_function(); +} diff --git a/src/test/run-make/raw-dylib-stdcall-ordinal/expected_output.txt b/src/test/run-make/raw-dylib-stdcall-ordinal/expected_output.txt new file mode 100644 index 0000000000000..20157763745f8 --- /dev/null +++ b/src/test/run-make/raw-dylib-stdcall-ordinal/expected_output.txt @@ -0,0 +1,2 @@ +exported_function_stdcall(6) +exported_function_fastcall(125) diff --git a/src/test/run-make/raw-dylib-stdcall-ordinal/exporter-gnu.def b/src/test/run-make/raw-dylib-stdcall-ordinal/exporter-gnu.def new file mode 100644 index 0000000000000..8d28d714b7e64 --- /dev/null +++ b/src/test/run-make/raw-dylib-stdcall-ordinal/exporter-gnu.def @@ -0,0 +1,4 @@ +LIBRARY exporter +EXPORTS + exported_function_stdcall@4 @15 NONAME + @exported_function_fastcall@4 @18 NONAME \ No newline at end of file diff --git a/src/test/run-make/raw-dylib-stdcall-ordinal/exporter-msvc.def b/src/test/run-make/raw-dylib-stdcall-ordinal/exporter-msvc.def new file mode 100644 index 0000000000000..5a4c79a58edfd --- /dev/null +++ b/src/test/run-make/raw-dylib-stdcall-ordinal/exporter-msvc.def @@ -0,0 +1,4 @@ +LIBRARY exporter +EXPORTS + _exported_function_stdcall@4 @15 NONAME + @exported_function_fastcall@4 @18 NONAME \ No newline at end of file diff --git a/src/test/run-make/raw-dylib-stdcall-ordinal/exporter.c b/src/test/run-make/raw-dylib-stdcall-ordinal/exporter.c new file mode 100644 index 0000000000000..1fb45bf010ff2 --- /dev/null +++ b/src/test/run-make/raw-dylib-stdcall-ordinal/exporter.c @@ -0,0 +1,11 @@ +#include + +void __stdcall exported_function_stdcall(int i) { + printf("exported_function_stdcall(%d)\n", i); + fflush(stdout); +} + +void __fastcall exported_function_fastcall(int i) { + printf("exported_function_fastcall(%d)\n", i); + fflush(stdout); +} diff --git a/src/test/run-make/raw-dylib-stdcall-ordinal/lib.rs b/src/test/run-make/raw-dylib-stdcall-ordinal/lib.rs new file mode 100644 index 0000000000000..07dd3d7be9b90 --- /dev/null +++ b/src/test/run-make/raw-dylib-stdcall-ordinal/lib.rs @@ -0,0 +1,20 @@ +#![feature(raw_dylib)] + +#[link(name = "exporter", kind = "raw-dylib")] +extern "stdcall" { + #[link_ordinal(15)] + fn imported_function_stdcall(i: i32); +} + +#[link(name = "exporter", kind = "raw-dylib")] +extern "fastcall" { + #[link_ordinal(18)] + fn imported_function_fastcall(i: i32); +} + +pub fn library_function() { + unsafe { + imported_function_stdcall(6); + imported_function_fastcall(125); + } +} diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.rs b/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.rs deleted file mode 100644 index 33f9c5393135f..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.rs +++ /dev/null @@ -1,8 +0,0 @@ -// gate-test-raw_dylib -// only-windows-gnu -#[link(name = "foo", kind = "raw-dylib")] -//~^ ERROR: kind="raw-dylib" is unstable -//~| WARNING: `#[link(...)]` with `kind = "raw-dylib"` not supported on windows-gnu -extern "C" {} - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.stderr b/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.stderr deleted file mode 100644 index 14dfadf4126f3..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: `#[link(...)]` with `kind = "raw-dylib"` not supported on windows-gnu - --> $DIR/feature-gate-raw-dylib-windows-gnu.rs:3:1 - | -LL | #[link(name = "foo", kind = "raw-dylib")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0658]: kind="raw-dylib" is unstable - --> $DIR/feature-gate-raw-dylib-windows-gnu.rs:3:1 - | -LL | #[link(name = "foo", kind = "raw-dylib")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #58713 for more information - = help: add `#![feature(raw_dylib)]` to the crate attributes to enable - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.rs b/src/test/ui/feature-gates/feature-gate-raw-dylib.rs similarity index 71% rename from src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.rs rename to src/test/ui/feature-gates/feature-gate-raw-dylib.rs index 49de24ea9ab42..995d9ced4801a 100644 --- a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.rs +++ b/src/test/ui/feature-gates/feature-gate-raw-dylib.rs @@ -1,5 +1,4 @@ -// gate-test-raw_dylib -// only-windows-msvc +// only-windows #[link(name = "foo", kind = "raw-dylib")] //~^ ERROR: kind="raw-dylib" is unstable extern "C" {} diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.stderr b/src/test/ui/feature-gates/feature-gate-raw-dylib.stderr similarity index 88% rename from src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.stderr rename to src/test/ui/feature-gates/feature-gate-raw-dylib.stderr index 1198808081213..bb64af38b2cb9 100644 --- a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.stderr +++ b/src/test/ui/feature-gates/feature-gate-raw-dylib.stderr @@ -1,5 +1,5 @@ error[E0658]: kind="raw-dylib" is unstable - --> $DIR/feature-gate-raw-dylib-windows-msvc.rs:3:1 + --> $DIR/feature-gate-raw-dylib.rs:2:1 | LL | #[link(name = "foo", kind = "raw-dylib")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs b/src/test/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs index 9874121267717..45796f077c216 100644 --- a/src/test/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs +++ b/src/test/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs @@ -1,4 +1,4 @@ -// only-windows-msvc +// only-windows #![feature(raw_dylib)] //~^ WARN the feature `raw_dylib` is incomplete diff --git a/src/test/ui/rfc-2627-raw-dylib/multiple-declarations.rs b/src/test/ui/rfc-2627-raw-dylib/multiple-declarations.rs index d02bebc9d61d2..13c9aa01e34ae 100644 --- a/src/test/ui/rfc-2627-raw-dylib/multiple-declarations.rs +++ b/src/test/ui/rfc-2627-raw-dylib/multiple-declarations.rs @@ -1,4 +1,5 @@ -// only-i686-pc-windows-msvc +// only-x86 +// only-windows // compile-flags: --crate-type lib --emit link #![allow(clashing_extern_declarations)] #![feature(raw_dylib)] diff --git a/src/test/ui/rfc-2627-raw-dylib/multiple-declarations.stderr b/src/test/ui/rfc-2627-raw-dylib/multiple-declarations.stderr index a9cfd6b23f9f8..93ca8f4d8d448 100644 --- a/src/test/ui/rfc-2627-raw-dylib/multiple-declarations.stderr +++ b/src/test/ui/rfc-2627-raw-dylib/multiple-declarations.stderr @@ -1,5 +1,5 @@ warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/multiple-declarations.rs:4:12 + --> $DIR/multiple-declarations.rs:5:12 | LL | #![feature(raw_dylib)] | ^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(raw_dylib)] = note: see issue #58713 for more information 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:15:9 | LL | fn f(x: i32); | ^^^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2627-raw-dylib/raw-dylib-msvc-only.rs b/src/test/ui/rfc-2627-raw-dylib/raw-dylib-msvc-only.rs deleted file mode 100644 index e9690f03f45c9..0000000000000 --- a/src/test/ui/rfc-2627-raw-dylib/raw-dylib-msvc-only.rs +++ /dev/null @@ -1,8 +0,0 @@ -// only-windows-gnu -// check-pass -// compile-flags: --crate-type lib -#![feature(raw_dylib)] -//~^ WARNING: the feature `raw_dylib` is incomplete -#[link(name = "foo", kind = "raw-dylib")] -//~^ WARNING: `#[link(...)]` with `kind = "raw-dylib"` not supported on windows-gnu -extern "C" {} diff --git a/src/test/ui/rfc-2627-raw-dylib/raw-dylib-msvc-only.stderr b/src/test/ui/rfc-2627-raw-dylib/raw-dylib-msvc-only.stderr deleted file mode 100644 index 6e24112b3c3e5..0000000000000 --- a/src/test/ui/rfc-2627-raw-dylib/raw-dylib-msvc-only.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/raw-dylib-msvc-only.rs:4:12 - | -LL | #![feature(raw_dylib)] - | ^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #58713 for more information - -warning: `#[link(...)]` with `kind = "raw-dylib"` not supported on windows-gnu - --> $DIR/raw-dylib-msvc-only.rs:6:1 - | -LL | #[link(name = "foo", kind = "raw-dylib")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: 2 warnings emitted - diff --git a/src/test/ui/rfc-2627-raw-dylib/unsupported-abi.rs b/src/test/ui/rfc-2627-raw-dylib/unsupported-abi.rs index e5a5ac2eb2bf1..dc647fd63f527 100644 --- a/src/test/ui/rfc-2627-raw-dylib/unsupported-abi.rs +++ b/src/test/ui/rfc-2627-raw-dylib/unsupported-abi.rs @@ -1,4 +1,5 @@ -// only-x86_64-pc-windows-msvc +// only-x86_64 +// only-windows // compile-flags: --crate-type lib --emit link #![allow(incomplete_features)] #![feature(raw_dylib)] diff --git a/src/test/ui/rfc-2627-raw-dylib/unsupported-abi.stderr b/src/test/ui/rfc-2627-raw-dylib/unsupported-abi.stderr index fc9008128ae43..d8a2a6af9c19e 100644 --- a/src/test/ui/rfc-2627-raw-dylib/unsupported-abi.stderr +++ b/src/test/ui/rfc-2627-raw-dylib/unsupported-abi.stderr @@ -1,5 +1,5 @@ error: ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture - --> $DIR/unsupported-abi.rs:7:5 + --> $DIR/unsupported-abi.rs:8:5 | LL | fn f(x: i32); | ^^^^^^^^^^^^^