forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#90782 - ricobbe:binutils-dlltool, r=michael…
…woerister Implement raw-dylib support for windows-gnu Add support for `#[link(kind = "raw-dylib")]` on windows-gnu targets. Work around binutils's linker's inability to read import libraries produced by LLVM by calling out to the binutils `dlltool` utility to create an import library from a temporary .DEF file; this approach is effectively a slightly refined version of `@mati865's` earlier attempt at this strategy in PR rust-lang#88801. (In particular, this attempt at this strategy adds support for `#[link_ordinal(...)]` as well.) In support of rust-lang#58713.
- Loading branch information
Showing
24 changed files
with
252 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extern crate raw_dylib_test; | ||
|
||
fn main() { | ||
raw_dylib_test::library_function(); | ||
} |
2 changes: 2 additions & 0 deletions
2
src/test/run-make/raw-dylib-stdcall-ordinal/expected_output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
exported_function_stdcall(6) | ||
exported_function_fastcall(125) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
LIBRARY exporter | ||
EXPORTS | ||
exported_function_stdcall@4 @15 NONAME | ||
@exported_function_fastcall@4 @18 NONAME |
4 changes: 4 additions & 0 deletions
4
src/test/run-make/raw-dylib-stdcall-ordinal/exporter-msvc.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
LIBRARY exporter | ||
EXPORTS | ||
_exported_function_stdcall@4 @15 NONAME | ||
@exported_function_fastcall@4 @18 NONAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <stdio.h> | ||
|
||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.rs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.