Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
78caecf
Special case DUMMY_SP to emit line 0/column 0 locations on DWARF plat…
khuey Aug 4, 2024
e587855
Use Span::is_dummy().
khuey Aug 4, 2024
5dc4a19
Fix warning.
khuey Aug 4, 2024
8a61674
WASI fixing unsafe_op_in_unsafe_fn for std::{os, sys}
g0djan Aug 5, 2024
1687c55
bootstrap: fix clean's `remove_dir_all` implementation
jieyouxu Aug 17, 2024
35752cf
Update `library/Cargo.toml` in weekly job
tgross35 Aug 19, 2024
76fbf0a
Test wholearchive on rust staticlib
ChrisDenton Aug 18, 2024
3c735a0
Add a test.
khuey Aug 20, 2024
4e9725c
Add a comment.
khuey Aug 20, 2024
9d7574f
rustdoc: animate the `:target` highlight
notriddle Aug 19, 2024
40af214
Make import libraries compatible with wholearchive
ChrisDenton Aug 19, 2024
e424e7f
Avoid extra `cast()`s after `CStr::as_ptr()`
cuviper Aug 20, 2024
be44e4d
Rollup merge of #128432 - g0djan:godjan/wasi_prohibit_implicit_unsafe…
tgross35 Aug 21, 2024
7b4bb15
Rollup merge of #128627 - khuey:DUMMY_SP-line-no, r=nnethercote
tgross35 Aug 21, 2024
6e7889d
Rollup merge of #129187 - jieyouxu:squeaky-clean-windows-symlinks, r=…
tgross35 Aug 21, 2024
bf47bb9
Rollup merge of #129257 - ChrisDenton:rename-null-descriptor, r=jieyouxu
tgross35 Aug 21, 2024
fdbe094
Rollup merge of #129264 - tgross35:dependencies-ci-library, r=Kobzol
tgross35 Aug 21, 2024
4785bcc
Rollup merge of #129284 - notriddle:notriddle/animate-target=light, r…
tgross35 Aug 21, 2024
54b3197
Rollup merge of #129332 - cuviper:cstr-cast, r=compiler-errors
tgross35 Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test wholearchive on rust staticlib
  • Loading branch information
ChrisDenton committed Aug 19, 2024
commit 76fbf0af77d98d60bbc7c2598cb6563e9e1ef7e3
1 change: 1 addition & 0 deletions tests/run-make/msvc-wholearchive/c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This page is intentionally left blank
4 changes: 4 additions & 0 deletions tests/run-make/msvc-wholearchive/dll.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LIBRARY dll
EXPORTS
hello
number
52 changes: 52 additions & 0 deletions tests/run-make/msvc-wholearchive/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//! This is a regression test for #129020
//! It ensures we can use `/WHOLEARCHIVE` to link a rust staticlib into DLL
//! using the MSVC linker

//@ only-msvc
// Reason: this is testing the MSVC linker

use std::path::PathBuf;

use run_make_support::{cc, cmd, env_var, extra_c_flags, rustc};

fn main() {
// Build the staticlib
rustc().crate_type("staticlib").input("static.rs").output("static.lib").run();
// Build an empty object to pass to the linker.
cc().input("c.c").output("c.obj").args(["-c"]).run();

// Find the C toolchain's linker.
let mut linker = PathBuf::from(env_var("CC"));
let linker_flavour = if linker.file_stem().is_some_and(|s| s == "cl") {
linker.set_file_name("link.exe");
"msvc"
} else if linker.file_stem().is_some_and(|s| s == "clang-cl") {
linker.set_file_name("lld-link.exe");
"llvm"
} else {
panic!("unknown C toolchain");
};

// As a sanity check, make sure this works without /WHOLEARCHIVE.
// Otherwise the actual test failure may be caused by something else.
cmd(&linker)
.args(["c.obj", "./static.lib", "-dll", "-def:dll.def", "-out:dll.dll"])
.args(extra_c_flags())
.run();

// FIXME(@ChrisDenton): this doesn't currently work with llvm's lld-link for other reasons.
// May need LLVM patches.
if linker_flavour == "msvc" {
// Link in the staticlib using `/WHOLEARCHIVE` and produce a DLL.
cmd(&linker)
.args([
"c.obj",
"-WHOLEARCHIVE:./static.lib",
"-dll",
"-def:dll.def",
"-out:dll_whole_archive.dll",
])
.args(extra_c_flags())
.run();
}
}
9 changes: 9 additions & 0 deletions tests/run-make/msvc-wholearchive/static.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[no_mangle]
pub extern "C" fn hello() {
println!("Hello world!");
}

#[no_mangle]
pub extern "C" fn number() -> u32 {
42
}