Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add windows-gnu CI and fix tests #8139

Merged
merged 4 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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