Skip to content

Commit

Permalink
Auto merge of #8139 - mati865:patch-1, r=ehuss
Browse files Browse the repository at this point in the history
Add windows-gnu CI and fix tests

One remaining failure:
```
---- features::feature_off_dylib stdout ----
running `d:\a\1\s\target\debug\cargo.exe build --features f1`
running `d:\a\1\s\target\debug\cargo.exe run -p bar`
thread 'features::feature_off_dylib' panicked at '
Expected: execs
    but: exited with exit code: 101
--- stdout

--- stderr
   Compiling foo v0.0.1 (D:\a\1\s\target\cit\t663\foo)
   Compiling bar v0.0.1 (D:\a\1\s\target\cit\t663\foo\bar)
    Finished dev [unoptimized + debuginfo] target(s) in 0.69s
     Running `target\debug\bar.exe`
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"f1"`,
 right: `"no f1"`', bar\src\main.rs:5:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\bar.exe` (exit code: 101)
', crates\cargo-test-support\src\lib.rs:833:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    features::feature_off_dylib
```

I disassembled the dylibs and `cargo run -p bar` correctly rebuilt it inside `target/debug/deps/` but did not copy it to `target/debug`. To further confirm, calling `cp target/debug/deps/foo.dll target/debug/` manually solved the issue.
Any idea?

----

I left `FIXME` in places where import lib should be added with #6875.

`TOOLCHAIN: nightly-x86_64-pc-windows-gnu` can be replaced with beta on Thursday.
  • Loading branch information
bors committed Apr 21, 2020
2 parents 9d84c0c + 2dd0b0d commit 97d39ae
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 8 deletions.
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
x86_64-msvc:
TOOLCHAIN: stable-x86_64-pc-windows-msvc
OTHER_TARGET: i686-pc-windows-msvc
x86_64-gnu:
TOOLCHAIN: nightly-x86_64-pc-windows-gnu
OTHER_TARGET: i686-pc-windows-gnu

- job: rustfmt
pool:
Expand Down
2 changes: 1 addition & 1 deletion ci/azure-install-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ steps:
rustup set profile minimal
rustup component remove --toolchain=$TOOLCHAIN rust-docs || echo "already removed"
rustup update --no-self-update $TOOLCHAIN
if [ "$TOOLCHAIN" = "nightly" ]; then
if [[ "$TOOLCHAIN" == "nightly"* ]]; then
rustup component add --toolchain=$TOOLCHAIN rustc-dev
fi
rustup default $TOOLCHAIN
Expand Down
2 changes: 2 additions & 0 deletions crates/cargo-test-support/src/cross_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ pub fn alternate() -> &'static str {
"i686-unknown-linux-gnu"
} else if cfg!(all(target_os = "windows", target_env = "msvc")) {
"i686-pc-windows-msvc"
} else if cfg!(all(target_os = "windows", target_env = "gnu")) {
"i686-pc-windows-gnu"
} else {
panic!("This test should be gated on cross_compile::disabled.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/context/compilation_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
// we don't want to link it up.
if out_dir.ends_with("deps") {
// Don't lift up library dependencies.
if unit.target.is_bin() || self.roots.contains(unit) {
if unit.target.is_bin() || self.roots.contains(unit) || unit.target.is_dylib() {
Some((
out_dir.parent().unwrap().to_owned(),
if unit.mode.is_any_test() {
Expand Down
13 changes: 11 additions & 2 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3769,7 +3769,11 @@ fn cdylib_not_lifted() {
p.cargo("build").run();

let files = if cfg!(windows) {
vec!["foo.dll.lib", "foo.dll.exp", "foo.dll"]
if cfg!(target_env = "msvc") {
vec!["foo.dll.lib", "foo.dll.exp", "foo.dll"]
} else {
vec!["libfoo.dll.a", "foo.dll"]
}
} else if cfg!(target_os = "macos") {
vec!["libfoo.dylib"]
} else {
Expand Down Expand Up @@ -3803,7 +3807,12 @@ fn cdylib_final_outputs() {
p.cargo("build").run();

let files = if cfg!(windows) {
vec!["foo_bar.dll.lib", "foo_bar.dll"]
if cfg!(target_env = "msvc") {
vec!["foo_bar.dll.lib", "foo_bar.dll"]
} else {
// FIXME https://github.com/rust-lang/cargo/pull/6875
vec!["foo_bar.dll"]
}
} else if cfg!(target_os = "macos") {
vec!["libfoo_bar.dylib"]
} else {
Expand Down
3 changes: 2 additions & 1 deletion tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,8 @@ fn build_script_with_dynamic_native_dependency() {
let src = root.join(&file);
let dst = out_dir.join(&file);
fs::copy(src, dst).unwrap();
if cfg!(windows) {
// FIXME https://github.com/rust-lang/cargo/pull/6875
if cfg!(target_env = "msvc") {
fs::copy(root.join("builder.dll.lib"),
out_dir.join("builder.dll.lib")).unwrap();
}
Expand Down
17 changes: 15 additions & 2 deletions tests/testsuite/out_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn binary_with_debug() {
&["foo"],
&["foo", "foo.dSYM"],
&["foo.exe", "foo.pdb"],
&["foo.exe"],
);
}

Expand Down Expand Up @@ -55,6 +56,7 @@ fn static_library_with_debug() {
&["libfoo.a"],
&["libfoo.a"],
&["foo.lib"],
&["libfoo.a"],
);
}

Expand Down Expand Up @@ -90,6 +92,8 @@ fn dynamic_library_with_debug() {
&["libfoo.so"],
&["libfoo.dylib"],
&["foo.dll", "foo.dll.lib"],
// FIXME https://github.com/rust-lang/cargo/pull/6875
&["foo.dll"],
);
}

Expand Down Expand Up @@ -124,6 +128,7 @@ fn rlib_with_debug() {
&["libfoo.rlib"],
&["libfoo.rlib"],
&["libfoo.rlib"],
&["libfoo.rlib"],
);
}

Expand Down Expand Up @@ -167,6 +172,7 @@ fn include_only_the_binary_from_the_current_package() {
&["foo"],
&["foo", "foo.dSYM"],
&["foo.exe", "foo.pdb"],
&["foo.exe"],
);
}

Expand Down Expand Up @@ -242,6 +248,7 @@ fn avoid_build_scripts() {
&["a", "b"],
&["a", "a.dSYM", "b", "b.dSYM"],
&["a.exe", "a.pdb", "b.exe", "b.pdb"],
&["a.exe", "b.exe"],
);
}

Expand All @@ -266,17 +273,23 @@ fn cargo_build_out_dir() {
&["foo"],
&["foo", "foo.dSYM"],
&["foo.exe", "foo.pdb"],
&["foo.exe"],
);
}

fn check_dir_contents(
out_dir: &Path,
expected_linux: &[&str],
expected_mac: &[&str],
expected_win: &[&str],
expected_win_msvc: &[&str],
expected_win_gnu: &[&str],
) {
let expected = if cfg!(target_os = "windows") {
expected_win
if cfg!(target_env = "msvc") {
expected_win_msvc
} else {
expected_win_gnu
}
} else if cfg!(target_os = "macos") {
expected_mac
} else {
Expand Down
3 changes: 2 additions & 1 deletion tests/testsuite/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ fn plugin_with_dynamic_native_dependency() {
let src = root.join(&file);
let dst = out_dir.join(&file);
fs::copy(src, dst).unwrap();
if cfg!(windows) {
// FIXME https://github.com/rust-lang/cargo/pull/6875
if cfg!(target_env = "msvc") {
fs::copy(root.join("builder.dll.lib"),
out_dir.join("builder.dll.lib")).unwrap();
}
Expand Down
6 changes: 6 additions & 0 deletions tests/testsuite/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ fn setup() -> Option<Setup> {
return None;
}

if cfg!(all(target_os = "windows", target_env = "gnu")) {
// FIXME: contains object files that we don't handle yet:
// https://github.com/rust-lang/wg-cargo-std-aware/issues/46
return None;
}

// Our mock sysroot requires a few packages from crates.io, so make sure
// they're "published" to crates.io. Also edit their code a bit to make sure
// that they have access to our custom crates with custom apis.
Expand Down

0 comments on commit 97d39ae

Please sign in to comment.